Ejemplo n.º 1
0
        /// <summary>
        /// 处理SELECT部分
        /// </summary>
        /// <param name="columnList"></param>
        /// <param name="table"></param>
        /// <param name="selectBuilder"></param>
        private void MakeSelectStarPartition(IEnumerable <FapColumn> columnList, AliasedSource aliaseSource, SelectBuilder select)
        {
            string tableAlias = aliaseSource.Alias;
            int    mcIndex    = 0;

            foreach (var column in columnList)
            {
                //AliasedSource table = select.AddTable(new Table($"{column.TableName}"), tableAlias);
                if (column.IsMultiLang == 1)
                {
                    if (IsGridQuery)
                    {
                        select.AddProjection(aliaseSource.Column($"{column.ColName}{CurrentLang}"), column.ColName);
                    }
                    else
                    {
                        select.AddProjection(aliaseSource.Column(column.ColName));
                    }
                    var langs = typeof(MultiLanguageEnum).EnumItems();
                    foreach (var lang in langs)
                    {
                        select.AddProjection(aliaseSource.Column($"{column.ColName}{lang.Value}"), $"{column.ColName}{lang.Value}");
                    }
                }
                else
                {
                    select.AddProjection(aliaseSource.Column(column.ColName));
                }
                if (this._withMC)
                {
                    //处理MC字段
                    if (FapColumn.CTRL_TYPE_COMBOBOX == column.CtrlType && !IsGridQuery)
                    {
                        string refAlias = "b" + (mcIndex++);
                        BuildFapDict(select, column, aliaseSource, refAlias);
                    }
                    else if (FapColumn.CTRL_TYPE_REFERENCE == column.CtrlType)
                    {
                        string refAlias = "b" + (mcIndex++);
                        BuildRefrenceName(select, column, aliaseSource, refAlias);
                    }
                }

                //处理MC字段的ID字段
                if (this._withId)
                {
                    if (FapColumn.CTRL_TYPE_REFERENCE == column.CtrlType)
                    {
                        string refAlias = "b" + (mcIndex++);
                        BuildRefrenceCode(select, column, aliaseSource, refAlias);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private static void BuildRefrenceCode(SelectBuilder select, FapColumn column, AliasedSource table, string refAlias)
        {
            string colName = column.RefCode;

            if (colName.IsPresent())
            {
                colName = "Id";
            }
            SelectBuilder inner      = new SelectBuilder();
            AliasedSource innerTable = inner.AddTable(new Table($"{column.RefTable}"), refAlias);

            inner.AddProjection(innerTable.Column($"{colName}"));
            if (column.MultiAble == 1) //是否多选
            {
            }
            FilterGroup joinFilter = new FilterGroup(Conjunction.And,
                                                     new EqualToFilter(innerTable.Column($"{column.RefID}"), table.Column(column.ColName)),
                                                     new LessThanEqualToFilter(innerTable.Column(FapDbConstants.FAPCOLUMN_FIELD_EnableDate), new ParameterLiteral(FapDbConstants.FAPCOLUMN_PARAM_CurrentDate)),
                                                     new GreaterThanEqualToFilter(innerTable.Column(FapDbConstants.FAPCOLUMN_FIELD_DisableDate), new ParameterLiteral(FapDbConstants.FAPCOLUMN_PARAM_CurrentDate)),
                                                     new EqualToFilter(innerTable.Column(FapDbConstants.FAPCOLUMN_FIELD_Dr), new ParameterLiteral(FapDbConstants.FAPCOLUMN_PARAM_Dr)));

            if (column.RefTable.EqualsWithIgnoreCase(nameof(FapColumn)))
            {
                IFilter filter = new EqualToFilter(innerTable.Column("TableName"), table.Column("TableName"));
                joinFilter.AddFilter(filter);
            }
            inner.AddWhere(joinFilter);
            select.AddProjection(inner, $"{column.ColName}MCID");
        }
Ejemplo n.º 3
0
        private static void BuildRefrenceName(SelectBuilder select, FapColumn column, AliasedSource table, string refAlias)
        {
            SelectBuilder inner      = new SelectBuilder();
            AliasedSource innerTable = inner.AddTable(new Table($"{column.RefTable}"), refAlias);

            inner.AddProjection(innerTable.Column($"{column.RefName}"));

            FilterGroup joinFilter = new FilterGroup(Conjunction.And,
                                                     new EqualToFilter(innerTable.Column($"{column.RefID}"), table.Column(column.ColName)),
                                                     new LessThanEqualToFilter(innerTable.Column(FapDbConstants.FAPCOLUMN_FIELD_EnableDate), new ParameterLiteral(FapDbConstants.FAPCOLUMN_PARAM_CurrentDate)),
                                                     new GreaterThanEqualToFilter(innerTable.Column(FapDbConstants.FAPCOLUMN_FIELD_DisableDate), new ParameterLiteral(FapDbConstants.FAPCOLUMN_PARAM_CurrentDate)),
                                                     new EqualToFilter(innerTable.Column(FapDbConstants.FAPCOLUMN_FIELD_Dr), new ParameterLiteral(FapDbConstants.FAPCOLUMN_PARAM_Dr)));

            if (column.RefTable.EqualsWithIgnoreCase(nameof(FapColumn)))
            {
                //fapcolumn存在重复colName,加一个去重
                IFilter filter = new EqualToFilter(innerTable.Column("TableName"), table.Column("RefTable"));
                joinFilter.AddFilter(filter);
            }
            inner.AddWhere(joinFilter);
            select.AddProjection(inner, $"{column.ColName}MC");
        }
Ejemplo n.º 4
0
        private static void BuildFapDict(SelectBuilder select, FapColumn column, AliasedSource table, string refAlias)
        {
            SelectBuilder inner      = new SelectBuilder();
            AliasedSource innerTable = inner.AddTable(new Table("FapDict"), refAlias);

            inner.AddProjection(innerTable.Column("Name"));
            if (column.MultiAble == 1) //是否多选
            {
            }
            FilterGroup joinFilter = new FilterGroup(Conjunction.And,
                                                     new EqualToFilter(innerTable.Column("Code"), table.Column(column.ColName)),
                                                     new EqualToFilter(innerTable.Column("Category"), new StringLiteral(column.ComboxSource)),
                                                     new LessThanEqualToFilter(innerTable.Column(FapDbConstants.FAPCOLUMN_FIELD_EnableDate), new ParameterLiteral(FapDbConstants.FAPCOLUMN_PARAM_CurrentDate)),
                                                     new GreaterThanEqualToFilter(innerTable.Column(FapDbConstants.FAPCOLUMN_FIELD_DisableDate), new ParameterLiteral(FapDbConstants.FAPCOLUMN_PARAM_CurrentDate)),
                                                     new EqualToFilter(innerTable.Column(FapDbConstants.FAPCOLUMN_FIELD_Dr), new ParameterLiteral(FapDbConstants.FAPCOLUMN_PARAM_Dr)));

            inner.AddWhere(joinFilter);
            select.AddProjection(inner, $"{column.ColName}MC");
            if (column.MultiAble == 1) //是否多选
            {
                //selectBuilder.Append(" for xml path('')"); // 逗号分隔的字符串,比如,以“aaa,bbb,ccc,”显示
            }
        }