예제 #1
0
        private void Login(string userName, string userPWD)
        {
            var baseUrl = "http://www.012395.com/e/enews/index.php";

            var response = ApiClient.Login(baseUrl, userName, userPWD);

            if (response == FuncConst.LoginErr)
            {
                FuncMsg.Error($"{FuncConst.LoginErr}\r\n{FuncConst.NetworkErr}");
                return;
            }

            HtmlAgilityPack.HtmlDocument html = new HtmlAgilityPack.HtmlDocument();
            html.LoadHtml(response);

            var node = html.DocumentNode.SelectSingleNode("//b");

            if (node != null)
            {
                var msg = node.InnerText;
                if (msg.Equals(SuccessStr))
                {
                    OpenEditor();
                    RefreshLately();
                }
                else
                {
                    FuncMsg.Error(msg);
                    return;
                }
            }
        }
예제 #2
0
        private bool InitSave()
        {
            var baseUrl = "http://www.012395.com/e/DoInfo/AddInfo.php?mid=15&enews=MAddInfo&classid=115&Submit=%E6%B7%BB%E5%8A%A0%E4%BF%A1%E6%81%AF";

            var response = ApiClient.AddInfo(baseUrl);

            if (response == FuncConst.AddErr)
            {
                FuncMsg.Error($"{FuncConst.AddErr}\r\n{FuncConst.NetworkErr}");
                return(false);
            }

            HtmlAgilityPack.HtmlDocument html = new HtmlAgilityPack.HtmlDocument();
            html.LoadHtml(response);

            if (!IsLogin(html))
            {
                return(false);
            }

            DataSource.Add("enews", GetNodeVal(html, "enews"));
            DataSource.Add("classid", GetNodeVal(html, "classid"));
            DataSource.Add("id", "");
            DataSource.Add("filepass", GetNodeVal(html, "filepass"));
            DataSource.Add("mid", "15");
            DataSource.Add("tokenid", "");
            return(true);
        }
예제 #3
0
        /// <summary>
        /// 刷新我的发布
        /// </summary>
        private void RefreshLately()
        {
            var baseUrl  = "http://www.012395.com/e/DoInfo/ListInfo.php?mid=15";
            var response = ApiClient.RefreshLately(baseUrl);

            if (response.Equals(FuncConst.RefreshErr))
            {
                FuncMsg.Error($"{FuncConst.RefreshErr}\r\n{FuncConst.NetworkErr}");
                return;
            }

            var html = new HtmlAgilityPack.HtmlDocument();

            html.LoadHtml(response);

            var node = html.DocumentNode.SelectSingleNode("//title");

            if (node != null)
            {
                var title = node.InnerText;
                if (title == FuncConst.ExTitle)
                {
                    node = html.DocumentNode.SelectSingleNode("//b");
                    if (node != null)
                    {
                        FuncMsg.Error(node.InnerText);
                        return;
                    }
                }
                else
                {
                    var nodes = html.DocumentNode.SelectNodes("//*[contains(@class,'table_list')]");
                    var list  = new List <ListViewItem>();
                    listView1.Items.Clear();
                    foreach (var item in nodes)
                    {
                        var tds = item.SelectNodes("tr/td");

                        var ctl = new ListViewItem();
                        ctl.Text = tds[0].InnerText;
                        ctl.SubItems.Add(tds[3].InnerText);
                        list.Add(ctl);
                        listView1.Items.Add(ctl);
                    }
                }
            }
        }
예제 #4
0
        private bool IsLogin(HtmlAgilityPack.HtmlDocument html)
        {
            var node = html.DocumentNode.SelectSingleNode("//title");

            if (node != null)
            {
                var title = node.InnerText;
                if (title == FuncConst.ExTitle)
                {
                    node = html.DocumentNode.SelectSingleNode("//b");
                    var msg = "您的账号在其它地方登录,请重新登录后重新发布";
                    if (node != null)
                    {
                        msg = node.InnerText + "\r\n请重新登录后再次发布";
                    }
                    FuncMsg.Error(msg);
                    groupBox2.Enabled = false;
                    toolStripTextBox1.Focus();
                    return(false);
                }
            }
            return(true);
        }
