/// <summary> /// 程式定義轉資料表定義 /// </summary> /// <param name="progDefine"></param> /// <returns></returns> public static IEnumerable<GDbTableDefine> ProgDefineToDbTableDefine(GProgramDefine progDefine) { foreach (GTableDefine tableDefine in progDefine.Tables) { var dbDefine = new GDbTableDefine { ProgID = progDefine.ProgID, TableName = tableDefine.DbTableName, DisplayName = tableDefine.DisplayName }; foreach (var field in tableDefine.Fields.Where(x => x.FieldType == Base.EFieldType.DataField)) dbDefine.Fields.Add(new GDbFieldDefine(field)); yield return dbDefine; } }
/// <summary> /// 解析並移除不需要的 [欄位變數] 過濾條件。 /// </summary> /// <param name="programDefine">程式定義。</param> public GFilterItemCollection ParseRemoveField(GProgramDefine programDefine) { GFilterItemCollection oFilterItems; GFilterItem oFilterItem; GFieldDefine oFieldDefine; EVariableType oVariableType; string sTableName; string sFieldName; oFilterItems = new GFilterItemCollection(); foreach (GFilterItem item in this.FilterItems) { // 產生過濾條件複本 oFilterItem = item.Clone(); // 解析變數值 this.VariableParser.Parse(item.FilterValue); // 變數類型 oVariableType = this.VariableParser.VariableType; if (oVariableType == EVariableType.Field || oVariableType == EVariableType.TableField) { // 拆解字串的資料表名稱及欄位名稱 StrFunc.StrSplitFieldName(this.VariableParser.Value, out sTableName, out sFieldName); if (StrFunc.StrIsEmpty(sTableName)) { sTableName = programDefine.ProgID; } // 只保留存在的 [欄位變數] 過濾條件 oFieldDefine = programDefine.FindField(sTableName, sFieldName); if (BaseFunc.IsNotNull(oFieldDefine)) { oFilterItems.Add(oFilterItem); } } else { // 加入非 [欄位變數] 過濾條件 oFilterItems.Add(oFilterItem); } } // 移除無查詢值的條件 oFilterItems.RemoveEmpty(); return(oFilterItems); }
/// <summary> /// 建構函式。 /// </summary> /// <param name="programDefine">程式定義。</param> public GTableDefineCollection(GProgramDefine programDefine) : base(programDefine) { }