public void ExportBizMasterData(string bizMasterDataCode) { ExecuteFunctionRun(() => { Acl.FunctionNode masterDataNode = this.Engine.FunctionAclManager.GetFunctionNodeByCode(bizMasterDataCode); //主数据根节点 XmlElement bizMasterData = XmlDoc.CreateElement(FunctionNodeType.BizObject.ToString()); //数据模型 BizObjectSchema Schema = this.Engine.BizObjectManager.GetDraftSchema(bizMasterDataCode); if (Schema != null) { bizMasterData.InnerXml += Convertor.ObjectToXml(Schema); } //监听实例 BizListenerPolicy policy = this.Engine.BizObjectManager.GetListenerPolicy(bizMasterDataCode); if (policy != null) { bizMasterData.InnerXml += Convertor.ObjectToXml(policy); } //定时作业 ScheduleInvoker[] scheduleInvokers = this.Engine.BizObjectManager.GetScheduleInvokerList(bizMasterDataCode); if (scheduleInvokers != null && scheduleInvokers.Length > 0) { XmlElement invokers = XmlDoc.CreateElement("ScheduleInvokers"); foreach (ScheduleInvoker item in scheduleInvokers) { invokers.InnerXml += Convertor.ObjectToXml(item); } bizMasterData.AppendChild(invokers); } //查询列表 BizQuery[] queries = this.Engine.BizObjectManager.GetBizQueries(bizMasterDataCode); if (queries != null && queries.Length > 0) { XmlElement bizQueries = XmlDoc.CreateElement("BizQueries"); foreach (BizQuery query in queries) { bizQueries.InnerXml += Convertor.ObjectToXml(query); } bizMasterData.AppendChild(bizQueries); } XmlDoc.AppendChild(bizMasterData); //导出文件 string path = Server.MapPath("~/TempImages/"); string fileName = bizMasterDataCode + ".xml"; XmlDoc.Save(path + fileName); this.Response.Clear(); this.Response.ContentType = "text/xml"; this.Response.AppendHeader("Content-Disposition", "attachment;filename=\"" + fileName + "\""); this.Response.TransmitFile(path + fileName); this.Response.End(); System.IO.File.Delete(path + fileName); return(null); }); }
public JsonResult SaveMasterPackage(MasterPackageViewModel model) { return(ExecuteFunctionRun(() => { ActionResult result = new ActionResult(); if (string.IsNullOrWhiteSpace(model.Code)) { result.Success = false; result.Message = "EditBizObjectSchema.CodeNotNull"; return Json(result, JsonRequestBehavior.AllowGet); //this.ShowErrorMessage(this.PortalResource.GetString("BizOperation_CodeNotNull")); } H3.DataModel.BizObjectSchema schema = null; if (model.IsImport) { if (!string.IsNullOrEmpty(model.BizService)) { schema = this.FromDbTableAdapter(model.Code, model.BizService); schema.DisplayName = model.DisplayName ?? schema.SchemaCode; } } else { ////手工新建 //if (string.IsNullOrWhiteSpace(model.DisplayName)) //{ // result.Success = false; // result.Message = "EditBizObjectSchema.DisplayNameNotNull"; // return Json(result, JsonRequestBehavior.AllowGet); //} StorageType storageType = (StorageType)int.Parse(model.StorageType); schema = new DataModel.BizObjectSchema(storageType, model.Code.Trim(), storageType != StorageType.PureServiceBased); schema.DisplayName = model.DisplayName ?? schema.SchemaCode; } if (schema == null) { result.Success = false; result.Message = "msgGlobalString.CreateFailed"; return Json(result, JsonRequestBehavior.AllowGet); } //添加校验 if (schema.SchemaCode.Length > BizObjectSchema.MaxCodeLength) { result.Success = false; result.Message = "EditBizObjectSchema.Msg1"; result.Extend = BizObjectSchema.MaxCodeLength; return Json(result, JsonRequestBehavior.AllowGet); //this.ShowWarningMessage(this.PortalResource.GetString("BizObjectSchema_Mssg1") + BizObjectSchema.MaxCodeLength); } //校验编码规范 System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(BizObjectSchema.CodeRegex); if (!regex.IsMatch(schema.SchemaCode)) { result.Success = false; result.Message = "EditBizObjectSchemaProperty.Msg2"; return Json(result, JsonRequestBehavior.AllowGet); //this.ShowWarningMessage(this.PortalResource.GetString("BizObjectSchema_Mssg2")); } if (!this.Engine.BizObjectManager.AddDraftSchema(schema)) { //保存失败,可能是由于编码重复 result.Success = false; result.Message = "EditBizObjectSchema.Msg3"; return Json(result, JsonRequestBehavior.AllowGet); } else { // 添加成功,这里还是需要写入FuntionNode节点的,为了跟流程包里的数据模型节点区别 Acl.FunctionNode node = new Acl.FunctionNode (schema.SchemaCode, schema.DisplayName, "", "", FunctionNodeType.BizObject, model.ParentCode, 0 ); this.Engine.FunctionAclManager.AddFunctionNode(node); } result.Success = true; result.Message = "msgGlobalString.SaveSuccess"; result.Extend = model.ParentId; return Json(result, JsonRequestBehavior.AllowGet); })); }
/// <summary> /// 导出流程包 /// </summary> /// <param name="PackageCode"></param> /// <returns></returns> public object Export(string PackageCode) { return(ExecuteFileResultFunctionRun(() => { Acl.FunctionNode PackageNode = this.Engine.FunctionAclManager.GetFunctionNodeByCode(PackageCode); //流程包 XmlElement BizWorkflowPackage = XmlDoc.CreateElement(FunctionNodeType.BizWorkflowPackage.ToString()); BizWorkflowPackage.AppendChild(CreateXmlElement("PackageCode", PackageNode.Code)); BizWorkflowPackage.AppendChild(CreateXmlElement("PackageName", PackageNode.DisplayName)); XmlDoc.AppendChild(BizWorkflowPackage); BizWorkflowPackage.InnerXml += Convertor.ObjectToXml(PackageNode); //数据模型 BizObjectSchema Schema = this.Engine.BizObjectManager.GetDraftSchema(PackageCode); if (Schema != null) { BizWorkflowPackage.InnerXml += Convertor.ObjectToXml(Schema); //监听实例 BizListenerPolicy policy = this.Engine.BizObjectManager.GetListenerPolicy(Schema.SchemaCode); if (policy != null) { BizWorkflowPackage.InnerXml += Convertor.ObjectToXml(policy); } //定时作业 ScheduleInvoker[] scheduleInvokers = this.Engine.BizObjectManager.GetScheduleInvokerList(Schema.SchemaCode); if (scheduleInvokers != null && scheduleInvokers.Length > 0) { XmlElement invokers = XmlDoc.CreateElement("ScheduleInvokers"); foreach (ScheduleInvoker item in scheduleInvokers) { invokers.InnerXml += Convertor.ObjectToXml(item); } BizWorkflowPackage.AppendChild(invokers); } //查询列表 BizQuery[] queries = this.Engine.BizObjectManager.GetBizQueries(Schema.SchemaCode); if (queries != null && queries.Length > 0) { XmlElement bizQueries = XmlDoc.CreateElement("BizQueries"); foreach (BizQuery query in queries) { bizQueries.InnerXml += Convertor.ObjectToXml(query); } BizWorkflowPackage.AppendChild(bizQueries); } } //表单 BizSheet[] Sheets = this.Engine.BizSheetManager.GetBizSheetBySchemaCode(PackageCode); XmlElement workflowSheets = XmlDoc.CreateElement("BizSheets"); if (Sheets != null) { foreach (BizSheet s in Sheets) { workflowSheets.InnerXml += Convertor.ObjectToXml(s); } } BizWorkflowPackage.AppendChild(workflowSheets); //流程 WorkflowTemplate.WorkflowClause[] WorkflowClauses = this.Engine.WorkflowManager.GetClausesBySchemaCode(PackageCode); XmlElement workflowTemps = XmlDoc.CreateElement("WorkflowTemplates"); if (WorkflowClauses != null) { foreach (WorkflowTemplate.WorkflowClause WorkflowClause in WorkflowClauses) { WorkflowTemplate.DraftWorkflowTemplate workflowTemplate = this.Engine.WorkflowManager.GetDraftTemplate(WorkflowClause.WorkflowCode); //发布后才能导出 if (workflowTemplate == null) { continue; } XmlElement workflowTempElement = XmlDoc.CreateElement("WorkflowTemplate"); //流程名称 workflowTempElement.AppendChild(this.CreateXmlElement("WorkflowTemplateName", WorkflowClause.WorkflowName)); //流程图 XmlElement workflowDocument = XmlDoc.CreateElement("WorkflowDocument"); workflowTemplate.SaveAsXml(XmlDoc, workflowDocument); workflowTempElement.AppendChild(workflowDocument); //流程模拟 XmlElement simulationElement = XmlDoc.CreateElement("Simulations"); InstanceSimulation[] simulations = this.Engine.SimulationManager.GetSimulationByWorkflow(workflowTemplate.WorkflowCode); if (simulations != null && simulations.Length > 0) { foreach (InstanceSimulation simulation in simulations) { simulationElement.InnerXml += Convertor.ObjectToXml(simulation); } } workflowTempElement.AppendChild(simulationElement); //流程模板簇 workflowTempElement.InnerXml += Convertor.ObjectToXml(WorkflowClause); //添加流程模板 workflowTemps.AppendChild(workflowTempElement); } } BizWorkflowPackage.AppendChild(workflowTemps); //导出文件 string path = Server.MapPath("~/TempImages/"); string fileName = PackageCode + ".xml"; XmlDoc.Save(path + fileName); return File(path + fileName, "application/octect-stream", fileName); })); }