public ResultOperation IsValid(FileUploadHtml fileUploadHtml, sysBpmsVariable variable, Guid?entityId, Guid?entitydefid, string currentUserName) { ResultOperation resultOperation = new ResultOperation(); if (variable != null && !entityId.HasValue) { sysBpmsEntityDef entityDef = new EntityDefService(base.UnitOfWork).GetInfo(variable.EntityDefID.Value); entitydefid = variable.EntityDefID.Value; entityId = new EntityDefEngine(base.EngineSharedModel, base.UnitOfWork).GetEntityID(entityDef, variable, base.EngineSharedModel.BaseQueryModel); } Dictionary <Guid, HttpPostedFileBase> files = fileUploadHtml.Value == null ? new Dictionary <Guid, HttpPostedFileBase>() : (((Dictionary <Guid, object>)fileUploadHtml.Value).ToDictionary(c => c.Key.ToGuidObj(), c => c.Value == null ? null : c.Value is HttpPostedFileBase ? (HttpPostedFileBase)c.Value : new HttpPostedFileWrapper((HttpPostedFile)c.Value))); if (files.Any()) { foreach (var item in files) { ResultOperation result = this.IsValid(entitydefid, entityId, item.Value?.InputStream, item.Value?.FileName, item.Key); if (!result.IsSuccess) { resultOperation.AddError(result.GetErrors()); } } } else { resultOperation = this.IsValid(entitydefid, entityId, null, null, fileUploadHtml.DocumentdefId.ToGuidObjNull().Value); } return(resultOperation); }
public ResultOperation SaveFile(FileUploadHtml fileUploadHtml, sysBpmsVariable variable, Guid?entityId, Guid?entitydefid, string captionOf, string currentUserName) { ResultOperation resultOperation = new ResultOperation(); if (variable != null && !entityId.HasValue) { sysBpmsEntityDef entityDef = new EntityDefService(base.UnitOfWork).GetInfo(variable.EntityDefID.Value); entitydefid = variable.EntityDefID.Value; entityId = new EntityDefEngine(base.EngineSharedModel, base.UnitOfWork).GetEntityID(entityDef, variable, base.EngineSharedModel.BaseQueryModel); } Dictionary <Guid, HttpPostedFileBase> files = fileUploadHtml.Value == null ? new Dictionary <Guid, HttpPostedFileBase>() : (((Dictionary <Guid, object>)fileUploadHtml.Value).ToDictionary(c => c.Key.ToGuidObj(), c => c.Value == null ? null : c.Value is HttpPostedFileBase ? (HttpPostedFileBase)c.Value : new HttpPostedFileWrapper((HttpPostedFile)c.Value))); foreach (var item in files) { if (resultOperation.IsSuccess) { resultOperation = this.SaveFile(item.Value?.InputStream, item.Value?.FileName, entityId, entitydefid, item.Key, captionOf, !fileUploadHtml.Multiple); } } return(resultOperation); }