public string GetLogicTypeName(LogicType logicType) { if (logicType == LogicType.None) { return(""); } return(logicType.ToString()); }
public Dictionary <string, object> ToDictionary() { var rlt = new Dictionary <string, object> { { Prefix + ValueFieldName, Value }, { Prefix + LogicTypeFieldName, LogicType.ToString() }, { Prefix + IsActiveFieldName, IsActive } }; if (TargetsKeys != null) { rlt.Add(Prefix + TargetsKeysFieldName, TargetsKeys); } return(rlt); }
private static void AddLogicType(LogicType logicType, XmlDocument xmlDocument, XmlNode root) { string logicTypeName = logicType.ToString(); int logicTypeId = (int)logicType; var element = xmlDocument.CreateElement("LogicType"); var idAttribute = xmlDocument.CreateAttribute("id"); idAttribute.Value = logicTypeId.ToString(); element.Attributes.Append(idAttribute); var textNode = xmlDocument.CreateTextNode(logicTypeName); element.AppendChild(textNode); root.AppendChild(element); }
/// <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="SchemaCode"></param> /// <param name="RuleCode"></param> /// <returns></returns> public JsonResult GetFormulaTips(string SchemaCode, string RuleCode) { return(ExecuteFunctionRun(() => { FormulaTipViewModel model = new FormulaTipViewModel(); #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 }); } } model.ParticipantFunctions = lstParticipantFunctions; #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) }); } model.LogicTypes = LogicTypeDictionary; #endregion #region 规则环境 if (!string.IsNullOrWhiteSpace(RuleCode)) { OThinker.H3.BizBus.BizRule.BizRuleTable rule = this.Engine.BizBus.GetBizRule(RuleCode); List <object> lstRuleElement = new List <object>(); if (rule != null) { if (rule.DataElements != null) { foreach (OThinker.H3.BizBus.BizRule.BizRuleDataElement RuleElement in rule.DataElements) { //词汇表 lstRuleElement.Add(new { Name = RuleElement.ElementName, DisplayName = RuleElement.DisplayName, LogicType = RuleElement.LogicType }); } } } model.RuleElement = lstRuleElement; } #endregion #region 流程环境 if (!string.IsNullOrEmpty(SchemaCode)) { ////系统数据 List <FormulaTreeNode> listSystemDatas = GetSystemDataItemNode(""); ////获取所有节点的文本集合,供智能感知 List <string> lstNodeStrings = new List <string>(); AddTreeString(listSystemDatas, lstNodeStrings); model.InstanceVariables = lstNodeStrings; } #endregion #region 数据模型环境 if (!string.IsNullOrEmpty(SchemaCode)) { DataModel.BizObjectSchema BizSchema = this.Engine.BizObjectManager.GetDraftSchema(SchemaCode); if (BizSchema != null) { 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 }); ; } } model.DataItems = lstDataItems; } } } #endregion return Json(model, JsonRequestBehavior.AllowGet); })); }