示例#1
0
        /// <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));
        }
示例#2
0
        /// <summary>
        /// 设置企业数据流向
        /// </summary>
        /// <param name="enterpriseId"></param>
        /// <returns></returns>
        public static string GetDataConn(int enterpriseId)
        {
            YSWL.Common.DataCacheCore coreBll = new DataCacheCore(new CacheOption
            {
                CacheType           = CacheType.Redis,
                CancelProductKey    = true,
                CancelEnterpriseKey = true,
                DefaultDb           = 0,
            });
            string BaseKey  = "OMS_ConnectionData";
            string CacheKey = BaseKey + "_" + enterpriseId;
            object objModel = coreBll.GetCache(CacheKey);

            if (objModel == null)
            {
                try
                {
                    Common.CallContextHelper.SetAutoTag(enterpriseId);
                    objModel = GetSysValue(BaseKey);
                    if (objModel != null)
                    {
                        coreBll.SetCache(CacheKey, objModel, DateTime.MaxValue, TimeSpan.Zero);
                    }
                }
                catch { }
            }
            return(Common.Globals.SafeString(objModel, "ERP"));
        }
示例#3
0
        /// <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));
        }
示例#4
0
        /// <summary>
        ///  Get an object entity,From cache
        /// </summary>
        /// <param name="Keyname"></param>
        /// <returns></returns>
        public static string GetValueByCache(string Keyname)
        {
#pragma warning disable CS0612 // “DataCacheCore.GetCache(string)”已过时
            object cache = dataCache.GetCache(Keyname);
#pragma warning restore CS0612 // “DataCacheCore.GetCache(string)”已过时
            if (cache != null)
            {
                return(cache.ToString());
            }
            cache = GetValue(Keyname);
            dataCache.SetCache(Keyname, cache, DateTime.Now.AddMinutes(Globals.SafeInt(GetCacheTimeByCache("CacheTime"), 30)), TimeSpan.Zero);
            return(cache.ToString());
        }
示例#5
0
        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));
        }