Beispiel #1
0
 /// <summary>
 /// 接收消息
 /// </summary>
 /// <param name="request">消息</param>
 private void ReceiveMessage(object request)
 {
     try
     {
         if (MessageReceived != null)
         {
             ProcessMessage requestMessage = request as ProcessMessage;
             if (requestMessage != null)
             {
                 MessageReceived(requestMessage);
             }
         }
     }
     catch
     {
     }
 }
Beispiel #2
0
        /// <summary>
        /// 进程间消息
        /// </summary>
        /// <param name="requestMessage"></param>
        private void cb_MessageReceived(ProcessMessage requestMessage)
        {
            if (requestMessage.RequestType == "AccountAndPassword")
            {
                Logger.LogInfo("收到帐号密码消息,值为:" + requestMessage.RequestString);
                string[] arr = requestMessage.RequestString.Split(',');
                if (arr.Length == 2)
                {
                    DataManager.Instance.Account  = arr[0];
                    DataManager.Instance.Password = arr[1];
                }
            }
            else if (requestMessage.RequestType == "Cookies")
            {
                Logger.LogInfo("收到Cookies消息,值为:" + requestMessage.RequestString);

                if (requestMessage.RequestString != null)
                {
                    string code = null;
                    var    arr  = requestMessage.RequestString.Split(';');
                    if (arr.Length > 1)
                    {
                        var temp = arr[1].Split('=');
                        if (temp.Length > 1)
                        {
                            code = temp[1];
                        }
                    }
                    if (code != null && code.Contains("%"))
                    {
                        code = HttpUtility.UrlDecode(code);
                    }
                    DataManager.Instance.SetCookies(code);
                }
            }
            else if (requestMessage.RequestType == "IsLogin")
            {
                Logger.LogInfo("收到登录成功消息,值为:" + requestMessage.RequestString);
                if (!DataManager.Instance.IsLogin)
                {
                    DataManager.Instance.Login();
                }
            }
        }
Beispiel #3
0
 /// <summary>
 /// 消息处理
 /// </summary>
 /// <param name="m">消息</param>
 protected override void DefWndProc(ref Message m)
 {
     if (m.Msg == WM_COPYDATA)
     {
         try
         {
             COPYDATASTRUCT mystr = new COPYDATASTRUCT();
             mystr = (COPYDATASTRUCT)Marshal.PtrToStructure(m.LParam, typeof(COPYDATASTRUCT));
             if (mystr.cbData > 0)
             {
                 if (mystr.lpData != IntPtr.Zero)
                 {
                     int    nLength = mystr.cbData / 2;
                     string str     = Marshal.PtrToStringUni(mystr.lpData, nLength);
                     if (str.Length > nLength)
                     {
                         str = str.Substring(0, nLength);
                     }
                     ProcessMessage requestMessage = new ProcessMessage();
                     requestMessage.ToClass(str);
                     ReceiveMessage(requestMessage);
                 }
                 else
                 {
                     ProcessMessage requestMessage = new ProcessMessage();
                     requestMessage.RequestString = mystr.cbData.ToString();
                     ReceiveMessage(requestMessage);
                 }
             }
         }
         catch
         {
         }
     }
     else
     {
         base.DefWndProc(ref m);
     }
 }
Beispiel #4
0
 protected override void SendMessage(ProcessMessage msg)
 {
     callBackFrm.SendMessage(msg);
 }
Beispiel #5
0
 protected virtual void SendMessage(ProcessMessage msg)
 {
 }
Beispiel #6
0
 /// <summary>
 /// 发送请求
 /// </summary>
 /// <param name="db">请求内容</param>
 public void Send(ProcessMessage db)
 {
     sendQueue.Enqueue(db);
 }
Beispiel #7
0
 /// <summary>
 /// 状态回调
 /// </summary>
 /// <param name="rs">验证结果</param>
 protected void Receive(ProcessMessage rs)
 {
     receiveQueue.Enqueue(rs);
 }