Пример #1
0
        public IList <TreeJSONBase> GetIndividualFieldTree(string bustype)
        {
            IList <TreeJSONBase> rootlist = new List <TreeJSONBase>();

            DataTable dt       = dac.GetTableRegByBusType(bustype);
            DataTable columndt = dac.GetColumnsByBusType(bustype);

            foreach (DataRow dr in dt.Rows)
            {
                //string code = dr["code"].ToString();
                string tname = dr["c_bname"].ToString();//表名


                TreeJSONBase table = new TreeJSONBase();
                table.id        = tname;
                table.text      = tname;
                table.leaf      = false;
                table.allowDrag = false;
                table.expanded  = true;

                IList <TreeJSONBase> list = new List <TreeJSONBase>();

                DataRow[] columns = columndt.Select("c_bname='" + tname + "'");

                //string uitype = columns[0]["container_uitype"].ToString();//ui类型,formpanel还是gridpanel

                for (int i = 0; i < columns.Length; i++)
                {
                    string uitype = columns[i]["container_uitype"].ToString();//ui类型,formpanel还是gridpanel

                    if ("formpanel" == uitype)
                    {
                        IndividualFieldTreeJson col = new IndividualFieldTreeJson();

                        string xtype     = columns[i]["uixtype"].ToString();
                        string fieldname = columns[i]["c_name"].ToString();          //字段
                        string label     = columns[i]["c_fullname"].ToString();      //字段名
                        string helpid    = columns[i]["helpid"].ToString();          //帮助id
                        string querymode = columns[i]["querymode"].ToString();       //remote;local
                        string combodata = columns[i]["combodata"].ToString();       //帮助id

                        string fieldtype = columns[i]["c_type"].ToString();          //字段类型
                        int    length;
                        Int32.TryParse(columns[i]["collen"].ToString(), out length); //字段长度
                        int declen;
                        Int32.TryParse(columns[i]["declen"].ToString(), out declen); //小数点位数

                        string fieldUIId = tname + "." + fieldname;
                        col.id                       = tname + "_" + fieldname;
                        col.text                     = label;
                        col.leaf                     = true;
                        col.allowDrag                = true;
                        col.control                  = IndividualInfoFactory.GetControlInfo(xtype, fieldname, label, fieldtype, length, declen);
                        col.listColumnInfo           = ColumnInfoBuilder.BuildBillListColumn(xtype, fieldname, label, helpid, combodata, declen);
                        col.control.FieldUIId        = fieldUIId;
                        col.listColumnInfo.FieldUIId = fieldUIId;
                        col.from                     = "toolbox";//控件来源标记
                        col.container_uitype         = uitype;

                        if (xtype == "ngRichHelp" && !string.IsNullOrWhiteSpace(helpid))
                        {
                            var help = col.control as NGRichHelp;

                            help.helpid  = helpid;
                            help.ORMMode = true;
                            DataTable helpinfoDt = dac.GetHelpInfo(helpid);
                            if (helpinfoDt.Rows.Count > 0)
                            {
                                string codeField = helpinfoDt.Rows[0]["codefield"].ToString().Trim();
                                if (codeField.IndexOf('.') > 0)
                                {
                                    help.valueField = codeField.Split('.')[1];//去掉表名
                                }
                                else
                                {
                                    help.valueField = codeField;
                                }
                                string nameField = helpinfoDt.Rows[0]["namefield"].ToString().Trim();
                                if (nameField.IndexOf('.') > 0)
                                {
                                    help.displayField = nameField.Split('.')[1];
                                }
                                else
                                {
                                    help.displayField = nameField;
                                }
                            }
                        }
                        else if (xtype == "ngComboBox")
                        {
                            var combo = col.control as NGComboBox;
                            combo.data = ColumnInfoBuilder.TranslateData(combodata, ';', '|');
                        }

                        list.Add(col);
                    }
                    else //gridpanel
                    {
                        GridColumnTreeJson col = new GridColumnTreeJson();

                        string xtype     = columns[i]["uixtype"].ToString();
                        string fieldname = columns[i]["c_name"].ToString();          //字段
                        string header    = columns[i]["c_fullname"].ToString();      //字段名
                        string helpid    = columns[i]["helpid"].ToString();          //帮助id
                        //string querymode = columns[i]["querymode"].ToString();//remote;local
                        string combodata = columns[i]["combodata"].ToString();       //帮助id
                        int    length;
                        Int32.TryParse(columns[i]["collen"].ToString(), out length); //字段长度
                        int declen;
                        Int32.TryParse(columns[i]["declen"].ToString(), out declen); //小数点位数

                        string fieldUIId = tname + "." + fieldname;
                        col.id                = tname + "_" + fieldname;
                        col.text              = header;
                        col.leaf              = true;
                        col.allowDrag         = true;
                        col.control           = ColumnInfoBuilder.Build(xtype, fieldname, header, helpid, combodata, length, declen);
                        col.control.FieldUIId = fieldUIId;
                        col.from              = "toolbox";//控件来源标记
                        col.container_uitype  = uitype;

                        list.Add(col);
                    }
                }

                //children为null,树就会一直发请求来取数,把children设置为空数组就好了
                //if(list.Count > 0)
                //{
                table.children = list;
                //}

                rootlist.Add(table);
            }

            return(rootlist);
        }
