Exemplo n.º 1
0
        /// <summary>
        /// 判断一个抽奖列表中分组信息是否正确、返回0 为正确反之不正确
        /// </summary>
        /// <param name="ListText">列表信息文本</param>
        /// <param name="MoShi">0:魔盒/1:袖珍罐/2:礼包/3:抽奖机</param>
        /// <param name="FenZu">魔盒:4/袖珍罐:3/礼包:3|5/抽奖机:4</param>
        /// <returns></returns>
        public int YesNoGeShi(string ListText, int MoShi, int FenZu)
        {
            int       Info  = 0;
            Regex_new regex = new Regex_new();

            switch (MoShi)
            {
            case 0:
                regex.创建(ListText, "\t", 0);
                Info = regex.取匹配数量() % FenZu;
                break;

            case 1:
                regex.创建(ListText.Substring(ListText.IndexOf("\t", ListText.IndexOf("\t") + 1) + 1), "\t", 0);
                Info = regex.取匹配数量() % FenZu;
                break;

            case 2:
                regex.创建(ListText.Substring(ListText.IndexOf("\t") + 1), "\t", 0);
                Info = regex.取匹配数量() % FenZu;
                break;

            case 3:
                regex.创建(ListText, "\t", 0);
                Info = regex.取匹配数量() % FenZu;
                break;
            }

            return(Info);
        }
