public void TestInitialize()
        {
			CacheManagerFactory factory = new CacheManagerFactory(TestConfigurationSource.GenerateConfiguration());
			cache = factory.Create("InDatabasePersistence");
			cache.Flush();
            wasCalledBack = false;
            initializationCount = 0;
        }
        public void WillThrowExceptionIfCannotFindSection()
        {
            CacheManagerFactory factory2 = new CacheManagerFactory(new DictionaryConfigurationSource());

            factory2.Create("some name");

            Assert.Fail("Should have thrown ConfigurationErrorsException");
        }
        public void CallingDifferentFactoryTwiceReturnsDifferentInstances()
        {
            CacheManager cacheOne = factory.GetCacheManager("InMemoryPersistence");

            CacheManagerFactory secondFactory = new CacheManagerFactory(Context);
            CacheManager cacheTwo = secondFactory.GetCacheManager("InMemoryPersistence");

            Assert.IsFalse(object.ReferenceEquals(cacheOne, cacheTwo), "Different factories should always return different instances for same instance name");
        }
        public void ThenReturnsNewlyConfiguredInstanceAfterReconfigureOfCacheManager()
        {
            cacheManagerData.Name = "New Name";
            configurationSource.DoSourceChanged(new string[]{CacheManagerSettings.SectionName});

            CacheManagerFactory factory = new CacheManagerFactory(serviceLcoator);
            ICacheManager cacheManager = factory.Create("New Name");
            Assert.IsNotNull(cacheManager);
        }
        public void CallingDifferentFactoryTwiceReturnsDifferentInstances()
        {
            CacheManager cacheOne = factory.Create("InMemoryPersistence");

            CacheManagerFactory secondFactory = new CacheManagerFactory(TestConfigurationSource.GenerateConfiguration());
            CacheManager cacheTwo = secondFactory.Create("InMemoryPersistence");

            Assert.IsFalse(object.ReferenceEquals(cacheOne, cacheTwo), "Different factories should always return different instances for same instance name");
        }
        public void CreateCache()
        {
            removedKey = null;
            expiredValue = null;
            removalReason = CacheItemRemovedReason.Unknown;

            factory = new CacheManagerFactory(TestConfigurationSource.GenerateConfiguration());
            cacheMgr = (CacheManager)factory.Create("SmallInMemoryPersistence");
        }
        public void WillThrowExceptionIfCannotDefault()
        {
            DictionaryConfigurationSource source = new DictionaryConfigurationSource();
            source.Add(CacheManagerSettings.SectionName, new CacheManagerSettings());
            CacheManagerFactory factory2 = new CacheManagerFactory(source);

            factory2.CreateDefault();

            Assert.Fail("Should have thrown ConfigurationErrorsException");
        }
		public void StartCacheProcesses()
        {
            factory = new CacheManagerFactory(TestConfigurationSource.GenerateConfiguration());
            shortCacheManager = factory.Create("ShortInMemoryPersistence");
            smallCacheManager = factory.Create("SmallInMemoryPersistence");

            expiredKeys = "";
            expiredValues = "";
            removalReasons = "";
        }
        public void CanCreateIsolatedStorageCacheManager()
        {
            cacheManager.Add("bab", "foo");
            Assert.AreEqual(1, cacheManager.Count);

            CacheManagerFactory differentFactory = new CacheManagerFactory(Context);
            CacheManager differentCacheManager = differentFactory.GetCacheManager("InIsoStorePersistence");
            int count = differentCacheManager.Count;
            differentCacheManager.Dispose();

            Assert.AreEqual(1, count, "If we actually persisted added item, different cache manager should see item, too.");
        }
        private void CacheManagerTest(string instanceName)
        {
            CacheManagerFactory factory = new CacheManagerFactory(Context);
            CacheManager mgr = factory.GetCacheManager(instanceName);

            string key = "key1";
            string val = "value123";

            mgr.Add(key, val);

            string result = (string)mgr.GetData(key);
            Assert.AreEqual(val, result, "result");
        }
        public void CanCreateIsolatedStorageCacheManager()
        {
            cacheManager.Add("bab", "foo");
            Assert.AreEqual(1, cacheManager.Count);

            CacheManagerFactory differentFactory = new CacheManagerFactory(TestConfigurationSource.GenerateConfiguration());
            CacheManager differentCacheManager = (CacheManager)differentFactory.Create("InIsoStorePersistence");

            int count = differentCacheManager.Count;
            differentCacheManager.Dispose();

            Assert.AreEqual(1, count, "If we actually persisted added item, different cache manager should see item, too.");
        }
        void CacheManagerTest(string instanceName)
        {
            CacheManagerFactory factory = new CacheManagerFactory(TestConfigurationSource.GenerateConfiguration());
            ICacheManager mgr = factory.Create(instanceName);

            string key = "key1";
            string val = "value123";

            mgr.Add(key, val);

            string result = (string)mgr.GetData(key);
            Assert.AreEqual(val, result, "result");
        }
