public HttpStreamRouter(IWebsiteRepository repository) { foreach (var website in repository.GetAll()) { if (!FactoryCache.ContainsKey(website.HostName)) { FactoryCache.Add(website.HostName, new ChannelFactory<IWebsiteAdapter>( new NetNamedPipeBinding() { MaxReceivedMessageSize = Int32.MaxValue }, new EndpointAddress(string.Format( "net.pipe://localhost/{0}", website.HostName)))); } } }
public WebsiteModel(IWebsiteRepository repository) { Websites = repository.GetAll(); }
public async Task <ApiResult <SaveWebSiteOutput> > SaveWebSite(SaveWebSiteInput input) { // 是否使用系统的配置 WhenUseSysAlipayPayment(input); WhenUseSysWeiXinPay(input); //todo:记日志 // 检查数据库中是否存在数据 var existedDatas = await _websiteRepository.GetAll() .Where(i => i.WebSiteKey == input.WebSiteKey || i.Id == input.Id) .Select(i => new { i.Id, i.WebSiteKey }).ToDynamicListAsync(); if (existedDatas.Any(i => i.Id == input.Id)) { throw new UserFriendlyException("站点Id已存在!"); } if (existedDatas.Any(i => i.WebSiteKey == input.WebSiteKey)) { throw new UserFriendlyException("订单Id前缀已存在!"); } // 创建站点管理员账号 // todo:管理员账号基础信息处理及角色分配 DateTime time = DateTime.Now; string userId = input.Id + time.ToString("yyyyMMddHHmmss") + RNG.Next(10).ToString().PadLeft(10, '0'); string safePassword = Guid.NewGuid().ToString("N").Substring(0, 6); // 创建站点 var siteFull = WebSiteFull.MapFrom(input); siteFull.WebSite.Id = input.Id; siteFull.WebSite.WebSiteMater = userId; var insertWebSiteTask = _siteFullRepository.InsertAsync(siteFull); // 创建站点管理员账号信息 var insertUserTask = _userRepository.InsertAsync(new Users { Id = userId, WebSiteId = input.Id, UserName = input.Loginname, LoginName = input.Loginname, EmailAddress = input.Email, Password = Encryptor.MD5Entry(safePassword), Safepassword = safePassword, IsActive = true, }); // 创建站点管理员附属信息(商务经理、省) var insertUserSysSettingTask = _userSysSettingRepository.InsertAsync(new UserSysSetting { Id = userId, Swfzr = input.WorkerName, Provinceid = input.PROVINCEID, WebSiteId = input.Id }); // 创建站点管理员的每月积分 var insertUserScoreTask = _userScoreRepository.InsertAsync(new UserScore { Id = userId, GivePointsPerMonth = input.GivePointsPerMonth, NotePrice = input.DefaultJfPrice, JfPrice = input.DefaultJfPrice }); await(insertWebSiteTask, insertUserTask, insertUserSysSettingTask, insertUserScoreTask); return(ApiResult.Success(new SaveWebSiteOutput { Safepassword = safePassword, LoginName = input.Loginname })); }