Example #1
0
 /// <summary>
 /// 接收来自该用户的消息
 /// </summary>
 /// <param name="msg"></param>
 public void ReceiveMsg(WXMsg msg)
 {
     _recvedMsg.Add(msg.Time, msg);
     if (MsgRecved != null)
     {
         MsgRecved(msg);
     }
 }
Example #2
0
        public void Send()
        {
            string     conn = ConfigurationManager.AppSettings["conn"].ToString();
            DataHelper data = new DataHelper(conn);
            //处理数据
            List <OriginMsg> orginList = new List <OriginMsg>();

            orginList = data.GetList <OriginMsg>(" issucc='0' ", "");

            foreach (OriginMsg msg in orginList)
            {
                Order  order  = OrderManager.Instance.ToOrder(msg.Content);
                NowMsg nowMsg = new NowMsg();
                nowMsg.MsgId        = msg.MsgId.ToString();
                nowMsg.MsgFromId    = msg.FromUin;
                nowMsg.MsgFromName  = msg.FromNickName;
                nowMsg.ReciveId     = msg.ToUserName; //接受人均为群
                nowMsg.ReciveName   = msg.ToUserName;
                nowMsg.MsgContent   = "";             //未赋值
                nowMsg.OrderContect = msg.Content;
                nowMsg.CommandOne   = order.CommandOne;
                nowMsg.CommandTwo   = order.CommandTwo;
                nowMsg.Score        = order.Score;
                nowMsg.CommandType  = order.CommandType.ToString();
                nowMsg.CreateDate   = msg.CreateTime;
                nowMsg.OpDate       = DateTime.Now.ToString();
                nowMsg.IsSucc       = 0;
                nowMsg.IsDelete     = "0";
                nowMsg.IsMsg        = order.CommandType.ToString();
                nowMsg.IsDeal       = "0";
                nowMsg.Period       = frmMainForm.Perioid;

                data.Insert <NowMsg>(nowMsg, "");
                data.ExecuteSql(string.Format("update OriginMsg set IsSucc = '1' where MsgId = '{0}'", msg.MsgId));
            }


            //处理指令,(下注指令要回复,错误指令要回复)
            List <NowMsg> nowMsgList = data.GetList <NowMsg>(" CommandType not in ('上下查') and isdelete='0' ", "");

            foreach (NowMsg msg in nowMsgList)
            {
                //1,处理指令
                WXMsg model = Msg2WxMsg.Instance.GetMsg(msg);

                //2,判断是否发送消息(如果返回的消息不为空)
                //成功提示,错误格式提示,余额不足提示,投注限制提示,封盘提示,
                if (model != null)
                {
                    //frmMainForm.CurrentWX.SendMsg(model, false);
                }
            }
        }
Example #3
0
        /// <summary>
        /// 向该用户发送消息
        /// </summary>
        /// <param name="msg"></param>
        public void SendMsg(WXMsg msg, bool showOnly)
        {
            //发送
            if (!showOnly)
            {
                WXService wxs = new WXService();
                wxs.SendMsg(msg.Msg, msg.From, msg.To, msg.Type);
            }

            _sentMsg.Add(msg.Time, msg);
            if (MsgSent != null)
            {
                MsgSent(msg);
            }
        }
Example #4
0
        /// <summary>
        /// 获取最近的一条消息
        /// </summary>
        /// <returns></returns>
        public WXMsg GetLatestMsg()
        {
            WXMsg msg = null;

            if (_sentMsg.Count > 0 && _recvedMsg.Count > 0)
            {
                msg = _sentMsg.Last().Value.Time > _recvedMsg.Last().Value.Time ? _sentMsg.Last().Value : _recvedMsg.Last().Value;
            }
            else if (_sentMsg.Count > 0)
            {
                msg = _sentMsg.Last().Value;
            }
            else if (_recvedMsg.Count > 0)
            {
                msg = _recvedMsg.Last().Value;
            }
            else
            {
                msg = null;
            }
            return(msg);
        }
