Example #1
0
        public void saveMsg(wxMessageClass msg)
        {
            /*
             * wxmsgid
             * msgFromUser
             * msgFromNike
             * msgFromMember
             * msgFromMemberNike
             * msgToUser
             * msgToNike
             * msgIsInRoomToMe
             * msgIsProviteToMe
             * orgContent
             * msgTime
             * providerUnionId
             * providerUserName
             * providerNike
             * 1	test	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
             */
            string urlM = "http://www.wolfinv.com/pk10/app/submitWXChatMsg.asp?" +
                          "msgFromUser={0}" +
                          "&msgFromNike={1}" +
                          "&msgFromMember={2}" +
                          "&msgFromMemberNike={3}" +
                          "&msgToUser={4}" +
                          "&msgToNike={5}" +
                          "&msgIsInRoomToMe={6}" +
                          "&msgIsProviteToMe={7}" +
                          "&orgContent={8}" +
                          "&msgTime={9}" +
                          "&providerUnionId={10}" +
                          "&providerUserName={11}" +
                          "&providerNike={12}";
            string url = string.Format(urlM,
                                       msg.FromUserNam,
                                       msg.FromNikeName,
                                       msg.FromMemberUserName,
                                       msg.FromMemberNikeName,
                                       msg.ToUserName,
                                       msg.ToNikeName,
                                       msg.IsAtToMe?1:0,
                                       msg.ToUserName == RobotUserName?1:0,
                                       msg.OrgMsg,
                                       msg.CreateTime,
                                       RobotUnionId,
                                       RobotUserName,
                                       RobotNikeName

                                       );

            try
            {
                WebClient wc = new WebClient();
                wc.Encoding = Encoding.UTF8;
                string res = wc.DownloadString(url);
            }
            catch (Exception ce)
            {
            }
        }
Example #2
0
 public void RefreshMsg(ListView msglist, List <wxMessageClass> msg)
 {
     try
     {
         for (int i = 0; i < msg.Count; i++)
         {
             wxMessageClass wxmsg = msg[i];
             ListViewItem   lvi   = new ListViewItem();
             lvi.Text = wxmsg.CreateTime.ToString();
             string tousers = (wxmsg.AtMemberNikeName == null || wxmsg.AtMemberNikeName.Length == 0) ? "" : string.Join(";", wxmsg.AtMemberNikeName);
             lvi.SubItems.AddRange(new string[] { wxmsg.FromNikeName ?? "", wxmsg.FromMemberNikeName ?? "", (wxmsg.IsAtToMe ? ">>" : "") + tousers, wxmsg.Msg });
             msglist.Items.Add(lvi);
         }
         int cnt = msglist.Items.Count;
         if (cnt == 0)
         {
             return;
         }
         msglist.Items[cnt - 1].EnsureVisible();
     }
     catch (Exception ce)
     {
         MessageBox.Show(string.Format("{0}:{1}", ce.Message, ce.StackTrace));
     }
 }
Example #3
0
        bool ProcessProviteMsg(wxMessageClass wxmsg)
        {
            ResponseAction_Chat   rc  = new ResponseAction_Chat(this, wxmsg);
            ShareLotteryPlanClass opt = null;

            rc.Response(ref opt);
            return(true);
        }
Example #4
0
        void refreshMsg(string sender, object data)
        {
            wxMessageClass a    = data as wxMessageClass;
            List <string>  txts = txt_ToMeMsgs.Lines.ToList();

            txts.Add(string.Format("[{0}] {1} :{2}", a.FromNikeName, a.FromMemberNikeName, a.Msg));
            txt_ToMeMsgs.Lines = txts.ToArray();
        }
        /*Ready,//筹备中
         * Subscribing,//正在认购中
         * Paying,//认购完成,正在缴款中
         * Paied,//缴款完成,等待开奖
         * Opened,//开奖完成,返奖
         * Completed //结束*/


        protected ResponseActionClass(WXMsgProcess wxprs, wxMessageClass msg)
        {
            wxprocess   = wxprs;
            wxmsg       = msg;
            Msg         = pureMsg;
            requestUser = wxmsg.FromMemberUserName;
            requestNike = wxmsg.FromMemberNikeName;
            roomId      = wxmsg.FromUserNam;
            roomName    = wxmsg.FromNikeName;
        }
