public JsonResult SaveWorkflowPackage(WorkflowPackageViewModel model) { return(ExecuteFunctionRun(() => { ActionResult result = new ActionResult(false); if (this.WorkflowLimit != 0) { int workflowCount = this.Engine.Query.Count(OThinker.H3.WorkflowTemplate.WorkflowClause.TableName, new string[] { OThinker.H3.WorkflowTemplate.WorkflowClause.PropertyName_State + "=" + (int)OThinker.H3.WorkflowTemplate.WorkflowState.Active }); if (workflowCount >= this.WorkflowLimit) { result.Success = false; result.Message = "WorkflowPackage.OverLimit"; return Json(result, JsonRequestBehavior.AllowGet); } } FunctionNodeType nodeType = string.IsNullOrWhiteSpace(model.ObjectType) ? FunctionNodeType.BizWorkflowPackage : (FunctionNodeType)Enum.Parse(typeof(FunctionNodeType), model.ObjectType); if (!Validator(nodeType, model, out result)) { return Json(result, JsonRequestBehavior.AllowGet); } if (nodeType == FunctionNodeType.BizWorkflowPackage) //流程包 { result = SavePackage(model); return Json(result, JsonRequestBehavior.AllowGet); } else //流程 { string code = model.Code.Trim(); if (this.Engine.WorkflowManager.GetDraftTemplate(code) != null) { result.Success = false; result.Message = "WorkflowPackage.Msg8"; return Json(result, JsonRequestBehavior.AllowGet); } int sortKey; Int32.TryParse(model.SortKey, out sortKey); OThinker.H3.DataModel.BizObjectSchema schema = this.Engine.BizObjectManager.GetDraftSchema(model.Folder); WorkflowTemplate.WorkflowClause wClause = new WorkflowTemplate.WorkflowClause(model.Folder, code, model.DisplayName, sortKey); wClause.IsShared = schema.IsShared; if (schema.IsQuotePacket) { //使用共享包的,用共享包的模型创建 wClause = new WorkflowTemplate.WorkflowClause(schema.BindPacket, code, model.DisplayName, sortKey); //加自己的标识 wClause.OwnSchemaCode = schema.SchemaCode; } result.Success = this.Engine.WorkflowManager.AddClause(wClause); result.Extend = model.ParentId; } return Json(result, JsonRequestBehavior.AllowGet); })); }
public JsonResult Load(string WorkflowCode) { return(ExecuteFunctionRun(() => { WorkflowClauseViewModel model = new WorkflowClauseViewModel(); WorkflowTemplate.WorkflowClause SelectedClause = this.Engine.WorkflowManager.GetClause(WorkflowCode); var WorkflowVersions = LoadVersion(WorkflowCode); // 流水号的重置策略 var SeqnoResetTypes = LoadSeqNoResetTypes(); //工作日历 var WorkCalendar = LoadWorkCalendar(); int defaultVersion = this.Engine.WorkflowManager.GetWorkflowDefaultVersion(WorkflowCode); model.WorkflowCode = WorkflowCode; model.WorkflowVersion = defaultVersion.ToString(); model.IsControlUsable = BizWorkflowPackageLockByID(WorkflowCode); model.SeqNoResetType = Instance.SequenceNoResetType.None.ToString(); //默认值 var returnValue = new{ IsControlUsable = true, //是否可编辑 WorkflowVersions = WorkflowVersions, //流程版本 SeqNoResetTypes = SeqnoResetTypes, //流水号重置策略 CalendarList = WorkCalendar, //工作日历 WorkflowClause = model //运行参数 }; //还没保存过运行参数 if (SelectedClause == null) { return Json(returnValue, JsonRequestBehavior.AllowGet); } //code、名称、排序 都读取节点信息,同步保存到策略上 model.SequenceCode = SelectedClause.SequenceCode ?? ""; model.DisplayName = SelectedClause.WorkflowName; model.SortKey = SelectedClause.SortKey; // 工作日历 model.WorkCalendar = SelectedClause.CalendarId; // 异常管理员 model.ExceptionManager = SelectedClause.ExceptionManager; //流程号重置方式 Instance.SequenceNoResetType sequenceNoResetType = SelectedClause.SeqNoResetType; model.SeqNoResetType = sequenceNoResetType.ToString(); // 获得选中的工作流模板的状态 WorkflowTemplate.WorkflowState state = SelectedClause.State; model.IsActive = state == OThinker.H3.WorkflowTemplate.WorkflowState.Active; // 流程模板的移动办公设置 model.MobileStart = SelectedClause.MobileStart; // 加载图标 model.ImageUrl = string.IsNullOrEmpty(SelectedClause.IconFileName) ? this.DefautIconImagePath : (this.PortalRoot + "/" + this.WorkflowIconDirectory + "/" + SelectedClause.IconFileName); return Json(returnValue, JsonRequestBehavior.AllowGet); })); }
public JsonResult Save(WorkflowClauseViewModel model) { return(ExecuteFunctionRun(() => { ActionResult result = new ActionResult(false, ""); System.Web.HttpFileCollectionBase files = HttpContext.Request.Files; WorkflowTemplate.WorkflowClause SelectedClause = this.Engine.WorkflowManager.GetClause(model.WorkflowCode); // 检查输入 int sortKey = model.SortKey; // 更新模板 SelectedClause.WorkflowName = model.DisplayName; SelectedClause.SortKey = sortKey; // 移动办公设置 SelectedClause.MobileStart = model.MobileStart; // 流水号编码 SelectedClause.SequenceCode = model.SequenceCode ?? ""; // 流水号重置方式 SelectedClause.SeqNoResetType = (Instance.SequenceNoResetType)Enum.Parse(typeof(Instance.SequenceNoResetType), model.SeqNoResetType); SelectedClause.State = model.IsActive ? WorkflowTemplate.WorkflowState.Active : OThinker.H3.WorkflowTemplate.WorkflowState.Inactive; SelectedClause.CalendarId = model.WorkCalendar; //异常管理员 SelectedClause.ExceptionManager = model.ExceptionManager; //旧图标地址 string oldImagePath = SelectedClause.IconFileName; // 设置图标 if (files.Count > 0 && files[0].FileName.Length > 0) { var fileIcon = files[0]; if (!System.IO.Directory.Exists(WorkflowIconRootPath)) { System.IO.Directory.CreateDirectory(WorkflowIconRootPath); } string fileExt = System.IO.Path.GetExtension(fileIcon.FileName); if (!(fileExt == ".png" || fileExt == ".jpg" || fileExt == ".gif" || fileExt == ".bmp")) { result.Message = "WorkflowSetting.WorkflowTemplateSetting_ImageFormat"; return Json(result, JsonRequestBehavior.AllowGet); } //记录旧图标 oldImagePath = SelectedClause.IconFileName; SelectedClause.IconFileName = Guid.NewGuid().ToString().ToLower() + fileExt; fileIcon.SaveAs(WorkflowIconRootPath + "/" + SelectedClause.IconFileName); } //设置默认版本号 int defaultVersion = SelectedClause.DefaultVersion; int.TryParse(model.WorkflowVersion, out defaultVersion); SelectedClause.DefaultVersion = defaultVersion; long result2 = this.Engine.WorkflowManager.UpdateClause(SelectedClause); if (result2 != ErrorCode.SUCCESS) { result.Message = "msgGlobalString.UpdateFailed"; return Json(result, "text/html", JsonRequestBehavior.AllowGet); } else { //删除旧图标 try { if (oldImagePath != SelectedClause.IconFileName) { System.IO.File.Delete(WorkflowIconRootPath + "/" + oldImagePath); } } catch { } // 通知结果 result.Message = "msgGlobalString.SaveSucced"; result.Success = true; return Json(result, "text/html", JsonRequestBehavior.AllowGet); } })); }
/// <summary> /// 保存工作流程信息 /// </summary> /// <param name="model">工作流程信息</param> /// <returns>是否成功</returns> private ActionResult SavePackage(WorkflowPackageViewModel model) { ActionResult result = new ActionResult(); FunctionNode functionNode = new FunctionNode(); if (string.IsNullOrEmpty(model.ObjectID)) { if (!ValidateExist(model.Code, out result)) { return(result); } functionNode.ParentCode = model.Folder; functionNode.Code = model.Code.Trim(); functionNode.NodeType = FunctionNodeType.BizWorkflowPackage; int sortKey; if (Int32.TryParse(model.SortKey, out sortKey)) { functionNode.SortKey = sortKey; } functionNode.DisplayName = model.DisplayName.Trim(); result.Extend = model.Folder; //添加流程包里的数据 result.Success = this.Engine.AppPackageManager.AddAppPackage(functionNode, (StorageType)int.Parse(model.StorageType), model.IsShared, model.IsQuotePacket, model.BindPacket); //使用了共享包,复制共享包的流程模型 if (model.IsQuotePacket) { //复制流程包的流程模板 OThinker.H3.WorkflowTemplate.WorkflowClause[] WorkflowClauses = this.Engine.WorkflowManager.GetClausesBySchemaCode(model.BindPacket); if (null != WorkflowClauses && WorkflowClauses.Length != 0) { //复制所有的父流程模板 WorkflowClauses = WorkflowClauses.Where(s => s.IsShared).ToArray(); for (int i = 0; i < WorkflowClauses.Length; i++) { string workflowClauseCode = i == 0 ? model.Code : model.Code + i; //使用共享包的,用共享包的模型创建 WorkflowTemplate.DraftWorkflowTemplate template = this.Engine.WorkflowManager.GetDraftTemplate(WorkflowClauses[i].WorkflowCode); if (template == null) { continue; } template.WorkflowCode = workflowClauseCode; this.Engine.WorkflowManager.SaveDraftTemplate(this.UserValidator.UserID, template); //添加流程包时已经默认增加了一个流程模板 if (i > 0) { WorkflowTemplate.WorkflowClause wClause = new WorkflowTemplate.WorkflowClause(model.BindPacket, workflowClauseCode, model.DisplayName, WorkflowClauses[i].SortKey); wClause.OwnSchemaCode = model.Code; this.Engine.WorkflowManager.AddClause(wClause); } } } } } else { functionNode = this.Engine.FunctionAclManager.GetFunctionNode(model.ObjectID); int sortKey; if (Int32.TryParse(model.SortKey, out sortKey)) { functionNode.SortKey = sortKey; } functionNode.DisplayName = model.DisplayName.Trim(); string nodeParentId = this.Engine.FunctionAclManager.GetFunctionNodeByCode(functionNode.ParentCode).ObjectID; functionNode.ParentCode = model.Folder; result.Success = this.Engine.FunctionAclManager.UpdateFunctionNode(functionNode) == ErrorCode.SUCCESS; result.Extend = nodeParentId; } return(result); }
/// <summary> /// 创建公式编辑器左边树 /// </summary> /// <param name="functionID"></param> /// <param name="nodes"></param> /// <returns></returns> protected List <FormulaTreeNode> GetFormulaTree(string SchemaCode, string RuleCode) { List <FormulaTreeNode> treeNodeList = new List <FormulaTreeNode>(); #region 输入 string InputObjectID = Guid.NewGuid().ToString();//构造一个ObjectID FormulaTreeNode InputNode = new FormulaTreeNode() { ObjectID = InputObjectID, Text = "FormulaEditor.FormulaEditor_Input", //显示 Icon = this.PortalRoot + "/WFRes/_Content/designer/image/formula/in.png", //图标 IsLeaf = true, LoadDataUrl = "", //加载数据,组织结构时使用 FormulaType = FormulaType.Input.ToString(), //判断类型 Value = "", //存储值,点击时传递该值 ParentID = "" }; treeNodeList.Add(InputNode); #endregion #region 常量 string BlockObjectID = Guid.NewGuid().ToString();//构造一个ObjectID FormulaTreeNode BlockNode = new FormulaTreeNode() { ObjectID = BlockObjectID, Text = "FormulaEditor.FormulaEditor_Constant", //显示 Icon = this.PortalRoot + "/WFRes/_Content/designer/image/formula/folder_16.png", //图标 IsLeaf = false, LoadDataUrl = "", //加载数据,组织结构时使用 FormulaType = FormulaType.Input.ToString(), //判断类型 Value = "", //存储值,点击时传递该值 ParentID = "" }; treeNodeList.Add(BlockNode); List <string> BlockValus = new List <string>(); BlockValus.Add("True"); BlockValus.Add("False"); BlockValus.Add("null"); foreach (string block in BlockValus) { FormulaTreeNode constNode = new FormulaTreeNode() { ObjectID = Guid.NewGuid().ToString(), Text = block, //显示 Icon = this.PortalRoot + "/WFRes/_Content/designer/image/formula/const.png", //图标 IsLeaf = true, LoadDataUrl = "", //加载数据,组织结构时使用 FormulaType = FormulaType.Block.ToString(), //判断类型 Value = block, //存储值,点击时传递该值 ParentID = BlockObjectID }; treeNodeList.Add(constNode); } #endregion #region 函数 var FunctionRootID = Guid.NewGuid().ToString(); FormulaTreeNode FunctionParentNode = new FormulaTreeNode() { ObjectID = FunctionRootID, Text = "FormulaEditor.FormulaEditor_Funciton", Value = "", ParentID = "", LoadDataUrl = "", IsLeaf = false, FormulaType = FormulaType.Function.ToString(), Icon = this.PortalRoot + "/WFRes/_Content/designer/image/formula/folder_16.png" //图标 }; treeNodeList.Add(FunctionParentNode); #endregion #region 参与者函数 List <object> lstParticipantFunctions = new List <object>(); foreach (OThinker.H3.Math.Function Function in OThinker.H3.Math.FunctionFactory.Create(this.Engine.Organization, this.Engine.BizBus)) { if (Function is OThinker.H3.Math.Function) { //ERROR:这两个函数名称不是Public所以不能访问,下行代码写死了函数名称 //以下两个函数不显示 if (Function.FunctionName == "OrgCodeToID" || Function.FunctionName == "OrgIDToCode") { continue; } OThinker.H3.Math.Parameter returns = Function.GetHelper().Return; //构造脚本 lstParticipantFunctions.Add(new { FunctionName = Function.FunctionName, Helper = ((OThinker.H3.Math.Function)Function).GetHelper(), ReturnType = returns == null ? null : returns.LogicTypes }); //构造树节点 FormulaTreeNode FunctionNode = new FormulaTreeNode() { ObjectID = Guid.NewGuid().ToString(), Text = Function.FunctionName, Value = Function.FunctionName, ParentID = FunctionRootID, LoadDataUrl = "", IsLeaf = true, FormulaType = FormulaType.ParticipantFunction.ToString(), Icon = this.PortalRoot + "/WFRes/_Content/designer/image/formula/pf.png" //图标 }; treeNodeList.Add(FunctionNode); } } #endregion #region 参数类型 // <Key,{Name,DisplayName}> Dictionary <string, object> LogicTypeDictionary = new Dictionary <string, object>(); foreach (Data.DataLogicType LogicType in Enum.GetValues(typeof(Data.DataLogicType))) { LogicTypeDictionary.Add(((int)LogicType).ToString(), new { Name = LogicType.ToString(), DisplayName = Data.DataLogicTypeConvertor.ToLogicTypeName(LogicType) }); } //TODO //ScriptManager.RegisterClientScriptBlock(this.Page, Page.GetType(), "LogicTypes", "var LogicTypes=" + this.JSSerializer.Serialize(LogicTypeDictionary) + ";", true); #endregion #region 规则环境 if (!string.IsNullOrWhiteSpace(RuleCode)) { OThinker.H3.BizBus.BizRule.BizRuleTable rule = this.Engine.BizBus.GetBizRule(RuleCode); if (rule != null) { string RuleRootID = Guid.NewGuid().ToString(); bool isleaf = rule.DataElements == null; FormulaTreeNode RuleRootNode = new FormulaTreeNode() { ObjectID = RuleRootID, Text = "FormulaEditor.FormulaEditor_Vocabulary", Value = "", ParentID = "", LoadDataUrl = "", IsLeaf = isleaf, FormulaType = FormulaType.RuleElement.ToString(), Icon = this.PortalRoot + "/WFRes/_Content/designer/image/formula/folder_16.png" //图标 }; treeNodeList.Add(RuleRootNode); if (rule.DataElements != null) { foreach (OThinker.H3.BizBus.BizRule.BizRuleDataElement RuleElement in rule.DataElements) { //词汇表 FormulaTreeNode RuleElementNode = new FormulaTreeNode() { ObjectID = Guid.NewGuid().ToString(), Text = RuleElement.DisplayName + "[" + RuleElement.ElementName + "]", Value = RuleElement.ElementName, ParentID = RuleRootID, LoadDataUrl = "", IsLeaf = true, FormulaType = FormulaType.RuleElement.ToString(), Icon = this.PortalRoot + "/WFRes/_Content/designer/image/formula/di.png" //图标 }; treeNodeList.Add(RuleElementNode); } } } } #endregion #region 流程环境 if (!string.IsNullOrEmpty(SchemaCode)) { //系统数据 List <FormulaTreeNode> listSystemDatas = GetSystemDataItemNode(""); treeNodeList.AddRange(listSystemDatas); } #endregion #region 数据模型环境 if (!string.IsNullOrEmpty(SchemaCode)) { DataModel.BizObjectSchema BizSchema = this.Engine.BizObjectManager.GetDraftSchema(SchemaCode); //如果 BizShceMa为空,把SchemaCode 作为流程编码查询对应的SchemaCode然后再查询 if (BizSchema == null) { WorkflowTemplate.WorkflowClause clause = this.Engine.WorkflowManager.GetClause(SchemaCode); { if (clause != null) { BizSchema = this.Engine.BizObjectManager.GetDraftSchema(clause.BizSchemaCode); } } } if (BizSchema != null) { if (BizSchema.IsQuotePacket) { BizSchema = this.Engine.BizObjectManager.GetDraftSchema(BizSchema.BindPacket); } string SchemaRootID = Guid.NewGuid().ToString(); FormulaTreeNode SchemaRootNode = new FormulaTreeNode() { ObjectID = SchemaRootID, Text = "FormulaEditor.FormulaEditor_BusinessPorperty", Value = "", ParentID = "", LoadDataUrl = "", IsLeaf = false, FormulaType = FormulaType.BizObjectSchema.ToString(), Icon = this.PortalRoot + "/WFRes/_Content/designer/image/formula/folder_16.png" //图标 }; if (BizSchema != null && BizSchema.Properties != null) { List <object> lstDataItems = new List <object>(); foreach (DataModel.PropertySchema Property in BizSchema.Properties) { //不显示保留数据项 if (!DataModel.BizObjectSchema.IsReservedProperty(Property.Name)) { lstDataItems.Add(new { Name = Property.Name, DisplayName = Property.DisplayName, LogicType = Property.LogicType }); TreeNode DataItemNode = new TreeNode(Property.FullName, Property.Name); DataItemNode.NavigateUrl = "javascript:FormulaSettings.InsertVariable('" + Property.Name + "')"; DataItemNode.ImageUrl = "../../WFRes/_Content/designer/image/formula/di.png"; FormulaTreeNode SchemaNode = new FormulaTreeNode() { ObjectID = Guid.NewGuid().ToString(), Text = Property.DisplayName + "[" + Property.Name + "]", Value = Property.Name, ParentID = SchemaRootID, LoadDataUrl = "", IsLeaf = true, FormulaType = FormulaType.BizObjectSchema.ToString(), Icon = this.PortalRoot + "/WFRes/_Content/designer/image/formula/di.png" //图标 }; treeNodeList.Add(SchemaNode); } } if (lstDataItems.Count == 0) { SchemaRootNode.IsLeaf = true; } treeNodeList.Add(SchemaRootNode); //ScriptManager.RegisterClientScriptBlock(this.Page, Page.GetType(), "FunctionNames", "var DataItems=" + this.JSSerializer.Serialize(lstDataItems) + ";", true); } } } #endregion #region 符号 string OperatorRootID = Guid.NewGuid().ToString(); FormulaTreeNode OperatorRootNode = new FormulaTreeNode() { ObjectID = OperatorRootID, Text = "FormulaEditor.FormulaEditor_Symbol", Value = "", ParentID = "", LoadDataUrl = "", IsLeaf = false, FormulaType = FormulaType.Operator.ToString(), Icon = this.PortalRoot + "/WFRes/_Content/designer/image/formula/folder_16.png" //图标 }; treeNodeList.Add(OperatorRootNode); //加减乘除 treeNodeList.Add(new FormulaTreeNode() { ObjectID = Guid.NewGuid().ToString(), ParentID = OperatorRootID, IsLeaf = true, Text = Enum.GetName(typeof(OThinker.H3.Math.Operator), OThinker.H3.Math.Operator.Plus) + " +", Value = "+", Icon = this.PortalRoot + "/WFRes/_Content/designer//image/formula/op.png", FormulaType = FormulaType.Operator.ToString() }); treeNodeList.Add(new FormulaTreeNode() { ObjectID = Guid.NewGuid().ToString(), ParentID = OperatorRootID, IsLeaf = true, Text = Enum.GetName(typeof(OThinker.H3.Math.Operator), OThinker.H3.Math.Operator.Minus) + " -", Value = "-", Icon = this.PortalRoot + "/WFRes/_Content/designer//image/formula/op.png", FormulaType = FormulaType.Operator.ToString() }); treeNodeList.Add(new FormulaTreeNode() { ObjectID = Guid.NewGuid().ToString(), ParentID = OperatorRootID, IsLeaf = true, Text = Enum.GetName(typeof(OThinker.H3.Math.Operator), OThinker.H3.Math.Operator.Mul) + " *", Value = "*", Icon = this.PortalRoot + "/WFRes/_Content/designer//image/formula/op.png", FormulaType = FormulaType.Operator.ToString() }); treeNodeList.Add(new FormulaTreeNode() { ObjectID = Guid.NewGuid().ToString(), ParentID = OperatorRootID, IsLeaf = true, Text = Enum.GetName(typeof(OThinker.H3.Math.Operator), OThinker.H3.Math.Operator.Div) + " /", Value = "/", Icon = this.PortalRoot + "/WFRes/_Content/designer//image/formula/op.png", FormulaType = FormulaType.Operator.ToString() }); treeNodeList.Add(new FormulaTreeNode() { ObjectID = Guid.NewGuid().ToString(), ParentID = OperatorRootID, IsLeaf = true, Text = Enum.GetName(typeof(OThinker.H3.Math.Operator), OThinker.H3.Math.Operator.Set) + " =", Value = "=", Icon = this.PortalRoot + "/WFRes/_Content/designer//image/formula/op.png", FormulaType = FormulaType.Operator.ToString() }); //大小等于 treeNodeList.Add(new FormulaTreeNode() { ObjectID = Guid.NewGuid().ToString(), ParentID = OperatorRootID, IsLeaf = true, Text = Enum.GetName(typeof(OThinker.H3.Math.Operator), OThinker.H3.Math.Operator.Gr) + " >", Value = ">", Icon = this.PortalRoot + "/WFRes/_Content/designer//image/formula/op.png", FormulaType = FormulaType.Operator.ToString() }); treeNodeList.Add(new FormulaTreeNode() { ObjectID = Guid.NewGuid().ToString(), ParentID = OperatorRootID, IsLeaf = true, Text = Enum.GetName(typeof(OThinker.H3.Math.Operator), OThinker.H3.Math.Operator.GrEq) + " >=", Value = ">=", Icon = this.PortalRoot + "/WFRes/_Content/designer//image/formula/op.png", FormulaType = FormulaType.Operator.ToString() }); treeNodeList.Add(new FormulaTreeNode() { ObjectID = Guid.NewGuid().ToString(), ParentID = OperatorRootID, IsLeaf = true, Text = Enum.GetName(typeof(OThinker.H3.Math.Operator), OThinker.H3.Math.Operator.Ls) + " <", Value = "<", Icon = this.PortalRoot + "/WFRes/_Content/designer//image/formula/op.png", FormulaType = FormulaType.Operator.ToString() }); treeNodeList.Add(new FormulaTreeNode() { ObjectID = Guid.NewGuid().ToString(), ParentID = OperatorRootID, IsLeaf = true, Text = Enum.GetName(typeof(OThinker.H3.Math.Operator), OThinker.H3.Math.Operator.LsEq) + " <=", Value = "<=", Icon = this.PortalRoot + "/WFRes/_Content/designer//image/formula/op.png", FormulaType = FormulaType.Operator.ToString() }); treeNodeList.Add(new FormulaTreeNode() { ObjectID = Guid.NewGuid().ToString(), ParentID = OperatorRootID, IsLeaf = true, Text = Enum.GetName(typeof(OThinker.H3.Math.Operator), OThinker.H3.Math.Operator.Eq) + " ==", Value = "==", Icon = this.PortalRoot + "/WFRes/_Content/designer//image/formula/op.png", FormulaType = FormulaType.Operator.ToString() }); treeNodeList.Add(new FormulaTreeNode() { ObjectID = Guid.NewGuid().ToString(), ParentID = OperatorRootID, IsLeaf = true, Text = Enum.GetName(typeof(OThinker.H3.Math.Operator), OThinker.H3.Math.Operator.NtEq) + " !=", Value = "!=", Icon = this.PortalRoot + "/WFRes/_Content/designer//image/formula/op.png", FormulaType = FormulaType.Operator.ToString() }); //与或非 treeNodeList.Add(new FormulaTreeNode() { ObjectID = Guid.NewGuid().ToString(), ParentID = OperatorRootID, IsLeaf = true, Text = Enum.GetName(typeof(OThinker.H3.Math.Operator), OThinker.H3.Math.Operator.And) + " &&", Value = "&&", Icon = this.PortalRoot + "/WFRes/_Content/designer//image/formula/op.png", FormulaType = FormulaType.Operator.ToString() }); treeNodeList.Add(new FormulaTreeNode() { ObjectID = Guid.NewGuid().ToString(), ParentID = OperatorRootID, IsLeaf = true, Text = Enum.GetName(typeof(OThinker.H3.Math.Operator), OThinker.H3.Math.Operator.Or) + " ||", Value = "||", Icon = this.PortalRoot + "/WFRes/_Content/designer//image/formula/op.png", FormulaType = FormulaType.Operator.ToString() }); treeNodeList.Add(new FormulaTreeNode() { ObjectID = Guid.NewGuid().ToString(), ParentID = OperatorRootID, IsLeaf = true, Text = Enum.GetName(typeof(OThinker.H3.Math.Operator), OThinker.H3.Math.Operator.Not) + " !", Value = "!", Icon = this.PortalRoot + "/WFRes/_Content/designer//image/formula/op.png", FormulaType = FormulaType.Operator.ToString() }); //左/右括号 treeNodeList.Add(new FormulaTreeNode() { ObjectID = Guid.NewGuid().ToString(), ParentID = OperatorRootID, IsLeaf = true, Text = Enum.GetName(typeof(OThinker.H3.Math.Operator), OThinker.H3.Math.Operator.LeftPar) + " (", Value = "(", Icon = this.PortalRoot + "/WFRes/_Content/designer//image/formula/op.png", FormulaType = FormulaType.Operator.ToString() }); treeNodeList.Add(new FormulaTreeNode() { ObjectID = Guid.NewGuid().ToString(), ParentID = OperatorRootID, IsLeaf = true, Text = Enum.GetName(typeof(OThinker.H3.Math.Operator), OThinker.H3.Math.Operator.RightPar) + " )", Value = ")", Icon = this.PortalRoot + "/WFRes/_Content/designer//image/formula/op.png", FormulaType = FormulaType.Operator.ToString() }); #endregion #region 组织架构 var OrgRootID = this.Engine.Organization.RootUnit.ObjectID; FormulaTreeNode OrgRootNode = new FormulaTreeNode() { ObjectID = OrgRootID, Text = this.Engine.Organization.RootUnit.Name, Value = OrgRootID, ParentID = "", LoadDataUrl = this.PortalRoot + "/Formula/LoadTreeData?unitID=" + OrgRootID, IsLeaf = false, FormulaType = FormulaType.Organization.ToString(), Icon = this.PortalRoot + "/WFRes/_Content/designer/image/formula/folder_16.png" //图标 }; treeNodeList.Add(OrgRootNode); ////选中事件,前台处理 //if (!string.IsNullOrEmpty(Company.Code)) // UserTree.NavigateUrl = "javascript:FormulaSettings.InsertUser(" + JSSerializer.Serialize(UserTree.Text) + "," + JSSerializer.Serialize(Company.Code) + ")"; //else // UserTree.NavigateUrl = "javascript:FormulaSettings.InsertUser(" + JSSerializer.Serialize(UserTree.Text) + ",'" + JSSerializer.Serialize(Company.ObjectID) + "')"; #endregion return(treeNodeList); }
/// <summary> /// 验证公式 /// </summary> /// <param name="Formula"></param> /// <param name="SchemaCode">流程模板编码</param> /// <param name="RuleCode"></param> /// <returns></returns> public JsonResult Validate(string Formula, string SchemaCode, string RuleCode) { return(ExecuteFunctionRun(() => { //校验结果 ActionResult result = new ActionResult(true, ""); Formula = Server.HtmlDecode(Formula); //错误项 string[] errorItems = null; //错误信息 List <string> Errors = new List <string>(); if (!string.IsNullOrEmpty(Formula)) { // 所有数据项的名称 Dictionary <string, string> formulaItemNames = new Dictionary <string, string>(); string formulaId = Guid.NewGuid().ToString(); formulaItemNames.Add(formulaId, Formula); //所有项名称:数据项、流程关键字 List <string> allItemNames = new List <string>(); //流程关键字 string[] words = OThinker.H3.Instance.Keywords.ParserFactory.GetKeywords(); allItemNames.AddRange(words); //业务模型数据项 //string SchemaCode = CurrentParams[ConstantString.Param_SchemaCode]; if (!string.IsNullOrEmpty(SchemaCode)) { DataModel.BizObjectSchema Schema = this.Engine.BizObjectManager.GetDraftSchema(SchemaCode); //如果一个流程包含有多个流程模板的时候,需要重新计算一下shcema if (Schema == null) { WorkflowTemplate.WorkflowClause clause = this.Engine.WorkflowManager.GetClause(SchemaCode); if (clause != null) { Schema = this.Engine.BizObjectManager.GetDraftSchema(clause.BizSchemaCode); } } if (Schema != null) { if (Schema.IsQuotePacket) { Schema = this.Engine.BizObjectManager.GetDraftSchema(Schema.BindPacket); } foreach (DataModel.PropertySchema item in Schema.Properties) { allItemNames.Add(item.Name); } } } //string RuleCode = CurrentContext.Request[ConstantString.Param_RuleCode]; // 业务规则数据项 if (!string.IsNullOrEmpty(RuleCode)) { OThinker.H3.BizBus.BizRule.BizRuleTable rule = this.Engine.BizBus.GetBizRule(RuleCode); if (rule != null) { if (rule.DataElements != null) { foreach (OThinker.H3.BizBus.BizRule.BizRuleDataElement RuleElement in rule.DataElements) { allItemNames.Add(RuleElement.ElementName); } } } } Function[] fs = FunctionFactory.Create(this.Engine.Organization, this.Engine.BizBus); Dictionary <string, Function> fDic = new Dictionary <string, Function>(); if (fs != null) { foreach (OThinker.H3.Math.Function f in fs) { fDic.Add(f.FunctionName, f); } } result.Success = FormulaParser.Validate(Formula, fDic, allItemNames, ref Errors); result.Message = string.Join(";", Errors); } return Json(result, JsonRequestBehavior.AllowGet); })); }
private object ChildrenForWrokflowPackage(string PackageID, string PackageCode) { FunctionNode package = _controller.Engine.FunctionAclManager.GetFunctionNode(PackageID); bool isLockedByCurrentUser = (package.IsLocked == true && _controller.UserValidator.UserID == package.LockedBy); List <FunctionNode> functionNodes = new List <FunctionNode>(); //所属流程包 //数据模型--流程包的编码,等于数据模型编码 BizObjectSchema schema = _controller.Engine.BizObjectManager.GetDraftSchema(PackageCode); BizObjectSchema schemaShared = null; //如果不是共享包,看是不是引用了共享包 BizSheet[] sheetsShared = null; WorkflowClause[] workflowClausesShared = null; if (!schema.IsShared) { //引用了共享包 if (schema.IsQuotePacket) { string bindSharedPacket = schema.BindPacket; //改为绑定的共享流程包 schemaShared = _controller.Engine.BizObjectManager.GetDraftSchema(bindSharedPacket); if (schemaShared != null) { //取共享的表单 sheetsShared = _controller.Engine.BizSheetManager.GetBizSheetBySchemaCode(schemaShared.SchemaCode); workflowClausesShared = _controller.Engine.WorkflowManager.GetClausesBySchemaCode(schemaShared.SchemaCode); } } } FunctionNode packageNode = null; if (schema.IsQuotePacket) { if (schemaShared != null) { packageNode = new FunctionNode(schemaShared.SchemaCode, schema.DisplayName, "", "", FunctionNodeType.BizObject, PackageCode, 0); packageNode.OwnSchemaCode = schema.SchemaCode; } } else { packageNode = new FunctionNode(schema.SchemaCode, schema.DisplayName, "", "", FunctionNodeType.BizObject, PackageCode, 0); } if (packageNode != null) { packageNode.IconCss = "fa icon-zhushujushili"; //数据模型子节点继承父流程包有关锁定的属性 packageNode.LockedBy = package.LockedBy; functionNodes.Add(packageNode); } //表单列表 BizSheet[] ownSheets = _controller.Engine.BizSheetManager.GetBizSheetBySchemaCode(PackageCode); BizSheet[] sheets = null; //引用了共享包 if (schema.IsQuotePacket && sheetsShared != null) { sheets = sheetsShared.Where(p => (p.OwnSchemaCode == schema.SchemaCode || p.IsShared)).ToArray(); foreach (var sheet in sheets) { sheet.ObjectID = Guid.NewGuid().ToString(); } if (ownSheets != null) { sheets = sheets.Concat(ownSheets).ToArray(); } } else if (ownSheets != null) { sheets = ownSheets.Where(p => string.IsNullOrEmpty(p.OwnSchemaCode)).ToArray(); } if (sheets != null) { foreach (BizSheet sheet in sheets) { FunctionNode node = new FunctionNode(sheet.ObjectID, sheet.SheetCode, sheet.DisplayName , "fa fa-file-o", "", FunctionNodeType.BizSheet, PackageCode, 0); node.IconCss = "fa fa-file-o"; node.IsSystem = sheet.SheetType == SheetType.DefaultSheet; //表单子节点继承父流程包有关锁定的属性 node.LockedBy = package.LockedBy; if (sheet.IsShared && schema.IsQuotePacket) { node.OwnSchemaCode = schema.SchemaCode; } functionNodes.Add(node); } } //流程模板 WorkflowClause[] workflowClausesMySelf = _controller.Engine.WorkflowManager.GetClausesBySchemaCode(PackageCode); WorkflowClause[] workflowClauses = null; //加入共享包模板 //如果是共享包 if (schema.IsShared) { workflowClauses = workflowClausesMySelf.Where(p => p.IsShared).ToArray(); } else { //引用了共享包 if (schema.IsQuotePacket && workflowClausesShared != null) { workflowClauses = workflowClausesShared.Where(p => p.OwnSchemaCode == schema.SchemaCode).ToArray(); } //没有引用共享包 else { workflowClauses = workflowClausesMySelf; } } //WorkflowClause[] workflowClauses = this.Engine.WorkflowManager.GetClausesBySchemaCode(PackageCode); WorkflowTemplate.WorkflowClause template = _controller.Engine.WorkflowManager.GetClause(PackageCode); //引用了共享包,改用共享包模板 if (template == null) { template = _controller.Engine.WorkflowManager.GetClause(schema.SchemaCode); } if (workflowClauses != null) { workflowClauses = workflowClauses.OrderBy(p => p.SortKey).ToArray();; foreach (WorkflowClause workflowClause in workflowClauses) { FunctionNode node = new FunctionNode(workflowClause.ObjectID, workflowClause.WorkflowCode , workflowClause.WorkflowName, "fa icon-liuchengshujumoxing", "", FunctionNodeType.BizWorkflow, PackageCode, 0); if (template != null) { if (template.State == WorkflowState.Inactive) { node.IconCss = "fa icon-liuchengmoxing Inactive"; } else { node.IconCss = "fa icon-liuchengmoxing"; } } else { //当流程包下面没有对应流程包编码的流程模板时,template==null,设置样式为默认流程模板样式 node.IconCss = "fa icon-liuchengmoxing"; } //流程模板子节点继承父流程包有关锁定的属性 node.LockedBy = package.LockedBy; if (workflowClause.IsShared && schema.IsQuotePacket) { node.OwnSchemaCode = schema.SchemaCode; } functionNodes.Add(node); } } //增加ExtendObject,存储DisplayName List <PortalTreeNode> list = ConvertToPortalTree(PackageID, functionNodes.ToArray()); foreach (var node in list) { node.ExtendObject = new { Text = functionNodes.FirstOrDefault(s => s.ObjectID == node.ObjectID).DisplayName, }; } return(list); }