//关于缓存期限: //1、用户邀请码配额 使用CachingExpirationType.SingleObject //2、邀请码实体、列表 使用CachingExpirationType.SingleObject、ObjectCollection //3、邀请好友记录列表 使用CachingExpirationType.ObjectCollection #region 邀请码 //done:zhengw,by mazq 方法名不好理解 或者直接与上一个方法合并叫 GetInvitationCode(long userId) 有什么问题? //zhengw回复:已修改 /// <summary> /// 获取邀请码 /// </summary> /// <param name="userId">申请人</param> public string GetInvitationCode(long userId) { //回复:我本身也没有判断吧。 string code = EncryptionUtility.MD5_16(userId.ToString() + DateTime.UtcNow.Ticks.ToString()); InviteFriendSettings inviteFriendSettings = inviteFriendSettingsManager.Get(); if (inviteFriendSettings.AllowInvitationCodeUseOnce) { InvitationCodeStatistic invitationCodeStatistic = GetUserInvitationCodeStatistic(userId); //如果配额够用的 if (ChangeUserInvitationCodeCount(userId, -1, 1, 1)) { InvitationCode invitationCode = new InvitationCode { Code = code, DateCreated = DateTime.UtcNow, ExpiredDate = DateTime.UtcNow.AddDays(inviteFriendSettings.InvitationCodeTimeLiness), IsMultiple = !inviteFriendSettings.AllowInvitationCodeUseOnce, UserId = userId }; invitationCodesRepository.Insert(invitationCode); } else { code = string.Empty; } //1.用户未使用邀请码配额减1,然后调用ChangeUserInvitationCodeCount进行更新 //2.过期时间根据InviteFriendSettings.InvitationCodeTimeLiness确定 } else { string todayCode = invitationCodesRepository.GetTodayCode(userId); if (string.IsNullOrEmpty(todayCode)) { InvitationCode invitationCode = new InvitationCode { Code = code, DateCreated = DateTime.UtcNow, ExpiredDate = DateTime.UtcNow.AddDays(inviteFriendSettings.InvitationCodeTimeLiness), IsMultiple = !inviteFriendSettings.AllowInvitationCodeUseOnce, UserId = userId }; invitationCodesRepository.Insert(invitationCode); } else { code = todayCode; } //检查今日是否有生成过的可多次使用的邀请码,若没有,则生成;否则,直接返回 //过期时间根据LinktimelinessSettings.Lowlinktimeliness确定 //设置IsMultiple为true } //向邀请码表中插入数据库 return(code); }
public WeatherDashboardModel GetForecast(decimal latitude, decimal longitude) { string weatherUndergroundApiUrl = settingsManager.Get(Constants.WEATHER_UNDERGROUND_API_URL); string weatherUndergroundApiKey = settingsManager.Get(Constants.WEATHER_UNDERGROUND_API_KEY); var url = string.Format(weatherUndergroundApiUrl, weatherUndergroundApiKey, latitude, longitude); var response = requestHandler.GetDeserializedObjectFromRequest <WeatherUndergroundModel>(url); return(mapper.Map(response)); }
public WeatherDashboardModel GetForecast(decimal latitude, decimal longitude) { string darkSkyApiUrl = settingsManager.Get(Constants.DARK_SKY_API_URL); string darkSkyApiKey = settingsManager.Get(Constants.DARK_SKY_API_KEY); var url = string.Format(darkSkyApiUrl, darkSkyApiKey, latitude, longitude); var response = requestHandler.GetDeserializedObjectFromRequest <DarkSkyModel>(url); return(mapper.Map(response)); }
/// <summary> /// 创建用户 /// </summary> /// <param name="user">待创建的用户</param> /// <param name="ignoreDisallowedUsername">是否忽略禁用的用户名称</param> /// <param name="userCreateStatus">用户帐号创建状态</param> /// <returns>创建成功返回IUser,创建失败返回null</returns> public IUser CreateUser(User user, bool ignoreDisallowedUsername, out UserCreateStatus userCreateStatus) { userCreateStatus = UserCreateStatus.UnknownFailure; UserSettings userSettings = userSettingsManager.Get(); if (!ignoreDisallowedUsername) { if (userSettings.DisallowedUserNames.Split(new char[] { ',', ',' }).Any(n => n.Equals(user.UserName, StringComparison.CurrentCultureIgnoreCase))) { //用户输入字段为禁用字段 userCreateStatus = UserCreateStatus.DisallowedUsername; return(null); } } //判断用户名是否唯一 if (GetUserIdByUserName(user.UserName) > 0) { userCreateStatus = UserCreateStatus.DuplicateUsername; return(null); } if (GetUser(user.UserId) != null) { userCreateStatus = UserCreateStatus.DuplicateUsername; return(null); } //判断邮箱是否唯一 if (!string.IsNullOrEmpty(user.AccountEmail) && GetUserIdByEmail(user.AccountEmail) > 0) { userCreateStatus = UserCreateStatus.DuplicateEmailAddress; return(null); } //如果不允许手机号重复的时候 if (!userSettings.RequiresUniqueMobile) { if (GetUserIdByMobile(user.AccountMobile) > 0) { userCreateStatus = UserCreateStatus.DuplicateMobile; return(null); } } user.UserId = IdGenerator.Next(); object userId_objcet = base.Insert(user); if (userId_objcet != null && (long)userId_objcet > 0) { userCreateStatus = UserCreateStatus.Created; } return(user); }
public static JenkensApi OnJenkinsDeloyer(ISettingsManager settings) { var api = new JenkensApi( settings.Get("jenkins_deployer_host", "http://therig1231:9999"), settings.Get("jenkins_deployer_user",null), settings.Get("jenkins_deployer_password",null) ); if (!string.IsNullOrEmpty(settings.GetDefaultProxy())) { api.Proxy = new WebProxy(new Uri(settings.GetDefaultProxy())); } return api; }
public MainViewModel( IMediator mediator, ISettingsManager settingsManager) { this.mediator = mediator; this.settingsManager = settingsManager; FirstApiUrl = settingsManager.Get(nameof(FirstApiUrl)); SecondApiUrl = settingsManager.Get(nameof(SecondApiUrl)); IsLoading = true; FetchEndpointsCommand = new RelayCommand(async obj => await FetchEndpoints()); }
/// <summary> /// 获取展示统计页面的连接 /// </summary> /// <returns></returns> public string GetCNZZStatisticsPageLink() { SystemDataService service = new SystemDataService(); long siteId = service.GetLong("CNZZStatisticsSiteId"); long password = service.GetLong("CNZZStatisticsPassword"); SiteSettings siteSettings = siteSettingsManager.Get(); if (siteId <= 0 || password <= 0) { return(string.Empty); } return(string.Format("http://wss.cnzz.com/user/companion/spacebuilder_login.php?site_id={0}&password={1}", siteId, password)); }
public ActionResult EditSection(long?sectionId = null) { pageResourceManager.InsertTitlePart("帖吧设置"); if (sectionId.HasValue) { BarSection section = barSectionService.Get(sectionId ?? 0); if (section == null) { return(HttpNotFound()); } ViewData["UserId"] = section.UserId; ViewData["ManagerUserIds"] = barSectionService.GetSectionManagers(sectionId ?? 0).Select(n => n.UserId); ISettingsManager <BarSettings> manager = DIContainer.Resolve <ISettingsManager <BarSettings> >(); BarSettings settings = manager.Get(); ViewData["SectionManagerMaxCount"] = settings.SectionManagerMaxCount; BarSectionEditModel model = section.AsEditModel(); IEnumerable <Category> categories = categoryService.GetCategoriesOfItem(section.SectionId, 0, TenantTypeIds.Instance().BarSection()); if (categories != null && categories.Count() > 0) { model.CategoryId = categories.ElementAt(0).CategoryId; } return(View(model)); } else { ViewData["UserId"] = UserContext.CurrentUser.UserId; } return(View(new BarSectionEditModel())); }
/// <summary> /// 获取一级地区 /// </summary> /// <param name="rootDisciplineCode">根级地区(默认取站点地区配置)</param> public Dictionary <string, string> GetRootDisciplineDictionary(string rootDisciplineCode = null) { if (rootDisciplineCode == null) { ISettingsManager <DisciplineSettings> disciplineSettingsManager = DIContainer.Resolve <ISettingsManager <DisciplineSettings> >(); if (disciplineSettingsManager != null) { DisciplineSettings disciplineSettings = disciplineSettingsManager.Get(); rootDisciplineCode = disciplineSettings.RootDisciplineCode; } } //获取根级地区 IEnumerable <Discipline> disciplines = null; if (!string.IsNullOrEmpty(rootDisciplineCode)) { Discipline discipline = disciplineService.Get(rootDisciplineCode); if (discipline != null) { disciplines = discipline.Children; } } else { disciplines = disciplineService.GetRoots(); } if (disciplines == null) { return(null); } return(disciplines.ToDictionary(n => n.DisciplineCode, n => n.Name)); }
//回复:此方法名。郑伟定的。等我问问郑伟。 /// <summary> /// 变更用户邀请码配额 /// </summary> /// <param name="userId">用户Id</param> /// <param name="userInvitationCodeUnUsedCount">用户未使用邀请码配额增量(若减少请使用负数)</param> /// <param name="userInvitationCodeUsedCount">用户使用的邀请码配额增量(若减少请使用负数)</param> /// <param name="userInvitationCodeBuyedCount">用户购买的邀请码配额增量(若减少请使用负数)</param> /// <returns>是否更新成功</returns> public bool ChangeUserInvitationCodeCount(long userId, int userInvitationCodeUnUsedCount, int userInvitationCodeUsedCount, int userInvitationCodeBuyedCount) { InvitationCodeStatistic invitationCodeStatistic = Get(userId); if (invitationCodeStatistic == null) { InviteFriendSettings inviteFriendSettings = inviteFriendSettingsManager.Get(); invitationCodeStatistic = new InvitationCodeStatistic { CodeBuyedCount = 0, CodeUnUsedCount = inviteFriendSettings.DefaultUserInvitationCodeCount, CodeUsedCount = 0, UserId = userId }; Insert(invitationCodeStatistic); } invitationCodeStatistic.CodeBuyedCount += userInvitationCodeBuyedCount; invitationCodeStatistic.CodeUnUsedCount += userInvitationCodeUnUsedCount; invitationCodeStatistic.CodeUsedCount += userInvitationCodeUsedCount; //done:bianchx by libsh,怎么能防止这些统计数被减到负数 //回复:在业务逻辑类中做了拦截,请查看业务逻辑类中的ChangeUserInvitationCodeCount方法 var sql_Update = PetaPoco.Sql.Builder .Append("update tn_InvitationCodeStatistics set CodeUnUsedCount=CodeUnUsedCount+@0,CodeUsedCount=CodeUsedCount+@1,CodeBuyedCount=CodeBuyedCount+@2 where UserId=@3", userInvitationCodeUnUsedCount, userInvitationCodeUsedCount, userInvitationCodeBuyedCount, userId); //done:bianchx by libsh,应该先做数据库操作再处理缓存 //回复:修改了执行顺序 int affectedCount = CreateDAO().Execute(sql_Update); OnUpdated(invitationCodeStatistic); return(affectedCount > 0); }
public WeatherDashboardModel Map(DarkSkyModel model) { var dashboardModel = new WeatherDashboardModel(); dashboardModel.CurrentCelsius = model.Currently.Temperature; dashboardModel.CurrentFahrenheit = model.Currently.Temperature * (decimal)1.8 + 32; //using conversion formula dashboardModel.CurrentSummary = model.Currently.Summary; dashboardModel.Icon = model.Currently.Icon; dashboardModel.IconUrl = null; dashboardModel.Forecast = new List <DayDashboard>(); foreach (var day in model.Daily.Data.Take(int.Parse(settingsManager.Get(Constants.FORECAST_DEFAULT_SIZE)))) { var dayDashboard = new DayDashboard(); dayDashboard.Summary = day.Summary; dayDashboard.LowCelsius = day.TemperatureLow; dayDashboard.LowFahrenheit = day.TemperatureLow * (decimal)1.8 + 32; dayDashboard.HighCelsius = day.TemperatureHigh; dayDashboard.HighFahrenheit = day.TemperatureHigh * (decimal)1.8 + 32; dayDashboard.Icon = day.Icon; dayDashboard.IconUrl = null; dayDashboard.Date = new DateTime(1970, 1, 1).AddSeconds(day.Time); dashboardModel.Forecast.Add(dayDashboard); } return(dashboardModel); }
/// <summary> /// 评分 /// </summary> /// <param name="entity"></param> /// <returns></returns> public override object Insert(Spacebuilder.Bar.BarRating entity) { //1.先检查用户今日大于零的评分总和是否超出限制; //2.对主题帖作者加威望 ISettingsManager <BarSettings> barSettingsManager = DIContainer.Resolve <ISettingsManager <BarSettings> >(); BarSettings barSettings = barSettingsManager.Get(); bool result = false; var sql = Sql.Builder; sql.Select("sum(ReputationPoints)") .From("spb_BarRatings") .Where("UserId=@0", entity.UserId) .Where("DateCreated>@0", new DateTime(DateTime.UtcNow.Year, DateTime.UtcNow.Month, DateTime.UtcNow.Day)) .Where("ReputationPoints>0"); long?sumReputationPoints = CreateDAO().FirstOrDefault <long?>(sql); if (!sumReputationPoints.HasValue || sumReputationPoints.Value <= barSettings.UserReputationPointsPerDay) { base.Insert(entity); result = true; } return(result); }
/// <summary> /// 是否具有创建BarSection的权限 /// </summary> /// <returns></returns> public static bool BarSection_Create(this Authorizer authorizer) { IUser currentUser = UserContext.CurrentUser; if (currentUser == null) { return(false); } if (authorizer.IsAdministrator(BarConfig.Instance().ApplicationId)) { return(true); } ISettingsManager <BarSettings> barSettingsManager = DIContainer.Resolve <ISettingsManager <BarSettings> >(); BarSettings barSetting = barSettingsManager.Get(); if (!barSetting.EnableUserCreateSection) { return(false); } if (currentUser.Rank < barSetting.UserRankOfCreateSection) { return(false); } return(true); }
public override void LoadSettings() { ISettingsManager manager = _container.Resolve <ISettingsManager>(); manager.Add(new MjolnirSettingsItem("Mjolnir Settings", 1, null)); manager.Get("Mjolnir Settings").Add(new MjolnirSettingsItem("General", 1, MjolnirTestSettings.Default)); }
/// <summary> /// 验证邮箱 /// </summary> /// <param name="email">待验证的邮箱</param> /// <param name="userId">用户Id</param> /// <param name="errorMessage">输出出错信息</param> /// <returns>是否通过验证</returns> public bool ValidateEmail(string email, long userId, out string errorMessage) { ISettingsManager <UserSettings> userSettingsManager = DIContainer.Resolve <ISettingsManager <UserSettings> >(); UserSettings userSettings = userSettingsManager.Get(); if (string.IsNullOrEmpty(email)) { errorMessage = ResourceAccessor.GetString("Validate_EmailRequired"); return(false); } Regex regex = new Regex(userSettings.EmailRegex, RegexOptions.ECMAScript); if (!regex.IsMatch(email)) { errorMessage = ResourceAccessor.GetString("Validate_EmailStyle"); return(false); } IUserService userService = DIContainer.Resolve <IUserService>(); IUser user = userService.FindUserByEmail(email); if (user != null) { //验证email是否已经存在 if (userId != user.UserId) { errorMessage = "对不起,您输入的帐号邮箱已被使用"; return(false); } } errorMessage = string.Empty; return(true); }
private void LoadSettings() { ISettingsManager manager = containerProvider.Resolve <ISettingsManager>(); manager.Add(new MDSettingsItem("Text Editor", 1, null)); manager.Get("Text Editor").Add(new MDSettingsItem("General", 1, EditorOptions.Default)); }
/// <summary> /// 获取一级地区 /// </summary> /// <param name="rootAreaCode">根级地区(默认取站点地区配置)</param> public Dictionary <string, string> GetRootAreaDictionary(string rootAreaCode = null) { if (rootAreaCode == null) { ISettingsManager <AreaSettings> areaSettingsManager = DIContainer.Resolve <ISettingsManager <AreaSettings> >(); if (areaSettingsManager != null) { AreaSettings areaSettings = areaSettingsManager.Get(); rootAreaCode = areaSettings.RootAreaCode; } } //获取根级地区 IEnumerable <Area> areas = null; if (!string.IsNullOrEmpty(rootAreaCode)) { Area area = areaService.Get(rootAreaCode); if (area != null) { areas = area.Children; } } else { areas = areaService.GetRoots(); } if (areas == null) { return(null); } return(areas.ToDictionary(n => n.AreaCode, n => n.Name)); }
/// <summary> /// 页脚 /// </summary> /// <returns></returns> public ActionResult _Footer(string spaceKey) { ISettingsManager <SiteSettings> siteSettingsManager = DIContainer.Resolve <ISettingsManager <SiteSettings> >(); ViewData["SiteSettings"] = siteSettingsManager.Get(); return(PartialView()); }
/// <summary> /// 在用户动态收件箱追溯OwnerId的动态 /// </summary> /// <remarks> /// 关注用户/加入群组、取消屏蔽用户/取消屏蔽群组时使用 /// </remarks> /// <param name="userId">UserId</param> /// <param name="ownerId">动态拥有者Id</param> /// <param name="ownerType">动态拥有者类型</param> public void TraceBackInboxAboutOwner(long userId, long ownerId, int ownerType) { //缓存需要即时 //1、仅追溯ActivitySettings.TraceBackNumber条非私有的动态; ActivitySettings activitySettings = activitySettingsManager.Get(); activityRepository.TraceBackInboxAboutOwner(userId, ownerId, ownerType, activitySettings.TraceBackNumber); }
/// <summary> /// 验证手机号 /// </summary> /// <param name="userName">待验证的手机号</param> /// <param name="errorMessage">输出出错信息</param> /// <returns>是否通过验证</returns> public static bool ValidateUserNameForPhone(string userName, out string errorMessage, bool isWeb = true) { if (string.IsNullOrEmpty(userName)) { if (isWeb) { errorMessage = ResourceAccessor.GetString("Validate_PhoneRequired"); } else { errorMessage = ResourceAccessor.GetString("Validate_PhoneRequiredForMobileClient"); } return(false); } ISettingsManager <UserSettings> userSettingsManager = DIContainer.Resolve <ISettingsManager <UserSettings> >(); UserSettings userSettings = userSettingsManager.Get(); Regex regex = new Regex(userSettings.PhoneRegex); if (!regex.IsMatch(userName)) { errorMessage = ResourceAccessor.GetString("Validate_PhoneRegex"); return(false); } //AuthorizationService authorizationService = new AuthorizationService(); //authorizationService.IsSuperAdministrator(UserContext.CurrentUser); ////验证UserName是否被禁止使用 //if (!authorizationService.IsSuperAdministrator(UserContext.CurrentUser) && // userSettings.DisallowedUserNames.Split(',', ',').Any(n => n.Equals(userName, StringComparison.CurrentCultureIgnoreCase))) //{ // if (isWeb) // errorMessage = ResourceAccessor.GetString("Validate_UserNameIsDisallowed"); // else // errorMessage = ResourceAccessor.GetString("Validate_UserNameIsDisallowedForMobileClient"); // return false; //} //验证UserName是否已经存在 IUserService userService = DIContainer.Resolve <IUserService>(); IUser user = userService.GetUser(userName); if (user != null) { if (isWeb) { errorMessage = ResourceAccessor.GetString("Validate_PhoneIsExisting"); } else { errorMessage = ResourceAccessor.GetString("Validate_PhoneIsExistingForMobileClient"); } return(false); } errorMessage = string.Empty; return(true); }
/// <summary> /// 转为Html属性集合 /// </summary> public IDictionary <string, object> ToUnobtrusiveHtmlAttributes() { var result = new Dictionary <string, object>(); if (HtmlAttributes != null) { result = new Dictionary <string, object>(HtmlAttributes); } if (result.Any(n => n.Key == "style")) { result["style"] += "width:100%;"; } else { result["style"] = "width:100%;"; } result["plugin"] = "tinymce"; var data = new Dictionary <string, object>(); if (AdditionalOptions != null) { data = new Dictionary <string, object>(AdditionalOptions); } data.TryAdd("editorMode", this.EditorMode.ToString()); data.TryAdd("lazyload", this.Lazyload); data.TryAdd("showPagebreak", this.ShowPagebreak); ISettingsManager <SiteSettings> siteSettingsManager = DIContainer.Resolve <ISettingsManager <SiteSettings> >(); SiteSettings siteSettings = siteSettingsManager.Get(); data.TryAdd("language", siteSettings.DefaultLanguage.ToLower()); bool tinyMCEJavaScriptGzipEnabled = false; bool.TryParse(ConfigurationManager.AppSettings["HttpCompressEnabled"], out tinyMCEJavaScriptGzipEnabled); if (tinyMCEJavaScriptGzipEnabled) { data.TryAdd("script_url", WebUtility.ResolveUrl("~/scripts/tinymce/tiny_mce_gzip.ashx")); } else { data.TryAdd("script_url", WebUtility.ResolveUrl("~/scripts/tinymce/tiny_mce_src.js")); } result.Add("data", Json.Encode(data)); if (this.CustomButtons == null) { this.CustomButtons = new Dictionary <string, string>(); } if (this.ShowSmileyButton) { this.CustomButtons["smileyButton"] = SiteUrls.Instance()._EmotionSelector(); } result.TryAdd("customButtons", Json.Encode(this.CustomButtons)); return(result); }
/// <summary> /// 首页 /// </summary> /// <returns></returns> public ActionResult Home() { pageResourceManager.InsertTitlePart("首页"); ISettingsManager <UserSettings> userSettingsManager = DIContainer.Resolve <ISettingsManager <UserSettings> >(); bool enableTrackAnonymous = userSettingsManager.Get().EnableTrackAnonymous; ViewData["enableTrackAnonymous"] = enableTrackAnonymous; return(View()); }
/// <summary> /// 根据一定规则重置所有的用户等级 /// </summary> public void ResetAllUser() { PointSettings pointSettings = pointSettingsManager.Get(); var sql_Update = PetaPoco.Sql.Builder; sql_Update.Append("update tn_Users set Rank = (select max(Rank) from tn_UserRanks UR where UR.PointLower <= (ExperiencePoints * @0 + ReputationPoints * @1) or ((ExperiencePoints * @0 + ReputationPoints * @1)<0 and UR.Rank = 1) )", pointSettings.ExperiencePointsCoefficient, pointSettings.ReputationPointsCoefficient); CreateDAO().Execute(sql_Update); }
/// <summary> /// 更新完成度 /// </summary> /// <param name="userId">用户Id</param> public void UpdateIntegrity(long userId) { ISettingsManager <UserProfileSettings> userProfileSettingsManager = DIContainer.Resolve <ISettingsManager <UserProfileSettings> >(); UserProfileSettings userProfileSettings = userProfileSettingsManager.Get(); int[] integrityItems = userProfileSettings.IntegrityProportions; int integrity = integrityItems[(int)ProfileIntegrityItems.Birthday]; Database dao = CreateDAO(); dao.OpenSharedConnection(); var sql = Sql.Builder; sql.Select("Count(*)") .From("spb_EducationExperiences") .Where("UserId = @0", userId); int countEducation = dao.ExecuteScalar <int>(sql); if (countEducation > 0) { integrity += integrityItems[(int)ProfileIntegrityItems.EducationExperience]; } sql = Sql.Builder; sql.Select("count(*)") .From("spb_WorkExperiences") .Where("UserId = @0", userId); int countWork = dao.ExecuteScalar <int>(sql); if (countWork > 0) { integrity += integrityItems[(int)ProfileIntegrityItems.WorkExperience]; } sql = Sql.Builder; sql.Where("userId = @0", userId); UserProfile userProfile = dao.FirstOrDefault <UserProfile>(sql); if (userProfile != null) { IUser user = DIContainer.Resolve <UserService>().GetUser(userProfile.UserId); integrity += (user.HasAvatar ? integrityItems[(int)ProfileIntegrityItems.Avatar] : 0); integrity += (userProfile.HasHomeAreaCode ? integrityItems[(int)ProfileIntegrityItems.HomeArea] : 0); integrity += (userProfile.HasIM ? integrityItems[(int)ProfileIntegrityItems.IM] : 0); integrity += (userProfile.HasIntroduction ? integrityItems[(int)ProfileIntegrityItems.Introduction] : 0); integrity += (userProfile.HasMobile ? integrityItems[(int)ProfileIntegrityItems.Mobile] : 0); integrity += (userProfile.HasNowAreaCode ? integrityItems[(int)ProfileIntegrityItems.NowArea] : 0); userProfile.Integrity = integrity; Update(userProfile); } dao.CloseSharedConnection(); }
public ActionResult SectionSettings() { IEnumerable <PointCategory> pointCategories = pointService.GetPointCategories(); ViewData["prePoint"] = pointCategories.FirstOrDefault(n => n.CategoryKey.Equals("ReputationPoints")).CategoryName; ISettingsManager <BarSettings> manager = DIContainer.Resolve <ISettingsManager <BarSettings> >(); BarSettings settings = manager.Get(); return(View(settings.AsEditModel())); }
/// <summary> /// 获取用户邮件模板的数据字典 /// </summary> /// <param name="emailBuilder"></param> /// <param name="user"></param> /// <returns></returns> public static dynamic GetUserEmailModel(this EmailBuilder emailBuilder, IUser user) { ISettingsManager <InviteFriendSettings> manager = DIContainer.Resolve <ISettingsManager <InviteFriendSettings> >(); dynamic model = emailBuilder.GetCommonEmailModel();//合并全局数据字典 model.UserName = user.UserName; model.UserDisplayName = user.DisplayName; model.PublicEmail = "PublicEmail"; model.LastLogin = SiteUrls.FullUrl(SiteUrls.Instance().Login()); model.ProfileUrl = SiteUrls.FullUrl(SiteUrls.Instance().SpaceHome(user.UserName)); model.ChangePasswordUrl = SiteUrls.FullUrl(SiteUrls.Instance().ChangePassword(user.UserName)); model.UserAvatarUrl = SiteUrls.FullUrl(SiteUrls.Instance().UserAvatarUrl(user, AvatarSizeType.Medium, false)); model.ResetPassword = SiteUrls.FullUrl(SiteUrls.Instance().ResetPassword(user.UserId)); model.ExpirationTime = DateTime.Now.AddDays(manager.Get().InvitationCodeTimeLiness); model.InvitationCodeTimeLiness = manager.Get().InvitationCodeTimeLiness; model.Highlinktimeliness = DIContainer.Resolve <ISettingsManager <LinktimelinessSettings> >().Get().Highlinktimeliness; model.HighlinktimelinessExpirationTime = DateTime.Now.AddDays(model.Highlinktimeliness); return(model); }
public void LoadData() { _applicationState.ShortCodes.Clear(); var shortCodes = _settingsManager.Get <ShortCode[]>("ShortCodes"); var nextShortCodeId = _settingsManager.Get <int>("NextShortCodeId"); _applicationState.NextShortCodeId = nextShortCodeId > 0 ? nextShortCodeId : 1; if (shortCodes != null) { foreach (var shortCode in shortCodes) { _applicationState.ShortCodes.Add(shortCode); } } _applicationState.IsDataLoaded = true; _applicationState.IsDataLoading = false; _commandBus.PublishCommand(new DataLoadedMessage()); }
/// <summary> /// 获取邮件模板的全局数据字典 /// </summary> /// <param name="emailBuilder"></param> /// <returns></returns> public static dynamic GetCommonEmailModel(this EmailBuilder emailBuilder) { ISettingsManager <SiteSettings> siteSettingsManager = DIContainer.Resolve <ISettingsManager <SiteSettings> >(); SiteSettings siteSettings = siteSettingsManager.Get(); dynamic model = new ExpandoObject(); model.SiteName = siteSettings.SiteName; model.AdminAddress = "*****@*****.**"; model.LoginUrl = SiteUrls.FullUrl(SiteUrls.Instance().Login()); model.HomeUrl = SiteUrls.FullUrl(SiteUrls.Instance().SiteHome()); model.DateCreated = DateTime.Now.ToString(); return(model); }
/// <summary> /// 创建短网址 /// </summary> /// <param name="url">需要处理的Url</param> /// <returns>Url别名</returns> public string Create(string url) { bool urlExists; IUrlShortner urlShortner = null; ShortUrlSettings settings = shortUrlSettingsManager.Get(); if (settings.IsEnableOtherShortner) { urlShortner = DIContainer.Resolve <IUrlShortner>(); } ShortUrlEntity entity = ShortUrlEntity.New(GetUrlAlias(url, out urlExists)); entity.Url = url; //判断Url是否存在 if (urlExists) { return(entity.Alias); } string primaryKey = string.Empty; EventBus <ShortUrlEntity> .Instance().OnBefore(entity, new CommonEventArgs(EventOperationType.Instance().Create())); if (settings.IsEnableOtherShortner && urlShortner != null) { entity.OtherShortUrl = urlShortner.Shortner(url); } primaryKey = shortUrlRepository.Insert(entity).ToString(); EventBus <ShortUrlEntity> .Instance().OnAfter(entity, new CommonEventArgs(EventOperationType.Instance().Create())); return(primaryKey); }
public ActionResult _EditIdentificationType(IdentificationTypeEditModel editModel) { string fileName = string.Empty; Stream stream = null; //获取上传图片 HttpPostedFileBase logo = Request.Files["IdentificationTypeLogo"]; //如果上传图片不为空则校验其扩展名和大小 if (logo != null && logo.ContentLength > 0) { fileName = logo.FileName; //校验附件的扩展名 ISettingsManager <LogoSettings> logoSettingsManager = DIContainer.Resolve <ISettingsManager <LogoSettings> >(); LogoSettings logoSettings = logoSettingsManager.Get(); if (!logoSettings.ValidateFileExtensions(fileName)) { return(Content(WarpJsonMessage(new StatusMessageData(StatusMessageType.Error, "只允许上传后缀名为 " + logoSettings.AllowedFileExtensions.TrimEnd(',') + " 的文件")))); } //校验附件的大小 TenantLogoSettings tenantLogoSettings = TenantLogoSettings.GetRegisteredSettings(TenantTypeIds.Instance().Identification()); if (!tenantLogoSettings.ValidateFileLength(logo.ContentLength)) { return(Content(WarpJsonMessage(new StatusMessageData(StatusMessageType.Error, string.Format("文件大小不允许超过{0}KB", tenantLogoSettings.MaxLogoLength))))); } stream = logo.InputStream; } //如果IdentificationTypeId大于0则为编辑标识 if (editModel.IdentificationTypeId > 0) { IdentificationType identificationType = editModel.AsIdentificationType(); identificationService.UpdateIdentificationType(identificationType, stream); } //否则为创建标识 else { if (logo == null || logo.ContentLength == 0) { return(Content(WarpJsonMessage(new StatusMessageData(StatusMessageType.Error, "图片不能为空!")))); } IdentificationType identificationType = editModel.AsIdentificationType(); identificationService.CreateIdentificationType(identificationType, stream); } return(Content(WarpJsonMessage(new StatusMessageData(StatusMessageType.Success, "操作成功!")))); }
/// <summary> /// 用户对某类型是否允许发送通知 /// </summary> /// <param name="userId">用户Id</param> /// <param name="typeId">通知类型Id</param> /// <returns></returns> public bool IsAllowedSend(long userId, int typeId) { Dictionary <int, bool> userSettings = userNoticeSettingsRepository.GetUserNoticeSettingses(userId); if (userSettings.ContainsKey(typeId)) { return(userSettings[typeId]); } NoticeSettings noticeSettings = noticeSettingsManager.Get(); if (!noticeSettings.NoticeTypeSettingses.Any(n => n.TypeId == typeId)) { return(false); } return(noticeSettings.NoticeTypeSettingses.Single(n => n.TypeId == typeId).IsAllow); }