Ejemplo n.º 1
0
 /// <summary>
 /// 销毁所有的映射。
 /// </summary>
 public virtual void DestroyAll()
 {
     CacheTypeName.Clear();
     CacheName.Clear();
     CacheType.Clear();
     GC.WaitForFullGCComplete();
 }
Ejemplo n.º 2
0
    private void RemovePage()
    {
        string info = Utils.GetRequest("info", "all", 1, "", "");
        int    id   = int.Parse(Utils.GetRequest("id", "get", 2, @"^[1-9]\d*$", "ID错误"));
        int    hid  = int.Parse(Utils.GetRequest("hid", "get", 2, @"^[1-9]\d*$", "会员ID错误"));

        if (info == "")
        {
            Master.Title = "撤销记录";
            builder.Append(Out.Tab("<div class=\"title\">", ""));
            builder.Append("确定撤销此记录吗");
            builder.Append(Out.Tab("</div>", "<br />"));
            builder.Append(Out.Tab("<div>", ""));
            builder.Append("<a href=\"" + Utils.getUrl("medal.aspx?info=ok&amp;act=remove&amp;id=" + id + "&amp;hid=" + hid + "&amp;backurl=" + Utils.getPage(0) + "") + "\">确定撤销</a><br />");
            builder.Append("<a href=\"" + Utils.getPage("medal.aspx?act=me&amp;hid=" + hid + "") + "\">先留着吧..</a>");
            builder.Append(Out.Tab("</div>", "<br />"));
        }
        else
        {
            if (!new BCW.BLL.Medal().Exists(id, hid))
            {
                Utils.Error("不存在的记录", "");
            }
            BCW.Model.Medal model  = new BCW.BLL.Medal().GetMedalMe(id);
            string          sPayID = string.Empty;
            sPayID = Utils.Mid(model.PayID, 1, model.PayID.Length);
            sPayID = Utils.DelLastChar(sPayID, "#");
            string[] temp = Regex.Split(sPayID, "##");
            //得到位置
            int strPn = 0;
            for (int i = 0; i < temp.Length; i++)
            {
                if (temp[i].ToString() == hid.ToString())
                {
                    strPn = i;
                    break;
                }
            }
            string sPayExTime = string.Empty;
            sPayExTime = Utils.Mid(model.PayExTime, 1, model.PayExTime.Length);
            sPayExTime = Utils.DelLastChar(sPayExTime, "#");
            string[] temp2     = Regex.Split(sPayExTime, "##");
            string   PayExTime = string.Empty;
            for (int i = 0; i < temp2.Length; i++)
            {
                if (i != strPn)
                {
                    PayExTime += "#" + temp2[i] + "#";
                }
            }
            string PayID = model.PayID.Replace("#" + hid + "#", "");
            //更新
            new BCW.BLL.Medal().UpdatePayID(id, PayID, PayExTime);
            //清缓存
            string CacheKey = CacheName.App_UserMedal(hid);
            DataCache.RemoveByPattern(CacheKey);
            Utils.Success("撤销", "撤销成功..", Utils.getPage("medal.aspx?act=me&amp;hid=" + hid + ""), "1");
        }
    }
Ejemplo n.º 3
0
 public ConnectionDataEvent(CacheName cache, ConnectionDataAction action, TKey key, TValue cValue, TValue oValue)
 {
     Cache        = cache;
     Action       = action;
     Key          = key;
     CurrentValue = cValue;
     OldValue     = oValue;
 }
        public override int GetHashCode()
        {
            int hash = 37;

            hash = hash * 23 + (HostIdentifier != null ? HostIdentifier.GetHashCode() : 0);
            hash = hash * 23 + (CacheName != null ? CacheName.GetHashCode() : 0);
            hash = hash * 23 + (AuthorizationToken != null ? AuthorizationToken.GetHashCode() : 0);
            hash = hash * 23 + CompressionIsEnabled.GetHashCode();
            return(hash);
        }
Ejemplo n.º 5
0
        public override int GetHashCode()
        {
            int hash = 37;

            hash = hash * 23 + HostIdentifier.GetHashCode();
            hash = hash * 23 + CacheName.GetHashCode();
            hash = hash * 23 + AuthorizationToken.GetHashCode();
            hash = hash * 23 + CompressionIsEnabled.GetHashCode();
            return(hash);
        }
Ejemplo n.º 6
0
    private void GrantSavePage()
    {
        int ID   = int.Parse(Utils.GetRequest("ID", "post", 2, @"^[1-9]\d*$", "勋章编号填写错误"));
        int iDay = int.Parse(Utils.GetRequest("iDay", "post", 2, @"^[0-9]\d*$", "勋章有效天数填写错误"));
        int hid  = int.Parse(Utils.GetRequest("hid", "post", 2, @"^[1-9]\d*$", "会员ID错误"));

        if (!new BCW.BLL.Medal().Exists(ID))
        {
            Utils.Error("不存在的勋章记录", "");
        }
        if (new BCW.BLL.Medal().Exists(ID, hid))
        {
            Utils.Error("此会员已存在这个勋章,如要修改期限请先撤销再授予", "");
        }

        BCW.Model.Medal model  = new BCW.BLL.Medal().GetMedal(ID);
        string          PayID  = model.PayID + "#" + hid + "#";
        string          ExTime = string.Empty;

        if (iDay == 0)
        {
            ExTime = "1990-1-1";
        }
        else
        {
            ExTime = DT.FormatDate(DateTime.Now.AddDays(iDay), 11);
        }

        string PayExTime = model.PayExTime + "#" + ExTime + "#";

        new BCW.BLL.Medal().UpdatePayID(ID, PayID, PayExTime);
        //清缓存
        string CacheKey = CacheName.App_UserMedal(hid);

        DataCache.RemoveByPattern(CacheKey);

        //记录获授勋章日志
        string DayTime = "" + iDay + "天";

        if (iDay == 0)
        {
            DayTime = "永久";
        }

        BCW.Model.Medalget m = new BCW.Model.Medalget();
        m.Types   = 0;
        m.UsID    = hid;
        m.MedalId = ID;
        m.Notes   = "" + model.Title + "[IMG]" + model.ImageUrl + "[/IMG][有效期" + DayTime + "]";
        m.AddTime = DateTime.Now;
        new BCW.BLL.Medalget().Add(m);


        Utils.Success("授予勋章", "授予勋章并记录授日志成功..", Utils.getUrl("medal.aspx?act=me&amp;hid=" + hid + "&amp;ptype=1"), "1");
    }
