/// <summary>
 /// 加载微信通讯录
 /// </summary>
 /// <param name="contact_all">The contact_all.</param>
 public void SetMessageView(QQGroupMessageModel message)
 {
     if (dgvMessageView.InvokeRequired)
     {
         this.dgvMessageView.Invoke(new Action <QQGroupMessageModel>(SetMessageView), new object[] { message });
     }
     else
     {
         int i = dgvMessageView.Rows.Count;
         dgvMessageView.Rows.Add();
         ++i;
         dgvMessageView.Rows[i - 1].Cells["MessageCode"].Value    = message.Code;
         dgvMessageView.Rows[i - 1].Cells["GroupName"].Value      = message.GroupName;
         dgvMessageView.Rows[i - 1].Cells["MessageContent"].Value = message.MessageContent;
         dgvMessageView.Rows[i - 1].Cells["MessageUrl1"].Value    = message.MessageUrl1;
         dgvMessageView.Rows[i - 1].Cells["MessageUrl2"].Value    = message.MessageUrl2;
         dgvMessageView.Rows[i - 1].Cells["MessageStatus"].Value  = message.MessageStatus == 0 ? "未处理" : "已完成";
         if (i % 2 == 0)
         {
             dgvMessageView.Rows[i - 1].DefaultCellStyle.BackColor          = Color.FromArgb(248, 248, 248);
             dgvMessageView.Rows[i - 1].DefaultCellStyle.SelectionBackColor = Color.FromArgb(248, 248, 248);
         }
         else
         {
             dgvMessageView.Rows[i - 1].DefaultCellStyle.BackColor          = Color.FromArgb(255, 255, 255);
             dgvMessageView.Rows[i - 1].DefaultCellStyle.SelectionBackColor = Color.FromArgb(255, 255, 255);
         }
         dgvMessageView.Rows[i - 1].DefaultCellStyle.ForeColor = Color.FromArgb(180, 180, 180);
         dgvMessageView.CurrentCell = dgvMessageView.Rows[dgvMessageView.Rows.Count - 1].Cells[dgvMessageView.CurrentCell.ColumnIndex];
     }
 }
Example #2
0
        /// <summary>
        /// 重新跟发
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void toolReSend_Click(object sender, EventArgs e)
        {
            if (this.dgvMessageView.Rows == null)
            {
                return;
            }
            DataGridViewCellCollection cells = this.dgvMessageView.Rows[currentRowIndex].Cells;

            if (cells != null)
            {
                string GroupName          = cells["GroupName"].Value.ToString();
                string msgContent         = cells["MessageContent"].Value.ToString();
                long   msgCode            = (long)cells["MessageCode"].Value;
                string FullMessageContent = cells["FullMessageContent"].Value.ToString();
                string url  = cells["MessageUrl1"].Value.ToString();
                string url2 = cells["MessageUrl2"].Value.ToString();


                var urls = UrlUtils.GetUrls(FullMessageContent);
                if (BuildGoodsHandler != null)
                {
                    QQGroupMessageModel message = new QQGroupMessageModel()
                    {
                        MessageContent     = msgContent,
                        Code               = msgCode,
                        GroupName          = GroupName,
                        MessageUrl1        = url,
                        MessageUrl2        = url2,
                        FullMessageContent = FullMessageContent
                    };
                    MessageHandler(urls, message);
                }
            }
        }