Beispiel #13
0
        /// <summary>
        /// 登录后绑定
        /// </summary>
        /// <param name="token"></param>
        /// <param name="socialUser"></param>
        /// <returns></returns>
        public AdvancedResult <string> BindSocialUserAfterLogin(string token, SocialUser socialUser)
        {
            AdvancedResult <string> result = new AdvancedResult <string>();

            try
            {
                if (!CacheManagerFactory.GetMemoryManager().Contains(token))
                {
                    result.Error = AppError.ERROR_PERSON_NOT_LOGIN;
                }
                else
                {
                    SocialUserAccessor.Instance.Insert(socialUser);
                    result.Error = AppError.ERROR_SUCCESS;
                }
            }
            catch (Exception e)
            {
                result.Error     = AppError.ERROR_FAILED;
                result.ExMessage = e.ToString();
            }
            return(result);
        }
Beispiel #14
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();

            services.AddDistributedMemoryCache();
            services.AddDistributedRedisCache(option =>
            {
                option.Configuration = "localhost:6379";
                option.InstanceName  = "master";
            });

            services.AddTransient <IBookService, BookService>();
            services.AddTransient <HttpClient>();
            services.AddSingleton <IApiEndPointsSetting>(Configuration.GetSection("ApiEndPoints").Get <ApiEndPointsSetting>());
            services.AddTransient <IRepository <int, Book>, BookRepository>();
            services.AddTransient <IRepository <int, Comment>, CommentRepository>();

            var cacheSettings = Configuration.GetSection("CacheOptions").Get <CacheSetting[]>();

            services.AddSingleton <ICacheManager>(serviceProvider =>
                                                  new SampleCacheManager(CacheManagerFactory.CreateCacheHierachy(serviceProvider.GetServices <IDistributedCache>().ToList(), cacheSettings.ToList <ICacheSetting>()))
                                                  );
        }
Beispiel #15
0
        public JsonResult Logout()
        {
            var        Res    = new JsonResult();
            RespResult result = new RespResult();

            try
            {
                if (CacheManagerFactory.GetMemoryManager().Contains(token))
                {
                    CacheManagerFactory.GetMemoryManager().Remove(token);
                }

                result.Error = AppError.ERROR_SUCCESS;
            }
            catch (Exception e)
            {
                result.Error     = AppError.ERROR_FAILED;
                result.ExMessage = e.ToString();
            }
            Res.Data = result;
            Res.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
            return(Res);
        }
        public AdvancedResult <bool> CheckLogin(string token)
        {
            AdvancedResult <bool> result = new AdvancedResult <bool>();

            try
            {
                if (CacheManagerFactory.GetMemoryManager().Contains(token))
                {
                    result.Data  = true;
                    result.Error = AppError.ERROR_SUCCESS;
                }
                else
                {
                    result.Error = AppError.ERROR_PERSON_NOT_LOGIN;
                }
            }
            catch (Exception e)
            {
                result.Error     = AppError.ERROR_FAILED;
                result.ExMessage = e.ToString();
            }
            return(result);
        }
        //获取单个销售机会的拜访记录(销售机会ID,toke)返回 拜访列表(拜访方式,拜访描述,报价,地点),赢率
        public JsonResult GetVisitInfo(int cid, int pageIndex, int pageSize)
        {
            var Res = new JsonResult();
            AdvancedResult <SingleVisitListModel> result = new AdvancedResult <SingleVisitListModel>();

            try
            {
                if (CacheManagerFactory.GetMemoryManager().Contains(token))
                {
                    if (!CheckUserFunction("1205"))
                    {
                        result.Error            = AppError.ERROR_PERMISSION_FORBID;
                        Res.Data                = result;
                        Res.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
                        return(Res);
                    }
                    PageEntity <MarketingVisit> returnValue = new PageEntity <MarketingVisit>();
                    result.Data       = new SingleVisitListModel();
                    result.Data.Vlist = MarketingVisitAccessor.Instance.Search(cid, pageIndex, pageSize);
                    result.Data.Rate  = MarketingChanceAccessor.Instance.Get(cid).Rate;
                    result.Error      = AppError.ERROR_SUCCESS;
                }
                else
                {
                    result.Error = AppError.ERROR_PERSON_NOT_LOGIN;
                }
            }
            catch (Exception e)
            {
                result.Error     = AppError.ERROR_FAILED;
                result.ExMessage = e.ToString();
            }

            Res.Data = result;
            Res.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
            return(Res);
        }
