Пример #1
0
        protected virtual void CreateDefaultValue(IInputData input, DataSet dataSet)
        {
            if (string.IsNullOrEmpty(TableName) || fMetaData == null || input.Style.Style != PageStyle.Insert)
            {
                return;
            }

            ITableSchemeEx scheme = fMetaData.GetTableScheme(TableName);

            if (scheme == null)
            {
                return;
            }
            MetaDataTableResolver resolver = new MetaDataTableResolver(scheme, this);

            using (resolver)
            {
                //DataTable table = DataSetUtil.CreateDataTable(scheme.TableName, scheme.Fields);
                DataTable table = resolver.CreateVirtualTable(true);
                DataRow   row   = table.NewRow();
                table.Rows.Add(row);
                resolver.SetDefaultValue(input.QueryString);
                resolver.SetDefaultValue(row);
                resolver.FillCodeTable(input.Style);
                resolver.Decode(input.Style);
            }
        }
Пример #2
0
        private void PostData(IInputData input)
        {
            DataSet postDataSet                   = input.PostObject.Convert <DataSet>();
            FieldErrorInfoCollection errors       = new FieldErrorInfoCollection();
            MetaDataTableResolver    metaResolver = MainResolver as MetaDataTableResolver;

            if (metaResolver != null)
            {
                metaResolver.CheckFirstConstraints(input, errors);
            }
            switch (input.Style.Style)
            {
            case PageStyle.Insert:
                MainResolver.Insert(postDataSet, input);
                break;

            case PageStyle.Update:
                MainResolver.Update(postDataSet, input);
                break;
            }
            if (metaResolver != null)
            {
                metaResolver.CheckLaterConstraints(input, errors);
            }

            errors.CheckError();
        }
Пример #3
0
        //private void ParseSortParams(IInputData input, out string orderby, out int sort, out string order)
        //{
        //    sort = input.QueryString["Sort"].Value<int>(-1);
        //    order = null;
        //    if (sort == -1 || fListFields == null)
        //    {
        //        orderby = OrderBy;
        //        if (!string.IsNullOrEmpty(orderby) && fListFields != null)
        //        {
        //            int comma = orderby.IndexOf(',');
        //            string subOrder = comma >= 0 ? orderby.Substring(0, comma - 1) : orderby;
        //            sort = fListFields.FindIndex(field =>
        //                subOrder.IndexOf(field.FieldName, StringComparison.Ordinal) != -1);
        //            if (sort != -1 && subOrder.IndexOf("DESC", StringComparison.OrdinalIgnoreCase) != -1)
        //                order = "DESC";
        //        }
        //    }
        //    else
        //    {
        //        if (sort < 0 || sort >= fListFields.Count)
        //            sort = 0;
        //        order = input.QueryString["Order"].Value<string>(string.Empty);
        //        orderby = string.Format(ObjectUtil.SysCulture, "ORDER BY {0} {1}",
        //            fListFields[sort].FieldName, order);
        //    }
        //}

        private string SetGetListInfo(IInputData input, ParamBuilderContainer condition, ListSortInfo listInfo)
        {
            //string orderby;
            //int sort;
            //string order;
            var jsonOrder = ParseSortParams2(input);
            //ParseSortParams(input, out orderby, out sort, out order);
            string queryCon = input.QueryString[CONDITION_HEADER_NAME];

            if (!string.IsNullOrEmpty(queryCon))
            {
                queryCon = Uri.UnescapeDataString(queryCon);
                QueryCondition queryCondition = QueryCondition.FromEncodeString(queryCon);
                condition.Add(queryCondition.Builder);
                DataTable queryTable = queryCondition.QueryData.CreateTable("_QueryData");
                DataSet.Tables.Add(queryTable);

                MetaDataTableResolver metaResolver = MainResolver as MetaDataTableResolver;
                if (metaResolver != null)
                {
                    metaResolver.DecodeQueryTable(queryTable);
                }
            }
            PrepareConditionData(DataSet.Tables[QUERY_TABLE_NAME], input);

            //listInfo.SortField = sort;
            //listInfo.Order = order != "DESC" ? "ASC" : "DESC";
            listInfo.SqlCon = queryCon;
            string result = jsonOrder.ToSqlOrder(MainResolver);

            // 对于自定义排序,由于无法改变ASC和DESC,将在ToSqlOrder中重置,所以,这行代码要放在后面
            listInfo.JsonOrder = jsonOrder.ToJson();
            return(result);
        }
Пример #4
0
        public static string GetCondition(MetaDataTableResolver resolver, string nickName, string value)
        {
            TkDebug.AssertArgumentNullOrEmpty(nickName, "nickName", null);
            TkDebug.AssertArgumentNull(value, "value", null);

            return(GetCondition(resolver, Tuple.Create(nickName, value)));
        }
