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 SaveListenerPolicy(ListenerPolicyViewModel model)
        {
            return(ExecuteFunctionRun(() =>
            {
                ActionResult result = new ActionResult();
                result = ParseParam(model.SchemaCode);
                if (!result.Success)
                {
                    return Json(result, JsonRequestBehavior.AllowGet);
                }
                BizListenerPolicyType policyType = (BizListenerPolicyType)Enum.Parse(typeof(BizListenerPolicyType), model.PolicyType);
                // 检查输入
                if ((policyType == BizListenerPolicyType.Batch || policyType == BizListenerPolicyType.EventDrivenAndBatch) &&
                    string.IsNullOrEmpty(model.Filter))
                {
                    //请输入过滤条件
                    result.Success = false;
                    result.Message = "ListenerPolicy.Msg4";
                    return Json(result, JsonRequestBehavior.AllowGet);
                }

                string conditions = model.Conditions == null ? "" : this.Filter(model.Conditions);
                //result.Extend = conditions;
                //return Json(result, JsonRequestBehavior.AllowGet);
                try
                {
                    if (model.Conditions != null && model.Conditions.Count > 0)
                    {
                        OThinker.Data.Convertor.XmlToObject(typeof(H3.BizBus.Filter.Filter), conditions);
                    }
                }
                catch
                {
                    //输入的过滤器格式错误
                    result.Success = false;
                    result.Message = "ListenerPolicy.Msg5";
                    return Json(result, JsonRequestBehavior.AllowGet);
                }
                // 验证输入是否正确
                int interval = 0;
                if (!int.TryParse(model.IntervalSecond, out interval))
                {
                    //时间间隔必须是正整数
                    result.Success = false;
                    result.Message = "ListenerPolicy.Msg6";
                    return Json(result, JsonRequestBehavior.AllowGet);
                }
                if (interval < H3.DataModel.Declaration.Filter_MinIntervalSecond)
                {
                    //时间间隔设置过于密集,会造成服务器资源消耗太大
                    result.Success = false;
                    result.Message = "ListenerPolicy.Msg7";
                    return Json(result, JsonRequestBehavior.AllowGet);
                }

                BizListenerPolicy ListenerPolicy = new BizListenerPolicy();

                ListenerPolicy.PolicyType = policyType;
                ListenerPolicy.IntervalSecond = int.Parse(model.IntervalSecond);
                ListenerPolicy.FilterMethod = model.FilterMethod;
                if (!string.IsNullOrEmpty(conditions))
                {
                    ListenerPolicy.Filter = (H3.BizBus.Filter.Filter)OThinker.Data.Convertor.XmlToObject(typeof(H3.BizBus.Filter.Filter), conditions);
                }

                if (!this.Engine.BizObjectManager.SetListenerPolicy(this.SchemaCode, ListenerPolicy))
                {
                    result.Success = false;
                    //保存失败(可能原因:1数据模型未发布;2数据模型被删除)
                    result.Message = "ListenerPolicy.Msg8";
                    return Json(result, JsonRequestBehavior.AllowGet);
                }
                else
                {
                    this.Engine.BizObjectManager.UpdateDraftSchema(this.Schema);
                    result.Success = true;
                    result.Message = "";
                    return Json(result, JsonRequestBehavior.AllowGet);
                }
            }));
        }
Example #3
0
        /// <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);
            }));
        }