예제 #5
0
        /// <summary>
        /// 是否成功
        /// </summary>
        /// <param name="htmlStr"></param>
        /// <returns></returns>
        private bool IsSuccess(string htmlStr)
        {
            if (htmlStr == FuncConst.AddErr)
            {
                FuncMsg.Error($"{FuncConst.AddErr}\r\n{FuncConst.NetworkErr}");
                return(false);
            }

            var html = new HtmlAgilityPack.HtmlDocument();

            html.LoadHtml(htmlStr);
            var node = html.DocumentNode.SelectSingleNode("//title");

            if (node != null)
            {
                var title = node.InnerText;
                if (title == FuncConst.ExTitle)
                {
                    node = html.DocumentNode.SelectSingleNode("//b");
                    if (node != null)
                    {
                        var msg = node.InnerText;
                        if (msg == "提交信息成功")
                        {
                            return(true);
                        }
                        else
                        {
                            FuncMsg.Error(msg);
                            return(false);
                        }
                    }
                }
            }
            FuncMsg.Error("其它错误,请稍后重试。");
            return(false);
        }
예제 #6
0
        /// <summary>
        /// 货源信息发布:模式2
        /// </summary>
        /// <param name="args"></param>
        /// <returns></returns>
        private bool Issue2(string args)
        {
            var idx1 = args.IndexOf("名称");
            var idx2 = args.IndexOf("运价");
            var plac = 0;

            if (idx2 == idx1 || idx1 > idx2)
            {
                FuncMsg.Error("[货源信息]检测失败,请检查待发布内容!\r\n可参考帮助界面中“货源信息模式二”中的内容示例");
                return(false);
            }
            plac = 2;
            DataSource.Add("title", args.Substring(idx1 + plac, idx2 - idx1 - plac).Trim());

            idx1 = args.IndexOf("吨位");
            idx2 = args.IndexOf("发出港");
            if (idx2 == idx1 || idx1 > idx2)
            {
                FuncMsg.Error("[吨位]检测失败,请检查待发布内容!\r\n可参考帮助界面中“货源信息模式二”中的内容示例");
                return(false);
            }
            plac = 2;
            DataSource.Add("h_dunwei", args.Substring(idx1 + plac, idx2 - idx1 - plac).Trim());

            idx1 = args.IndexOf("发出港");
            idx2 = args.IndexOf("所属省市");
            if (idx2 == idx1 || idx1 > idx2)
            {
                FuncMsg.Error("[发出港]检测失败,请检查待发布内容!\r\n可参考帮助界面中“货源信息模式二”中的内容示例");
                return(false);
            }
            plac = 3;
            DataSource.Add("h_fachu", args.Substring(idx1 + plac, idx2 - idx1 - plac).Trim());

            idx1 = args.IndexOf("到达港");
            idx2 = args.IndexOf("到达省市");
            if (idx2 == idx1 || idx1 > idx2)
            {
                FuncMsg.Error("[到达港]检测失败,请检查待发布内容!\r\n可参考帮助界面中“货源信息模式二”中的内容示例");
                return(false);
            }
            plac = 3;
            DataSource.Add("h_daoda", args.Substring(idx1 + plac, idx2 - idx1 - plac).Trim());

            idx1 = args.IndexOf("包装");
            idx2 = args.IndexOf("类型");
            if (idx2 == idx1 || idx1 > idx2)
            {
                FuncMsg.Error("[包装形式]检测失败,请检查待发布内容!\r\n可参考帮助界面中“货源信息模式二”中的内容示例");
                return(false);
            }
            plac = 2;
            DataSource.Add("h_xings", args.Substring(idx1 + plac, idx2 - idx1 - plac).Trim());

            idx1 = args.IndexOf("类型");
            idx2 = args.IndexOf("发货日期");
            if (idx2 == idx1 || idx1 > idx2)
            {
                FuncMsg.Error("[航运类型]检测失败,请检查待发布内容!\r\n可参考帮助界面中“货源信息模式二”中的内容示例");
                return(false);
            }
            plac = 2;
            DataSource.Add("h_leix", args.Substring(idx1 + plac, idx2 - idx1 - plac).Trim());

            idx1 = args.IndexOf("发货日期");
            idx2 = args.IndexOf("截止日期");
            if (idx2 == idx1 || idx1 > idx2)
            {
                FuncMsg.Error("[装运期限(起始)]检测失败,请检查待发布内容!\r\n可参考帮助界面中“货源信息模式二”中的内容示例");
                return(false);
            }
            plac = 4;
            var startDate = args.Substring(idx1 + plac, idx2 - idx1 - plac).Trim();
            var tuple     = startDate.ToDateStr();

            // 月
            DataSource.Add("h_yue", tuple.Item1);
            // 日
            DataSource.Add("h_ri", tuple.Item2);

            idx1 = args.IndexOf("截止日期");
            idx2 = args.IndexOf("是否交易");
            if (idx2 == idx1 || idx1 > idx2)
            {
                FuncMsg.Error("[装运期限(结束)]检测失败,请检查待发布内容!\r\n可参考帮助界面中“货源信息模式二”中的内容示例");
                return(false);
            }
            plac = 4;
            var endDate = args.Substring(idx1 + plac, idx2 - idx1 - plac).Trim();
            var tuple2  = endDate.ToDateStr();

            // 月
            DataSource.Add("h_yue1", tuple2.Item1);
            // 日
            DataSource.Add("h_ri1", tuple2.Item2);
            // 有效期
            DataSource.Add("h_xiaoqi", "7天");

            idx1 = args.IndexOf("联系人");
            idx2 = args.IndexOf("手机");
            if (idx2 == idx1 || idx1 > idx2)
            {
                FuncMsg.Error("[联系人]检测失败,请检查待发布内容!\r\n可参考帮助界面中“货源信息模式二”中的内容示例");
                return(false);
            }
            plac = 4;
            DataSource.Add("hy_lxr", args.Substring(idx1 + plac, idx2 - idx1 - plac).Trim());

            idx1 = args.IndexOf("手机");
            idx2 = args.IndexOf("QQ号");
            if (idx2 == idx1 || (idx2 > -1 && idx1 > idx2))
            {
                FuncMsg.Error("[联系电话]检测失败,请检查待发布内容!\r\n可参考帮助界面中“货源信息模式二”中的内容示例");
                return(false);
            }
            plac = 3;
            DataSource.Add("hy_lxdh", args.Substring(idx1 + plac, idx2 - idx1 - plac).Trim());

            idx1 = args.IndexOf("备注");
            idx2 = args.IndexOf("联系方式");
            if (idx2 == idx1 || (idx2 > -1 && idx1 > idx2))
            {
                FuncMsg.Error("[备注]检测失败,请检查待发布内容!\r\n可参考帮助界面中“货源信息模式二”中的内容示例");
                return(false);
            }
            plac = 3;
            DataSource.Add("h_conter", args.Substring(idx1 + plac, idx2 - idx1 - plac).Trim());

            return(true);
        }