Пример #5
0
        private string SetPostListInfo(IInputData input, ParamBuilderContainer condition, ListSortInfo listInfo)
        {
            MetaDataTableResolver metaResolver = MainResolver as MetaDataTableResolver;

            if (metaResolver != null)
            {
                QueryConditionObject conditionData = input.PostObject.Convert <QueryConditionObject>();
                IParamBuilder        builder       = metaResolver.GetQueryCondition(conditionData);
                if (builder != null)
                {
                    QueryCondition queryCondition = new QueryCondition(conditionData.Condition, builder);
                    condition.Add(builder);
                    listInfo.SqlCon = queryCondition.ToEncodeString();
                }
            }
            if (SortQuery)
            {
                //string orderby;
                //int sort;
                //string order;
                var jsonOrder = ParseSortParams2(input);
                //ParseSortParams(input, out orderby, out sort, out order);
                //listInfo.SortField = sort;
                //listInfo.Order = order != "DESC" ? "ASC" : "DESC";
                listInfo.JsonOrder = jsonOrder.ToJson();

                return(jsonOrder.ToSqlOrder(MainResolver));
            }

            return(string.Empty);
        }
Пример #6
0
        protected override void DefaultUpdateAction(IInputData input)
        {
            base.DefaultUpdateAction(input);

            if (Operators != null && input.Style.Style == PageStyle.Detail)
            {
                if (MainResolver.HostTable.Rows.Count > 0)
                {
                    MakeOperateRight(input);
                }
            }

            MetaDataTableResolver metaResolver = MainResolver as MetaDataTableResolver;

            Decode(input, metaResolver);
            if (OneToOneTables != null)
            {
                foreach (var item in OneToOneTables)
                {
                    metaResolver = item.Resolver as MetaDataTableResolver;
                    Decode(input, metaResolver);
                }
            }
            if (FillDetailData)
            {
                foreach (var resolver in ChildResolvers)
                {
                    metaResolver = resolver as MetaDataTableResolver;
                    Decode(input, metaResolver);
                }
            }
        }
        protected override void DefaultUpdateAction(IInputData input)
        {
            ProcessFillingUpdateEvent(input);
            FillUpdateTables(input);

            FilledUpdateEventArgs e = new FilledUpdateEventArgs(input);

            OnFilledUpdateTables(e);

            if (SupportData)
            {
                foreach (DataRow row in MainResolver.HostTable.Rows)
                {
                    CheckDataRight(input, row);
                }
            }

            if (!input.IsPost)
            {
                MetaDataTableResolver metaResolver = MainResolver as MetaDataTableResolver;
                if (metaResolver != null)
                {
                    metaResolver.Decode(input.Style);

                    if (input.Style.Style == PageStyle.Update)
                    {
                        metaResolver.FillCodeTable(input.Style);
                    }
                }
            }
        }
Пример #8
0
        public override OutputData DoAction(IInputData input)
        {
            if (MainResolver != null)
            {
                IParamBuilder builder;
                if (FilterSql != null)
                {
                    builder = ParamBuilder.CreateSql(Expression.Execute(FilterSql, this));
                }
                else
                {
                    builder = ParamBuilder.CreateSql("1=1");
                }
                MainResolver.Select(builder, OrderBy);

                MetaDataTableResolver metaResolver = MainResolver as MetaDataTableResolver;
                if (metaResolver != null)
                {
                    metaResolver.Decode(input.Style);
                }
            }

            if (UseCallerInfo)
            {
                input.CallerInfo.AddInfo(DataSet);
            }

            return(OutputData.Create(DataSet));
        }
Пример #9
0
 protected override void OnReadMetaData(TableResolver resolver,
                                        IPageStyle style, ITableSchemeEx scheme)
 {
     fListFields = (from field in scheme.Fields
                    let tk5field = field.Convert <Tk5FieldInfoEx>()
                                   where IsListField(tk5field, style)
                                   orderby field.Control.GetOrder(style)
                                   select MetaDataTableResolver.GetSortField(field)).ToList();
 }
Пример #10
0
        private static void DecodeResolver(IInputData input, TableResolver resolver)
        {
            MetaDataTableResolver metaResolver = resolver as MetaDataTableResolver;

            if (metaResolver != null)
            {
                metaResolver.FillCodeTable(input.Style);
                metaResolver.Decode(input.Style);
            }
        }
Пример #11
0
        private static void Decode(IInputData input, MetaDataTableResolver metaResolver)
        {
            if (metaResolver != null)
            {
                metaResolver.Decode(input.Style);

                if (input.Style.Style == PageStyle.Update)
                {
                    metaResolver.FillCodeTable(input.Style);
                }
            }
        }
