예제 #1
0
        /// <summary>
        /// 从取值对象中获得属性,从条件对象中获得值
        /// </summary>
        /// <param name="valObj"></param>
        /// <param name="condObj"></param>
        /// <returns></returns>
        public List <DataBaseField> Parse(ITableImplement valObj, ITableImplement condObj)
        {
            List <DataBaseField> list2 = new List <DataBaseField>();
            List <AttributeItem> list  = new List <AttributeItem>();

            list.AddRange(valObj.af_GetAvailableAttributeItem());
            if (list.Count == 0)
            {
                list.AddRange(valObj.af_AttributeItemList);
            }

            string tbName = valObj._TableName.ToLower();

            if (tbName == ITableImplement.defaultTableName.ToLower())
            {
                tbName = list[0].TableName;
            }
            #region 表操作
            DataBaseTable dt1 = null;
            dt1 = Runtime_PersistenceLayer.Factory(conn).DataBase.DataTables[tbName];
            if (dt1 == null)
            {
                ConsoleService.Warn(tbName + " 数据表不存在");
                return(new List <DataBaseField>());
            }
            #endregion

            foreach (AttributeItem item in list)
            {
                string fieldName = item.FieldName.ToLower();
                #region 列操作
                DataBaseField f1 = null;
                if (!dt1.DataFields.TryGetValue(fieldName, out f1))
                {
                    ConsoleService.Warn(string.Format("数据表{0},数据字段{1}不存在", tbName, fieldName));
                    continue;
                }
                if (f1.Desc.CtrlType == BaseCtrlType.Text || f1.Desc.CtrlType == BaseCtrlType.HTML ||
                    f1.Desc.CtrlType == BaseCtrlType.SmallText)
                {
                    continue;
                }
                if (condObj != null && condObj.IsNotNull())
                {
                    f1.Value = condObj.GetString(item);
                }
                #endregion
                list2.Add(f1);
            }
            return(list2);
        }
예제 #2
0
        /// <summary>
        /// TF_FORM 从配置中获得表单布局
        /// </summary>
        /// <param name="conn"></param>
        /// <param name="cond"></param>
        /// <returns></returns>
        public bool Parse(TF_TABLE cond,
                          out ITableImplement valObj, out ITableImplement condObj, out List <Relation> relationList, out List <ITableImplement> otherValueList,
                          out List <ITableImplement> condList, ref string msg)
        {
            valObj  = new ITableImplement();
            condObj = new ITableImplement();
            //载入关系
            otherValueList = new List <ITableImplement>();
            condList       = new List <ITableImplement>();
            relationList   = new List <Relation>();

            msg = "条件不存在";
            if (string.IsNullOrEmpty(cond.TB_NAME))
            {
                return(false);
            }

            DataBaseTable        tb1;
            List <DataBaseField> listf1  = new List <DataBaseField>();
            List <DataBaseTable> listTb1 = new List <DataBaseTable>();


            bool ret = true; tb1 = null;
            //TF_TABLE val = BLLTable<TF_TABLE>.Factory(conn).GetRowData(new TF_TABLE(), cond);

            TF_TB_FIELD val1 = new TF_TB_FIELD();
            TF_F_COLUMN val2 = new TF_F_COLUMN();
            TF_TABLE    val3 = new TF_TABLE();

            TF_TB_FIELD            cond1           = new TF_TB_FIELD();
            TF_F_COLUMN            cond2           = new TF_F_COLUMN();
            TF_FORM                cond3           = new TF_FORM();
            List <ITableImplement> otherValueList1 = new List <ITableImplement>();
            List <ITableImplement> condList1       = new List <ITableImplement>();

            otherValueList1.Add(val2); otherValueList1.Add(val3);

            condList1.Add(cond);
            List <Relation> relationList1 = new List <Relation>();

            relationList1.Add(RelationFactory.TF_TABLE_TF_FORM);
            relationList1.Add(RelationFactory.TF_TABLE_TF_TB_FIELD);
            relationList1.Add(RelationFactory.TF_TB_FIELD_TF_F_COLUMN);

            int                pageSize  = 100;
            int                pageIndex = 1;
            int                recount   = -1;
            string             cachekey  = null;
            List <TF_TB_FIELD> list1     = BLLTable <TF_TB_FIELD> .Factory(conn).SelectByPage(val1, relationList1, otherValueList1, condList1,
                                                                                              pageSize, pageIndex, ref recount, out cachekey);

            if (list1.Count == 0)
            {
                DataBaseTable dt1 = null;
                dt1 = Runtime_PersistenceLayer.Factory(conn).DataBase.DataTables[cond.TB_NAME];
                msg = cond.TB_NAME + " 数据表不存在";
                if (dt1 == null)
                {
                    ret = false;
                    ConsoleService.Warn(msg);
                }
                return(ret);
            }
            if (list1.Count > 90)
            {
                msg = "条件错误,所配置的字段记录超过90";
                return(false);
            }
            //生成布局模版用
            tb1 = new DataBaseTable();
            foreach (TF_TB_FIELD item in list1)
            {
                string tbName = Convert.ToString(item.GetValue(TF_TABLE.Attribute.TB_NAME)).ToLower();
                #region 表操作
                DataBaseTable dt1 = null;
                dt1 = Runtime_PersistenceLayer.Factory(conn).DataBase.DataTables[tbName];
                msg = tbName + " 数据表不存在"; ret = false;
                if (dt1 == null)
                {
                    ConsoleService.Warn(msg);
                    return(ret);
                }
                tb1 = dt1;
                listTb1.Add(dt1);
                //是否显示
                object obj1 = null;
                object obj2 = null;
                object obj3 = null;
                if (item.TryGetValue(TF_FORM.Attribute.FORM_ID, out obj1))
                {
                    dt1.IsVisable = true;
                }

                #endregion
                string fieldName = item.FIELD_NAME.ToLower();
                #region 列操作
                DataBaseField f1 = null;
                msg = string.Format("数据表{0},数据字段{1}不存在", tbName, fieldName);
                if (!dt1.DataFields.TryGetValue(fieldName, out f1))
                {
                    ret = false;
                    ConsoleService.Warn(msg);
                    continue;
                }
                //是否显示
                obj1 = null; obj2 = null; obj3 = null;
                if (item.TryGetValue(TF_F_COLUMN.Attribute.COLUMN_ID, out obj1) &&
                    item.TryGetValue(TF_F_COLUMN.Attribute.SHOW_NAME, out obj2) &&
                    item.TryGetValue(TF_F_COLUMN.Attribute.CTRL_TYPE, out obj3))
                {
                    //f1.IsVisable = true;
                }
                #endregion
                listf1.Add(f1);
            }
            //取值对象
            valObj = ITableImplement.Factory(tb1);
            //其他取值对象
            foreach (DataBaseTable tb2 in listTb1)
            {
                if (tb2.TableName == tb1.TableName)
                {
                    continue;
                }
                otherValueList.Add(ITableImplement.Factory(tb2));
            }
            //关系呢
            return(ret);
        }