/// <summary>
        /// 初始化
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnInit_Click(object sender, EventArgs e)
        {
            UpdateDBConnection();

            IDataInit service = GetService();

            if (null != service)
            {
                service.Init();
            }
        }
        /// <summary>
        /// 获取服务
        /// </summary>
        /// <returns></returns>
        private IDataInit GetService()
        {
            string combValue = this.combInitType.SelectedValue.ToString();

            if (combValue == "0")
            {
                MessageBox.Show("请选择要操作的数据类型");
                return(null);
            }

            DataInitType initType = (DataInitType)Enum.Parse(typeof(DataInitType), combValue);

            IDataInit service = null;

            switch (initType)
            {
            case DataInitType.AdPosition:
                service = new ADPositionInitService();
                break;

            case DataInitType.ApiAuthoriza:
                service = new ApiAuthorizaInitService();
                break;

            case DataInitType.AreaCity:
                service = new SystemAreaInitService();
                break;

            case DataInitType.DefaultTianDaoAdminAccount:
                service = new AdminAccountInitService();
                break;

            case DataInitType.Empirical:
                service = new EmpiricalInitService();
                break;

            case DataInitType.GlobalConfig:
                service = new GlobalConfigInitService();
                break;

            case DataInitType.Industry:
                service = new IndustryInitService();
                break;

            case DataInitType.Level:
                service = new UserLevelInitService();
                break;

            case DataInitType.Points:
                service = new PointsInitService();
                break;

            case DataInitType.ServiceCategory:
                service = new ServiceCategoryInitService();
                break;

            case DataInitType.ProductLibraryCategory:
                service = new ProductLibraryCategoryInitService();
                break;

            case DataInitType.MerchantGoodsSystemCategory:
                service = new MerchantGoodsSystemCategoryInitService();
                break;

            case DataInitType.JobCategory:
                service = new JobCategoryInitService();
                break;
            }

            return(service);
        }
Exemplo n.º 3
0
 public UserContext(DbContextOptions <UserContext> options, IDataInit dataInit)
     : base(options)
 {
     _dataInit = dataInit ?? throw new ArgumentNullException(nameof(dataInit));
 }