private void ReadXmlFile(BizMasterDataImportViewModel model) { //从服务器加载 XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(this.Session[model.XmlSessionName].ToString()); //根节点 XmlElement bizMasterData = xmlDoc.DocumentElement; //数据模型 XmlNodeList bizObjectSchemaNodes = bizMasterData.GetElementsByTagName("BizObjectSchema"); if (bizObjectSchemaNodes != null) { bizObjectSchema = Convertor.XmlToObject(typeof(BizObjectSchema), bizObjectSchemaNodes[0].OuterXml) as BizObjectSchema; } //主数据编码、名称 if (bizObjectSchema != null) { model.MasterDataCode = bizObjectSchema.SchemaCode; model.MasterDataName = bizObjectSchema.DisplayName; } //监听实例 XmlNodeList bizListenerPolicyNodes = bizMasterData.GetElementsByTagName("BizListenerPolicy"); if (bizListenerPolicyNodes != null && bizListenerPolicyNodes.Count > 0) { bizListenerPolicy = Convertor.XmlToObject(typeof(BizListenerPolicy), bizListenerPolicyNodes[0].OuterXml) as BizListenerPolicy; } //定时作业 XmlNodeList scheduleInvokerNodes = bizMasterData.GetElementsByTagName("ScheduleInvokers"); if (scheduleInvokerNodes != null && scheduleInvokerNodes.Count > 0) { scheduleInvokerList = new List <ScheduleInvoker>(); foreach (XmlNode scheduleInvoker in scheduleInvokerNodes[0].ChildNodes) { scheduleInvokerList.Add(Convertor.XmlToObject(typeof(ScheduleInvoker), scheduleInvoker.OuterXml) as ScheduleInvoker); } } //查询列表 XmlNodeList bizQueryNodes = bizMasterData.GetElementsByTagName("BizQueries"); if (bizQueryNodes != null && bizQueryNodes.Count > 0) { bizQueryList = new List <BizQuery>(); foreach (XmlNode query in bizQueryNodes[0].ChildNodes) { bizQueryList.Add(Convertor.XmlToObject(typeof(BizQuery), query.OuterXml) as BizQuery); } } }
/// <summary> /// 读取导入的XML文件 /// </summary> /// <param name="mapPath"></param> private void ReadXmlFile(WorkflowPackageImportViewModel model) { //从服务器加载 XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(Session[model.XMLString].ToString()); XmlElement BizWorkflowPackage = xmlDoc.DocumentElement;//根节点 //流程包编码、名称 PackageCode = BizWorkflowPackage.GetElementsByTagName("PackageCode")[0].InnerXml; PackageName = BizWorkflowPackage.GetElementsByTagName("PackageName")[0].InnerXml; //流程包 XmlNodeList packageNodes = BizWorkflowPackage.GetElementsByTagName("FunctionNode"); if (packageNodes != null && packageNodes.Count > 0) { XmlNode openNewWindow = packageNodes[0].SelectSingleNode("OpenNewWindow"); if (openNewWindow != null) { openNewWindow.InnerText = openNewWindow.InnerText.ToLower(); } package = Convertor.XmlToObject(typeof(FunctionNode), packageNodes[0].OuterXml) as FunctionNode; package.ParentCode = model.ParentCode; } //数据模型 XmlNodeList bizObjectSchemaNodes = BizWorkflowPackage.GetElementsByTagName("BizObjectSchema"); if (bizObjectSchemaNodes != null && bizObjectSchemaNodes.Count > 0) { BizObjectSchema = (DataModel.BizObjectSchema)Convertor.XmlToObject(typeof(DataModel.BizObjectSchema), bizObjectSchemaNodes[0].OuterXml); //监听实例 XmlNodeList bizListenerPolicyNodes = BizWorkflowPackage.GetElementsByTagName("BizListenerPolicy"); if (bizListenerPolicyNodes != null && bizListenerPolicyNodes.Count > 0) { bizListenerPolicy = Convertor.XmlToObject(typeof(BizListenerPolicy), bizListenerPolicyNodes[0].OuterXml) as BizListenerPolicy; } //定时作业 XmlNodeList scheduleInvokerNodes = BizWorkflowPackage.GetElementsByTagName("ScheduleInvokers"); if (scheduleInvokerNodes != null && scheduleInvokerNodes.Count > 0) { scheduleInvokerList = new List <ScheduleInvoker>(); foreach (XmlNode scheduleInvoker in scheduleInvokerNodes[0].ChildNodes) { scheduleInvokerList.Add(Convertor.XmlToObject(typeof(ScheduleInvoker), scheduleInvoker.OuterXml) as ScheduleInvoker); } } //查询列表 XmlNodeList bizQueryNodes = BizWorkflowPackage.GetElementsByTagName("BizQueries"); if (bizQueryNodes != null && bizQueryNodes.Count > 0) { bizQueryList = new List <BizQuery>(); foreach (XmlNode query in bizQueryNodes[0].ChildNodes) { bizQueryList.Add(Convertor.XmlToObject(typeof(BizQuery), query.OuterXml) as BizQuery); } } } //流程表单 XmlNode SheetRoot = BizWorkflowPackage.GetElementsByTagName("BizSheets")[0]; XmlNodeList Sheets = ((XmlElement)SheetRoot).GetElementsByTagName("BizSheet"); BizSheets = new List <BizSheet>(); foreach (XmlNode node in Sheets) { BizSheet sheet = (BizSheet)Convertor.XmlToObject(typeof(BizSheet), node.OuterXml); if (sheet.SheetType == SheetType.DefaultSheet) {//清空默认表单 sheet.SheetAddress = string.Empty; } var BizSheetModel = (BizSheet)Convertor.XmlToObject(typeof(BizSheet), node.OuterXml); //处理旧版本的默认表单的发起时间绑定字段是OriginateDate 而新版本的是OriginateTime 做兼容处理 if (BizSheetModel.DesignModeContent != null) { BizSheetModel.DesignModeContent = BizSheetModel.DesignModeContent.Replace(@"OriginateDate", "OriginateTime"); } if (BizSheetModel.RuntimeContent != null) { BizSheetModel.RuntimeContent = BizSheetModel.RuntimeContent.Replace(@"OriginateDate", "OriginateTime"); } BizSheets.Add(BizSheetModel); } //流程模板 XmlNode TemplateRoot = BizWorkflowPackage.GetElementsByTagName("WorkflowTemplates")[0]; XmlNodeList Templates = ((XmlElement)TemplateRoot).GetElementsByTagName("WorkflowTemplate"); if (Templates.Count > 0) { WorkflowTemplates = new List <DraftWorkflowTemplate>(); foreach (XmlNode node in Templates) { DraftWorkflowTemplate draftWorkflowTemplate = new DraftWorkflowTemplate(((XmlElement)node).GetElementsByTagName("WorkflowDocument")[0].OuterXml); WorkflowNames.Add(draftWorkflowTemplate.WorkflowCode, ((XmlElement)node).GetElementsByTagName("WorkflowTemplateName")[0].InnerXml); WorkflowTemplates.Add(draftWorkflowTemplate); } //流程模拟 XmlNode SimulationRoot = BizWorkflowPackage.GetElementsByTagName("Simulations")[0]; XmlNodeList SimulationNodes = ((XmlElement)SimulationRoot).GetElementsByTagName("InstanceSimulation"); this.Simulations = new List <InstanceSimulation>(); foreach (XmlNode simulation in SimulationNodes) { this.Simulations.Add((InstanceSimulation)Convertor.XmlToObject(typeof(InstanceSimulation), simulation.OuterXml)); } XmlNodeList clauseNodes = BizWorkflowPackage.GetElementsByTagName("WorkflowClause"); if (clauseNodes != null && clauseNodes.Count > 0) { foreach (XmlNode clauseNode in clauseNodes) { this.clauses.Add((WorkflowClause)Convertor.XmlToObject(typeof(WorkflowClause), clauseNode.OuterXml)); } } } }