Beispiel #18
0
        /// <summary>
        /// 根据合同编号获取应收款详情(合同编号,token)
        /// 返回 (合同编号,合同名称,客户名称,合同有效期1,合同有效期2,合同承办人,
        /// 合同签订时间,合同金额,付款方式列表(序号,收款时间,实际收款时间,收款状态))
        /// </summary>
        /// <param name="eid"></param>
        /// <returns></returns>
        public JsonResult GetHowToPayByEID(string contractNo)
        {
            var Res = new JsonResult();
            AdvancedResult <ContractInfo> result = new AdvancedResult <ContractInfo>();

            try
            {
                if (CacheManagerFactory.GetMemoryManager().Contains(token))
                {
                    if (!CheckUserFunction("1103"))
                    {
                        result.Error            = AppError.ERROR_PERMISSION_FORBID;
                        Res.Data                = result;
                        Res.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
                        return(Res);
                    }
                    // int ownerid = Convert.ToInt32(CacheManagerFactory.GetMemoryManager().Get(token));
                    ContractInfo con = new ContractInfo();
                    con = ContractInfoAccessor.Instance.Get(contractNo);
                    con.HowtopayList = ContractHowtopayAccessor.Instance.Search(contractNo, 0);
                    result.Error     = AppError.ERROR_SUCCESS;
                    result.Data      = con;
                }
                else
                {
                    result.Error = AppError.ERROR_PERSON_NOT_LOGIN;
                }
            }
            catch (Exception e)
            {
                result.Error     = AppError.ERROR_FAILED;
                result.ExMessage = e.ToString();
            }
            Res.Data = result;
            Res.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
            return(Res);
        }
Beispiel #19
0
        //关联企业
        public JsonResult EditeUserEntId(int entId)
        {
            var        Res    = new JsonResult();
            RespResult result = new RespResult();

            try
            {
                if (!CacheManagerFactory.GetMemoryManager().Contains(token))
                {
                    result.Error = AppError.ERROR_PERSON_NOT_LOGIN;
                }
                else
                {
                    int userid = Convert.ToInt32(CacheManagerFactory.GetMemoryManager().Get(token));
                    if (userid > 0)
                    {
                        SysUser olduser = SysUserAccessor.Instance.Get(userid);
                        olduser.EntId = entId;

                        SysUserAccessor.Instance.Update(olduser);
                        result.Error = AppError.ERROR_SUCCESS;
                    }
                    else
                    {
                        result.Error = AppError.ERROR_FAILED;
                    }
                }
            }
            catch (Exception e)
            {
                result.Error     = AppError.ERROR_FAILED;
                result.ExMessage = e.ToString();
            }
            Res.Data = result;
            Res.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
            return(Res);
        }
        /// <summary>
        /// 通过权限ID获取用户信息 返回 用户列表(账号,姓名,sex,头像,手机号,入职时间,权限ID)
        /// </summary>
        /// <param name="roleId">0获取全部,-1 获取未审核用户</param>
        /// <returns></returns>
        public JsonResult SearchUserListByRoleId(int roleId)
        {
            var Res = new JsonResult();
            AdvancedResult <List <SysUser> > result = new AdvancedResult <List <SysUser> >();
            List <SysUser> userlist = new List <SysUser>();

            try
            {
                if (CacheManagerFactory.GetMemoryManager().Contains(token))
                {
                    if (!CheckUserFunction(26))
                    {
                        result.Error            = AppError.ERROR_PERMISSION_FORBID;
                        Res.Data                = result;
                        Res.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
                        return(Res);
                    }
                    userlist = SysUserAccessor.Instance.LoadSysUserByRoleId(CurrentUser.EntId, roleId);

                    result.Error = AppError.ERROR_SUCCESS;
                    result.Data  = userlist;
                }
                else
                {
                    result.Error = AppError.ERROR_PERSON_NOT_LOGIN;
                }
            }
            catch (Exception e)
            {
                result.Error     = AppError.ERROR_FAILED;
                result.ExMessage = e.ToString();
            }

            Res.Data = result;
            Res.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
            return(Res);
        }
Beispiel #21
0
        /// <summary>
        /// 修改用户密码
        /// </summary>
        /// <param name="oldpwd"></param>
        /// <param name="newpwd"></param>
        /// <param name="token"></param>
        /// <returns></returns>
        public JsonResult UpdatePwd(string oldpwd, string newpwd)
        {
            var        Res    = new JsonResult();
            RespResult result = new RespResult();

            try
            {
                if (!CacheManagerFactory.GetMemoryManager().Contains(token))
                {
                    result.Error = AppError.ERROR_PERSON_NOT_LOGIN;
                }
                else
                {
                    SysUser olduser = SysUserAccessor.Instance.Get(CurrentUser.UserId);

                    if (SecurityHelper.MD5(oldpwd) != olduser.Pwd)
                    {
                        result.Error = AppError.ERROR_FAILED;
                    }
                    else
                    {
                        olduser.Pwd = SecurityHelper.MD5(newpwd);

                        SysUserAccessor.Instance.Update(olduser);
                        result.Error = AppError.ERROR_SUCCESS;
                    }
                }
            }
            catch (Exception e)
            {
                result.Error     = AppError.ERROR_FAILED;
                result.ExMessage = e.ToString();
            }
            Res.Data = result;
            Res.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
            return(Res);
        }
        //---------------员工管理-----------------

