Beispiel #1
0
 protected void Application_Start()
 {
     RegisterConfig.RegisterDependencies();
     BundleConfig.RegisterBundles(BundleTable.Bundles);
     AreaRegistration.RegisterAllAreas();
     RouteConfig.RegisterRoutes(RouteTable.Routes);
 }
Beispiel #2
0
        static async Task Main(string[] args)
        {
            await RegisterConfig.InitConfig();

start_build_code:
            Console.WriteLine("是否要指定表生成,请选择选项:");
            Console.WriteLine("0:生成所有表,1:指定表生成");
            var is_table = Console.ReadLine();
            var tableStr = string.Empty;

            if (is_table.Equals("1"))
            {
startInPutTable:
                Console.WriteLine("请输入要构建的表名称以“,”隔开:");
                tableStr = Console.ReadLine();
                try
                {
                    tableStr.Split(',');
                }
                catch (Exception)
                {
                    Console.WriteLine("格式不正确");
                    goto startInPutTable;
                }
            }

            Console.WriteLine("是否要指定模板生成(FileDirName):");
            Console.WriteLine("0:生成所有模板,1:指定模板生成");
            var is_template = Console.ReadLine();
            var templateStr = string.Empty;

            if (is_template.Equals("1"))
            {
startInPutTable:
                Console.WriteLine("请输入要构建的模板文件夹名称(FileDirName)以“,”隔开:");
                templateStr = Console.ReadLine();
                try
                {
                    templateStr.Split(',');
                }
                catch (Exception)
                {
                    Console.WriteLine("格式不正确");
                    goto startInPutTable;
                }
            }

            var path = await new BuildModels().BuildStart(tableStr, templateStr);

            Console.WriteLine("输出文件路径:" + path);
            Console.WriteLine("是否从新开始:0:1");
            if (Console.ReadLine().Equals("1"))
            {
                goto start_build_code;
            }
        }
Beispiel #3
0
        public async Task <IActionResult> Index()
        {
            RegisterConfig config = await this.configService.GetConfigAsync <RegisterConfig>();

            InviteIndexModel model = new InviteIndexModel {
                IsEnableInviteCode = config.IsEnableInviteCode
            };

            return(View(model));
        }
Beispiel #4
0
 /// <summary>
 /// 启用或禁止邀请码注册
 /// </summary>
 public async Task ChangeCodeRegister(bool isEnableInviteCode)
 {
     using (var work = this.dbFactory.StartWork())
     {
         RegisterConfig config = new RegisterConfig {
             IsEnableInviteCode = isEnableInviteCode
         };
         await work.Config.SetConfigAsync <RegisterConfig>(config);
     }
 }
Beispiel #5
0
 public RegisterEditViewModel GetRegisterEditViewModel(RegisterConfig register)
 {
     return(new RegisterEditViewModel()
     {
         Id = register.Id,
         Title = register.Title,
         Type = register.Type,
         Offset = register.Offset,
         Count = register.Count
     });
 }
Beispiel #6
0
        public void RegisterLocalTest()
        {
            RegisterConfig registerConfig = new RegisterConfig();

            registerConfig.ConfigAll();

            IFactory factory = registerConfig.Factory;

            Assert.IsInstanceOfType(factory.GetInstance <IPeople>(), typeof(IPeople));
            Assert.IsInstanceOfType(factory.GetInstance <ICustomer>("2"), typeof(Customer2));
            Assert.IsInstanceOfType(factory.GetInstance <IMaintenance <object> >("2"), typeof(Customer2));
        }
Beispiel #7
0
        public void RegisterManualLocalTests()
        {
            RegisterConfig registerConfig = new RegisterConfig();

            registerConfig.Config(cfg =>
            {
                cfg.Register <ICustomer, Customer2>();
                cfg.Register <IMaintenance <object>, Customer2>();
            });

            var t = registerConfig.Factory.GetInstance <ICustomer>((object)"Renato");

            IFactory factory = registerConfig.Factory;

            Assert.ThrowsException <InstanceForFacadeNotFoundException>(() => factory.GetInstance <IPeople>());
            Assert.ThrowsException <InstanceForFacadeNotFoundException>(() => factory.GetInstance <ICustomer>("2"));
            Assert.IsInstanceOfType(factory.GetInstance <IMaintenance <object> >(), typeof(Customer2));
        }