Example #5
0
        private void NewMethod()
        {
            string     conn = ConfigurationManager.AppSettings["conn"].ToString();
            DataHelper data = new DataHelper(conn);
            //处理数据
            List <OriginMsg> orginList = new List <OriginMsg>();

            orginList = data.GetList <OriginMsg>(" issucc='0' ", "");

            foreach (OriginMsg msg in orginList)
            {
                Order order = new Order();
                try
                {
                    order = OrderManager.Instance.ToOrder(msg.Content);
                }
                catch (Exception ex)
                {
                    //删除msg
                    data.ExecuteSql(string.Format("delete from originmsg where msgid='{0}'", msg.MsgId));
                    continue;
                }
                NowMsg nowMsg = new NowMsg();
                nowMsg.MsgId        = msg.MsgId.ToString();
                nowMsg.MsgFromId    = msg.FromUin;
                nowMsg.MsgFromName  = msg.FromNickName;
                nowMsg.ReciveId     = msg.ToUserName; //接受人均为群
                nowMsg.ReciveName   = msg.ToUserName;
                nowMsg.MsgContent   = "";             //未赋值
                nowMsg.OrderContect = msg.Content;
                nowMsg.CommandOne   = order.CommandOne;
                nowMsg.CommandTwo   = order.CommandTwo;
                nowMsg.Score        = order.Score;
                nowMsg.CommandType  = order.CommandType.ToString();
                nowMsg.CreateDate   = msg.CreateTime;
                nowMsg.OpDate       = DateTime.Now.ToString();
                nowMsg.IsSucc       = 0;
                nowMsg.IsDelete     = "0";
                nowMsg.IsMsg        = order.CommandType.ToString();
                nowMsg.IsDeal       = "0";
                nowMsg.Period       = frmMainForm.Perioid;

                //先查消息id是否重复,如果重复,则跳过不处理
                List <KeyValuePair <string, object> > pkList = new List <KeyValuePair <string, object> >();
                pkList.Add(new KeyValuePair <string, object>("MsgId", msg.MsgId));
                NowMsg exitNowMsg = data.First <NowMsg>(pkList, "");
                if (exitNowMsg == null)
                {
                    if (nowMsg.CommandType == "上下查")
                    {
                        data.Insert <NowMsg>(nowMsg, "");
                    }
                    else if (!string.IsNullOrWhiteSpace(nowMsg.Period))
                    {
                        data.Insert <NowMsg>(nowMsg, "");
                    }
                }
                else
                {
                    Log.WriteLogByDate("NowMsg消息重复:msgID=" + msg.MsgId);
                }
                data.ExecuteSql(string.Format("update OriginMsg set IsSucc = '1' where MsgId = '{0}'", msg.MsgId));
            }


            //处理指令,(下注指令要回复,错误指令要回复)
            List <NowMsg> nowMsgList = data.GetList <NowMsg>(" isdelete='0' ", "");

            foreach (NowMsg msg in nowMsgList)
            {
                //1,处理指令
                WXMsg model = null;

                try
                {
                    model = Msg2WxMsg.Instance.GetMsg(msg);
                }
                catch (Exception ex)
                {
                    data.ExecuteSql(string.Format("delete from nowmsg where msgid='{0}'", msg.MsgId));
                    continue;
                }

                //2,判断是否发送消息(如果返回的消息不为空)
                //成功提示,错误格式提示,余额不足提示,投注限制提示,封盘提示,
                if (model != null)
                {
                    frmMainForm.CurrentWX.SendMsg(model, false);
                }
            }
        }