//        通过token获取企业所有权限 返回 权限列表(权限ID,全部(人数))

        public JsonResult SearchEntRole()
        {
            var Res = new JsonResult();
            AdvancedResult <List <SysRole> > result = new AdvancedResult <List <SysRole> >();
            List <SysRole> rolelist = new List <SysRole>();

            try
            {
                if (CacheManagerFactory.GetMemoryManager().Contains(token))
                {
                    if (!CheckUserFunction(26))
                    {
                        result.Error            = AppError.ERROR_PERMISSION_FORBID;
                        Res.Data                = result;
                        Res.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
                        return(Res);
                    }
                    rolelist = SysRoleAccessor.Instance.LoadEntRole(CurrentUser.EntId);
                    rolelist.Single(o => o.RoleId == 0).Count = rolelist.Single(o => o.RoleId == 0).Count + rolelist.Single(o => o.RoleId == -1).Count;
                    result.Error = AppError.ERROR_SUCCESS;
                    result.Data  = rolelist;
                }
                else
                {
                    result.Error = AppError.ERROR_PERSON_NOT_LOGIN;
                }
            }
            catch (Exception e)
            {
                result.Error     = AppError.ERROR_FAILED;
                result.ExMessage = e.ToString();
            }

            Res.Data = result;
            Res.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
            return(Res);
        }
Beispiel #23
0
        public JsonResult UpdateNewPwd(string userToken, string newPwd)
        {
            var        Res    = new JsonResult();
            RespResult result = new RespResult();

            try
            {
                if (!CacheManagerFactory.GetMemoryManager().Contains(userToken))
                {
                    result.Error = AppError.ERROR_FAILED;
                }
                else
                {
                    int userid = Convert.ToInt32(CacheManagerFactory.GetMemoryManager().Get(userToken));
                    if (userid > 0)
                    {
                        SysUser olduser = SysUserAccessor.Instance.Get(userid);
                        olduser.Pwd = SecurityHelper.MD5(newPwd);

                        SysUserAccessor.Instance.Update(olduser);
                        result.Error = AppError.ERROR_SUCCESS;
                    }
                    else
                    {
                        result.Error = AppError.ERROR_FAILED;
                    }
                }
            }
            catch (Exception e)
            {
                result.Error     = AppError.ERROR_FAILED;
                result.ExMessage = e.ToString();
            }
            Res.Data = result;
            Res.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
            return(Res);
        }
        //根据用户ID查询个人客户(token)返回 个人客户列表(姓名,年龄,所属行业,所在地,联系方式)
        public JsonResult SearchCustomerPrivByOwnerId(int pageIndex, int pageSize)
        {
            var Res = new JsonResult();
            AdvancedResult <PageEntity <CustomerPrivate> > result = new AdvancedResult <PageEntity <CustomerPrivate> >();

            if (CacheManagerFactory.GetMemoryManager().Contains(token))
            {
                if (!CheckUserFunction(8))
                {
                    result.Error            = AppError.ERROR_PERMISSION_FORBID;
                    Res.Data                = result;
                    Res.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
                    return(Res);
                }

                int ownerid = Convert.ToInt32(CacheManagerFactory.GetMemoryManager().Get(token));
                try
                {
                    PageEntity <CustomerPrivate> list = new PageEntity <CustomerPrivate>();
                    list         = CustomerPrivateAccessor.Instance.SearchCustomerPrivByOwnerId(ownerid, pageIndex, pageSize);
                    result.Error = AppError.ERROR_SUCCESS;
                    result.Data  = list;
                }
                catch (Exception e)
                {
                    result.Error     = AppError.ERROR_FAILED;
                    result.ExMessage = e.ToString();
                }
            }
            else
            {
                result.Error = AppError.ERROR_PERSON_NOT_LOGIN;
            }
            Res.Data = result;
            Res.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
            return(Res);
        }
Beispiel #25
0
        public void TestHit()
        {
            var cache = CacheManagerFactory.CreateManager();

            if (cache is MemoryCacheManager mem)
            {
                //mem.Capacity = 1000;
            }

            for (var i = 0; i < 100; i++)
            {
                cache.Add("a" + i, i);
            }

            Assert.AreEqual(cache.Get("a0"), 0);

            for (var i = 0; i < 200; i++)
            {
                cache.Add("b" + i, i);
            }

            Assert.AreEqual(cache.Get("a88"), 88);
            Assert.AreEqual(cache.Get("a2"), 2);
            Assert.AreEqual(cache.Get("a2"), 2);

            for (var i = 0; i < 99; i++)
            {
                cache.Add("b" + i, i);
            }

            Thread.Sleep(6000);

            //Assert.AreEqual(cache.Get("a2"), 2);
            //Assert.IsFalse(cache.Contains("a0"));
            //Assert.IsFalse(cache.Contains("a5"));
        }