Пример #12
0
        private void PostData(IInputData input)
        {
            DataSet postDataSet             = input.PostObject.Convert <DataSet>();
            FieldErrorInfoCollection errors = new FieldErrorInfoCollection();
            var childResolvers = ChildResolvers.ToArray();
            MetaDataTableResolver metaResolver = MainResolver as MetaDataTableResolver;

            if (metaResolver != null)
            {
                metaResolver.CheckFirstConstraints(input, errors);
            }
            foreach (var item in childResolvers)
            {
                MetaDataTableResolver childResolver = item as MetaDataTableResolver;
                if (childResolver != null)
                {
                    childResolver.CheckFirstConstraints(input, errors);
                }
            }
            switch (input.Style.Style)
            {
            case PageStyle.Insert:
                MainResolver.Insert(postDataSet, input);
                foreach (var item in childResolvers)
                {
                    item.Insert(postDataSet, input);
                }
                break;

            case PageStyle.Update:
                MainResolver.Update(postDataSet, input);
                foreach (var item in childResolvers)
                {
                    item.Update(postDataSet, input);
                }
                break;
            }
            if (metaResolver != null)
            {
                metaResolver.CheckLaterConstraints(input, errors);
            }
            foreach (var item in childResolvers)
            {
                MetaDataTableResolver childResolver = item as MetaDataTableResolver;
                if (childResolver != null)
                {
                    childResolver.CheckLaterConstraints(input, errors);
                }
            }
            errors.CheckError();
        }
Пример #13
0
        protected void DoInsertAction(IInputData input)
        {
            DataTable table = MainResolver.CreateVirtualTable();
            DataRow   row   = table.NewRow();

            table.Rows.Add(row);
            MainResolver.SetDefaultValue(input.QueryString);
            MainResolver.SetDefaultValue(row);
            MetaDataTableResolver metaResolver = MainResolver as MetaDataTableResolver;

            if (metaResolver != null)
            {
                metaResolver.FillCodeTable(input.Style);
                metaResolver.Decode(input.Style);
            }
        }
Пример #14
0
        public static string GetCondition(MetaDataTableResolver resolver, params Tuple <string, string>[] conditions)
        {
            TkDebug.AssertArgumentNull(resolver, "resolver", null);
            TkDebug.AssertArgumentNull(conditions, "conditions", null);

            Dictionary <string, string> dict = new Dictionary <string, string>();

            foreach (var item in conditions)
            {
                dict[item.Item1] = item.Item2;
            }

            QueryConditionObject obj       = new QueryConditionObject(true, dict);
            IParamBuilder        builder   = resolver.GetQueryCondition(obj);
            QueryCondition       condition = new QueryCondition(dict, builder);

            return(condition.ToEncodeString());
        }
Пример #15
0
        protected override OutputData DoPost(IInputData input)
        {
            QueryConditionPostObject postObject = input.PostObject.Convert <QueryConditionPostObject>();
            TableResolver            resolver   = PlugInFactoryManager.CreateInstance <TableResolver>(
                ResolverPlugInFactory.REG_NAME, postObject.Resolver, this);

            using (resolver)
            {
                MetaDataTableResolver metaResolver = resolver as MetaDataTableResolver;
                if (metaResolver != null)
                {
                    IParamBuilder builder = metaResolver.GetQueryCondition(postObject.Query);
                    if (builder != null)
                    {
                        QueryCondition condition = new QueryCondition(postObject.Query.Condition, builder);
                        return(OutputData.Create(condition.ToEncodeString()));
                    }
                }
                return(OutputData.Create(string.Empty));
            }
        }
Пример #16
0
            public override OutputData DoAction(IInputData input)
            {
                Tk5ListMetaData metaData = fMetaData as Tk5ListMetaData;

                if (metaData != null)
                {
                    string tableName = metaData.Table.TableName;
                    var    scheme    = fMetaData.GetTableScheme(tableName);
                    MetaDataTableResolver resolver = new MetaDataTableResolver(scheme, this);
                    using (resolver)
                    {
                        DataTable table = resolver.CreateVirtualTable();
                        table.TableName = "Condition";
                        DataRow row = table.NewRow();
                        resolver.SetDefaultValue(row);
                        table.Rows.Add(row);
                        resolver.FillCodeTable((PageStyleClass)PageStyle.List);
                    }
                }

                return(OutputData.Create(DataSet));
            }
Пример #17
0
        protected override void DefaultUpdateAction(IInputData input)
        {
            base.DefaultUpdateAction(input);

            if (Operators != null && input.Style.Style == PageStyle.Detail)
            {
                if (MainResolver.HostTable.Rows.Count > 0)
                {
                    MakeOperateRight(input);
                }
            }
            MetaDataTableResolver metaResolver = MainResolver as MetaDataTableResolver;

            if (metaResolver != null)
            {
                metaResolver.Decode(input.Style);

                if (input.Style.Style == PageStyle.Update)
                {
                    metaResolver.FillCodeTable(input.Style);
                }
            }
        }