Example #6
0
        public void NewMethod()
        {
            JObject sync_result = frmMainForm.wxs.WxSync();//进行同步

            if (sync_result == null)
            {
                return;
            }
            string     conn = ConfigurationManager.AppSettings["conn"].ToString();
            DataHelper data = new DataHelper(conn);
            //保存微信群联系人
            //1,获取群信息
            //只有人员有变动,才会有值,才能获取到uin
            JToken contactList    = sync_result["ModContactList"];
            string qUserName      = "";
            string qNickName      = "";
            string qChatRoomOwner = "";

            if (contactList != null)
            {
                foreach (JObject qun in contactList)
                {
                    if (qun["UserName"].ToString() != frmMainForm.CurrentQun)
                    {
                        continue;
                    }
                    qUserName      = qun["UserName"].ToString();
                    qNickName      = qun["NickName"].ToString().ClearHtml();
                    qChatRoomOwner = qun["ChatRoomOwner"].ToString();

                    JToken memberList = qun["MemberList"];
                    foreach (JObject member in memberList)
                    {
                        string uin       = member["Uin"].ToString();
                        string userName  = member["UserName"].ToString();
                        string nickName  = member["NickName"].ToString().ClearHtml();
                        string pyQuanPin = member["PYQuanPin"].ToString();
                        string remark    = member["RemarkPYQuanPin"].ToString();

                        List <KeyValuePair <string, object> > pkList = new List <KeyValuePair <string, object> >();
                        pkList.Add(new KeyValuePair <string, object>("Uin", uin));
                        Contact modelOrgin = data.First <Contact>(pkList, "");
                        if (modelOrgin == null)
                        {
                            Contact model = new Contact();
                            model.Uuid      = Guid.NewGuid().ToString();
                            model.NickName  = nickName;
                            model.Uin       = uin;
                            model.UserName  = userName;
                            model.QuanPin   = pyQuanPin;
                            model.QuserName = qUserName;
                            model.QnickName = qNickName;
                            model.Remark    = remark;
                            data.Insert <Contact>(model, "");
                        }
                        else
                        {
                            modelOrgin.NickName  = nickName;
                            modelOrgin.UserName  = userName;
                            modelOrgin.QuanPin   = pyQuanPin;
                            modelOrgin.QuserName = qUserName;
                            modelOrgin.QnickName = qNickName;
                            modelOrgin.Remark    = remark;
                            data.Update <Contact>(modelOrgin, pkList, "");
                        }

                        //根据userName更新nickName
                        List <KeyValuePair <string, object> > pkList2 = new List <KeyValuePair <string, object> >();
                        pkList2.Add(new KeyValuePair <string, object>("UserName", userName));
                        Contact modelOrgin2 = data.First <Contact>(pkList2, "");
                        if (modelOrgin2 != null)
                        {
                            modelOrgin2.NickName = nickName;
                            data.Update <Contact>(modelOrgin2, pkList2, "");
                        }
                    }
                }
            }

            //获取群里所有联系人,无uuin,根据昵称来更新userName和uin
            string qun1 = frmMainForm.wxs.GetQun(frmMainForm.CurrentQun);

            //Log.WriteLogByDate("群成员列表json:"+qun1);

            if (!string.IsNullOrEmpty(qun1))
            {
                JObject qunObj = JsonConvert.DeserializeObject(qun1) as JObject;

                if (qunObj["MemberList"] != null)
                {
                    foreach (JObject member in qunObj["MemberList"])
                    {
                        List <KeyValuePair <string, object> > pkList2 = new List <KeyValuePair <string, object> >();
                        pkList2.Add(new KeyValuePair <string, object>("NickName", member["NickName"].ToString().ClearHtml()));
                        Contact modelOne = data.First <Contact>(pkList2, "");
                        if (modelOne != null)
                        {
                            modelOne.UserName = member["UserName"].ToString();
                            List <KeyValuePair <string, object> > pkList3 = new List <KeyValuePair <string, object> >();
                            pkList3.Add(new KeyValuePair <string, object>("Uin", modelOne.Uin));
                            data.Update <Contact>(modelOne, pkList3, "");
                        }
                    }
                }
            }

            Log.WriteLogByDate("开始更新本地昵称:qunObj[\"ContactList\"][0][\"MemberList\"]");
            if (!string.IsNullOrEmpty(qun1))//更新本地昵称
            {
                JObject qunObj = JsonConvert.DeserializeObject(qun1) as JObject;

                //if (qunObj["MemberList"] != null)
                //{
                //    foreach (JObject member in qunObj["MemberList"])
                //    {
                //        List<KeyValuePair<string, object>> pkList2 = new List<KeyValuePair<string, object>>();
                //        pkList2.Add(new KeyValuePair<string, object>("UserName", member["UserName"].ToString()));
                //        Contact modelOne = data.First<Contact>(pkList2, "");
                //        if (modelOne != null)
                //        {
                //            modelOne.NickName = member["NickName"].ToString().ClearHtml();
                //            List<KeyValuePair<string, object>> pkList3 = new List<KeyValuePair<string, object>>();
                //            pkList3.Add(new KeyValuePair<string, object>("UserName", modelOne.UserName));
                //            data.Update<Contact>(modelOne, pkList3, "");
                //        }
                //    }
                //}
                if (qunObj["ContactList"][0]["MemberList"] != null)
                {
                    foreach (JObject member in qunObj["ContactList"][0]["MemberList"])
                    {
                        List <KeyValuePair <string, object> > pkList2 = new List <KeyValuePair <string, object> >();
                        pkList2.Add(new KeyValuePair <string, object>("UserName", member["UserName"].ToString()));
                        Contact modelOne = data.First <Contact>(pkList2, "");
                        if (modelOne != null)
                        {
                            modelOne.NickName = member["NickName"].ToString().ClearHtml();
                            List <KeyValuePair <string, object> > pkList3 = new List <KeyValuePair <string, object> >();
                            pkList3.Add(new KeyValuePair <string, object>("UUID", modelOne.Uuid));
                            data.Update <Contact>(modelOne, pkList3, "");

                            //更新contactScore的昵称
                            List <KeyValuePair <string, object> > pkList4 = new List <KeyValuePair <string, object> >();
                            pkList4.Add(new KeyValuePair <string, object>("UIN", modelOne.Uin));
                            ContactScore score = data.First <ContactScore>(pkList4, "");
                            //score.NickName = modelOne.NickName;
                            //List<KeyValuePair<string, object>> pkList5 = new List<KeyValuePair<string, object>>();
                            //pkList5.Add(new KeyValuePair<string, object>("UUID", score.Uuid));
                            //data.Update<ContactScore>(score, pkList5, "");
                            if (score != null)
                            {
                                data.ExecuteSql(string.Format("update contactScore set nickname='{0}' where uuid='{1}'", modelOne.NickName, score.Uuid));
                            }
                        }
                    }
                }
            }

            Log.WriteLogByDate("开始保存消息");
            //获取到消息
            if (sync_result["AddMsgCount"] != null && sync_result["AddMsgCount"].ToString() != "0")
            {
                // Log.WriteLogByDate("获取消息:");

                foreach (JObject m in sync_result["AddMsgList"])
                {
                    if (m["FromUserName"].ToString() != frmMainForm.CurrentQun)
                    {
                        continue;
                    }

                    string[] content = m["Content"].ToString().Split(new string[] { "<br/>" }, StringSplitOptions.RemoveEmptyEntries);
                    if (content != null && content.Length == 2)
                    {
                        //Log.WriteLogByDate("获取消息:"+ content[1]);

                        OriginMsg msg = new OriginMsg();
                        msg.MsgId = m["MsgId"].ToString() + m["CreateTime"].ToString();//用msgId和createTime
                        string userName = content[0].Replace(":", "");
                        msg.FromUserName = userName;
                        msg.ToUserName   = m["ToUserName"].ToString();
                        msg.MsgType      = m["MsgType"].ToString();
                        msg.Content      = content[1];
                        msg.Status       = m["Status"].ToString();
                        msg.ImgStatus    = m["ImgStatus"].ToString();
                        msg.CreateTime   = m["CreateTime"].ToString();
                        msg.NewMsgId     = m["NewMsgId"].ToString();
                        msg.IsSucc       = "0";
                        List <KeyValuePair <string, object> > pkList3 = new List <KeyValuePair <string, object> >();
                        pkList3.Add(new KeyValuePair <string, object>("UserName", userName));
                        Contact model3 = data.First <Contact>(pkList3, "");
                        if (model3 != null)
                        {
                            msg.FromNickName = model3.NickName;
                            msg.FromUin      = model3.Uin;
                            msg.QnickName    = qNickName;
                            //插入消息前检查
                            List <KeyValuePair <string, object> > pkList4 = new List <KeyValuePair <string, object> >();
                            pkList4.Add(new KeyValuePair <string, object>("MsgId", msg.MsgId));

                            OriginMsg orginMsg2 = data.First <OriginMsg>(pkList4, "");
                            if (orginMsg2 == null)
                            {
                                if (msg.FromUin != "0")
                                {
                                    //简单检查指令
                                    if (OrderFirstCheck.Instance.CheckOne(msg.Content))
                                    {
                                        data.Insert <OriginMsg>(msg, "");
                                    }
                                    else
                                    {
                                        //检查是否封盘
                                        //获取开奖信息,并将开奖信息保存到数据库

                                        if (frmMainForm.IsComplete && frmMainForm.IsJieDan)
                                        {
                                            //简单检查指令是否存在关键字,
                                            foreach (string item in OrderKey)
                                            {
                                                if (msg.Content.Contains(item))
                                                {
                                                    data.Insert <OriginMsg>(msg, "");
                                                    break;
                                                }
                                            }
                                        }
                                        else
                                        {
                                            //封盘阶段
                                            WXMsg model = new WXMsg()
                                            {
                                                To = frmMainForm.CurrentQun, From = frmMainForm.CurrentWX.UserName, Msg = "正在封盘"
                                            };
                                            frmMainForm.CurrentWX.SendMsg(model, false);
                                            continue;
                                        }
                                    }
                                }
                            }
                            else
                            {
                                Log.WriteLogByDate("OriginMsg消息重复:msgID=" + msg.MsgId);
                            }
                        }
                        else
                        {
                            Log.WriteLogByDate("无法获取到uin,读取到的消息不保存");
                        }
                    }
                }
            }
        }