Пример #2
0
        public IList <ExtControlInfoBase> GetIndividualQueryPanel(string pageId, string ocode, string logid)
        {
            #region 获取控件
            DataTable dt = queryPanelDac.GetIndividualQueryPanelInfo(pageId, ocode, logid);
            IList <ExtControlInfoBase> list = new List <ExtControlInfoBase>();
            if (dt.Rows.Count == 0)
            {
                return(list);//无内嵌查询
            }

            #region 缓存处理

            string cachedKey = new StringBuilder().Append(CACHEDID).Append("_")
                               .Append(ocode).Append("_").Append(logid).Append("_").Append(pageId).ToString();
            string cachedTimeKey = cachedKey + "time";//时间戳缓存键

            string localTimeStamp     = HttpRuntime.Cache.Get(cachedTimeKey) as String;
            string cachedSrvTimeStamp = NG.Cache.Client.CacheClient.Instance.GetData(MAINKEY, cachedTimeKey) as String;
            if (localTimeStamp == cachedSrvTimeStamp)//本地时间戳与缓存服务器的时间戳比对
            {
                IList <ExtControlInfoBase> cachedList = HttpRuntime.Cache.Get(cachedKey) as IList <ExtControlInfoBase>;
                if (cachedList != null)
                {
                    return(cachedList);
                }
            }

            #endregion

            //获取内嵌查询多语言键值对
            Dictionary <string, string> langDic = SUP.Common.DataAccess.LangInfo.GetLabelLang(pageId);

            string    tables     = GetTableNames(dt);
            DataTable PropertyDt = queryPanelDac.GetPropertyDt(tables);

            RichHelpDac richHelpDac = new RichHelpDac();

            foreach (DataRow dr in dt.Rows)
            {
                ExtControlInfoBase col = new ExtControlInfoBase();


                string searchetable = dr["searchtable"].ToString();
                string searchfield  = dr["searchfield"].ToString();
                string fieldname    = dr["searchfield"].ToString();
                string langkey      = dr["langkey"].ToString();;//全部
                fieldname = GetPropertyName(PropertyDt, searchetable, searchfield, fieldname);

                //处理itemId
                string itemId = fieldname;

                fieldname = DealDataType(dr, fieldname);
                fieldname = DealOperation(dr, fieldname);

                fieldname += "*" + dr["isaddtowhere"].ToString();//是否直接参与查询


                string label = dr["fname_chn"].ToString();//标签名
                if (langDic.ContainsKey(langkey) && !string.IsNullOrEmpty(langDic[langkey]))
                {
                    label = langDic[langkey];//取多语言
                }
                string xtype         = string.Empty;
                string displayfield  = "";
                string valuefield    = "";
                string namefield     = "";
                string codefield     = "";
                string usercodefield = string.Empty; //用户编码
                string usercodePro   = string.Empty; //用户编码对应的属性名
                switch (dr["controltype"].ToString())
                {
                case "TextBox":
                    xtype = "ngText";
                    break;

                case "CompositeTextBox":
                    xtype = "ngRichHelp";
                    NGRichHelp richhelp = new NGRichHelp();
                    richhelp.helpid          = dr["controlflag"].ToString();
                    richhelp.xtype           = xtype;
                    richhelp.name            = fieldname;
                    richhelp.itemId          = itemId;
                    richhelp.fieldLabel      = label;
                    richhelp.matchFieldWidth = false;
                    //if (dr["matchfieldwidth"] != null && dr["matchfieldwidth"] != DBNull.Value)
                    //{
                    //    if (dr["matchfieldwidth"].ToString() == "0")
                    //    {
                    //        richhelp.matchFieldWidth = false;
                    //    }
                    //}
                    //else
                    //{
                    //    richhelp.matchFieldWidth = false;//为空也设置为false
                    //}
                    richhelp.showAutoHeader = false;
                    if (!string.IsNullOrEmpty(richhelp.helpid))
                    {
                        SUP.Common.DataEntity.CommonHelpEntity helpEntity = richHelpDac.GetCommonHelpItem(richhelp.helpid);

                        namefield     = helpEntity.NameField;
                        codefield     = helpEntity.CodeField;
                        codefield     = this.DeleteTableName(codefield);
                        namefield     = this.DeleteTableName(namefield);
                        usercodefield = helpEntity.UserCodeField;
                        string tablename = helpEntity.TableName;
                        displayfield  = helpEntity.NameProperty;
                        valuefield    = helpEntity.CodeProperty;
                        usercodefield = this.DeleteTableName(usercodefield);
                        valuefield    = this.DeleteTableName(valuefield);
                        displayfield  = this.DeleteTableName(displayfield);
                        if (string.IsNullOrWhiteSpace(usercodefield))
                        {
                            usercodefield = codefield;
                        }
                        else
                        {
                            usercodePro = helpEntity.UserCodeProperty;
                        }
                        if (string.IsNullOrEmpty(displayfield) && string.IsNullOrEmpty(valuefield))
                        {
                            richhelp.displayField  = namefield;
                            richhelp.valueField    = codefield;
                            richhelp.usercodeField = usercodefield;
                            richhelp.ORMMode       = false;//richhelp这个必须为false
                        }
                        else
                        {
                            if (tablename.IndexOf(",") > 0 || tablename.IndexOf("=") > 0) //表名有多表关联,属性无法正确获取,不走orm
                            {
                                richhelp.ORMMode = false;                                 //richhelp这个必须为false
                            }
                            richhelp.displayField  = displayfield;
                            richhelp.valueField    = valuefield;
                            richhelp.usercodeField = usercodePro;
                        }
                    }
                    richhelp.listFields      = richhelp.usercodeField + "," + richhelp.displayField + "," + richhelp.valueField;
                    richhelp.value           = dr["defaultdata"].ToString();
                    richhelp.listHeadTexts   = "代码,名称";
                    richhelp.clientSqlFilter = dr["sqlfilter"].ToString();    //sql过滤条件
                    list.Add(richhelp);
                    continue;

                case "NGCustomFormHelp":
                    xtype = "ngCustomFormHelp";
                    NGCustomFormHelp customhelp = new NGCustomFormHelp();    //自定义表单的帮助
                    customhelp.helpid         = dr["controlflag"].ToString();
                    customhelp.xtype          = xtype;
                    customhelp.name           = fieldname;
                    customhelp.itemId         = itemId;
                    customhelp.fieldLabel     = label;
                    customhelp.showAutoHeader = false;
                    if (!string.IsNullOrEmpty(customhelp.helpid))
                    {
                        SUP.CustomForm.DataAccess.HelpDac    customdac  = new CustomForm.DataAccess.HelpDac();
                        SUP.CustomForm.DataEntity.HelpEntity helpEntity = customdac.GetCustomFormHelpItem(customhelp.helpid);
                        namefield = helpEntity.NameField;
                        codefield = helpEntity.CodeField;
                        if (codefield.IndexOf(".") > 0)
                        {
                            codefield = codefield.Split('.')[1];    //
                        }
                        if (namefield.IndexOf(".") > 0)
                        {
                            namefield = namefield.Split('.')[1];
                        }
                        usercodefield = helpEntity.NoField;

                        customhelp.displayField  = namefield;
                        customhelp.valueField    = codefield;
                        customhelp.usercodeField = usercodefield;
                        customhelp.ORMMode       = false;
                    }
                    customhelp.listFields      = customhelp.usercodeField + "," + customhelp.displayField + "," + customhelp.valueField;
                    customhelp.value           = dr["defaultdata"].ToString();
                    customhelp.listHeadTexts   = "代码,名称";
                    customhelp.clientSqlFilter = dr["sqlfilter"].ToString();    //sql过滤条件
                    list.Add(customhelp);
                    continue;

                case "DateBox":
                    xtype = "ngDate";
                    break;

                case "DateTimeBox":
                    xtype = "ngDateTime";
                    break;

                case "DropDownList":
                    xtype = "ngComboBox";
                    NGComboBox combo = new NGComboBox();
                    combo.helpid = dr["controlflag"].ToString();
                    if (dr["matchfieldwidth"] != null && dr["matchfieldwidth"] != DBNull.Value)
                    {
                        if (dr["matchfieldwidth"].ToString() == "0")
                        {
                            combo.matchFieldWidth = false;
                        }
                    }
                    if (!string.IsNullOrEmpty(combo.helpid))
                    {
                        SUP.Common.DataEntity.CommonHelpEntity helpEntity = richHelpDac.GetCommonHelpItem(combo.helpid);
                        combo.queryMode = "remote";
                        namefield       = helpEntity.NameField;
                        codefield       = helpEntity.CodeField;
                        usercodefield   = helpEntity.UserCodeField;
                        codefield       = this.DeleteTableName(codefield);
                        namefield       = this.DeleteTableName(namefield);
                        string tablename = helpEntity.TableName;
                        displayfield = helpEntity.NameProperty;
                        valuefield   = helpEntity.CodeProperty;
                        if (string.IsNullOrWhiteSpace(usercodefield))
                        {
                            usercodefield = codefield;
                        }
                        else
                        {
                            usercodePro = helpEntity.UserCodeProperty;
                        }
                        if (string.IsNullOrEmpty(displayfield) && string.IsNullOrEmpty(valuefield))
                        {
                            combo.displayField  = namefield;
                            combo.valueField    = codefield;
                            combo.usercodeField = usercodefield;
                            combo.ORMMode       = false;//richhelp这个必须为false
                        }
                        else
                        {
                            if (tablename.IndexOf(",") > 0 || tablename.IndexOf("=") > 0) //表名有多表关联,属性无法正确获取,不走orm
                            {
                                combo.ORMMode = false;                                    //richhelp这个必须为false
                            }
                            combo.displayField  = displayfield;
                            combo.valueField    = valuefield;
                            combo.usercodeField = usercodePro;
                        }
                        if (namefield == codefield)    //不相等出两列
                        {
                            combo.listFields    = combo.displayField;
                            combo.listHeadTexts = "名称";
                        }
                        else
                        {
                            combo.listFields    = combo.usercodeField + "," + combo.displayField + "," + combo.valueField;
                            combo.listHeadTexts = "编码,名称";
                        }
                    }
                    else
                    {
                        if (string.IsNullOrWhiteSpace(dr["datasource"].ToString()))
                        {
                            throw new Exception(string.Format("内嵌查询字段【{0}】类型为下拉,但未配置数据源!", itemId));
                        }
                        combo.data      = ColumnInfoBuilder.TranslateData(dr["datasource"].ToString(), '|', ':');
                        combo.queryMode = "local";
                    }
                    combo.xtype           = xtype;
                    combo.name            = fieldname;
                    combo.itemId          = itemId;
                    combo.fieldLabel      = label;
                    combo.value           = dr["defaultdata"].ToString();
                    combo.clientSqlFilter = dr["sqlfilter"].ToString();    //sql过滤条件
                    list.Add(combo);
                    continue;

                case "CheckBoxList":
                    xtype = "ngCheckbox";
                    break;

                case "AutoCompleteWithCommonHelpControl":
                    xtype     = "ngCommonHelp";
                    namefield = dr["namefield"].ToString();
                    codefield = dr["codefield"].ToString();
                    NGCommonHelp commonHelp = new NGCommonHelp();
                    commonHelp.helpid = dr["controlflag"].ToString();
                    displayfield      = DataConverterHelper.FieldToProperty(dr["tablename"].ToString(), namefield);
                    valuefield        = DataConverterHelper.FieldToProperty(dr["tablename"].ToString(), codefield);
                    if (string.IsNullOrEmpty(codefield) && string.IsNullOrEmpty(namefield))    //从xml取数
                    {
                        DataEntity.CommonHelpEntity item = new CommonHelpDac().GetHelpItem(commonHelp.helpid);
                        commonHelp.displayField = item.NameField;
                        commonHelp.valueField   = item.CodeField;
                    }
                    else if (string.IsNullOrEmpty(dr["modelname"].ToString()) && string.IsNullOrEmpty(displayfield) && string.IsNullOrEmpty(valuefield))
                    {
                        commonHelp.displayField = namefield;
                        commonHelp.valueField   = codefield;
                    }
                    else
                    {
                        commonHelp.displayField = dr["modelname"].ToString() + '.' + displayfield;
                        commonHelp.valueField   = dr["modelname"].ToString() + '.' + valuefield;
                    }
                    commonHelp.xtype      = xtype;
                    commonHelp.fieldLabel = label;
                    commonHelp.name       = fieldname;
                    list.Add(commonHelp);
                    continue;

                case "ngOrgHelp":
                    xtype = "ngOrgHelp";    //组织组件
                    break;

                case "ngProjectHelp":
                    xtype = "ngProjectHelp";    //项目组件
                    break;

                case "ngCustomFileHelp":
                    xtype = "ngCustomFileHelp";    //客户
                    break;

                case "ngSupplyFileHelp":
                    xtype = "ngSupplyFileHelp";    //供应商
                    break;

                case "ngEnterpriseHelp":
                    xtype = "ngEnterpriseHelp";    //往来单位
                    break;

                case "ngEmpHelp":
                    xtype = "ngEmpHelp";    //员工
                    break;

                case "WbsHelpField":
                    xtype = "WbsHelpField";    //wbs
                    break;

                case "ItemDataHelpField":
                    xtype = "ItemDataHelpField";    //物料帮助
                    break;

                case "CntInfoHelpField":
                    xtype = "CntInfoHelpField";    //合同帮助
                    break;

                //增加numberfield控件
                case "numberfield":
                    xtype = "numberfield";    //数字控件
                    break;

                default:
                    xtype = "ngText";
                    break;
                }

                col       = IndividualInfoFactory.GetControlInfo(xtype, fieldname, label, string.Empty, 100, 2);//内嵌查询最大长度100,2位小数
                col.value = dr["defaultdata"].ToString();
                list.Add(col);
            }

            #region 缓存处理
            //缓存起来
            HttpRuntime.Cache.Remove(cachedKey);//先remove
            HttpRuntime.Cache.Add(cachedKey,
                                  list,
                                  null,
                                  DateTime.Now.AddDays(1),
                                  Cache.NoSlidingExpiration,
                                  CacheItemPriority.NotRemovable,
                                  null);

            string time = DateTime.Now.ToString("yyyyMMddhhmmss");
            //时间戳本地缓存
            HttpRuntime.Cache.Remove(cachedTimeKey);//先remove
            HttpRuntime.Cache.Add(cachedTimeKey,
                                  time,
                                  null,
                                  DateTime.Now.AddDays(1),
                                  Cache.NoSlidingExpiration,
                                  CacheItemPriority.NotRemovable,
                                  null);

            NG.Cache.Client.CacheClient.Instance.Add(MAINKEY, cachedTimeKey, time);//外部缓存存放时间戳
            #endregion

            return(list);

            #endregion
        }