Example #1
0
File: WeChat.cs Project: MrNor/WxQY
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="corpID">企业Id</param>
 /// <param name="secret">管理组的凭证密钥</param>
 /// <param name="agentID">企业应用的id</param>
 public WeChat(string corpID, string secret, string agentID)
 {
     this._corpID = corpID;
     this._secret = secret;
     this._agentID = agentID;
     this._cache = CacheHelper.GetInstance();
 }
Example #2
0
        public SiteManager(
            SiteContext currentSite,
            ISiteCommands siteCommands,
            ISiteQueries siteQueries,
            IUserCommands userCommands,
            IUserQueries userQueries,
            SiteDataProtector dataProtector,
            IHttpContextAccessor contextAccessor,
            ILogger<SiteManager> logger,
            IOptions<MultiTenantOptions> multiTenantOptionsAccessor,
            IOptions<SiteConfigOptions> setupOptionsAccessor,
            CacheHelper cacheHelper
            )
        {

            commands = siteCommands;
            queries = siteQueries;
            this.userCommands = userCommands;
            this.userQueries = userQueries;
            multiTenantOptions = multiTenantOptionsAccessor.Value;
            setupOptions = setupOptionsAccessor.Value;
            _context = contextAccessor?.HttpContext;
            this.dataProtector = dataProtector;
            log = logger;

            //resolver = siteResolver;
            siteSettings = currentSite;
            this.cacheHelper = cacheHelper;
        }
Example #3
0
File: WeChat.cs Project: MrNor/WxQY
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="corpID">企业Id</param>
 /// <param name="secret">管理组的凭证密钥</param>
 /// <param name="agentID">企业应用的id</param>
 /// <param name="token">可由企业任意填写,用于生成签名</param>
 /// <param name="encodingAESKey">用于消息体的加密,是AES密钥的Base64编码</param>
 public WeChat(string corpID, string secret, string agentID, string token, string encodingAESKey)
 {
     this._corpID = corpID;
     this._secret = secret;
     this._agentID = agentID;
     this._token = token;
     this._encodingAESKey = encodingAESKey;
     this._cache = CacheHelper.GetInstance();
 }
        public void GetCollection_with_caching_enabled_expect_correct_cacheKey_retrieved()
        {
            _config.Stub(c => c.Cache).Return(CacheStub);
            _config.EnableCaching = true;

            var helper = new CacheHelper<FakeObject>(_config);

            helper.GetCollection();

            _config.Cache.AssertWasCalled(c => c.Get(FakeObject.RootCacheKey));
        }
        public void GetObject_caching_enabled_expect_correct_cacheKey_retrieved()
        {
            _config.Stub(c => c.Cache).Return(CacheStub);
            _config.EnableCaching = true;

            var helper = new CacheHelper<FakeObject>(_config);

            helper.GetObject(FakeObject.InstanceIdentifier);

            _config.Cache.AssertWasCalled(c => c.Get(FakeObject.CacheKey));
        }
Example #6
0
 /// <summary>
 /// 获取Cache单例
 /// </summary>
 public static CacheHelper GetInstance()
 {
     if (instance == null)
     {
         lock (obj)
         {
             if (instance == null)
             {
                 instance = new CacheHelper();
             }
         }
     }
     return instance;
 }
        public List<BannerItem> GetGroupFeed()
        {
            //var token = "159921737683962|5w_vxQq5eTz2wG1y8wKQl3yuP-8";
            //var client = new FacebookClient(token);
            var cacheHlp = new CacheHelper();

            List<BannerItem> bannerItems = new List<BannerItem>();
            var fbItems = cacheHlp.GetFbItems();
            var ybItems = cacheHlp.GetYbItems();
            //var reader = new FeedReader();
            //var ybItems = reader.YoutubeItems();
            List<BannerItem> umbracoEvents = UmbracoEvents();
            bannerItems.AddRange(umbracoEvents);
            bannerItems.AddRange(fbItems);
            bannerItems.AddRange(ybItems);
            bannerItems.OrderBy(x=>x.published);
            //bannerItems.Shuffle();
            return bannerItems;
        }
        /// <summary>
        /// �����湤����������
        /// </summary>
        /// <returns>������������</returns>
        public static IDBHelper CreateFactoryByCache()
        {
            string typeName = DBProviderName;
            string cacheKey = string.Format(CultureInfo.InvariantCulture, "Reflection.CreateInstance.{0}", typeName);

            object db;

            CacheHelper cache = new CacheHelper();
            if (cache.Get(cacheKey) == null)
            {
                db = ReflectionHelper.CreateInstance(typeName);
                cache.Add(cacheKey, db);
            }
            else
            {
                db = cache.Get(cacheKey);
            }
            return (IDBHelper) db;
        }
Example #9
0
 private void LoadSettings()
 {
     siteSettings = CacheHelper.GetCurrentSiteSettings();
     RegexRelativeImageUrlPatern = SecurityHelper.RegexRelativeImageUrlPatern;
 }
Example #10
0
 /// <summary>
 /// 构造函数
 /// </summary>
 public IOrdNurseCareDOCrudServiceImpl()
 {
     ch     = new CacheHelper <OrdNurseCareDO>();
     si     = new ServiceInvocationImpl();
     si.url = url;
 }
        /// <summary>
        /// Builds the various services
        /// </summary>
        private void BuildServiceCache(
            IScopeUnitOfWorkProvider provider,
            CacheHelper cache,
            RepositoryFactory repositoryFactory,
            ILogger logger,
            IEventMessagesFactory eventMessagesFactory,
            IdkMap idkMap)
        {
            EventMessagesFactory = eventMessagesFactory;

            if (_migrationEntryService == null)
            {
                _migrationEntryService = new Lazy <IMigrationEntryService>(() => new MigrationEntryService(provider, repositoryFactory, logger, eventMessagesFactory));
            }

            if (_externalLoginService == null)
            {
                _externalLoginService = new Lazy <IExternalLoginService>(() => new ExternalLoginService(provider, repositoryFactory, logger, eventMessagesFactory));
            }

            if (_publicAccessService == null)
            {
                _publicAccessService = new Lazy <IPublicAccessService>(() => new PublicAccessService(provider, repositoryFactory, logger, eventMessagesFactory));
            }

            if (_taskService == null)
            {
                _taskService = new Lazy <ITaskService>(() => new TaskService(provider, repositoryFactory, logger, eventMessagesFactory));
            }

            if (_domainService == null)
            {
                _domainService = new Lazy <IDomainService>(() => new DomainService(provider, repositoryFactory, logger, eventMessagesFactory));
            }

            if (_auditService == null)
            {
                _auditService = new Lazy <IAuditService>(() => new AuditService(provider, repositoryFactory, logger, eventMessagesFactory));
            }

            if (_localizedTextService == null)
            {
                _localizedTextService = new Lazy <ILocalizedTextService>(() => new LocalizedTextService(
                                                                             new Lazy <LocalizedTextServiceFileSources>(() =>
                {
                    var mainLangFolder   = new DirectoryInfo(IOHelper.MapPath(SystemDirectories.Umbraco + "/config/lang/"));
                    var appPlugins       = new DirectoryInfo(IOHelper.MapPath(SystemDirectories.AppPlugins));
                    var configLangFolder = new DirectoryInfo(IOHelper.MapPath(SystemDirectories.Config + "/lang/"));

                    var pluginLangFolders = appPlugins.Exists == false
                            ? Enumerable.Empty <LocalizedTextServiceSupplementaryFileSource>()
                            : appPlugins.GetDirectories()
                                            .SelectMany(x => x.GetDirectories("Lang"))
                                            .SelectMany(x => x.GetFiles("*.xml", SearchOption.TopDirectoryOnly))
                                            .Where(x => Path.GetFileNameWithoutExtension(x.FullName).Length == 5)
                                            .Select(x => new LocalizedTextServiceSupplementaryFileSource(x, false));

                    //user defined langs that overwrite the default, these should not be used by plugin creators
                    var userLangFolders = configLangFolder.Exists == false
                            ? Enumerable.Empty <LocalizedTextServiceSupplementaryFileSource>()
                            : configLangFolder
                                          .GetFiles("*.user.xml", SearchOption.TopDirectoryOnly)
                                          .Where(x => Path.GetFileNameWithoutExtension(x.FullName).Length == 10)
                                          .Select(x => new LocalizedTextServiceSupplementaryFileSource(x, true));

                    return(new LocalizedTextServiceFileSources(
                               logger,
                               cache.RuntimeCache,
                               mainLangFolder,
                               pluginLangFolders.Concat(userLangFolders)));
                }),
                                                                             logger));
            }


            if (_notificationService == null)
            {
                _notificationService = new Lazy <INotificationService>(() => new NotificationService(provider, _userService.Value, _contentService.Value, logger));
            }

            if (_serverRegistrationService == null)
            {
                _serverRegistrationService = new Lazy <IServerRegistrationService>(() => new ServerRegistrationService(provider, repositoryFactory, logger, eventMessagesFactory));
            }

            if (_userService == null)
            {
                _userService = new Lazy <IUserService>(() => new UserService(provider, repositoryFactory, logger, eventMessagesFactory));
            }

            if (_memberService == null)
            {
                _memberService = new Lazy <IMemberService>(() => new MemberService(provider, repositoryFactory, logger, eventMessagesFactory, _memberGroupService.Value, _dataTypeService.Value));
            }

            if (_contentService == null)
            {
                _contentService = new Lazy <IContentService>(() => new ContentService(provider, repositoryFactory, logger, eventMessagesFactory, _dataTypeService.Value, _userService.Value, idkMap));
            }

            if (_mediaService == null)
            {
                _mediaService = new Lazy <IMediaService>(() => new MediaService(provider, repositoryFactory, logger, eventMessagesFactory, _dataTypeService.Value, _userService.Value, idkMap));
            }

            if (_contentTypeService == null)
            {
                _contentTypeService = new Lazy <IContentTypeService>(() => new ContentTypeService(provider, repositoryFactory, logger, eventMessagesFactory, _contentService.Value, _mediaService.Value));
            }

            if (_dataTypeService == null)
            {
                _dataTypeService = new Lazy <IDataTypeService>(() => new DataTypeService(provider, repositoryFactory, logger, eventMessagesFactory));
            }

            if (_fileService == null)
            {
                _fileService = new Lazy <IFileService>(() => new FileService(provider, repositoryFactory, logger, eventMessagesFactory));
            }

            if (_localizationService == null)
            {
                _localizationService = new Lazy <ILocalizationService>(() => new LocalizationService(provider, repositoryFactory, logger, eventMessagesFactory));
            }

            if (_entityService == null)
            {
                _entityService = new Lazy <IEntityService>(() => new EntityService(
                                                               provider, repositoryFactory, logger, eventMessagesFactory,
                                                               _contentService.Value, _contentTypeService.Value, _mediaService.Value, _dataTypeService.Value, _memberService.Value, _memberTypeService.Value,
                                                               idkMap));
            }

            if (_packagingService == null)
            {
                _packagingService = new Lazy <IPackagingService>(() => new PackagingService(logger, _contentService.Value, _contentTypeService.Value, _mediaService.Value, _macroService.Value, _dataTypeService.Value, _fileService.Value, _localizationService.Value, _entityService.Value, _userService.Value, repositoryFactory, provider));
            }

            if (_relationService == null)
            {
                _relationService = new Lazy <IRelationService>(() => new RelationService(provider, repositoryFactory, logger, eventMessagesFactory, _entityService.Value));
            }

            if (_treeService == null)
            {
                _treeService = new Lazy <IApplicationTreeService>(() => new ApplicationTreeService(logger, cache));
            }

            if (_sectionService == null)
            {
                _sectionService = new Lazy <ISectionService>(() => new SectionService(_userService.Value, _treeService.Value, provider, cache));
            }

            if (_macroService == null)
            {
                _macroService = new Lazy <IMacroService>(() => new MacroService(provider, repositoryFactory, logger, eventMessagesFactory));
            }

            if (_memberTypeService == null)
            {
                _memberTypeService = new Lazy <IMemberTypeService>(() => new MemberTypeService(provider, repositoryFactory, logger, eventMessagesFactory, _memberService.Value));
            }

            if (_tagService == null)
            {
                _tagService = new Lazy <ITagService>(() => new TagService(provider, repositoryFactory, logger, eventMessagesFactory));
            }

            if (_memberGroupService == null)
            {
                _memberGroupService = new Lazy <IMemberGroupService>(() => new MemberGroupService(provider, repositoryFactory, logger, eventMessagesFactory));
            }

            if (_redirectUrlService == null)
            {
                _redirectUrlService = new Lazy <IRedirectUrlService>(() => new RedirectUrlService(provider, repositoryFactory, logger, eventMessagesFactory));
            }
        }