Beispiel #26
0
        public JsonResult AddPic(string sourcePath, PicType picType, string description)
        {
            var Res = new JsonResult();
            AdvancedResult <ResPic> result = new AdvancedResult <ResPic>();

            try
            {
                if (!CacheManagerFactory.GetMemoryManager().Contains(token))
                {
                    result.Error = AppError.ERROR_PERSON_NOT_LOGIN;
                }
                else
                {
                    int    userid = Convert.ToInt32(CacheManagerFactory.GetMemoryManager().Get(token));
                    ResPic pic    = new ResPic();
                    pic.ObjId          = userid;
                    pic.ObjType        = picType;
                    pic.PicUrl         = sourcePath;
                    pic.PicDescription = description;
                    pic.State          = StateType.Active;

                    int picid = ResPicAccessor.Instance.Insert(pic);
                    pic.PicId    = picid;
                    result.Data  = pic;
                    result.Error = AppError.ERROR_SUCCESS;
                }
            }
            catch (Exception e)
            {
                result.Error     = AppError.ERROR_FAILED;
                result.ExMessage = e.ToString();
            }
            Res.Data = result;
            Res.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
            return(Res);
        }
Beispiel #27
0
        /// <summary>
        /// 将对象克隆为指定类型的实例。
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="conversionType"></param>
        /// <returns></returns>
        private static object CloneTo(this object obj, Type conversionType)
        {
            Guard.ArgumentNull(obj, "obj");
            var sourceType = obj.GetType();

            if (conversionType.IsAssignableFrom(sourceType))
            {
                return(obj);
            }

            //接口或抽象类,生成一个实现类
            if (conversionType.IsInterface || conversionType.IsAbstract)
            {
                conversionType = conversionType.BuildImplementType();
            }

            //如果可枚举
            var enumerable = obj as IEnumerable;

            if (enumerable != null && typeof(IEnumerable).IsAssignableFrom(conversionType))
            {
                if (typeof(IDictionary).IsAssignableFrom(conversionType))
                {
                    return(ConvertToDictionary(enumerable, conversionType));
                }
                else
                {
                    return(ConvertToEnumerable(enumerable, conversionType));
                }
            }

            var cacheMgr = CacheManagerFactory.CreateManager();
            var func     = cacheMgr.TryGet(sourceType.FullName + "-" + conversionType.FullName, () => BuildCloneToDelegate(obj, conversionType));

            return(func.DynamicInvoke(obj));
        }
        /// <summary>
        /// //获取销售机会列表(同获取客户信息列表(包括个人跟企业))(token)
        /// 返回 列表(机会描述,联系人,联系方式,创建时间,企业/个人客户)
        /// </summary>
        /// <param name="entid"></param>
        /// <returns></returns>
        public JsonResult SearchMarketingList(int pageIndex, int pageSize)
        {
            var Res = new JsonResult();
            AdvancedResult <PageEntity <MarketingChance> > result = new AdvancedResult <PageEntity <MarketingChance> >();

            try
            {
                if (CacheManagerFactory.GetMemoryManager().Contains(token))
                {
                    if (!CheckUserFunction("1201"))
                    {
                        result.Error            = AppError.ERROR_PERMISSION_FORBID;
                        Res.Data                = result;
                        Res.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
                        return(Res);
                    }
                    PageEntity <MarketingChance> returnValue = new PageEntity <MarketingChance>();
                    returnValue  = MarketingChanceAccessor.Instance.Search(1, CurrentUser.UserId, pageIndex, pageSize);//1:未拜访 2:已拜访
                    result.Error = AppError.ERROR_SUCCESS;
                    result.Data  = returnValue;
                }
                else
                {
                    result.Error = AppError.ERROR_PERSON_NOT_LOGIN;
                }
            }
            catch (Exception e)
            {
                result.Error     = AppError.ERROR_FAILED;
                result.ExMessage = e.ToString();
            }

            Res.Data = result;
            Res.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
            return(Res);
        }
        //获取单个销售机会详情(销售机会ID,token) 返回 (机会类型,客户类型,机会描述,联系人,联系方式,录入时间)
        public JsonResult GetMarketingInfo(int cid)
        {
            var Res = new JsonResult();
            AdvancedResult <MarketingChance> result = new AdvancedResult <MarketingChance>();

            try
            {
                if (CacheManagerFactory.GetMemoryManager().Contains(token))
                {
                    if (!CheckUserFunction("1205"))
                    {
                        result.Error            = AppError.ERROR_PERMISSION_FORBID;
                        Res.Data                = result;
                        Res.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
                        return(Res);
                    }
                    MarketingChance chance = new MarketingChance();
                    chance       = MarketingChanceAccessor.Instance.Get(cid);
                    result.Error = AppError.ERROR_SUCCESS;
                    result.Data  = chance;
                }
                else
                {
                    result.Error = AppError.ERROR_PERSON_NOT_LOGIN;
                }
            }
            catch (Exception e)
            {
                result.Error     = AppError.ERROR_FAILED;
                result.ExMessage = e.ToString();
            }

            Res.Data = result;
            Res.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
            return(Res);
        }
