public override OutputData DoAction(IInputData input)
        {
            string context = input.QueryString["Context"];

            if (!string.IsNullOrEmpty(context))
            {
                Context = DbContextUtil.CreateDbContext(context);
            }
            AttachmentResolver resolver = new AttachmentResolver(this);

            using (resolver)
            {
                DataRow     row        = resolver.Query(input.QueryString);
                bool        noFileName = input.QueryString["NoFileName"].Value <bool>();
                FileContent content;

                if (noFileName)
                {
                    content = new FileContent(row["ContentType"].ToString(), (byte[])row["Content"]);
                }
                else
                {
                    content = new FileContent(row["ContentType"].ToString(),
                                              row["OriginalName"].ToString(), (byte[])row["Content"]);
                }
                return(OutputData.Create(content));
            }
        }
Esempio n. 2
0
        internal TreeSource(ITreeCreator creator)
        {
            if (!string.IsNullOrEmpty(creator.Context))
            {
                Context = DbContextUtil.CreateDbContext(creator.Context);
            }

            Tree = creator.CreateTree(this);
        }
Esempio n. 3
0
 public SqlSource(string contextName, bool useCallerInfo, string successMessage)
 {
     if (!string.IsNullOrEmpty(contextName))
     {
         Context = DbContextUtil.CreateDbContext(contextName);
     }
     UseCallerInfo  = useCallerInfo;
     SuccessMessage = successMessage;
 }
Esempio n. 4
0
        protected void SetConfig(IBaseDbConfig config)
        {
            TkDebug.AssertArgumentNull(config, "config", this);

            if (!string.IsNullOrEmpty(config.Context))
            {
                Context = DbContextUtil.CreateDbContext(config.Context);
            }
        }
Esempio n. 5
0
        internal SwitchFieldSource(SwitchFieldSourceConfig config)
        {
            if (!string.IsNullOrEmpty(config.Context))
            {
                Context = DbContextUtil.CreateDbContext(config.Context);
            }

            Resolver = config.Resolver.CreateObject(this);
            Switch   = config.Switch;
        }
Esempio n. 6
0
            public StdCodeTableDetailSource(StdCodeTableSourceConfig config, string tableName)
            {
                if (!string.IsNullOrEmpty(config.Context))
                {
                    Context = DbContextUtil.CreateDbContext(config.Context);
                }

                MainResolver = config.CreateTableRsolver(this, tableName);
                UseMetaData  = false;
            }
Esempio n. 7
0
            public StdCodeTableDeleteSource(StdCodeTableSourceConfig config, string tableName)
            {
                if (!string.IsNullOrEmpty(config.Context))
                {
                    Context = DbContextUtil.CreateDbContext(config.Context);
                }

                MainResolver = config.CreateTableRsolver(this, tableName);
                fTableName   = tableName;
            }
Esempio n. 8
0
        public ISource CreateObject(params object[] args)
        {
            CodeTableSource source = new CodeTableSource(RegName);

            if (!string.IsNullOrEmpty(Context))
            {
                source.Context = DbContextUtil.CreateDbContext(Context);
            }

            return(source);
        }
Esempio n. 9
0
        public TableResolver CreateObject(params object[] args)
        {
            IDbDataSource source  = ObjectUtil.ConfirmQueryObject <IDbDataSource>(this, args);
            TkDbContext   context = string.IsNullOrEmpty(Context) ? DbContextUtil.CreateDefault()
                : DbContextUtil.CreateDbContext(Context);

            using (context)
            {
                var scheme   = DbUtil.CreateSqlTableScheme(Sql, TableName, KeyFields, context);
                var schemeEx = MetaDataUtil.ConvertToTableSchemeEx(scheme);
                return(new SqlTableResolver(Sql, schemeEx, source));
            }
        }
Esempio n. 10
0
            public StdCodeTableListSource(StdCodeTableSourceConfig config, string tableName)
            {
                if (!string.IsNullOrEmpty(config.Context))
                {
                    Context = DbContextUtil.CreateDbContext(config.Context);
                }

                MainResolver = config.CreateTableRsolver(this, tableName);
                UseMetaData  = false;
                PageSize     = int.MaxValue;
                SortQuery    = true;
                OrderBy      = "ORDER BY " + DecoderConst.DEFAULT_ORDER;
                if (config.UseQueryString)
                {
                    var operators = new StandardOperatorsConfig
                    {
                        Right = new SimpleListOperateRightConfig {
                            Operators = UpdateKind.All
                        },
                        Operators = new List <IConfigCreator <OperatorConfig> >()
                    };
                    var url = new MarcoConfigItem(true, true,
                                                  string.Format("~/c/{{ModuleCreator}}/insert/{{CcSource}}?{0}={{#{0}}}", config.TableName));
                    operators.Operators.Add(new OperatorConfig(RightConst.INSERT, "新建", OperatorPosition.Global,
                                                               "Dialog", null, "icon-plus", url));
                    url = new MarcoConfigItem(true, true,
                                              string.Format("~/c/{{ModuleCreator}}/update/{{CcSource}}?{0}={{#{0}}}", config.TableName));
                    operators.Operators.Add(new OperatorConfig(RightConst.UPDATE, "修改", OperatorPosition.Row,
                                                               "Dialog", null, "icon-edit", url)
                    {
                        UseKey = true
                    });
                    operators.Operators.Add(OperatorConfig.DeleteOperator);
                    Operators = operators;
                }
                else
                {
                    var    pinyinOper = config.AutoPinyin ? DataString.AutoPinyinOperator : string.Empty;
                    string oper       = string.Format(ObjectUtil.SysCulture, DataString.StdCodeOperators, pinyinOper);
                    var    operators  = oper.ReadXmlFromFactory
                                        <IConfigCreator <IOperatorsConfig> >(OperatorsConfigFactory.REG_NAME);
                    Operators = operators.CreateObject();
                }
            }