Ejemplo n.º 1
0
        private List <BizRuleDecisionMatrixItemViewModel> GetMatrixData(OThinker.H3.BizBus.BizRule.Header[] headers, string ParenStrIndexes = "")
        {
            List <BizRuleDecisionMatrixItemViewModel> dataList = new List <BizRuleDecisionMatrixItemViewModel>();

            for (int i = 0, j = headers.Length; i < j; i++)
            {
                OThinker.H3.BizBus.BizRule.Header header = headers[i];

                BizRuleDecisionMatrixItemViewModel model = new BizRuleDecisionMatrixItemViewModel();
                model.Index              = i;
                model.DisplayName        = header.DisplayName;
                model.EffectiveCondition = header.Value;
                model.Description        = header.Description;
                model.SortKey            = header.SortKey;
                model.ParentStrIndexs    = ParenStrIndexes;

                if (header.Children != null && header.Children.Length > 0)
                {
                    List <BizRuleDecisionMatrixItemViewModel> listChildren = GetMatrixData(header.Children, ParenStrIndexes + "\\" + i);
                    if (model.children != null)
                    {
                        model.children.AddRange(listChildren);
                    }
                    else
                    {
                        model.children = new List <BizRuleDecisionMatrixItemViewModel>();
                        model.children.AddRange(listChildren);
                    }
                    //dataList.AddRange(listChildren);
                }
                dataList.Add(model);
            }
            return(dataList);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 加载行信息
        /// </summary>
        /// <param name="ruleCode"></param>
        /// <param name="matrixCode"></param>
        /// <param name="columnIndex"></param>
        /// <param name="parentIndexes"></param>
        /// <returns></returns>
        public JsonResult Load(string ruleCode, string matrixCode, int rowIndex, string parentIndexes)
        {
            return(ExecuteFunctionRun(() =>
            {
                ActionResult result = new ActionResult();
                BizRuleTable Rule = Engine.BizBus.GetBizRule(ruleCode);
                BizRuleDecisionMatrix DecisionMatrix = null;
                if (Rule != null)
                {
                    DecisionMatrix = Rule.GetDecisionMatrix(matrixCode);
                }

                Header Row = null;       // 当前行

                Header ParentRow = null; // 直接父级行
                List <int> ParentRowIndexes = GetPrentIndexes(parentIndexes);

                if (ParentRowIndexes.Count > 0)
                {//如果存在父节点,则逐步找到最后一个节点,也就是直接上级
                    foreach (int index in ParentRowIndexes)
                    {
                        if (ParentRow == null)
                        {
                            ParentRow = DecisionMatrix.Rows[index];
                        }
                        else
                        {
                            ParentRow = ParentRow.Children[index];
                        }
                    }
                }

                //如果存在当前行,则看有无直接上级
                if (ParentRow == null)
                {
                    Row = DecisionMatrix.Rows[rowIndex];
                }
                else
                {
                    Row = ParentRow.Children[rowIndex];
                }

                BizRuleDecisionMatrixItemViewModel model = new BizRuleDecisionMatrixItemViewModel();
                model.Index = rowIndex;
                if (Row != null)
                {
                    model.ObjectID = Row.GetHashCode().ToString();//做判断是否为新增使用,不为空表示为更新
                    model.DisplayName = Row.DisplayName;
                    model.Description = Row.Description;
                    model.EffectiveCondition = Row.Value;
                    model.IsDefault = Row.IsDefault;
                    model.SortKey = Row.SortKey;
                    model.RuleCode = ruleCode;
                    model.MatrixCode = matrixCode;
                }
                return Json(model, JsonRequestBehavior.AllowGet);
            }));
        }
Ejemplo n.º 3
0
        private ActionResult ValidateData(BizRuleDecisionMatrixItemViewModel model)
        {
            ActionResult result = new ActionResult(true, "");

            if (string.IsNullOrWhiteSpace(model.DisplayName))
            {
                //this.ShowWarningMessage(this.PortalResource.GetString("EmptyName"));
                result.Success = true;
                result.Message = "BizRule.EmptyName";
            }

            return(result);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 保存决策表列信息
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public JsonResult Save(BizRuleDecisionMatrixItemViewModel model)
        {
            return(ExecuteFunctionRun(() =>
            {
                ActionResult result = new ActionResult();
                //校验数据

                result = ValidateData(model);

                bool IsCreate = string.IsNullOrEmpty(model.ObjectID);
                BizRuleTable Rule = Engine.BizBus.GetBizRule(model.RuleCode);
                if (Rule == null)
                {
                    //业务对象模式不存在,或者已经被删除
                    result.Success = false;
                    result.Message = "BizRule.DeletedOrNotExists";
                    return Json(result);
                }

                BizRuleDecisionMatrix DecisionMatrix = Rule.GetDecisionMatrix(model.MatrixCode);
                if (DecisionMatrix == null)
                {
                    //业务对象模式不存在,或者已经被删除
                    result.Success = false;
                    result.Message = "BizRule.DeletedOrNotExists";
                    return Json(result);
                }

                if (!result.Success)
                {
                    return Json(result);
                }
                if (string.IsNullOrEmpty(model.EffectiveCondition) && !model.IsDefault)
                {
                    // this.ShowWarningMessage(this.PortalResource.GetString("EditBizRuleTableColumn_Mssg1"));
                    result.Success = false;
                    result.Message = "BizRule.SelectDefault";
                    return Json(result);
                }
                if (IsCreate)
                {
                    OThinker.H3.BizBus.BizRule.Header column = new H3.BizBus.BizRule.Header();
                    column.DisplayName = model.DisplayName;
                    column.Description = model.Description;
                    column.Value = model.EffectiveCondition;
                    column.IsDefault = model.IsDefault;
                    column.SortKey = model.SortKey;
                    DecisionMatrix.AddColumn(GetPrentIndexes(model.ParentStrIndexs).ToArray(), column);
                }
                else
                {
                    Header Column = null;       // 当前列

                    Header ParentColumn = null; // 直接父级列
                    List <int> ParentColumnIndexes = GetPrentIndexes(model.ParentStrIndexs);

                    if (ParentColumnIndexes.Count > 0)
                    {//如果存在父节点,则逐步找到最后一个节点,也就是直接上级
                        foreach (int index in ParentColumnIndexes)
                        {
                            if (ParentColumn == null)
                            {
                                ParentColumn = DecisionMatrix.Columns[index];
                            }
                            else
                            {
                                ParentColumn = ParentColumn.Children[index];
                            }
                        }
                    }

                    if (model.Index > -1)
                    {
                        //如果存在当前列,则看有无直接上级
                        if (ParentColumn == null)
                        {
                            Column = DecisionMatrix.Columns[model.Index];
                        }
                        else
                        {
                            Column = ParentColumn.Children[model.Index];
                        }
                    }

                    Column.DisplayName = model.DisplayName;
                    Column.Value = model.EffectiveCondition;
                    Column.Description = model.Description;
                    Column.IsDefault = model.IsDefault;
                    Column.SortKey = model.SortKey;

                    //DecisionMatrix.Resort();
                }
                if (this.Engine.BizBus.UpdateBizRule(Rule))
                {
                    result.Success = true;
                    result.Message = "msgGlobalString.SaveSucced";
                }
                else
                {
                    //this.ShowWarningMessage(this.PortalResource.GetString("EditBizRuleTableColumn_SaveFailed"));
                    result.Success = false;
                    result.Message = "msgGlobalString.SaveFailed";
                }

                return Json(result, JsonRequestBehavior.AllowGet);
            }));
        }