You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
DS7/JobGuanMaoYun/JobGuanMaoYunInfo.cs

763 lines
37 KiB
C#

using log4net;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Quartz;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Linq;
using System.Text;
using HcUtility.Core;
using HcUtility.Comm;
using System.Data.Entity;
using System.Net;
using System.Text.RegularExpressions;
using System.Xml.Serialization;
using InvokeWebService;
namespace JobGuanMaoYun
{
public class blnopack
{
//private static MBLNOList;
}
public class JobGuanMaoYun : IJob
{
private ILog log = LogManager.GetLogger(typeof(JobGuanMaoYun));
private string connStr { get; set; }
private string userKey { get; set; }
private Int32 StartDays { get; set; }
private Int32 EndDays { get; set; }
//
private Int32 StartTime_single { get; set; }
private Int32 EndTime_single { get; set; }
public void Execute(IJobExecutionContext context)
{
log.Debug($"Execute开始");
try
{
connStr = context.JobDetail.JobDataMap.GetString("ConnectString");
userKey = context.JobDetail.JobDataMap.GetString("userKey");
StartDays = Convert.ToInt32(context.JobDetail.JobDataMap.GetString("StartDays"));
EndDays = Convert.ToInt32(context.JobDetail.JobDataMap.GetString("EndDays"));
StartTime_single = Convert.ToInt32(context.JobDetail.JobDataMap.GetString("StartTime_single"));
EndTime_single = Convert.ToInt32(context.JobDetail.JobDataMap.GetString("EndTime_single"));
log.Debug($"连接字符串:{connStr}");
log.Debug($"起始天数:{StartDays}");
log.Debug($"终止天数:{EndDays}");
//1 读取关贸云数据
//2 解析后向数据库保存
//3 将保存成功的标记为已读
}
catch (Exception ex)
{
log.Error(ex.Message);
log.Error(ex.StackTrace);
}
}
private void DoSendMessage(string mblno)
{
}
public class GMYRequest {
public string serviceName { get; set; }
public Array[] requestContext { get; set; }
public Array[] requestData { get; set; }
public Array[] responseContext { get; set; }
public Array[] responseData { get; set; }
}
public const string url = "http://www.yydy.com/GacoWebService/DyxtService.asmx";
public static object InvokeWebService_GuanMaoYun( GMYRequest requestinfo)
{
return WebServiceHelper.InvokeWebService(url,requestinfo.serviceName, requestinfo.requestContext);
}
#region 调用关贸云webservice接口
static public DBResult SETTLE_QUERY_DATA_HANDLER()
{
var result = new DBResult();
result.Success = true;
var requestinfo = new GMYRequest();
requestinfo.serviceName = "SETTLE_QUERY_DATA_HANDLER";
try
{
//object resultXml = WebServiceHelper.InvokeWebService(url, "SETTLE_QUERY_DATA_HANDLER", args);
//StringReader rdr = new StringReader(resultXml.ToString());
//XmlSerializer serializer = new XmlSerializer(typeof(DAYA));
//DAYA xmlDoc = (DAYA)serializer.Deserialize(rdr);
//if (xmlDoc != null)
//{
// dayatable[] ds = xmlDoc.ds;
// for (int i = 0; i < ds.Length; i++)
// {
// MsOpSeaeDetail data = new MsOpSeaeDetail();
// data.CNTRNO = ds[i].CTNNO;
// data.SEALNO = ds[i].SEALNO;
// data.CTNALL = ds[i].CTNSZ + ds[i].CTNTP;
// try
// {
// if (ds[i].PKGS != "")
// data.PKGS = Convert.ToInt16(ds[i].PKGS);
// }
// catch
// { }
// try
// {
// if (ds[i].ALKWGT != "")
// data.KGS = Convert.ToDecimal(ds[i].ALKWGT);
// }
// catch
// { }
// try
// {
// if (ds[i].ALCUBAGE != "")
// data.CBM = Convert.ToDecimal(ds[i].ALCUBAGE);
// }
// catch
// { }
// try
// {
// if (ds[i].ECTNWT != "")
// data.TAREWEIGHT = Convert.ToDecimal(ds[i].ECTNWT);
// }
// catch
// { }
// bodyList.Add(data);
// }
//}
}
catch
{
result.Success = false;
result.Message = "提取数据过程中发生错误,请联系系统管理员!";
}
//result.Data = bodyList.ToList();
return result;
}
public static long ConvertDateTimeInt(System.DateTime time)
{
//double intResult = 0;
System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1, 0, 0, 0, 0));
//intResult = (time- startTime).TotalMilliseconds;
long t = (time.Ticks - startTime.Ticks) / 10000; //除10000调整为13位
return t;
}
static public DBResult GetDAYAWEBCTNList(string mblno, string bsno, bool isweb = false)
{
var result = new DBResult();
result.Success = true;
//var bodyList = new List<MsOpSeaeDetail>();
//var bodyList3 = new List<MsOpSeaeDetail>();
//MsOpSeaeQDPortDataDAL msd = new MsOpSeaeQDPortDataDAL("");
//try
//{
// string datahtml = "";
// //请求一次页面获取__VIEWSTATE和__EVENTVALIDATION
// HttpHelper http = new HttpHelper();
// HttpResult resulthtml = new HttpResult();
// for (int i = 0; i < 7; i++)
// {
// // TimeSpan ts = DateTime.Now - DateTime.Parse("1970-1-1");
// string strtime = ConvertDateTimeInt(DateTime.Now).ToString();
// Dictionary<string, string> dict = msd.getVerificationCodebygdv(0, "http://www.yydy.com/dyxt/BasicService/CreateCheckCode.aspx?" + strtime);//<string, string> <验证码|错误码, Cookie>
// if (String.IsNullOrEmpty(dict.Keys.First())) continue;
// if (dict.Keys.First().Length != 4)
// {
// if (dict.Keys.First() == "14")
// result.Message = "IAM鉴权失败,请检查业务参数配置PARAMNAMECLOUDBAIDUOCRApi、CLOUDBAIDUOCRSec";
// else if (dict.Keys.First() == "17")
// result.Message = "每日请求量超出限额,请在业务参数中更新百度云ApiKey及SecretKey";
// else
// result.Message = "提取数据出错,错误码:" + dict.Keys.First();
// result.Success = false;
// return result;
// }
// //ts = DateTime.Now - DateTime.Parse("1970-1-1");
// strtime = ConvertDateTimeInt(DateTime.Now).ToString();
// HttpItem item = new HttpItem()
// {
// URL = "http://www.yydy.com/dyxt/BasicService/QueryService.aspx?" + strtime + "&oper=QueryByBill&param=" + mblno + "&CheckCode=" + dict.Keys.First(),
// // ContentType = "application/x-www-form-urlencoded",
// Method = "GET",
// Host = "www.yydy.com",
// // Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
// // UserAgent = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.170 Safari/537.36",
// Cookie = dict.Values.First(),
// ResultType = ResultType.Byte
// };
// if (http.GetHtml(item).Html == "OK")
// {
// // item = new HttpItem()
// // {
// // // URL = "http://www.yydy.com/dyxt/Query/QueryMainFrame.aspx?type=B&value=" + mblno+"&code="+ dict.Keys.First(),//URL这里都是测试 必需项
// // URL = "http://www.yydy.com/dyxt/Query/ExportByBill.aspx?s_no=" + mblno,
// // // ContentType = "application/x-www-form-urlencoded",
// //// Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
// // Host = "www.yydy.com",
// // // UserAgent = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.170 Safari/537.36",
// // Method = "GET",
// // Cookie = dict.Values.First()
// // };
// //datahtml = http.GetHtml(item).Html;
// string whlURL = "http://www.yydy.com/dyxt/Query/ExportByBill.aspx?s_no=" + mblno;
// WebRequest request = WebRequest.Create(whlURL);
// request.Method = "GET";
// request.Headers.Add("Cookie", dict.Values.First());
// HttpWebResponse response = (HttpWebResponse)request.GetResponse();
// string url = response.ResponseUri.AbsoluteUri;
// StreamReader reader = new StreamReader(response.GetResponseStream());
// string content = reader.ReadToEnd();
// datahtml = content;
// break;
// }
// }
// //移除多余部分
// var datahtml1 = datahtml.Remove(0, datahtml.IndexOf("$('#myBillTable tbody').html"));//提单信息
// datahtml1 = datahtml1.Remove(datahtml1.IndexOf("</script><script>$('#partBillTable tbody').html"));
// datahtml1 = new Regex(@"<tr.+</tr>").Match(datahtml1).Value;
// datahtml1 = new Regex(@"(?<=tr)[\w\s=\'\(\);]+").Replace(datahtml1, "");//去除tr 属性
// datahtml1 = new Regex(@"(?<=td)[\s\w=\':;]+").Replace(datahtml1, "");//去掉td 属性
// var datahtml2 = datahtml.Remove(0, datahtml.IndexOf("$('#partBillTable tbody').html"));//箱及分单信息
// datahtml2 = datahtml2.Remove(datahtml2.IndexOf("</script>"));
// datahtml2 = new Regex(@"<tr.+</tr>").Match(datahtml2).Value;
// datahtml2 = new Regex(@"(?<=tr)[\w\s=\'\(\);]+").Replace(datahtml2, "");//去除tr 属性
// datahtml2 = new Regex(@"(?<=td)[\s\w=\':;]+").Replace(datahtml2, "");//去掉td 属性
// if (isweb == true)
// {
// result.Data = "<table><thead><th>船名</th><th>航次</th><th>装船时间</th><th>提单</th></thead><tbody>" + datahtml1 + "</tbody></table><br/>" +
// "<table><thead><th>分单号</th><th>箱号</th><th>铅封号</th><th>箱型</th><th>件</th><th>包装</th><th>重</th><th>尺</th></thead><tbody>" + datahtml2 + "</tbody></table>";
// }
// else
// {
// var trList1 = datahtml1.Split(new string[] { "<tr>", "</tr>" }, StringSplitOptions.RemoveEmptyEntries).ToList();//按tr分组
// var VESSEL = "";
// var VOYNO = "";
// if (trList1.Count > 0)
// {
// var tdList = trList1[0].Split(new string[] { "<td>", "</td>" }, StringSplitOptions.RemoveEmptyEntries).ToList();//按td分组
// VESSEL = tdList[0];
// VOYNO = tdList[1];
// }
// var trList2 = datahtml2.Split(new string[] { "<tr>", "</tr>" }, StringSplitOptions.RemoveEmptyEntries).ToList();//按tr分组
// trList2.RemoveAt(trList2.Count - 1);
// foreach (var item in trList2)
// {
// var tdList = item.Replace("<td></td>", "<td>" + mblno + "</td>").Split(new string[] { "<td>", "</td>" }, StringSplitOptions.RemoveEmptyEntries).ToList();//按td分组
// if (tdList[0].Contains("此票总计"))
// continue;
// MsOpSeaeDetail data = new MsOpSeaeDetail();
// data.BSNO = mblno;
// data.CTNNUM = 1;//箱量
// data.CNTRNO = tdList[1];
// data.CBM = Convert.ToDecimal(tdList[7]);
// data.CTNALL = tdList[3];
// data.KGS = Convert.ToDecimal(tdList[6]);
// data.PKGS = Convert.ToInt32(tdList[4]);
// data.VESSEL = VESSEL;
// data.VOYNO = VOYNO;
// data.SEALNO = tdList[2];
// bodyList.Add(data);
// }
// bodyList = SumBodyList(bodyList);
// result.Data = bodyList.ToList();
// }
//}
//catch (Exception ex)
//{
// //return GetDAYAWEBCTNList2(mblno, bsno, isweb);
//}
return result;
}
#endregion
#region (远洋)大亚场站
/*
static public DBResult GetDAYACTNList(string mblno, string bsno, string username, string password, bool isweb = false)
{
var result = new DBResult();
result.Success = true;
var bodyList = new List<MsOpSeaeDetail>();
try
{
string url = "http://www.yydy.com/GacoWebService/DyxtService.asmx";
string[] args = new string[5];
args[0] = username;
args[1] = password;
args[2] = mblno;
args[3] = "";
args[4] = "1";
object resultXml = WebServiceHelper.InvokeWebService(url, "GetBackFCtnInfoXml", args);
StringReader rdr = new StringReader(resultXml.ToString());
XmlSerializer serializer = new XmlSerializer(typeof(DAYA));
DAYA xmlDoc = (DAYA)serializer.Deserialize(rdr);
if (xmlDoc != null)
{
dayatable[] ds = xmlDoc.ds;
for (int i = 0; i < ds.Length; i++)
{
MsOpSeaeDetail data = new MsOpSeaeDetail();
data.CNTRNO = ds[i].CTNNO;
data.SEALNO = ds[i].SEALNO;
data.CTNALL = ds[i].CTNSZ + ds[i].CTNTP;
try
{
if (ds[i].PKGS != "")
data.PKGS = Convert.ToInt16(ds[i].PKGS);
}
catch
{ }
try
{
if (ds[i].ALKWGT != "")
data.KGS = Convert.ToDecimal(ds[i].ALKWGT);
}
catch
{ }
try
{
if (ds[i].ALCUBAGE != "")
data.CBM = Convert.ToDecimal(ds[i].ALCUBAGE);
}
catch
{ }
try
{
if (ds[i].ECTNWT != "")
data.TAREWEIGHT = Convert.ToDecimal(ds[i].ECTNWT);
}
catch
{ }
bodyList.Add(data);
}
}
}
catch
{
result.Success = false;
result.Message = "提取数据过程中发生错误,请联系系统管理员!";
}
result.Data = bodyList.ToList();
return result;
}
public static long ConvertDateTimeInt(System.DateTime time)
{
//double intResult = 0;
System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1, 0, 0, 0, 0));
//intResult = (time- startTime).TotalMilliseconds;
long t = (time.Ticks - startTime.Ticks) / 10000; //除10000调整为13位
return t;
}
//(远洋)大亚场站//COAU7054586970
//static public DBResult GetDAYAWEBCTNList2(string mblno, string bsno, bool isweb = false)
//{
// //var result = new DBResult();
// //result.Success = true;
// //var bodyList = new List<MsOpSeaeDetail>();
// //var bodyList3 = new List<MsOpSeaeDetail>();
// //MsOpSeaeQDPortDataDAL msd = new MsOpSeaeQDPortDataDAL("");
// //try
// //{
// // string datahtml = "";
// // //请求一次页面获取__VIEWSTATE和__EVENTVALIDATION
// // HttpHelper http = new HttpHelper();
// // HttpResult resulthtml = new HttpResult();
// // DataMining dm = new DataMining();
// // datahtml = dm.GetHTMLWithMBLNO(mblno);
// // if (isweb == true)
// // {
// // datahtml = datahtml.Replace("../CSS/Style1.css", "http://www.yydy.com/dyxt/CSS/Style.css");
// // datahtml = datahtml.Replace("../JS/jquery-1.9.1.min.js", "http://www.yydy.com/dyxt/JS/jquery-1.9.1.min.js");
// // datahtml = datahtml.Replace("../JS/basicFun.js", "http://www.yydy.com/dyxt/CSS/GridViewStyle.css/JS/basicFun.js");
// // datahtml = datahtml.Replace("../JS/Query/ExportByBill.js", "http://www.yydy.com/dyxt/CSS/GridViewStyle.css/JS/Query/ExportByBill.js");
// // result.Data = datahtml;
// // }
// // else
// // {
// // var datahtml3 = GetDataHtmlList(datahtml, "GridView1", "</table>");
// // if (datahtml3 != "")
// // {
// // #region 船名航次信息
// // var i = 1;
// // while (datahtml3.IndexOf("</tr>") >= 0)
// // {
// // var datalength = datahtml3.IndexOf("</tr>");
// // var recdatastr = datahtml3.Substring(0, datalength + 5);
// // datahtml3 = datahtml3.Substring(datalength + 5, datahtml3.Length - datalength - 5);
// // recdatastr = recdatastr.Remove(0, recdatastr.IndexOf("<tr") + 3);
// // recdatastr = recdatastr.Remove(recdatastr.IndexOf("</tr>"), 5);
// // var fieldno = 1;
// // if (i != 1)
// // {
// // MsOpSeaeDetail data = new MsOpSeaeDetail();
// // data.BSNO = bsno;//业务编号
// // data.CTNNUM = 1;//箱量
// // while (recdatastr.IndexOf("<td") >= 0)
// // {
// // var fieldlength = recdatastr.IndexOf("</td>");
// // var fielddatastr = recdatastr.Substring(0, fieldlength + 5);
// // recdatastr = recdatastr.Substring(fieldlength + 5, recdatastr.Length - fieldlength - 5);
// // fielddatastr = fielddatastr.Remove(fielddatastr.IndexOf("</td>"), 5);
// // fielddatastr = fielddatastr.Remove(0, fielddatastr.IndexOf(">") + 1);
// // fielddatastr = fielddatastr.Replace("\r\n", "");
// // //fielddatastr = fielddatastr.Replace(" ", "");
// // fielddatastr = fielddatastr.Replace("\t", "");
// // if (fieldno == 2)
// // {
// // data.VOYNO = fielddatastr;
// // }
// // if (fieldno == 3)
// // {
// // data.VESSEL = fielddatastr;
// // }
// // fieldno = fieldno + 1;
// // }
// // bodyList3.Add(data);
// // }
// // i = i + 1;
// // }
// // #endregion
// // }
// // //
// // var datahtml2 = GetDataHtmlList(datahtml, "GridView8", "</table>");
// // if (datahtml2 != "")
// // {
// // #region 实装箱信息
// // var i = 1;
// // while (datahtml2.IndexOf("</tr>") >= 0)
// // {
// // var datalength = datahtml2.IndexOf("</tr>");
// // var recdatastr = datahtml2.Substring(0, datalength + 5);
// // datahtml2 = datahtml2.Substring(datalength + 5, datahtml2.Length - datalength - 5);
// // recdatastr = recdatastr.Remove(0, recdatastr.IndexOf("<tr") + 3);
// // recdatastr = recdatastr.Remove(recdatastr.IndexOf("</tr>"), 5);
// // var fieldno = 1;
// // var istrue = false;
// // if (i != 1)
// // {
// // MsOpSeaeDetail data = new MsOpSeaeDetail();
// // data.BSNO = bsno;//业务编号
// // data.CTNNUM = 1;//箱量
// // while (recdatastr.IndexOf("<td") >= 0)
// // {
// // var fieldlength = recdatastr.IndexOf("</td>");
// // var fielddatastr = recdatastr.Substring(0, fieldlength + 5);
// // recdatastr = recdatastr.Substring(fieldlength + 5, recdatastr.Length - fieldlength - 5);
// // fielddatastr = fielddatastr.Remove(fielddatastr.IndexOf("</td>"), 5);
// // fielddatastr = fielddatastr.Remove(0, fielddatastr.IndexOf(">") + 1);
// // fielddatastr = fielddatastr.Replace("\r\n", "");
// // fielddatastr = fielddatastr.Replace(" ", "");
// // fielddatastr = fielddatastr.Replace("\t", "");
// // if (fieldno == 2)
// // {
// // fielddatastr = fielddatastr.Remove(0, fielddatastr.IndexOf(">") + 1);
// // fielddatastr = fielddatastr.Remove(fielddatastr.IndexOf("</a>"), 4);
// // if (fielddatastr == "" || fielddatastr == "<bstyle=\"color:Red\">暂无相关数据</b>") istrue = false; else istrue = true;
// // data.CNTRNO = fielddatastr;
// // foreach (var enumValue in bodyList3)
// // {
// // data.VESSEL = enumValue.VESSEL;
// // data.VOYNO = enumValue.VOYNO;
// // }
// // }
// // if (fieldno == 4)
// // {
// // data.CTNALL = fielddatastr;
// // }
// // if (fieldno == 6)
// // {
// // try
// // {
// // data.TAREWEIGHT = Convert.ToDecimal(fielddatastr);
// // }
// // catch
// // { }
// // }
// // if (fieldno == 7)
// // {
// // data.SEALNO = fielddatastr;
// // }
// // if (fieldno == 8)
// // {
// // data.KINDPKGS = fielddatastr;
// // }
// // if (fieldno == 9)
// // {
// // try
// // {
// // fielddatastr = fielddatastr.Remove(fielddatastr.IndexOf(".000"), 4);
// // data.PKGS = Convert.ToInt32(fielddatastr);
// // }
// // catch
// // {
// // data.PKGS = 0;
// // }
// // }
// // if (fieldno == 10)
// // {
// // try
// // {
// // data.KGS = Convert.ToDecimal(fielddatastr);
// // }
// // catch
// // {
// // data.KGS = 0;
// // }
// // }
// // if (fieldno == 11)
// // {
// // try
// // {
// // data.CBM = Convert.ToDecimal(fielddatastr);
// // }
// // catch
// // {
// // data.CBM = 0;
// // }
// // }
// // fieldno = fieldno + 1;
// // }
// // if (istrue)
// // bodyList.Add(data);
// // }
// // i = i + 1;
// // }
// // #endregion
// // }
// // else
// // {
// // result.Success = false;
// // result.Message = "未重箱回场,请稍后重试!";
// // return result;
// // }
// // if (bodyList.Count == 0)
// // {
// // bodyList = bodyList3;
// // }
// // bodyList = SumBodyList(bodyList);
// // result.Data = bodyList.ToList();
// // }
// //}
// //catch (Exception e)
// //{
// // result.Success = false;
// // result.Message = "未提取到数据!";
// //}
// //return result;
//}
static public DBResult GetDAYAWEBCTNList(string mblno, string bsno, bool isweb = false)
{
var result = new DBResult();
result.Success = true;
var bodyList = new List<MsOpSeaeDetail>();
var bodyList3 = new List<MsOpSeaeDetail>();
MsOpSeaeQDPortDataDAL msd = new MsOpSeaeQDPortDataDAL("");
try
{
string datahtml = "";
//请求一次页面获取__VIEWSTATE和__EVENTVALIDATION
HttpHelper http = new HttpHelper();
HttpResult resulthtml = new HttpResult();
for (int i = 0; i < 7; i++)
{
// TimeSpan ts = DateTime.Now - DateTime.Parse("1970-1-1");
string strtime = ConvertDateTimeInt(DateTime.Now).ToString();
Dictionary<string, string> dict = msd.getVerificationCodebygdv(0, "http://www.yydy.com/dyxt/BasicService/CreateCheckCode.aspx?" + strtime);//<string, string> <验证码|错误码, Cookie>
if (String.IsNullOrEmpty(dict.Keys.First())) continue;
if (dict.Keys.First().Length != 4)
{
if (dict.Keys.First() == "14")
result.Message = "IAM鉴权失败,请检查业务参数配置PARAMNAMECLOUDBAIDUOCRApi、CLOUDBAIDUOCRSec";
else if (dict.Keys.First() == "17")
result.Message = "每日请求量超出限额,请在业务参数中更新百度云ApiKey及SecretKey";
else
result.Message = "提取数据出错,错误码:" + dict.Keys.First();
result.Success = false;
return result;
}
//ts = DateTime.Now - DateTime.Parse("1970-1-1");
strtime = ConvertDateTimeInt(DateTime.Now).ToString();
HttpItem item = new HttpItem()
{
URL = "http://www.yydy.com/dyxt/BasicService/QueryService.aspx?" + strtime + "&oper=QueryByBill&param=" + mblno + "&CheckCode=" + dict.Keys.First(),
// ContentType = "application/x-www-form-urlencoded",
Method = "GET",
Host = "www.yydy.com",
// Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,* /*;q=0.8",
// UserAgent = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.170 Safari/537.36",
Cookie = dict.Values.First(),
ResultType = ResultType.Byte
};
if (http.GetHtml(item).Html == "OK")
{
// item = new HttpItem()
// {
// // URL = "http://www.yydy.com/dyxt/Query/QueryMainFrame.aspx?type=B&value=" + mblno+"&code="+ dict.Keys.First(),//URL这里都是测试 必需项
// URL = "http://www.yydy.com/dyxt/Query/ExportByBill.aspx?s_no=" + mblno,
// // ContentType = "application/x-www-form-urlencoded",
//// Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,* /*;q=0.8",
// Host = "www.yydy.com",
// // UserAgent = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.170 Safari/537.36",
// Method = "GET",
// Cookie = dict.Values.First()
// };
//datahtml = http.GetHtml(item).Html;
string whlURL = "http://www.yydy.com/dyxt/Query/ExportByBill.aspx?s_no=" + mblno;
WebRequest request = WebRequest.Create(whlURL);
request.Method = "GET";
request.Headers.Add("Cookie", dict.Values.First());
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
string url = response.ResponseUri.AbsoluteUri;
StreamReader reader = new StreamReader(response.GetResponseStream());
string content = reader.ReadToEnd();
datahtml = content;
break;
}
}
//移除多余部分
var datahtml1 = datahtml.Remove(0, datahtml.IndexOf("$('#myBillTable tbody').html"));//提单信息
datahtml1 = datahtml1.Remove(datahtml1.IndexOf("</script><script>$('#partBillTable tbody').html"));
datahtml1 = new Regex(@"<tr.+</tr>").Match(datahtml1).Value;
datahtml1 = new Regex(@"(?<=tr)[\w\s=\'\(\);]+").Replace(datahtml1, "");//去除tr 属性
datahtml1 = new Regex(@"(?<=td)[\s\w=\':;]+").Replace(datahtml1, "");//去掉td 属性
var datahtml2 = datahtml.Remove(0, datahtml.IndexOf("$('#partBillTable tbody').html"));//箱及分单信息
datahtml2 = datahtml2.Remove(datahtml2.IndexOf("</script>"));
datahtml2 = new Regex(@"<tr.+</tr>").Match(datahtml2).Value;
datahtml2 = new Regex(@"(?<=tr)[\w\s=\'\(\);]+").Replace(datahtml2, "");//去除tr 属性
datahtml2 = new Regex(@"(?<=td)[\s\w=\':;]+").Replace(datahtml2, "");//去掉td 属性
if (isweb == true)
{
result.Data = "<table><thead><th>船名</th><th>航次</th><th>装船时间</th><th>提单</th></thead><tbody>" + datahtml1 + "</tbody></table><br/>" +
"<table><thead><th>分单号</th><th>箱号</th><th>铅封号</th><th>箱型</th><th>件</th><th>包装</th><th>重</th><th>尺</th></thead><tbody>" + datahtml2 + "</tbody></table>";
}
else
{
var trList1 = datahtml1.Split(new string[] { "<tr>", "</tr>" }, StringSplitOptions.RemoveEmptyEntries).ToList();//按tr分组
var VESSEL = "";
var VOYNO = "";
if (trList1.Count > 0)
{
var tdList = trList1[0].Split(new string[] { "<td>", "</td>" }, StringSplitOptions.RemoveEmptyEntries).ToList();//按td分组
VESSEL = tdList[0];
VOYNO = tdList[1];
}
var trList2 = datahtml2.Split(new string[] { "<tr>", "</tr>" }, StringSplitOptions.RemoveEmptyEntries).ToList();//按tr分组
trList2.RemoveAt(trList2.Count - 1);
foreach (var item in trList2)
{
var tdList = item.Replace("<td></td>", "<td>" + mblno + "</td>").Split(new string[] { "<td>", "</td>" }, StringSplitOptions.RemoveEmptyEntries).ToList();//按td分组
if (tdList[0].Contains("此票总计"))
continue;
MsOpSeaeDetail data = new MsOpSeaeDetail();
data.BSNO = mblno;
data.CTNNUM = 1;//箱量
data.CNTRNO = tdList[1];
data.CBM = Convert.ToDecimal(tdList[7]);
data.CTNALL = tdList[3];
data.KGS = Convert.ToDecimal(tdList[6]);
data.PKGS = Convert.ToInt32(tdList[4]);
data.VESSEL = VESSEL;
data.VOYNO = VOYNO;
data.SEALNO = tdList[2];
bodyList.Add(data);
}
bodyList = SumBodyList(bodyList);
result.Data = bodyList.ToList();
}
}
catch (Exception ex)
{
//return GetDAYAWEBCTNList2(mblno, bsno, isweb);
}
return result;
}
*/
#endregion
}
}