Beispiel #30
0
        /// <summary>
        /// 从 <see cref="ImportConfigurationSetting"/> 对象中解析出 <see cref="ComposablePartCatalog"/> 对象。
        /// </summary>
        /// <param name="setting">用于配置目录的配置对象。</param>
        /// <returns>从 <paramref name="setting"/> 解析出的 <see cref="ComposablePartCatalog"/> 对象。</returns>
        protected ComposablePartCatalog ResolveCatalog(ImportConfigurationSetting setting)
        {
            if (!string.IsNullOrEmpty(setting.Assembly))
            {
                files = new List <string>();
                var cacheMgr = CacheManagerFactory.CreateManager();
                return(cacheMgr.TryGet(setting.Assembly, () =>
                {
                    try
                    {
                        var assembly = Assembly.Load(new AssemblyName(setting.Assembly));
                        files.Add(assembly.Location);
                        return new AssemblyCatalog(assembly);
                    }
                    catch (Exception ex)
                    {
                        throw new CompositionException(SR.GetString(SRKind.UnableLoadAssembly, setting.Assembly), ex);
                    }
                }));
            }

            return(setting.ImportType == null || setting.ContractType == null
                       ? null : new TypeCatalog(setting.ImportType));
        }
Beispiel #31
0
        /// <summary>
        /// 删除当个宝贝相关信息
        /// </summary>
        /// <param name="bbID">宝贝ID</param>
        /// <returns></returns>
        public RespResult DeleteBBPic(int picID, string token)
        {
            RespResult result = new RespResult();

            try
            {
                if (!CacheManagerFactory.GetMemoryManager().Contains(token))
                {
                    result.Error = AppError.ERROR_PERSON_NOT_LOGIN;
                }
                else
                {
                    int userid = Convert.ToInt32(CacheManagerFactory.GetMemoryManager().Get(token));
                    ResPicAccessor.Instance.Delete(picID);
                    result.Error = AppError.ERROR_SUCCESS;
                }
            }
            catch (Exception e)
            {
                result.Error     = AppError.ERROR_FAILED;
                result.ExMessage = e.ToString();
            }
            return(result);
        }
        //根据联系人名称查询个人客户(联系人名称,token)返回(联系方式,个人信息)
        public JsonResult SearchCustomerPrivateByName(string name)
        {
            var Res = new JsonResult();
            AdvancedResult <List <CustomerPrivate> > result = new AdvancedResult <List <CustomerPrivate> >();

            if (CacheManagerFactory.GetMemoryManager().Contains(token))
            {
                if (!CheckUserFunction(8))
                {
                    result.Error            = AppError.ERROR_PERMISSION_FORBID;
                    Res.Data                = result;
                    Res.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
                    return(Res);
                }

                try
                {
                    List <CustomerPrivate> list = new List <CustomerPrivate>();
                    list         = CustomerPrivateAccessor.Instance.SearchCustomerPrivByName(name);
                    result.Error = AppError.ERROR_SUCCESS;
                    result.Data  = list;
                }
                catch (Exception e)
                {
                    result.Error     = AppError.ERROR_FAILED;
                    result.ExMessage = e.ToString();
                }
            }
            else
            {
                result.Error = AppError.ERROR_PERSON_NOT_LOGIN;
            }
            Res.Data = result;
            Res.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
            return(Res);
        }
