public virtual void OnItemRemoved(string key, object value, ItemRemoveReason reason, BitSet Flag, bool notifyAsync, EventCacheItem item) { try { if (item != null && item.Value != null) { item.Value = value = GetObject(value, Flag); } this._eventManager.RaiseGeneralCacheNotification(key, EventType.ItemRemoved, item, null, WebCacheHelper.GetWebItemRemovedReason(reason), notifyAsync); } catch { } }
/// 获取签到信息 /// </summary> /// <param name="userId">用户ID</param> /// <returns>MemberSignModel.</returns> public static MemberSignModel GetMemberSignModel(int userId) { using (var dal = FactoryDispatcher.UserFactory()) { string cacheKey = GetMemberSignCacheKey(userId); MemberSignModel model = WebCacheHelper <MemberSignModel> .Get(cacheKey); if (model == null) { model = dal.GetMemberSignModel(userId); if (model == null) { return(null); } WebCacheHelper.Insert(cacheKey, model, new System.Web.Caching.CacheDependency(WebCacheHelper.GetDepFile(cacheKey))); } return(model); } }
public int UpdateData(CustomerModel customerInfo) { string userAccount = HttpContextHandler.GetHeaderObj("UserAccount").ToString(); if (!string.IsNullOrEmpty(userAccount)) { customerInfo.Updater = userAccount; } //操作日志 OperationLogService operationService = new OperationLogService(); operationService.PostData(new OperationLogModel() { Remark = customerInfo.Id, OptContent = "更新客户" }); string userClientId = HttpContextHandler.GetHeaderObj("UserClientId").ToString(); WebCacheHelper.ClearIds(userClientId); return(GenerateDal.Update(CommonSqlKey.UpdateCustomer, customerInfo)); }
/// <summary> /// /// </summary> /// <param name="type">0总后台菜单,1总门店菜单,2分店菜单</param> /// <returns></returns> public static List <SystemMenuModel> GetMenuList(int type) { using (var dal = FactoryDispatcher.SystemFactory()) { //读取缓存数据 List <SystemMenuModel> menuData = WebCacheHelper <List <SystemMenuModel> > .Get(GetCacheKey(type)); if (menuData == null) { menuData = dal.GetMenuList(type); //将数据插入缓存中 if (menuData != null) { WebCacheHelper.Insert(GetCacheKey(type), menuData, "bameng/cacheMenuKey_" + type); } } return(menuData); } }
/// <summary> /// 新增/修改会员信息 /// </summary> /// <param name="memberInfo"></param> /// <returns></returns> public int PostData(CustomerModel customerInfo) { int result; string userClientId = HttpContextHandler.GetHeaderObj("UserClientId").ToString(); if (string.IsNullOrEmpty(userClientId)) { return(0); } string userAccount = HttpContextHandler.GetHeaderObj("UserAccount").ToString(); if (string.IsNullOrEmpty(userAccount)) { return(0); } if (!string.IsNullOrEmpty(userClientId)) { customerInfo.ClientFatherId = userClientId; } if (!string.IsNullOrEmpty(userAccount)) { customerInfo.Creator = userAccount; } //customerInfo.Id = Guid.NewGuid().ToString(); result = GenerateDal.Create(customerInfo); //操作日志 OperationLogService operationService = new OperationLogService(); operationService.PostData(new OperationLogModel() { Remark = customerInfo.Id, OptContent = "新增或修改会员信息" }); WebCacheHelper.ClearIds(userClientId); return(result); }
/// <summary> /// 获取后台首页数据 /// </summary> /// <param name="user">The user.</param> /// <returns>List<AdminHomeDataModel>.</returns> public static List <AdminHomeDataModel> GetHomeData(AdminLoginModel user) { List <AdminHomeDataModel> result = new List <AdminHomeDataModel>(); using (var dal = FactoryDispatcher.SystemFactory()) { //获取今日数据 string todayKey = "HOMEDATA" + DateTime.Now.ToString("yyyyMMddHH") + "_" + user.UserIndentity.ToString() + user.ID.ToString(); AdminHomeDataModel todayData = WebCacheHelper <AdminHomeDataModel> .Get(todayKey); if (todayData == null) { todayData = new AdminHomeDataModel(); todayData.NewAllyCount = dal.GetNewAllyCount(user.ID, user.UserIndentity); todayData.NewArticleCount = dal.GetNewArticleCount(user.ID, user.UserIndentity); todayData.NewCustomerCount = dal.GetNewCustomerCount(user.ID, user.UserIndentity); todayData.NewMessageCount = dal.GetNewMessageCount(user.ID, user.UserIndentity); WebCacheHelper.Insert(todayKey, todayData, new System.Web.Caching.CacheDependency(WebCacheHelper.GetDepFile(todayKey))); } result.Add(todayData); //读取缓存数据 string yesterdayKey = "HOMEDATA" + DateTime.Now.AddDays(-1).ToString("yyyyMMdd") + "_" + user.UserIndentity.ToString() + user.ID.ToString(); AdminHomeDataModel yesterdayData = WebCacheHelper <AdminHomeDataModel> .Get(yesterdayKey); if (yesterdayData == null) { yesterdayData = new AdminHomeDataModel(); //获取昨日数据 yesterdayData.NewAllyCount = dal.GetNewAllyCount(user.ID, user.UserIndentity, false); yesterdayData.NewCustomerCount = dal.GetNewCustomerCount(user.ID, user.UserIndentity, false); WebCacheHelper.Insert(yesterdayKey, yesterdayData, new System.Web.Caching.CacheDependency(WebCacheHelper.GetDepFile(yesterdayKey))); } result.Add(yesterdayData); return(result); } }
/// <summary> /// 从缓存中获取基本配置信息 /// </summary> /// <returns></returns> public BaseConfigModel GetModelCached() { if (HttpContext.Current != null) { BaseConfigModel model = WebCacheHelper <BaseConfigModel> .Get(CACHEKEY); if (model == null) { model = dal.GetTopModel(); if (model == null) { return(null); } WebCacheHelper.Insert(CACHEKEY, model, new System.Web.Caching.CacheDependency(this.GetDepFile())); } return(model); } else { return(dal.GetTopModel()); } }
/// <summary> /// 从缓存中得到字典 /// </summary> /// <returns></returns> public List <DdkAppsModel> GetAppCacheList() { if (HttpContext.Current != null) { List <DdkAppsModel> list = WebCacheHelper <List <DdkAppsModel> > .Get(CACHEKEY); if (list == null) { list = DdkAppsBLL.Instance.GetEffectList(); if (list == null) { return(null); } WebCacheHelper.Insert(CACHEKEY, list, new System.Web.Caching.CacheDependency(this.GetDepFile())); } return(list); } else { return(DdkAppsBLL.Instance.GetEffectList()); } }
public IHttpActionResult Login(EmployeeLoginModelGet adminLoginModelGet) { DataRow dataRow = _employeeInfoDal.Login(adminLoginModelGet.AccountId, adminLoginModelGet.LoginPassword); EmployeeLoginModelResult adminLoginModelResult = null; if (dataRow != null) { adminLoginModelResult = new EmployeeLoginModelResult(); adminLoginModelResult.AccountId = dataRow["AccountId"].ToString(); adminLoginModelResult.Id = Convert.ToInt32(dataRow["Id"]); adminLoginModelResult.Nickname = dataRow["Nickname"].ToString(); adminLoginModelResult.Phone = dataRow["Phone"].ToString(); adminLoginModelResult.PhoneAreaId = dataRow["PhoneAreaId"].ToString(); adminLoginModelResult.State = dataRow["State"].ToString(); adminLoginModelResult.Type = dataRow["Type"].ToString(); adminLoginModelResult.Token = ServerHelper.GetToken; WebCacheHelper.SetCache(adminLoginModelResult.Id + "_" + 0, adminLoginModelResult.Token); } return(Json(new ResultDataModel <EmployeeLoginModelResult> { Code = dataRow == null ? -1 : 0, Data = adminLoginModelResult })); }
public AlipayConfig() { //↓↓↓↓↓↓↓↓↓↓请在这里配置您的基本信息↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ SitePayAPI m_pay = SitePayAPI.GetModel(t => t.ApiType == "支付宝"); //合作身份者ID,以2088开头由16位纯数字组成的字符串 partner = m_pay.AppIdentity; //交易安全检验码,由数字和字母组成的32位字符串 key = m_pay.AppKey; //签约支付宝账号或卖家支付宝帐户 seller_email = m_pay.Account; //付完款后跳转的页面 要用 http://格式的完整路径,不允许加?id=123这类自定义参数 return_url = WebCacheHelper.GetSiteInfo().WebAddress + "/Alipay/Alipay_Return"; //交易过程中服务器通知的页面 要用 http://格式的完整路径,不允许加?id=123这类自定义参数 notify_url = WebCacheHelper.GetSiteInfo().WebAddress + "/Alipay/Alipay_Notify"; //网站商品的展示地址,不允许加?id=123这类自定义参数 show_url = WebCacheHelper.GetSiteInfo().WebAddress; //收款方名称,如:公司名称、网站名称、收款人姓名等 mainname = "Site Name"; //↑↑↑↑↑↑↑↑↑↑请在这里配置您的基本信息↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ //字符编码格式 目前支持 gbk 或 utf-8 input_charset = "utf-8"; //签名方式 不需修改 sign_type = "MD5"; //访问模式,根据自己的服务器是否支持ssl访问,若支持请选择https;若不支持请选择http transport = "http"; }
public void OnAuthorization(AuthorizationContext filterContext) { #region 初始判断 if (filterContext == null) { throw new ArgumentNullException("filterContext"); } #endregion #region 登陆的判断 bool _isLogin = false; Model.Admin m_Admin = null; if (Common.Globals.isAdminLogin()) { m_Admin = DealMvc.Model.Admin.getAdminByAdminID(Common.Globals.getAdminName()); if (m_Admin != null) { _isLogin = true; } } if (_isLogin) {//已登录 //是否启用了权限模块 Model.SiteInfo m_SiteInfo = WebCacheHelper.GetSiteInfo(); if (!m_SiteInfo.WebCompetence) { return; } string ControllerName = filterContext.RouteData.Values["controller"].ToString().Trim().ToLower(); string ActionName = filterContext.RouteData.Values["action"].ToString().Trim().ToLower(); string AdminPowerValues = "|" + m_Admin.AdminPowerValues.ToLower(); if (AdminPowerValues.IndexOf("|" + ControllerName + "/" + ActionName + "#") >= 0 || m_Admin.AdminPowerValues.ToLower() == "all" || !IsAuthorize) {//有权限 return; } else { // /CmsAdmin/AEAdmin // /CmsAdmin/EAdminPwd bool s = !string.IsNullOrEmpty(filterContext.RouteData.Values["a_i_id"] == null ? "" : filterContext.RouteData.Values["a_i_id"].ToString()); if (ControllerName == "CmsAdmin".ToLower() && ActionName == "AEAdmin".ToLower() && s) { } else if (ControllerName == "CmsAdmin".ToLower() && ActionName == "EAdminPwd".ToLower() && s) { } else { filterContext.Result = new RedirectToRouteResult(new System.Web.Routing.RouteValueDictionary(new { controller = "Cms", action = "NoAuthorize" })); } return; } } else { filterContext.Result = new RedirectToRouteResult(new System.Web.Routing.RouteValueDictionary(new { controller = "Cms", action = "Index" })); return; } #endregion }
/// <summary> /// 获取配置数据 /// </summary> /// <returns>List<ConfigModel>.</returns> public static List <ConfigModel> GetConfigList() { List <ConfigModel> lst = WebCacheHelper <List <ConfigModel> > .Get(cacheKey); if (lst == null) { using (var dal = FactoryDispatcher.ConfigFactory()) { lst = dal.List(); WebCacheHelper.Insert(cacheKey, lst, new System.Web.Caching.CacheDependency(WebCacheHelper.GetDepFile(cacheKey))); } } return(lst); }
public static Dictionary <string, string> ResolveUserAccounts(ITeamCalendarUserDataResolver userDataResolver, string strTeamList) { if (string.IsNullOrWhiteSpace(strTeamList)) { throw new ArgumentNullException(nameof(strTeamList)); } var accountAliasMap = WebCacheHelper.Get <Dictionary <string, string> >(UserAliasCachekey); if ((accountAliasMap != null) && accountAliasMap.Any()) { return(accountAliasMap); } accountAliasMap = new Dictionary <string, string>(); short cntUserNotFound = 0; foreach (var strUser in strTeamList.Split(new[] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries)) { var userId = strUser.Trim(); if (string.IsNullOrEmpty(userId)) { continue; } //by AD id if ((userId.IndexOf(' ') == -1) && (userId.IndexOf('@') == -1)) { var userEml = userDataResolver.ResolveEmailByUsername(userId); if (string.IsNullOrEmpty(userEml)) { cntUserNotFound++; accountAliasMap[$"unresolved_{cntUserNotFound}"] = "N/A: " + userId; } else { accountAliasMap[userEml] = userDataResolver.ResolveAccountDisplayNameByEmail(userId); } continue; } //by full name if ((userId.IndexOf(' ') != -1) && (userId.IndexOf('@') == -1)) { var userEml = userDataResolver.ResolveEmailByUsername(userId); if (string.IsNullOrEmpty(userEml)) { cntUserNotFound++; accountAliasMap[$"unresolved_{cntUserNotFound}"] = "N/A: " + userId; } else { accountAliasMap[userEml] = userId; } continue; } //by email if ((userId.IndexOf(' ') == -1) && (userId.IndexOf('@') != -1)) { var userName = userDataResolver.ResolveAccountDisplayNameByEmail(userId); if (string.IsNullOrEmpty(userName)) { cntUserNotFound++; accountAliasMap[$"unresolved_{cntUserNotFound}@"] = "N/A: " + userId; } else { accountAliasMap[userId] = userName; } } } WebCacheHelper.Set(accountAliasMap, UserAliasCachekey, DateTime.UtcNow.AddHours(1).TimeOfDay.TotalSeconds); return(accountAliasMap); }
public static IEnumerable <CalendarInfo> ResolveCalendarData(ITeamCalendarDataProvider calendarDataProvider, DateTime startDate, IList <string> userAccounts) { if ((userAccounts == null) || !userAccounts.Any()) { throw new InvalidOperationException("no user account data found."); } const ushort CacheTimeout = 60; var cacheKey = $"{CacheKeyMain}:{calendarDataProvider.GetHashCode()}:{startDate.ToFileTimeUtc()}"; List <CalendarInfo> cInfoList = null; cInfoList = WebCacheHelper.Get <List <CalendarInfo> >(cacheKey); if (cInfoList != null) { return(cInfoList); } cInfoList = new List <CalendarInfo>(); //fetch foreach (var userEmail in userAccounts) { try { var calendarInfos = calendarDataProvider.GetCalendarInfo(userEmail, startDate, new DateTime(startDate.Year, startDate.Month, startDate.Day).AddDays(1).AddSeconds(-1)); if (calendarInfos != null) { cInfoList.AddRange(calendarInfos.ToList()); } } catch (Exception ex) { TraceTool.Instance.Value.TraceMessageFormat( "Unable to retrive calendar information for '{0}': '{1}'", userEmail, ex.Message); if (!string.IsNullOrEmpty(ConfigurationManager.AppSettings["TeamCalendar.DiagnisticMode"]) && ConfigurationManager.AppSettings["TeamCalendar.DiagnisticMode"].ToLower().Equals("true")) { throw new InvalidOperationException( $"{DateTime.UtcNow.ToShortTimeString()} Unable to retrive calendar information for '{userEmail}': '{ex.Message}'"); } break; } } //sort / merge if (cInfoList.Any()) { var listMerge = (from c in cInfoList group c by new { c.ResourceEmail, c.Location, c.StartTime, c.EndTime } into g select g.Aggregate(delegate(CalendarInfo current, CalendarInfo next) { current.Subject += "; " + next.Subject; return(current); })).ToList(); WebCacheHelper.Set(listMerge, cacheKey, CacheTimeout); return(listMerge); } return(Enumerable.Empty <CalendarInfo>()); }
public virtual void OnCustomRemoveCallback(string key, object value, ItemRemoveReason reason, BitSet Flag, bool notifyAsync) { try { object[] args = value as object[]; if (args != null) { object val = args[0]; if (value is UserBinaryObject) { value = ((UserBinaryObject)value).GetFullObject(); } CallbackInfo cbInfo = args[1] as CallbackInfo; if (cbInfo != null) { val = _parent.SafeDeserialize(val, _parent._serializationContext, Flag); int processid = System.Diagnostics.Process.GetCurrentProcess().Id; CacheItemRemovedCallback cb = (CacheItemRemovedCallback)_parent.CallbackIDsMap.GetResource(cbInfo.Callback); if (cb != null) { if (notifyAsync) { #if !NETCORE cb.BeginInvoke(key, val, WebCacheHelper.GetWebItemRemovedReason(reason), null, null); #elif NETCORE TaskFactory factory = new TaskFactory(); Task task = factory.StartNew(() => cb(key, val, WebCacheHelper.GetWebItemRemovedReason(reason))); #endif } else { cb(key, value, WebCacheHelper.GetWebItemRemovedReason(reason)); } } } } } catch { } }
/// <summary> /// 更新缓存 /// </summary> /// <param name="userId">用户ID</param> /// <param name="memberSign">签到数据</param> private static void RefreshMemberSignCache(int userId, MemberSignModel memberSign) { string cacheKey = GetMemberSignCacheKey(userId); WebCacheHelper.Insert(cacheKey, memberSign, new System.Web.Caching.CacheDependency(WebCacheHelper.GetDepFile(cacheKey))); }