Example #12
0
        public virtual List <T> DataTableToList <T>(string filePath, string sheetName) where T : IExeclImport, new()
        {
            List <T>  listEntity = new List <T>();
            DataTable dt         = excelReader.ReaderExcel(filePath, sheetName);

            if (dt.Rows.Count > this.MaxLeng)
            {
                this.ErrorMsg = $"超过最大条数{MaxLeng}";
                return(null);
            }
            string TName = GetTName <T>();
            Type   TType = typeof(T);

            #region 获取实体类映射集合
            string ExeclMappingPropertyInfosKey      = $"{TName}_ExeclMappingPropertys";
            IEnumerable <PropertyInfo> PropertyInfos = CacheHelper.GetCache <IEnumerable <PropertyInfo> >(ExeclMappingPropertyInfosKey);
            if (PropertyInfos == null)
            {
                PropertyInfos = TType.GetProperties().Where(m => m.GetCustomAttribute <ExeclMappingAttribute>(true) != null);
                if (PropertyInfos != null)
                {
                    CacheHelper.SetCache(ExeclMappingPropertyInfosKey, PropertyInfos);
                }
            }
            #endregion

            if (PropertyInfos == null || PropertyInfos.Count() <= 0)
            {
                this.ErrorMsg = $"传入实体无Execl映射信息";
                return(null);
            }
            foreach (DataRow row in dt.Rows)
            {
                T t = new T();
                foreach (PropertyInfo Prty in PropertyInfos)
                {
                    #region 获取指定字段ExeclMappingAttribute
                    string ExeclMappingPropertyKey         = $"{TName}_{Prty.Name}_ExeclMappingPropertyKey";
                    string ExeclMappingPropertyKeyNoHave   = $"{TName}_{Prty.Name}_ExeclMappingPropertyKeyNoHave";
                    ExeclMappingAttribute PrtyExeclMapping = CacheHelper.GetCache <ExeclMappingAttribute>(ExeclMappingPropertyKey);
                    if (PrtyExeclMapping == null && !CacheHelper.IsExist(ExeclMappingPropertyKeyNoHave))
                    {
                        PrtyExeclMapping = Prty.GetCustomAttribute <ExeclMappingAttribute>(true);
                        if (PrtyExeclMapping != null)
                        {
                            CacheHelper.SetCache(ExeclMappingPropertyKey, PrtyExeclMapping);
                        }
                        else
                        {
                            CacheHelper.SetCache(ExeclMappingPropertyKeyNoHave, true);
                        }
                    }
                    #endregion

                    if (PrtyExeclMapping != null && dt.Columns.Contains(PrtyExeclMapping.ExeclHeadName))
                    {
                        // 判断此属性是否有Setter
                        if (!Prty.CanWrite)
                        {
                            continue;                //该属性不可写,直接跳出
                        }
                        //取值
                        object value = row[PrtyExeclMapping.ExeclHeadName];
                        //如果非空,则赋给对象的属性
                        if (value != DBNull.Value && value != null && !string.IsNullOrEmpty(value.ToString()))
                        {
                            #region 获取指定字段ConvertValueAttribute
                            string ConvertValuePropertyKey              = $"{TName}_{Prty.Name}_ConvertValuePropertyKey";
                            string ConvertValuePropertyKeyNoHave        = $"{TName}_{Prty.Name}_ConvertValuePropertyKeyNoHave";
                            ConvertValueAttribute appointValueAttribute = CacheHelper.GetCache <ConvertValueAttribute>(ConvertValuePropertyKey);
                            if (appointValueAttribute == null && !CacheHelper.IsExist(ConvertValuePropertyKeyNoHave))
                            {
                                appointValueAttribute = Prty.GetCustomAttribute <ConvertValueAttribute>(true);
                                if (appointValueAttribute != null)
                                {
                                    CacheHelper.SetCache(ConvertValuePropertyKey, appointValueAttribute);
                                }
                                else
                                {
                                    CacheHelper.SetCache(ConvertValuePropertyKeyNoHave, true);
                                }
                            }
                            #endregion

                            if (appointValueAttribute != null)
                            {
                                value = appointValueAttribute.GetConvertValueValue(value);
                            }



                            ExcelNumberAttribute excelNumberAttribute = Prty.GetCustomAttribute <ExcelNumberAttribute>(true);

                            #region 字段验证BaseValidationAttribute
                            string BaseValidationPropertyKey       = $"{TName}_{Prty.Name}_BaseValidationPropertyKey";
                            string BaseValidationPropertyKeyNoHave = $"{TName}_{Prty.Name}_BaseValidationPropertyKeyNoHave";
                            IEnumerable <ExcelBaseValidationAttribute> baseValidationAttributeArray = CacheHelper.GetCache <IEnumerable <ExcelBaseValidationAttribute> >(BaseValidationPropertyKey);
                            if (baseValidationAttributeArray == null && !CacheHelper.IsExist(BaseValidationPropertyKeyNoHave))
                            {
                                baseValidationAttributeArray = Prty.GetCustomAttributes <ExcelBaseValidationAttribute>(true);
                                if (baseValidationAttributeArray != null)
                                {
                                    CacheHelper.SetCache(BaseValidationPropertyKey, baseValidationAttributeArray);
                                }
                                else
                                {
                                    CacheHelper.SetCache(BaseValidationPropertyKeyNoHave, true);
                                }
                            }
                            #endregion
                            if (baseValidationAttributeArray != null && baseValidationAttributeArray.Count() > 0)
                            {
                                foreach (ExcelBaseValidationAttribute baseValidationAttribute in baseValidationAttributeArray)
                                {
                                    if (!baseValidationAttribute.IsValid(value))
                                    {
                                        PropertyInfo ExeclRowErrorMsgProperty = TType.GetProperty("ExeclRowErrorMsg");
                                        if (ExeclRowErrorMsgProperty != null)
                                        {
                                            ExeclRowErrorMsgProperty.SetValue(t,
                                                                              string.IsNullOrEmpty(baseValidationAttribute.ErrorMsg)? baseValidationAttribute.ErrorMsg:$"{baseValidationAttribute.GetType().Name} 验证未通过"
                                                                              , null);
                                        }
                                    }
                                }
                            }


                            object objValue = GetValue(Prty, value);
                            Prty.SetValue(t, objValue, null);
                        }
                    }
                }
                listEntity.Add(t);
            }
            return(listEntity);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="VirtualProductContentCache"/> class.
 /// </summary>
 /// <param name="cache">
 /// The cache.
 /// </param>
 /// <param name="modified">
 /// The modified.
 /// </param>
 public VirtualProductContentCache(CacheHelper cache, bool modified)
     : this(cache, null, modified)
 {
 }
Example #14
0
        //获取分类列表
        public List <GgcmsCategories> Categories()
        {
            List <GgcmsCategories> list = CacheHelper.GetCategorys(Prefix);

            return(list);
        }
Example #15
0
 /// <summary>
 /// 构造函数
 /// </summary>
 public IOpernurecordCrudServiceImpl()
 {
     ch     = new CacheHelper <OpernurecordAggDO>();
     si     = new ServiceInvocationImpl();
     si.url = url;
 }
        public override Dictionary <string, object> ToUpdate(IMemoryCache memoryCache, out BaseModel updatedElement)
        {
            Dictionary <string, object> changes = new Dictionary <string, object>();

            BlobContent refInCache = null;

            if (Id != Guid.Empty)
            {
                refInCache = CacheHelper.GetBlobContentFromCache(memoryCache, Id);

                if (refInCache != null)
                {
                    if (Name != null && !Name.Equals(refInCache.Name))
                    {
                        changes.Add("Name", Name);
                    }
                    if (Description != null && !Description.Equals(refInCache.Description))
                    {
                        changes.Add("Description", Description);
                    }
                    if (!Sharing.Equals(refInCache.Sharing))
                    {
                        changes.Add("Sharing", Sharing);
                    }
                    if (!Type.Equals(refInCache.Type))
                    {
                        changes.Add("Type", Type);
                    }
                    if (!Subtype.Equals(refInCache.Subtype))
                    {
                        changes.Add("Subtype", Subtype);
                    }
                }
                else
                {
                    refInCache = this;

                    if (Name != null)
                    {
                        changes.Add("Name", Name);
                    }
                    if (Description != null)
                    {
                        changes.Add("Description", Description);
                    }
                    if (Sharing != null)
                    {
                        changes.Add("Sharing", Sharing);
                    }
                    if (Type != null)
                    {
                        changes.Add("Type", Type);
                    }
                    if (Subtype != null)
                    {
                        changes.Add("Subtype", Subtype);
                    }
                }
            }
            updatedElement = refInCache;
            return(changes);
        }
Example #17
0
        /// <summary>
        /// 输入验证
        /// </summary>
        /// <returns></returns>
        protected bool RegValidate()
        {
            lgk.Model.tb_user recommendInfo = new lgk.Model.tb_user();


            if (txtUserCode.Value.Trim() == "")
            {
                MessageBox.ShowBox(this.Page, "", GetLanguage("PleaseNumber"), Library.Enums.ModalTypes.warning);//请输入会员编号

                return(false);
            }
            if (!PageValidate.checkUserCode(txtUserCode.Value.Trim()))
            {
                MessageBox.ShowBox(this.Page, "", GetLanguage("MemberNumber"), Library.Enums.ModalTypes.warning);//会员编号必须由6-10位的英文字母或数字组成
                return(false);
            }

            if (GetUserID(txtUserCode.Value.Trim()) > 0)
            {
                MessageBox.ShowBox(this.Page, "", GetLanguage("Memberexists"), Library.Enums.ModalTypes.info);//该会员编号已存在,请重新输入!
                return(false);
            }

            //if (sex1.Checked != true && sex2.Checked != true)
            //{
            //    ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('" + GetLanguage("PleaseArea") + "');", true);//请选择注册区域
            //    return false;
            //}

            //int iLocation = 0;
            //if (sex1.Checked == true) { iLocation = 1; }
            //if (sex2.Checked == true) { iLocation = 2; }
            #region 手机号码验证
            if (txtPhoneNum.Value == "")
            {
                MessageBox.ShowBox(this.Page, "", GetLanguage("Phoneempty"), Library.Enums.ModalTypes.warning);//手机号码不能为空
                return(false);
            }
            var strPhoneNum = this.txtPhoneNum.Value.Trim();

            if (!string.IsNullOrEmpty(strPhoneNum) && !PageValidate.RegexPhone(strPhoneNum))
            {
                MessageBox.ShowBox(this.Page, "", GetLanguage("PhoneMust"), Library.Enums.ModalTypes.error);//联系电话格式错误
                return(false);
            }

            int userid = GetUserIDbByPhone(strPhoneNum);
            if (userid > 0)
            {
                MessageBox.ShowBox(this.Page, "", GetLanguage("PhoneRegExists"), Library.Enums.ModalTypes.info);//该手机号码已注册
                return(false);
            }

            if (appId == "Open")
            {
                if (verifid_code.Value.Trim() == "")
                {
                    MessageBox.ResponseScript(this, "msg_disp('请输入验证码!');");
                    return(false);
                }
                DataSet ds = new lgk.BLL.SMS().GetList(" IsValid=0 and ToUserCode='" + Session.SessionID + "' and ToPhone='" + txtPhoneNum.Value.Trim() + "' and SCode='" + verifid_code.Value.Trim() + "' and ValidTime >= getdate() ");
                if (ds == null || ds.Tables == null || ds.Tables[0] == null || ds.Tables[0].Rows.Count <= 0)
                {
                    MessageBox.ResponseScript(this, "msg_disp('验证码无效!');");
                    return(false);
                }
                else
                {
                    lgk.Model.SMS sms = new lgk.BLL.SMS().GetModel(long.Parse(ds.Tables[0].Rows[0]["ID"].ToString()));
                    sms.IsValid = -1;
                    new lgk.BLL.SMS().Update(sms);
                    CacheHelper.Remove(Session.SessionID);
                }
            }
            #endregion

            #region 密码验证
            if (txtPassword.Value.Trim() == "")
            {
                MessageBox.ShowBox(this.Page, "", GetLanguage("PasswordISNull"), Library.Enums.ModalTypes.warning);//登录密码不能为空
                return(false);
            }



            if (txtSecondPassword.Value.Trim() == "")
            {
                MessageBox.ShowBox(this.Page, "", GetLanguage("SecondaryISNUll"), Library.Enums.ModalTypes.warning);//二级密码不能为空
                return(false);
            }



            #endregion



            #region 推荐人验证
            if (txtRecommendCode.Value == "")
            {
                MessageBox.ShowBox(this.Page, GetLanguage("ReferenceNumberIsnull"), Library.Enums.ModalTypes.warning);//推荐人编号不能为空
                return(false);
            }
            else
            {
                string reName = this.txtRecommendCode.Value.Trim();
                recommendInfo = userBLL.GetModel(GetUserID(reName));//推薦用户
                if (recommendInfo == null)
                {
                    MessageBox.ShowBox(this.Page, "", GetLanguage("featuredNotExist"), Library.Enums.ModalTypes.warning);//该推荐会员不存在
                    return(false);
                }
                if (recommendInfo.IsOpend == 0)
                {
                    MessageBox.ShowBox(this.Page, "", GetLanguage("MemberISNull"), Library.Enums.ModalTypes.warning);//该会员尚未开通,不能作为推荐会员
                    return(false);
                }
            }
            #endregion


            return(true);
        }
Example #18
0
        /// <summary>
        /// 从IIS缓存中获取LoginLog表记录
        /// </summary>
        /// <param name="isCache">是否从缓存中读取</param>
        public IList <DataAccess.Model.LoginLog> GetList(bool isCache = true)
        {
            try
            {
                //判断是否使用缓存
                if (CommonBll.IsUseCache() && isCache)
                {
                    //检查指定缓存是否过期——缓存当天有效,第二天自动清空
                    if (CommonBll.CheckCacheIsExpired(const_CacheKey_Date))
                    {
                        //删除缓存
                        DelAllCache();
                    }

                    //从缓存中获取DataTable
                    var obj = CacheHelper.GetCache(const_CacheKey);
                    //如果缓存为null,则查询数据库
                    if (obj == null)
                    {
                        var list = GetList(false);

                        //将查询出来的数据存储到缓存中
                        CacheHelper.SetCache(const_CacheKey, list);
                        //存储当前时间
                        CacheHelper.SetCache(const_CacheKey_Date, DateTime.Now);

                        return(list);
                    }
                    //缓存中存在数据,则直接返回
                    else
                    {
                        return((IList <DataAccess.Model.LoginLog>)obj);
                    }
                }
                else
                {
                    //定义临时实体集
                    IList <DataAccess.Model.LoginLog> list = null;

                    //获取全表缓存加载条件表达式
                    var exp = GetExpression <LoginLog>();
                    //如果条件为空,则查询全表所有记录
                    if (exp == null)
                    {
                        //从数据库中获取所有记录
                        var all = LoginLog.All();
                        list = all == null ? null : Transform(all.ToList());
                    }
                    else
                    {
                        //从数据库中查询出指定条件的记录,并转换为指定实体集
                        var all = LoginLog.Find(exp);
                        list = all == null ? null : Transform(all);
                    }

                    return(list);
                }
            }
            catch (Exception e)
            {
                //记录日志
                CommonBll.WriteLog("从IIS缓存中获取LoginLog表记录时出现异常", e);
            }

            return(null);
        }
    /// <summary>
    /// Raised when the Save action is required.
    /// </summary>
    protected bool OnSaveEventHandler(object sender, EventArgs e)
    {
        if (!CMSContext.CurrentUser.IsAuthorizedPerResource("CMS.Design", "EditCode"))
        {
            return(false);
        }

        webPart.SetValue("WebPartCode", txtCode.Text);

        bool isWebPartVariant = (variantId > 0) || (zoneVariantId > 0) || isNewVariant;

        if (!isWebPartVariant)
        {
            // Update page template
            PageTemplateInfoProvider.SetPageTemplateInfo(pti);
        }
        else
        {
            // Save the variant properties
            if ((webPart != null) &&
                (webPart.ParentZone != null) &&
                (webPart.ParentZone.ParentTemplateInstance != null) &&
                (webPart.ParentZone.ParentTemplateInstance.ParentPageTemplate != null))
            {
                XmlDocument doc         = new XmlDocument();
                XmlNode     xmlWebParts = null;

                if (zoneVariantId > 0)
                {
                    // This webpart is in a zone variant therefore save the whole variant webparts
                    xmlWebParts = webPart.ParentZone.GetXmlNode(doc);
                    if (webPart.VariantMode == VariantModeEnum.MVT)
                    {
                        ModuleCommands.OnlineMarketingSaveMVTVariantWebParts(zoneVariantId, xmlWebParts);
                    }
                    else if (webPart.VariantMode == VariantModeEnum.ContentPersonalization)
                    {
                        ModuleCommands.OnlineMarketingSaveContentPersonalizationVariantWebParts(zoneVariantId, xmlWebParts);
                    }
                }
                else if (variantId > 0)
                {
                    // This webpart is a web part variant
                    xmlWebParts = webPart.GetXmlNode(doc);
                    if (webPart.VariantMode == VariantModeEnum.MVT)
                    {
                        ModuleCommands.OnlineMarketingSaveMVTVariantWebParts(variantId, xmlWebParts);
                    }
                    else if (webPart.VariantMode == VariantModeEnum.ContentPersonalization)
                    {
                        ModuleCommands.OnlineMarketingSaveContentPersonalizationVariantWebParts(variantId, xmlWebParts);
                    }
                }
            }
        }

        string parameters = aliasPath + "/" + zoneId + "/" + webpartId;
        string cacheName  = "CMSVirtualWebParts|" + parameters.ToLowerCSafe().TrimStart('/');

        CacheHelper.Remove(cacheName);

        ShowChangesSaved();

        return(true);
    }
    /// <summary>
    /// Handles reset button click. Resets zones of specified type to default settings.
    /// </summary>
    protected void btnReset_Click(object sender, EventArgs e)
    {
        // Disable the reset action when document editing is not allowed (i.e. non-editable workflow step)
        if (!WidgetActionsEnabled)
        {
            resetAllowed = false;
        }

        // Security check
        if (!DisplayResetButton || !resetAllowed)
        {
            return;
        }

        PageInfo pi = CurrentPageInfo;

        if (pi == null)
        {
            return;
        }

        if ((zoneType == WidgetZoneTypeEnum.Editor) || (zoneType == WidgetZoneTypeEnum.Group))
        {
            // Clear document webparts/group webparts
            TreeNode node = DocumentHelper.GetDocument(pi.DocumentID, TreeProvider);

            if (node != null)
            {
                bool updateDocument = true;

                if (zoneType == WidgetZoneTypeEnum.Editor)
                {
                    if (ViewMode.IsEdit(true) || ViewMode.IsEditLive())
                    {
                        // Do not save the document to the database, keep it in only in the memory
                        updateDocument = false;

                        // Get the default template widgets
                        PortalContext.SaveEditorWidgets(pi.DocumentID, pi.UsedPageTemplateInfo.TemplateInstance.GetZonesXML(WidgetZoneTypeEnum.Editor));
                    }
                    else
                    {
                        node.SetValue("DocumentWebParts", String.Empty);
                    }

                    // Delete all variants
                    if (pi.UsedPageTemplateInfo != null)
                    {
                        foreach (WebPartZoneInstance zoneInstance in zoneInstances)
                        {
                            if (zoneInstance.WebPartsContainVariants)
                            {
                                VariantHelper.DeleteWidgetVariants(zoneInstance.ZoneID, pi.UsedPageTemplateInfo.PageTemplateId, node.DocumentID);
                            }
                        }
                    }
                }
                else if (zoneType == WidgetZoneTypeEnum.Group)
                {
                    node.SetValue("DocumentGroupWebParts", String.Empty);
                }

                if (updateDocument)
                {
                    // Save the document
                    DocumentHelper.UpdateDocument(node, TreeProvider);
                }
            }
        }
        else if (zoneType == WidgetZoneTypeEnum.User)
        {
            // Delete user personalization info
            PersonalizationInfo up = PersonalizationInfoProvider.GetUserPersonalization(MembershipContext.AuthenticatedUser.UserID, pi.DocumentID);
            PersonalizationInfoProvider.DeletePersonalizationInfo(up);

            // Clear cached values
            TreeNode node = DocumentHelper.GetDocument(pi.DocumentID, TreeProvider);
            if (node != null)
            {
                CacheHelper.TouchKeys(TreeProvider.GetDependencyCacheKeys(node, SiteContext.CurrentSiteName));
            }
        }
        else if (zoneType == WidgetZoneTypeEnum.Dashboard)
        {
            // Delete user personalization info
            PersonalizationInfo up = PersonalizationInfoProvider.GetDashBoardPersonalization(MembershipContext.AuthenticatedUser.UserID, PortalContext.DashboardName, PortalContext.DashboardSiteName);
            PersonalizationInfoProvider.DeletePersonalizationInfo(up);

            // Clear cached page template
            if (pi.UsedPageTemplateInfo != null)
            {
                CacheHelper.TouchKey("cms.pagetemplate|byid|" + pi.UsedPageTemplateInfo.PageTemplateId);
            }
        }

        // Make redirect to see changes after load
        string url = RequestContext.CurrentURL;

        if (ViewMode.IsEdit(true) || ViewMode.IsEditLive())
        {
            // Ensure that the widgets will be loaded from the session layer (not from database)
            url = URLHelper.UpdateParameterInUrl(url, "cmscontentchanged", "true");
        }

        URLHelper.Redirect(url);
    }
 /// <summary>
 /// Initializes a new instance of the <see cref="VirtualProductContentCache"/> class.
 /// </summary>
 /// <param name="cache">
 /// The cache.
 /// </param>
 /// <param name="fetch">
 /// The fetch.
 /// </param>
 /// <param name="modified">
 /// The modified.
 /// </param>
 public VirtualProductContentCache(CacheHelper cache, Func <Guid, IProductContent> fetch, bool modified)
     : base(cache, fetch, modified)
 {
 }
Example #22
0
 public DependencyHelper(ProviderMetadata providerMetadata, CacheHelper cacheHelper)
     : base(providerMetadata)
 {
     Mandate.ParameterNotNull(cacheHelper, "cacheHelper");
     CacheHelper = cacheHelper;
 }
 public static void ClearCache()
 {
     CacheHelper.Clear(_CacheKeyName);
 }
Example #24
0
 public WxMPUtility()
 {
     this._cache = CacheHelper.GetInstance();
 }
Example #25
0
        public async Task SubmitForm(RoleEntity roleEntity, string[] permissionIds, string[] permissionfieldsIds, string keyValue)
        {
            if (!string.IsNullOrEmpty(keyValue))
            {
                roleEntity.F_Id = keyValue;
            }
            else
            {
                roleEntity.F_DeleteMark  = false;
                roleEntity.F_AllowEdit   = false;
                roleEntity.F_AllowDelete = false;
                roleEntity.Create();
            }
            var moduledata = await moduleApp.GetList();

            var buttondata = await moduleButtonApp.GetList();

            var fieldsdata = await moduleFieldsApp.GetList();

            List <RoleAuthorizeEntity> roleAuthorizeEntitys = new List <RoleAuthorizeEntity>();

            foreach (var itemId in permissionIds)
            {
                RoleAuthorizeEntity roleAuthorizeEntity = new RoleAuthorizeEntity();
                roleAuthorizeEntity.F_Id         = Utils.GuId();
                roleAuthorizeEntity.F_ObjectType = 1;
                roleAuthorizeEntity.F_ObjectId   = roleEntity.F_Id;
                roleAuthorizeEntity.F_ItemId     = itemId;
                if (moduledata.Find(t => t.F_Id == itemId) != null)
                {
                    roleAuthorizeEntity.F_ItemType = 1;
                    roleAuthorizeEntitys.Add(roleAuthorizeEntity);
                }
                if (buttondata.Find(t => t.F_Id == itemId) != null)
                {
                    roleAuthorizeEntity.F_ItemType = 2;
                    roleAuthorizeEntitys.Add(roleAuthorizeEntity);
                }
            }
            foreach (var itemId in permissionfieldsIds)
            {
                RoleAuthorizeEntity roleAuthorizeEntity = new RoleAuthorizeEntity();
                roleAuthorizeEntity.F_Id         = Utils.GuId();
                roleAuthorizeEntity.F_ObjectType = 1;
                roleAuthorizeEntity.F_ObjectId   = roleEntity.F_Id;
                roleAuthorizeEntity.F_ItemId     = itemId;
                if (fieldsdata.Find(t => t.F_Id == itemId) != null)
                {
                    roleAuthorizeEntity.F_ItemType = 3;
                    roleAuthorizeEntitys.Add(roleAuthorizeEntity);
                }
            }
            uniwork.BeginTrans();
            if (!string.IsNullOrEmpty(keyValue))
            {
                await repository.Update(roleEntity);
            }
            else
            {
                roleEntity.F_Category = 1;
                await repository.Insert(roleEntity);
            }
            await uniwork.Delete <RoleAuthorizeEntity>(t => t.F_ObjectId == roleEntity.F_Id);

            await uniwork.Insert(roleAuthorizeEntitys);

            uniwork.Commit();
            await CacheHelper.Remove(cacheKey + keyValue);

            await CacheHelper.Remove(cacheKey + "list");

            await CacheHelper.Remove(authorizecacheKey + "list");

            await CacheHelper.Remove(authorizecacheKey + "authorize_list");

            await CacheHelper.Remove(initcacheKey + "modulebutton_list");

            await CacheHelper.Remove(initcacheKey + "modulefields_list");

            await CacheHelper.Remove(initcacheKey + "list");
        }
Example #26
0
        public virtual List <T> DataTableToList <T>(string filePath, string sheetName) where T : IExeclImport, new()
        {
            List <T>  listEntity = new List <T>();
            DataTable dt         = excelReader.ReaderExcel(filePath, sheetName);

            if (dt.Rows.Count > this.MaxLeng)
            {
                this.ErrorMsg = $"超过最大条数{MaxLeng}";
                return(null);
            }
            string TName = GetTName <T>();

            #region 获取实体类映射集合
            string ExeclMappingPropertyInfosKey      = $"{TName}_ExeclMappingPropertys";
            IEnumerable <PropertyInfo> PropertyInfos = CacheHelper.GetCache <IEnumerable <PropertyInfo> >(ExeclMappingPropertyInfosKey);
            if (PropertyInfos == null)
            {
                PropertyInfos = typeof(T).GetProperties().Where(m => m.GetCustomAttributes(typeof(ExeclMappingAttribute), true) != null);
                CacheHelper.SetCache(ExeclMappingPropertyInfosKey, PropertyInfos);
            }
            #endregion

            if (PropertyInfos == null || PropertyInfos.Count() <= 0)
            {
                this.ErrorMsg = $"传入实体无Execl映射信息";
                return(null);
            }

            foreach (DataRow row in dt.Rows)
            {
                T t = new T();
                foreach (PropertyInfo Prty in PropertyInfos)
                {
                    string ExeclMappingPropertyKey = $"{TName}_{Prty.Name}_ExeclMappingPropertyKey";

                    #region 获取指定字段ExeclMappingAttribute
                    ExeclMappingAttribute PrtyExeclMapping = CacheHelper.GetCache <ExeclMappingAttribute>(ExeclMappingPropertyTimeKey);
                    if (PropertyInfos == null)
                    {
                        PrtyExeclMapping = Prty.GetCustomAttribute <ExeclMappingAttribute>(true);
                        CacheHelper.SetCache(ExeclMappingPropertyTimeKey, PropertyInfos);
                    }
                    #endregion

                    if (dt.Columns.Contains(PrtyExeclMapping.ExeclHeadName))
                    {
                        // 判断此属性是否有Setter
                        if (!Prty.CanWrite)
                        {
                            continue;                //该属性不可写,直接跳出
                        }
                        //取值
                        object value = row[PrtyExeclMapping.ExeclHeadName];
                        //如果非空,则赋给对象的属性
                        if (value != DBNull.Value && value != null && !string.IsNullOrEmpty(value.ToString()))
                        {
                            string ConvertValuePropertyKey = $"{TName}_{Prty.Name}_ConvertValuePropertyKey";
                            ConvertValueAttribute appointValueAttribute = CacheHelper.GetCache <ConvertValueAttribute>(ConvertValuePropertyKey);
                            if (appointValueAttribute == null)
                            {
                                appointValueAttribute = Prty.GetCustomAttribute <appointValueAttribute>(true);
                                CacheHelper.SetCache(ConvertValuePropertyKey, PropertyInfos);
                            }

                            if (appointValueAttribute != null)
                            {
                                value = appointValueAttribute.GetConvertValueValue(value);
                            }
                            object objValue = GetValue(Prty, value);
                            Prty.SetValue(t, objValue, null);
                        }
                    }
                }
                listEntity.Add(t);
            }
            return(listEntity);
        }
Example #27
0
 public override void EndTest()
 {
     CacheHelper.StopJavaServers();
     base.EndTest();
 }
 /// <summary>
 /// 构造函数
 /// </summary>
 public ICiapprissheetCrudServiceImpl()
 {
     ch     = new CacheHelper <CiAppRisSheetDO>();
     si     = new ServiceInvocationImpl();
     si.url = url;
 }
Example #29
0
        public void StepOnePdxQE(string locators)
        {
            CacheHelper.CreateTCRegion_Pool <object, object>(QERegionName, true, true,
                                                             null, locators, "__TESTPOOL1_", true);
            IRegion <object, object> region = CacheHelper.GetVerifyRegion <object, object>(QERegionName);
            PortfolioPdx             p1     = new PortfolioPdx(1, 100);
            PortfolioPdx             p2     = new PortfolioPdx(2, 100);
            PortfolioPdx             p3     = new PortfolioPdx(3, 100);
            PortfolioPdx             p4     = new PortfolioPdx(4, 100);

            region["1"] = p1;
            region["2"] = p2;
            region["3"] = p3;
            region["4"] = p4;

            var qs = CacheHelper.DCache.GetPoolManager().Find("__TESTPOOL1_").GetQueryService();
            CqAttributesFactory <object, object> cqFac    = new CqAttributesFactory <object, object>();
            ICqListener <object, object>         cqLstner = new MyCqListener <object, object>();

            cqFac.AddCqListener(cqLstner);
            CqAttributes <object, object> cqAttr = cqFac.Create();
            CqQuery <object, object>      qry    = qs.NewCq(CqName, "select * from /" + QERegionName + "  p where p.ID!=2", cqAttr, false);

            qry.Execute();
            Thread.Sleep(18000); // sleep 0.3min to allow server c query to complete
            region["4"] = p1;
            region["3"] = p2;
            region["2"] = p3;
            region["1"] = p4;
            Thread.Sleep(18000); // sleep 0.3min to allow server c query to complete

            qry = qs.GetCq <object, object>(CqName);

            CqServiceStatistics cqSvcStats = qs.GetCqStatistics();

            Assert.AreEqual(1, cqSvcStats.numCqsActive());
            Assert.AreEqual(1, cqSvcStats.numCqsCreated());
            Assert.AreEqual(1, cqSvcStats.numCqsOnClient());

            cqAttr = qry.GetCqAttributes();
            ICqListener <object, object>[] vl = cqAttr.getCqListeners();
            Assert.IsNotNull(vl);
            Assert.AreEqual(1, vl.Length);
            cqLstner = vl[0];
            Assert.IsNotNull(cqLstner);
            MyCqListener <object, object> myLisner = (MyCqListener <object, object>)cqLstner;// as MyCqListener<object, object>;

            Util.Log("event count:{0}, error count {1}.", myLisner.getEventCountBefore(), myLisner.getErrorCountBefore());

            CqStatistics cqStats = qry.GetStatistics();

            Assert.AreEqual(cqStats.numEvents(), myLisner.getEventCountBefore());
            if (myLisner.getEventCountBefore() + myLisner.getErrorCountBefore() == 0)
            {
                Assert.Fail("cq before count zero");
            }
            qry.Stop();
            Assert.AreEqual(1, cqSvcStats.numCqsStopped());
            qry.Close();
            Assert.AreEqual(1, cqSvcStats.numCqsClosed());
            // Bring down the region
            region.GetLocalView().DestroyRegion();
        }
Example #30
0
 private void LoadSettings()
 {
     siteSettings = CacheHelper.GetCurrentSiteSettings();
     serverVars   = Request.ServerVariables;
 }
Example #31
0
        /*
         * public void StepOneFailover()
         * {
         * // This is here so that Client1 registers information of the cacheserver
         * // that has been already started
         * CacheHelper.SetupJavaServers("remotequery.xml",
         *  "cqqueryfailover.xml");
         * CacheHelper.StartJavaServer(1, "GFECS1");
         * Util.Log("Cacheserver 1 started.");
         *
         * CacheHelper.CreateTCRegion(QueryRegionNames[0], true, true, null, true);
         *
         * Region region = CacheHelper.GetVerifyRegion(QueryRegionNames[0]);
         * Portfolio p1 = new Portfolio(1, 100);
         * Portfolio p2 = new Portfolio(2, 200);
         * Portfolio p3 = new Portfolio(3, 300);
         * Portfolio p4 = new Portfolio(4, 400);
         *
         * region.Put("1", p1);
         * region.Put("2", p2);
         * region.Put("3", p3);
         * region.Put("4", p4);
         * }
         */
        /*
         * public void StepTwoFailover()
         * {
         * CacheHelper.StartJavaServer(2, "GFECS2");
         * Util.Log("Cacheserver 2 started.");
         *
         * IAsyncResult killRes = null;
         * KillServerDelegate ksd = new KillServerDelegate(KillServer);
         * CacheHelper.CreateTCRegion(QueryRegionNames[0], true, true, null, true);
         *
         * IRegion<object, object> region = CacheHelper.GetVerifyRegion<object, object>(QueryRegionNames[0]);
         *
         * var qs = CacheHelper.DCache.GetQueryService();
         * CqAttributesFactory cqFac = new CqAttributesFactory();
         * ICqListener cqLstner = new MyCqListener();
         * cqFac.AddCqListener(cqLstner);
         * CqAttributes cqAttr = cqFac.Create();
         * CqQuery qry = qs.NewCq(CqName1, "select * from /" + QERegionName + "  p where p.ID!<4", cqAttr, true);
         * qry.Execute();
         * Thread.Sleep(18000); // sleep 0.3min to allow server c query to complete
         * qry = qs.GetCq(CqName1);
         * cqAttr = qry.GetCqAttributes();
         * ICqListener[] vl = cqAttr.getCqListeners();
         * Assert.IsNotNull(vl);
         * Assert.AreEqual(1, vl.Length);
         * cqLstner = vl[0];
         * Assert.IsNotNull(cqLstner);
         * MyCqListener myLisner = cqLstner as MyCqListener;
         * if (myLisner.getEventCountAfter() + myLisner.getErrorCountAfter() != 0)
         * {
         *  Assert.Fail("cq after count not zero");
         * }
         *
         * killRes = ksd.BeginInvoke(null, null);
         * Thread.Sleep(18000); // sleep 0.3min to allow failover complete
         * myLisner.failedOver();
         *
         * Portfolio p1 = new Portfolio(1, 100);
         * Portfolio p2 = new Portfolio(2, 200);
         * Portfolio p3 = new Portfolio(3, 300);
         * Portfolio p4 = new Portfolio(4, 400);
         *
         * region.Put("4", p1);
         * region.Put("3", p2);
         * region.Put("2", p3);
         * region.Put("1", p4);
         * Thread.Sleep(18000); // sleep 0.3min to allow server c query to complete
         *
         * qry = qs.GetCq(CqName1);
         * cqAttr = qry.GetCqAttributes();
         * vl = cqAttr.getCqListeners();
         * cqLstner = vl[0];
         * Assert.IsNotNull(vl);
         * Assert.AreEqual(1, vl.Length);
         * cqLstner = vl[0];
         * Assert.IsNotNull(cqLstner);
         * myLisner = cqLstner as MyCqListener;
         * if (myLisner.getEventCountAfter() + myLisner.getErrorCountAfter() == 0)
         * {
         *  Assert.Fail("no cq after failover");
         * }
         *
         * killRes.AsyncWaitHandle.WaitOne();
         * ksd.EndInvoke(killRes);
         * qry.Stop();
         * qry.Close();
         * }
         */

        public void ProcessCQ(string locators)
        {
            CacheHelper.CreateTCRegion_Pool <object, object>(QERegionName, true, true,
                                                             null, locators, "__TESTPOOL1_", true);

            IRegion <object, object> region = CacheHelper.GetVerifyRegion <object, object>(QERegionName);
            Portfolio p1 = new Portfolio(1, 100);
            Portfolio p2 = new Portfolio(2, 100);
            Portfolio p3 = new Portfolio(3, 100);
            Portfolio p4 = new Portfolio(4, 100);

            region["1"] = p1;
            region["2"] = p2;
            region["3"] = p3;
            region["4"] = p4;

            var qs = CacheHelper.DCache.GetPoolManager().Find("__TESTPOOL1_").GetQueryService();

            CqAttributesFactory <object, object> cqFac          = new CqAttributesFactory <object, object>();
            ICqListener <object, object>         cqLstner       = new MyCqListener <object, object>();
            ICqStatusListener <object, object>   cqStatusLstner = new MyCqStatusListener <object, object>(1);

            ICqListener <object, object>[] v = new ICqListener <object, object> [2];
            cqFac.AddCqListener(cqLstner);
            v[0] = cqLstner;
            v[1] = cqStatusLstner;
            cqFac.InitCqListeners(v);
            Util.Log("InitCqListeners called");
            CqAttributes <object, object> cqAttr = cqFac.Create();
            CqQuery <object, object>      qry1   = qs.NewCq("CQ1", "select * from /" + QERegionName + "  p where p.ID >= 1", cqAttr, false);

            qry1.Execute();

            Thread.Sleep(18000); // sleep 0.3min to allow server c query to complete
            region["4"] = p1;
            region["3"] = p2;
            region["2"] = p3;
            region["1"] = p4;
            Thread.Sleep(18000); // sleep 0.3min to allow server c query to complete

            qry1   = qs.GetCq <object, object>("CQ1");
            cqAttr = qry1.GetCqAttributes();
            ICqListener <object, object>[] vl = cqAttr.getCqListeners();
            Assert.IsNotNull(vl);
            Assert.AreEqual(2, vl.Length);
            cqLstner = vl[0];
            Assert.IsNotNull(cqLstner);
            MyCqListener <object, object> myLisner = (MyCqListener <object, object>)cqLstner;// as MyCqListener<object, object>;

            Util.Log("event count:{0}, error count {1}.", myLisner.getEventCountBefore(), myLisner.getErrorCountBefore());
            Assert.AreEqual(4, myLisner.getEventCountBefore());

            cqStatusLstner = (ICqStatusListener <object, object>)vl[1];
            Assert.IsNotNull(cqStatusLstner);
            MyCqStatusListener <object, object> myStatLisner = (MyCqStatusListener <object, object>)cqStatusLstner;// as MyCqStatusListener<object, object>;

            Util.Log("event count:{0}, error count {1}.", myStatLisner.getEventCountBefore(), myStatLisner.getErrorCountBefore());
            Assert.AreEqual(1, myStatLisner.getCqConnectedCount());
            Assert.AreEqual(4, myStatLisner.getEventCountBefore());

            CqAttributesMutator <object, object> mutator = qry1.GetCqAttributesMutator();

            mutator.RemoveCqListener(cqLstner);
            cqAttr = qry1.GetCqAttributes();
            Util.Log("cqAttr.getCqListeners().Length = {0}", cqAttr.getCqListeners().Length);
            Assert.AreEqual(1, cqAttr.getCqListeners().Length);

            mutator.RemoveCqListener(cqStatusLstner);
            cqAttr = qry1.GetCqAttributes();
            Util.Log("1 cqAttr.getCqListeners().Length = {0}", cqAttr.getCqListeners().Length);
            Assert.AreEqual(0, cqAttr.getCqListeners().Length);

            ICqListener <object, object>[] v2 = new ICqListener <object, object> [2];
            v2[0] = cqLstner;
            v2[1] = cqStatusLstner;
            MyCqListener <object, object> myLisner2 = (MyCqListener <object, object>)cqLstner;

            myLisner2.Clear();
            MyCqStatusListener <object, object> myStatLisner2 = (MyCqStatusListener <object, object>)cqStatusLstner;

            myStatLisner2.Clear();
            mutator.SetCqListeners(v2);
            cqAttr = qry1.GetCqAttributes();
            Assert.AreEqual(2, cqAttr.getCqListeners().Length);

            region["4"] = p1;
            region["3"] = p2;
            region["2"] = p3;
            region["1"] = p4;
            Thread.Sleep(18000); // sleep 0.3min to allow server c query to complete

            qry1   = qs.GetCq <object, object>("CQ1");
            cqAttr = qry1.GetCqAttributes();
            ICqListener <object, object>[] v3 = cqAttr.getCqListeners();
            Assert.IsNotNull(v3);
            Assert.AreEqual(2, vl.Length);
            cqLstner = v3[0];
            Assert.IsNotNull(cqLstner);
            myLisner2 = (MyCqListener <object, object>)cqLstner;// as MyCqListener<object, object>;
            Util.Log("event count:{0}, error count {1}.", myLisner2.getEventCountBefore(), myLisner2.getErrorCountBefore());
            Assert.AreEqual(4, myLisner2.getEventCountBefore());

            cqStatusLstner = (ICqStatusListener <object, object>)v3[1];
            Assert.IsNotNull(cqStatusLstner);
            myStatLisner2 = (MyCqStatusListener <object, object>)cqStatusLstner;// as MyCqStatusListener<object, object>;
            Util.Log("event count:{0}, error count {1}.", myStatLisner2.getEventCountBefore(), myStatLisner2.getErrorCountBefore());
            Assert.AreEqual(0, myStatLisner2.getCqConnectedCount());
            Assert.AreEqual(4, myStatLisner2.getEventCountBefore());

            mutator = qry1.GetCqAttributesMutator();
            mutator.RemoveCqListener(cqLstner);
            cqAttr = qry1.GetCqAttributes();
            Util.Log("cqAttr.getCqListeners().Length = {0}", cqAttr.getCqListeners().Length);
            Assert.AreEqual(1, cqAttr.getCqListeners().Length);

            mutator.RemoveCqListener(cqStatusLstner);
            cqAttr = qry1.GetCqAttributes();
            Util.Log("1 cqAttr.getCqListeners().Length = {0}", cqAttr.getCqListeners().Length);
            Assert.AreEqual(0, cqAttr.getCqListeners().Length);

            region["4"] = p1;
            region["3"] = p2;
            region["2"] = p3;
            region["1"] = p4;
            Thread.Sleep(18000); // sleep 0.3min to allow server c query to complete

            qry1   = qs.GetCq <object, object>("CQ1");
            cqAttr = qry1.GetCqAttributes();
            ICqListener <object, object>[] v4 = cqAttr.getCqListeners();
            Assert.IsNotNull(v4);
            Assert.AreEqual(0, v4.Length);
            Util.Log("cqAttr.getCqListeners() done");
        }
Example #32
0
 public DataTypePreValueRepository(IScopeUnitOfWork work, CacheHelper cache, ILogger logger, ISqlSyntaxProvider sqlSyntax)
     : base(work, cache, logger, sqlSyntax)
 {
 }
Example #33
0
 /// <summary>
 /// 实例缓存
 /// </summary>
 /// <returns></returns>
 public static CacheHelper GetInstance()
 {
     if (_instance == null) _instance = new CacheHelper();
     return _instance;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="DigitalMediaRepository"/> class.
 /// </summary>
 /// <param name="work">
 /// The work.
 /// </param>
 /// <param name="cache">
 /// The cache.
 /// </param>
 public DigitalMediaRepository(IDatabaseUnitOfWork work, CacheHelper cache, ILogger logger, ISqlSyntaxProvider sqlSyntax)
     : base(work, cache, logger, sqlSyntax)
 {
 }
    /// <summary>
    /// Sends the given file within response.
    /// </summary>
    /// <param name="file">File to send</param>
    protected void SendFile(CMSOutputForumAttachment file)
    {
        // Clear response.
        CookieHelper.ClearResponseCookies();
        Response.Clear();

        // Set the revalidation
        SetRevalidation();

        if (file != null)
        {
            // Redirect if the file should be redirected
            if (file.RedirectTo != "")
            {
                URLHelper.RedirectPermanent(file.RedirectTo, CurrentSiteName);
            }

            // Prepare etag
            string etag = file.LastModified.ToString();

            // Client caching - only on the live site
            if (useClientCache && AllowCache && ETagsMatch(etag, file.LastModified))
            {
                // Set correct response content type
                SetResponseContentType(file);

                SetTimeStamps(file.LastModified);

                RespondNotModified(etag);
                return;
            }

            // If physical file not present, try to load
            if (file.PhysicalFile == null)
            {
                EnsurePhysicalFile(outputFile);
            }

            // Ensure the file data if physical file not present
            if (!file.DataLoaded && (file.PhysicalFile == ""))
            {
                byte[] cachedData = GetCachedOutputData();
                if (file.EnsureData(cachedData))
                {
                    if ((cachedData == null) && (CacheMinutes > 0))
                    {
                        SaveOutputDataToCache(file.OutputData, GetOutputDataDependency(file.ForumAttachment));
                    }
                }
            }

            // Send the file
            if ((file.OutputData != null) || (file.PhysicalFile != ""))
            {
                // Set correct response content type
                SetResponseContentType(file);

                string extension = file.ForumAttachment.AttachmentFileExtension;
                SetDisposition(file.ForumAttachment.AttachmentFileName, extension);

                // Set if resumable downloads should be supported
                AcceptRange = !IsExtensionExcludedFromRanges(extension);

                if (useClientCache && AllowCache)
                {
                    SetTimeStamps(file.LastModified);

                    Response.Cache.SetETag(etag);
                }
                else
                {
                    SetCacheability();
                }

                // Add the file data
                if ((file.PhysicalFile != "") && (file.OutputData == null))
                {
                    if (!File.Exists(file.PhysicalFile))
                    {
                        // File doesn't exist
                        NotFound();
                    }
                    else
                    {
                        // If the output data should be cached, return the output data
                        bool cacheOutputData = false;
                        if (file.ForumAttachment != null)
                        {
                            cacheOutputData = CacheHelper.CacheImageAllowed(CurrentSiteName, file.ForumAttachment.AttachmentFileSize);
                        }

                        // Stream the file from the file system
                        file.OutputData = WriteFile(file.PhysicalFile, cacheOutputData);
                    }
                }
                else
                {
                    // Use output data of the file in memory if present
                    WriteBytes(file.OutputData);
                }
            }
            else
            {
                NotFound();
            }
        }
        else
        {
            NotFound();
        }

        CompleteRequest();
    }
Example #36
0
 protected RepositoryBase(IScopeAccessor scopeAccessor, CacheHelper cache, ILogger logger)
 {
     ScopeAccessor = scopeAccessor ?? throw new ArgumentNullException(nameof(scopeAccessor));
     Logger        = logger ?? throw new ArgumentNullException(nameof(logger));
     GlobalCache   = cache ?? throw new ArgumentNullException(nameof(cache));
 }
    protected void Page_Load(object sender, EventArgs e)
    {
        fileGuid = QueryHelper.GetGuid("fileguid", Guid.Empty);

        DebugHelper.SetContext("GetForumAttachment");

        int cacheMinutes = CacheMinutes;

        // Try to get data from cache
        using (var cs = new CachedSection <CMSOutputForumAttachment>(ref outputFile, cacheMinutes, true, null, "getforumattachment", CurrentSiteName, GetBaseCacheKey(), Request.QueryString))
        {
            if (cs.LoadData)
            {
                // Disable caching before check permissions
                cs.CacheMinutes = 0;

                // Process the file
                ProcessFile();

                // Keep original cache minutes if permissions are ok
                cs.CacheMinutes = cacheMinutes;

                // Ensure the cache settings
                if (cs.Cached)
                {
                    // Prepare the cache dependency
                    CMSCacheDependency cd = null;
                    if (outputFile != null)
                    {
                        if (outputFile.ForumAttachment != null)
                        {
                            cd = CacheHelper.GetCacheDependency(outputFile.ForumAttachment.GetDependencyCacheKeys());

                            // Do not cache if too big file which would be stored in memory
                            if (!CacheHelper.CacheImageAllowed(CurrentSiteName, outputFile.ForumAttachment.AttachmentFileSize) && !ForumAttachmentInfoProvider.StoreFilesInFileSystem(CurrentSiteName))
                            {
                                cacheMinutes = largeFilesCacheMinutes;
                            }
                        }
                    }

                    if ((cd == null) && (CurrentSite != null) && (outputFile != null))
                    {
                        // Get the current forum id
                        int forumId = 0;
                        if (outputFile.ForumAttachment != null)
                        {
                            forumId = outputFile.ForumAttachment.AttachmentForumID;
                        }

                        // Set default dependency based on GUID
                        cd = GetCacheDependency(new List <string> {
                            "forumattachment|" + fileGuid.ToString().ToLowerCSafe() + "|" + CurrentSite.SiteID, "forumattachment|" + forumId
                        });
                    }

                    // Cache the data
                    cs.CacheMinutes    = cacheMinutes;
                    cs.CacheDependency = cd;
                }

                cs.Data = outputFile;
            }
        }

        // Send the data
        SendFile(outputFile);

        DebugHelper.ReleaseContext();
    }
Example #38
0
 public PrintUtility()
 {
     _cacheHelper = CacheHelper.Instance;
 }
Example #39
0
    protected void Page_Load(object sender, EventArgs e)
    {
        DateTime time;

        base.Response.Expires = 0;
        if (!base.IsUserLoginByMobileForAjax())
        {
            this.Session.Abandon();
            base.Response.Write("<script>top.location.href='/m'</script>");
            base.Response.End();
        }
        int num30 = 3;

        if (!base.IsLotteryExistByPhone(num30.ToString()))
        {
            this.Session.Abandon();
            base.Response.Write("<script>top.location.href='/m'</script>");
            base.Response.End();
        }
        string str  = this.Session["user_name"].ToString();
        string str2 = "";
        cz_userinfo_session getUserModelInfo = base.GetUserModelInfo;

        if (FileCacheHelper.get_RedisStatOnline().Equals(1))
        {
            base.CheckIsOut(getUserModelInfo.get_u_name());
            base.stat_online_redis(getUserModelInfo.get_u_name(), "hy");
        }
        else if (FileCacheHelper.get_RedisStatOnline().Equals(2))
        {
            base.CheckIsOutStack(getUserModelInfo.get_u_name());
            base.stat_online_redisStack(getUserModelInfo.get_u_name(), "hy");
        }
        else
        {
            MemberPageBase.stat_online_bet(getUserModelInfo.get_u_name(), "hy");
        }
        if (!base.BetCreditLock(str))
        {
            str2 = "系統繁忙,請稍後!";
            str2 = string.Format("<script>alert('{0}');</script>", str2);
            base.Response.Write(str2);
            base.Response.End();
        }
        user_kc_rate rate  = base.GetUserRate_kc(getUserModelInfo.get_zjname());
        DataTable    table = null;
        DataSet      set   = CallBLL.cz_users_bll.AccountIsDisabled(rate.get_fgsname(), rate.get_gdname(), rate.get_zdname(), rate.get_dlname(), getUserModelInfo.get_u_name());

        if (set != null)
        {
            table = set.Tables[0];
            if ((table != null) && (table.Rows.Count > 0))
            {
                if (table.Rows[0]["a_state"].ToString().Trim() == "1")
                {
                    base.DeleteCreditLock(str);
                    str2 = "會員或上級已經被凍結,請與上級聯系!";
                    str2 = string.Format("<script>alert('{0}');</script>", str2);
                    base.Response.Write(str2);
                    base.Response.End();
                }
                else
                {
                    base.DeleteCreditLock(str);
                    str2 = "會員或上級已經被停用,請與上級聯系!";
                    str2 = string.Format("<script>alert('{0}');</script>", str2);
                    base.Response.Write(str2);
                    base.Response.End();
                }
            }
        }
        else
        {
            base.Response.End();
        }
        string str4  = base.qq("caizhong");
        string str5  = base.qq("wanfa");
        string str6  = base.qq("jiangqi");
        string str7  = "XYNC_" + str5 + ".aspx?lottery_type=" + str4 + "&player_type=" + str5;
        string str8  = "";
        string str9  = "";
        string str10 = "";
        string str11 = "";
        string str12 = "";

        str9  = base.qq("uPI_ID");
        str10 = base.qq("uPI_P");
        str11 = base.qq("uPI_M");
        string[] strArray = base.qq("i_index").Split(new char[] { ',' });
        str12 = base.qq("JeuValidate");
        str8  = base.qq("shortcut");
        if ((((string.IsNullOrEmpty(str4) || string.IsNullOrEmpty(str5)) || (string.IsNullOrEmpty(str6) || string.IsNullOrEmpty(str9))) || string.IsNullOrEmpty(str10)) || string.IsNullOrEmpty(str11))
        {
            base.DeleteCreditLock(str);
            base.Response.End();
        }
        string[] source = str9.Split(new char[] { ',' });
        if (source.Distinct <string>().ToList <string>().Count != source.Length)
        {
            base.DeleteCreditLock(str);
            base.Response.End();
        }
        if (source.Length > FileCacheHelper.get_GetXYNCMaxGroup())
        {
            base.DeleteCreditLock(str);
            base.Response.End();
        }
        string str13 = str5;
        string s     = str6;
        int    num2  = 3;

        if ((this.Session["JeuValidate"].ToString().Trim() != str12) || (this.Session["JeuValidate"].ToString().Trim() == ""))
        {
            base.DeleteCreditLock(str);
            base.Response.Write("<script>alert('下注規則有誤,請重新下注,謝謝合作!');$('#JeuValidate').val('" + base.get_JeuValidate() + "');</script>");
            base.Response.End();
        }
        else
        {
            this.Session["JeuValidate"] = "";
        }
        int num3 = 1;

        if (getUserModelInfo.get_su_type().ToString().Trim() != "dl")
        {
            num3 = -1;
        }
        int index = 0;

        Label_05EB :;
        if (index < str11.Split(new char[] { ',' }).Length)
        {
            if (!base.IsNumber(str11.Split(new char[] { ',' })[index]))
            {
                base.DeleteCreditLock(str);
                base.Response.Write("<script>alert($(\"#v_" + strArray[index] + "\").text()+' 下注金額有誤!');$('#m_" + strArray[index] + "').focus();$('#JeuValidate').val('" + base.get_JeuValidate() + "');</script>");
                base.Response.End();
                return;
            }
            index++;
            goto Label_05EB;
        }
        if (getUserModelInfo.get_begin_kc().Trim() != "yes")
        {
            getUserModelInfo = base.GetRateByUserObject(2, rate);
        }
        string str16 = "";
        string str17 = "";

        if (!Utils.IsInteger(s))
        {
            base.Response.End();
        }
        DataTable table2 = CallBLL.cz_phase_xync_bll.GetIsClosedByTime(int.Parse(s)).Tables[0];

        if ((table2 != null) && (table2.Rows.Count > 0))
        {
            if (table2.Rows[0]["is_closed"].ToString().Trim() == "1")
            {
                base.DeleteCreditLock(str);
                base.Response.Write("<script>alert('該獎期已經截止下注!');window.location=\"" + str7 + "\";</script>");
                base.Response.End();
                return;
            }
            str16 = table2.Rows[0]["phase"].ToString();
            str17 = table2.Rows[0]["p_id"].ToString();
            time  = Convert.ToDateTime(table2.Rows[0]["stop_date"].ToString());
            num30 = 3;
            string str18 = base.BetReceiveEnd(num30.ToString());
            if (!string.IsNullOrEmpty(str18))
            {
                time = Convert.ToDateTime(table2.Rows[0]["play_open_date"].ToString()).AddSeconds((double)-int.Parse(str18));
            }
        }
        else
        {
            base.DeleteCreditLock(str);
            base.Response.Write("<script>alert('該獎期已經截止下注!');window.location=\"" + str7 + "\";</script>");
            base.Response.End();
            return;
        }
        string    str19  = "";
        string    str20  = "";
        double    num5   = 0.0;
        DataTable table3 = CallBLL.cz_users_bll.GetUserRate(str, 2).Tables[0];

        str19 = table3.Rows[0]["kc_kind"].ToString().Trim().ToUpper();
        str20 = table3.Rows[0]["su_type"].ToString().Trim();
        num5  = double.Parse(table3.Rows[0]["kc_usable_credit"].ToString().Trim());
        getUserModelInfo.set_kc_kind(str19.ToUpper());
        string str21 = "0";
        string str22 = "0";
        string str23 = "0";
        string str24 = "0";
        string str25 = "0";
        string str26 = "0";
        double num6  = 0.0;
        double num7  = 0.0;
        double num8  = 0.0;
        double num9  = 0.0;
        double num10 = 0.0;
        double num11 = 0.0;
        string str27 = "";
        string str28 = "";
        string str29 = "";
        string str30 = "";
        string str31 = "";

        string[]  strArray3 = str9.Split(new char[] { ',' });
        string[]  strArray4 = str10.Split(new char[] { ',' });
        string[]  strArray5 = str11.Split(new char[] { ',' });
        DataTable plDT      = CallBLL.cz_odds_xync_bll.GetPlayOddsByID(str9).Tables[0];

        if (plDT.Rows.Count == 0)
        {
            base.DeleteCreditLock(str);
            base.Response.End();
        }
        else
        {
            DataTable table5 = CallBLL.cz_bet_kc_bll.GetSinglePhaseByBet(str16, str, num2.ToString(), str9, null).Tables[0];
            if ((plDT.Rows.Count == 0) || (plDT.Rows.Count != strArray3.Count <string>()))
            {
                base.DeleteCreditLock(str);
                base.Response.End();
            }
            else
            {
                double        num12 = 0.0;
                string        str32 = "";
                List <string> list  = new List <string>();
                List <string> list2 = new List <string>();
                int           num13 = 0;
                foreach (string str33 in strArray3)
                {
                    num6  = 0.0;
                    row   = plDT.Select(string.Format(" odds_id= {0} ", str33.Trim()))[0];
                    str32 = row["is_open"].ToString().Trim();
                    str28 = row["current_odds"].ToString().Trim();
                    str29 = row[str19 + "_diff"].ToString().Trim();
                    str27 = row["play_id"].ToString().Trim();
                    str30 = row["play_name"].ToString().Trim();
                    str31 = row["put_amount"].ToString().Trim();
                    num11 = double.Parse(row["allow_min_amount"].ToString().Trim());
                    num8  = double.Parse(row["allow_max_amount"].ToString().Trim());
                    num10 = double.Parse(row["allow_max_put_amount"].ToString().Trim());
                    if ((table5 != null) && (table5.Rows.Count > 0))
                    {
                        DataRow[] rowArray2 = table5.Select(string.Format(" odds_id = {0} ", str33.Trim()));
                        if (rowArray2.Count <DataRow>() > 0)
                        {
                            num6 = double.Parse(rowArray2[0]["sumbet"].ToString().Trim());
                        }
                    }
                    DataTable table6 = null;
                    if (FileCacheHelper.get_GetKCPutMoneyCache() == "1")
                    {
                        if (CacheHelper.GetCache("kc_drawback_FileCacheKey_xync" + str27 + this.Session["user_name"].ToString()) == null)
                        {
                            table6 = CallBLL.cz_drawback_xync_bll.GetDrawback(str27, str).Tables[0];
                        }
                        else
                        {
                            table6 = base.GetUserDrawback_xync(rate, getUserModelInfo.get_kc_kind(), str27);
                        }
                    }
                    else if (CacheHelper.GetCache("kc_drawback_FileCacheKey_xync" + this.Session["user_name"].ToString()) == null)
                    {
                        table6 = CallBLL.cz_drawback_xync_bll.GetDrawback(str27, str).Tables[0];
                    }
                    else
                    {
                        table6 = base.GetUserDrawback_xync(rate, getUserModelInfo.get_kc_kind());
                    }
                    DataRow[] rowArray3 = table6.Select(string.Format(" play_id={0} and u_name='{1}' ", str27, str));
                    num7 = double.Parse(rowArray3[0]["single_max_amount"].ToString().Trim());
                    double num14 = double.Parse(rowArray3[0]["single_min_amount"].ToString().Trim());
                    num9 = double.Parse(rowArray3[0]["single_phase_amount"].ToString().Trim());
                    if (num7 > num8)
                    {
                        num7 = num8;
                    }
                    if (num9 > num10)
                    {
                        num9 = num10;
                    }
                    if (num14 > num11)
                    {
                        num11 = num14;
                    }
                    if (str32 != "1")
                    {
                        base.DeleteCreditLock(str);
                        base.Response.Write("<script>alert('" + str30 + "【" + str31 + "】已經停止投注!!');$('#JeuValidate').val('" + base.get_JeuValidate() + "');</script>");
                        base.Response.End();
                    }
                    num12 = double.Parse(str28) + double.Parse(str29);
                    string pl = num12.ToString();
                    base.GetOdds_KC(3, str33, ref pl);
                    num12 = Convert.ToDouble(pl);
                    if (!(double.Parse(strArray4[num13]) == double.Parse(num12.ToString())))
                    {
                        list.Add(num13.ToString());
                        list2.Add(num12.ToString());
                    }
                    if (list.Count > 0)
                    {
                        base.DeleteCreditLock(str);
                        base.Response.Write("<script>alert('" + str30 + "【" + str31 + "】賠率已經由 " + strArray4[num13] + " 變為 " + num12.ToString() + " 請確認再投註!');$('#v_" + strArray[num13] + " ~ span.hong').text('" + num12.ToString() + "');$('#p_" + strArray[num13] + "').val('" + num12.ToString() + "');$('#JeuValidate').val('" + base.get_JeuValidate() + "');</script>");
                        base.Response.End();
                        return;
                    }
                    if (double.Parse(strArray5[num13]) > num7)
                    {
                        base.DeleteCreditLock(str);
                        base.Response.Write("<script>alert($(\"#v_" + strArray[num13] + "\").text()+' 下注金額超出單注最大金額!');$('#m_" + strArray[num13] + "').focus();$('#JeuValidate').val('" + base.get_JeuValidate() + "');</script>");
                        base.Response.End();
                        return;
                    }
                    if (double.Parse(strArray5[num13]) < num11)
                    {
                        base.DeleteCreditLock(str);
                        base.Response.Write("<script>alert($(\"#v_" + strArray[num13] + "\").text()+' 下注金額低過最低金額!');$('#m_" + strArray[num13] + "').focus();$('#JeuValidate').val('" + base.get_JeuValidate() + "');</script>");
                        base.Response.End();
                        return;
                    }
                    if (double.Parse(strArray5[num13]) > num5)
                    {
                        base.DeleteCreditLock(str);
                        base.Response.Write("<script>alert($(\"#v_" + strArray[num13] + "\").text()+' 下注金額超出可用金額!');$('#m_" + strArray[num13] + "').focus();$('#JeuValidate').val('" + base.get_JeuValidate() + "');</script>");
                        base.Response.End();
                        return;
                    }
                    if ((double.Parse(strArray5[num13]) + num6) > num9)
                    {
                        base.DeleteCreditLock(str);
                        base.Response.Write("<script>alert('" + str30 + "【" + str31 + "】下註單期金額超出單期最大金額!');</script>");
                        base.Response.End();
                        return;
                    }
                    num13++;
                }
                double num15 = 0.0;
                int    num16 = 0;
                foreach (string str35 in strArray3)
                {
                    num15 += double.Parse(strArray5[num16].ToString().Trim());
                    num16++;
                }
                if (num5 < num15)
                {
                    base.DeleteCreditLock(str);
                    base.Response.Write("<script>alert('可用餘額不足!');$('#JeuValidate').val('" + base.get_JeuValidate() + "');</script>");
                    base.Response.End();
                }
                else
                {
                    DataTable     dataTable      = null;
                    bool          flag2          = false;
                    List <string> successBetList = new List <string>();
                    DateTime?     nullable       = null;
                    num13 = 0;
                    foreach (string str33 in strArray3)
                    {
                        double num20;
                        if (FileCacheHelper.get_AddBetLockUType_KC().Equals("zj"))
                        {
                            num30 = 3;
                            base.Add_Bet_Lock(num30.ToString(), getUserModelInfo.get_zjname(), str33);
                        }
                        DataTable table8 = CallBLL.cz_odds_xync_bll.GetOddsByID(str33).Tables[0];
                        int       num17  = int.Parse(table8.Rows[0]["play_id"].ToString());
                        string    str36  = table8.Rows[0]["play_name"].ToString();
                        string    str37  = table8.Rows[0]["put_amount"].ToString();
                        string    ratio  = table8.Rows[0]["ratio"].ToString();
                        if (FileCacheHelper.get_GetKCPutMoneyCache() == "1")
                        {
                            dataTable = base.GetUserDrawback_xync(rate, getUserModelInfo.get_kc_kind(), num17.ToString());
                        }
                        else
                        {
                            dataTable = base.GetUserDrawback_xync(rate, getUserModelInfo.get_kc_kind());
                        }
                        if (dataTable == null)
                        {
                            base.DeleteCreditLock(str);
                            if (FileCacheHelper.get_AddBetLockUType_KC().Equals("zj"))
                            {
                                num30 = 3;
                                base.Un_Bet_Lock(num30.ToString(), getUserModelInfo.get_zjname(), str33);
                            }
                            else
                            {
                                num30 = 3;
                                base.Un_Bet_Lock(num30.ToString(), rate.get_fgsname(), str33);
                            }
                            base.Response.Write("<script>alert('系統錯誤,請重試!');$('#JeuValidate').val('" + base.get_JeuValidate() + "');</script>");
                            base.Response.End();
                            return;
                        }
                        DataRow[] rowArray4 = dataTable.Select(string.Format(" play_id={0} ", num17));
                        foreach (DataRow row in rowArray4)
                        {
                            string str42 = row["u_type"].ToString().Trim();
                            if (str42 != null)
                            {
                                if (!(str42 == "zj"))
                                {
                                    if (str42 == "fgs")
                                    {
                                        goto Label_1525;
                                    }
                                    if (str42 == "gd")
                                    {
                                        goto Label_1549;
                                    }
                                    if (str42 == "zd")
                                    {
                                        goto Label_156D;
                                    }
                                    if (str42 == "dl")
                                    {
                                        goto Label_1591;
                                    }
                                    if (str42 == "hy")
                                    {
                                        goto Label_15B5;
                                    }
                                }
                                else
                                {
                                    str21 = row[str19 + "_drawback"].ToString().Trim();
                                }
                            }
                            continue;
Label_1525:
                            str22 = row[str19 + "_drawback"].ToString().Trim();
                            continue;
Label_1549:
                            str23 = row[str19 + "_drawback"].ToString().Trim();
                            continue;
Label_156D:
                            str24 = row[str19 + "_drawback"].ToString().Trim();
                            continue;
Label_1591:
                            str25 = row[str19 + "_drawback"].ToString().Trim();
                            continue;
Label_15B5:
                            if (getUserModelInfo.get_su_type() == "dl")
                            {
                                str26 = row[str19 + "_drawback"].ToString().Trim();
                            }
                            else if (getUserModelInfo.get_su_type() == "zd")
                            {
                                str25 = row[str19 + "_drawback"].ToString().Trim();
                                str26 = row[str19 + "_drawback"].ToString().Trim();
                            }
                            else if (getUserModelInfo.get_su_type() == "gd")
                            {
                                str24 = row[str19 + "_drawback"].ToString().Trim();
                                str26 = row[str19 + "_drawback"].ToString().Trim();
                            }
                            else if (getUserModelInfo.get_su_type() == "fgs")
                            {
                                str23 = row[str19 + "_drawback"].ToString().Trim();
                                str26 = row[str19 + "_drawback"].ToString().Trim();
                            }
                        }
                        double num18 = 0.0;
                        double num19 = 0.0;
                        if (rate.get_zcyg().Equals("1"))
                        {
                            num20 = (((100.0 - double.Parse(rate.get_fgszc())) - double.Parse(rate.get_gdzc())) - double.Parse(rate.get_zdzc())) - double.Parse(rate.get_dlzc());
                            num18 = num20;
                            num19 = double.Parse(rate.get_fgszc());
                        }
                        else
                        {
                            num20 = (((100.0 - double.Parse(rate.get_zjzc())) - double.Parse(rate.get_gdzc())) - double.Parse(rate.get_zdzc())) - double.Parse(rate.get_dlzc());
                            num19 = num20;
                            num18 = double.Parse(rate.get_zjzc());
                        }
                        if (DateTime.Now >= time.AddSeconds(0.0))
                        {
                            flag2 = true;
                            break;
                        }
                        if (!FileCacheHelper.get_AddBetLockUType_KC().Equals("zj"))
                        {
                            num30 = 3;
                            base.Add_Bet_Lock(num30.ToString(), rate.get_fgsname(), str33);
                        }
                        double num33 = double.Parse(table8.Rows[0]["current_odds"].ToString()) + Convert.ToDouble(table8.Rows[0][str19 + "_diff"].ToString().Trim());
                        string str39 = num33.ToString();
                        string str40 = str39.ToString();
                        base.GetOdds_KC(3, str33, ref str40);
                        double playDrawbackValue = base.GetPlayDrawbackValue(str22, ratio);
                        if ((playDrawbackValue != 0.0) && (double.Parse(str39) > playDrawbackValue))
                        {
                            base.DeleteCreditLock(str);
                            if (FileCacheHelper.get_AddBetLockUType_KC().Equals("zj"))
                            {
                                num30 = 3;
                                base.Un_Bet_Lock(num30.ToString(), getUserModelInfo.get_zjname(), str33);
                            }
                            else
                            {
                                num30 = 3;
                                base.Un_Bet_Lock(num30.ToString(), rate.get_fgsname(), str33);
                            }
                            base.Response.Write("<script>alert('賠率錯誤!');$('#JeuValidate').val('" + base.get_JeuValidate() + "');</script>");
                            base.Response.End();
                        }
                        if (!nullable.HasValue)
                        {
                            nullable = new DateTime?(DateTime.Now);
                        }
                        cz_bet_kc _kc = new cz_bet_kc();
                        _kc.set_order_num(Utils.GetOrderNumber());
                        _kc.set_checkcode(str12);
                        _kc.set_u_name(getUserModelInfo.get_u_name());
                        _kc.set_u_nicker(getUserModelInfo.get_u_nicker());
                        _kc.set_phase_id(new int?(int.Parse(str17)));
                        _kc.set_phase(str16);
                        _kc.set_bet_time(nullable);
                        _kc.set_odds_id(new int?(int.Parse(str33)));
                        _kc.set_category(table8.Rows[0]["category"].ToString());
                        _kc.set_play_id(new int?(int.Parse(table8.Rows[0]["play_id"].ToString())));
                        _kc.set_play_name(table8.Rows[0]["play_name"].ToString());
                        _kc.set_bet_val(table8.Rows[0]["put_amount"].ToString());
                        _kc.set_odds(str40);
                        _kc.set_amount(new decimal?(decimal.Parse(strArray5[num13])));
                        _kc.set_profit(0);
                        _kc.set_hy_drawback(new decimal?(decimal.Parse(str26)));
                        _kc.set_dl_drawback(new decimal?(decimal.Parse(str25)));
                        _kc.set_zd_drawback(new decimal?(decimal.Parse(str24)));
                        _kc.set_gd_drawback(new decimal?(decimal.Parse(str23)));
                        _kc.set_fgs_drawback(new decimal?(decimal.Parse(str22)));
                        _kc.set_zj_drawback(new decimal?(decimal.Parse(str21)));
                        _kc.set_dl_rate((float)int.Parse(rate.get_dlzc()));
                        _kc.set_zd_rate((float)int.Parse(rate.get_zdzc()));
                        _kc.set_gd_rate((float)int.Parse(rate.get_gdzc()));
                        _kc.set_fgs_rate(float.Parse(num19.ToString()));
                        _kc.set_zj_rate(float.Parse(num18.ToString()));
                        _kc.set_dl_name(rate.get_dlname());
                        _kc.set_zd_name(rate.get_zdname());
                        _kc.set_gd_name(rate.get_gdname());
                        _kc.set_fgs_name(rate.get_fgsname());
                        _kc.set_is_payment(0);
                        _kc.set_m_type(new int?(num3));
                        _kc.set_kind(str19);
                        _kc.set_ip(LSRequest.GetIP());
                        _kc.set_lottery_type(new int?(num2));
                        _kc.set_lottery_name(base.GetGameNameByID(_kc.get_lottery_type().ToString()));
                        _kc.set_ordervalidcode(Utils.GetOrderValidCode(_kc.get_u_name(), _kc.get_order_num(), _kc.get_bet_val(), _kc.get_odds(), _kc.get_kind(), Convert.ToInt32(_kc.get_phase_id()), Convert.ToInt32(_kc.get_odds_id()), Convert.ToDouble(_kc.get_amount())));
                        _kc.set_odds_zj(str39);
                        _kc.set_isPhone(1);
                        int num22 = 0;
                        if (!CallBLL.cz_bet_kc_bll.AddBet(_kc, decimal.Parse(strArray5[num13]), str, ref num22) || (num22 <= 0))
                        {
                            base.DeleteCreditLock(str);
                            if (FileCacheHelper.get_AddBetLockUType_KC().Equals("zj"))
                            {
                                num30 = 3;
                                base.Un_Bet_Lock(num30.ToString(), getUserModelInfo.get_zjname(), str33);
                            }
                            else
                            {
                                num30 = 3;
                                base.Un_Bet_Lock(num30.ToString(), rate.get_fgsname(), str33);
                            }
                            base.Response.Write("<script>alert('系統錯誤,請重試!');$('#JeuValidate').val('" + base.get_JeuValidate() + "');</script>");
                            base.Response.End();
                            return;
                        }
                        successBetList.Add(string.Concat(new object[] { _kc.get_odds_id(), ",", _kc.get_order_num(), ",", _kc.get_play_name(), ",", _kc.get_bet_val(), ",", _kc.get_odds(), ",", _kc.get_amount() }));
                        double num23 = (double.Parse(strArray5[num13]) * num18) / 100.0;
                        CallBLL.cz_odds_xync_bll.UpdateGrandTotal(Convert.ToDecimal(num23), int.Parse(str33));
                        double num24 = double.Parse(table8.Rows[0]["grand_total"].ToString()) + num23;
                        double num25 = double.Parse(table8.Rows[0]["downbase"].ToString());
                        double num26 = Math.Floor((double)(num24 / num25));
                        if ((num26 >= 1.0) && (num25 >= 1.0))
                        {
                            double        num27 = double.Parse(table8.Rows[0]["down_odds_rate"].ToString()) * num26;
                            int           num29 = CallBLL.cz_odds_xync_bll.UpdateGrandTotalCurrentOdds(num27.ToString(), (num23 - (num25 * num26)).ToString(), str33);
                            cz_system_log _log  = new cz_system_log();
                            _log.set_user_name("系統");
                            _log.set_children_name("");
                            _log.set_category(table8.Rows[0]["category"].ToString());
                            _log.set_play_name(str36);
                            _log.set_put_amount(str37);
                            num30 = 3;
                            _log.set_l_name(base.GetGameNameByID(num30.ToString()));
                            _log.set_l_phase(str16);
                            _log.set_action("降賠率");
                            _log.set_odds_id(int.Parse(str33));
                            string str41 = table8.Rows[0]["current_odds"].ToString();
                            _log.set_old_val(str41);
                            num33 = double.Parse(str41) - num27;
                            _log.set_new_val(num33.ToString());
                            _log.set_ip(LSRequest.GetIP());
                            _log.set_add_time(DateTime.Now);
                            _log.set_note("系統自動降賠");
                            _log.set_type_id(Convert.ToInt32((LSEnums.LogTypeID) 0));
                            _log.set_lottery_type(3);
                            CallBLL.cz_system_log_bll.Add(_log);
                            cz_jp_odds _odds = new cz_jp_odds();
                            _odds.set_add_time(DateTime.Now);
                            _odds.set_odds_id(int.Parse(str33));
                            _odds.set_phase_id(int.Parse(str17));
                            _odds.set_play_name(str36);
                            _odds.set_put_amount(str37);
                            _odds.set_odds(num27.ToString());
                            _odds.set_lottery_type(3);
                            _odds.set_phase(str16);
                            _odds.set_old_odds(str41);
                            _odds.set_new_odds((double.Parse(str41) - num27).ToString());
                            CallBLL.cz_jp_odds_bll.Add(_odds);
                        }
                        DataTable fgsWTTable = null;
                        if (getUserModelInfo.get_kc_op_odds().Equals(1))
                        {
                            fgsWTTable = base.GetFgsWTTable(3);
                        }
                        CallBLL.cz_autosale_xync_bll.DLAutoSale(_kc.get_order_num(), str12, getUserModelInfo.get_u_nicker(), getUserModelInfo.get_u_name(), str19, table8.Rows[0]["play_id"].ToString(), str33.Trim(), str21, str22, str23, str24, str25, str26, str17, str16, _kc.get_ip(), num2, _kc.get_lottery_name(), getUserModelInfo, rate, fgsWTTable);
                        if (getUserModelInfo.get_kc_op_odds().Equals(1))
                        {
                            fgsWTTable = base.GetFgsWTTable(3);
                        }
                        CallBLL.cz_autosale_xync_bll.ZDAutoSale(_kc.get_order_num(), str12, getUserModelInfo.get_u_nicker(), getUserModelInfo.get_u_name(), str19, table8.Rows[0]["play_id"].ToString(), str33.Trim(), str21, str22, str23, str24, str25, str26, str17, str16, _kc.get_ip(), num2, _kc.get_lottery_name(), getUserModelInfo, rate, fgsWTTable);
                        if (getUserModelInfo.get_kc_op_odds().Equals(1))
                        {
                            fgsWTTable = base.GetFgsWTTable(3);
                        }
                        CallBLL.cz_autosale_xync_bll.GDAutoSale(_kc.get_order_num(), str12, getUserModelInfo.get_u_nicker(), getUserModelInfo.get_u_name(), str19, table8.Rows[0]["play_id"].ToString(), str33.Trim(), str21, str22, str23, str24, str25, str26, str17, str16, _kc.get_ip(), num2, _kc.get_lottery_name(), getUserModelInfo, rate, fgsWTTable);
                        if (getUserModelInfo.get_kc_op_odds().Equals(1))
                        {
                            fgsWTTable = base.GetFgsWTTable(3);
                        }
                        CallBLL.cz_autosale_xync_bll.FGSAutoSale(_kc.get_order_num(), str12, getUserModelInfo.get_u_nicker(), getUserModelInfo.get_u_name(), str19, table8.Rows[0]["play_id"].ToString(), str33.Trim(), str21, str22, str23, str24, str25, str26, str17, str16, _kc.get_ip(), num2, _kc.get_lottery_name(), getUserModelInfo, rate, fgsWTTable);
                        if (FileCacheHelper.get_AddBetLockUType_KC().Equals("zj"))
                        {
                            num30 = 3;
                            base.Un_Bet_Lock(num30.ToString(), getUserModelInfo.get_zjname(), str33);
                        }
                        else
                        {
                            base.Un_Bet_Lock(3.ToString(), rate.get_fgsname(), str33);
                        }
                        num13++;
                        if (FileCacheHelper.get_GetKCPutMoneyCache() == "1")
                        {
                            base.SetUserDrawback_xync(dataTable, num17.ToString());
                        }
                    }
                    base.SetUserRate_kc(rate);
                    if (FileCacheHelper.get_GetKCPutMoneyCache() != "1")
                    {
                        base.SetUserDrawback_xync(dataTable);
                    }
                    getUserModelInfo.set_begin_kc("yes");
                    base.UserPutBetByPhone(plDT, successBetList, strArray3, strArray4, strArray5);
                    base.DeleteCreditLock(str);
                    base.Response.Write(string.Format("<script>window.location=\"tj_ok.aspx?lottery_type={0}&player_type={1}\";</script>", str4, str5));
                    base.Response.End();
                }
            }
        }
    }
Example #40
0
 public PrintUtility()
 {
     _cacheHelper = new CacheHelper();
 }
 public void KillServer()
 {
     CacheHelper.StopJavaServer(1);
     Util.Log("Cacheserver 1 stopped.");
 }
Example #42
0
 public void CreateRegion(string locators, string servergroup, string regionName, string poolName)
 {
     CacheHelper.CreateTCRegion_Pool <object, object>(regionName, true, true,
                                                      null, locators, poolName, true, servergroup);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="VirtualProductContentCache"/> class.
 /// </summary>
 /// <param name="cache">
 /// The cache.
 /// </param>
 public VirtualProductContentCache(CacheHelper cache)
     : this(cache, true)
 {
 }