Beispiel #33
0
        //获取与我相关的宝贝回复列表
        public AdvancedResult <PageEntity <GenReply> > LoadMyBBReplyList(string token, int pageInex, int pageSize)
        {
            AdvancedResult <PageEntity <GenReply> > result = new AdvancedResult <PageEntity <GenReply> >();

            try
            {
                if (!CacheManagerFactory.GetMemoryManager().Contains(token))
                {
                    result.Error = AppError.ERROR_PERSON_NOT_LOGIN;
                }
                else
                {
                    int userid = Convert.ToInt32(CacheManagerFactory.GetMemoryManager().Get(token));
                    result.Data  = GenReplyAccessor.Instance.Search(0, ReplyType.BB, userid, StateType.Active, 0, 0, pageInex, pageSize);
                    result.Error = AppError.ERROR_SUCCESS;
                }
            }
            catch (Exception e)
            {
                result.Error     = AppError.ERROR_FAILED;
                result.ExMessage = e.ToString();
            }
            return(result);
        }
        //
        // GET: /ProductManagement/Production/

        #region IProductionController 成员
        /// <summary>
        /// 根据分类获取产品列表(Ok)
        /// </summary>
        /// <param name="typeid">分类ID	</param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <returns>产品列表(产品名称,售价,最低售价,库存。。。)</returns>
        public JsonResult SearchProductionSByType(int typeid, int pageIndex, int pageSize)
        {
            var Res = new JsonResult();
            AdvancedResult <PageEntity <ProProduction> > result = new AdvancedResult <PageEntity <ProProduction> >();

            try
            {
                if (!CheckUserFunction("2013"))
                {
                    result.Error            = AppError.ERROR_PERMISSION_FORBID;
                    Res.Data                = result;
                    Res.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
                    return(Res);
                }
                if (CacheManagerFactory.GetMemoryManager().Contains(token))
                {
                    PageEntity <ProProduction> list = new PageEntity <ProProduction>();
                    int userid = Convert.ToInt32(CacheManagerFactory.GetMemoryManager().Get(token));
                    list         = ProProductionAccessor.Instance.Search(string.Empty, typeid, userid, pageIndex, pageSize);
                    result.Error = AppError.ERROR_SUCCESS;
                    result.Data  = list;
                }
                else
                {
                    result.Error = AppError.ERROR_PERSON_NOT_LOGIN;
                }
            }
            catch (Exception e)
            {
                result.Error     = AppError.ERROR_FAILED;
                result.ExMessage = e.ToString();
            }
            Res.Data = result;
            Res.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
            return(Res);
        }
        public void CleanAllCaches_RemovesExpiredCacheItems_Success()
        {
            CacheManagerFactory sut = new CacheManagerFactory();

            try
            {
                CacheManager testCache = sut.CreateCache("clear all", new TimeSpan(0, 0, 0, 0, 15), false, true);

                Assert.IsNotNull(testCache);
                testCache.Add("test 1", new CacheItem("test 1", true));

                Assert.AreEqual(1, testCache.Count);

                Thread.Sleep(30);

                sut.CleanAllCaches();

                Assert.AreEqual(0, testCache.Count);
            }
            finally
            {
                sut.RemoveCache("clear all");
            }
        }
        /// <summary>
        /// 根据采购批次确认应付款(采购批次,token)返回(true/false)
        /// </summary>
        /// <param name="eid"></param>
        /// <returns></returns>
        public JsonResult ConfirmPay(string PCode, int PId, int Num)
        {
            var        Res    = new JsonResult();
            RespResult result = new RespResult();

            try
            {
                if (CacheManagerFactory.GetMemoryManager().Contains(token))
                {
                    if (!CheckUserFunction(15))
                    {
                        result.Error            = AppError.ERROR_PERMISSION_FORBID;
                        Res.Data                = result;
                        Res.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
                        return(Res);
                    }
                    ProProductonDetailAccessor.Instance.ConfirmPay(PCode);
                    //确认付款更新库存
                    ProProduction pro = ProProductionAccessor.Instance.Get(PId);
                    ProProductionAccessor.Instance.UpdateStockCount(PId, pro.StockCount + Num);
                    result.Error = AppError.ERROR_SUCCESS;
                }
                else
                {
                    result.Error = AppError.ERROR_PERSON_NOT_LOGIN;
                }
            }
            catch (Exception e)
            {
                result.Error     = AppError.ERROR_FAILED;
                result.ExMessage = e.ToString();
            }
            Res.Data = result;
            Res.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
            return(Res);
        }
        /// <summary>
        /// 获取产品入库单列表
        /// </summary>
        /// <param name="pid"></param>
        /// <returns></returns>
        public JsonResult SearchProductonDetailList(int pid, int pageIndex, int pageSize)
        {
            var Res = new JsonResult();
            AdvancedResult <PageEntity <ProProductonDetail> > result = new AdvancedResult <PageEntity <ProProductonDetail> >();

            try
            {
                if (CacheManagerFactory.GetMemoryManager().Contains(token))
                {
                    if (!CheckUserFunction("2011"))
                    {
                        result.Error            = AppError.ERROR_PERMISSION_FORBID;
                        Res.Data                = result;
                        Res.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
                        return(Res);
                    }

                    PageEntity <ProProductonDetail> list = new PageEntity <ProProductonDetail>();
                    list         = ProProductonDetailAccessor.Instance.Search(CurrentUser.UserId, pid, CurrentUser.EntId, pageIndex, pageSize);
                    result.Error = AppError.ERROR_SUCCESS;
                    result.Data  = list;
                }
                else
                {
                    result.Error = AppError.ERROR_PERSON_NOT_LOGIN;
                }
            }
            catch (Exception e)
            {
                result.Error     = AppError.ERROR_FAILED;
                result.ExMessage = e.ToString();
            }
            Res.Data = result;
            Res.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
            return(Res);
        }
		public void CreateFactory()
        {
			factory = new CacheManagerFactory(TestConfigurationSource.GenerateConfiguration());
        }
        public void ItemsInitializeTheirExpirationsProperlyWhenLoaded()
        {
            cache.Add("key", "value", CacheItemPriority.Normal, null, new MockExpiration());

			CacheManager differentCacheManager = new CacheManagerFactory(TestConfigurationSource.GenerateConfiguration()).Create("SecondInDatabasePersistence");
            differentCacheManager.Dispose();

            Assert.AreEqual(1, initializationCount, "Act of creating new cache manager should have caused items to be loaded, initializing expirations");
        }
 public void GetCacheManagerWithNullEncryption()
 {
     CacheManagerFactory factory = new CacheManagerFactory(Context);
     CacheManager mgr = factory.GetCacheManager("InMemoryPersistenceWithNullEncryption");
     CacheManagerTest(mgr);
 }
 public void GetCacheManagerWithNullEncryption()
 {
     CacheManagerFactory factory = new CacheManagerFactory(TestConfigurationSource.GenerateConfiguration());
     ICacheManager mgr = factory.Create("InMemoryPersistenceWithNullEncryption");
     CacheManagerTest(mgr);
 }
        public void ThenReturnsNewlyConfiguredInstanceAfterReconfigureOfStorageEncryptionProvider()
        {
            MockStorageEncryptionProvider.Instantiated = false;

            storageEncryptionProviderData = new MockStorageEncryptionProviderData("Storage Encryption");
            cacheSettings.EncryptionProviders.Add(storageEncryptionProviderData);
            
            IsolatedStorageCacheStorageData isolatedStoreData = new IsolatedStorageCacheStorageData();
            isolatedStoreData.Name = "Isolated Storage";
            isolatedStoreData.PartitionName = "entlib";
            isolatedStoreData.StorageEncryption = storageEncryptionProviderData.Name;

            cacheSettings.BackingStores.Add(isolatedStoreData);
            
            cacheManagerData.CacheStorage = isolatedStoreData.Name;
            configurationSource.DoSourceChanged(new string[] { CacheManagerSettings.SectionName });

            CacheManagerFactory factory = new CacheManagerFactory(serviceLcoator);
            ICacheManager cacheManager = factory.Create(cacheSettings.DefaultCacheManager);
            Assert.IsTrue(MockStorageEncryptionProvider.Instantiated);
        }
 public void CreateFactory()
 {
     factory = new CacheManagerFactory(Context);
 }
        public void TestInitialize()
        {
            CacheManagerFactory factory = new CacheManagerFactory(TestConfigurationSource.GenerateConfiguration());

            cache = factory.Create("InDatabasePersistence");
        }
 public void TestInitialize()
 {
     CacheManagerFactory factory = new CacheManagerFactory(TestConfigurationSource.GenerateConfiguration());
     cache = (CacheManager)factory.Create("InDatabasePersistence");
 }