예제 #7
0
        /// <summary>
        /// 货源信息发布:模式1
        /// </summary>
        /// <param name="args"></param>
        private bool Issue1(string args)
        {
            /*货源名称煤炭航线类别长江-内河所需船型单机货物吨位5700发出港镇江 到达港芜湖 发布时间2021-03-19装运期限2021-03-19至2021-03-19浏览次数6次运价元/吨联系人: 顾孝飞
             * 联系电话:15896025008 */

            var idx1 = args.IndexOf("货源名称");
            var idx2 = args.IndexOf("航线类别");
            var plac = 0;

            if (idx2 == idx1 || idx1 > idx2)
            {
                FuncMsg.Error("[货源信息]检测失败,请检查待发布内容!\r\n可参考帮助界面中“货源信息模式一”中的内容示例");
                return(false);
            }
            plac = 4;
            DataSource.Add("title", args.Substring(idx1 + plac, idx2 - idx1 - plac).Trim());

            idx1 = args.IndexOf("吨位");
            idx2 = args.IndexOf("发出港");
            if (idx2 == idx1 || idx1 > idx2)
            {
                FuncMsg.Error("[吨位]检测失败,请检查待发布内容!\r\n可参考帮助界面中“货源信息模式一”中的内容示例");
                return(false);
            }
            plac = 2;
            DataSource.Add("h_dunwei", args.Substring(idx1 + plac, idx2 - idx1 - plac).Trim());

            idx1 = args.IndexOf("发出港");
            idx2 = args.IndexOf("到达港");
            if (idx2 == idx1 || idx1 > idx2)
            {
                FuncMsg.Error("[发出港]检测失败,请检查待发布内容!\r\n可参考帮助界面中“货源信息模式一”中的内容示例");
                return(false);
            }
            plac = 3;
            DataSource.Add("h_fachu", args.Substring(idx1 + plac, idx2 - idx1 - plac).Trim());

            idx1 = args.IndexOf("到达港");
            idx2 = args.IndexOf("发布时间");
            if (idx2 == idx1 || idx1 > idx2)
            {
                FuncMsg.Error("[到达港]检测失败,请检查待发布内容!\r\n可参考帮助界面中“货源信息模式一”中的内容示例");
                return(false);
            }
            plac = 3;
            DataSource.Add("h_daoda", args.Substring(idx1 + plac, idx2 - idx1 - plac).Trim());

            DataSource.Add("h_xings", "散装");
            DataSource.Add("h_leix", "内河");

            idx1 = args.IndexOf("装运期限");
            idx2 = args.IndexOf("至");
            if (idx2 == idx1 || idx1 > idx2)
            {
                FuncMsg.Error("[装运期限(起始)]检测失败,请检查待发布内容!\r\n可参考帮助界面中“货源信息模式一”中的内容示例");
                return(false);
            }
            plac = 4;
            var startDate = args.Substring(idx1 + plac, idx2 - idx1 - plac).Trim();
            var tuple     = startDate.ToDateStr();

            // 月
            DataSource.Add("h_yue", tuple.Item1);
            // 日
            DataSource.Add("h_ri", tuple.Item2);

            idx1 = args.IndexOf("至");
            idx2 = args.IndexOf("浏览次数");
            if (idx2 == idx1 || idx1 > idx2)
            {
                FuncMsg.Error("[装运期限(结束)]检测失败,请检查待发布内容!\r\n可参考帮助界面中“货源信息模式一”中的内容示例");
                return(false);
            }
            plac = 1;
            var endDate = args.Substring(idx1 + plac, idx2 - idx1 - plac).Trim();
            var tuple2  = endDate.ToDateStr();

            // 月
            DataSource.Add("h_yue1", tuple2.Item1);
            // 日
            DataSource.Add("h_ri1", tuple2.Item2);
            // 有效期
            DataSource.Add("h_xiaoqi", "7天");

            idx1 = args.IndexOf("联系人");
            idx2 = args.IndexOf("联系电话");
            if (idx2 == idx1 || idx1 > idx2)
            {
                FuncMsg.Error("[联系人]检测失败,请检查待发布内容!\r\n可参考帮助界面中“货源信息模式一”中的内容示例");
                return(false);
            }
            plac = 4;
            DataSource.Add("hy_lxr", args.Substring(idx1 + plac, idx2 - idx1 - plac).Trim());

            idx1 = args.IndexOf("联系电话");
            idx2 = args.IndexOf("备注");
            if (idx2 == idx1 || (idx2 > -1 && idx1 > idx2))
            {
                FuncMsg.Error("[联系电话]检测失败,请检查待发布内容!\r\n可参考帮助界面中“货源信息模式一”中的内容示例");
                return(false);
            }

            var phone  = "";
            var remark = "";

            if (idx2 < 0)
            {
                phone = args.Substring(idx1 + 5).Trim();
            }
            else
            {
                plac  = 4;
                phone = args.Substring(idx1 + plac, idx2 - idx1 - plac).Trim();

                remark = args.Substring(idx2 + 3);
            }
            DataSource.Add("hy_lxdh", phone);
            DataSource.Add("h_conter", remark);

            return(true);
        }
