Пример #1
0
 public DictService(IDictFor dictFor, INameConverter nameConverter, DictSettings settings)
 {
     _dictFor            = dictFor;
     _db                 = DBFactory.CreateDBHelper("Default");
     _db.DbNameConverter = null; //不转换字典sql中输出的字段名
     _nameConverter      = nameConverter;
     _settings           = settings;
 }
Пример #2
0
        /// <summary>
        /// 控制台控制自动生成数据模型Json文件
        /// </summary>
        /// <param name="args">
        /// </param>
        static void Main(string[] args)
        {
            Startup();
            dictSettings = new DictSettings();
            var cfgSection = Consts.Config.GetSection("DictSettings");

            if (cfgSection.Exists())
            {
                dictSettings.CreateDict   = cfgSection.GetValue <bool>("CreateDict");
                dictSettings.CreateKeys   = cfgSection.GetValue <bool>("CreateKeys");
                dictSettings.CreateModels = cfgSection.GetValue <bool>("CreateModels");
                dictSettings.DictFile     = cfgSection.GetValue <string>("DictFile");
                dictSettings.ModelFile    = cfgSection.GetValue <string>("ModelFile");
                dictSettings.KeyFile      = cfgSection.GetValue <string>("KeyFile");
                dictSettings.TableReg     = cfgSection.GetValue <string>("TableReg");
                dictSettings.Tables       = cfgSection.GetValue <string>("Tables").ToStr().Split(",")
                                            .Select(t => t.ToStr())
                                            .Where(t => !t.IsEmpty()).ToArray();
            }
            if (!GetSettingsFromArgs(args))
            {
                return;
            }
            if (!cfgSection.Exists() && args.Length == 0)
            {
                Error("没有在配置文件appsettings.json中发现指定的生成信息,也没有在命令行参数中发现。");
                Usage();
            }
            IDictFor dict = Consts.Config.GetConnectionString("Default").Contains("DESCRIPTION", StringComparison.OrdinalIgnoreCase) ?
                            (IDictFor) new DictForOracle() : new DictForSqlServer();
            DictService dictService = new DictService(dict, new UpperNameConverter(), dictSettings);

            dictService.Run();
            Console.Write("执行完毕,按任意键退出");
#if DEBUG
            Console.ReadLine();
#endif
        }