Example #3
0
        /// <summary>
        /// 群消息处理
        /// </summary>
        /// <param name="msgContent"></param>
        /// <param name="urls"></param>
        private void QqForm_GroupMsgHandler(long msgCode, long gid, string msgGroupName, string msgContent, string FullMessageContent, List <string> urls)
        {
            QQGroup group = QQGlobal.listenGroups.Find(g => { return(g.Gid == gid); });

            //TODO:接收群消息
            QQGroupMessageModel message = new QQGroupMessageModel()
            {
                GroupName = group != null?group.GetGroupName() : msgGroupName,
                                MessageContent     = msgContent,
                                FullMessageContent = FullMessageContent,
                                MessageStatus      = 0,
                                Code = msgCode
            };

            if (urls != null)
            {
                if (urls.Count() > 0)
                {
                    message.MessageUrl1 = urls[0];
                }
                if (urls.Count() > 1)
                {
                    message.MessageUrl2 = urls[1];
                }
            }
            SetMessageView(message);
            if (BuildGoodsHandler != null)
            {
                MessageHandler(urls, message);
            }
        }
        /// <summary>
        /// 群消息处理
        /// </summary>
        /// <param name="msgContent"></param>
        /// <param name="urls"></param>
        private void QqForm_GroupMsgHandler(long msgCode, string msgGroupName, string msgContent, List <string> urls)
        {
            //TODO:接收群消息
            QQGroupMessageModel message = new QQGroupMessageModel()
            {
                GroupName      = msgGroupName,
                MessageContent = msgContent.Replace('"', ' ').Replace(" ", "\n"),
                MessageStatus  = 0,
                Code           = msgCode
            };

            if (urls != null)
            {
                if (urls.Count() > 0)
                {
                    message.MessageUrl1 = urls[0];
                }
                if (urls.Count() > 1)
                {
                    message.MessageUrl2 = urls[1];
                }
            }
            SetMessageView(message);
            //TODO:
            if (urls != null && urls.Count() > 0)
            {
                bool isAutoSend = ckbAutoSend.Checked;
                new System.Threading.Thread(() =>
                {
                    long code = msgCode;
                    //消息处理回调
                    BuildGoodsHandler?.Invoke(code, urls, isAutoSend, (ret, i, t) =>
                    {
                        string text = "";
                        switch (ret)
                        {
                        case MessageCallBackType.正在准备:
                            text = "正在准备";
                            break;

                        case MessageCallBackType.开始转链:
                            text = string.Format("开始转链{0}/{1}", i, t);
                            break;

                        case MessageCallBackType.转链完成:
                            text = string.Format("转链完成");
                            break;

                        case MessageCallBackType.开始创建计划:
                            text = string.Format("创建计划..");
                            break;

                        case MessageCallBackType.完成:
                            text = string.Format("已完成");
                            break;

                        default:
                            break;
                        }
                        if (!string.IsNullOrEmpty(text))
                        {
                            SetMesageViewByMessageCode(msgCode, text);
                        }
                    });
                })
                {
                    IsBackground = true
                }.Start();
            }
        }
Example #5
0
        /// <summary>
        /// 消息处理
        /// </summary>
        /// <param name="urls"></param>
        /// <param name="msgCode"></param>
        /// <param name="msgContent"></param>
        private void MessageHandler(List <string> urls, QQGroupMessageModel message)
        {
            //TODO:
            if (urls != null && urls.Count() > 0)
            {
                bool isAutoSend     = ckbAutoSend.Checked;
                bool isEnableCustom = ckbEnableCustomTemplate.Checked;
                new System.Threading.Thread(() =>
                {
                    try
                    {
                        //消息处理回调
                        BuildGoodsHandler?.Invoke(message.Code, message.GroupName, message.MessageContent, message.FullMessageContent, urls, isAutoSend, isEnableCustom, (ret, i, t) =>
                        {
                            string text = "";
                            switch (ret)
                            {
                            case MessageCallBackType.正在准备:
                                text = "正在准备";
                                break;

                            case MessageCallBackType.开始转链:
                                text = string.Format("开始转链{0}/{1}", i, t);
                                break;

                            case MessageCallBackType.转链完成:
                                text = string.Format("转链完成");
                                break;

                            case MessageCallBackType.开始创建计划:
                                text = string.Format("创建计划..");
                                break;

                            case MessageCallBackType.完成:
                                text = string.Format("已完成");
                                break;

                            case MessageCallBackType.未准备:
                                text = "未准备";
                                break;

                            case MessageCallBackType.失败:
                                text = "失败";
                                break;

                            default:
                                break;
                            }
                            if (!string.IsNullOrEmpty(text))
                            {
                                SetMesageViewByMessageCode(message.Code, text);
                            }
                        });
                    }
                    catch (Exception)
                    {
                        SetMesageViewByMessageCode(message.Code, "已完成");
                    }
                })
                {
                    IsBackground = true
                }.Start();
            }
        }