Beispiel #46
0
        public void CreateCache()
        {
            removedKey = null;
            expiredValue = null;
            removalReason = CacheItemRemovedReason.Unknown;

            factory = new CacheManagerFactory(Context);
            cacheMgr = factory.GetCacheManager("SmallInMemoryPersistence");
        }
        public void StartCacheProcesses()
        {
            factory = new CacheManagerFactory(Context);
            shortCacheManager = factory.GetCacheManager("ShortInMemoryPersistence");
            smallCacheManager = factory.GetCacheManager("SmallInMemoryPersistence");

            expiredKeys = "";
            expiredValues = "";
            removalReasons = "";
        }
 public override void FixtureSetup()
 {
     base.FixtureSetup ();
     CacheManagerFactory factory = new CacheManagerFactory(Context);
     cache = factory.GetCacheManager("InDatabasePersistence");
 }
        public void CreateManagerInnerTest()
        {
            var cacheManager = CacheManagerFactory.CreateManager("inner");

            Assert.IsNotNull(cacheManager);
        }
Beispiel #50
0
 public static void ClearCache(this Repository repository)
 {
     CacheManagerFactory.ClearWithNotify(repository.GetKey());
 }
		public void CreateCacheManager()
        {
			factory = new CacheManagerFactory(TestConfigurationSource.GenerateConfiguration());
            cacheManager = factory.Create("InIsoStorePersistence");
            cacheManager.Flush();
        }
        public void CreateManagerNoneTest()
        {
            var cacheManager = CacheManagerFactory.CreateManager("none");

            Assert.IsNull(cacheManager);
        }
 public void CreateCacheManager()
 {
     factory = new CacheManagerFactory(Context);
     cacheManager = factory.GetCacheManager("InIsoStorePersistence");
 }
Beispiel #54
0
 public Schema GetActualSchema()
 {
     return(CacheManagerFactory.GetActual(Name, GetType().Name, this));
 }
        public void ThenReturnsNewlyConfiguredInstanceAfterReconfigureOfBackingStore()
        {
            MockCustomStorageBackingStore.Instantiated = false;

            cacheSettings.BackingStores.Remove("Null Storage");
            cacheSettings.BackingStores.Add(new CustomCacheStorageData("Custom Store", typeof(MockCustomStorageBackingStore)));
            cacheManagerData.CacheStorage = "Custom Store";

            configurationSource.DoSourceChanged(new string[] { CacheManagerSettings.SectionName });

            CacheManagerFactory factory = new CacheManagerFactory(serviceLcoator);
            ICacheManager cacheManager = factory.Create(cacheSettings.DefaultCacheManager);
            Assert.IsTrue(MockCustomStorageBackingStore.Instantiated);
        }