public virtual void DoModifyFileOperations(string rootPath, MaterialFileOeprationInfo fileOperation, MaterialContent content) { var task = new InvokeServiceTask() { TaskID = UuidHelper.NewUuidString(), TaskTitle = string.Format(this.taskTitleTemplate, fileOperation.Material.OriginalName, fileOperation.Material.ID), }; var parameters = new WfServiceOperationParameterCollection { new WfServiceOperationParameter("rootPath", rootPath), new WfServiceOperationParameter("fileOperation", fileOperation.Operation.ToString()), new WfServiceOperationParameter("materialConnectionName", DbConnectionMappingContext.GetMappedConnectionName(MaterialAdapter.Instance.GetConnectionName())), new WfServiceOperationParameter("contentConnectionName", DbConnectionMappingContext.GetMappedConnectionName(MaterialContentAdapter.Instance.ConnectionName)), new WfServiceOperationParameter("materialId", fileOperation.Material.ID), new WfServiceOperationParameter("url", fileOperation.Material.ShowFileUrl) }; task.SvcOperationDefs.Add(new WfServiceOperationDefinition( new WfServiceAddressDefinition(WfServiceRequestMethod.Post, null, ResourceUriSettings.GetConfig().Paths[this.resourceUri].Uri.ToString()), "DoFileToDocService", parameters, "ReturnValue") ); DbConnectionMappingContext.DoMappingAction( DbConnectionMappingContext.GetMappedConnectionName(InvokeServiceTaskAdapter.Instance.ConnectionName), InvokeServiceTaskAdapter.Instance.ConnectionName, () => { InvokeServiceTaskAdapter.Instance.Update(task); }); }
public void DoModifyFileOperations(string rootPathName, MaterialFileOeprationInfo fileOp, MaterialContent content) { string uploadRootPath = AppPathConfigSettings.GetConfig().Paths[rootPathName].Dir; ExceptionHelper.CheckStringIsNullOrEmpty(uploadRootPath, "uploadRootPath"); IMaterialContentPersistManager persistManager = GetMaterialContentPersistManager(rootPathName, fileOp); if (content == null) { content = fileOp.Material.GenerateMaterialContent(); } switch (fileOp.Operation) { case FileOperation.Add: case FileOperation.Update: persistManager.SaveMaterialContent(content); break; case FileOperation.Delete: persistManager.DeleteMaterialContent(content); break; default: break; } }
private static IMaterialContentPersistManager GetMaterialContentPersistManager(string rootPathName, MaterialFileOeprationInfo fileOp) { string uploadRootPath = AppPathConfigSettings.GetConfig().Paths[rootPathName].Dir; FileInfo sourceFile = new FileInfo(uploadRootPath + @"Temp\" + Path.GetFileName(fileOp.Material.RelativeFilePath)); FileInfo destFile = new FileInfo(uploadRootPath + fileOp.Material.RelativeFilePath); IMaterialContentPersistManager persistManager = MaterialContentSettings.GetConfig().PersistManager; persistManager.SourceFileInfo = sourceFile; persistManager.DestFileInfo = destFile; if (fileOp.Operation == FileOperation.Update) persistManager.CheckSourceFileExists = false; return persistManager; }
public void InsertWithContent(MaterialList materials) { materials.NullCheck("materials"); StringBuilder strB = new StringBuilder(); ORMappingItemCollection mappings = ORMapping.GetMappingInfo(typeof(Material)); foreach (Material m in materials) { if (strB.Length > 0) { strB.Append(TSqlBuilder.Instance.DBStatementSeperator); } InsertSqlClauseBuilder builder = ORMapping.GetInsertSqlClauseBuilder(m, mappings, "CreateDateTime"); builder.AppendItem("CREATE_DATETIME", m.CreateDateTime); strB.AppendFormat("INSERT INTO {0}{1}", mappings.TableName, builder.ToSqlString(TSqlBuilder.Instance)); } if (strB.Length > 0) { using (TransactionScope scope = TransactionScopeFactory.Create()) { DbHelper.RunSql(strB.ToString(), GetConnectionName()); foreach (Material m in materials) { m.Content.RelativeID = m.ResourceID; MaterialFileOeprationInfo fileOp = new MaterialFileOeprationInfo(m, FileOperation.Update); DoFileOperation(MaterialAdapter.DefaultUploadPathName, fileOp, m.Content); } scope.Complete(); } } }
public void DoModifyFileOperations(string rootPathName, MaterialFileOeprationInfo fileOp, MaterialContent content) { string uploadRootPath = AppPathConfigSettings.GetConfig().Paths[rootPathName].Dir; ExceptionHelper.CheckStringIsNullOrEmpty(uploadRootPath, "uploadRootPath"); IMaterialContentPersistManager persistManager = GetMaterialContentPersistManager(rootPathName, fileOp); if (content == null) content = fileOp.Material.GenerateMaterialContent(); switch (fileOp.Operation) { case FileOperation.Add: case FileOperation.Update: persistManager.SaveMaterialContent(content); break; case FileOperation.Delete: persistManager.DeleteMaterialContent(content); break; default: break; } }
public void InsertWithContent(MaterialList materials) { materials.NullCheck("materials"); StringBuilder strB = new StringBuilder(); ORMappingItemCollection mappings = ORMapping.GetMappingInfo(typeof(Material)); foreach (Material m in materials) { if (strB.Length > 0) strB.Append(TSqlBuilder.Instance.DBStatementSeperator); InsertSqlClauseBuilder builder = ORMapping.GetInsertSqlClauseBuilder(m, mappings, "CreateDateTime"); builder.AppendItem("CREATE_DATETIME", m.CreateDateTime); strB.AppendFormat("INSERT INTO {0}{1}", mappings.TableName, builder.ToSqlString(TSqlBuilder.Instance)); } if (strB.Length > 0) { using (TransactionScope scope = TransactionScopeFactory.Create()) { DbHelper.RunSql(strB.ToString(), GetConnectionName()); foreach (Material m in materials) { m.Content.RelativeID = m.ResourceID; MaterialFileOeprationInfo fileOp = new MaterialFileOeprationInfo(m, FileOperation.Update); DoFileOperation(MaterialAdapter.DefaultUploadPathName, fileOp, m.Content); } scope.Complete(); } } }
private void DoFileOperation(string rootPathName, MaterialFileOeprationInfo fileOp, MaterialContent content) { MaterialFileOperationSettings.GetConfig().Operations.ForEach(op => op.DoModifyFileOperations(rootPathName, fileOp, content)); }
private static IMaterialContentPersistManager GetMaterialContentPersistManager(string rootPathName, MaterialFileOeprationInfo fileOp) { string uploadRootPath = AppPathConfigSettings.GetConfig().Paths[rootPathName].Dir; FileInfo sourceFile = new FileInfo(uploadRootPath + @"Temp\" + Path.GetFileName(fileOp.Material.RelativeFilePath)); FileInfo destFile = new FileInfo(uploadRootPath + fileOp.Material.RelativeFilePath); IMaterialContentPersistManager persistManager = MaterialContentSettings.GetConfig().PersistManager; persistManager.SourceFileInfo = sourceFile; persistManager.DestFileInfo = destFile; if (fileOp.Operation == FileOperation.Update) { persistManager.CheckSourceFileExists = false; } return(persistManager); }