예제 #1
0
        public ActionResult List()
        {
            var engineeringInfoID = this.GetQueryString("EngineeringInfoID");
            var folderKey         = this.GetQueryString("FolderKey");
            var engineeringInfo   = this.GetEntityByID <S_I_Engineering>(engineeringInfoID);

            if (engineeringInfo == null)
            {
                throw new Formula.Exceptions.BusinessValidationException("没有找到指定的工程信息");
            }
            ViewBag.EngineeringInfoID = engineeringInfo.ID;
            var folder = engineeringInfo.S_D_Folder.FirstOrDefault(c => c.FolderKey == folderKey);

            ViewBag.HasAttr = false;
            if (folder == null)
            {
                folder = engineeringInfo.S_D_Folder.FirstOrDefault(c => c.Code == folderKey);
                if (folder == null)
                {
                    return(View());
                }
            }

            ViewBag.FolderID = folder.ID;
            string tmplCode      = "DocumentBaseInfo";
            var    baseDbContext = FormulaHelper.GetEntities <BaseEntities>();
            var    formInfo      = baseDbContext.S_UI_Form.FirstOrDefault(c => c.Code == tmplCode);

            if (formInfo == null)
            {
                ViewBag.BaseHtml       = "";
                ViewBag.BaseScrpitHtml = "";
            }
            else
            {
                //var uiFo = FormulaHelper.CreateFO<Base.Logic.BusinessFacade.UIFO>();
                //ViewBag.BaseHtml = uiFo.CreateFormHtml(tmplCode, null);
                //ViewBag.BaseScrpitHtml = uiFo.CreateFormScript(tmplCode);
                var uiFO    = FormulaHelper.CreateFO <UIFO>();
                var formDef = UIFO.GetFormDef(tmplCode, Request["ID"]);
                ViewBag.BaseHtml = uiFO.CreateFormHtml(formDef);
                if (ViewBag.BaseScrpitHtml != null && !String.IsNullOrEmpty(ViewBag.BaseScrpitHtml))
                {
                    ViewBag.BaseScrpitHtml += "\n " + uiFO.CreateFormScript(formDef);
                }
                else
                {
                    ViewBag.BaseScrpitHtml = uiFO.CreateFormScript(formDef);
                }
            }

            if (!String.IsNullOrEmpty(folder.AttrDefine))
            {
                var attrList = JsonHelper.ToList(folder.AttrDefine);
                if (attrList.Count > 0)
                {
                    ViewBag.HasAttr = true;
                }
            }
            return(View());
        }
예제 #2
0
        public ActionResult DocumentManager()
        {
            var baseDbContext = FormulaHelper.GetEntities <BaseEntities>();
            var level         = String.IsNullOrEmpty(this.GetQueryString("Level").Trim()) ? "true" : this.GetQueryString("Level");

            ViewBag.DisplayLevel = level;
            string tmplCode = "DocumentBaseInfo";
            var    formInfo = baseDbContext.S_UI_Form.FirstOrDefault(c => c.Code == tmplCode);

            if (formInfo == null)
            {
                ViewBag.BaseHtml       = "";
                ViewBag.BaseScrpitHtml = "";
            }
            else
            {
                //var uiFo = FormulaHelper.CreateFO<Base.Logic.BusinessFacade.UIFO>();
                //ViewBag.BaseHtml = uiFo.CreateFormHtml(tmplCode, null);
                //ViewBag.BaseScrpitHtml = uiFo.CreateFormScript(tmplCode);
                var uiFO    = FormulaHelper.CreateFO <UIFO>();
                var formDef = UIFO.GetFormDef(tmplCode, Request["ID"]);
                ViewBag.BaseHtml = uiFO.CreateFormHtml(formDef);
                if (ViewBag.BaseScrpitHtml != null && !String.IsNullOrEmpty(ViewBag.BaseScrpitHtml))
                {
                    ViewBag.BaseScrpitHtml += "\n " + uiFO.CreateFormScript(formDef);
                }
                else
                {
                    ViewBag.BaseScrpitHtml = uiFO.CreateFormScript(formDef);
                }
            }

            var engineeringInfoID = this.GetQueryString("EngineeringInfoID");
            var engineeringInfo   = this.GetEntityByID <S_I_Engineering>(engineeringInfoID);

            if (engineeringInfo != null)
            {
                if (engineeringInfo.Mode == null)
                {
                    throw new Formula.Exceptions.BusinessValidationException("未找到该项目的项目模式");
                }

                var infrastructureDbContext = FormulaHelper.GetEntities <InfrastructureEntities>();
                var folderTemplate          = infrastructureDbContext.Set <S_T_FolderTemplate>().FirstOrDefault(a => a.ModeKey.Contains(engineeringInfo.Mode.ID));
                if (folderTemplate == null)
                {
                    throw new Formula.Exceptions.BusinessValidationException("没有找到指定的文档目录结构模板");
                }

                ViewBag.QuickSearchName = "";
                ViewBag.QuickSearchCode = "";
                if (!string.IsNullOrEmpty(folderTemplate.DisplayColJson))
                {
                    var dicList = JsonHelper.ToList(folderTemplate.DisplayColJson);
                    ViewBag.ColDefine       = dicList;
                    ViewBag.QuickSearchName = string.Join("或", dicList.Where(a => a.GetValue("IsQuickSearch") == "true")
                                                          .Select(a => a.GetValue("Name")));
                    ViewBag.QuickSearchCode = string.Join(",", dicList.Where(a => a.GetValue("IsQuickSearch") == "true")
                                                          .Select(a => a.GetValue("Code")));
                }
            }
            return(View());
        }