Example #6
0
        public ResponseAction_ValidateInfo(WXMsgProcess wxprs, wxMessageClass msg) : base(wxprs, msg)
        {
            Regex           regTr     = new Regex(string.Format(@"\d+", pureMsg));
            MatchCollection mcs       = regTr.Matches(pureMsg);
            int             chargeAmt = 0;

            for (int i = 0; i < mcs.Count; i++)
            {
                answers.Add(mcs[i].Value);
            }
        }
Example #7
0
        ////public void GetObjectData(SerializationInfo info, StreamingContext context)
        ////{
        ////    try
        ////    {
        ////        info.AddValue("WXMsgProcess_ProcessName", ProcessName);
        ////        info.AddValue("WXMsgProcess_SendMsg", SendMsg, typeof(Func<string, string, string>));
        ////        info.AddValue("WXMsgProcess_SharePlanChanged", SharePlanChanged, typeof(Action<string, ShareLotteryPlanClass>));
        ////        info.AddValue("WXMsgProcess_MsgChanged", MsgChanged, typeof(Action<string, wxMessageClass>));
        ////        info.AddValue("WXMsgProcess_AllPlan", AllPlan, typeof(ShareLotteryPlanCollection));
        ////    }
        ////    catch(Exception ce)
        ////    {

        ////    }

        ////    //base.GetObjectData(info, context);

        ////    //info.AddValue("WXMsgProcess_Value", Value);
        ////}
        ////protected WXMsgProcess(SerializationInfo info, StreamingContext context)
        ////{
        ////    try
        ////    {
        ////        ProcessName = info.GetString("WXMsgProcess_ProcessName");
        ////        SendMsg = (Func<string, string, string>)info.GetValue("WXMsgProcess_SendMsg", typeof(Func<string, string, string>));
        ////        SharePlanChanged = (Action<string, ShareLotteryPlanClass>)info.GetValue("WXMsgProcess_SharePlanChanged",  typeof(Action<string, ShareLotteryPlanClass>));
        ////        MsgChanged = (Action<string, wxMessageClass>)info.GetValue("WXMsgProcess_MsgChanged", typeof(Action<string, wxMessageClass>));
        ////        AllPlan = (ShareLotteryPlanCollection)info.GetValue("WXMsgProcess_AllPlan", typeof(ShareLotteryPlanCollection));
        ////    }
        ////    catch(Exception ce)
        ////    {

        ////    }
        ////}
        #endregion
        ////public void ReceiveMsg()
        ////{
        ////    RefreshMsg(sender, msgs);
        ////}

        public void RefreshMsg(object sender, List <wxMessageClass> msgs)
        {
            wxMessageClass wxmsg = null;

            try
            {
                for (int i = 0; i < msgs.Count; i++)
                {
                    wxmsg = msgs[i];
                    //if(wxmsg.FromMemberNikeName == null)
                    //{
                    //    continue;
                    //}
                    if (SystemSetting.saveMsg == "1")//如果保存记录
                    {
                        Task.Run(() => {
                            saveMsg(wxmsg);
                        });
                    }
                    if (!wxmsg.IsAtToMe)
                    {
                        if (wxmsg.ToUserName == RobotUserName && SystemSetting.allProviteChat == "1")//个人对我说的话,转入私聊
                        {
                            ProcessProviteMsg(wxmsg);
                        }
                        //if(wxmsg.ToUserName == )
                        continue;
                    }
                    MsgChanged?.Invoke(wxmsg.FromMemberNikeName, wxmsg); //更新消息
                    ShareLotteryPlanClass optPlan = null;
                    if (!ProcessOneMsg(wxmsg, ref optPlan))              //不是群内对我说的话
                    {
                        continue;
                    }
                    if (optPlan != null)
                    {
                        AllPlan.setCurrPlan(optPlan);
                        SharePlanChanged?.Invoke(optPlan.wxRootName, optPlan);
                    }
                }
            }
            catch (Exception ce)
            {
                SendMsg?.Invoke(string.Format("{0}:{1}", ce.Message, ce.StackTrace), wxmsg.FromUserNam);
            }
        }
