예제 #1
0
        public static void send_houtai(CmsForm cmsForm, string content, string content_img, ArrayList imgList)
        {
            LogUtil.log_call(cmsForm, "开始微信后台发送商品!");

            content = content.Replace("<BR>", "\n");

            int count = 0;

            if (imgList != null && imgList.Count > 0)
            {
                count = imgList.Count;
            }

            JsonData jd = new JsonData();

            jd["content"]       = content;
            jd["imgs"]          = new JsonData();//**新添加一层关系时,需要再次 new** JsonData()
            jd["imgs"]["count"] = "" + count;
            if (imgList != null && imgList.Count > 0)
            {
                jd["imgs"]["items"] = new JsonData();
                foreach (string key in imgList)
                {
                    JsonData jd_item = new JsonData();
                    jd_item["url"] = key;
                    jd["imgs"]["items"].Add(jd_item);
                }
            }
            string content_json = JsonMapper.ToJson(jd);

            //LogUtil.log_call(cmsForm, "content_json:" + content_json);

            WeixinUtil.sendForm(cmsForm, content_json);
        }
예제 #2
0
        public static void send(CmsForm cmsForm, string content, string content_img, ArrayList imgList, string content_org, int url_type, int goods_type)
        {
            string   out_log = "";
            GStruct0 gStruct0;

            try
            {
                if (cmsForm.radioButton_fasong_weixin_fashi_houtai.Checked)
                {
                    WeixinUtil.login(cmsForm);
                    WeixinUtil.send_houtai(cmsForm, content, content_img, imgList);
                    return;
                }

                if (cmsForm.appBean.weixin_list == null || cmsForm.appBean.weixin_list.Count == 0)
                {
                    LogUtil.log_call(cmsForm, "没有微信群!");
                    return;
                }
                //this.string_50 = this.method_151(cmsForm);
                //᝚.ᜃ(this.string_50);
                //ContentItem contentItem = WeixinUtil.get_weixin_content(cmsForm,content,out out_log);
                //LogUtil.log_call(cmsForm, gClass27.content);
                int i = 0;
                while (i < cmsForm.appBean.weixin_list.Count)
                {
                    if (!cmsForm.appBean.send_status && !cmsForm.appBean.qunfa_genfa_qunfa_status)
                    {
                        out_log = "群发被强制停止";
                        return;
                    }
                    else
                    {
                        string item = (string)cmsForm.appBean.weixin_list[i];

                        string weiba_all  = QqUtil.weiba(cmsForm, out out_log);
                        string weiba      = "";
                        string weixin_pid = PidUtil.get_weixin_pid_qun(cmsForm, item, cmsForm.appBean.member_id, out weiba);
                        if (!string.IsNullOrEmpty(weixin_pid))
                        {
                            if (goods_type != 2)
                            {
                                ContentItem contentItem_qun = UrlUtil.parseContent(cmsForm, content_org, weixin_pid, cmsForm.checkBox_qunfa_pid.Checked, false, url_type);
                                UrlUtil.parseContent_weixin(cmsForm, contentItem_qun, weixin_pid, cmsForm.checkBox_qunfa_pid.Checked);
                                UrlUtil.template_qq(cmsForm, contentItem_qun, weixin_pid, cmsForm.checkBox_qunfa_pid.Checked, cmsForm.appBean.weixin_template);

                                content     = contentItem_qun.content_weixin;
                                content_img = contentItem_qun.content_weixin_img;
                                imgList     = contentItem_qun.imgList;
                                weiba_all   = weiba;
                            }
                            else
                            {
                                ContentItem contentItem_qun = UrlHptUtil.parseContent(cmsForm, content_org, weixin_pid, cmsForm.checkBox_qunfa_pid.Checked, false, url_type);
                                UrlUtil.parseContent_weixin(cmsForm, contentItem_qun, weixin_pid, false);

                                content = contentItem_qun.content_send;
                                content = WeixinUtil.remove_img(content);

                                LogUtil.log_call(cmsForm, content);
                                content_img = contentItem_qun.content_weixin_img;
                                imgList     = contentItem_qun.imgList;
                                weiba_all   = weiba;
                            }
                        }
                        else
                        {
                            if (goods_type != 2)
                            {
                            }
                            else
                            {
                                content = WeixinUtil.remove_img(content);
                            }
                        }

                        IntPtr intPtr = CmsForm.FindWindow(null, item);
                        if (intPtr == IntPtr.Zero)
                        {
                            out_log = string.Concat("微信群【", item, "】窗口没有打开,软件自动拖动微信群成为独立的窗口!");
                            CmsForm.EnumWindows(new GDelegate66(cmsForm.method_121), IntPtr.Zero);
                            if (!WeixinUtil.method_120(cmsForm.appBean.weixin_win_id))
                            {
                                LogUtil.log_call(cmsForm, "微信没有打开!");
                                goto Label2;
                            }
                            LogUtil.log_call(cmsForm, "微信已经打开!正在拖动。。。。");
                            CmsForm.ShowWindowAsync(cmsForm.appBean.weixin_win_id, GClass13.int_13);
                            Thread.Sleep(150);
                            CmsForm.SetForegroundWindow(cmsForm.appBean.weixin_win_id);
                            Thread.Sleep(150);
                            CmsForm.GetWindowRect(cmsForm.appBean.weixin_win_id, out gStruct0);
                            MouseUtil.smethod_9(cmsForm.appBean.weixin_win_id, gStruct0.int_0 + 100, gStruct0.int_1 + 25);
                            Thread.Sleep(200);
                            SendKeys.SendWait("{BACKSPACE}");
                            Thread.Sleep(200);
                            SendKeys.SendWait(item);
                            Thread.Sleep(200);
                            SendKeys.SendWait("{ENTER}");
                            Thread.Sleep(250);
                            MouseUtil.smethod_13(gStruct0.int_0 + 100, gStruct0.int_1 + 75, gStruct0.int_0 + 400);
                            Thread.Sleep(150);
                        }
                        intPtr = CmsForm.FindWindow(null, item);
                        if (intPtr != IntPtr.Zero)
                        {
                            CmsForm.ShowWindowAsync(intPtr, GClass13.int_13);
                            Thread.Sleep(150);
                            CmsForm.SetForegroundWindow(intPtr);
                            Thread.Sleep(150);
                            CmsForm.GetWindowRect(intPtr, out gStruct0);
                            MouseUtil.smethod_9(intPtr, gStruct0.int_2 - 60, gStruct0.int_3 - 70);
                            if (content_img != null && !"".Equals(content_img))
                            {
                                //LogUtil.log_call(cmsForm, content_img);

                                //CommonUtil.clipboard(content_img, out out_log);
                                QqUtil.copy_content(cmsForm, content_img, out out_log);
                                Thread.Sleep(1000);
                                MouseUtil.paste();     //粘贴消息
                                Thread.Sleep(1000);
                                MouseUtil.enter();     // 回车
                                Thread.Sleep(1000);
                                LogUtil.log_call(cmsForm, "发送图片结束");
                                try
                                {
                                    Thread.Sleep(int.Parse(cmsForm.textBox_qunfa_weixin_fatu_times.Text.Trim()));
                                }
                                catch (Exception)
                                {
                                    Thread.Sleep(1000);
                                }
                            }
                            if ((content != null && !content.Equals("")))
                            {
                                //CommonUtil.clipboard(string.Concat(content, QqUtil.weiba(cmsForm, out out_log)), out out_log);
                                QqUtil.copy_content(cmsForm, string.Concat(content, weiba_all), out out_log);
                                Thread.Sleep(1000);
                                MouseUtil.paste();     //粘贴消息
                                Thread.Sleep(1000);
                                MouseUtil.enter();     // 回车
                                Thread.Sleep(1000);
                            }
                            Thread.Sleep(1000);
                        }
                        else
                        {
                            LogUtil.log_call(cmsForm, string.Concat("微信群【", item, "】窗口没有打开,软件拖动失败,跳过跟发!"));
                        }
Label2:
                        i = i + 1;
                    }
                }
                //this.bool_34 = false;
                //this.string_76 = "";
                //this.int_26 = 0;
                if (!cmsForm.checkBox_qunfa_qq_zuixiaohua.Checked)
                {
                    QqUtil.method_167(cmsForm, out out_log);
                }
                else
                {
                    QqUtil.method_168(cmsForm, out out_log);
                }
                //QqUtil.method_156(cmsForm);
                //QqUtil.method_134(cmsForm);
                LogUtil.log_call(cmsForm, "微信群发完成!");
            }
            catch (Exception exception)
            {
                LogUtil.log_call(cmsForm, string.Concat("[autoSendWeixin]出错:", exception.ToString()));
            }
            return;
        }