/// <summary> /// 免费的员工数 (业务员数) /// </summary> /// <returns></returns> private static int GetFreeSalses() { YSWL.Common.DataCacheCore coreBll = new DataCacheCore(new CacheOption { CacheType = CacheType.Redis, CancelProductKey = true, CancelEnterpriseKey = true, DefaultDb = 0, ReadWriteHosts = SAASInfo.GetSystemValue("RedisCacheReadWriteHosts"), ReadOnlyHosts = SAASInfo.GetSystemValue("RedisCacheReadOnlyHosts"), }); string CacheKey = "SAAS_FreeEnterpriseSales"; object objModel = coreBll.GetCache(CacheKey); if (objModel == null) { try { objModel = GetSysValue(CacheKey); if (objModel != null) { coreBll.SetCache(CacheKey, objModel, DateTime.MaxValue, TimeSpan.Zero); } } catch { } } return(Common.Globals.SafeInt(objModel, 5)); }
/// <summary> /// 获取企业客户数 (Redis 缓存) /// </summary> /// <returns></returns> public static int GetCacheCusts(long enterpriseId) { YSWL.Common.DataCacheCore coreBll = new DataCacheCore(new CacheOption { CacheType = CacheType.Redis, CancelProductKey = true, CancelEnterpriseKey = true, DefaultDb = 0, ReadWriteHosts = SAASInfo.GetSystemValue("RedisCacheReadWriteHosts"), ReadOnlyHosts = SAASInfo.GetSystemValue("RedisCacheReadOnlyHosts"), }); string CacheKey = "SAAS_EnterpriseCusts_" + enterpriseId; object objModel = coreBll.GetCache(CacheKey); if (objModel == null) { try { objModel = GetUserCounts(1, enterpriseId); if (objModel != null) { coreBll.SetCache(CacheKey, objModel, DateTime.MaxValue, TimeSpan.Zero); } } catch { } } return(Common.Globals.SafeInt(objModel, 0)); }
/// <summary> /// 获取企业的数据库配置信息 /// </summary> /// <returns></returns> public static string GetBusinnessConStr(string applicationTag) { applicationTag = applicationTag.ToUpper(); string CacheKey = "SAAS_ConnectionString_" + applicationTag + "_" + Common.CallContextHelper.GetAutoTag(); dataCache = new DataCacheCore( new CacheOption { CacheType = CacheType.Redis, CancelProductKey = true, CancelEnterpriseKey = true, DefaultDb = 0, ReadWriteHosts = SAASInfo.GetSystemValue("RedisCacheReadWriteHosts"), ReadOnlyHosts = SAASInfo.GetSystemValue("RedisCacheReadOnlyHosts"), }); object objModel = dataCache.GetCache(CacheKey); if (objModel == null || String.IsNullOrWhiteSpace(objModel.ToString())) { try { DataSet ds = Query( "select * from SA_EnterpriseDBConfig where EnterpriseId=@EnterpriseId and [State]=1 and ApplicationTag=@ApplicationTag", new SqlParameter[] { new SqlParameter("@EnterpriseId", Common.CallContextHelper.GetAutoTag()), new SqlParameter("@ApplicationTag", applicationTag) }); if (ds == null || ds.Tables.Count <= 0 || ds.Tables[0].Rows.Count > 1) { return(null); } foreach (DataRow item in ds.Tables[0].Rows) { objModel = "server=" + item["RemoteDB_IP"] + ";database=" + item["DBName"] + ";uid=" + item["UserInstance"] + ";pwd=" + item["Passworld"]; break; } if (objModel != null && !String.IsNullOrWhiteSpace(objModel.ToString())) { dataCache.SetCache(CacheKey, objModel, DateTime.MaxValue, TimeSpan.Zero); } } catch (Exception ex) { Log.LogHelper.AddErrorLog("获取连接地址失败:" + ex.Message, "详细错误为:" + ex.StackTrace); throw ex; } } return(Common.Globals.SafeString(objModel, "")); }
/// <summary> /// 设置购买状态缓存 /// </summary> /// <param name="applicationId"></param> /// <param name="enterpriseId"></param> /// <returns></returns> public static bool SetBuyCache(int applicationId, long enterpriseId) { YSWL.Common.DataCacheCore coreBll = new DataCacheCore(new CacheOption { CacheType = CacheType.Redis, CancelProductKey = true, CancelEnterpriseKey = true, DefaultDb = 0, ReadWriteHosts = SAASInfo.GetSystemValue("RedisCacheReadWriteHosts"), ReadOnlyHosts = SAASInfo.GetSystemValue("RedisCacheReadOnlyHosts"), }); string CacheKey = "SAAS_AppIsBuy_" + applicationId + "_" + enterpriseId; return(coreBll.SetCache(CacheKey, true)); }
/// <summary> /// 清除员工缓存数 /// </summary> /// <param name="enterpriseId"></param> /// <returns></returns> public static bool ClearCacheSales(long enterpriseId) { YSWL.Common.DataCacheCore coreBll = new DataCacheCore(new CacheOption { CacheType = CacheType.Redis, CancelProductKey = true, CancelEnterpriseKey = true, DefaultDb = 0, ReadWriteHosts = SAASInfo.GetSystemValue("RedisCacheReadWriteHosts"), ReadOnlyHosts = SAASInfo.GetSystemValue("RedisCacheReadOnlyHosts"), }); string CacheKey = "SAAS_EnterpriseSales_" + enterpriseId; return(coreBll.DeleteCache(CacheKey)); }
private static DateTime GetEndTime(int applicationId, long enterpriseId) { YSWL.Common.DataCacheCore coreBll = new DataCacheCore(new CacheOption { CacheType = CacheType.Redis, CancelProductKey = true, DefaultDb = 0, CancelEnterpriseKey = true, ReadWriteHosts = SAASInfo.GetSystemValue("RedisCacheReadWriteHosts"), ReadOnlyHosts = SAASInfo.GetSystemValue("RedisCacheReadOnlyHosts"), }); string CacheKey = "SAAS_AppEndTime_" + applicationId + "_" + enterpriseId; object objModel = coreBll.GetCache(CacheKey); if (objModel == null) { try { StringBuilder strSql = new StringBuilder(); strSql.Append("select EndTime from SA_EnterpriseBuyJurisdiction"); strSql.Append(" where EnterpriseId=@EnterpriseId and ApplicationId=@ApplicationId and IsTrial=0"); SqlParameter[] parameters = { new SqlParameter("@EnterpriseId", SqlDbType.Int, 4), new SqlParameter("@ApplicationId", SqlDbType.Int, 4) }; parameters[0].Value = enterpriseId; parameters[1].Value = applicationId; objModel = YSWL.DBUtility.ConnectionStrManage.GetSingle(strSql.ToString(), parameters); if (objModel != null) { coreBll.SetCache(CacheKey, objModel, DateTime.MaxValue, TimeSpan.Zero); } } catch { } } return(Common.Globals.SafeDateTime(objModel, DateTime.Now)); }