第八章 启动与执行业务流程(八)
来源:互联网 发布:淘宝教育客户端下载 编辑:程序博客网 时间:2024/06/05 18:38
8.2 启动与执行业务流程
8.2.2 TaskInstance.aspx.cs文件代码:
......(续前页)
//保存附件
bool SaveAttached(string processinstanceid,string relatedtable,
string identityfield,string fieldvalue)
{
SqlParameter pimage;
SqlParameter pimagetype;
//获取文件上传html控件组
HttpFileCollection files = HttpContext.Current.Request.Files;
int imagesize;
string imagetype;
Stream imagestream;
string attachedname;
for(int i=0;i<files.Count;i++)
{
HttpPostedFile ofile = files[i];
imagesize=ofile.ContentLength;
if(imagesize>0)
{
//获取上传文件后缀(扫描图片文件或word转pdf文件)
string fileExt = Path.GetExtension(ofile.FileName).ToLower() ;
if (fileExt != ".jpg" & fileExt != ".jpeg" & fileExt != ".gif"
& fileExt != ".png" & fileExt !=".pdf")
{
Label1.Text = Path.GetFileName(ofile.FileName)
+"不是jpg,jpeg,gif,png,pdf格式的文件,未上传成功.请重新上传该文件!";
return false;
}
attachedname=Request.Form["filename"+(i+1)].Trim();
if(attachedname == "")
{
Label1.Text="附件名称不能为空";
return false;
}
Regex reg=new Regex(@"^[\u4e00-\u9fa5]*\w*$");//汉字或字母下划线
if(! reg.IsMatch(attachedname))
{