/// <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();
            }
        }
示例#2
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();
            }
        }