Example #7
0
        public WXMsg GetMsg(NowMsg msg)
        {
            string     conn = ConfigurationManager.AppSettings["conn"].ToString();
            DataHelper data = new DataHelper(conn);

            WXMsg model = null;

            //处理消息
            if (msg == null)
            {
                return(model);
            }

            if (msg.MsgFromId == null)
            {
                return(model);
            }

            model = new WXMsg();

            List <KeyValuePair <string, object> > pkList = new List <KeyValuePair <string, object> >();

            pkList.Add(new KeyValuePair <string, object>("Uin", msg.MsgFromId));
            ContactScore contactScore = data.First <ContactScore>(pkList, "");

            if (contactScore == null)
            {
                contactScore            = new ContactScore();
                contactScore.Uuid       = Guid.NewGuid().ToString();
                contactScore.SyScore    = 0;
                contactScore.TotalScore = 0;
                contactScore.RunScore   = 0;
                contactScore.Uin        = msg.MsgFromId;
                contactScore.NickName   = msg.MsgFromName;
                data.Insert <ContactScore>(contactScore, "");
            }

            if (String.IsNullOrEmpty(frmMainForm.CurrentQun))
            {
                model.To = "@";
            }
            else
            {
                model.To = frmMainForm.CurrentQun;
            }
            if (frmMainForm.CurrentWX == null)
            {
                Log.WriteLogByDate("当前微信未登陆");
                model.From = "@";
            }
            else
            {
                model.From = frmMainForm.CurrentWX.UserName;
            }
            model.Type = 1;
            model.Time = DateTime.Now;
            StringBuilder content = new StringBuilder();

            switch (msg.CommandType)
            {
            case "上下查":
                if (msg.CommandOne.Contains("查"))
                {
                    List <KeyValuePair <string, object> > pkContact = new List <KeyValuePair <string, object> >();
                    pkContact.Add(new KeyValuePair <string, object>("Uin", msg.MsgFromId));
                    ContactScore contactScore2 = data.First <ContactScore>(pkList, "");
                    if (contactScore != null)
                    {
                        content.Append("@" + msg.MsgFromName + " ");
                        content.Append(" 当前积分:" + contactScore2.TotalScore);
                    }
                }
                else
                {
                    model = null;
                    return(model);
                }


                break;

            case "买名次":
                content.Append("@" + msg.MsgFromName + " ");
                content.Append(" 下注成功");
                Dictionary <string, string> dic = new Dictionary <string, string>();
                dic.Add("0", "十名");
                dic.Add("1", "冠军");
                dic.Add("2", "亚军");
                dic.Add("3", "季军");
                dic.Add("4", "四名");
                dic.Add("5", "五名");
                dic.Add("6", "六名");
                dic.Add("7", "七名");
                dic.Add("8", "八名");
                dic.Add("9", "九名");

                int userScore = 0;
                if (msg.CommandOne.ExitHanZi())
                {
                    foreach (Char item in msg.CommandTwo)
                    {
                        content.AppendFormat("\r\n冠军[{0}]{1} ", item, msg.Score);
                        userScore++;
                    }
                }
                else
                {
                    foreach (Char item in msg.CommandOne)
                    {
                        foreach (Char item2 in msg.CommandTwo)
                        {
                            content.AppendFormat("\r\n{0}[{1}]{2}", dic[item.ToString()], item2, msg.Score);
                            userScore++;
                        }
                    }
                }

                //计算剩余积分
                if ((contactScore.TotalScore - userScore * msg.Score.ToInt()) < 0)
                {
                    content.Clear();
                    content.Append("@" + msg.MsgFromName + " ");
                    content.Append("积分不足");
                    content.Append("\r\n当前积分:" + contactScore.TotalScore);

                    //删除指令
                    data.ExecuteSql(string.Format(" delete from nowmsg where MsgId='{0}'", msg.MsgId));
                }
                else
                {
                    contactScore.TotalScore = contactScore.TotalScore - userScore * msg.Score.ToInt();
                    contactScore.RunScore   = contactScore.RunScore + userScore * msg.Score.ToInt();
                    List <KeyValuePair <string, object> > pkList3 = new List <KeyValuePair <string, object> >();
                    pkList3.Add(new KeyValuePair <string, object>("Uuid", contactScore.Uuid));
                    data.Update <ContactScore>(contactScore, pkList3, "");
                    content.Append("\r\n当前积分:" + contactScore.TotalScore);
                }

                break;

            case "名次大小单双龙虎":
                content.Append("@" + msg.MsgFromName + " ");
                content.Append(" 下注成功");
                Dictionary <string, string> dicMC = new Dictionary <string, string>();
                dicMC.Add("0", "十名");
                dicMC.Add("1", "冠军");
                dicMC.Add("2", "亚军");
                dicMC.Add("3", "季军");
                dicMC.Add("4", "四名");
                dicMC.Add("5", "五名");
                dicMC.Add("6", "六名");
                dicMC.Add("7", "七名");
                dicMC.Add("8", "八名");
                dicMC.Add("9", "九名");
                int n2 = 0;
                foreach (char item in msg.CommandOne)
                {
                    if (dicMC.ContainsKey(item.ToString()))
                    {
                        content.AppendFormat("\r\n{0} {1} {2}", dicMC[item.ToString()], msg.CommandTwo, msg.Score);
                        n2++;
                    }
                }
                if ((contactScore.TotalScore - n2 * msg.Score.ToInt()) < 0)
                {
                    content.Clear();
                    content.Append("@" + msg.MsgFromName + " ");
                    content.Append("积分不足");
                    content.Append("\r\n当前积分:" + contactScore.TotalScore);
                    //删除指令
                    data.ExecuteSql(string.Format(" delete from nowmsg where MsgId='{0}'", msg.MsgId));
                }
                else
                {
                    contactScore.TotalScore = contactScore.TotalScore - n2 * msg.Score.ToInt();
                    contactScore.RunScore   = contactScore.RunScore + n2 * msg.Score.ToInt();
                    List <KeyValuePair <string, object> > pkList3 = new List <KeyValuePair <string, object> >();
                    pkList3.Add(new KeyValuePair <string, object>("Uuid", contactScore.Uuid));
                    data.Update <ContactScore>(contactScore, pkList3, "");
                    content.Append("\r\n当前积分:" + contactScore.TotalScore);
                }


                break;

            case "冠亚和":
                content.Append("@" + msg.MsgFromName + " ");
                if (string.IsNullOrEmpty(msg.CommandTwo))
                {
                    content.Append("指令格式错误");
                    data.ExecuteSql(string.Format(" delete from nowmsg where MsgId='{0}'", msg.MsgId));
                    break;
                }

                int n = 0;

                string comTwo = msg.CommandTwo.Replace("/", "");
                if (comTwo.Length <= 2 && Convert.ToInt32(comTwo) <= 19)
                {
                    switch (comTwo)
                    {
                    case "3":
                    case "4":
                    case "5":
                    case "6":
                    case "7":
                    case "8":
                    case "9":
                    case "10":
                    case "11":
                    case "12":
                    case "13":
                    case "14":
                    case "15":
                    case "16":
                    case "17":
                    case "18":
                    case "19":
                        n++;
                        break;
                    }
                }
                else
                {
                    //多条和指令
                    while (comTwo.Length > 0 && comTwo != "0" && comTwo != "1" && comTwo != "2")

                    {
                        char first = comTwo.First();

                        if (first.ToString().ToInt() >= 3 && first.ToString().ToInt() <= 9)
                        {
                            switch (first.ToString())
                            {
                            case "3":
                            case "4":
                            case "5":
                            case "6":
                            case "7":
                            case "8":
                            case "9":
                                n++;
                                break;
                            }

                            comTwo = string.Join("", comTwo.Reverse());
                            comTwo = comTwo.Remove(comTwo.Length - 1, 1);
                            comTwo = string.Join("", comTwo.Reverse());
                        }
                        else
                        {
                            if (comTwo.Length >= 2)
                            {
                                string str = comTwo.Substring(0, 2);

                                switch (str)
                                {
                                case "10":
                                case "11":
                                case "12":
                                case "13":
                                case "14":
                                case "15":
                                case "16":
                                case "17":
                                case "18":
                                case "19":
                                    n++;
                                    break;
                                }

                                comTwo = string.Join("", comTwo.Reverse());
                                comTwo = comTwo.Remove(comTwo.Length - 2, 2);
                                comTwo = string.Join("", comTwo.Reverse());
                            }
                        }
                    }
                }
                content.Append(" 下注成功");
                string[] commandTwos = msg.CommandTwo.Split(new string[] { "/" }, StringSplitOptions.RemoveEmptyEntries);
                foreach (string item in commandTwos)
                {
                    content.Append("\r\n" + msg.CommandOne + " " + item + " " + msg.Score);
                }

                if ((contactScore.TotalScore - n * msg.Score.ToInt()) < 0)
                {
                    content.Clear();
                    content.Append(msg.MsgFromName + " ");
                    content.Append("积分不足");
                    content.Append("\r\n当前积分:" + contactScore.TotalScore);

                    //删除指令
                    data.ExecuteSql(string.Format(" delete from nowmsg where MsgId='{0}'", msg.MsgId));
                }
                else
                {
                    contactScore.TotalScore = contactScore.TotalScore - n * msg.Score.ToInt();
                    contactScore.RunScore   = contactScore.RunScore + n * msg.Score.ToInt();
                    List <KeyValuePair <string, object> > pkList3 = new List <KeyValuePair <string, object> >();
                    pkList3.Add(new KeyValuePair <string, object>("Uuid", contactScore.Uuid));
                    data.Update <ContactScore>(contactScore, pkList3, "");
                    content.Append("\r\n当前积分:" + contactScore.TotalScore);
                }
                break;

            case "和大":
            case "和小":
            case "和单":
            case "和双":

                if ((contactScore.TotalScore - msg.Score.ToInt()) < 0)
                {
                    content.Clear();
                    content.Append("@" + msg.MsgFromName + " ");
                    content.Append("积分不足");
                    //删除指令
                    data.ExecuteSql(string.Format(" delete from nowmsg where MsgId='{0}'", msg.MsgId));
                }
                else
                {
                    content.Append("@" + msg.MsgFromName + " " + "下注成功");
                    content.Append("\r\n" + msg.CommandType + " " + msg.Score);
                    contactScore.TotalScore = contactScore.TotalScore - msg.Score.ToInt();
                    contactScore.RunScore   = contactScore.RunScore + msg.Score.ToInt();
                }
                List <KeyValuePair <string, object> > pkList5 = new List <KeyValuePair <string, object> >();
                pkList5.Add(new KeyValuePair <string, object>("Uuid", contactScore.Uuid));
                data.Update <ContactScore>(contactScore, pkList5, "");
                content.Append("\r\n当前积分:" + contactScore.TotalScore);
                break;

            case "取消":
            case "取消指令":
                content.Append("@" + msg.MsgFromName + " " + "取消下注成功");
                data.ExecuteSql("delete from Nowmsg  where msgfromid=" + msg.MsgFromId + " and period=" + msg.Period);
                data.ExecuteSql(string.Format("update contactscore set totalscore=totalscore+runscore where uin={0}", msg.MsgFromId));
                data.ExecuteSql(string.Format("update contactscore set runscore=0 where uin={0}", msg.MsgFromId));
                break;

            case "指令格式错误":
                content.Append("@" + msg.MsgFromName + " " + "指令格式错误");
                //删除指令
                data.ExecuteSql(string.Format(" delete from nowmsg where MsgId='{0}'", msg.MsgId));
                break;

            case "下注积分范围错误":
                content.Append("@" + msg.MsgFromName + " " + "下注积分范围错误");
                //删除指令
                data.ExecuteSql(string.Format(" delete from nowmsg where MsgId='{0}'", msg.MsgId));
                break;

            default:
                content.Append("@" + msg.MsgFromName + " " + "暂不支持此指令");
                //删除指令
                data.ExecuteSql(string.Format(" delete from nowmsg where MsgId='{0}'", msg.MsgId));
                break;
            }

            msg.IsDeal   = "1";
            msg.IsDelete = "1";
            msg.IsSucc   = 1;
            List <KeyValuePair <string, object> > pkList4 = new List <KeyValuePair <string, object> >();

            pkList4.Add(new KeyValuePair <string, object>("MsgId", msg.MsgId));
            data.Update <NowMsg>(msg, pkList4, "");

            model.Msg = content.ToString();

            return(model);
        }