Ejemplo n.º 7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CacheKey"/> class.
        /// </summary>
        /// <param name="cacheName">
        /// The cache name.
        /// </param>
        /// <param name="key">
        /// The cache key.
        /// </param>
        /// <param name="cultureName">
        /// The culture name.
        /// </param>
        internal CacheKey(CacheName cacheName, string key, string cultureName)
        {
            this.CacheName   = cacheName;
            this.Key         = key;
            this.CultureName = cultureName;

            this.internalKey = string.Format(
                CultureInfo.InvariantCulture,
                "Zen::{0}:{1}:{2}",
                this.CultureName,
                this.CacheName,
                this.Key);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CacheKey"/> class.
        /// </summary>
        /// <param name="cacheName">
        /// The cache name.
        /// </param>
        /// <param name="key">
        /// The cache key.
        /// </param>
        /// <param name="cultureName">
        /// The culture name.
        /// </param>
        internal CacheKey(CacheName cacheName, string key, string cultureName)
        {
            this.CacheName = cacheName;
            this.Key = key;
            this.CultureName = cultureName;

            this.internalKey = string.Format(
                CultureInfo.InvariantCulture,
                "Zen::{0}:{1}:{2}",
                this.CultureName,
                this.CacheName,
                this.Key);
        }
        public void Flush(CacheName cache)
        {
            if (this.Enabled)
            {
                IDictionaryEnumerator enumerator = this.cache.GetEnumerator();

                while (enumerator.MoveNext())
                {
                    CacheKey enumeratorKey = (CacheKey)enumerator.Key.ToString();

                    if (enumeratorKey != null && enumeratorKey.CacheName == cache)
                    {
                        this.cache.Remove(enumeratorKey);
                    }
                }
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// 得到权限实体,从缓存中。
        /// </summary>
        public string GetLimitByCache(int ID)
        {
            string CacheKey = CacheName.App_LimitModel(ID);
            object objModel = DataCache.GetCache(CacheKey);

            if (objModel == null)
            {
                try
                {
                    objModel = dal.GetLimit(ID);
                    if (objModel != null)
                    {
                        int ModelCache = CacheTime.LimitExpir;
                        DataCache.SetCache(CacheKey, objModel, DateTime.Now.AddMinutes(ModelCache), TimeSpan.Zero);
                    }
                }
                catch { }
            }
            return(objModel.ToString());
        }
Ejemplo n.º 11
0
        /// <summary>
        /// The main entry point for the tool.
        /// </summary>
        public void SetBridgeCacheMode()
        {
            try
            {
                _bridgeService = new NCBridgeRPCService(BridgeServer);
                _bridgeServer  = _bridgeService.GetBridgeServer(TimeSpan.FromSeconds(30));

                NCacheRPCService nService = new NCacheRPCService(CacheServer);
                cacheServer = nService.GetCacheServer(new TimeSpan(0, 0, 0, 30));

                if (!ValidateParameters())
                {
                    return;
                }

                //**********************************
                config = cacheServer.GetCacheConfiguration(CacheName);

                if (config == null)
                {
                    OutputProvider.WriteErrorLine("Error : The cache'{0}' does not exist on server {1}:{2} .", CacheName, NCache.ServerName, NCache.Port);
                    return;
                }

                if (config.CacheType.ToLower().Equals("local-cache"))
                {
                    OutputProvider.WriteLine("Local Cache cannot be Set as a bridge cache");
                    return;
                }
                //cacheServer = GetCacheServers(config.Cluster.GetAllConfiguredNodes());
                bool isNotMaster  = false;
                int  passiveCount = 0;

                TargetCacheCofiguration targtCacheConfig = null;
                if (_bridgeServer != null)
                {
                    try
                    {
                        OutputProvider.WriteLine("Setting Cache Mode To Bridge '{0}' on {1}:{2}.", BridgeId, _bridgeService.ServerName, _bridgeService.Port);
                        Alachisoft.NCache.Bridging.Configuration.BridgeConfiguration bridgeConfig = _bridgeServer.GetBridgeConfiguration(BridgeId);

                        ToolsUtil.VerifyBridgeConfigurations(bridgeConfig, BridgeId);

                        List <TargetCacheCofiguration> previouslyAddedCaches = bridgeConfig.TargetCacheConfigList;
                        if (previouslyAddedCaches.Count >= 1)
                        {
                            //checking validations regarding bridge
                            foreach (TargetCacheCofiguration pCache in previouslyAddedCaches)
                            {
                                if (pCache.CacheID.ToLower().Equals(CacheName.ToLower()))
                                {
                                    isNotMaster      = !pCache.IsMaster;
                                    targtCacheConfig = pCache;
                                }
                                if (pCache.Status.Equals("passive"))
                                {
                                    passiveCount++;
                                }
                            }
                        }
                        else
                        {
                            OutputProvider.WriteErrorLine("No Cache Exists in Bridge {0}", BridgeId);
                        }

                        if (passiveCount >= 1 && State.Equals(BridgeCacheStateParam.Passive))
                        {
                            OutputProvider.WriteErrorLine("There is already a Passive cache in Bridge", BridgeId);
                            return;
                        }
                        if (!isNotMaster)
                        {
                            OutputProvider.WriteErrorLine("Bridge Cache '{0}' is a master Node,please change masterNode first", CacheName);
                            return;
                        }
                        if (targtCacheConfig.Status.Equals(State.ToString()))
                        {
                            OutputProvider.WriteErrorLine("Bridge Cache '{0}' is already {1}", CacheName, State.ToString());
                            return;
                        }

                        //

                        //Adding Bridge to config.ncconf
                        BridgeConfig bridgeConf = config.Bridge;
                        bridgeConf.Status = State.ToString();

                        config.Bridge = bridgeConf;
                        WriteToClientConf();

                        WriteToBridgeConf(bridgeConfig, targtCacheConfig);

                        OutputProvider.WriteLine("Cache '{0}' mode set to {1}", BridgeId, State.ToString());
                    }
                    catch (SecurityException e)
                    {
                        OutputProvider.WriteErrorLine("Failed to Add Cache to bridge '{0}'. Error: {1} ", BridgeId, e.Message);
                    }
                    catch (Exception e)
                    {
                        OutputProvider.WriteErrorLine("Failed to Add Cache to bridge '{0}'. Error: {1} ", BridgeId, e.Message);
                    }
                }
            }
            catch (Exception e)
            {
                OutputProvider.WriteErrorLine("Error: {0}", e.Message);
            }
            finally
            {
                if (_bridgeService != null)
                {
                    _bridgeService.Dispose();
                }
                if (NCache != null)
                {
                    NCache.Dispose();
                }
            }
        }
        /// <summary>
        /// The main entry point for the tool.
        /// </summary>
        public void SetBridgeCacheConnection()
        {
            try
            {
                _bridgeService = new NCBridgeRPCService(BridgeServer);
                _bridgeServer  = _bridgeService.GetBridgeServer(TimeSpan.FromSeconds(30));


                if (!ValidateParameters())
                {
                    return;
                }

                //**********************************

                //cacheServer = GetCacheServers(config.Cluster.GetAllConfiguredNodes());
                bool isNotMaster  = false;
                int  passiveCount = 0;
                bool cacheExists  = false;
                TargetCacheCofiguration targtCacheConfig = null;
                if (_bridgeServer != null)
                {
                    try
                    {
                        OutputProvider.WriteLine("Setting Cache '{0}' Connection To Bridge '{1}' on {2}:{3}.", CacheName, BridgeId, _bridgeService.ServerName, _bridgeService.Port);
                        Alachisoft.NCache.Bridging.Configuration.BridgeConfiguration bridgeConfig = _bridgeServer.GetBridgeConfiguration(BridgeId);
                        ToolsUtil.VerifyBridgeConfigurations(bridgeConfig, BridgeId);


                        List <TargetCacheCofiguration> previouslyAddedCaches = bridgeConfig.TargetCacheConfigList;
                        if (previouslyAddedCaches.Count >= 1)
                        {
                            //checking validations regarding bridge
                            foreach (TargetCacheCofiguration pCache in previouslyAddedCaches)
                            {
                                if (pCache.CacheID.ToLower().Equals(CacheName.ToLower()))
                                {
                                    cacheExists      = true;
                                    isNotMaster      = !pCache.IsMaster;
                                    targtCacheConfig = pCache;
                                }
                                if (pCache.Status.Equals("passive"))
                                {
                                    passiveCount++;
                                }
                            }
                        }
                        else
                        {
                            OutputProvider.WriteErrorLine("No Cache Exists in Bridge {0}", BridgeId);
                            return;
                        }
                        if (previouslyAddedCaches.Count == 2 && !isNotMaster && cacheExists && Connection.ToString().ToLower().Equals("disconnect"))
                        {
                            OutputProvider.WriteErrorLine("Master Cache '{0}'cannot be disconnected,please change the master cache First", CacheName);
                            return;
                        }

                        if (!cacheExists)
                        {
                            OutputProvider.WriteErrorLine("No Cache Exists in Bridge {0} with CacheId {1}", BridgeId, CacheName);
                        }


                        WriteToBridgeConf(bridgeConfig, targtCacheConfig);
                        OutputProvider.WriteLine("Bridge Connection for Bridge {0} set to {1} Successfully!", BridgeId, Connection.ToString());
                    }
                    catch (SecurityException e)
                    {
                        OutputProvider.WriteErrorLine("Failed to Set Cache Connection Status to bridge '{0}'. Error: {1} ", BridgeId, e.Message);
                    }
                    catch (Exception e)
                    {
                        OutputProvider.WriteErrorLine("Failed to Set Cache Connection Status to bridge '{0}'. Error: {1} ", BridgeId, e.Message);
                    }
                }
            }
            catch (Exception e)
            {
                OutputProvider.WriteErrorLine("Error: {0}", e.Message);
            }
            finally
            {
                if (_bridgeService != null)
                {
                    _bridgeService.Dispose();
                }
            }
        }
Ejemplo n.º 13
0
 /// <summary>
 /// Initializes a new instance of the CachedAttribute class.
 /// </summary>
 /// <param name="cache">
 /// The name of the cache to store the data
 /// </param>
 public CachedAttribute(CacheName cache)
 {
     this.cache = cache;
 }
Ejemplo n.º 14
0
    private void CentPage()
    {
        int forumid = int.Parse(Utils.GetRequest("forumid", "all", 2, @"^[0-9]\d*$", "论坛ID错误"));

        if (!new BCW.BLL.Forum().Exists2(forumid))
        {
            Utils.Success("访问论坛", "该论坛不存在或已暂停使用", Utils.getUrl("forum.aspx"), "1");
        }
        if (new BCW.User.ForumInc().IsForumGSIDS(forumid) == true)
        {
        }
        else
        {
            Utils.Error("不存在的记录", "");
        }
        Master.Title = "奖励会员";
        int meid = new BCW.User.Users().GetUsId();

        if (meid == 0)
        {
            Utils.Login();
        }

        string GsAdminID = ub.GetSub("BbsGsAdminID", xmlPath);

        if (!("#" + GsAdminID + "#").Contains("#" + meid + "#"))
        {
            Utils.Error("权限不足", "");
        }

        int bid = int.Parse(Utils.GetRequest("bid", "all", 2, @"^[0-9]\d*$", "ID错误"));

        if (!new BCW.BLL.Text().Exists2(bid, forumid))
        {
            Utils.Error("帖子不存在或已被删除", "");
        }
        BCW.Model.Text model = new BCW.BLL.Text().GetText(bid);

        string info = Utils.GetRequest("info", "post", 1, "", "");

        if (info != "")
        {
            string Content = Utils.GetRequest("Content", "post", 2, @"^[\s\S]{1,50}$", "奖励原因限1-50字内,不能留空");
            long   Gold    = Int64.Parse(Utils.GetRequest("iGold", "post", 1, @"^[0-9]\d*$", "0"));
            long   Money   = Int64.Parse(Utils.GetRequest("iMoney", "post", 1, @"^[0-9]\d*$", "0"));
            long   Score   = Int64.Parse(Utils.GetRequest("iScore", "post", 1, @"^[0-9]\d*$", "0"));
            int    Vip     = int.Parse(Utils.GetRequest("iVip", "post", 1, @"^[0-3]$", "0"));

            string LogText = "" + Content + "";
            if (Gold > 0)
            {
                LogText += "/奖" + Gold + "" + ub.Get("SiteBz") + "";
            }
            if (Money > 0)
            {
                LogText += "/奖" + Money + "" + ub.Get("SiteBz2") + "";
            }
            if (Score > 0)
            {
                LogText += "/奖" + Score + "积分";
            }
            if (Vip > 0)
            {
                LogText += "/奖VIP" + Vip + "月";
            }

            if (info == "ok")
            {
                builder.Append(Out.Tab("<div class=\"text\">", ""));
                builder.Append("奖励对象:<a href=\"" + Utils.getUrl("uinfo.aspx?uid=" + model.UsID + "&amp;backurl=" + Utils.PostPage(1) + "") + "\">" + model.UsName + "(" + model.UsID + ")</a>");
                builder.Append(Out.Tab("</div>", "<br />"));
                builder.Append(Out.Tab("<div class=\"text\">", ""));
                builder.Append("奖励并生成日志:" + LogText + "");
                builder.Append(Out.Tab("</div>", "<br />"));

                string strName = "Content,iGold,iMoney,iScore,iVip,forumid,bid,act,info,backurl";
                string strValu = "" + Content + "'" + Gold + "'" + Money + "'" + Score + "'" + Vip + "'" + forumid + "'" + bid + "'cent'ok2'" + Utils.getPage(0) + "'";
                string strOthe = "确认奖励,Gstoplist.aspx,post,0,red";

                builder.Append(Out.wapform(strName, strValu, strOthe));
            }
            else
            {
                if (Gold > 0)
                {
                    new BCW.BLL.User().UpdateiGold(model.UsID, model.UsName, Gold, Content);
                }
                if (Money > 0)
                {
                    new BCW.BLL.User().UpdateiMoney(model.UsID, model.UsName, Money, Content);
                }
                if (Score > 0)
                {
                    new BCW.BLL.User().UpdateiScore(model.UsID, Score);
                }
                if (Vip > 0)
                {
                    string xmlPathvip = "/Controls/bbs.xml";
                    int    VipGrow1   = Utils.ParseInt(ub.GetSub("VipGrow1", xmlPathvip));
                    int    VipGrow2   = Utils.ParseInt(ub.GetSub("VipGrow2", xmlPathvip));
                    int    VipGrow3   = Utils.ParseInt(ub.GetSub("VipGrow3", xmlPathvip));
                    int    VipGrow4   = Utils.ParseInt(ub.GetSub("VipGrow4", xmlPathvip));

                    int Grow = 0;
                    int Day  = 0;
                    if (Vip == 1)
                    {
                        Grow = VipGrow1;
                        Day  = 30;
                    }
                    else if (Vip == 2)
                    {
                        Grow = VipGrow2;
                        Day  = 90;
                    }
                    else if (Vip == 3)
                    {
                        Grow = VipGrow3;
                        Day  = 180;
                    }

                    BCW.Model.User model2 = new BCW.BLL.User().GetVipData(model.UsID);
                    try
                    {
                        if (model2.VipDate != null && model2.VipDate > DateTime.Now)
                        {
                            new BCW.BLL.User().UpdateVipData(model.UsID, Grow, model2.VipDate.AddDays(Day));
                        }
                        else
                        {
                            new BCW.BLL.User().UpdateVipData(model.UsID, Grow, DateTime.Now.AddDays(Day));
                        }
                    }
                    catch
                    {
                        new BCW.BLL.User().UpdateVipData(model.UsID, Grow, DateTime.Now.AddDays(Day));
                    }
                    //清缓存
                    string CacheKey = CacheName.App_UserVip(model.UsID);
                    DataCache.RemoveByPattern(CacheKey);
                }
                //记录日志
                BCW.Model.Forumvotelog m = new BCW.Model.Forumvotelog();
                m.UsID    = model.UsID;
                m.UsName  = model.UsName;
                m.AdminId = meid;
                m.BID     = bid;
                m.ForumId = forumid;
                m.Title   = model.Title;
                m.Notes   = LogText;
                m.AddTime = DateTime.Now;
                new BCW.BLL.Forumvotelog().Add(m);

                Utils.Success("奖励会员", "恭喜,奖励成功,正在返回..", Utils.getPage("Gstoplist.aspx?forumid=" + forumid + ""), "2");
            }
        }
        else
        {
            builder.Append(Out.Tab("<div class=\"title\">", ""));
            builder.Append("主题:<a href=\"" + Utils.getUrl("topic.aspx?forumid=" + model.ForumId + "&amp;bid=" + bid + "&amp;backurl=" + Utils.PostPage(1) + "") + "\">" + model.Title + "</a>");
            builder.Append(Out.Tab("</div>", "<br />"));
            builder.Append(Out.Tab("<div class=\"text\">", ""));
            builder.Append("奖励对象:<a href=\"" + Utils.getUrl("uinfo.aspx?uid=" + model.UsID + "&amp;backurl=" + Utils.PostPage(1) + "") + "\">" + model.UsName + "(" + model.UsID + ")</a><br />");
            builder.Append("<a href=\"" + Utils.getUrl("Gstoplist.aspx?act=centlist&amp;forumid=" + model.ForumId + "&amp;hid=" + model.UsID + "&amp;backurl=" + Utils.PostPage(1) + "") + "\">查看奖励记录&gt;&gt;</a>");
            builder.Append(Out.Tab("</div>", ""));
            string strText = "奖励原因(如填写:2013001期5连中):/,奖" + ub.Get("SiteBz") + ":/,奖" + ub.Get("SiteBz2") + ":/,奖积分:/,奖VIP:/,,,,,,";
            string strName = "Content,iGold,iMoney,iScore,iVip,forumid,bid,act,info,backurl";
            string strType = "textarea,num,num,num,select,hidden,hidden,hidden,hidden,hidden";
            string strValu = "''''0'" + forumid + "'" + bid + "'cent'ok'" + Utils.getPage(0) + "";
            string strEmpt = "true,true,true,true,0|不赠送|1|1个月|2|3个月|3|6个月,false,false,false,false,false";
            string strIdea = "/";
            string strOthe = "确定奖励,Gstoplist.aspx,post,1,red";
            builder.Append(Out.wapform(strText, strName, strType, strValu, strEmpt, strIdea, strOthe));

            builder.Append(Out.Tab("<div class=\"title\">", "<br />"));
            builder.Append("<a href=\"" + Utils.getPage("Gstoplist.aspx?forumid=" + forumid + "") + "\">&lt;&lt;返回上级</a>");
            builder.Append(Out.Tab("</div>", ""));
            builder.Append(Out.Tab("<div class=\"title\">", "<br />"));
            builder.Append("<a href=\"" + Utils.getUrl("/default.aspx") + "\">首页</a>-");
            builder.Append("<a href=\"" + Utils.getUrl("uinfo.aspx?backurl=" + Utils.getPage(0) + "") + "\">上级</a>-");
            builder.Append("<a href=\"" + Utils.getUrl("forum.aspx?forumid=" + forumid + "") + "\">论坛</a>");
            builder.Append(Out.Tab("</div>", ""));
        }
    }
Ejemplo n.º 15
0
        private void ConveyToRegisteredNodes()
        {
            byte[] userId = null;
            byte[] paswd  = null;
            if (UserId != string.Empty && Password != string.Empty)
            {
                userId = EncryptionUtil.Encrypt(UserId);
                paswd  = EncryptionUtil.Encrypt(Password);
            }


            string pId = "";
            NewCacheRegisterationInfo info = cacheServer.GetNewUpdatedCacheConfiguration(CacheName.ToLower(), pId, CacheServer, true);
            // Now update the cache configurations on all the servers where the cache
            //is registered...
            IPAddress address;
            string    clusterIp;
            bool      reregister = false;

            config.ConfigVersion++;
            foreach (string serverName in info.AffectedNodes)
            {
                if (info.AffectedPartitions.Count > 0)
                {
                    foreach (string partId in info.AffectedPartitions)
                    {
                        try
                        {
                            NCache            = new NCacheRPCService(serverName);
                            NCache.ServerName = serverName;
                            if (!IPAddress.TryParse(NCache.ServerName, out address))
                            {
                                clusterIp = cacheServer.GetClusterIP();
                                if (clusterIp != null && clusterIp != string.Empty)
                                {
                                    NCache.ServerName = clusterIp;
                                }
                            }
                            reregister  = true;
                            cacheServer = NCache.GetCacheServer(new TimeSpan(0, 0, 0, 30));
                            cacheServer.ConfigureBridgeToCache(config, userId, paswd, true);
                            cacheServer.HotApplyBridgeReplicator(CacheName, false);
                        }
                        catch (Exception ex)
                        {
                            OutputProvider.WriteErrorLine("Failed to Create Cache on '{0}'. ", NCache.ServerName);
                            OutputProvider.WriteErrorLine("Error Detail: '{0}'. ", ex.Message);
                        }
                        finally
                        {
                            cacheServer.Dispose();
                        }
                    }
                }
                else
                {
                    try
                    {
                        NCache.ServerName = serverName;
                        if (!IPAddress.TryParse(NCache.ServerName, out address))
                        {
                            clusterIp = cacheServer.GetClusterIP();
                            if (clusterIp != null && clusterIp != string.Empty)
                            {
                                NCache.ServerName = clusterIp;
                            }
                        }
                        reregister  = true;
                        cacheServer = NCache.GetCacheServer(new TimeSpan(0, 0, 0, 30));
                        cacheServer.ConfigureBridgeToCache(config, userId, paswd, true);
                        cacheServer.HotApplyBridgeReplicator(CacheName, false);
                    }
                    catch (Exception ex)
                    {
                        OutputProvider.WriteErrorLine("Failed to Create Cache on '{0}'. ", NCache.ServerName);
                        OutputProvider.WriteErrorLine("Error Detail: '{0}'. ", ex.Message);


                        NCache.Dispose();
                        return;
                    }
                    finally
                    {
                        cacheServer.Dispose();
                    }
                }
            }

            /*
             *
             * byte[] userId = null;
             * byte[] paswd = null;
             * if (UserId != string.Empty && Password != string.Empty)
             * {
             *  userId = EncryptionUtil.Encrypt(UserId);
             *  paswd = EncryptionUtil.Encrypt(Password);
             * }
             * Alachisoft.NCache.Bridging.Configuration.BridgeConfiguration bridgeConfig = _bridgeServer.GetBridgeConfiguration(BridgeId);
             * List<TargetCacheCofiguration> previouslyAddedCaches = bridgeConfig.TargetCacheConfigList;
             * char[] separater = { ',' };
             * foreach (TargetCacheCofiguration pCache in previouslyAddedCaches)
             * {
             *  if (pCache.CacheID.ToLower().Equals(CacheId.ToLower()))
             *  {
             *      //if exists than remove
             *      foreach (string server in pCache.Servers.Split(separater).ToList())
             *      {
             *          NCacheRPCService nNCache = new NCacheRPCService(server);
             *          cacheServer = NCache.GetCacheServer(new TimeSpan(0, 0, 0, 30));
             *          cacheServer.ConfigureBridgeToCache(config, userId, paswd, true);
             *          cacheServer.HotApplyBridgeReplicator(CacheId, false);
             *
             *      }
             *  }
             *
             * }
             * */
        }
Ejemplo n.º 16
0
        /// <summary>
        /// The main entry point for the tool.
        /// </summary>
        public void RemoveBridgeCache()
        {
            try
            {
                _bridgeService = new NCBridgeRPCService(BridgeServer);
                _bridgeServer  = _bridgeService.GetBridgeServer(TimeSpan.FromSeconds(30));

                NCacheRPCService nService = new NCacheRPCService(CacheServer);
                cacheServer = nService.GetCacheServer(new TimeSpan(0, 0, 0, 30));

                if (!ValidateParameters())
                {
                    return;
                }

                //**********************************
                config = cacheServer.GetCacheConfiguration(CacheName);
                if (config == null)
                {
                    OutputProvider.WriteErrorLine("Error : The cache'{0}' does not exist on server {1}:{2} .", CacheName, NCache.ServerName, NCache.Port);
                    return;
                }
                {
                    //OutputProvider.WriteErrorLine("Error : The Bidge {0} is running on {1} , please stop Bridge and try again .", BridgeId, NCache.ServerName);
                    //return;
                }
                if (config.CacheType.ToLower().Equals("local-cache"))
                {
                    OutputProvider.WriteLine("Local Cache cannot be added as a bridge cache");
                    return;
                }
                //cacheServer = GetCacheServers(config.Cluster.GetAllConfiguredNodes());

                if (_bridgeServer != null)
                {
                    try
                    {
                        OutputProvider.WriteLine("Removing Cache To Bridge '{0}' on {1}:{2}.", BridgeId, _bridgeService.ServerName, _bridgeService.Port);
                        Alachisoft.NCache.Bridging.Configuration.BridgeConfiguration bridgeConfig = _bridgeServer.GetBridgeConfiguration(BridgeId);

                        ToolsUtil.VerifyBridgeConfigurations(bridgeConfig, BridgeId);
                        if (bridgeConfig == null)
                        {
                            OutputProvider.WriteErrorLine("No Bridge with Bridge ID '{0} exists' on Server {1}:{2}.", BridgeId, _bridgeService.ServerName, _bridgeService.Port);
                            return;
                        }

                        TargetCacheCofiguration targtCacheConfig = new TargetCacheCofiguration();
                        targtCacheConfig.CacheID     = CacheName;
                        targtCacheConfig.Servers     = cacheServer.GetHostName();
                        targtCacheConfig.IsConnected = true;
                        {
                            if (!VerifyBridgeMasterCache(BridgeId, false, bridgeConfig))
                            {
                                targtCacheConfig.IsMaster = true;
                            }
                            targtCacheConfig.Status = BridgeCacheStateParam.Active.ToString();
                        }

                        List <TargetCacheCofiguration> previouslyAddedCaches = bridgeConfig.TargetCacheConfigList;
                        int removedCacheIndex = -1;
                        if (previouslyAddedCaches.Count >= 1)
                        {
                            int iteration = 0;
                            //checking validations regarding bridge
                            foreach (TargetCacheCofiguration pCache in previouslyAddedCaches)
                            {
                                //if exists than remove
                                if (pCache.CacheID.ToLower().Equals(CacheName.ToLower()))
                                {
                                    if (pCache.CacheAlias.ToLower().Equals(Alias.ToLower()) || string.IsNullOrEmpty(Alias))
                                    {
                                        removedCacheIndex = iteration;
                                        if (pCache.IsMaster)
                                        {
                                            OutputProvider.WriteErrorLine("Failed to Remove Cache to bridge '{0}'. Error: Master cache cannot be removed ", BridgeId);
                                            return;
                                        }
                                    }
                                }
                                if (pCache.Status.Equals("passive"))
                                {
                                    OutputProvider.WriteErrorLine("Failed to Remove Cache to bridge '{0}'. Error: No both bridge caches can be passive ", BridgeId);
                                    return;
                                }
                                iteration++;
                            }
                        }
                        else
                        {
                            OutputProvider.WriteErrorLine("Failed to Remove Cache There is currently no Cache Added in Bridge {0} ", BridgeId);
                            return;
                        }
                        //
                        if (removedCacheIndex >= 0)
                        {
                            bridgeConfig.TargetCacheConfigList.RemoveAt(removedCacheIndex);
                        }
                        else
                        {
                            OutputProvider.WriteErrorLine("Bridge Cache Does not exists with name{0} in Bridge '{1}'", CacheName, BridgeId);
                            return;
                        }
                        //Adding Bridge to config.ncconf

                        BridgeConfig bridgeConf = config.Bridge;

                        config.Bridge = null;

                        byte[] userId = null;
                        byte[] paswd  = null;
                        if (UserId != string.Empty && Password != string.Empty)
                        {
                            userId = EncryptionUtil.Encrypt(UserId);
                            paswd  = EncryptionUtil.Encrypt(Password);
                        }

                        //writing to config.ncconf
                        config.ConfigVersion++;
                        cacheServer.ConfigureBridgeToCache(config, userId, paswd, true);
                        cacheServer.HotApplyBridgeReplicator(CacheName, false);

                        ConveyToRegisteredNodes();


                        char[] separater = { ',' };
                        // write in all bridge nodes bridge.nconnf file
                        bool write = false;
                        foreach (string bridgeIp in bridgeConfig.BridgeNodes.Split(separater).ToList())
                        {
                            try{
                                _bridgeService = new NCBridgeRPCService(bridgeIp);
                                _bridgeServer  = _bridgeService.GetBridgeServer(TimeSpan.FromSeconds(30));


                                _bridgeServer.RegisterBridge(bridgeConfig, true, true);
                                write = true;
                                OutputProvider.WriteLine("Removed Bridge Cache {0} From Bridge {1}", CacheName, BridgeId);
                            }
                            catch (Exception e)
                            {
                                OutputProvider.WriteErrorLine("Removing Bridge Cache {0} From Bridge Server{1} Gives Error: {2}", bridgeConf, bridgeIp, e.Message);
                            }
                        }
                    }
                    catch (SecurityException e)
                    {
                        OutputProvider.WriteErrorLine("Failed to Remove Cache to bridge '{0}'. Error: {1} ", BridgeId, e.Message);
                    }
                    catch (Exception e)
                    {
                        OutputProvider.WriteErrorLine("Failed to Remove Cache to bridge '{0}'. Error: {1} ", BridgeId, e.Message);
                    }
                }
            }
            catch (Exception e)
            {
                OutputProvider.WriteErrorLine("Error: {0}", e.Message);
            }
            finally
            {
                if (_bridgeService != null)
                {
                    _bridgeService.Dispose();
                }
                if (NCache != null)
                {
                    NCache.Dispose();
                }
            }
        }
Ejemplo n.º 17
0
 public void AddIncluded(string filename) => _included.Add(CacheName.Normalize(filename));
Ejemplo n.º 18
0
        internal void Parse(string domain)
        {
            if (!string.IsNullOrEmpty(СтрокаЗапрос))
            {
                if (СтрокаЗапрос.Contains("<Запрос>"))
                {
                    var xml = new XmlDocument();
                    xml.LoadXml(ParseSql(СтрокаЗапрос, domain));
                    var xmlNode = xml.SelectSingleNode("//Sql");
                    if (xmlNode != null)
                    {
                        Sql = xmlNode.InnerText;
                    }
                }
                else if (СтрокаЗапрос.StartsWith("http://") || СтрокаЗапрос.StartsWith("https://"))
                {
                    //загрузка xml
                }
                else if (СтрокаЗапрос.StartsWith("["))
                {
                    #region parse
                    var matchs = Regex.Matches(СтрокаЗапрос.Trim("[]".ToArray()), @"(?<FUNCTION>([\w]+?))=(?<PARAM>([^;]+))[;]?", RegexOptions.Singleline | RegexOptions.Compiled);
                    foreach (Match item in matchs)
                    {
                        switch (item.Groups["FUNCTION"].Value.Trim())
                        {
                        case "Типы":
                        {
                            var _Типы = item.Groups["PARAM"].Value;
                            //удалить первые скобочки
                            if (_Типы.StartsWith(@"(") && _Типы.EndsWith(")"))
                            {
                                _Типы = _Типы.Substring(1, _Типы.Length - 2);
                            }

                            Типы.AddRange(_Типы.Split(',').Select(p => p.Trim()));
                        }
                        break;

                        case "ВыводимыеКолонки":
                        case "Колонки":
                        {
                            var _ВыводимыеКолонки = item.Groups["PARAM"].Value;
                            //удалить первые скобочки
                            if (_ВыводимыеКолонки.StartsWith(@"(") && _ВыводимыеКолонки.EndsWith(")"))
                            {
                                _ВыводимыеКолонки = _ВыводимыеКолонки.Substring(1, _ВыводимыеКолонки.Length - 2);
                            }

                            foreach (var i in _ВыводимыеКолонки.Split(','))
                            {
                                var match     = Regex.Match(i, @"\(?(?<FUNCTION>(\w+))?\((?<PARAM>(.+))\)|(?<PARAM>(.+))\)?");
                                var _FUNCTION = match.Groups["FUNCTION"].Value.Trim();
                                var aggr      = string.IsNullOrEmpty(_FUNCTION)
                                                   ? ФункцияАгрегации.None
                                                   : (ФункцияАгрегации)Enum.Parse(typeof(ФункцияАгрегации), _FUNCTION, true);

                                ВыводимыеКолонки.Add(new Колонка()
                                    {
                                        Атрибут = match.Groups["PARAM"].Value.Trim(),
                                        Функция = aggr
                                    });
                            }
                        }
                        break;

                        case "МестаПоиска":
                        case "Места":
                        {
                            foreach (Match i in Regex.Matches(item.Groups["PARAM"].Value, @"\((?<Attr1>(.+?))\,(?<Attr2>(.+?))\)"))
                            {
                                try
                                {
                                    МестаПоиска.Add(new Query.МестоПоиска()
                                        {
                                            id_node             = Convert.ToDecimal(i.Groups["Attr1"].Value),
                                            МаксимальнаяГлубина = Convert.ToInt32(i.Groups["Attr2"].Value)
                                        });
                                }
                                catch
                                {
                                    МестаПоиска.Add(new Query.МестоПоиска()
                                        {
                                            id_node             = i.Groups["Attr1"].Value,
                                            МаксимальнаяГлубина = Convert.ToInt32(i.Groups["Attr2"].Value)
                                        });
                                }
                            }
                        }
                        break;

                        case "УсловияПоиска":
                        case "Условия":
                        {
                            foreach (Match i in Regex.Matches(item.Groups["PARAM"].Value, @"\((?<Attr1>(.+?))\,(\""(?<Attr2>(.+?))\""|'(?<Attr2>(.+?))'|(?<Attr2>(.+?)))\,(?<Attr3>(.+?))\)"))
                            {
                                var cond = new Query.УсловиеПоиска()
                                {
                                    Атрибут  = i.Groups["Attr1"].Value,
                                    Значение = i.Groups["Attr2"].Value,
                                    Оператор = (Query.Оператор)Enum.Parse(typeof(Query.Оператор), i.Groups["Attr3"].Value)
                                };

                                if (cond.Атрибут != null && cond.Атрибут.EndsWith("%"))
                                {
                                    cond.УчитыватьВремя = true;
                                    cond.Атрибут        = cond.Атрибут.Substring(0, cond.Атрибут.Length - 1);
                                }

                                УсловияПоиска.Add(cond);
                            }
                        }
                        break;

                        case "Сортировки":
                        {
                            foreach (Match i in Regex.Matches(item.Groups["PARAM"].Value, @"\((?<Attr1>(.+?))\,(?<Attr2>(.+?))\)"))
                            {
                                Сортировки.Add(new Query.Сортировка()
                                    {
                                        Атрибут     = i.Groups["Attr1"].Value,
                                        Направление = (Query.НаправлениеСортировки)Enum.Parse(typeof(Query.НаправлениеСортировки), i.Groups["Attr2"].Value)
                                    });
                            }
                        }
                        break;

                        case "КоличествоВыводимыхДанных":
                        case "Количество":
                        {
                            КоличествоВыводимыхДанных = Convert.ToInt32(item.Groups["PARAM"].Value);
                        }
                        break;

                        case "КоличествоВыводимыхСтраниц":
                        case "КоличествоСтраниц":
                        case "Страниц":
                        {
                            КоличествоВыводимыхСтраниц = Convert.ToInt32(item.Groups["PARAM"].Value);
                        }
                        break;

                        case "Группировки":
                        {
                            Группировки.AddRange(item.Groups["PARAM"].Value.Trim("()".ToCharArray()).Split(','));
                        }
                        break;

                        case "Объединения":
                        {
                            foreach (Match i in Regex.Matches(item.Groups["PARAM"].Value, @"\((?<Attr1>(.+?))\,(?<Attr2>(.+?))\)"))
                            {
                                Объединения.Add(new Query.Объединение()
                                    {
                                        Атрибут     = i.Groups["Attr1"].Value,
                                        МестоПоиска = new МестоПоиска()
                                        {
                                            id_node = i.Groups["Attr2"].Value, МаксимальнаяГлубина = 0
                                        }
                                    });
                            }
                        }
                        break;

                        case "ВКорзине":
                        {
                            ВКорзине = item.Groups["PARAM"].Value == "1";
                        }
                        break;

                        case "CacheName":
                        {
                            CacheName = item.Groups["PARAM"].Value;
                        }
                        break;

                        case "Файл":
                        {
                            Файл = item.Groups["PARAM"].Value;
                        }
                        break;


                        case "Атрибут":
                        {
                            Атрибут = item.Groups["PARAM"].Value;
                        }
                        break;

                        case "ФорматДат":
                        {
                            ФорматДат = (ФорматДаты)Enum.Parse(typeof(ФорматДаты), item.Groups["PARAM"].Value);
                        }
                        break;

                        default:
                            throw new Exception(string.Format("Не известный параметр {0}", item.Groups["FUNCTION"].Value));
                        }
                    }
                    #endregion
                }
                else
                {
                    Sql = СтрокаЗапрос;
                }
            }

            //проверить все ли параметры в запросе есть
            if (УсловияПоиска != null)
            {
                foreach (var item in УсловияПоиска.Where(p => !p.ИгрнорироватьПараметр))
                {
                    if (Convert.ToString(item.Значение).StartsWith("@"))
                    {
                        var param = Параметры.SingleOrDefault(p => p.Имя == (string)item.Значение);
                        if (param == null)
                        {
                            throw new Exception(string.Format("Параметр '{0}' не задан.", item.Значение));
                        }
                    }
                }

                //проверить если ли условия поиска по всем атрибутам
                var itemFull = УсловияПоиска.FirstOrDefault(p => p.Атрибут.Equals("*"));
                if (itemFull != null && !(itemFull.Значение == null ||
                                          itemFull.Значение.Equals(string.Empty) ||
                                          itemFull.Значение.Equals("%%") || itemFull.Значение.Equals("%")))
                {
                    IsПоискПоСодержимому = true;

                    //проверить если указано как параметр
                    if (Convert.ToString(itemFull.Значение).StartsWith("@") &&
                        Параметры != null &&
                        Параметры.FirstOrDefault(p => p.Имя.Equals(itemFull.Значение) &&
                                                 string.IsNullOrEmpty(p.Значение as string)
                                                 ) != null)
                    {
                        IsПоискПоСодержимому = false;
                    }
                }
            }
            if (МестаПоиска != null)
            {
                foreach (var item in МестаПоиска)
                {
                    if (Convert.ToString(item.id_node).StartsWith("@"))
                    {
                        var param = Параметры.SingleOrDefault(p => p.Имя == (string)item.id_node);
                        if (param == null)
                        {
                            throw new Exception(string.Format("Параметр '{0}' не задан.", item.id_node));
                        }
                    }
                }
            }
            if (!string.IsNullOrEmpty(CacheName) && CacheName.Length >= 2 && CacheName.First() == '{' && CacheName.Last() == '}')
            {
                CacheReadOnly = true;
                CacheName     = CacheName.Substring(1, CacheName.Length - 2);
            }

            #region Подставить параметры, если они есть
            if (Параметры != null && Параметры.Count > 0)
            {
                foreach (var item in УсловияПоиска.Where(p => !p.ИгрнорироватьПараметр &&
                                                         p.Значение is string && ((string)p.Значение).StartsWith("@")))
                {
                    item.Значение = Параметры.SingleOrDefault(p => p.Имя == (string)item.Значение).Значение;
                }
            }
            #endregion
        }
Ejemplo n.º 19
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CacheKey"/> class.
 /// </summary>
 /// <param name="cacheName">
 /// The cache name.
 /// </param>
 /// <param name="key">
 /// The cache key.
 /// </param>
 public CacheKey(CacheName cacheName, string key)
     : this(cacheName, key, CultureInfo.CurrentCulture.Name)
 {
 }
        public void Flush(CacheName cache)
        {
            if (this.Enabled)
            {
                IDictionaryEnumerator enumerator = this.cache.GetEnumerator();

                while (enumerator.MoveNext())
                {
                    CacheKey enumeratorKey = (CacheKey) enumerator.Key.ToString();

                    if (enumeratorKey != null && enumeratorKey.CacheName == cache)
                    {
                        this.cache.Remove(enumeratorKey);
                    }
                }
            }
        }
Ejemplo n.º 21
0
 _helper = new CacheHelper(CacheName, cpf, factory, formatter, serializer, manager, options, DefaultTtl);
Ejemplo n.º 22
0
    private void ChangeInfoPage()
    {
        Master.Title = "兑换礼品";

        #region 判断登陆状态
        int meid = new BCW.User.Users().GetUsId();
        if (meid == 0)
        {
            Utils.Login();
        }
        #endregion

        #region 兑换类型判断
        int p = int.Parse(Utils.GetRequest("p", "all", 2, @"^[1-9]\d*$", "兑换类型错误"));
        if (p > 18)
        {
            Utils.Error("兑换类型错误", "");
        }

        if (p == 8)
        {
            Utils.Error("兑换类型错误", "");
        }
        builder.Append(Out.Tab("<div class=\"text\">", ""));
        builder.Append("您的物品总量:" + new BCW.BLL.Game.GiftFlows().GetTotal(meid) + "/剩余:" + new BCW.BLL.Game.GiftFlows().GetTotall(meid) + "个");
        builder.Append("<a href=\"" + Utils.getUrl("flows.aspx?act=me") + "\">&gt;&gt;详细</a>");
        builder.Append(Out.Tab("</div>", "<br />"));
        builder.Append(Out.Tab("<div class=\"title\">", ""));
        #endregion

        #region 判断数量
        bool Isbl = true;
        if (p == 1 || p == 2 || p == 3)
        {
            int num = 0;
            if (p == 1)
            {
                builder.Append("您选择兑换:3个x33种共99个物品=8000" + ub.Get("SiteBz") + "");
                num = 3;
            }
            else if (p == 2)
            {
                builder.Append("您选择兑换:2个x33种共66个物品=3000" + ub.Get("SiteBz") + "");
                num = 2;
            }
            else
            {
                builder.Append("您选择兑换:1个x33种共33个物品=300" + ub.Get("SiteBz") + "");
                num = 1;
            }
            //判断是否有33个不同物品
            for (int i = 1; i <= 33; i++)
            {
                if (!new BCW.BLL.Game.GiftFlows().Exists(i, meid, num))
                {
                    Isbl = false;
                    break;
                }
            }
        }
        else if (p == 4)
        {
            builder.Append("您选择兑换:不同物品32个物品=300" + ub.Get("SiteBz") + "");
            if (new BCW.BLL.Game.GiftFlows().GetTypesTotal(meid) < 32)
            {
                Isbl = false;
            }
        }
        else if (p == 5)
        {
            builder.Append("您选择兑换:不同物品30个物品=200" + ub.Get("SiteBz") + "");
            if (new BCW.BLL.Game.GiftFlows().GetTypesTotal(meid) < 30)
            {
                Isbl = false;
            }
        }
        else if (p == 6)
        {
            builder.Append("您选择兑换:不同物品25个物品=200" + ub.Get("SiteBz") + "");
            if (new BCW.BLL.Game.GiftFlows().GetTypesTotal(meid) < 25)
            {
                Isbl = false;
            }
        }
        else if (p == 7)
        {
            builder.Append("您选择兑换:不同物品20个物品=80" + ub.Get("SiteBz") + "");
            if (new BCW.BLL.Game.GiftFlows().GetTypesTotal(meid) < 20)
            {
                Isbl = false;
            }
        }
        else if (p == 8)
        {
            builder.Append("您选择兑换:不同物品15个物品=商城礼物1个");
            if (new BCW.BLL.Game.GiftFlows().GetTypesTotal(meid) < 15)
            {
                Isbl = false;
            }
        }
        else if (p == 9)
        {
            builder.Append("您选择兑换:不同物品10个物品=1000" + ub.Get("SiteBz2") + "");
            if (new BCW.BLL.Game.GiftFlows().GetTypesTotal(meid) < 10)
            {
                Isbl = false;
            }
        }
        else if (p == 10)
        {
            builder.Append("您选择兑换:物品总数5000个=8000" + ub.Get("SiteBz") + "");
            if (new BCW.BLL.Game.GiftFlows().GetTotall(meid) < 5000)
            {
                Isbl = false;
            }
        }
        else if (p == 11)
        {
            builder.Append("您选择兑换:物品总数3000个=5000" + ub.Get("SiteBz") + "");
            if (new BCW.BLL.Game.GiftFlows().GetTotall(meid) < 3000)
            {
                Isbl = false;
            }
        }
        else if (p == 12)
        {
            builder.Append("您选择兑换:物品总数2000个=二个月VIP");
            if (new BCW.BLL.Game.GiftFlows().GetTotall(meid) < 2000)
            {
                Isbl = false;
            }
        }
        else if (p == 13)
        {
            builder.Append("您选择兑换:物品总数1500个=一个月VIP");
            if (new BCW.BLL.Game.GiftFlows().GetTotall(meid) < 1500)
            {
                Isbl = false;
            }
        }
        else if (p == 14)
        {
            builder.Append("您选择兑换:物品总数1200个=1500" + ub.Get("SiteBz") + "");
            if (new BCW.BLL.Game.GiftFlows().GetTotall(meid) < 1200)
            {
                Isbl = false;
            }
        }
        else if (p == 15)
        {
            builder.Append("您选择兑换:物品总数1000个=1200" + ub.Get("SiteBz") + "");
            if (new BCW.BLL.Game.GiftFlows().GetTotall(meid) < 1000)
            {
                Isbl = false;
            }
        }
        else if (p == 16)
        {
            builder.Append("您选择兑换:物品总数800个=300" + ub.Get("SiteBz") + "");
            if (new BCW.BLL.Game.GiftFlows().GetTotall(meid) < 800)
            {
                Isbl = false;
            }
        }
        else if (p == 17)
        {
            builder.Append("您选择兑换:物品总数500个=2000" + ub.Get("SiteBz2") + "");
            if (new BCW.BLL.Game.GiftFlows().GetTotall(meid) < 500)
            {
                Isbl = false;
            }
        }
        else if (p == 18)
        {
            builder.Append("您选择兑换:物品总数300个=1000" + ub.Get("SiteBz2") + "");
            if (new BCW.BLL.Game.GiftFlows().GetTotall(meid) < 300)
            {
                Isbl = false;
            }
        }
        #endregion

        builder.Append(Out.Tab("</div>", Out.Hr()));
        string info = Utils.GetRequest("info", "all", 1, "", "");
        if (info != "ok")
        {
            #region 确认兑换
            if (!Isbl)
            {
                builder.Append(Out.Tab("<div class=\"text\">", ""));
                builder.Append("很遗憾,您的物品量还没有达到兑换所需的条件");
                builder.Append(Out.Tab("</div>", ""));
            }
            else
            {
                builder.Append(Out.Tab("<div class=\"text\">", ""));
                builder.Append("恭喜,您的物品量已达到兑换所需的条件");
                builder.Append(Out.Tab("</div>", ""));
                //if (p == 1 || p == 2 || p == 10 | p == 11)
                //{
                //    string strText = "填写充值到的手机号:/,再次输入手机号;/,,,";
                //    string strName = "Notes,Notes2,p,act,info";
                //    string strType = "text,text,hidden,hidden,hidden";
                //    string strValu = "''" + p + "'changeinfo'ok";
                //    string strEmpt = "false,false,false,false,false";
                //    string strIdea = "/";
                //    string strOthe = "申请兑换,flows.aspx,post,1,red";
                //    builder.Append(Out.wapform(strText, strName, strType, strValu, strEmpt, strIdea, strOthe));
                //}
                //else
                //{
                builder.Append(Out.Tab("", "<br />"));
                string strName = "p,act,info";
                string strValu = "" + p + "'changeinfo'ok";
                string strOthe = "确认兑换,flows.aspx,post,0,red";
                builder.Append(Out.wapform(strName, strValu, strOthe));
                //}
            }
            #endregion
        }
        else
        {
            #region 兑换过程
            if (!Isbl)
            {
                Utils.Error("很遗憾,您的物品量还没有达到兑换所需的条件", "");
            }

            #region 变量
            string mename = new BCW.BLL.User().GetUsName(meid);
            string Notes  = string.Empty;
            int    State  = 1;
            //if (p == 1 || p == 2 || p == 10 || p == 11)
            //{
            //    Notes = Utils.GetRequest("Notes", "post", 2, @"^(?:13|14|15|18)\d{9}$", "请正确输入手机号");
            //    string Notes2 = Utils.GetRequest("Notes2", "post", 2, @"^(?:13|14|15|18)\d{9}$", "请正确输入手机号");
            //    if (Notes != Notes2)
            //    {
            //        Utils.Error("您的手机号输入不一致,请重新输入", "");
            //    }
            //    State = 0;
            //}
            #endregion

            #region 前三种兑换 33个物品一起减去相应数量
            if (p == 1 || p == 2 || p == 3)
            {
                int num = 0;
                if (p == 1)
                {
                    num = 3;
                }
                else if (p == 2)
                {
                    num = 2;
                }
                else
                {
                    num = 1;
                }

                //33个物品一起减去相应数量
                for (int i = 1; i <= 33; i++)
                {
                    new BCW.BLL.Game.GiftFlows().UpdateTotall(i, meid, -num);
                }
                if (p == 1)
                {
                    ///30000酷币改8000
                    new BCW.BLL.User().UpdateiGold(meid, mename, 8000, "兑换物品获得");
                }
                if (p == 2)
                {
                    ///20000酷币改3000
                    new BCW.BLL.User().UpdateiGold(meid, mename, 3000, "兑换物品获得");
                }
                if (p == 3)
                {
                    ///800酷币改300
                    new BCW.BLL.User().UpdateiGold(meid, mename, 300, "兑换物品获得");
                }
            }
            #endregion

            #region 4-9种兑换处理
            else if (p >= 4 && p <= 9)
            {
                int num = 0;
                if (p == 4)
                {
                    ///800酷币改300
                    new BCW.BLL.User().UpdateiGold(meid, mename, 300, "兑换物品获得");
                    num = 32;
                }
                else if (p == 5)
                {
                    ///600酷币改200
                    new BCW.BLL.User().UpdateiGold(meid, mename, 200, "兑换物品获得");
                    num = 30;
                }
                else if (p == 6)
                {
                    ///500酷币改200
                    new BCW.BLL.User().UpdateiGold(meid, mename, 200, "兑换物品获得");
                    num = 25;
                }
                else if (p == 7)
                {
                    ///100酷币改80
                    new BCW.BLL.User().UpdateiGold(meid, mename, 80, "兑换物品获得");
                    num = 20;
                }
                else if (p == 8)
                {
                    //商城礼品一个
                    num = 15;
                }
                else
                {
                    //1000爆谷
                    new BCW.BLL.User().UpdateiMoney(meid, mename, 1000, "兑换物品获得");
                    num = 10;
                }

                int k = 0;
                for (int i = 1; i <= 33; i++)
                {
                    int rac = new BCW.BLL.Game.GiftFlows().UpdateTotall(i, meid, -1);
                    if (rac > 0)
                    {
                        k++;
                    }

                    if (k == num)
                    {
                        break;
                    }
                }
            }
            #endregion

            #region 10-18兑换处理
            else
            {
                int num = 0;
                if (p == 10)
                {
                    ///50000酷币8000
                    new BCW.BLL.User().UpdateiGold(meid, mename, 8000, "兑换物品获得");
                    num = 5000;
                }
                else if (p == 11)
                {
                    ///30000酷币改5000
                    new BCW.BLL.User().UpdateiGold(meid, mename, 5000, "兑换物品获得");
                    num = 3000;
                }
                else if (p == 12)
                {
                    //VIP二个月
                    num = 2000;
                }
                else if (p == 13)
                {
                    //VIP一个月
                    num = 1500;
                }
                else if (p == 14)
                {
                    ///2000酷币改1500
                    new BCW.BLL.User().UpdateiGold(meid, mename, 1500, "兑换物品获得");
                    num = 1200;
                }
                else if (p == 15)
                {
                    ///1000酷币改1200
                    new BCW.BLL.User().UpdateiGold(meid, mename, 1200, "兑换物品获得");
                    num = 1000;
                }
                else if (p == 16)
                {
                    ///800酷币改300
                    new BCW.BLL.User().UpdateiGold(meid, mename, 300, "兑换物品获得");
                    num = 800;
                }
                else if (p == 17)
                {
                    ///10000爆谷改2000
                    new BCW.BLL.User().UpdateiMoney(meid, mename, 2000, "兑换物品获得");
                    num = 500;
                }
                else
                {
                    ///6000爆谷改1000
                    new BCW.BLL.User().UpdateiMoney(meid, mename, 1000, "兑换物品获得");
                    num = 300;
                }

                if (p == 12 || p == 13)//兑换VIP
                {
                    BCW.Model.User vipmodel = new BCW.BLL.User().GetVipData(meid);
                    int            Grow     = 0;
                    int            Day      = 0;
                    if (p == 12)
                    {
                        Grow = 8;
                        Day  = 60;
                    }
                    else
                    {
                        Grow = 8;
                        Day  = 30;
                    }
                    if (vipmodel.VipDate != null && vipmodel.VipDate > DateTime.Now)
                    {
                        new BCW.BLL.User().UpdateVipData(meid, Grow, vipmodel.VipDate.AddDays(Day));
                    }
                    else
                    {
                        new BCW.BLL.User().UpdateVipData(meid, Grow, DateTime.Now.AddDays(Day));
                    }

                    //清缓存
                    string CacheKey = CacheName.App_UserVip(meid);
                    DataCache.RemoveByPattern(CacheKey);
                }

                DataSet ds = BCW.Data.SqlHelper.Query("SELECT ID, Totall FROM tb_GiftFlows Where UsID=" + meid + " and Totall>0 ORDER by ID ASC");
                if (ds != null && ds.Tables[0].Rows.Count > 0)
                {
                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        int ID       = int.Parse(ds.Tables[0].Rows[i]["ID"].ToString());
                        int getTotal = int.Parse(ds.Tables[0].Rows[i]["Totall"].ToString());

                        if (getTotal <= num)
                        {
                            new BCW.BLL.Game.GiftFlows().UpdateTotall(ID, -getTotal);
                        }
                        else
                        {
                            new BCW.BLL.Game.GiftFlows().UpdateTotall(ID, -num);
                        }
                        num = num - getTotal;

                        if (num <= 0)
                        {
                            break;
                        }
                    }
                }
            }
            #endregion

            #region 写入兑换记录
            //写入兑换记录
            BCW.Model.Game.GiftChange model = new BCW.Model.Game.GiftChange();
            model.UsID    = meid;
            model.UsName  = mename;
            model.Types   = p;
            model.State   = State;
            model.Notes   = Notes;
            model.AddTime = DateTime.Now;
            new BCW.BLL.Game.GiftChange().Add(model);

            //if (p == 1 || p == 2 || p == 10 || p == 11)
            //{
            //    //通知客服10086

            //    new BCW.BLL.Guest().Add(10086, "客服", "[url=/bbs/uinfo.aspx?uid=" + meid + "]" + mename + "(" + meid + ")[/url]兑换了周年拾物活动-话费卡,请在后台进行处理");

            //    Utils.Success("兑换礼品", "恭喜,兑换成功,礼品属于话费卡,请留意系统给您的完成充值的内线通知<br /><a href=\"" + Utils.getUrl("flows.aspx?act=change") + "\">&gt;&gt;继续兑换礼品</a>", Utils.getUrl("flows.aspx"), "3");
            //}
            //else
            //{
            Utils.Success("兑换礼品", "恭喜,兑换成功!<br /><a href=\"" + Utils.getUrl("flows.aspx?act=change") + "\">&gt;&gt;继续兑换礼品</a>", Utils.getUrl("flows.aspx"), "3");
            //}
            #endregion

            #endregion
        }
        builder.Append(Out.Tab("<div class=\"text\">", Out.Hr()));
        builder.Append("<a href=\"" + Utils.getUrl("flows.aspx?act=change") + "\">&gt;&gt;重新选择兑换</a>");
        builder.Append(Out.Tab("</div>", ""));
        builder.Append(Out.Tab("<div class=\"title\">", "<br />"));
        builder.Append("<a href=\"" + Utils.getUrl("/default.aspx") + "\">首页</a>-");
        builder.Append("<a href=\"" + Utils.getUrl("flows.aspx") + "\">上级</a>-");
        builder.Append("<a href=\"" + Utils.getUrl("/bbs/uinfo.aspx") + "\">空间</a>");
        builder.Append(Out.Tab("</div>", ""));
    }
Ejemplo n.º 23
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CacheKey"/> class.
 /// </summary>
 /// <param name="cacheName">
 /// The cache name.
 /// </param>
 /// <param name="key">
 /// The cache key.
 /// </param>
 public CacheKey(CacheName cacheName, string key)
     : this(cacheName, key, CultureInfo.CurrentCulture.Name)
 {
 }