Example #8
0
        bool ProcessOneMsg(wxMessageClass wxmsg, ref ShareLotteryPlanClass optPlan)
        {
            ActionDefine define     = null;
            ActionType   curraction = checkTheAction(wxmsg, ref define);

            if (waitingAsk != null)
            {
                if (waitingAsk.ContainsKey(wxmsg.FromUserNam) && waitingAsk[wxmsg.FromUserNam].ContainsKey(wxmsg.FromMemberUserName))
                {
                    //如果回复的人就是等待回答清单中的人,首先判断是否是回复,如果不是回复,宣布首先回答我的问题,其他问题无效,等下再问
                    if (curraction != ActionType.ValidateInfo)
                    {
                        TheAskWaitingUserAnswer askObj = waitingAsk[wxmsg.FromUserNam][wxmsg.FromMemberUserName];
                        string msg = string.Format(@"@{0} 请您先回答我刚才提出的问题!在回答之前我不会接受你其他任何请求.
{1}", wxmsg.FromMemberNikeName, askObj.askMsg);
                        SendMsg(msg, wxmsg.FromUserNam);
                        return(false);
                    }
                }
            }


            ResponseActionClass rac = ResponseActionClass.CreateAction(curraction, this, wxmsg);

            rac.actionDefine = define;
            if (rac == null)
            {
                optPlan = null;
                return(false);
            }
            if (curraction == ActionType.Undefined)
            {
                rac.currPlan = null;
            }
            else
            {
                rac.currPlan = AllPlan.getCurrRoomPlan(wxmsg.FromUserNam);
            }
            return(rac.Response(ref optPlan));

            if (curraction == ActionType.Undefined)
            {
                return(false);
            }
        }
Example #9
0
        public ActionType checkTheAction(wxMessageClass wxmsg, ref ActionDefine define)
        {
            define = new ActionDefine();
            string myname = string.Format("@{0}", wxmsg.AtMemberNikeName[0]);
            string msg    = wxmsg.Msg.Replace(myname, "").Trim().Replace(" ", "");

            ////string strtest = @"\[[\s\S]*?]";
            ////Regex regtest = new Regex(strtest);

            ////MatchCollection tmcs = regtest.Matches(msg);

            if (ActionDic == null)
            {
                ActionDic = getActionDictionary();
            }
            Type  t   = typeof(ActionType);
            Array arr = Enum.GetValues(t);

            foreach (int myCode in arr)
            {
                string strName = Enum.GetName(t, myCode);//获取名称
                if (!ActionDic.ContainsKey(strName))
                {
                    continue;
                }
                ActionDefine dic = ActionDic[strName];
                if (dic == null)
                {
                    continue;
                }
                for (int i = 0; i < dic.regConditions.Count; i++)
                {
                    Regex           regTr = new Regex(dic.regConditions[i]);
                    MatchCollection mcs   = regTr.Matches(msg);
                    if (mcs.Count > 0)
                    {
                        return((ActionType)myCode);
                    }
                }
            }
            return(ActionType.Undefined);
        }
 public ResponseAction_ClosePlan(WXMsgProcess wxprs, wxMessageClass msg) : base(wxprs, msg)
 {
     ActionName = "响应结束合买信息";
 }
        //public ResponseAction_Charge()
        //{

        //}
        //DbClass db;

        public ResponseAction_Charge(WXMsgProcess wxprs, wxMessageClass msg) : base(wxprs, msg)
        {
            ActionName = "充值";
            //db = new DbClass(SystemSetting.DbHost, SystemSetting.DbUser, SystemSetting.DbPwd, SystemSetting.DbName);
        }
Example #12
0
 public ResponseAction_Undefined(WXMsgProcess wxprs, wxMessageClass msg) : base(wxprs, msg)
 {
 }
 public ResponseAction_SubcribeShares(WXMsgProcess wxprs, wxMessageClass msg) : base(wxprs, msg)
 {
     ActionName = "响应认购份额";
 }
 public ResponseAction_ShowPlan(WXMsgProcess wxprs, wxMessageClass msg) : base(wxprs, msg)
 {
     ActionName = "响应显示合买信息";
 }
Example #15
0
        public void RefreshMsg(object sender, TEventArgs <List <AddMsg> > e)
        {
            try
            {
                List <AddMsg>                msg      = e.Result;
                string                       dicitems = "FromUserName,FromUserNikeName,FromMemberName,FromMemerNikeName,ToUserName,ToUserNikeName,AtNikeNames,Message,MsgTime";
                string[]                     itemArr  = dicitems.Split(',');
                List <wxMessageClass>        messages = new List <wxMessageClass>();
                Dictionary <string, Contact> AllUsers = contactDict;
                //List<string> msgs = tbox.Lines.ToList();
                //List<ListViewItem> msgs = new List<ListViewItem>();
                for (int i = 0; i < msg.Count; i++)
                {
                    AddMsg wxmsg = msg[i];
                    if (wxmsg.MsgType != MsgType.MM_DATA_TEXT)
                    {
                        continue;
                    }
                    string fromName = wxmsg.FromUserName;
                    string NickName = fromName;
                    if (AllUsers.ContainsKey(fromName))//联系人发来的
                    {
                        ////if(fromName.StartsWith("@@"))
                        ////{
                        ////    client.GetBatchGetContactAsync(string.Join(",",AllUsers[fromName].MemberDict.Keys.ToArray()),fromName);
                        ////}
                        NickName = AllUsers[fromName].NickName;
                        if (AllUsers[fromName].MemberList.Count > 0) //是群
                        {
                            if (!AllUsers[fromName].DisplayNikeName) //所有的群都显示昵称
                            {
                                client.GetBatchGetContactAsync(string.Join(",", AllUsers[fromName].MemberList.Select(a => a.UserName)), fromName);
                                AllUsers[fromName].DisplayNikeName = true;
                            }
                        }
                    }
                    else
                    {
                        client.GetBatchGetContactAsync(fromName);
                        continue;
                    }
                    string ToName     = wxmsg.ToUserName;
                    string ToNameNike = null;
                    if (AllUsers.ContainsKey(ToName))
                    {
                        ToNameNike = AllUsers[ToName].NickName;
                    }

                    //string[] strMsg = new string[5];
                    wxMessageClass wmsg = new wxMessageClass();

                    if (wxmsg.MsgType == MsgType.MM_DATA_IMG)
                    {
                        string strImg = wxmsg.Content;
                    }

                    if (fromName.StartsWith("@@"))
                    {
                        string[] content = wxmsg.Content.Split(new string[] { ":<br/>" }, StringSplitOptions.RemoveEmptyEntries);
                        content[1] = content[1].Replace("<br/>", "\r\n");
                        string memName = "";
                        if (1 == 2 && AllUsers.ContainsKey(content[0]))
                        {
                            memName = AllUsers[content[0]].DisplayName;
                            if (string.IsNullOrEmpty(memName))
                            {
                                memName = AllUsers[content[0]].NickName;
                            }
                        }
                        else
                        {
                            if (AllUsers[fromName].MemberDict.ContainsKey(content[0]))
                            {
                                memName = AllUsers[fromName].MemberDict[content[0]].DisplayName;
                            }
                            if (string.IsNullOrEmpty(memName) && AllUsers.ContainsKey(fromName) && AllUsers[fromName].MemberDict.ContainsKey(content[0]))
                            {
                                memName = AllUsers[fromName].MemberDict[content[0]].NickName;
                            }
                        }

                        //strMsg = string.Format("[{0}]{1}:{2}", NickName, memName, string.Join("",content.Skip(1).ToArray()));
                        //strMsg = new string[] { DateTime.Now.ToShortTimeString(), NickName, memName, "", string.Join("", content.Skip(1).ToArray()) };
                        wmsg.FromUserNam        = fromName;
                        wmsg.FromNikeName       = NickName;
                        wmsg.FromMemberUserName = content[0];
                        wmsg.FromMemberNikeName = memName;
                        wmsg.CreateTime         = wxmsg.CreateTime;
                        wmsg.Msg    = content[1];
                        wmsg.OrgMsg = wxmsg.Content;
                        Regex           regTr  = new Regex(@"@(.*?) ");
                        List <string>   atlist = new List <string>();
                        MatchCollection mcs    = regTr.Matches(wmsg.Msg);
                        for (int mi = 0; mi < mcs.Count; mi++)
                        {
                            atlist.Add(mcs[mi].Value.Trim().Replace("@", ""));
                        }
                        wmsg.AtMemberNikeName = atlist.ToArray();
                        if (wmsg.AtMemberNikeName != null && wmsg.AtMemberNikeName.Length == 1)
                        {
                            var matchnicks = AllUsers[fromName].MemberDict.Where(a => a.Value.DisplayName == wmsg.AtMemberNikeName[0] || a.Value.NickName == wmsg.AtMemberNikeName[0]);
                            foreach (var mem in matchnicks)
                            {
                                if (mem.Value.UserName == client.user.UserName)
                                {
                                    wmsg.IsAtToMe = true;
                                    break;
                                }
                            }
                        }
                    }
                    else
                    {
                        wmsg.FromUserNam        = fromName;
                        wmsg.FromNikeName       = NickName;
                        wmsg.FromMemberUserName = null;
                        wmsg.FromMemberNikeName = null;
                        wmsg.ToUserName         = ToName;
                        wmsg.ToNikeName         = ToNameNike;
                        wmsg.CreateTime         = wxmsg.CreateTime;
                        wmsg.Msg    = wxmsg.Content.Replace("<br/>", "\r\t");
                        wmsg.OrgMsg = wxmsg.Content;
                    }
                    messages.Add(wmsg);
                    //msgs.Add(new ListViewItem(strMsg));
                }
                if (messages.Count > 0)
                {
                    Task.Run(() => {
                        MsgProcessCompleted?.Invoke(this, messages);
                    });
                    Task.Run(() => {
                        InjectBuffs(messages);
                    });
                    //?.Invoke(this, messages);
                    ////if(MsgProcessCompleted_ForExtralInterfaceInvoke!=null)
                    ////{
                    ////    MsgProcessCompleted_ForExtralInterfaceInvoke.ForEach(
                    ////        a => {
                    ////            a.Invoke(this, messages);
                    ////        }
                    ////        );
                    ////}
                }
            }
            catch (Exception ce)
            {
                MessageBox.Show(string.Format("{0}:{1}", ce.Message, ce.StackTrace));
            }
            //tbox.Lines = msgs.ToArray();
            //tbox.Focus();
            //tbox.Select(tbox.Text.Length, 0);
            //tbox.ScrollToCaret();
        }
 public ResponseAction_ModifyStatus(WXMsgProcess wxprs, wxMessageClass msg, SharePlanStatus newStatus, string vals = null) : base(wxprs, msg)
 {
     ActionName     = "响应取消合买信息";
     changeToStatus = newStatus;
     updateVals     = vals;
 }
 public ResponseAction_SubmitNewInfo(WXMsgProcess wxprs, wxMessageClass msg) : base(wxprs, msg)
 {
     ActionName = "响应提供详细合买信息";
 }
Example #18
0
 public ResponseAction_ApplyCreate(WXMsgProcess wxprs, wxMessageClass msg) : base(wxprs, msg)
 {
     ActionName = "响应新建合买";
 }
        public static ResponseActionClass CreateAction(ActionType act, WXMsgProcess wxprs, wxMessageClass msg)
        {
            ResponseActionClass ret = null;

            switch (act)
            {
            case ActionType.ResetSystem:
            {
                ShareLotteryPlanClass.Reset();
                WXMsgProcess.ActionDic = null;
                break;
            }

            case ActionType.ApplyCreate:
            {
                ret = new ResponseAction_ApplyCreate(wxprs, msg);
                break;
            }

            case ActionType.SubmitNewInfo:
            {
                ret = new ResponseAction_SubmitNewInfo(wxprs, msg);
                break;
            }

            case ActionType.CancelCurr:
            {
                ret = new ResponseAction_CancelCurr(wxprs, msg);
                break;
            }

            case ActionType.SubcribeShares:
            {
                ret = new ResponseAction_SubcribeShares(wxprs, msg);
                break;
            }

            case ActionType.ModifyPlan:
            {
                ret = new ResponseAction_ModifyStatus(wxprs, msg, SharePlanStatus.Ready);
                break;
            }

            case ActionType.AppendShares:
            {
                ret = new ResponseAction_ModifyStatus(wxprs, msg, SharePlanStatus.Paied);
                break;
            }

            case ActionType.JdUnion:
            {
                ret = new ResponseAction_JdUnion(wxprs, msg);
                break;
            }

            case ActionType.ShowPlan:
            {
                ret = new ResponseAction_ShowPlan(wxprs, msg);
                break;
            }

            case ActionType.EndTheSubscribe:
            {
                ret = new ResponseAction_ModifyStatus(wxprs, msg, SharePlanStatus.Paying);
                break;
            }

            case ActionType.DeclareResult:
            {
                ret = new ResponseAction_ModifyStatus(wxprs, msg, SharePlanStatus.Opened);
                break;
            }

            case ActionType.DeclareProfit:
            {
                ret = new ResponseAction_ModifyStatus(wxprs, msg, SharePlanStatus.Opened);
                break;
            }

            case ActionType.ClosePlan:
            {
                ret = new ResponseAction_ClosePlan(wxprs, msg);
                break;
            }

            case ActionType.Charge:
            {
                ret = new ResponseAction_Charge(wxprs, msg);
                break;
            }

            case ActionType.ValidateInfo:
            {
                ret = new ResponseAction_ValidateInfo(wxprs, msg);
                break;
            }

            case ActionType.ManualInstructs:
            {
                ret = new ResponseAction_ManualIntructs(wxprs, msg);
                break;
            }

            case ActionType.Undefined:
            default:
            {
                ret = new ResponseAction_Undefined(wxprs, msg);
                break;
            }
            }
            return(ret);
        }
Example #20
0
 public void refreshMsg(string sender, wxMessageClass data)
 {
     SetDataGridDataTable(txt_ToMeMsgs, sender, data);
 }
        //public ResponseAction_Charge()
        //{

        //}
        //DbClass db;

        public ResponseAction_ManualIntructs(WXMsgProcess wxprs, wxMessageClass msg) : base(wxprs, msg)
        {
            ActionName = "手动下注";
            //db = new DbClass(SystemSetting.DbHost, SystemSetting.DbUser, SystemSetting.DbPwd, SystemSetting.DbName);
        }
 public ResponseAction_CancelCurr(WXMsgProcess wxprs, wxMessageClass msg) : base(wxprs, msg)
 {
     ActionName     = "响应取消合买信息";
     changeToStatus = SharePlanStatus.Completed;
 }
Example #23
0
        //public ResponseAction_Charge()
        //{

        //}
        //DbClass db;

        public ResponseAction_LotteryRunningTimeInfoQuery(WXMsgProcess wxprs, wxMessageClass msg) : base(wxprs, msg)
        {
            ActionName = "彩票运行信息查询";
            //db = new DbClass(SystemSetting.DbHost, SystemSetting.DbUser, SystemSetting.DbPwd, SystemSetting.DbName);
        }
 public ResponseAction_AskLotteryBetInfo(WXMsgProcess wxprs, wxMessageClass msg) : base(wxprs, msg)
 {
     ActionName = "响应买啥";
 }
 public ResponseAction_ModifyStatus(WXMsgProcess wxprs, wxMessageClass msg) : base(wxprs, msg)
 {
     ActionName = "响应取消合买信息";
 }