Beispiel #8
0
        public async Task <IActionResult> Register()
        {
            if (User.Identity.IsAuthenticated)
            {
                return(this.RedirectToAction("ContinueLogout"));
            }
            else
            {
                AccountRegisterModel model  = new AccountRegisterModel();
                RegisterConfig       config = await this.siteConfigService.GetConfigAsync <RegisterConfig>();

                PageConfig pageConfig = await this.siteConfigService.GetConfigAsync <PageConfig>();

                model.IsEnableInviteCode = config.IsEnableInviteCode;
                model.AlertMsg           = pageConfig.RegisterAlert;
                model.SiteName           = (await this.siteConfigService.GetHomeConfigAsync()).SiteName;
                return(this.View(model));
            }
        }
Beispiel #9
0
 /// <summary>
 /// 设置注册选项
 /// </summary>
 public async Task <int> SetRegisterConfigAsync(RegisterConfig register, DbTransaction transaction = null)
 {
     return(await this.SetConfigAsync <RegisterConfig>(register, transaction));
 }
Beispiel #10
0
 void Draw(ConfigManager config, string title, RegisterConfig register)
 {
     EditorGUILayout.LabelField("'".Multiply(500), EditorStyles.miniBoldLabel);
     EditorGUILayout.LabelField(title, EditorStyles.boldLabel);
     Draw(config, register);
 }
Beispiel #11
0
 void Draw(ConfigManager config, RegisterConfig register)
 {
     register(config);
     EditorGUILayout.Space();
 }
Beispiel #12
0
        /// <summary>
        /// 注册用户
        /// </summary>
        public async Task <Person> Register(AccountRegisterModel model)
        {
            if (model == null)
            {
                throw new ArgumentNullException(nameof(model));
            }
            using (UnitOfWork work = this.dbFactory.StartWork())
            {
                RegisterConfig config = await work.Config.GetRegisterConfigAsync();

                #region 检查邀请码
                if (config.IsEnableInviteCode)
                {
                    if (string.IsNullOrWhiteSpace(model.InviteCode))
                    {
                        throw new ModelException(nameof(model.InviteCode), "请填写邀请码");
                    }
                    else
                    {
                        string inputCode = model.InviteCode.Trim();
                        if (!(await work.InviteCode.IsExistCodeAsync(inputCode)))
                        {
                            throw new ModelException(nameof(model.InviteCode), "该邀请码不存在,请重新输入");
                        }
                    }
                }
                #endregion
                #region 检查账户
                if (model.UserName.ToLower().Contains("admin"))
                {
                    throw new ModelException(nameof(model.UserName), "该账户被系统保留,禁止使用该名称");
                }
                if (await work.Person.IsExistNameAsync(model.UserName))
                {
                    throw new ModelException(nameof(model.UserName), "该账户已被注册");
                }
                #endregion
                Role role = await work.Role.GetSingleAsync(Enums.RoleType.User);

                DateTime now = DateTime.Now;
                using (var trans = work.BeginTransaction())
                {
                    try
                    {
                        Person person = new Person
                        {
                            Id          = GuidHelper.CreateSequential(),
                            AccountName = model.UserName.Trim(),
                            CreateTime  = now,
                            LastUpdated = now,
                            NickName    = model.UserName.Trim(),
                            RoleId      = role.Id,
                            Password    = this.encryptService.PasswordHash(model.Password),
                            Avatar      = GlobalVariable.DefaultAvatar
                        };
                        await work.Person.InsertAsync(person, trans);

                        PersonData personData = new PersonData()
                        {
                            Id         = GuidHelper.CreateSequential(),
                            AnswerNum  = 0,
                            ArticleNum = 0,
                            AskNum     = 0,
                            LikeNum    = 0,
                            PersonId   = person.Id,
                            Score      = 0
                        };
                        await work.PersonData.InsertAsync(personData, trans);

                        trans.Commit();
                        return(person);
                    }
                    catch (Exception)
                    {
                        trans.Rollback();
                        throw;
                    }
                }
            }
        }
Beispiel #13
0
	void Draw(ConfigManager config, string title, RegisterConfig register)
	{
		EditorGUILayout.LabelField("'".Multiply(500), EditorStyles.miniBoldLabel);
		EditorGUILayout.LabelField(title, EditorStyles.boldLabel);
		Draw(config, register);
	}
Beispiel #14
0
	void Draw(ConfigManager config, RegisterConfig register)
	{
		register(config);
		EditorGUILayout.Space();
	}
 public async Task Remove(RegisterConfig register)
 {
     _unitOfWork.RegistersRepository.Delete(register);
     await _unitOfWork.SaveChangesAsync();
 }
 public async Task Create(RegisterConfig register)
 {
     _unitOfWork.RegistersRepository.Insert(register);
     await _unitOfWork.SaveChangesAsync();
 }