Exemplo n.º 2
0
        //设置QQ群号码后会进入此处并且会验证群号码以及QQ号
        private void WebBrowser1_ProgressChanged(object sender, WebBrowserProgressChangedEventArgs e)
        {
            if (webBrowser1 != null)
            {
                if (webBrowser1.Url != null)
                {
                    if (webBrowser1.Url.ToString().StartsWith("http://qun.qzone.qq.com"))
                    {
                        webBrowser1.Visible = false;
                        HtmlElement groupList = webBrowser1.Document.GetElementById("my_group_list_container");
                        if (groupList == null)
                        {
                            return;
                        }
                        webBrowser1.ProgressChanged -= WebBrowser1_ProgressChanged;
                        string groupListText = webBrowser1.DocumentText;//获取所有的网站文本

                        Regex_new regex = new Regex_new();
                        regex.创建(groupListText, @" uin:(\d+)';", 1);
                        if (regex.取匹配数量() > 0)
                        {
                            string groupid = "759213683";                          //得到群号
                            string QqId    = regex.取子匹配文本(1, 1);                   //得到QQ
                            Form1.MysqlYz.qq  = QqId;
                            Form1.MysqlYz.md5 = new Verification().GetMD5String(); //获取机器码
                            //验证QQ群号码以及QQ号码
                            if (groupListText.Contains($"data-groupid=\"{ groupid}\"><"))
                            {
                                if (Form1.MysqlYz.ChaXun())//数据库中查询成功
                                {
                                    Form1.MysqlYz.ChaR();
                                    MessageBox.Show("尊敬的大佬,请尽情使用强大的功能吧~", "验证成功", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                                    Form1.MysqlYz.Yse(); //恢复窗体正常
                                    Close();             //关闭子窗口
                                }
                                else
                                {
                                    new Verification().End();
                                    Close();
                                }
                            }
                            else
                            {
                                CuoWu();
                            }
                        }
                        else
                        {
                            CuoWu();
                        }
                    }
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 获取外网IP地址
        /// </summary>
        /// <returns></returns>
        public string GetIP()
        {
            string tempip = "";

            try
            {
                WebRequest   wr    = WebRequest.Create("http://ip.tool.chinaz.com/");
                Stream       s     = wr.GetResponse().GetResponseStream();
                StreamReader sr    = new StreamReader(s, Encoding.UTF8);
                Regex_new    regex = new Regex_new();
                regex.创建(sr.ReadToEnd(), ">您的IP<.+\r\n.+\">(.+)</dd>\r\n.+\r\n.+<dd>([^<]*)<", 1);
                tempip = regex.取子匹配文本(1, 1) + " " + regex.取子匹配文本(1, 2);
                sr.Close();
                s.Close();
            }
            catch
            {
            }
            return(tempip);
        }
Exemplo n.º 4
0
        public Dictionary <int, MoHe> StartMoHe(string LstNameText, string RandomListText, int ChouQuTimeS)
        {
            //if(YesNoGeShi(RandomListText,4) != 0)
            //{
            //    MessageBox.Show("抱歉您所需要模拟抽奖的数据错误;错误内容为:\r\n" +
            //        "抽奖的信息分组不正确,请仔细检查对应的分组信息。\r\n" +
            //        "正确信息应该为:\r\n" +
            //        "第一个数为抽取次数\r\n" +
            //        "第二、三、四个数为物品代码、给予数量、是否公告\r\n" +
            //        "往后都是四个数为一组", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            //    return RandomInfo;
            //}

            //if(YesNoGaiLv(RandomListText,0,1000000)==false)
            //{
            //    MessageBox.Show("抱歉您所需要模拟抽奖的总概率错误;错误内容为:\r\n" +
            //           "抽取的总概率不能超过100W,请更正后再试。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            //    return RandomInfo;
            //}

            Regex_new regex = new Regex_new();
            Dictionary <int, MoHe> RandomInfo = new Dictionary <int, MoHe>();
            Random random = new Random();

            int ZhongGaiLv = ZongGaiLv(RandomListText, 0, 4);
            int YuanChiShu = ChouQuCiShu(RandomListText);

            MoHeAddInfo(RandomListText, RandomInfo, LstNameInfo(LstNameText));

            for (int q = 0; q < ChouQuTimeS; q++)
            {
                for (int w = 0; w < YuanChiShu; w++)
                {
                    int SuiJiShu = random.Next(1000000);
                    if (SuiJiShu > ZhongGaiLv)
                    {
                        RandomInfo[0].GoodsCount++;
                    }
                    else
                    {
                        bool YesNoChouZhong = false;

                        for (int i = 0; i < RandomInfo.Count; i++)
                        {
                            int LinShiZongShu = 0;
                            for (int a = i; a < RandomInfo.Count; a++)
                            {
                                LinShiZongShu += RandomInfo[a].GoodsProbability;
                            }

                            int LinShiSuiJiShu = random.Next(LinShiZongShu);

                            //if (LinShiSuiJiShu + RandomInfo[i].GoodsProbability > LinShiZongShu)
                            //{
                            //    RandomInfo[i].GoodsCount++;
                            //    YesNoChouZhong = true;
                            //    break;
                            //}

                            if (LinShiSuiJiShu <= RandomInfo[i].GoodsProbability)
                            {
                                RandomInfo[i].GoodsCount++;
                                YesNoChouZhong = true;
                                break;
                            }
                        }


                        if (YesNoChouZhong == false)
                        {
                            RandomInfo[0].GoodsCount++;
                        }
                    }
                }
            }

            return(RandomInfo);
        }
Exemplo n.º 5
0
        /// <summary>
        /// 把抽奖信息汇总到字典中
        /// </summary>
        /// <param name="ListText">待汇总的抽奖信息</param>
        /// <param name="RandomInfo">加入的字典</param>
        public void MoHeAddInfo(string ListText, Dictionary <int, MoHe> RandomInfo, List <List <string> > LstNameInfo)
        {
            Regex_new regex = new Regex_new();

            string AwName = "";
            int    AwId;
            int    AwSl;
            int    AwGg;


            ListText = ListText.Substring(ListText.IndexOf("\t") + 1);
            AwId     = Convert.ToInt32(ListText.Remove(ListText.IndexOf("\t")));
            ListText = ListText.Substring(ListText.IndexOf("\t") + 1);
            AwSl     = Convert.ToInt32(ListText.Remove(ListText.IndexOf("\t")));
            ListText = ListText.Substring(ListText.IndexOf("\t") + 1);
            AwGg     = Convert.ToInt32(ListText.Remove(ListText.IndexOf("\t")));
            ListText = ListText.Substring(ListText.IndexOf("\t") + 1);

            int Pos = LstNameInfo[0].IndexOf(AwId.ToString());

            if (Pos != -1)
            {
                AwName = LstNameInfo[1][Pos];
            }

            int AddCount = 0;

            RandomInfo.Add(AddCount, new MoHe(
                               AwName,
                               AwId,
                               0,
                               AwSl,
                               AwGg,
                               0
                               ));
            AddCount++;


            regex.创建(ListText, "([\x20-\x7f]+)\t([\x20-\x7f]+)\t([\x20-\x7f]+)\t([\x20-\x7f]+)\t", 0);
            foreach (Match item in regex.正则返回集合())
            {
                string Id   = item.Groups[1].Value;
                string Name = "";

                int Poss = LstNameInfo[0].IndexOf(Id);
                if (Poss != -1)
                {
                    Name = LstNameInfo[1][Poss];
                }

                RandomInfo.Add(AddCount, new MoHe(
                                   Name,
                                   Convert.ToInt32(Id),
                                   Convert.ToInt32(item.Groups[2].Value),
                                   Convert.ToInt32(item.Groups[3].Value),
                                   Convert.ToInt32(item.Groups[4].Value),
                                   0
                                   ));
                AddCount++;
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// 获得抽奖列表内的总概率
        /// </summary>
        /// <param name="ListText">待获取概率的文本</param>
        /// <param name="MoShi">0:魔盒/1:袖珍罐/2:礼包/3:抽奖机</param>
        /// <param name="FenZu">魔盒:4/袖珍罐:3/礼包:3|5/抽奖机:4</param>
        /// <returns>总概率</returns>
        public int ZongGaiLv(string ListText, int MoShi, int FenZu)
        {
            int       Count = 0;
            Regex_new regex = new Regex_new();

            switch (MoShi)
            {
            case 0:
                regex.创建(ListText.Substring(
                             ListText.IndexOf("\t",
                                              ListText.IndexOf("\t",
                                                               ListText.IndexOf("\t",
                                                                                ListText.IndexOf("\t") + 1) + 1) + 1) + 1), "[\x20-\x7f]+\t([\x20-\x7f]+)\t[\x20-\x7f]+\t[\x20-\x7f]+\t", 0);
                foreach (Match item in regex.正则返回集合())
                {
                    Count += Convert.ToInt32(item.Groups[1].Value);
                }

                break;

            case 1:
                regex.创建(ListText.Substring(
                             ListText.IndexOf("\t",
                                              ListText.IndexOf("\t") + 1) + 1), "[\x20-\x7f]+\t([\x20-\x7f]+)\t[\x20-\x7f]+\t", 0);
                foreach (Match item in regex.正则返回集合())
                {
                    Count += Convert.ToInt32(item.Groups[1].Value);
                }

                break;

            case 2:
                switch (FenZu)
                {
                case 3:
                    regex.创建(ListText.Substring(ListText.IndexOf("\t") + 1), "[\x20-\x7f]+\t([\x20-\x7f]+)\t[\x20-\x7f]+\t", 0);
                    break;

                case 5:
                    regex.创建(ListText.Substring(ListText.IndexOf("\t") + 1), "[\x20-\x7f]+\t([\x20-\x7f]+)\t[\x20-\x7f]+\t[\x20-\x7f]+\t[\x20-\x7f]+\t", 0);
                    break;
                }
                foreach (Match item in regex.正则返回集合())
                {
                    Count += Convert.ToInt32(item.Groups[1].Value);
                }

                break;

            case 3:
                regex.创建(ListText, "[\x20-\x7f]+\t([\x20-\x7f]+)\t[\x20-\x7f]+\t[\x20-\x7f]+\t", 0);
                foreach (Match item in regex.正则返回集合())
                {
                    Count += Convert.ToInt32(item.Groups[1].Value);
                }

                break;
            }

            return(Count);
        }