protected override DataTable FetchRows(TkDbContext context, DataSet dataSet,
                                               IParamBuilder builder, int topCount)
        {
            SqlSelector selector = new SqlSelector(context, dataSet);

            using (selector)
            {
                IParamBuilder addBuilder = CreateAdditionCondition(context, fScheme);
                builder = ParamBuilder.CreateParamBuilder(builder, addBuilder);
                string whereSql;
                if (builder == null)
                {
                    whereSql = string.Empty;
                }
                else
                {
                    whereSql = "WHERE " + builder.Sql;
                }

                TableSchemeData schemeData = TableSchemeData.Create(context, fScheme);
                var             result     = context.ContextConfig.GetListSql(schemeData.SelectFields,
                                                                              GetTableName(context), schemeData.KeyFieldArray,
                                                                              whereSql, OrderBy, 0, topCount);
                ISimpleAdapter adapter = selector;
                adapter.SetSql(result.ListSql, builder);
                context.ContextConfig.SetListData(result, adapter, dataSet, 0, TopCount, EASYSEARCH_TABLE_NAME);

                return(dataSet.Tables[EASYSEARCH_TABLE_NAME]);
            }
        }
        protected override IParamBuilder GetRefParamBuilder(TkDbContext context, List <EasySearchRefField> refFields)
        {
            if (refFields == null || refFields.Count == 0)
            {
                return(null);
            }

            var builders = from item in refFields
                           select CreateRefBuilder(context, item);

            return(ParamBuilder.CreateParamBuilder(builders));
        }
Beispiel #3
0
        public override OutputData DoAction(IInputData input)
        {
            DateTime      current    = DateTime.Today;
            DateTime      firstMonth = new DateTime(current.Year, current.Month, 1);
            DateTime      endMonth   = firstMonth.AddMonths(1);
            TkDbContext   context    = Context;
            FieldItem     field      = new FieldItem("WM_SEND_DATE", TkDataType.DateTime);
            IParamBuilder builder    = ParamBuilder.CreateParamBuilder(
                SqlParamBuilder.CreateSingleSql(context, field, ">=", firstMonth),
                SqlParamBuilder.CreateSingleSql(context, field, "<", "WM_SEND_DATE1", endMonth));
            int count = DbUtil.ExecuteScalar("SELECT COUNT(*) FROM CS_WEIXIN_MASS", context, builder)
                        .Value <int>();

            return(OutputData.Create(count.ToString()));
        }
Beispiel #4
0
        public override IEnumerable <IDecoderItem> Search(SearchField field,
                                                          string text, List <EasySearchRefField> refFields)
        {
            IFieldInfo fieldName = null;

            switch (field)
            {
            case SearchField.Value:
            case SearchField.DefaultValue:
                fieldName = ValueField;
                break;

            case SearchField.Name:
                fieldName = NameField;
                break;

            case SearchField.Pinyin:
                fieldName = PinyinField ?? NameField;
                break;
            }
            TkDbContext context = string.IsNullOrEmpty(ContextName) ? DbContextUtil.CreateDefault()
                : DbContextUtil.CreateDbContext(ContextName);

            using (context)
            {
                IParamBuilder builder = SearchMethod.Search(this, field, context, fieldName, text);
                if (refFields != null && refFields.Count > 0)
                {
                    IParamBuilder refBuilder = GetRefParamBuilder(context, refFields);
                    builder = ParamBuilder.CreateParamBuilder(builder, refBuilder);
                }
                DataTable table = FetchRows(context, fDataSet, builder, TopCount);
                if (table == null || table.Rows.Count == 0)
                {
                    return(null);
                }

                List <IDecoderItem>  result  = new List <IDecoderItem>(table.Rows.Count);
                DataColumnCollection columns = table.Columns;
                foreach (DataRow row in table.Rows)
                {
                    result.Add(new DataRowDecoderItem(columns, row,
                                                      DecoderConst.CODE_NICK_NAME, fExpression, fDisplayExpression));
                }
                return(result);
            }
        }