예제 #3
0
        public void Validate()
        {
            var   rangeSQL = this.ModelDic.GetValue("ApportionSQL");
            Regex reg      = new Regex("\\{[0-9a-zA-Z_\\.]*\\}");

            var formDef   = UIFO.GetFormDef("CostApportion", string.Empty);
            var formItems = JsonHelper.ToObject <List <FormItem> >(formDef.Items);

            #region 校验计算范围的SQL语句定义是否正确
            var variateList = reg.Matches(rangeSQL);
            foreach (Match variate in variateList)
            {
                string value      = variate.Value.Trim('{', '}');
                var    matchDatas = value.Split('.');
                if (matchDatas.Length == 1)
                {
                    throw new Formula.Exceptions.BusinessValidationException("计算数据源中定义变量必须指定变量的来源,以固定格式{XXX.XXX}来定义");
                }
                if (matchDatas[0] == InputPre)
                {
                    if (this.InputDefineList.Count == 0 || this.InputDefineList.Count(c => c.GetValue("Code") == matchDatas[1]) == 0)
                    {
                        throw new Formula.Exceptions.BusinessValidationException("计算数据源定义中,未能找到编号为【" + matchDatas[1] + "】的输入控件定义");
                    }
                }
                else if (matchDatas[0] == ParamPre)
                {
                    if (this.ParamDefineList.Count == 0 || this.ParamDefineList.Count(c => c.GetValue("Code") == matchDatas[1]) == 0)
                    {
                        throw new Formula.Exceptions.BusinessValidationException("计算数据源定义中,未能找到编号为【" + matchDatas[1] + "】的参数数据源定义");
                    }
                }
                else if (matchDatas[0] == FormPre)
                {
                    if (formItems.Count == 0 || formItems.Count(c => c.Code == matchDatas[1]) == 0)
                    {
                        throw new Formula.Exceptions.BusinessValidationException("计算数据源定义中,未能在分摊页面找到编号为【" + matchDatas[1] + "】的控件定义");
                    }
                }
                else
                {
                    throw new Formula.Exceptions.BusinessValidationException("计算数据源定义中,无法识别数据获取对象,获取对象前缀必须是 Input 或 Param");
                }
            }
            #endregion

            #region 校验计算公式定义
            foreach (var calDefine in this.CaculateDefineList)
            {
                var content = calDefine.GetValue("Content");
                if (String.IsNullOrEmpty(content))
                {
                    continue;
                }
                if (reg.IsMatch(content))
                {
                    Match  m          = reg.Match(content);
                    string value      = m.Value.Trim('{', '}');
                    var    matchDatas = value.Split('.');
                    if (matchDatas.Length == 1)
                    {
                        throw new Formula.Exceptions.BusinessValidationException("计算配置定义中,字段【" + calDefine.GetValue("Code") + "】的定义不正确,以固定格式{XXX.XXX}来定义");
                    }
                    if (matchDatas[0] == InputPre)
                    {
                        if (this.InputDefineList.Count == 0 || this.InputDefineList.Count(c => c.GetValue("Code") == matchDatas[1]) == 0)
                        {
                            throw new Formula.Exceptions.BusinessValidationException("计算数据源定义中,未能找到编号为【" + matchDatas[1] + "】的输入控件定义");
                        }
                    }
                    else if (matchDatas[0] == ParamPre)
                    {
                        if (this.ParamDefineList.Count == 0 || this.ParamDefineList.Count(c => c.GetValue("Code") == matchDatas[1]) == 0)
                        {
                            throw new Formula.Exceptions.BusinessValidationException("计算数据源定义中,未能找到编号为【" + matchDatas[1] + "】的参数数据源定义");
                        }
                    }
                    else if (matchDatas[0] == FormPre)
                    {
                        if (formItems.Count == 0 || formItems.Count(c => c.Code == matchDatas[1]) == 0)
                        {
                            throw new Formula.Exceptions.BusinessValidationException("计算数据源定义中,未能在分摊页面找到编号为【" + matchDatas[1] + "】的控件定义");
                        }
                    }
                    else if (matchDatas[0] == RangePre)
                    {
                        if (this.RangeStructDt == null)
                        {
                            throw new Formula.Exceptions.BusinessValidationException("计算数据源定义错误,请检查SQL语句");
                        }
                        if (!this.RangeStructDt.Columns.Contains(matchDatas[1]))
                        {
                            throw new Formula.Exceptions.BusinessValidationException("计算配置定义中,字段【" + calDefine.GetValue("Code") + "】的定义不正确,计算数据源不包含【" + matchDatas[1] + "】的字段");
                        }
                    }
                    else
                    {
                        throw new Formula.Exceptions.BusinessValidationException("计算配置定义中,字段【" + calDefine.GetValue("Code") + "】的定义不正确,前缀只能是 【" + InputPre + "】或【" + ParamPre + "】或【" + RangePre + "】");
                    }
                }
            }
            #endregion

            #region 校验参数数据源的SQL定义是否正确
            foreach (var item in this.ParamDefineList)
            {
                if (String.IsNullOrEmpty(item.GetValue("SQL")))
                {
                    throw new Formula.Exceptions.BusinessValidationException("编号为【" + item.GetValue("Code") + "】的参数数据源SQL语句未定义");
                }
                var matchs = reg.Matches(item.GetValue("SQL"));
                foreach (Match m in matchs)
                {
                    var value      = m.Value.Trim('{', '}');
                    var matchDatas = value.Split('.');
                    if (matchDatas.Length == 1)
                    {
                        throw new Formula.Exceptions.BusinessValidationException("参数数据源定义中,字段【" + item.GetValue("Code") + "】的定义不正确,以固定格式{XXX.XXX}来定义");
                    }
                    else if (matchDatas[0] == InputPre)
                    {
                        if (this.InputDefineList.Count == 0 || this.InputDefineList.Count(c => c.GetValue("Code") == matchDatas[1]) == 0)
                        {
                            throw new Formula.Exceptions.BusinessValidationException("参数数据源定义中,未能找到编号为【" + matchDatas[1] + "】的输入控件定义");
                        }
                    }
                    else if (matchDatas[0] == FormPre)
                    {
                        if (formItems.Count == 0 || formItems.Count(c => c.Code == matchDatas[1]) == 0)
                        {
                            throw new Formula.Exceptions.BusinessValidationException("参数数据源定义中,未能在分摊页面找到编号为【" + matchDatas[1] + "】的控件定义");
                        }
                    }
                    else
                    {
                        throw new Formula.Exceptions.BusinessValidationException("参数数据源定义中,字段【" + item.GetValue("Code") + "】的定义不正确,前缀只能是 【" + InputPre + "】");
                    }
                }
            }
            #endregion
        }