예제 #8
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(richTextBox1.Text))
            {
                FuncMsg.Warn("请输入要发布的内容");
                return;
            }
            ;

            var orders = richTextBox1.Text.Split('\n');

            if (orders.Length < 12)
            {
                FuncMsg.Warn("数据填写不全,请补全后重新提交!");
                return;
            }
            DataSource = new JObject();

            var baseUrl = "http://www.012395.com/e/DoInfo/AddInfo.php?mid=15&enews=MAddInfo&classid=115&Submit=%E6%B7%BB%E5%8A%A0%E4%BF%A1%E6%81%AF";

            var response = ApiClient.AddInfo(baseUrl);

            if (response == FuncConst.AddErr)
            {
                FuncMsg.Error($"{FuncConst.AddErr}\r\n{FuncConst.NetworkErr}");
                return;
            }

            HtmlAgilityPack.HtmlDocument html = new HtmlAgilityPack.HtmlDocument();
            html.LoadHtml(response);

            if (!IsLogin(html))
            {
                return;
            }

            DataSource.Add("enews", GetNodeVal(html, "enews"));
            DataSource.Add("classid", GetNodeVal(html, "classid"));
            DataSource.Add("id", "");
            DataSource.Add("filepass", GetNodeVal(html, "filepass"));
            DataSource.Add("mid", "15");
            DataSource.Add("tokenid", "");

            if (chkSimple.Checked)
            {
                SimpleModel(orders);
            }
            else
            {
                StandardModel(orders);
            }

            var postUrl = "http://www.012395.com/e/DoInfo/ecms.php";

            var result = ApiClient.SaveInfo(postUrl, DataSource);

            if (IsSuccess(result))
            {
                FuncMsg.Info($"货源信息:[{DataSource["title"].ToString()}]发布成功!");
                RefreshLately();
                if (chkSimple.Checked)
                {
                    richTextBox2.Visible = true;
                    SwitchSimpleModel();
                }
                else
                {
                    richTextBox2.Visible = false;
                    SwitchStandardModel();
                }
            }
        }