示例#1
0
        private void UploadViedo(List <MessageType> message, List <WXMesssage> wxMsgList)
        {
            WXMesssage msg       = new WXMesssage();
            var        sendVideo = message.Where(a => a.SendType == "视频").FirstOrDefault();

            if (null != sendVideo)
            {
                if (!File.Exists(sendVideo.TxtContent))
                {
                    MetroMessageBox.Show(this, "文件不存在,请选择好文件!!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                MessageTypeServices svc = new MessageTypeServices();
                var result = svc.SetMessgeSendCount(sendVideo.Id);
                if (result.Code != ResultCodeEnums.success)
                {
                    MetroMessageBox.Show(this, result.Msg, "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                WXServices wxServices = new WXServices();
                ExecEven("正在上传文件到微信服务器.........", null);
                var resultJson = wxServices.UploadVideo(sendVideo.TxtContent, _me.UserName, contact_all[0].UserName);
                if (!string.IsNullOrEmpty(resultJson))
                {
                    JObject obj = JsonConvert.DeserializeObject(resultJson) as JObject;
                    msg.MediaId = obj["MediaId"].ToString();
                    msg.Type    = 43;
                    msg.Readed  = false;
                    msg.Time    = DateTime.Now;
                    msg.From    = _me.UserName;
                    wxMsgList.Add(msg);
                }
            }
        }
示例#2
0
 private void SendViedo(WXMesssage msg, int count)
 {
     if (null != msg)
     {
         if ((count % 120) == 0)
         {
             ExecEven("休息一下等待下一轮发送.........", null);
             Thread.Sleep(60 * 1000);
         }
         _me.SendVideo(msg);
         Thread.Sleep(900);
         var semdLog = string.Format("{0}\t已发【视频】信息给{1}", DateTime.Now.ToString(), msg.ToNickName);
         ExecEven(semdLog, null);
     }
 }
示例#3
0
        private void SetText(List <MessageType> message, List <WXMesssage> wxMsgList)
        {
            var sendMsg = message.Where(a => a.SendType == "文本").FirstOrDefault();

            if (null != sendMsg)
            {
                MessageTypeServices svc = new MessageTypeServices();
                var result = svc.SetMessgeSendCount(sendMsg.Id);
                if (result.Code != ResultCodeEnums.success)
                {
                    MetroMessageBox.Show(this, result.Msg, "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                WXMesssage msg = new WXMesssage();
                msg.Type   = 1;
                msg.Msg    = WXFace.AddFace(sendMsg.TxtContent);
                msg.Readed = false;
                msg.Time   = DateTime.Now;
                msg.From   = _me.UserName;
                wxMsgList.Add(msg);
            }
        }
示例#4
0
        public void SendImage(WXMesssage msg)
        {
            WXServices wxs = new WXServices();

            wxs.SendImage(msg.MediaId, msg.From, msg.To, msg.Type);
        }
示例#5
0
        public void SendFile(WXMesssage msg, long totallen, string title, string fileext)
        {
            WXServices wxs = new WXServices();

            wxs.SendFile(msg.MediaId, totallen, title, fileext, msg.From, msg.To);
        }
示例#6
0
        /// <summary>
        /// 向该用户发送消息
        /// </summary>
        /// <param name="msg"></param>
        public void SendMsg(WXMesssage msg)
        {
            WXServices wxs = new WXServices();

            wxs.SendMessage(msg.Msg, msg.From, msg.To, msg.Type);
        }
示例#7
0
        public void SendVideo(WXMesssage msg)
        {
            WXServices wxs = new WXServices();

            wxs.SendVideo(msg.MediaId, msg.From, msg.To);
        }
示例#8
0
        private void skinButton1_Click(object sender, EventArgs e)
        {
            this.skinButton1.Enabled = false;
            List <MessageType> message = new List <MessageType>();
            int count = DataGridMessage.Rows.Count;

            for (int i = 0; i < count; i++)
            {
                DataGridViewCheckBoxCell checkCell = (DataGridViewCheckBoxCell)DataGridMessage.Rows[i].Cells[0];
                Boolean flag = Convert.ToBoolean(checkCell.Value);
                if (flag == true)
                {
                    MessageType msgType = new MessageType()
                    {
                        SendType   = this.DataGridMessage.Rows[i].Cells[1].Value.ToString(),
                        TxtContent = this.DataGridMessage.Rows[i].Cells[2].Value.ToString()
                    };
                    message.Add(msgType);
                }
            }
            if (message.Count <= 0)
            {
                MessageBox.Show("请选择好你要发送的消息!");
                return;
            }
            WXMesssage msg = new WXMesssage();
            //发消息
            var sendMsg = message.Where(a => a.SendType == "文本").FirstOrDefault();

            if (null != sendMsg)
            {
                foreach (var item in contact_all)
                {
                    msg.From   = _me.UserName;
                    msg.Readed = false;
                    msg.To     = item.UserName;
                    msg.Time   = DateTime.Now;
                    msg.Type   = 1;
                    msg.Msg    = sendMsg.TxtContent;
                    _me.SendMsg(msg);
                    outPost(item.NickName, sendMsg.SendType);
                }
            }
            //发图片
            var sendImage = message.Where(a => a.SendType == "图片").FirstOrDefault();

            if (null != sendImage)
            {
                if (!File.Exists(sendImage.TxtContent))
                {
                    MessageBox.Show("文件不存在,请选择好文件!");
                    return;
                }
                //先上传
                WXServices wxServices = new WXServices();
                var        resultJson = wxServices.UploadImage(sendImage.TxtContent);
                if (!string.IsNullOrEmpty(resultJson))
                {
                    JObject obj     = JsonConvert.DeserializeObject(resultJson) as JObject;
                    string  mediaId = obj["MediaId"].ToString();
                    if (!string.IsNullOrEmpty(mediaId))
                    {
                        foreach (var item in contact_all)
                        {
                            msg.From    = _me.UserName;
                            msg.Readed  = false;
                            msg.To      = item.UserName;
                            msg.Time    = DateTime.Now;
                            msg.MediaId = mediaId;
                            _me.SendImage(msg);
                            outPost(item.NickName, sendImage.SendType);
                        }
                    }
                }
            }
            //发视频
            var sendVideo = message.Where(a => a.SendType == "视频").FirstOrDefault();

            if (null != sendVideo)
            {
                if (!File.Exists(sendVideo.TxtContent))
                {
                    MessageBox.Show("文件不存在,请选择好文件!");
                    return;
                }
                WXServices wxServices = new WXServices();
                var        resultJson = wxServices.UploadVideo(sendVideo.TxtContent, _me.UserName, contact_all[0].UserName);
                if (!string.IsNullOrEmpty(resultJson))
                {
                    JObject obj     = JsonConvert.DeserializeObject(resultJson) as JObject;
                    string  mediaId = obj["MediaId"].ToString();
                    if (!string.IsNullOrEmpty(mediaId))
                    {
                        foreach (var item in contact_all)
                        {
                            msg.From    = _me.UserName;
                            msg.Readed  = false;
                            msg.To      = item.UserName;
                            msg.Time    = DateTime.Now;
                            msg.MediaId = mediaId;
                            _me.SendVideo(msg);
                            outPost(item.NickName, sendVideo.SendType);
                        }
                    }
                }
            }
            this.skinButton1.Enabled = true;
        }