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/DSWeb/Areas/MvcShipping/DAL/MsOpSeae/MsOpSeaeYardDAL.cs

9604 lines
530 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using System;
using System.Net;
using System.Data;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Web;
using System.Drawing;
using System.Data.SqlClient;
using System.IO;
using System.Xml;
using System.Xml.Serialization;
using System.Linq;
using DotNet4.Utilities;
using InvokeWebService;
using Microsoft.Practices.EnterpriseLibrary.Data;
using HcUtility.Comm;
using HcUtility.Core;
using DSWeb.EntityDA;
using DSWeb.Areas.CommMng.Models;
using DSWeb.Areas.CommMng.DAL;
using DSWeb.Areas.MvcShipping.DAL.MsOpSeaeQDPortDataDAL;
using DSWeb.DataAccess;
using DSWeb.MvcShipping.Models.MsOpSeae;
using DSWeb.MvcShipping.Models.MsOpSeaeYard;
using DSWeb.MvcShipping.Models.MsOpSeaeBill;
using DSWeb.MvcShipping.Models.CompanyDef;
using DSWeb.MvcShipping.Models.FtpSet;
using DSWeb.MvcShipping.DAL.MsCodeYardDataSet;
using DSWeb.MvcShipping.DAL.YARDCTNXML;
using DSWeb.MvcShipping.DAL.MsSysParamSet;
using DSWeb.MvcShipping.DAL.MsOpSeaeDAL;
using DSWeb.MvcShipping.Helper;
using Spire.Pdf;
using Newtonsoft.Json.Linq;
using System.Web.Configuration;
using static DSWeb.Areas.CommMng.DAL.BasicDataRefDAL;
namespace DSWeb.MvcShipping.DAL.MsOpSeaeYardDAL
{
public class MsOpSeaeYardDAL
{
static public string GetPortEDICodeByEname(string port, string EDINAME = "")
{
string EDICODE = "";
var strSql = new StringBuilder();
if (EDINAME == "")
strSql.Append("select EDICODE from code_disport where PORT='" + port + "'");
else
strSql.Append("select EDICODE from code_disport_edi where PORTDISCHARGE='" + port + "' AND EDINAME='" + EDINAME + "'");
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
EDICODE = Convert.ToString(reader["EDICODE"]).Trim();
}
reader.Close();
}
if (EDICODE.Trim() == "" && EDINAME != "")
{
var strSql2 = new StringBuilder();
strSql2.Append("select EDICODE from code_disport where PORT='" + port + "' ");
db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql2.ToString()))
{
while (reader.Read())
{
EDICODE = Convert.ToString(reader["EDICODE"]).Trim();
}
reader.Close();
}
}
return EDICODE;
}
#region 提取中远BC PDF
static public DBResult GetCOSCO_BC_PDF(string pdffile, Stream fileStream)
{
var result = new DBResult();
var strMsg = "";
try
{
PdfDocument doc = new PdfDocument();
// Load the PDF Document
doc.LoadFromFile(pdffile);
// String for hold the extracted text
BC_ExcelInfo BC = new BC_ExcelInfo(pdffile);
StringBuilder buffer = new StringBuilder();
int i = 0;
foreach (PdfPageBase page in doc.Pages)
{
buffer.Append(page.ExtractText());
i++;
}
doc.Close();
var BCStr = buffer.ToString();
if (BCStr != "")
{
MsOpSeae head = null;
head = new MsOpSeae();
head.MBLNO = GetDataHtmlList(BCStr, "订舱号:", Environment.NewLine).Trim();
//var VESSELVOY = GetDataHtmlList(BCStr, "船名/航次:", Environment.NewLine).Trim();
//var vesselindex = VESSELVOY.LastIndexOf(" ");
//head.VESSEL = VESSELVOY.Substring(0, vesselindex).Trim();
//head.VOYNO = VESSELVOY.Substring(vesselindex+1).Trim();
head.VESSEL = BC.GetValue("船名");
head.VOYNO = BC.GetValue("航次");
head.ETD = BC.GetValue("ETD");
head.ETA = BC.GetValue("ETA");
head.PLACERECEIPT = GetDataHtmlList(BCStr, "接货地:", Environment.NewLine).ToUpper().Trim();
head.PLACEDELIVERY = GetDataHtmlList(BCStr, "交货地:", Environment.NewLine).ToUpper().Trim();
head.YARD = GetDataHtmlList(BCStr, "提箱点:", "提箱校验码:").Trim();
head.APPLYNO = GetDataHtmlList(BCStr, "提箱校验码:", Environment.NewLine).Trim();
head.CLOSEDOCDATE = GetDataHtmlList(BCStr, "样单截单时间:", Environment.NewLine).Trim();
head.CLOSINGDATE = GetDataHtmlList(BCStr, "截港时间:", Environment.NewLine).Trim();
head.PLACERECEIPTID = GetPortEDICodeByEname(head.PLACERECEIPT);
head.PLACEDELIVERYID = GetPortEDICodeByEname(head.PLACEDELIVERY);
try
{
var goodsname = GetDataHtmlList(buffer.ToString(), "Sub. Equip Gross Weight", "Intended Schedule Plan");
goodsname = goodsname.Substring(goodsname.IndexOf(Environment.NewLine) + 1);
goodsname = goodsname.Substring(0, goodsname.LastIndexOf(Environment.NewLine));
goodsname = goodsname.Substring(44, 33).Trim();
head.GOODSNAME = goodsname.ToUpper();
}
catch
{
head.GOODSNAME = "";
}
result.Data = head;
result.Success = true;
}
else
{
result.Success = false;
result.Message = "未提取到相关数据,请检查PDF文件是否正确";
}
}
catch (Exception e)
{
result.Success = false;
result.Message = $"提取数据过程中发生错误[{e.Message}],请联系系统管理员!";
}
return result;
}
#endregion
#region 提取天津中远BC PDF
static public DBResult GetTianJinCOSCO_BC_PDF(string pdffile)
{
var result = new DBResult();
try
{
PdfDocument doc = new PdfDocument();
// Load the PDF Document
doc.LoadFromFile(pdffile);
// String for hold the extracted text
StringBuilder buffer = new StringBuilder();
int i = 0;
foreach (PdfPageBase page in doc.Pages)
{
buffer.Append(page.ExtractText());
i++;
}
doc.Close();
var BCStr = buffer.ToString();
if (BCStr != "")
{
MsOpSeae head = null;
head = new MsOpSeae();
head.MBLNO = GetDataHtmlList(BCStr, "订舱号:", Environment.NewLine).Trim();
//订舱编号
string orderno = head.MBLNO.Substring(4);
head.ORDERNO = orderno;
var VESSELVOY = GetDataHtmlList(BCStr, "船名/航次:", Environment.NewLine).Trim();
var vesselindex = VESSELVOY.LastIndexOf(" ");
head.VESSEL = VESSELVOY.Substring(0, vesselindex).Trim();
head.VOYNO = VESSELVOY.Substring(vesselindex + 1).Trim();
head.PORTLOAD = GetDataHtmlList(BCStr, "接货地:", Environment.NewLine).ToUpper().Trim();
head.PLACEDELIVERY = GetDataHtmlList(BCStr, "交货地:", Environment.NewLine).ToUpper().Trim();
head.APPLYNO = GetDataHtmlList(BCStr, "提箱校验码:", Environment.NewLine).Trim();
head.CLOSEDOCDATE = GetDataHtmlList(BCStr, "样单截单时间:", Environment.NewLine).Trim();
head.CLOSINGDATE = GetDataHtmlList(BCStr, "截港时间:", Environment.NewLine).Trim();
//head.PLACERECEIPTID = GetPortEDICodeByEname(head.PLACERECEIPT);
//head.PLACEDELIVERYID = GetPortEDICodeByEname(head.PLACEDELIVERY);
string etdstr = GetDataHtmlList(BCStr, "船舶预计开航时间:", Environment.NewLine).Trim();
DateTime dtEtd = DateTime.Parse(etdstr);
head.ETD = dtEtd.ToString("yyyy-MM-dd");
result.Data = head;
result.Success = true;
}
else
{
result.Success = false;
result.Message = "未提取到相关数据,请检查PDF文件是否正确";
}
}
catch
{
result.Success = false;
result.Message = "提取数据过程中发生错误,请联系系统管理员!";
}
return result;
}
#endregion
#region 长荣BCPDF
static public DBResult GetCHANGRONG_BC_PDF(string pdffile)
{
var result = new DBResult();
try
{
PdfDocument doc = new PdfDocument();
// Load the PDF Document
doc.LoadFromFile(pdffile);
// String for hold the extracted text
StringBuilder buffer = new StringBuilder();
int i = 0;
foreach (PdfPageBase page in doc.Pages)
{
buffer.Append(page.ExtractText());
i++;
}
doc.Close();
var BCStr = buffer.ToString();
if (BCStr != "")
{
MsOpSeae head = null;
head = new MsOpSeae();
head.MBLNO = GetDataHtmlList(BCStr, "订舱号码):", "APPLICATION").Trim();
try
{
string yardtelstr = GetDataHtmlList(BCStr, "空箱提领处 :", "重箱返还处").Trim();
yardtelstr = yardtelstr.Replace("\r\n", "$");
string[] teltemp = yardtelstr.Split('$');
head.YARDTEL = teltemp[teltemp.Length - 1].Trim();
}
catch (Exception)
{
}
head.ETD = GetDataHtmlList(BCStr, "ETD DATE", Environment.NewLine).ToString().Replace(" :","").Trim();
head.ETD = head.ETD.Replace("/", "-");
var VESSELVOY = GetDataHtmlList(BCStr, "VESSEL/VOYAGE(船名/航次):", Environment.NewLine).Trim();
var vesselindex = VESSELVOY.LastIndexOf(" ");
head.VESSEL = VESSELVOY.Substring(0, vesselindex).Trim();
head.VOYNO = VESSELVOY.Substring(vesselindex + 1).Trim();
head.PLACERECEIPT = GetDataHtmlList(BCStr, "收货地):", Environment.NewLine).ToUpper().Trim();
head.PLACEDELIVERY = GetDataHtmlList(BCStr, "交货地):", Environment.NewLine).ToUpper().Trim();
head.YARD = GetDataHtmlList(BCStr, "空箱提领处 :", Environment.NewLine).Trim();
// head.APPLYNO = GetDataHtmlList(BCStr, "提箱校验码:", Environment.NewLine).Trim();
string CLOSINGDATE = "";
string CLOSEDOCDATE = "";
try
{
string temp = GetDataHtmlList(BCStr, "截关时间", Environment.NewLine).ToString().Replace(" :", "").Trim();
temp = temp.Replace("/", "-");
DateTime dt = DateTime.Parse(temp);
CLOSINGDATE = dt.ToString("yyyy-MM-dd hh:mm:ss");
string temp2 = GetDataHtmlList(BCStr, "提单补料截止时间", Environment.NewLine).ToString().Replace(" :", "").Trim();
temp2 = temp2.Replace("/", "-");
DateTime dt2 = DateTime.Parse(temp2);
CLOSEDOCDATE = dt2.ToString("yyyy-MM-dd hh:mm:ss");
}
catch (Exception)
{
throw;
}
head.CLOSINGDATE = CLOSINGDATE;
head.CLOSEDOCDATE = CLOSEDOCDATE;
head.PLACERECEIPTID = GetPortEDICodeByEname(head.PLACERECEIPT);
head.PLACEDELIVERYID = GetPortEDICodeByEname(head.PLACEDELIVERY);
try
{
var goodsname = GetDataHtmlList(BCStr, "货物品名)", Environment.NewLine).ToString().Replace(" :", "").Trim(); ;
if (goodsname.Contains("PURCHASE NUMBER"))
{
goodsname = goodsname.Substring(0, goodsname.IndexOf("PURCHASE NUMBER"));
}
head.GOODSNAME = goodsname.ToUpper();
}
catch
{
head.GOODSNAME = "";
}
result.Data = head;
result.Success = true;
}
else
{
result.Success = false;
result.Message = "未提取到相关数据,请检查PDF文件是否正确";
}
}
catch
{
result.Success = false;
result.Message = "提取数据过程中发生错误,请联系系统管理员!";
}
return result;
}
#endregion
#region 马士基BC PDF
static public DBResult GetMaersk_BC_PDF_New(string pdffile)
{
var result = new DBResult();
try
{
PdfDocument doc = new PdfDocument();
// Load the PDF Document
doc.LoadFromFile(pdffile);
// String for hold the extracted text
StringBuilder buffer = new StringBuilder();
int i = 0;
foreach (PdfPageBase page in doc.Pages)
{
buffer.Append(page.ExtractText());
i++;
}
doc.Close();
var BCStr = buffer.ToString();
if (BCStr != "")
{
MsOpSeae head = null;
head = new MsOpSeae();
head.MBLNO = GetDataHtmlList(BCStr, "Booking No.: ", " ").ToUpper().Trim();
BC_ExcelInfo BC = new BC_ExcelInfo(pdffile);
//var VESSELVOY = GetDataHtmlList(BCStr, "船名/航次(Vessel/Voyage):", Environment.NewLine).Trim();
//if (VESSELVOY=="")
//{
// VESSELVOY = GetDataHtmlList(BCStr, "船名/航次(Vessel): ", Environment.NewLine).Trim();
//}
//if (VESSELVOY != "")
//{
// var vesselindex = VESSELVOY.LastIndexOf("/");
// head.VESSEL = VESSELVOY.Substring(0, vesselindex).Trim();
// head.VOYNO = VESSELVOY.Substring(vesselindex + 1).Trim();
// if (head.VESSEL.IndexOf("(")>0) head.VESSEL = head.VESSEL.Substring(0, head.VESSEL.IndexOf("(")).Trim();
//}
head.VESSEL = BC.GetValue("船名");
head.VOYNO = BC.GetValue("航次");
head.PORTLOAD = GetDataHtmlList(BCStr, "收货地: ", Environment.NewLine).ToUpper().Trim();
head.PLACEDELIVERY = GetDataHtmlList(BCStr, "交货地:", Environment.NewLine).ToUpper().Trim();
//string etdstr = GetDataHtmlList(BCStr, "开港时间(CY Open): ", "(").Trim();
//if (etdstr=="")
//{
// etdstr = GetDataHtmlList(BCStr, "开港时间(CY open): ", "(").Trim();
//}
//if (etdstr != "")
//{
// DateTime dtEtd = DateTime.Parse(etdstr);
// head.ETD = dtEtd.ToString("yyyy-MM-dd");
//}
head.ETD = BC.GetValue("ETD");
head.ETA = BC.GetValue("ETA");
string jiegangshijian = GetDataHtmlList(BCStr, "截载时间(CY cut off)/VGM Submission Deadline:", "(").Trim();
if (jiegangshijian == "")
{
jiegangshijian = GetDataHtmlList(BCStr, "截港时间(CY cut off)/VGM Submission Deadline", "(").Trim();
}
if (jiegangshijian == "")
{
jiegangshijian = GetDataHtmlList(BCStr, "截载时间(CY cut off):", "(").Trim();
}
if (jiegangshijian != "")
{
DateTime dtJGSJ = DateTime.Parse(jiegangshijian);
head.CLOSINGDATE = dtJGSJ.ToString("yyyy-MM-dd HH:mm:ss");
}
string jiedanshijian = GetDataHtmlList(BCStr, "样单截至时间(SI Cutoff):", Environment.NewLine).Trim();
if (jiedanshijian == "")
{
jiedanshijian = GetDataHtmlList(BCStr, "样单截止时间(SI cut off): ", Environment.NewLine).Trim();
}
if (jiedanshijian == "")
{
jiedanshijian = GetDataHtmlList(BCStr, "样单截至时间(SI Cutoff) / MCC VGM截止时间:", Environment.NewLine).Trim();
}
if (jiedanshijian != "")
{
DateTime dtJDSJ = DateTime.Parse(jiedanshijian);
head.CLOSEDOCDATE = dtJDSJ.ToString("yyyy-MM-dd HH:mm:ss");
}
head.PLACERECEIPTID = GetPortEDICodeByEname(head.PLACERECEIPT);
head.PLACEDELIVERYID = GetPortEDICodeByEname(head.PLACEDELIVERY);
result.Data = head;
result.Success = true;
}
else
{
result.Success = false;
result.Message = "未提取到相关数据,请检查PDF文件是否正确";
}
}
catch (Exception e)
{
result.Success = false;
result.Message = "提取数据过程中发生错误,请联系系统管理员!" + e.Message;
}
return result;
}
#endregion
#region 马士基BCPDF
static public DBResult GetMaersk_BC_PDF ( string pdffile )
{
var result = new DBResult();
try
{
PdfDocument doc = new PdfDocument();
// Load the PDF Document
doc.LoadFromFile(pdffile);
// String for hold the extracted text
StringBuilder buffer = new StringBuilder();
int i = 0;
foreach (PdfPageBase page in doc.Pages)
{
buffer.Append(page.ExtractText());
i++;
}
doc.Close();
var BCStr = buffer.ToString();
if (BCStr != "")
{
MsOpSeae head = null;
head = new MsOpSeae();
head.MBLNO = GetDataHtmlList(BCStr, "订舱号码):", "APPLICATION").Trim();
try
{
string yardtelstr = GetDataHtmlList(BCStr, "空箱提领处 :", "重箱返还处").Trim();
yardtelstr = yardtelstr.Replace("\r\n", "$");
string[] teltemp = yardtelstr.Split('$');
head.YARDTEL = teltemp[teltemp.Length - 1].Trim();
}
catch (Exception)
{
}
head.ETD = GetDataHtmlList(BCStr, "ETA DATE :", Environment.NewLine).ToString();
head.ETD = head.ETD.Replace("/", "-");
var VESSELVOY = GetDataHtmlList(BCStr, "船名/航次):", Environment.NewLine).Trim();
var vesselindex = VESSELVOY.LastIndexOf(" ");
head.VESSEL = VESSELVOY.Substring(0, vesselindex).Trim();
head.VOYNO = VESSELVOY.Substring(vesselindex + 1).Trim();
head.PLACERECEIPT = GetDataHtmlList(BCStr, "收货地):", Environment.NewLine).ToUpper().Trim();
head.PLACEDELIVERY = GetDataHtmlList(BCStr, "交货地):", Environment.NewLine).ToUpper().Trim();
head.YARD = GetDataHtmlList(BCStr, "空箱提领处 :", Environment.NewLine).Trim();
// head.APPLYNO = GetDataHtmlList(BCStr, "提箱校验码:", Environment.NewLine).Trim();
string CLOSINGDATE = "";
string CLOSEDOCDATE = "";
try
{
string temp = GetDataHtmlList(BCStr, "截关时间 :", Environment.NewLine).Trim();
temp = temp.Replace("/", "-");
DateTime dt = DateTime.Parse(temp);
CLOSINGDATE = dt.ToString("yyyy-MM-dd hh:mm:ss");
string temp2 = GetDataHtmlList(BCStr, "VGM CUT OFF via EDI/WEB/APP :", Environment.NewLine).Trim();
temp2 = temp2.Replace("/", "-");
DateTime dt2 = DateTime.Parse(temp2);
CLOSEDOCDATE = dt2.ToString("yyyy-MM-dd hh:mm:ss");
}
catch (Exception)
{
throw;
}
head.CLOSINGDATE = CLOSINGDATE;
head.CLOSEDOCDATE = CLOSEDOCDATE;
head.PLACERECEIPTID = GetPortEDICodeByEname(head.PLACERECEIPT);
head.PLACEDELIVERYID = GetPortEDICodeByEname(head.PLACEDELIVERY);
try
{
var goodsname = GetDataHtmlList(BCStr, "货物品名) :", Environment.NewLine);
if (goodsname.Contains("PURCHASE NUMBER"))
{
goodsname = goodsname.Substring(0, goodsname.IndexOf("PURCHASE NUMBER"));
}
head.GOODSNAME = goodsname.ToUpper();
}
catch
{
head.GOODSNAME = "";
}
result.Data = head;
result.Success = true;
}
else
{
result.Success = false;
result.Message = "未提取到相关数据,请检查PDF文件是否正确";
}
}
catch
{
result.Success = false;
result.Message = "提取数据过程中发生错误,请联系系统管理员!";
}
return result;
}
#endregion
#region 获取场站数据
static public DBResult GetYARDCTNList ( string bsno, string mblno, string yard, string companyid, string userid, bool isweb = false, string jck = "all")
{
var result = new DBResult();
result.Success = true;
var yarddataset = MsCodeYardDataSetDAL.GetData("YARD='" + yard + "'", companyid);
if ((yard != "YGT" ) &&(yarddataset == null || yarddataset.YARDCODE == ""))
{
result.Message = "不能提取数据,未设置此场站提取数据的相关的参数!";
result.Success = false;
}
else
{
var yardid = yarddataset.YARDCODE;
if (yard == "YGT") yardid = "YGT";
var USEDSINTERFACE = MsSysParamSetDAL.GetData("PARAMNAME='USEDSINTERFACE'");
if (USEDSINTERFACE.PARAMVALUE == "1")
result = GetYardInterfaceList(mblno, bsno, yardid,userid, isweb,jck);
else
result = GetYARDDataList(bsno, mblno, yardid, userid, isweb);
}
return result;
}
static public DBResult GetYARDDataList ( string bsno, string mblno, string yardid, string userid,bool isweb = false )
{
var result = new DBResult();
result.Success = true;
if (yardid == "STXKEYUN")//世腾克运
{
result = GetSTXKEYUNCTNList(mblno, bsno, isweb);
}
else if (yardid == "DAYA")//大亚
{
//result = GetDAYACTNList(mblno, bsno, yarddataset.LOGINNAME, yarddataset.PASSWORD);
if (mblno.Contains("COSU") || mblno.Contains("COAU") || mblno.Contains("PASU"))
{
//result = GetDAYAWEBCTNList2(mblno, bsno, isweb);
}
else
{
result = GetDAYAWEBCTNList(mblno, bsno, isweb);
}
}
else if (yardid == "JIEFENG")//捷丰
{
result = GetJIEFENGWEBCTNList(mblno, bsno, isweb);
}
else if (yardid == "LUHAI")//路海
{
result = GetLUHAIWEBCTNList(mblno, bsno, isweb);
}
else if (yardid == "ZHONGCHUANG")//中创
{
result = GetZHONGCHUANGWEBCTNList(mblno, bsno, isweb);
}
else if (yardid == "GangLianXin")//中创_港联欣场站
{
result = GetGangLianXinWEBCTNList(mblno, bsno, isweb);
}
else if (yardid == "YZH")
{
result = GetYIHANGCTNList(mblno, bsno, isweb);
}
else if (yardid == "CHANGRONG")//长荣
{
result = GetCHANGRONGCTNList(mblno, bsno, userid, isweb);
}
else if (yardid == "GLR")//港联荣
{
result = GetGLRCTNList(mblno, bsno, userid, isweb);
}
else if (yardid == "SSCZ")
{
result = GetSSCZCTNList(mblno, bsno, isweb);
}
else if (yardid == "WYCZ")//外运场站
{
result = GetWAIYUNTNList(mblno, bsno, isweb);
}
else if (yardid == "GLCZ")
{
result = GetGLCZCTNList(mblno, bsno, isweb);
}
else if (yardid == "MJCZ")
{
result = GetMJCZCTNList(mblno, bsno, isweb);
}
else if (yardid == "MGDG")
{
result = GetMGDGCTNList(mblno, bsno, isweb);
}
else if (yardid == "XDF")
{
result = GetXDFCTNList(mblno, bsno, isweb);
}
else if (yardid == "SZX")//神州场站
{
result = GetSZXCTNList(mblno, bsno, isweb);
}
else if (yardid == "QQCTU")
{
result = GetQQCTUCTNList(mblno, bsno, isweb);
}
else if (yardid == "ZHENGHUA")//振华
{
result = GetZHENGHUACTNList(mblno, bsno, isweb);
}
else if (yardid == "YIHANG"|| yardid == "GLJ")//青岛怡航场站/鲁艺场站(查询地址相同)
{
result = GetYIHANGCTNList(mblno, bsno, isweb);
}
else if (yardid == "JINHENG")//锦恒
{
result = GetJINHENGCTNList(mblno, bsno, isweb);
}
else if (yardid == "HANGJIN")//韩进
{
result = GetHANJINCTNList(mblno, bsno, isweb);
}
else if (yardid == "YANTAIYARD")//烟台
{
result = GetYANTAIYARDList(mblno, bsno, isweb);
}
else if (yardid == "GANGWAN")//港湾场站
{
result = GetGANGWANCTNList(mblno, bsno, isweb);
}
else if (yardid == "XINBADA")//新霸达场站
{
result = GetXINBADACTNList(mblno, bsno, isweb);
}
else if (yardid == "QQCT")//青岛前湾QQCT场站
{
result = GetQQCTCTNList(mblno, bsno, isweb);
}
else if (yardid == "RUNHAI")//润海场站
{
result = GetRUNHAICTNList(mblno, bsno, isweb);
}
else if (yardid == "LUYI")//鲁艺场站
{
result = GetYIHANGCTNList(mblno, bsno, isweb);
}
else if (yardid == "MGCZ")//明港场站
{
result = GetMGCZCTNList(mblno, bsno, isweb);
}
else if (yardid == "HTZX")//海铁中心
{
result = GetMGCZCTNList(mblno, bsno, isweb);
}
else if (yardid == "ZhongWaiYun")//中外运集装箱运输有限公司
{
//result = GetZhongWaiYunCTNList(mblno, bsno, isweb);//中外运验证码未提取成功,因此暂时屏蔽
}
else if (yardid == "KEYUN")//克运场站
{
result = GetKEYUNCTNList(mblno, bsno, isweb);
}
return result;
}
static public DBResult GetYardInterfaceList(string mblno, string bsno, string yardid,string userid, bool isweb = false, string jck = "all")
{
var result = new DBResult();
result.Success = true;
string iswebstr = "1";
if (!isweb) iswebstr = "0";
string qduname ="";
string qdpwd ="";
string customername = "";
string password = "";
try
{
#region 抓取页面
if (yardid == "YIHANG" || yardid == "YZH") yardid = "GLJ";
//if (yardid == "YGT" || yardid == "CHANGRONG"|| yardid == "GLR"|| yardid == "JZLG" || yardid == "XINBADA") {
var thirdpartyaccount = MsSysThirdPartyAccount.MsSysThirdPartyAccountDAL.GetData(" THIRDPARTY='运港通' and USERID='"+userid+"' ");
if (string.IsNullOrEmpty(thirdpartyaccount.ACCOUNT))
{
qduname = MsSysParamSetDAL.GetData("PARAMNAME='QDPORTUSER'").PARAMVALUE;
qdpwd = MsSysParamSetDAL.GetData("PARAMNAME='QDPORTPASS'").PARAMVALUE;
}
else {
qduname = thirdpartyaccount.ACCOUNT;
qdpwd = thirdpartyaccount.ACCOUNTPSW;
}
//}
customername = MsSysParamSetDAL.GetData("PARAMNAME='GETDATANAME'").PARAMVALUE;
password = MsSysParamSetDAL.GetData("PARAMNAME='GETDATAPASS'").PARAMVALUE;
if (yardid == "YGT" && isweb != true) yardid = "YGTJSON";
var GetYardDataUrl = "";
try
{
GetYardDataUrl = WebConfigurationManager.AppSettings["GetDataUrl"].ToString();
}
catch
{
}
if (GetYardDataUrl=="") GetYardDataUrl = "http://47.104.90.170:5000/query";
HttpHelper http = new HttpHelper();
HttpItem item = new HttpItem()
{
URL = GetYardDataUrl,//URL这里都是测试 必需项
Encoding = null,//编码格式utf-8,gb2312,gbk 可选项 默认类会自动识别
Host = "47.104.90.170:5000",
Timeout=600000,
UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)",
Accept = "gzip, deflate",// 可选项有默认值
ContentType = "application/x-www-form-urlencoded",
Postdata = "webusername=" + qduname + "&webuserpass=" + qdpwd + "&mblno=" + mblno + "&yardid=" + yardid + "&isweb=" + iswebstr+ "&custname=" + customername + "&psw=" + password + "&jck=" + jck,
Method = "POST",//URL 可选项 默认为Get
};
HttpResult resulthtml = http.GetHtml(item);
var datahtml = resulthtml.Html;
#endregion
if (isweb == true)
{
var objRtn = Newtonsoft.Json.JsonConvert.DeserializeAnonymousType(datahtml, new { status = "", message = "" });
var viewstatehtml = GetDataHtmlList(objRtn.message, "__VIEWSTATE", "/>");
var htmstr = objRtn.message;
if (viewstatehtml!="")
htmstr = objRtn.message.Replace(viewstatehtml,"");
//if (yardid != "YGT")
//htmstr = htmstr.Replace("display: none;", "");
result.Data = htmstr;
}
else
{
var objRtn = Newtonsoft.Json.JsonConvert.DeserializeAnonymousType(datahtml, new { status = ""});
if (objRtn.status == "1")
{
if (yardid == "YGTJSON")
{
var objRtn2 = Newtonsoft.Json.JsonConvert.DeserializeAnonymousType(datahtml, new { status = "", message = "" });
result.Success = true;
result.Data = objRtn2.message;
}
else
{
var objRtn2 = Newtonsoft.Json.JsonConvert.DeserializeAnonymousType(datahtml, new JsonMsOpSeaeDetail());
result.Success = true;
result.Data = objRtn2.message.ToList();
}
// objRtn = Newtonsoft.Json.JsonConvert.DeserializeAnonymousType(datahtml, new {<List< MsOpSeaeDetail>> message });
// var data1 = JsonConvert.Deserialize<List<MsOpSeaeDetail>>(objRtn.message);
// result.Data = data1.ToList();
}
else
{
var objRtn2 = Newtonsoft.Json.JsonConvert.DeserializeAnonymousType(datahtml, new { status = "", message = "" });
result.Success = false;
result.Message = objRtn2.message;
}
}
}
catch (Exception e)
{
result.Success = false;
result.Message = "没有提取到需要的数据!"+e.Message;
}
return result;
}
static public DBResult GetCarrierCtnStatus(string mblno, string carrierid, bool isweb = false)
{
var result = new DBResult();
result.Success = true;
string iswebstr = "1";
if (!isweb) iswebstr = "0";
string qduname = "";
string qdpwd = "";
string customername = "";
string password = "";
try
{
#region 抓取页面
customername = MsSysParamSetDAL.GetData("PARAMNAME='GETDATANAME'").PARAMVALUE;
password = MsSysParamSetDAL.GetData("PARAMNAME='GETDATAPASS'").PARAMVALUE;
var GetYardDataUrl = "";
if (GetYardDataUrl == "") GetYardDataUrl = "http://47.104.90.170:6000/ship/query";
HttpHelper http = new HttpHelper();
HttpItem item = new HttpItem()
{
URL = GetYardDataUrl,//URL这里都是测试 必需项
Encoding = null,//编码格式utf-8,gb2312,gbk 可选项 默认类会自动识别
Host = "47.104.90.170:5000",
UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)",
Accept = "gzip, deflate",// 可选项有默认值
ContentType = "application/x-www-form-urlencoded",
Postdata = "mblno=" + mblno + "&yardid=" + carrierid + "&isweb=" + iswebstr + "&custname=" + customername + "&psw=" + password,
Method = "POST",//URL 可选项 默认为Get
};
HttpResult resulthtml = http.GetHtml(item);
var datahtml = resulthtml.Html;
#endregion
if (isweb == true)
{
var objRtn = Newtonsoft.Json.JsonConvert.DeserializeAnonymousType(datahtml, new { status = "", message = "" });
if (objRtn.status == "1")
{
var htmstr = objRtn.message;
result.Data = htmstr;
}
else {
result.Success =false;
result.Message = objRtn.message;
}
}
else
{
}
}
catch (Exception e)
{
result.Success = false;
result.Message = "没有提取到需要的数据!" + e.Message;
}
return result;
}
static public string GetDataHtmlList ( string html, string startstr, string endstr )
{
var subhtml = html;
var htmllength = subhtml.Length;
var startindex = subhtml.IndexOf(startstr);
//if (startindex == -1 || startindex == 0) return "";
if (startindex == -1) return "";
subhtml = subhtml.Substring(startindex + startstr.Length, htmllength - startindex - startstr.Length);
var endindex = subhtml.IndexOf(endstr);
if (endindex != -1 && endindex != 0)
subhtml = subhtml.Substring(0, endindex);
return subhtml;
}
static public List<MsOpSeaeDetail> SumBodyList ( List<MsOpSeaeDetail> bodylist )
{
var newbodyList = new List<MsOpSeaeDetail>();
var tranbodylist = bodylist;
foreach (var enumValue in bodylist)
{
var istrue = true;
int pkgs = 0;
decimal kgs = 0;
decimal cbm = 0;
foreach (var newenumValue in newbodyList)
{
if (newenumValue.CNTRNO == enumValue.CNTRNO) istrue = false;
}
if (istrue)
{
MsOpSeaeDetail data = new MsOpSeaeDetail();
data.BSNO = enumValue.BSNO;
data.CTNNUM = 1;
data.CNTRNO = enumValue.CNTRNO;
data.CTNALL = enumValue.CTNALL;
data.TAREWEIGHT = enumValue.TAREWEIGHT;
data.KINDPKGS = enumValue.KINDPKGS;
data.SEALNO = enumValue.SEALNO;
data.VESSEL = enumValue.VESSEL;
data.VOYNO = enumValue.VOYNO;
foreach (var tranenumValue in tranbodylist)
{
if (tranenumValue.CNTRNO == enumValue.CNTRNO)
{
pkgs = pkgs + tranenumValue.PKGS;
kgs = kgs + tranenumValue.KGS;
cbm = cbm + tranenumValue.CBM;
}
}
data.PKGS = pkgs;
data.KGS = kgs;
data.CBM = cbm;
newbodyList.Add(data);
}
}
return newbodyList;
}
static public List<MsOpSeaeDetail> AddBodyList ( List<MsOpSeaeDetail> bodylist, List<MsOpSeaeDetail> bodylist2 )
{
var newbodyList = bodylist;
foreach (var enumValue in bodylist2)
{
var iffind = false;
for (var i = 0; i < newbodyList.Count; i++)
{
if (enumValue.CNTRNO == newbodyList[i].CNTRNO)
{
if (newbodyList[i].SEALNO == "")
newbodyList[i].SEALNO = enumValue.SEALNO;
if (newbodyList[i].EXITDOOR == "")
newbodyList[i].EXITDOOR = enumValue.EXITDOOR;
if (newbodyList[i].ENTERDOOR == "")
newbodyList[i].ENTERDOOR = enumValue.ENTERDOOR;
if (newbodyList[i].CTNSTATUS == "")
newbodyList[i].CTNSTATUS = enumValue.CTNSTATUS;
if (newbodyList[i].TRUCKNO == "")
newbodyList[i].TRUCKNO = enumValue.TRUCKNO;
if (newbodyList[i].TRUCKTYPE == "")
newbodyList[i].TRUCKTYPE = enumValue.TRUCKTYPE;
if (newbodyList[i].ONBORD == "")
newbodyList[i].ONBORD = enumValue.ONBORD;
if (newbodyList[i].ETD == "")
newbodyList[i].ETD = enumValue.ETD;
iffind = true;
}
}
if (iffind == false)
{
newbodyList.Add(enumValue);
}
}
return newbodyList;
}
#region 世腾克运//POBUTAO161000180//船名航次为中文,提取时需要从船名航次表中提取英文数据,没有则显示中文船名
static public DBResult GetSTXKEYUNCTNList ( string mblno, string bsno, bool isweb = false )
{
var result = new DBResult();
result.Success = true;
var bodyList = new List<MsOpSeaeDetail>();
var bodyList3 = new List<MsOpSeaeDetail>();
try
{
#region 抓取页面
HttpHelper http = new HttpHelper();
HttpItem item = new HttpItem()
{
URL = "http://www.stx-keyun.com/query/search_bl_no.asp",//URL这里都是测试 必需项
Encoding = null,//编码格式utf-8,gb2312,gbk 可选项 默认类会自动识别
Host = "www.stx-keyun.com",
UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)",
Accept = "text/html, application/xhtml+xml, */*",// 可选项有默认值
ContentType = "text/html",
Method = "get",//URL 可选项 默认为Get
};
HttpResult resulthtml = http.GetHtml(item);
var mycookie = resulthtml.Cookie;
item = new HttpItem()
{
URL = "http://www.stx-keyun.com/query/search_bl_no.asp?BL_NO1=" + mblno + "&submit1=%B2%E9%D1%AF HTTP/1.1",//URL这里都是测试 必需项
Referer = "http://www.stx-keyun.com/query/search_bl_no.asp",
Encoding = null,//编码格式utf-8,gb2312,gbk 可选项 默认类会自动识别
Cookie = mycookie,
Host = "www.stx-keyun.com",
UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)",
Accept = "text/html, application/xhtml+xml, */*",// 可选项有默认值
ContentType = "application/x-www-form-urlencoded",
Method = "GET",//URL 可选项 默认为Get
};
#endregion
resulthtml = http.GetHtml(item);
if (isweb == true)
{
var datahtml = resulthtml.Html;
datahtml = datahtml.Replace("../css/sheet.css", "http://www.stx-keyun.com/css/sheet.css");
result.Data = datahtml;
}
else
{
#region 船名航次
var datahtml3 = GetDataHtmlList(resulthtml.Html, "下货纸信息</font>", "</font><br>");
if (datahtml3 != "")
{
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
MsOpSeaeDetail data = new MsOpSeaeDetail();
data.BSNO = bsno;//业务编号
data.CTNNUM = 1;//箱量
var fielddatastr = datahtml3.Remove(0, datahtml3.IndexOf(">") + 1);
data.VESSEL = fielddatastr.Substring(0, fielddatastr.IndexOf("/")).ToString().Trim();
string sVESSEL = T_ALL_DA.GetStrSQL("VESSEL", "select top 1 isnull(VESSEL,'') as VESSEL from code_vessel where CNAME='" + data.VESSEL.ToString().Trim() + "'");
data.VESSEL = (sVESSEL == "" ? data.VESSEL.ToString().Trim() : sVESSEL);
data.VOYNO = fielddatastr.Substring(fielddatastr.IndexOf("/")+1).ToString().Trim();
bodyList3.Add(data);
}
#endregion
#region 装箱信息
var datahtml = GetDataHtmlList(resulthtml.Html, "装箱信息</font><br>", "</table>");
if (datahtml != "")
{
var i = 1;
while (datahtml.IndexOf("</tr>") >= 0)
{
var datalength = datahtml.IndexOf("</tr>");
var recdatastr = datahtml.Substring(0, datalength + 5);
datahtml = datahtml.Substring(datalength + 5, datahtml.Length - datalength - 5);
recdatastr = recdatastr.Remove(0, recdatastr.IndexOf("<tr>") + 4);
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);
if (fieldno == 2)
{
data.CNTRNO = fielddatastr;
foreach (var enumValue in bodyList3)
{
data.VESSEL = enumValue.VESSEL;
data.VOYNO = enumValue.VOYNO;
}
}
if (fieldno == 3)
{
data.CTNALL = fielddatastr;
}
if (fieldno == 4)
{
data.SEALNO = fielddatastr;
}
if (fieldno == 5)
{
try
{
data.PKGS = Convert.ToInt32(fielddatastr);
}
catch
{
data.PKGS = 0;
}
}
if (fieldno == 7)
{
try
{
data.KGS = Convert.ToDecimal(fielddatastr);
}
catch
{
data.KGS = 0;
}
}
if (fieldno == 9)
{
try
{
data.CBM = Convert.ToDecimal(fielddatastr);
}
catch
{
}
}
if (fieldno == 11)
{
try
{
data.TAREWEIGHT = Convert.ToDecimal(fielddatastr);
}
catch
{ }
}
fieldno = fieldno + 1;
}
bodyList.Add(data);
}
i = i + 1;
}
}
#endregion
if (bodyList.Count == 0)
{
bodyList = bodyList3;
}
bodyList = SumBodyList(bodyList);
result.Data = bodyList.ToList();
}
}
catch
{
result.Success = false;
result.Message = "提取数据过程中发生错误,请联系系统管理员!";
}
//bodyList=SumBodyList(bodyList);
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
#region 捷丰场站
static public DBResult GetJIEFENGCTNList ( string mblno, string bsno, bool isweb = false )
{
var result = new DBResult();
result.Success = true;
var bodyList = new List<MsOpSeaeDetail>();
try
{
string url = "http://www.sdsmart.cn/DongShengWS/Service.asmx";
string[] args = new string[1];
args[0] = mblno;
object resultXml = WebServiceHelper.InvokeWebService(url, "GetBLNoInfo", args);
StringReader rdr = new StringReader(resultXml.ToString());
XmlSerializer serializer = new XmlSerializer(typeof(JIEFENG));
JIEFENG xmlDoc = (JIEFENG)serializer.Deserialize(rdr);
if (xmlDoc != null)
{
ds[] ds = xmlDoc.ds;
for (int i = 0; i < ds.Length; i++)
{
MsOpSeaeDetail data = new MsOpSeaeDetail();
data.CNTRNO = ds[i].CNTRNO;
data.SEALNO = ds[i].SEALNO;
data.CTNALL = ds[i].CNTRSIZE + ds[i].CNTRTYPE;
try
{
if (ds[i].CARGOQTY != "")
data.PKGS = Convert.ToInt16(ds[i].CARGOQTY);
}
catch
{ }
try
{
if (ds[i].CARGOWEIGHT != "")
data.KGS = Convert.ToDecimal(ds[i].CARGOWEIGHT);
}
catch
{ }
try
{
if (ds[i].CARGOVOLUME != "")
data.CBM = Convert.ToDecimal(ds[i].CARGOVOLUME);
}
catch
{ }
bodyList.Add(data);
}
}
}
catch
{
result.Success = false;
result.Message = "提取数据过程中发生错误,请联系系统管理员!";
}
bodyList = SumBodyList(bodyList);
result.Data = bodyList.ToList();
return result;
}
//捷丰//需求编号SR2017041100027//599439499//SITRTATK486949//KKLUTAO704646//QDAC024718//需求编号SR2017082500005
static public DBResult GetJIEFENGWEBCTNList ( string mblno, string bsno, bool isweb = false )
{
var result = new DBResult();
result.Success = true;
var bodyList = new List<MsOpSeaeDetail>();
var bodyList3 = new List<MsOpSeaeDetail>();
var bodyList2 = new List<MsOpSeaeDetail>();
try
{
HttpHelper http = new HttpHelper();
HttpItem item = new HttpItem()
{
//URL = "http://www.sdsmartlogistics.com/Search/YD_BLQueryGrid.aspx?blno=" + mblno,//URL这里都是测试 必需项
URL = "http://www.sdsmart.cn/FindClass/YD_BLQueryGrid.aspx?blno=" + mblno,//URL这里都是测试 必需项
Encoding = null,//编码格式utf-8,gb2312,gbk 可选项 默认类会自动识别
Host = "www.sdsmart.cn",
UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)",
Accept = "text/html, application/xhtml+xml, */*",// 可选项有默认值
ContentType = "text/html",
Method = "get",//URL 可选项 默认为Get
};
HttpResult resulthtml = http.GetHtml(item);
if (isweb == true)
{
var datahtml = resulthtml.Html;
datahtml = datahtml.Replace("../css/sheet.css", "http://www.sdsmart.cn/css/sheet.css");
result.Data = datahtml;
}
else
{
resulthtml = http.GetHtml(item);
var datahtml3 = GetDataHtmlList(resulthtml.Html, "id=\"Grid1\"", "</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>") + 4);
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);
if (fieldno == 1)
{
data.VESSEL = fielddatastr;
}
if (fieldno == 3)
{
data.VOYNO = fielddatastr;
}
fieldno = fieldno + 1;
}
bodyList3.Add(data);
}
i = i + 1;
}
#endregion
}
//
resulthtml = http.GetHtml(item);
var datahtml2 = GetDataHtmlList(resulthtml.Html, "id=\"Grid4\"", "</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>") + 4);
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);
if (fieldno == 11)
{
try
{
data.TAREWEIGHT = Convert.ToDecimal(fielddatastr);
}
catch
{
data.TAREWEIGHT = 0;
}
}
fieldno = fieldno + 1;
}
bodyList2.Add(data);
}
i = i + 1;
}
#endregion
}
//
var ctnall = "";
var datahtml = GetDataHtmlList(resulthtml.Html, "id=\"Grid3\"", "</table>");
if (datahtml != "")
{
#region 装货信息
var i = 1;
while (datahtml.IndexOf("</tr>") >= 0)
{
var datalength = datahtml.IndexOf("</tr>");
var recdatastr = datahtml.Substring(0, datalength + 5);
datahtml = datahtml.Substring(datalength + 5, datahtml.Length - datalength - 5);
recdatastr = recdatastr.Remove(0, recdatastr.IndexOf("<tr>") + 4);
recdatastr = recdatastr.Remove(recdatastr.IndexOf("</tr>"), 5);
var fieldno = 1;
if (i != 1)
{
MsOpSeaeDetail data = new MsOpSeaeDetail();
data.BSNO = bsno;//业务编号
data.CTNNUM = 1;//箱量
var istrue = false;
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);
if (fieldno == 1)
{
fielddatastr = fielddatastr.Remove(0, fielddatastr.IndexOf(">") + 1);
if (fielddatastr == "<a>合计</a>")
istrue = false;
else
istrue = true;
}
if (fieldno == 2)
{
data.CNTRNO = fielddatastr;
foreach (var enumValue in bodyList3)
{
data.VESSEL = enumValue.VESSEL;
data.VOYNO = enumValue.VOYNO;
}
foreach (var enumValue in bodyList2)
{
try
{
data.TAREWEIGHT = enumValue.TAREWEIGHT;
}
catch
{
data.TAREWEIGHT = 0;
}
}
}
if (fieldno == 3)
{
ctnall = fielddatastr;
if (ctnall == "&nbsp;") istrue = false;
}
if (fieldno == 4)
{
data.CTNALL = fielddatastr + ctnall;
}
if (fieldno == 5)
{
data.SEALNO = fielddatastr;
}
if (fieldno == 6)
{
try
{
data.PKGS = Convert.ToInt32(fielddatastr);
}
catch
{
data.PKGS = 0;
}
}
if (fieldno == 75)
{
data.KINDPKGS = fielddatastr;
}
if (fieldno == 8)
{
try
{
data.KGS = Convert.ToDecimal(fielddatastr);
}
catch
{
data.KGS = 0;
}
}
if (fieldno == 9)
{
try
{
data.CBM = Convert.ToDecimal(fielddatastr);
}
catch
{
}
}
fieldno = fieldno + 1;
}
if (istrue)
bodyList.Add(data);
}
i = i + 1;
}
#endregion
}
if (bodyList.Count == 0)
{
bodyList = bodyList3;
}
bodyList = SumBodyList(bodyList);
result.Data = bodyList.ToList();
}
}
catch
{
result.Success = false;
result.Message = "提取数据过程中发生错误,请联系系统管理员!";
}
return result;
}
#endregion
#region 陆海场站//177OHPHPQ8004VFB
static public DBResult GetLUHAICTNList ( string mblno, string bsno, bool isweb = false )
{
var result = new DBResult();
result.Success = true;
var bodyList = new List<MsOpSeaeDetail>();
try
{
string url = "http://www.lhl.cn:8190/WebServiceTest/services/myService";
string[] args = new string[1];
args[0] = mblno;
object resultXml = WebServiceHelper.InvokeWebService(url, "CntrMess", 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 = "提取数据过程中发生错误,请联系系统管理员!";
}
bodyList = SumBodyList(bodyList);
result.Data = bodyList.ToList();
return result;
}
static public DBResult GetLUHAIWEBCTNList ( string mblno, string bsno, bool isweb = false )
{
var result = new DBResult();
result.Success = true;
var bodyList = new List<MsOpSeaeDetail>();
var bodyList3 = new List<MsOpSeaeDetail>();
try
{
#region 抓取页面
HttpHelper http = new HttpHelper();
//HttpItem item = new HttpItem()
//{
// URL = "http://221.215.96.158:8086/root/jsp/",//URL这里都是测试 必需项
// Encoding = null,//编码格式utf-8,gb2312,gbk 可选项 默认类会自动识别
// Host = "221.215.96.158:8086",
// UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)",
// Accept = "text/html, application/xhtml+xml, */*",// 可选项有默认值
// ContentType = "text/html",
// Method = "get",//URL 可选项 默认为Get
//};
//HttpResult resulthtml = http.GetHtml(item);
var mycookie = "";
HttpItem item = new HttpItem()
{
URL = "http://221.215.96.158:8086/root/jsp/mainframe.jsp",//URL这里都是测试 必需项
Referer = "http://221.215.96.158:8086/root/jsp/",
Encoding = null,//编码格式utf-8,gb2312,gbk 可选项 默认类会自动识别
Cookie = mycookie,
Host = "221.215.96.158:8086",
UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)",
Accept = "text/html, application/xhtml+xml, */*",// 可选项有默认值
ContentType = "application/x-www-form-urlencoded",
Postdata = "strlogname=guest&strpwd=guest&submit1=+%B5%C7%C2%BC+",
Method = "POST",//URL 可选项 默认为Get
};
HttpResult resulthtml = http.GetHtml(item);
mycookie = resulthtml.Cookie;
item = new HttpItem()
{
URL = "http://221.215.96.158:8086/root/jsp/search/search0402.jsp",//URL这里都是测试 必需项
Referer = "http://221.215.96.158:8086/root/jsp/search/search0402.jsp",
Encoding = null,//编码格式utf-8,gb2312,gbk 可选项 默认类会自动识别
Cookie = mycookie,
Host = "221.215.96.158:8086",
UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)",
Accept = "text/html, application/xhtml+xml, */*",// 可选项有默认值
ContentType = "application/x-www-form-urlencoded",
Postdata = "BillNo=" + mblno + "&submit1=+%B2%E9%D5%D2+",
Method = "POST",//URL 可选项 默认为Get
};
#endregion
resulthtml = http.GetHtml(item);
if (isweb == true)
{
var datahtml = resulthtml.Html;
datahtml = datahtml.Replace("../css/sheet.css", "http://221.215.96.158:8086/css/sheet.css");
result.Data = datahtml;
}
else
{
#region 船名航次
var datahtml3 = GetDataHtmlList(resulthtml.Html, "table1", "</table>");
datahtml3 = datahtml3.Remove(datahtml3.IndexOf("</tr>"), 5);
datahtml3 = datahtml3.Remove(0, datahtml3.IndexOf(">") + 1);
datahtml3 = datahtml3.Remove(0, datahtml3.IndexOf(">") + 1);
if (datahtml3 != "")
{
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 != 0)
{
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.Remove(0, fielddatastr.IndexOf(">") + 1);
fielddatastr = fielddatastr.Replace("<A id=TCount>","");
if (fielddatastr.IndexOf("<") > -1)
{
fielddatastr = fielddatastr.Remove(fielddatastr.IndexOf("<"), fielddatastr.Length - fielddatastr.IndexOf("<"));
}
if (fieldno == 1)
{
data.VESSEL = fielddatastr;
}
if (fieldno == 3)
{
data.VOYNO = fielddatastr;
}
fieldno = fieldno + 1;
}
bodyList3.Add(data);
}
i = i + 1;
}
}
#endregion
#region 集装箱信息
var datahtml = GetDataHtmlList(resulthtml.Html, "table5", "</table>");
datahtml = datahtml.Remove(datahtml.IndexOf("</tr>"), 5);
datahtml = datahtml.Remove(0, datahtml.IndexOf(">") + 1);
datahtml = datahtml.Remove(0, datahtml.IndexOf(">") + 1);
var ctnall = "";
if (datahtml != "")
{
var i = 1;
while (datahtml.IndexOf("</tr>") >= 0)
{
var datalength = datahtml.IndexOf("</tr>");
var recdatastr = datahtml.Substring(0, datalength + 5);
datahtml = datahtml.Substring(datalength + 5, datahtml.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 != 0)
{
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.Remove(0, fielddatastr.IndexOf(">") + 1);
fielddatastr = fielddatastr.Remove(fielddatastr.IndexOf("<"), fielddatastr.Length - fielddatastr.IndexOf("<"));
if (fieldno == 1)
{
if (fielddatastr == "&nbsp;") istrue = false; else istrue = true;
}
if (fieldno == 2)
{
data.CNTRNO = fielddatastr;
if (fielddatastr == "&nbsp;") istrue = false; else istrue = true;
foreach (var enumValue in bodyList3)
{
data.VESSEL = enumValue.VESSEL;
data.VOYNO = enumValue.VOYNO;
}
}
if (fieldno == 4)
{
ctnall = fielddatastr;
}
if (fieldno == 5)
{
data.CTNALL = ctnall + fielddatastr;
}
if (fieldno == 6)
{
data.SEALNO = fielddatastr;
}
if (fieldno == 7)
{
try
{
data.TAREWEIGHT = Convert.ToDecimal(fielddatastr);
}
catch
{
}
}
if (fieldno == 10)
{
try
{
data.PKGS = Convert.ToInt32(fielddatastr);
}
catch
{
data.PKGS = 0;
}
}
if (fieldno == 11)
{
try
{
data.KGS = Convert.ToDecimal(fielddatastr);
}
catch
{
data.KGS = 0;
}
}
if (fieldno == 12)
{
try
{
data.CBM = Convert.ToDecimal(fielddatastr);
}
catch
{
}
}
fieldno = fieldno + 1;
}
if (istrue)
bodyList.Add(data);
}
i = i + 1;
}
}
#endregion
if (bodyList.Count == 0)
{
bodyList = bodyList3;
}
bodyList = SumBodyList(bodyList);
result.Data = bodyList.ToList();
}
}
catch
{
result.Success = false;
result.Message = "提取数据过程中发生错误,请联系系统管理员!";
}
return result;
}
#endregion
#region 中创场站/中创保税仓库/中创保税物流园//NYKS2410075330
static public DBResult GetZHONGCHUANGCTNList ( string mblno, string bsno, string password, bool isweb = false )
{
var result = new DBResult();
result.Success = true;
var bodyList = new List<MsOpSeaeDetail>();
try
{
string url = "http://www.cmlog.com.cn:8003/cmlwebservice/CaragtQuery_Cxwl.asmx";
string[] args = new string[2];
args[0] = mblno;
args[1] = password;
object resultXml = WebServiceHelper.InvokeWebService(url, "GetInfo", args);
StringReader rdr = new StringReader(resultXml.ToString());
XmlSerializer serializer = new XmlSerializer(typeof(ZHONGCHUANG));
ZHONGCHUANG xmlDoc = (ZHONGCHUANG)serializer.Deserialize(rdr);
if (xmlDoc != null)
{
zhongchuangtable[] ds = xmlDoc.ds;
for (int i = 0; i < ds.Length; i++)
{
MsOpSeaeDetail data = new MsOpSeaeDetail();
data.CNTRNO = ds[i].CNTRNO;
data.SEALNO = ds[i].SEALNO.ToString().Trim();
data.CTNALL = ds[i].CTNSIZE + ds[i].CTNTYPE;
try
{
if (ds[i].PKGS != "")
data.PKGS = Convert.ToInt16(ds[i].PKGS);
}
catch
{ }
try
{
if (ds[i].KGS != "")
data.KGS = Convert.ToDecimal(ds[i].KGS);
}
catch
{ }
try
{
if (ds[i].CBM != "")
data.CBM = Convert.ToDecimal(ds[i].CBM);
}
catch
{ }
try
{
if (ds[i].TAREWEIGHT != "")
data.TAREWEIGHT = Convert.ToDecimal(ds[i].TAREWEIGHT);
}
catch
{ }
bodyList.Add(data);
}
}
}
catch
{
result.Success = false;
result.Message = "提取数据过程中发生错误,请联系系统管理员!";
}
bodyList = SumBodyList(bodyList);
result.Data = bodyList.ToList();
return result;
}
//中创//JJHB17QTY0001
static public DBResult GetZHONGCHUANGWEBCTNList ( string mblno, string bsno, bool isweb = false )
{
//2017-02-06
//地址http://www.cmlog.com:8003/cmlwebservice/CaragtQuery_LH.asmx
//GetInfo为远达
//GetInfoGlx为港联欣
var result = new DBResult();
result.Success = true;
var bodyList = new List<MsOpSeaeDetail>();
var bodyList2 = new List<MsOpSeaeDetail>();
var bodyList3 = new List<MsOpSeaeDetail>();
try
{
#region 连接地址URL
HttpHelper http = new HttpHelper();
HttpItem item = new HttpItem()
{
//URL = "http:///www.cmlog.com.cn/WebApp/LoginNew.aspx",//URL这里都是测试 必需项
URL = "http://www.cmlog.com.cn/zcxt/query/ExportUsual.aspx",//URL这里都是测试 必需项
Encoding = null,//编码格式utf-8,gb2312,gbk 可选项 默认类会自动识别
Host = "www.cmlog.com.cn",
UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)",
Accept = "text/html, application/xhtml+xml, */*",// 可选项有默认值
ContentType = "text/html",
Method = "GET",//URL 可选项 默认为Get
};
HttpResult resulthtml = http.GetHtml(item);
//
var viewstatehtml = resulthtml.Html;
viewstatehtml = GetDataHtmlList(viewstatehtml, "__VIEWSTATE", "/>");
viewstatehtml = viewstatehtml.Replace("\"", "");
//viewstatehtml = GetDataHtmlList(viewstatehtml, "/", "/>").Trim();
//viewstatehtml = "__EVENTTARGET=&__EVENTARGUMENT=&__VIEWSTATE=%2F" + viewstatehtml + "&_ctl0%3AContentPlaceHolder1%3ATextBox1=" + mblno + "&_ctl0%3AContentPlaceHolder1%3AbtnQuery=%E6%9F%A5+%E8%AF%A2&_ctl0%3AContentPlaceHolder1%3AhidAtddt=2015%2F4%2F19+7%3A40%3A00&_ctl0%3AContentPlaceHolder1%3AhidCMAFX=&_ctl0%3AContentPlaceHolder1%3AhidLocklb=0&_ctl0%3AContentPlaceHolder1%3AhidCorplb=";
//viewstatehtml = viewstatehtml.Replace("+", "%2B");
//viewstatehtml = viewstatehtml.Replace("/", "%2F");
//viewstatehtml = GetDataHtmlList(viewstatehtml, "/", "/>").Trim();
viewstatehtml = GetDataHtmlList(viewstatehtml, " value =", "/>").Trim();
viewstatehtml = viewstatehtml.Replace("+", "%2B");
viewstatehtml = viewstatehtml.Replace("/", "%2F");
viewstatehtml = "__EVENTTARGET=&__EVENTARGUMENT=&__VIEWSTATE=" + viewstatehtml + "&__VIEWSTATEENCRYPTED=" + "&_ctl0%3AContentPlaceHolder1%3ATextBox1=" + mblno + "&_ctl0%3AContentPlaceHolder1%3AbtnQuery=%E6%9F%A5+%E8%AF%A2&_ctl0%3AContentPlaceHolder1%3AhidAtddt=2019%2f5%2f5+7%3a00%3a00&_ctl0%3AContentPlaceHolder1%3AhidCMAFX=&_ctl0%3AContentPlaceHolder1%3AhidLocklb=&_ctl0%3AContentPlaceHolder1%3AhidCorplb=";
var mycookie = resulthtml.Cookie;
item = new HttpItem()
{
URL = "http://www.cmlog.com.cn/zcxt/query/ExportUsual.aspx",//URL这里都是测试 必需项
Referer = "http://www.cmlog.com.cn/zcxt/query/ExportUsual.aspx",
Encoding = null,//编码格式utf-8,gb2312,gbk 可选项 默认类会自动识别
Host = "www.cmlog.com.cn",
UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36",
Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3",
ContentType = "application/x-www-form-urlencoded",
Cookie = mycookie,
#region Postdata
//Postdata = "__EVENTTARGET=&__EVENTARGUMENT=&__VIEWSTATE=%2FwEPDwUKMTM1NzMyNzMwMQ9kFgJmD2QWAgIDD2QWAgIJD2QWBAIDDw9kFgIeB29uY2xpY2sFDlNob3dXYWl0aW5nKCk7ZAIHDxYCHgdWaXNpYmxlZxYaAgEPZBYCZg9kFgICAQ88KwARAwAPFgQeC18hRGF0YUJvdW5kZx4LXyFJdGVtQ291bnQCAWQBEBYAFgAWAAwUKwAAFgJmD2QWBAIBD2QWGmYPZBYCZg8VAQExZAICDw8WAh4EVGV4dAUESEpTT2RkAgMPDxYCHwQFDOmfqei%2Fm%2BengOmVkGRkAgQPDxYCHwQFDEhBTkpJTiBTT09IT2RkAgUPDxYCHwQFBTAwMTVXZGQCBg8PFgIfBAUQMjAxNS0wNC0xOSAwNzo0MGRkAgcPDxYCHwQFEDIwMTUtMDQtMTYgMDY6MjBkZAIIDw8WAh8EBRAyMDE1LTA0LTE3IDE1OjIwZGQCCg8PFgIfBAUEUUNUM2RkAgsPDxYCHwQFBiZuYnNwO2RkAgwPDxYCHwQFBiZuYnNwO2RkAg0PDxYCHwRlZGQCDg8PFgIfBGVkZAICDw8WAh8BaGRkAgMPZBYCZg9kFgICAQ88KwARAwAPFgQfAmcfAwIBZAEQFgAWABYADBQrAAAWAmYPZBYEAgEPZBYYZg9kFgJmDxUBATFkAgEPDxYCHwQFC0NOUUlOMTQyMTA4ZGQCAg9kFgICAQ8PFgIeD0NvbW1hbmRBcmd1bWVudAUKMTUwNDAxMTY5MGRkAgMPDxYCHwQFC0NOUUlOMTQyMTA4ZGQCBA8PFgIfBAUFRVNBTEdkZAIFDw8WAh8EBQVOR0FQUGRkAggPDxYCHwQFBiZuYnNwO2RkAgkPDxYCHwQFBiZuYnNwO2RkAgoPDxYCHwQFBiZuYnNwO2RkAgsPDxYCHwQFATBkZAIMDw8WAh8EBQQzNzIwZGQCDQ8PFgIfBAUBMGRkAgIPDxYCHwFoZGQCBQ9kFgJmD2QWAgIBDzwrABEDAA8WBB8CZx8DZmQBEBYAFgAWAAwUKwAAZAIGD2QWAmYPZBYCAgEPDxYCHwFnZGQCBw9kFgJmD2QWAgIBDzwrABEDAA8WBB8CZx8DZmQBEBYAFgAWAAwUKwAAZAIID2QWAmYPZBYCAgEPDxYCHwFnZGQCCQ9kFgJmD2QWAgIBDzwrABEDAA8WBB8CZx8DAgFkARAWABYAFgAMFCsAABYCZg9kFgQCAQ9kFhhmD2QWAmYPFQEBMWQCAQ8PFgIfBAUDVUFTZGQCAg8PFgIfBAUEMjBHUGRkAgMPDxYCHwQFATFkZAIEDw8WAh8EBQFOZGQCBQ8PFgIfBAUBWWRkAgYPDxYCHwQFBiZuYnNwO2RkAgcPDxYCHwQFBiZuYnNwO2RkAggPDxYCHwQFBiZuYnNwO2RkAgkPDxYCHwQFBuWklueCuWRkAgsPDxYCHwQFDOayoeacieimgeaxgmRkAgwPDxYCHwQFBiZuYnNwO2RkAgIPDxYCHwFoZGQCCg9kFgJmD2QWAgIBDw8WAh8BZ2RkAgsPZBYCZg9kFgICAQ88KwARAwAPFgQfAmcfA2ZkARAWABYAFgAMFCsAAGQCDA9kFgJmD2QWAgIBDw8WAh8BZ2RkAg0PZBYCZg9kFgICAQ88KwARAwAPFgQfAmcfAwIBZAEQFgAWABYADBQrAAAWAmYPZBYEAgEPDxYEHglGb3JlQ29sb3IKJR4EXyFTQgIEZBYiZg9kFgJmDxUBATFkAgEPDxYCHwQFC1VBQ1UzODQwMTk5ZGQCAg8PFgIfBAUDVUFTZGQCAw8PFgIfBAUEMjBHUGRkAgQPDxYCHwQFBDIyOTBkZAIFDw8WAh8EBQYwMDY4OTlkZAIGDw8WAh8EBRAyMDE1LTA0LTE1IDA5OjI4ZGQCBw8PFgIfBAUHTEJXNTcxNmRkAggPDxYCHwQFCzE1NjE1MDE5NDY2ZGQCCQ8PFgIfBAUBWWRkAgoPDxYCHwQFEDIwMTUtMDQtMTcgMTE6NDBkZAILDw8WAh8EBQnmnKrliJLmi6hkZAIMDw8WAh8EBQblt7Lmj5BkZAINDw8WAh8EBQYmbmJzcDtkZAIODw8WAh8EBQYmbmJzcDtkZAIQDw8WAh8EBQblt7Lmj5BkZAISDw8WAh8EBQzmuK%2Fnq5nmlrDljLpkZAICDw8WAh8BaGRkAg8PZBYCZg9kFgICAQ8PFgIfAWdkZAIQD2QWAmYPZBYCAgEPPCsAEQMADxYEHwJnHwMCAWQBEBYAFgAWAAwUKwAAFgJmD2QWBAIBD2QWGmYPZBYCZg8VAQExZAIDDw8WAh8EBQtVQUNVMzg0MDE5OWRkAgQPDxYCHwQFC0NOUUlOMTQyMTA4ZGQCBQ8PFgIfBAUGMDA2ODk5ZGQCBg8PFgIfBAUSMjAxNS80LzE3IDExOjQwOjI3ZGQCBw8PFgIfBAUEMjI5MGRkAggPDxYCHwQFBDQ2OTBkZAIJDw8WAh8EBQYmbmJzcDtkZAIKDw8WAh8EBQYmbmJzcDtkZAILDw8WAh8EBQIxNWRkAgwPDxYCHwQFBDI0MDBkZAINDw8WAh8EBQIyNWRkAg8PZBYCZg8PFgIeC05hdmlnYXRlVXJsBUFodHRwOi8vd3d3LnFpbmdkYW9wb3J0Lm5ldC95d3p4L3FxY3QvZHBjeC95ZGJnLmpzcD94aD1VQUNVMzg0MDE5OWRkAgIPZBYIAgkPDxYCHwQFCeWQiOiuoe%2B8mmRkAgsPDxYCHwQFAjE1ZGQCDA8PFgIfBAUEMjQwMGRkAg0PDxYCHwQFAjI1ZGQYCAUlX2N0bDA6Q29udGVudFBsYWNlSG9sZGVyMTpndlNoaVpodWFuZw88KwAMAwYVAQZjdG5yZWYHFCsAARQrAAEFCjE1MDMxNDUyMjQIAgFkBSJfY3RsMDpDb250ZW50UGxhY2VIb2xkZXIxOmd2VmVzdm95DzwrAAwDBhUBBVpDWVdZBxQrAAEUKwABZAgCAWQFJF9jdGwwOkNvbnRlbnRQbGFjZUhvbGRlcjE6Z3ZFeHByZXN0dQ88KwAMAwYVBQhjdG5hcHBsYgV0eGVkdAVlaXJubwdlbWZ1ZWR0BWN0bm5vBxQrAAEUKwAFBQFZZGUGoPWPmXVF0ggFC1VBQ1UzODQwMTk5CAIBZAUiX2N0bDA6Q29udGVudFBsYWNlSG9sZGVyMTpndkN1c3RvbQ88KwAMAQhmZAUgX2N0bDA6Q29udGVudFBsYWNlSG9sZGVyMTpndkJpbGwPPCsADAMGFQMGYmlsbG5vB21iaWxsbm8IZXhiaWxyZWYHFCsAARQrAAMFC0NOUUlOMTQyMTA4BQtDTlFJTjE0MjEwOAUKMTUwNDAxMTY5MAgCAWQFIl9jdGwwOkNvbnRlbnRQbGFjZUhvbGRlcjE6Z3JkVHJrdGIPPCsADAEIZmQFIV9jdGwwOkNvbnRlbnRQbGFjZUhvbGRlcjE6Z3ZFb3lwbA88KwAMAQgCAWQFI19jdGwwOkNvbnRlbnRQbGFjZUhvbGRlcjE6Z3ZEaW5naGFvDzwrAAwBCGZkykdttiaXXIjoowe1gga1tue1cwRrgRQ6a1t3iIN8X7g%3D&_ctl0%3AContentPlaceHolder1%3ATextBox1=" + mblno + "&_ctl0%3AContentPlaceHolder1%3AbtnQuery=%E6%9F%A5+%E8%AF%A2&_ctl0%3AContentPlaceHolder1%3AhidAtddt=2015%2F4%2F19+7%3A40%3A00&_ctl0%3AContentPlaceHolder1%3AhidCMAFX=&_ctl0%3AContentPlaceHolder1%3AhidLocklb=0&_ctl0%3AContentPlaceHolder1%3AhidCorplb=",
#endregion
//2016-12-14 重新从网站获取Postdata配置信息
Postdata = viewstatehtml,
Method = "POST",//URL 可选项 默认为Get
};
#endregion
resulthtml = http.GetHtml(item);
if (isweb == true)
{
var datahtml = resulthtml.Html;
datahtml = datahtml.Replace("../Css/admincenter.css", "http://www.cmlog.com.cn/zcxt/Css/admincenter.css");
result.Data = datahtml;
}
else
{
#region 船名航次信息
var datahtml3 = GetDataHtmlList(resulthtml.Html, "_ctl0_ContentPlaceHolder1_gvVesvoy", "</table>");
if (datahtml3 != "")
{
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);
if (fieldno == 4)
{
data.VESSEL = fielddatastr;
}
if (fieldno == 5)
{
data.VOYNO = fielddatastr;
}
fieldno = fieldno + 1;
}
bodyList3.Add(data);
}
i = i + 1;
}
}
#endregion
#region 用箱信息
var datahtml2 = GetDataHtmlList(resulthtml.Html, "_ctl0_ContentPlaceHolder1_gvExprestu", "</table>");
if (datahtml2 != "")
{
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;
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);
if (fieldno == 1)
{
}
if (fieldno == 2)
{
data.CNTRNO = fielddatastr;
foreach (var enumValue in bodyList3)
{
data.VESSEL = enumValue.VESSEL;
data.VOYNO = enumValue.VOYNO;
}
}
if (fieldno == 4)
{
data.CTNALL = fielddatastr;
data.SIZE = fielddatastr.Trim().Substring(0,2);
data.CTN = fielddatastr.Trim().Substring(2);
}
if (fieldno == 5)
{
try
{
data.TAREWEIGHT = Convert.ToDecimal(fielddatastr);
}
catch
{
data.TAREWEIGHT = 0;
}
}
if (fieldno == 6)
{
data.SEALNO = fielddatastr.ToString().Trim();
}
fieldno = fieldno + 1;
}
bodyList2.Add(data);
}
i = i + 1;
}
}
#endregion
#region 实装箱信息
var datahtml = GetDataHtmlList(resulthtml.Html, "_ctl0_ContentPlaceHolder1_gvShiZhuang", "</table>");
if (datahtml.ToString().Trim() != "")
{
datahtml = datahtml.Remove(datahtml.IndexOf("</tr>"), 5);
datahtml = datahtml.Remove(0, datahtml.IndexOf(">") + 1);
if (datahtml != "")
{
var i = 1;
while (datahtml.IndexOf("</tr>") >= 0)
{
var datalength = datahtml.IndexOf("</tr>");
var recdatastr = datahtml.Substring(0, datalength + 5);
datahtml = datahtml.Substring(datalength + 5, datahtml.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 != 0)
{
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);
if (fieldno == 1)
{
if (fielddatastr == "&nbsp;") istrue = false; else istrue = true;
}
if (fieldno == 2)
{
data.CNTRNO = fielddatastr.Trim();
if (fielddatastr == "&nbsp;") istrue = false; else istrue = true;
foreach (var enumValue in bodyList2)
{
if (enumValue.CNTRNO.ToString().Trim() == fielddatastr.Trim())
{
data.SEALNO = enumValue.SEALNO.ToString().Trim();
data.CTNALL = enumValue.CTNALL;
data.SIZE = enumValue.SIZE;
data.CTN = enumValue.CTN;
data.TAREWEIGHT = enumValue.TAREWEIGHT;
}
}
foreach (var enumValue in bodyList3)
{
data.VESSEL = enumValue.VESSEL;
data.VOYNO = enumValue.VOYNO;
}
}
if (fieldno == 4)
{
data.SEALNO = fielddatastr.ToString().Trim();
}
if (fieldno == 6)
{
try
{
data.TAREWEIGHT = Convert.ToDecimal(fielddatastr);
}
catch
{
}
}
if (fieldno == 8)
{
//data.KINDPKGS = fielddatastr;
}
if (fieldno == 10)
{
try
{
data.PKGS = Convert.ToInt32(fielddatastr);
}
catch
{
data.PKGS = 0;
}
}
if (fieldno == 11)
{
try
{
data.KGS = Convert.ToDecimal(fielddatastr);
}
catch
{
data.KGS = 0;
}
}
if (fieldno == 12)
{
try
{
data.CBM = Convert.ToDecimal(fielddatastr);
}
catch
{
data.CBM = 0;
}
}
fieldno = fieldno + 1;
}
if (istrue)
bodyList.Add(data);
}
i = i + 1;
}
}
else
{
bodyList = bodyList2;
}
}
else
{
bodyList = bodyList2;
}
#endregion
if (bodyList.Count == 0)
{
bodyList = bodyList3;
}
bodyList = SumBodyList(bodyList);
result.Data = bodyList.ToList();
}
}
catch
{
result.Success = false;
result.Message = "提取数据过程中发生错误,请联系系统管理员!";
}
return result;
}
#endregion
#region 中创_港联欣场站//6TAOSD0245
static public DBResult GetGangLianXinWEBCTNList(string mblno, string bsno, bool isweb = false)
{
//2017-02-06
//地址http://www.cmlog.com:8003/cmlwebservice/CaragtQuery_LH.asmx
//GetInfo为远达
//GetInfoGlx为港联欣
var result = new DBResult();
result.Success = true;
var bodyList = new List<MsOpSeaeDetail>();
var bodyList2 = new List<MsOpSeaeDetail>();
var bodyList3 = new List<MsOpSeaeDetail>();
try
{
#region 连接地址URL
HttpHelper http = new HttpHelper();
HttpItem item = new HttpItem()
{
URL = "http://www.cmlog.com.cn/zcxt/glx/ExportUsual.aspx",//URL这里都是测试 必需项
Encoding = null,//编码格式utf-8,gb2312,gbk 可选项 默认类会自动识别
Host = "www.cmlog.com.cn",
UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)",
Accept = "text/html, application/xhtml+xml, */*",// 可选项有默认值
ContentType = "text/html",
Method = "GET",//URL 可选项 默认为Get
};
HttpResult resulthtml = http.GetHtml(item);
//
var viewstatehtml = resulthtml.Html;
viewstatehtml = GetDataHtmlList(viewstatehtml, "__VIEWSTATE", "/>");
viewstatehtml = viewstatehtml.Replace("\"", "");
viewstatehtml = GetDataHtmlList(viewstatehtml, "value=", "/>").Trim();
viewstatehtml = viewstatehtml.Replace("+", "%2B");
viewstatehtml = viewstatehtml.Replace("/", "%2F");
viewstatehtml = "__EVENTTARGET=&__EVENTARGUMENT=&__VIEWSTATE=" + viewstatehtml + "&__VIEWSTATEENCRYPTED=" + "&_ctl0%3AContentPlaceHolder1%3ATextBox1=" + mblno + "&_ctl0%3AContentPlaceHolder1%3AbtnQuery=%E6%9F%A5+%E8%AF%A2&_ctl0%3AContentPlaceHolder1%3AhidAtddt=2019%2f5%2f5+7%3a00%3a00&_ctl0%3AContentPlaceHolder1%3AhidCMAFX=&_ctl0%3AContentPlaceHolder1%3AhidLocklb=&_ctl0%3AContentPlaceHolder1%3AhidCorplb=";
// viewstatehtml = GetDataHtmlList(viewstatehtml, "/", "/>").Trim();
// viewstatehtml = "__EVENTTARGET=&__EVENTARGUMENT=&__VIEWSTATE=%2F" + viewstatehtml + "&_ctl0%3AContentPlaceHolder1%3ATextBox1=" + mblno + "&_ctl0%3AContentPlaceHolder1%3AbtnQuery=%E6%9F%A5+%E8%AF%A2&_ctl0%3AContentPlaceHolder1%3AhidAtddt=2015%2F4%2F19+7%3A40%3A00&_ctl0%3AContentPlaceHolder1%3AhidCMAFX=&_ctl0%3AContentPlaceHolder1%3AhidLocklb=0&_ctl0%3AContentPlaceHolder1%3AhidCorplb=";
// viewstatehtml = viewstatehtml.Replace("+", "%2B");
// viewstatehtml = viewstatehtml.Replace("/", "%2F");
var mycookie = resulthtml.Cookie;
item = new HttpItem()
{
URL = "http://www.cmlog.com.cn/zcxt/glx/ExportUsual.aspx",//URL这里都是测试 必需项
Referer = "http://www.cmlog.com.cn/zcxt/glx/ExportUsual.aspx",
Encoding = null,//编码格式utf-8,gb2312,gbk 可选项 默认类会自动识别
Host = "www.cmlog.com.cn",
UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36",
Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3",
ContentType = "application/x-www-form-urlencoded",
Cookie = mycookie,
//2016-12-14 重新从网站获取Postdata配置信息
Postdata = viewstatehtml,
Method = "POST",//URL 可选项 默认为Get
};
#endregion
resulthtml = http.GetHtml(item);
if (isweb == true)
{
var datahtml = resulthtml.Html;
datahtml = datahtml.Replace("../Css/admincenter.css", "http://www.cmlog.com.cn/zcxt/Css/admincenter.css");
result.Data = datahtml;
}
else
{
#region 船名航次信息
var datahtml3 = GetDataHtmlList(resulthtml.Html, "_ctl0_ContentPlaceHolder1_gvVesvoy", "</table>");
if (datahtml3 != "")
{
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);
if (fieldno == 4)
{
data.VESSEL = fielddatastr;
}
if (fieldno == 5)
{
data.VOYNO = fielddatastr;
}
fieldno = fieldno + 1;
}
bodyList3.Add(data);
}
i = i + 1;
}
}
#endregion
#region 用箱信息
var datahtml2 = GetDataHtmlList(resulthtml.Html, "_ctl0_ContentPlaceHolder1_gvExprestu", "</table>");
if (datahtml2 != "")
{
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;
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);
if (fieldno == 1)
{
}
if (fieldno == 2)
{
data.CNTRNO = fielddatastr;
foreach (var enumValue in bodyList3)
{
data.VESSEL = enumValue.VESSEL;
data.VOYNO = enumValue.VOYNO;
}
}
if (fieldno == 4)
{
data.CTNALL = fielddatastr;
data.SIZE = fielddatastr.Trim().Substring(0, 2);
data.CTN = fielddatastr.Trim().Substring(2);
}
if (fieldno == 5)
{
try
{
data.TAREWEIGHT = Convert.ToDecimal(fielddatastr);
}
catch
{
data.TAREWEIGHT = 0;
}
}
if (fieldno == 6)
{
data.SEALNO = fielddatastr.ToString().Trim();
}
fieldno = fieldno + 1;
}
bodyList2.Add(data);
}
i = i + 1;
}
}
#endregion
#region 实装箱信息
var datahtml = GetDataHtmlList(resulthtml.Html, "_ctl0_ContentPlaceHolder1_gvShiZhuang", "</table>");
if (datahtml.ToString().Trim() != "")
{
datahtml = datahtml.Remove(datahtml.IndexOf("</tr>"), 5);
datahtml = datahtml.Remove(0, datahtml.IndexOf(">") + 1);
if (datahtml != "")
{
var i = 1;
while (datahtml.IndexOf("</tr>") >= 0)
{
var datalength = datahtml.IndexOf("</tr>");
var recdatastr = datahtml.Substring(0, datalength + 5);
datahtml = datahtml.Substring(datalength + 5, datahtml.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 != 0)
{
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);
if (fieldno == 1)
{
if (fielddatastr == "&nbsp;") istrue = false; else istrue = true;
}
if (fieldno == 2)
{
data.CNTRNO = fielddatastr.Trim();
if (fielddatastr == "&nbsp;") istrue = false; else istrue = true;
foreach (var enumValue in bodyList2)
{
if (enumValue.CNTRNO.ToString().Trim() == fielddatastr.Trim())
{
data.SEALNO = enumValue.SEALNO;
data.CTNALL = enumValue.CTNALL;
data.SIZE = enumValue.SIZE;
data.CTN = enumValue.CTN;
data.TAREWEIGHT = enumValue.TAREWEIGHT;
}
}
foreach (var enumValue in bodyList3)
{
data.VESSEL = enumValue.VESSEL;
data.VOYNO = enumValue.VOYNO;
}
}
if (fieldno == 4)
{
data.SEALNO = fielddatastr.ToString().Trim();
}
if (fieldno == 6)
{
try
{
data.TAREWEIGHT = Convert.ToDecimal(fielddatastr);
}
catch
{
}
}
if (fieldno == 8)
{
//data.KINDPKGS = fielddatastr;
}
if (fieldno == 10)
{
try
{
data.PKGS = Convert.ToInt32(fielddatastr);
}
catch
{
data.PKGS = 0;
}
}
if (fieldno == 11)
{
try
{
data.KGS = Convert.ToDecimal(fielddatastr);
}
catch
{
data.KGS = 0;
}
}
if (fieldno == 12)
{
try
{
data.CBM = Convert.ToDecimal(fielddatastr);
}
catch
{
data.CBM = 0;
}
}
fieldno = fieldno + 1;
}
if (istrue)
bodyList.Add(data);
}
i = i + 1;
}
}
else
{
bodyList = bodyList2;
}
}
else
{
bodyList = bodyList2;
}
#endregion
if (bodyList.Count == 0)
{
bodyList = bodyList3;
}
bodyList = SumBodyList(bodyList);
result.Data = bodyList.ToList();
}
}
catch
{
result.Success = false;
result.Message = "提取数据过程中发生错误,请联系系统管理员!";
}
return result;
}
#endregion
#region 珉钧场站//6TAOKU6860//无船名航次,暂不提取
static public DBResult GetMJCZCTNList ( string mblno, string bsno, bool isweb = false)
{
var result = new DBResult();
result.Success = true;
var bodyList = new List<MsOpSeaeDetail>();
MsOpSeaeQDPortDataDAL msd=new MsOpSeaeQDPortDataDAL("");
try
{
HttpResult resulthtml=new HttpResult();
for (int i = 0; i < 7; i++)
{
Dictionary<string, string> dict = msd.getVerificationCodebygdv(0,"http://www.gfqd.com.cn/vcode.asp");//<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;
}
HttpHelper http = new HttpHelper();
HttpItem item = new HttpItem()
{
URL = "http://www.gfqd.com.cn/bnq.asp",//URL这里都是测试 必需项
ContentType = "application/x-www-form-urlencoded",
Postdata = "bill_no=" + mblno + "&yzm=" + dict.Keys.First(),
UserAgent = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.170 Safari/537.36",
Method = "post",
Cookie = dict.Values.First()
};
if (!http.GetHtml(item).Html.Contains("您输入的确认码和系统产生的不一致,请重新输入!"))
{
resulthtml = http.GetHtml(item);
break;
}
}
if (String.IsNullOrEmpty(resulthtml.Html))
{
result.Success = false;
result.Message = "提取数据超时,请重试!";
return result;
}
if (isweb == true)
{
var datahtml = resulthtml.Html;
datahtml = datahtml.Replace("css/main.css", "http://www.gfqd.com.cn/css/main.css");
result.Data = datahtml;
}
else
{
Regex reg = new Regex(@"<table.*(?=>)(.|\n)*?</table>");
var datahtml = reg.Match(resulthtml.Html).Value;//匹配所有table标签(包含p标签、h2标签)
datahtml = new Regex(@"<p>&nbsp;</p>").Replace(datahtml, "");//去掉 p标签
datahtml = new Regex(@"<h2 class=\'bold\'>\s*([^u4e00-u9fa5]){5,6}</h2>").Replace(datahtml, "");//去掉 h2标签及其内容
string[] tableArr = datahtml.Split(new string[] { "<table>","</table>" }, StringSplitOptions.RemoveEmptyEntries);//按table分组
if (tableArr.Length > 2)
{
datahtml = tableArr[2] + "</table>"; //取第三个table
datahtml = new Regex(@"(?<=<table)\s*[\w=%\'\s#]*").Replace(datahtml, "");//去掉 table标签内所有属性
datahtml = new Regex(@"&nbsp;+|[\r\n]*").Replace(datahtml, "");//去掉 nbsp;、换行和回车符
datahtml = new Regex(@"<font color=\'#\w+\'>\s*|\s*</font>").Replace(datahtml, "");//去掉 font标签及空白字符
datahtml = new Regex(@"(?<=<tr)\s*\w+=\d+").Replace(datahtml, "");//去掉 tr标签内的属性
datahtml = new Regex(@"(?<=<td)\s*\w+=\'#\w+\'").Replace(datahtml, "");//去掉 td标签内的属性
datahtml = new Regex(@"(?<=<td>)\s*").Replace(datahtml, "");//去掉 td标签innerHTML中的空白
datahtml = new Regex(@"<table>|</table>").Replace(datahtml, "");
var trList = datahtml.Split(new string[] { "<tr>", "</tr>" }, StringSplitOptions.RemoveEmptyEntries).ToList();//按tr分组
trList.RemoveAt(0);//删除表头
//遍历tr列表 foreach...
foreach (var item in trList)
{
var tdList = item.Split(new string[] { "<td>", "</td>" }, StringSplitOptions.RemoveEmptyEntries).ToList();//按td分组
MsOpSeaeDetail data = new MsOpSeaeDetail();
data.BSNO = bsno;//业务编号
data.CTNNUM = 1;//箱量
data.CNTRNO = tdList[1];//箱号;
data.CTNALL = tdList[3] + tdList[4];//箱型
data.TAREWEIGHT = String.IsNullOrEmpty(tdList[9]) ? 0M : Convert.ToDecimal(tdList[9]);//皮重
data.PKGS = String.IsNullOrEmpty(tdList[6]) ? 0 : Convert.ToInt32(tdList[6]);//件数
data.KGS = String.IsNullOrEmpty(tdList[7]) ? 0M : Convert.ToDecimal(tdList[7]);//重量
data.CBM = String.IsNullOrEmpty(tdList[8]) ? 0M : Convert.ToDecimal(tdList[8]);//尺码(寸)
data.SEALNO = tdList[2];//铅封号
bodyList.Add(data);
}
}
//泛型集合处理
bodyList = SumBodyList(bodyList);
result.Data = bodyList.ToList();
}
}
catch(Exception se)
{
result.Success = false;
result.Message = se.Message;
}
return result;
}
#endregion
#region 明港场站/海铁中心//140600161817//MOLU11029771705
static public DBResult GetMGCZCTNList ( string mblno, string bsno, bool isweb = false )
{
var result = new DBResult();
result.Success = true;
//var bodyList = new List<MsOpSeaeDetail>();
//var bodyList3 = new List<MsOpSeaeDetail>();
//try
//{
// var datahtml = MsGetQingdaoPortDAL.GetHtmlData("http://www.qingdaoport.net/ywzx/qqct/dpcx/cargoDyaMgcz.jsp", "tdh=" + mblno);
// if (isweb == true)
// {
// datahtml = datahtml.Replace("/common/css/style2009.css", "http://www.qingdaoport.net/common/css/style2009.css");
// datahtml = datahtml.Replace("/common/css/table.css", "http://www.qingdaoport.net/common/css/table.css");
// datahtml = datahtml.Replace("/common/js/common.js", "http://www.qingdaoport.net/common/js/common.js");
// datahtml = datahtml.Replace("/common/js/validation.js", "http://www.qingdaoport.net/common/js/validation.js");
// datahtml = datahtml.Replace("/common/js/date.js", "http://www.qingdaoport.net/common/js/date.js");
// //var i = datahtml.IndexOf("<table");
// //var j = datahtml.IndexOf("</TBODY>\r\n</TABLE>");
// //datahtml = datahtml.Remove(i, j + 20 - i);
// //i = datahtml.IndexOf("<form");
// //j = datahtml.IndexOf("</form>");
// //datahtml = datahtml.Remove(i, j + 7 - i);
// result.Data = datahtml;
// }
// else
// {
// var datahtml3 = GetDataHtmlList(datahtml, "出口-海关报关单放行", "</table>");
// if (datahtml3 != "" && datahtml3.ToString().IndexOf("暂无") < 0)
// {
// #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>") + 4);
// recdatastr = recdatastr.Remove(recdatastr.IndexOf("</tr>"), 5);
// var fieldno = 1;
// if (i != 1 && i != 2)
// {
// 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);
// if (fielddatastr.IndexOf("</td>") > -1)
// {
// fielddatastr = fielddatastr.Remove(fielddatastr.IndexOf("</td>"), 5);
// }
// fielddatastr = fielddatastr.Remove(0, fielddatastr.IndexOf(">") + 1);
// if (fieldno == 5)
// {
// data.VESSEL = fielddatastr;
// }
// else if (fieldno == 6)
// {
// data.VOYNO = fielddatastr;
// }
// fieldno = fieldno + 1;
// }
// bodyList3.Add(data);
// }
// i = i + 1;
// }
// #endregion
// }
// var datahtml2 = GetDataHtmlList(datahtml, "实际装货信息</b></td>", "</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") + 4);
// recdatastr = recdatastr.Remove(recdatastr.IndexOf("</tr>"), 5);
// var ctnall = "";
// var fieldno = 1;
// if (i != 1 && i != 2)
// {
// 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);
// if (fieldno == 3)
// {
// data.CNTRNO = fielddatastr;
// foreach (var enumValue in bodyList3)
// {
// data.VESSEL = enumValue.VESSEL;
// data.VOYNO = enumValue.VOYNO;
// }
// }
// if (fieldno == 4)
// {
// ctnall = fielddatastr;
// }
// if (fieldno == 5)
// {
// data.CTNALL = fielddatastr + ctnall;
// }
// if (fieldno == 6)
// {
// data.SEALNO = fielddatastr;
// }
// if (fieldno == 7)
// {
// try
// {
// data.PKGS = Convert.ToInt32(fielddatastr);
// }
// catch
// {
// data.PKGS = 0;
// }
// }
// if (fieldno == 8)
// {
// data.KINDPKGS = fielddatastr;
// }
// if (fieldno == 9)
// {
// try
// {
// data.KGS = Convert.ToDecimal(fielddatastr);
// }
// catch
// {
// data.KGS = 0;
// }
// }
// if (fieldno == 10)
// {
// try
// {
// data.CBM = Convert.ToDecimal(fielddatastr);
// }
// catch
// {
// }
// }
// fieldno = fieldno + 1;
// }
// bodyList.Add(data);
// }
// i = i + 1;
// }
// #endregion
// }
// bodyList = SumBodyList(bodyList);
// if (bodyList.Count > 0)
// {
// result.Data = bodyList.ToList();
// }
// else
// {
// datahtml2 = GetDataHtmlList(datahtml, "码头信息", "合计");
// if (datahtml2 != "" && datahtml2.ToString().IndexOf("暂无") < 0)
// {
// #region 码头信息
// var i = 1;
// var ctnall = "";
// 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>") + 4);
// recdatastr = recdatastr.Remove(recdatastr.IndexOf("</tr>"), 5);
// var fieldno = 1;
// if (i != 1 && i != 2)
// {
// 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);
// if (fielddatastr.IndexOf("</td>") > -1)
// {
// fielddatastr = fielddatastr.Remove(fielddatastr.IndexOf("</td>"), 5);
// }
// fielddatastr = fielddatastr.Remove(0, fielddatastr.IndexOf(">") + 1);
// if (fieldno == 5)
// {
// fielddatastr = fielddatastr.Remove(0, fielddatastr.IndexOf(">") + 1);
// fielddatastr = fielddatastr.Remove(0, fielddatastr.IndexOf(">") + 1);
// if (fielddatastr.IndexOf("</a>") > -1)
// {
// fielddatastr = fielddatastr.Remove(fielddatastr.IndexOf("</a>"), 4);
// }
// data.CNTRNO = fielddatastr;
// foreach (var enumValue in bodyList3)
// {
// data.VESSEL = enumValue.VESSEL;
// data.VOYNO = enumValue.VOYNO;
// }
// }
// else if (fieldno == 6)
// {
// ctnall = fielddatastr;//尺码
// }
// else if (fieldno == 7)
// {
// data.CTNALL = ctnall + fielddatastr;//表现形式
// }
// else if (fieldno == 9)
// {
// data.SEALNO = fielddatastr;//铅封号
// }
// else if (fieldno == 10)
// {
// try
// {
// data.TAREWEIGHT = Convert.ToDecimal(fielddatastr); //箱皮重
// }
// catch
// {
// data.TAREWEIGHT = 0; //箱皮重
// }
// }
// data.KGS = 0; //毛重
// data.PKGS = 0; //件数
// fieldno = fieldno + 1;
// }
// bodyList.Add(data);
// }
// i = i + 1;
// }
// #endregion
// }
// datahtml2 = GetDataHtmlList(datahtml, "出口-海关报关单放行", "</table>");
// if (datahtml2 != "" && datahtml2.ToString().IndexOf("暂无") < 0)
// {
// #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>") + 4);
// recdatastr = recdatastr.Remove(recdatastr.IndexOf("</tr>"), 5);
// var fieldno = 1;
// if (i != 1 && i != 2)
// {
// 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);
// if (fielddatastr.IndexOf("</td>") > -1)
// {
// fielddatastr = fielddatastr.Remove(fielddatastr.IndexOf("</td>"), 5);
// }
// fielddatastr = fielddatastr.Remove(0, fielddatastr.IndexOf(">") + 1);
// if (fieldno == 8)
// {
// fielddatastr = fielddatastr.Remove(0, fielddatastr.IndexOf(">") + 1);
// fielddatastr = fielddatastr.Remove(0, fielddatastr.IndexOf(">") + 1);
// if (fielddatastr.IndexOf("</a>") > -1)
// {
// fielddatastr = fielddatastr.Remove(fielddatastr.IndexOf("</a>"), 4);
// }
// data.CNTRNO = fielddatastr;
// }
// else if (fieldno == 5)
// {
// data.VESSEL = fielddatastr;
// }
// else if (fieldno == 6)
// {
// data.VOYNO = fielddatastr;
// }
// else if (fieldno == 4)
// {
// try
// {
// data.PKGS = Convert.ToInt32(fielddatastr); //件数
// }
// catch
// {
// data.PKGS = 0; //件数
// }
// }
// else if (fieldno == 10)
// {
// try
// {
// data.KGS = Convert.ToDecimal(fielddatastr); //毛重
// }
// catch
// {
// data.KGS = 0; //毛重
// }
// }
// fieldno = fieldno + 1;
// }
// bodyList.Add(data);
// }
// i = i + 1;
// }
// #endregion
// }
// }
// if (bodyList.Count == 0)
// {
// bodyList = bodyList3;
// }
// bodyList = SumBodyList(bodyList);
// result.Data = bodyList.ToList();
// }
//}
//catch
//{
// result.Success = false;
// result.Message = "提取数据过程中发生错误,请联系系统管理员!";
//}
return result;
}
#endregion
public class dgcz
{
public string RN { get; set; }
public string TDH { get; set; }
public string XH { get; set; }
public string CC { get; set; }
public string XX { get; set; }
public string QFH1 { get; set; }
public string JS { get; set; }
public string HZ { get; set; }
public string TJ { get; set; }
}
#region 明港东港场站/东港场站//OOLU2579806180//船名航次为中文,提取时需要从船名航次表中提取英文数据,没有则显示中文船名
static public DBResult GetMGDGCTNList ( string mblno, string bsno, bool isweb = false )
{
var result = new DBResult();
result.Success = true;
var bodyList = new List<MsOpSeaeDetail>();
var bodyList2 = new List<MsOpSeaeDetail>();
var bodyList3 = new List<MsOpSeaeDetail>();
try
{
#region 抓取页面
HttpHelper http = new HttpHelper();
HttpItem item = new HttpItem()
{
URL = "http://qoct.qingdao-port.com/cjtdcx/index.jhtml",//URL这里都是测试 必需项
Encoding = null,//编码格式utf-8,gb2312,gbk 可选项 默认类会自动识别
Host = "qoct.qingdao-port.com",
UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)",
Accept = "text/html, application/xhtml+xml, */*",// 可选项有默认值
ContentType = "text/html",
Method = "get",//URL 可选项 默认为Get
};
HttpResult resulthtml = http.GetHtml(item);
var mycookie = resulthtml.Cookie;
item = new HttpItem()
{
URL = "http://qoct.qingdao-port.com/data.jspx",//URL这里都是测试 必需项
Referer = "http://qoct.qingdao-port.com/cjtdcx/index.jhtml",
Encoding = null,//编码格式utf-8,gb2312,gbk 可选项 默认类会自动识别
Cookie = mycookie,
Host = "qoct.qingdao-port.com",
UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)",
Accept = "text/html, application/xhtml+xml, */*",// 可选项有默认值
ContentType = "application/x-www-form-urlencoded",
Postdata = "pageNo=1&tdh=" + mblno + "&flag=sjzh&pageSize=10",
Method = "POST",//URL 可选项 默认为Get
};
#endregion
resulthtml = http.GetHtml(item);
var data1 = new System.Web.Script.Serialization.JavaScriptSerializer()
.Deserialize<List<dgcz>>(resulthtml.Html);
var str = "<table>";
foreach(var item1 in data1)
{
//循环显示的代号、名称、父级代号
str += "<tr><td>" + item1.RN
+ "</td><td>" + item1.TDH
+ "</td><td>" + item1.XH
+ "</td><td>" + item1.CC
+ "</td><td>" + item1.XX
+ "</td><td>" + item1.QFH1
+ "</td><td>" + item1.JS
+ "</td><td>" + item1.HZ
+ "</td><td>" + item1.TJ
+ "</td></tr>";
}
str += "</table>";
resulthtml.Html = str;
if (isweb == true)
{
var datahtml = resulthtml.Html;
datahtml = datahtml.Replace("/gxcz/common/css/Style.css", "http://www.qingdaoportec.net/gxcz/common/css/Style.css");
datahtml = datahtml.Replace("/gxcz/common/css/Styletit.css", "http://www.qingdaoportec.net/gxcz/common/css/Styletit.css");
datahtml = datahtml.Replace("common/css/css.css", "http://www.qingdaoportec.net/nqoct/common/css/css.css");
//var i = datahtml.IndexOf("<table");
//var j = datahtml.IndexOf("</TBODY>\r\n</TABLE>");
//datahtml = datahtml.Remove(i, j + 20 - i);
//i = datahtml.IndexOf("<form");
//j = datahtml.IndexOf("</form>");
//datahtml = datahtml.Remove(i, j + 7 - i);
result.Data = datahtml;
}
else
{
//OOLU2581018180
#region 订舱信息
var datahtml3 = GetDataHtmlList(resulthtml.Html, "订舱信息", "</table>");
if (datahtml3 != "")
{
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)
{
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
MsOpSeaeDetail data = new MsOpSeaeDetail();
data.BSNO = bsno;//业务编号
data.CTNNUM = 1;//箱量
while (fieldno <= 2)
{
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);
if (fieldno == 1)
{
fielddatastr = fielddatastr.Remove(0, fielddatastr.IndexOf(">") + 1);
data.VESSEL = fielddatastr;
string sVESSEL = T_ALL_DA.GetStrSQL("VESSEL", "select top 1 isnull(VESSEL,'') as VESSEL from code_vessel where CNAME='" + data.VESSEL.ToString().Trim() + "'");
data.VESSEL = (sVESSEL == "" ? data.VESSEL.ToString().Trim() : sVESSEL);
}
if (fieldno == 2)
{
data.VOYNO = fielddatastr;
}
fieldno = fieldno + 1;
}
bodyList3.Add(data);
}
i = i + 1;
}
}
#endregion
#region 集货动态
var datahtml2 = GetDataHtmlList(resulthtml.Html, "集货动态", "</table>");
if (datahtml2 != "")
{
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 ctnall = "";
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);
if (fieldno == 1)
{
fielddatastr = fielddatastr.Remove(0, fielddatastr.IndexOf(">") + 1);
data.CNTRNO = fielddatastr;
foreach (var enumValue in bodyList3)
{
data.VESSEL = enumValue.VESSEL;
data.VOYNO = enumValue.VOYNO;
}
}
if (fieldno == 2)
{
ctnall = fielddatastr;
}
if (fieldno == 3)
{
data.CTNALL = ctnall + fielddatastr;
}
if (fieldno == 4)
{
try
{
data.TAREWEIGHT = Convert.ToDecimal(fielddatastr);
}
catch
{
}
}
if (fieldno == 5)
{
data.SEALNO = fielddatastr;
}
fieldno = fieldno + 1;
}
bodyList2.Add(data);
}
i = i + 1;
}
}
#endregion
#region 实际装货信息
foreach (var item1 in data1)
{
MsOpSeaeDetail data = new MsOpSeaeDetail();
data.BSNO = bsno;//业务编号
data.CTNNUM = 1;//箱量
data.CNTRNO = item1.XH;//箱号
data.CBM = Convert.ToDecimal(item1.TJ);//
data.CTNALL = item1.CC + item1.XX;//尺寸+箱型(箱型)
data.KGS = Convert.ToDecimal(item1.HZ); //毛重
data.PKGS = Convert.ToInt32(item1.JS); //件数
data.VESSEL = "";
data.VOYNO = "";
data.SEALNO = item1.QFH1;
data.TAREWEIGHT = 0; //箱皮重
bodyList.Add(data);
}
#endregion
bodyList = SumBodyList(bodyList);
bodyList2 = SumBodyList(bodyList2);
if (bodyList.Count == 0)
{
if (bodyList2.Count == 0)
{
bodyList2 = bodyList3;
}
result.Data = bodyList2.ToList();
}
else
{
result.Data = bodyList.ToList();
}
}
}
catch
{
result.Success = false;
result.Message = "提取数据过程中发生错误,请联系系统管理员!";
}
return result;
}
#endregion
#region 韩进储运场站//TAQA62234400
static public DBResult GetHANJINCTNList ( string mblno, string bsno, bool isweb = false )
{
var result = new DBResult();
result.Success = true;
var bodyList = new List<MsOpSeaeDetail>();
var bodyList2 = new List<MsOpSeaeDetail>();
var bodyList3 = new List<MsOpSeaeDetail>();
try
{
HttpHelper http = new HttpHelper();
HttpItem item = new HttpItem()
{
URL = "http://222.173.95.226:8889/cntaoyd/renew/CheckBlNo.jsp",//URL这里都是测试 必需项
Referer = "http://222.173.95.226:8889/cntaoyd/renew/FindBl.html",
Encoding = null,//编码格式utf-8,gb2312,gbk 可选项 默认类会自动识别
Host = "222.173.95.226:8889",
UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)",
Accept = "text/html, application/xhtml+xml, */*",// 可选项有默认值
ContentType = "application/x-www-form-urlencoded",
Postdata = "__VIEWSTATE=%2FwEPDwULLTE1ODM4ODE4NTdkZFB2%2BQ0gtbtA1JEPM1RqoXiiVVcC&frm_bl_no=" + mblno + "&__EVENTVALIDATION=%2FwEWAwK%2FxuHvDwLVtaiXDAKln%2FPuCkuicsJ%2FSIejrE6MoE7ttsUASyw6",
Method = "POST",//URL 可选项 默认为Get
};
HttpResult resulthtml = http.GetHtml(item);
if (isweb == true)
{
var datahtml = resulthtml.Html;
datahtml = datahtml.Replace("/cntaoyd/css/tao.css", "http://222.173.95.226:8889/cntaoyd/css/tao.css");
result.Data = datahtml;
}
else
{
var datahtml3 = GetDataHtmlList(resulthtml.Html, "英文船名:", "</table>");
var datahtml = GetDataHtmlList(resulthtml.Html, "id=\"table1\"", "</table>");
var datahtml2 = GetDataHtmlList(resulthtml.Html, "集装箱信息:", "</table>");
#region 船名航次
if (datahtml3 != "")
{
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;
MsOpSeaeDetail data = new MsOpSeaeDetail();
data.BSNO = bsno;//业务编号
data.CTNNUM = 1;//箱量
while (fieldno < 3)
{
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);
if (fieldno == 1)
{
fielddatastr = fielddatastr.Remove(0, fielddatastr.IndexOf(">") + 1);
fielddatastr = fielddatastr.Replace("</span>", "");
data.VESSEL = fielddatastr;
}
if (fieldno == 2)
{
fielddatastr = fielddatastr.Remove(0, fielddatastr.IndexOf("\">") + 1);
fielddatastr = fielddatastr.Remove(0, fielddatastr.IndexOf("\">") + 2);
fielddatastr = fielddatastr.Replace("</span>", "");
data.VOYNO = fielddatastr;
}
fieldno = fieldno + 1;
}
bodyList3.Add(data);
}
#endregion
#region table1信息
if (datahtml2 != "")
{
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;
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);
if (fieldno == 2)
{
fielddatastr = fielddatastr.Remove(0, fielddatastr.IndexOf(">") + 1);
data.CNTRNO = fielddatastr;
foreach (var enumValue in bodyList3)
{
data.VESSEL = enumValue.VESSEL;
data.VOYNO = enumValue.VOYNO;
}
}
if (fieldno == 3)
{
data.SEALNO = fielddatastr;
}
if (fieldno == 5)
{
data.CTNALL = fielddatastr;
}
if (fieldno == 6)
{
try
{
data.TAREWEIGHT = Convert.ToDecimal(fielddatastr);
}
catch
{
}
}
fieldno = fieldno + 1;
}
bodyList2.Add(data);
}
i = i + 1;
}
}
#endregion
#region 集装箱信息
if (datahtml != "")
{
var i = 1;
while (datahtml.IndexOf("</tr>") >= 0)
{
var datalength = datahtml.IndexOf("</tr>");
var recdatastr = datahtml.Substring(0, datalength + 5);
datahtml = datahtml.Substring(datalength + 5, datahtml.Length - datalength - 5);
recdatastr = recdatastr.Remove(0, recdatastr.IndexOf("<tr") + 3);
recdatastr = recdatastr.Remove(recdatastr.IndexOf("</tr>"), 5);
var istrue = false;
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);
if (fieldno == 1)
{
fielddatastr = fielddatastr.Remove(0, fielddatastr.IndexOf(">") + 1);
if (fielddatastr == "" || fielddatastr == "<b>合计</b>") istrue = false; else istrue = true;
}
if (fieldno == 4)
{
fielddatastr = fielddatastr.Remove(0, fielddatastr.IndexOf(">") + 1);
data.CNTRNO = fielddatastr;
foreach (var enumValue in bodyList2)
{
if (enumValue.CNTRNO == fielddatastr)
{
data.SEALNO = enumValue.SEALNO;
data.CTNALL = enumValue.CTNALL;
data.TAREWEIGHT = enumValue.TAREWEIGHT;
}
}
foreach (var enumValue in bodyList3)
{
data.VESSEL = enumValue.VESSEL;
data.VOYNO = enumValue.VOYNO;
}
}
if (fieldno == 5)
{
if (fielddatastr != "")
data.SEALNO = fielddatastr;
}
if (fieldno == 7)
{
try
{
data.PKGS = Convert.ToInt32(fielddatastr);
}
catch
{
data.PKGS = 0;
}
}
if (fieldno == 8)
{
try
{
fielddatastr = fielddatastr.Replace(",", "");
data.KGS = Convert.ToDecimal(fielddatastr);
}
catch
{
data.KGS = 0;
}
}
if (fieldno == 9)
{
try
{
data.CBM = Convert.ToDecimal(fielddatastr);
}
catch
{
}
}
fieldno = fieldno + 1;
}
if (istrue)
bodyList.Add(data);
}
i = i + 1;
}
}
#endregion
if (bodyList.Count == 0)
{
bodyList = bodyList3;
}
bodyList = SumBodyList(bodyList);
result.Data = bodyList.ToList();
}
}
catch
{
result.Success = false;
result.Message = "提取数据过程中发生错误,请联系系统管理员!";
}
return result;
}
#endregion
#region 青岛QQCTU场站//无法确定页面
//http:///cx.qqctu.cc/system/backend_page!main.action#publicquery/public_query!list?flg=dp//APLU660104669多个提单号都无数据不能确定新页面是否有用
static public DBResult GetQQCTUCTNList ( string mblno, string bsno, bool isweb = false )
{
var result = new DBResult();
result.Success = true;
var bodyList = new List<MsOpSeaeDetail>();
var bodyList2 = new List<MsOpSeaeDetail>();
try
{
HttpHelper http = new HttpHelper();
HttpItem item = new HttpItem()
{
URL = "http://www.qqctu.cc/findTdh.action",//URL这里都是测试 必需项
Encoding = null,//编码格式utf-8,gb2312,gbk 可选项 默认类会自动识别
Host = "www.qqctu.cc",
UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)",
Accept = "text/html, application/xhtml+xml, */*",// 可选项有默认值
ContentType = "text/html",
Method = "get",//URL 可选项 默认为Get
};
HttpResult resulthtml = http.GetHtml(item);
var mycookie = resulthtml.Cookie;
item = new HttpItem()
{
URL = "http://www.qqctu.cc/findTdh.action",//URL这里都是测试 必需项
Referer = "http://www.qqctu.cc/findTdh.action",
Encoding = null,//编码格式utf-8,gb2312,gbk 可选项 默认类会自动识别
Cookie = mycookie,
Host = "www.qqctu.cc",
UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)",
Accept = "text/html, application/xhtml+xml, */*",// 可选项有默认值
ContentType = "application/x-www-form-urlencoded",
Postdata = "billNo=" + mblno + "&btnQueryBill=+%B2%E9%D1%AF+",
Method = "POST",//URL 可选项 默认为Get
};
resulthtml = http.GetHtml(item);
if (isweb == true)
{
var datahtml = resulthtml.Html;
datahtml = datahtml.Replace("../cssjs/", "http://www.qqctu.cc/cssjs/css.css");
datahtml = datahtml.Replace("../iframe/", "http://www.qqctu.cc/iframe/");
datahtml = datahtml.Replace("../common/css/", "http://www.qqctu.cc/common/css/");
result.Data = datahtml;
}
else
{
var datahtml = GetDataHtmlList(resulthtml.Html, "实际装货信息", "</table>");
var datahtml2 = GetDataHtmlList(resulthtml.Html, "集货动态", "</table>");
if (datahtml2 != "")
{
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 ctnall = "";
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("&nbsp;</td>"), 11);
fielddatastr = fielddatastr.Remove(0, fielddatastr.IndexOf(">") + 1);
if (fieldno == 1)
{
fielddatastr = fielddatastr.Remove(0, fielddatastr.IndexOf(">") + 1);
data.CNTRNO = fielddatastr;
}
if (fieldno == 2)
{
ctnall = fielddatastr;
}
if (fieldno == 3)
{
data.CTNALL = ctnall + fielddatastr;
}
if (fieldno == 4)
{
try
{
data.TAREWEIGHT = Convert.ToDecimal(fielddatastr);
}
catch
{
}
}
if (fieldno == 5)
{
data.SEALNO = fielddatastr;
}
fieldno = fieldno + 1;
}
bodyList2.Add(data);
}
i = i + 1;
}
}
if (datahtml != "")
{
var i = 1;
while (datahtml.IndexOf("</tr>") >= 0)
{
var datalength = datahtml.IndexOf("</tr>");
var recdatastr = datahtml.Substring(0, datalength + 5);
datahtml = datahtml.Substring(datalength + 5, datahtml.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("&nbsp;</td>"), 11);
fielddatastr = fielddatastr.Remove(0, fielddatastr.IndexOf(">") + 1);
if (fieldno == 1)
{
fielddatastr = fielddatastr.Remove(0, fielddatastr.IndexOf(">") + 1);
data.CNTRNO = fielddatastr;
foreach (var enumValue in bodyList2)
{
if (enumValue.CNTRNO == fielddatastr)
{
data.SEALNO = enumValue.SEALNO;
data.CTNALL = enumValue.CTNALL;
data.TAREWEIGHT = enumValue.TAREWEIGHT;
}
}
}
if (fieldno == 2)
{
if (fielddatastr != "")
data.SEALNO = fielddatastr;
}
if (fieldno == 3)
{
try
{
data.PKGS = Convert.ToInt32(fielddatastr);
}
catch
{
data.PKGS = 0;
}
}
if (fieldno == 4)
{
try
{
data.KGS = Convert.ToDecimal(fielddatastr);
}
catch
{
data.KGS = 0;
}
}
if (fieldno == 5)
{
try
{
data.CBM = Convert.ToDecimal(fielddatastr);
}
catch
{
}
}
fieldno = fieldno + 1;
}
bodyList.Add(data);
}
i = i + 1;
}
}
bodyList = SumBodyList(bodyList);
if (bodyList.Count == 0)
result.Data = bodyList2.ToList();
else
result.Data = bodyList.ToList();
}
}
catch
{
result.Success = false;
result.Message = "提取数据过程中发生错误,请联系系统管理员!";
}
return result;
}
#endregion
#region 青岛振华场站 //需求编号SR2017082500003 //EASFT0109QB003 //HASLNREE87000700
static public DBResult GetZHENGHUACTNList ( string mblno, string bsno, bool isweb = false )
{
var result = new DBResult();
result.Success = true;
var bodyList = new List<MsOpSeaeDetail>();
var bodyList3 = new List<MsOpSeaeDetail>();
try
{
#region 抓取页面
HttpHelper http = new HttpHelper();
HttpItem item = new HttpItem()
{
//需求编号SR2017062000001
//原振华场站地址www.qdzh-logistics.com
//原振华场站地址http:///221.215.94.251:8123/search/searchBillCase!findByBillNo
//新振华场站地址http:///58.56.168.6:8123/search/searchBillCase!findByBillNo
// URL = "http://58.56.168.6:8123/search/searchBillCase!findByBillNo",//URL这里都是测试 必需项
URL = "http://222.173.69.38:8123/search/searchBillCase!findByBillNo",//URL这里都是测试 必需项
Encoding = null,//编码格式utf-8,gb2312,gbk 可选项 默认类会自动识别
Host = "222.173.69.38:8123",
UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)",
Accept = "text/html, application/xhtml+xml, */*",// 可选项有默认值
ContentType = "text/html",
Method = "get",//URL 可选项 默认为Get
};
HttpResult resulthtml = http.GetHtml(item);
var mycookie = resulthtml.Cookie;
item = new HttpItem()
{
URL = "http://222.173.69.38:8123/search/searchBillCase!findByBillNo",//URL这里都是测试 必需项
Referer = "http://222.173.69.38:8123/search/searchBillCase!findByBillNo",
Encoding = null,//编码格式utf-8,gb2312,gbk 可选项 默认类会自动识别
Cookie = mycookie,
Host = "222.173.69.38:8123",
UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)",
Accept = "text/html, application/xhtml+xml, */*",// 可选项有默认值
ContentType = "application/x-www-form-urlencoded",
Postdata = "tidan=" + mblno + "&search1=%E6%9F%A5+%E8%AF%A2",
Method = "POST",//URL 可选项 默认为Get
};
#endregion
resulthtml = http.GetHtml(item);
if (isweb == true)
{
var datahtml = resulthtml.Html;
datahtml = datahtml.Replace("/css/catelogue.css", "http://222.173.69.38:8123/css/catelogue.css");
datahtml = datahtml.Replace("/css/public_head_footer.css", "http://222.173.69.38:8123/css/public_head_footer.css");
datahtml = datahtml.Replace("/images/", "http://222.173.69.38:8123/images/");
result.Data = datahtml;
}
else
{
#region 船舶信息
var datahtml3 = GetDataHtmlList(resulthtml.Html, "操作员/电话", "</table>");
datahtml3 = datahtml3.Remove(datahtml3.IndexOf("</tr>"), 5);
datahtml3 = datahtml3.Remove(0, datahtml3.IndexOf(">") + 1);
if (datahtml3 != "")
{
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 != 0)
{
MsOpSeaeDetail data = new MsOpSeaeDetail();
data.BSNO = bsno;//业务编号
data.CTNNUM = 1;//箱量
while (fieldno <= 3)
{
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);
if (fieldno == 2)
{
data.VESSEL = fielddatastr;
}
if (fieldno == 3)
{
data.VOYNO = fielddatastr;
}
fieldno = fieldno + 1;
}
bodyList3.Add(data);
}
i = i + 1;
}
}
#endregion
#region 配箱数据
var datahtml = GetDataHtmlList(resulthtml.Html, "特殊用箱要求", "</table>");
datahtml = datahtml.Remove(datahtml.IndexOf("</tr>"), 5);
datahtml = datahtml.Remove(0, datahtml.IndexOf(">") + 1);
if (datahtml != "")
{
var i = 1;
while (datahtml.IndexOf("</tr>") >= 0)
{
var datalength = datahtml.IndexOf("</tr>");
var recdatastr = datahtml.Substring(0, datalength + 5);
datahtml = datahtml.Substring(datalength + 5, datahtml.Length - datalength - 5);
recdatastr = recdatastr.Remove(0, recdatastr.IndexOf("<tr") + 3);
recdatastr = recdatastr.Remove(recdatastr.IndexOf("</tr>"), 5);
var ctnall = "";
var fieldno = 1;
var istrue = false;
if (i != 0)
{
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);
if (fieldno == 2)
{
if (fielddatastr == "总计:") istrue = false; else istrue = true;
}
if (fieldno == 3)
{
ctnall = fielddatastr;
}
if (fieldno == 4)
{
data.CTNALL = ctnall + fielddatastr;
}
if (fieldno == 5)
{
data.CNTRNO = fielddatastr;
foreach (var enumValue in bodyList3)
{
data.VESSEL = enumValue.VESSEL;
data.VOYNO = enumValue.VOYNO;
}
}
if (fieldno == 6)
{
data.SEALNO = fielddatastr;
}
if (fieldno == 7)
{
try
{
data.TAREWEIGHT = Convert.ToDecimal(fielddatastr);
}
catch
{
data.TAREWEIGHT = 0;
}
}
if (fieldno == 8)
{
try
{
data.PKGS = Convert.ToInt32(fielddatastr);
}
catch
{
data.PKGS = 0;
}
}
if (fieldno == 9)
{
try
{
data.KGS = Convert.ToDecimal(fielddatastr);
}
catch
{
data.KGS = 0;
}
}
if (fieldno == 10)
{
try
{
data.CBM = Convert.ToDecimal(fielddatastr);
}
catch
{
data.CBM = 0;
}
}
fieldno = fieldno + 1;
}
if (istrue)
bodyList.Add(data);
}
i = i + 1;
}
}
#endregion
if (bodyList.Count == 0)
{
bodyList = bodyList3;
}
bodyList = SumBodyList(bodyList);
result.Data = bodyList.ToList();
}
}
catch
{
result.Success = false;
result.Message = "提取数据过程中发生错误,请联系系统管理员!";
}
return result;
}
#endregion
#region 怡之航场站(改名怡航)
static public DBResult GetYZHCTNList ( string mblno, string bsno, string password, bool isweb = false )
{
var result = new DBResult();
result.Success = true;
var bodyList = new List<MsOpSeaeDetail>();
try
{
string url = "http://222.173.95.170:78/Service.asmx";
string[] args = new string[2];
args[0] = mblno;
args[1] = password;
object resultXml = WebServiceHelper.InvokeWebService(url, "P_GETDATA", args);
StringReader rdr = new StringReader(resultXml.ToString());
XmlSerializer serializer = new XmlSerializer(typeof(ZHONGCHUANG));
ZHONGCHUANG xmlDoc = (ZHONGCHUANG)serializer.Deserialize(rdr);
if (xmlDoc != null)
{
zhongchuangtable[] ds = xmlDoc.ds;
for (int i = 0; i < ds.Length; i++)
{
MsOpSeaeDetail data = new MsOpSeaeDetail();
data.CNTRNO = ds[i].CNTRNO;
data.SEALNO = ds[i].SEALNO;
data.CTNALL = ds[i].CTNSIZE + ds[i].CTNTYPE;
try
{
if (ds[i].PKGS != "")
data.PKGS = Convert.ToInt16(ds[i].PKGS);
}
catch
{
data.PKGS = 0;
}
try
{
if (ds[i].KGS != "")
data.KGS = Convert.ToDecimal(ds[i].KGS);
}
catch
{
data.KGS = 0;
}
try
{
if (ds[i].CBM != "")
data.CBM = Convert.ToDecimal(ds[i].CBM);
}
catch
{
data.CBM = 0;
}
try
{
if (ds[i].TAREWEIGHT != "")
data.TAREWEIGHT = Convert.ToDecimal(ds[i].TAREWEIGHT);
}
catch
{
data.TAREWEIGHT = 0;
}
bodyList.Add(data);
}
}
}
catch
{
result.Success = false;
result.Message = "提取数据过程中发生错误,请联系系统管理员!";
}
bodyList = SumBodyList(bodyList);
result.Data = bodyList.ToList();
return result;
}
#endregion
#region 青岛怡航场站/鲁艺场站/港联捷(查询地址相同)//I240195363
static public DBResult GetYIHANGCTNList ( string mblno, string bsno, bool isweb = false )
{
var result = new DBResult();
result.Success = true;
var bodyList = new List<MsOpSeaeDetail>();
var bodyList3 = new List<MsOpSeaeDetail>();
try
{
#region 抓取页面
HttpHelper http = new HttpHelper();
HttpItem item = new HttpItem()
{
// URL = "http://www.worldex.com.cn/glj/querydata/billquerysearch.aspx",//URL这里都是测试 必需项
URL = "http://www.qdglj.cn:1027/querydata/billquerysearch.aspx?tdsourcetag=s_pcqq_aiomsg",//URL这里都是测试 必需项
Encoding = null,//编码格式utf-8,gb2312,gbk 可选项 默认类会自动识别
// Host = "www.worldex.com.cn",
Host = "www.qdglj.cn:1027",
UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)",
Accept = "text/html, application/xhtml+xml, */*",// 可选项有默认值
ContentType = "text/html",
Method = "get",//URL 可选项 默认为Get
};
HttpResult resulthtml = http.GetHtml(item);
var viewstatehtml = resulthtml.Html;
viewstatehtml = GetDataHtmlList(viewstatehtml, "__VIEWSTATE", "/>");
viewstatehtml = viewstatehtml.Replace("\"", "");
viewstatehtml = GetDataHtmlList(viewstatehtml, "/", "/>").Trim();
viewstatehtml = "__VIEWSTATE=%2F" + viewstatehtml + "&ctl00%24Maincontent%24txtBillNo=" + mblno + "&ctl00%24Maincontent%24btnSearch=%E6%9F%A5%E8%AF%A2";
viewstatehtml = viewstatehtml.Replace("+", "%2B");
viewstatehtml = viewstatehtml.Replace("/", "%2F");
var mycookie = resulthtml.Cookie;
item = new HttpItem()
{
URL = "http://www.qdglj.cn:1027/querydata/billquerysearch.aspx?tdsourcetag=s_pcqq_aiomsg",//URL这里都是测试 必需项
Referer = "http://www.qdglj.cn:1027/querydata/billquerysearch.aspx?tdsourcetag=s_pcqq_aiomsg",
Encoding = null,//编码格式utf-8,gb2312,gbk 可选项 默认类会自动识别
Cookie = mycookie,
Host = "www.qdglj.cn:1027",
UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)",
Accept = "text/html, application/xhtml+xml, */*",// 可选项有默认值
ContentType = "application/x-www-form-urlencoded",
Postdata = viewstatehtml,
Method = "POST",//URL 可选项 默认为Get
};
#endregion
resulthtml = http.GetHtml(item);
if (isweb == true)
{
var datahtml = resulthtml.Html;
datahtml = datahtml.Replace("../style/", "http://www.qdglj.cn:1027/style/");
datahtml = datahtml.Replace("../Scripts/", "http://www.qdglj.cn:1027/Scripts/");
datahtml = datahtml.Replace("../scripts/", "http://www.qdglj.cn:1027/scripts/");
datahtml = datahtml.Replace("../css/style.css", "http://www.qdglj.cn:1027/css/style.css");
datahtml = datahtml.Replace("../News/", "http://www.qdglj.cn:1027/News/");
datahtml = datahtml.Replace("../querydata/", "http://www.qdglj.cn:1027/querydata/");
datahtml = datahtml.Replace("#tbDcxx", "");
datahtml = datahtml.Replace("#tbZHXX", "");
datahtml = datahtml.Replace("#tbXhdt", "");
datahtml = datahtml.Replace("#tbZDXH", "");
datahtml = datahtml.Replace("display: none", "display:block");
result.Data = datahtml;
}
else
{
#region 船名航次//需求编号SR2017052500003-3
var datahtml3 = GetDataHtmlList(resulthtml.Html, "tbMainData", "</table>");
datahtml3 = datahtml3.Remove(0, datahtml3.IndexOf(">") + 1);
if (datahtml3 != "")
{
var i = 1;
while (datahtml3.IndexOf("</tr>") >= 0 && i <= 2)
{
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 && recdatastr.IndexOf("暂无相关数据")<0)
{
MsOpSeaeDetail data = new MsOpSeaeDetail();
data.BSNO = bsno;//业务编号
data.CTNNUM = 1;//箱量
while (fieldno <= 2)
{
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", "");
if (fieldno == 1)
{
fielddatastr = fielddatastr.Remove(0, fielddatastr.IndexOf(">") + 1);
fielddatastr = fielddatastr.Remove(fielddatastr.IndexOf("/"));
int ikg = 0;
for (int j = 0; j < fielddatastr.Length; j++)
{
if (fielddatastr.Substring(j, 1) == " ")
{
ikg++;
}
else
{
break;
}
}
fielddatastr = fielddatastr.Remove(0, ikg);
ikg = 0;
for (int j = fielddatastr.Length-1; j > -1; j--)
{
if (fielddatastr.Substring(j, 1) == " ")
{
ikg = j;
}
else
{
break;
}
}
fielddatastr = fielddatastr.Remove(ikg);
data.VESSEL = fielddatastr;
}
if (fieldno == 2)
{
fielddatastr = fielddatastr.Replace(" ", "");
data.VOYNO = fielddatastr;
}
fieldno = fieldno + 1;
}
bodyList3.Add(data);
}
i = i + 1;
}
}
#endregion
#region 实际装货信息
var datahtml = GetDataHtmlList(resulthtml.Html, "实际装货信息", "</table>");
datahtml = datahtml.Remove(datahtml.IndexOf("</tr>"), 5);
datahtml = datahtml.Remove(0, datahtml.IndexOf(">") + 1);
if (datahtml != "")
{
var i = 1;
while (datahtml.IndexOf("</tr>") >= 0)
{
var datalength = datahtml.IndexOf("</tr>");
var recdatastr = datahtml.Substring(0, datalength + 5);
datahtml = datahtml.Substring(datalength + 5, datahtml.Length - datalength - 5);
recdatastr = recdatastr.Remove(0, recdatastr.IndexOf("<tr") + 3);
recdatastr = recdatastr.Remove(recdatastr.IndexOf("</tr>"), 5);
var ctnall = "";
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(" ", "");
if (fieldno == 1)
{
fielddatastr = fielddatastr.Remove(0, fielddatastr.IndexOf(">") + 1);
if (fielddatastr == "合计:" || fielddatastr == "<bstyle=\"color:Red\">暂无相关数据</b>") istrue = false; else istrue = true;
}
if (fieldno == 2)
{
data.CNTRNO = fielddatastr;
foreach (var enumValue in bodyList3)
{
data.VESSEL = enumValue.VESSEL;
data.VOYNO = enumValue.VOYNO;
}
}
if (fieldno == 3)
{
ctnall = fielddatastr;
}
if (fieldno == 4)
{
data.CTNALL = ctnall + fielddatastr;
}
if (fieldno == 5)
{
data.SEALNO = fielddatastr;
}
if (fieldno == 6)
{
try
{
data.PKGS = Convert.ToInt32(fielddatastr);
}
catch
{
data.PKGS = 0;
}
}
if (fieldno == 7)
{
data.KINDPKGS = fielddatastr;
}
if (fieldno == 8)
{
try
{
data.KGS = Convert.ToDecimal(fielddatastr);
}
catch
{
data.KGS = 0;
}
}
if (fieldno == 9)
{
try
{
data.CBM = Convert.ToDecimal(fielddatastr);
}
catch
{
}
}
fieldno = fieldno + 1;
}
if (istrue)
bodyList.Add(data);
}
i = i + 1;
}
}
#endregion
if (bodyList.Count == 0)
{
bodyList = bodyList3;
}
bodyList = SumBodyList(bodyList);
result.Data = bodyList.ToList();
}
}
catch
{
result.Success = false;
result.Message = "提取数据过程中发生错误,请联系系统管理员!";
}
return result;
}
#endregion
#region 烟台国际码头//SNL7YTJLV15T67铅封号//SITYAYOR266371
static public DBResult GetYANTAIYARDList ( string mblno, string bsno, bool isweb = false )
{
var result = new DBResult();
result.Success = true;
var bodyList = new List<MsOpSeaeDetail>();
var bodyList2 = new List<MsOpSeaeDetail>();
var bodyList3 = new List<MsOpSeaeDetail>();
var bodyList4 = new List<MsOpSeaeDetail>();
try
{
HttpHelperX2 ShippHttp = new HttpHelperX2();
var refurl = "http://www.ictsiyantai.com/search/index_common_ingate.asp";//进闸信息查询
var Postdata = "search=true&companyname=&companycode=&bill_no=" + mblno + "&btn3.x=54&btn3.y=13";
var alldatahtml = ShippHttp.PostAndGetHtml(refurl, Postdata, "application/x-www-form-urlencoded", refurl, true, Encoding.GetEncoding("gb2312"));
if (isweb == true)
{
result.Data = alldatahtml;
}
else
{
#region 进闸信息查询
var datahtml = GetDataHtmlList(alldatahtml, "dgdList6", "</table>");
if (datahtml != "")
{
var i = 1;
while (datahtml.IndexOf("</tr>") >= 0)
{
var datalength = datahtml.IndexOf("</tr>");
var recdatastr = datahtml.Substring(0, datalength + 5);
datahtml = datahtml.Substring(datalength + 5, datahtml.Length - datalength - 5);
recdatastr = recdatastr.Remove(0, recdatastr.IndexOf("<tr>") + 4);
recdatastr = recdatastr.Remove(recdatastr.IndexOf("</tr>"), 5);
var fieldno = 1;
var ctnall = "";
if (i != 1)
{
MsOpSeaeDetail data = new MsOpSeaeDetail();
data.BSNO = bsno;//业务编号
data.CTNNUM = 1;//箱量
data.MBLNO = mblno;
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);
if (fieldno == 2)
{
data.CNTRNO = fielddatastr;
}
if (fieldno == 3)
{
data.SIZE = fielddatastr;
ctnall = fielddatastr;
}
if (fieldno == 4)
{
data.CTN = fielddatastr;
if (fielddatastr == "普通箱")
data.CTNALL = ctnall + "GP";
else if (fielddatastr == "超高箱")
data.CTNALL = ctnall + "HC";
else if (fielddatastr.IndexOf("超高冻") > 0)
data.CTNALL = ctnall + "RH";
else if (fielddatastr.IndexOf("冻") > 0)
data.CTNALL = ctnall + "RF";
}
if (fieldno == 6)
{
data.ENTERDOOR = fielddatastr;
}
if (fieldno == 8)
{
data.VESSEL = fielddatastr;
}
if (fieldno == 9)
{
data.VOYNO = fielddatastr;
}
if (fieldno == 14)
{
data.TRUCKNO = fielddatastr;
}
if (fieldno == 15)
{
data.TRUCKTYPE = fielddatastr;
}
fieldno = fieldno + 1;
}
if (data.CNTRNO != "")
bodyList.Add(data);
}
i = i + 1;
}
}
#endregion
#region 出闸信息查询
ShippHttp = new HttpHelperX2();
refurl = "http://www.ictsiyantai.com/search/index_me_gate.asp";//出闸信息查询
Postdata = "search=true&companyname=&companycode=&bill_no=" + mblno + "&btn3.x=52&btn3.y=11";
alldatahtml = ShippHttp.PostAndGetHtml(refurl, Postdata, "application/x-www-form-urlencoded", refurl, true, Encoding.GetEncoding("gb2312"));
datahtml = GetDataHtmlList(alldatahtml, "dgdList6", "</table>");
if (datahtml != "")
{
#region 出闸信息查询
var i = 1;
while (datahtml.IndexOf("</tr>") >= 0)
{
var datalength = datahtml.IndexOf("</tr>");
var recdatastr = datahtml.Substring(0, datalength + 5);
datahtml = datahtml.Substring(datalength + 5, datahtml.Length - datalength - 5);
recdatastr = recdatastr.Remove(0, recdatastr.IndexOf("<tr>") + 4);
recdatastr = recdatastr.Remove(recdatastr.IndexOf("</tr>"), 5);
var fieldno = 1;
var ctnall = "";
if (i != 1)
{
MsOpSeaeDetail data = new MsOpSeaeDetail();
data.BSNO = bsno;//业务编号
data.CTNNUM = 1;//箱量
data.MBLNO = mblno;
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);
if (fieldno == 2)
{
data.CNTRNO = fielddatastr;
}
if (fieldno == 3)
{
data.SIZE = fielddatastr;
ctnall = fielddatastr;
}
if (fieldno == 4)
{
data.CTN = fielddatastr;
if (fielddatastr == "普通箱")
data.CTNALL = ctnall + "GP";
else if (fielddatastr == "超高箱")
data.CTNALL = ctnall + "HC";
else if (fielddatastr.IndexOf("超高冻") > 0)
data.CTNALL = ctnall + "RH";
else if (fielddatastr.IndexOf("冻") > 0)
data.CTNALL = ctnall + "RF";
}
if (fieldno == 6)
{
data.EXITDOOR = fielddatastr;
}
if (fieldno == 8)
{
data.VESSEL = fielddatastr;
}
if (fieldno == 9)
{
data.VOYNO = fielddatastr;
}
if (fieldno == 14)
{
data.TRUCKNO = fielddatastr;
}
if (fieldno == 15)
{
data.TRUCKTYPE = fielddatastr;
}
fieldno = fieldno + 1;
}
if (data.CNTRNO != "")
bodyList2.Add(data);
}
i = i + 1;
}
#endregion
}
bodyList = AddBodyList(bodyList, bodyList2);
#endregion
#region 在港箱信息查询
ShippHttp = new HttpHelperX2();
refurl = "http://www.ictsiyantai.com/search/index_gi_container.asp";//在港箱信息查询
Postdata = "search=true&companyname=&companycode=&container_no=&bill_no=" + mblno + "&btn3.x=33&btn3.y=10";
alldatahtml = ShippHttp.PostAndGetHtml(refurl, Postdata, "application/x-www-form-urlencoded", refurl, true, Encoding.GetEncoding("gb2312"));
datahtml = GetDataHtmlList(alldatahtml, "dgdList6", "</table>");
if (datahtml != "")
{
#region 在港箱信息查询
var i = 1;
while (datahtml.IndexOf("</tr>") >= 0)
{
var datalength = datahtml.IndexOf("</tr>");
var recdatastr = datahtml.Substring(0, datalength + 5);
datahtml = datahtml.Substring(datalength + 5, datahtml.Length - datalength - 5);
recdatastr = recdatastr.Remove(0, recdatastr.IndexOf("<tr>") + 4);
recdatastr = recdatastr.Remove(recdatastr.IndexOf("</tr>"), 5);
var fieldno = 1;
var ctnall = "";
if (i != 1)
{
MsOpSeaeDetail data = new MsOpSeaeDetail();
data.BSNO = bsno;//业务编号
data.CTNNUM = 1;//箱量
data.MBLNO = mblno;
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);
if (fieldno == 2)
{
data.CNTRNO = fielddatastr;
}
if (fieldno == 3)
{
data.SIZE = fielddatastr;
ctnall = fielddatastr;
}
if (fieldno == 4)
{
data.CTN = fielddatastr;
if (fielddatastr == "普通箱")
{
data.CTNALL = ctnall + "GP";
}
else if (fielddatastr == "超高箱")
{
data.CTNALL = ctnall + "HC";
}
else if (fielddatastr.IndexOf("超高冻") > 0)
{
data.CTNALL = ctnall + "RH";
}
else if (fielddatastr.IndexOf("冻") > 0)
{
data.CTNALL = ctnall + "RF";
}
}
if (fieldno == 12)
{
data.CTNSTATUS = fielddatastr;
}
if (fieldno == 19)
{
if (fielddatastr.Length > 4)
{
data.SEALNO = fielddatastr;
}
}
fieldno = fieldno + 1;
}
if (data.CNTRNO != "")
{
bodyList3.Add(data);
}
}
i = i + 1;
}
#endregion
}
bodyList = AddBodyList(bodyList, bodyList3);
#endregion
#region 装船信息查询
foreach (var enumValue in bodyList)
{
ShippHttp = new HttpHelperX2();
refurl = "http://www.ictsiyantai.com/search/index_common_ship.asp";//装船信息查询
Postdata = "search=true&companyname=&companycode=&container_no=" + enumValue.CNTRNO + "&btn3.x=28&btn3.y=9";
alldatahtml = ShippHttp.PostAndGetHtml(refurl, Postdata, "application/x-www-form-urlencoded", refurl, true, Encoding.GetEncoding("gb2312"));
datahtml = GetDataHtmlList(alldatahtml, "dgdList6", "</table>");
if (datahtml != "")
{
#region 装船信息查询
var i = 1;
while (datahtml.IndexOf("</tr>") >= 0)
{
var datalength = datahtml.IndexOf("</tr>");
var recdatastr = datahtml.Substring(0, datalength + 5);
datahtml = datahtml.Substring(datalength + 5, datahtml.Length - datalength - 5);
recdatastr = recdatastr.Remove(0, recdatastr.IndexOf("<tr") + 4);
recdatastr = recdatastr.Remove(0, recdatastr.IndexOf(">") + 1);
recdatastr = recdatastr.Remove(recdatastr.IndexOf("</tr>"), 5);
var fieldno = 1;
var istruectn = 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);
if (fieldno == 3)
{
data.MBLNO = fielddatastr;
if (data.MBLNO == enumValue.MBLNO)
istruectn = true;
else
istruectn = false;
}
if (fieldno == 4)
{
data.CNTRNO = fielddatastr;
}
if (fieldno == 8)
{
data.ONBORD = fielddatastr;
}
if (fieldno == 9)
{
data.ETD = fielddatastr;
}
fieldno = fieldno + 1;
}
if (istruectn)
bodyList4.Add(data);
}
i = i + 1;
}
#endregion
}
}
bodyList = AddBodyList(bodyList, bodyList4);
#endregion
result.Data = bodyList.ToList();
}
}
catch
{
result.Success = false;
result.Message = "提取数据过程中发生错误,请联系系统管理员!";
}
return result;
}
#endregion
#region 胜狮场站
static public DBResult GetSSCZCTNList ( string mblno, string bsno, bool isweb = false )
{
var result = new DBResult();
result.Success = true;
var bodyList = new List<MsOpSeaeDetail>();
try
{
if (isweb == true)
{
HttpHelper http = new HttpHelper();
HttpItem item = new HttpItem()
{
URL = "http://www.ssqd.cn/Scfs.aspx",//URL这里都是测试 必需项
Referer = "http://www.ssqd.cn/Scfs.aspx",
Encoding = null,//编码格式utf-8,gb2312,gbk 可选项 默认类会自动识别
Host = "www.ssqd.cn:808",
UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)",
Accept = "text/html, application/xhtml+xml, */*",// 可选项有默认值
ContentType = "application/x-www-form-urlencoded",
//Postdata = "__LASTFOCUS=&__EVENTTARGET=&__EVENTARGUMENT=&__VIEWSTATE=%2FwEPDwUKMjEwNDg2MDI2MA9kFgICAw9kFgoCCw8PZBYCHgVzdHlsZQUMZGlzcGxheTpub25lZAITDzwrABEBARAWABYAFgBkAhUPD2QWAh8ABQxkaXNwbGF5Om5vbmVkAhcPPCsAEQBkAhsPZBYEAgEPD2QWAh8ABQxkaXNwbGF5Om5vbmVkAgMPD2QWAh8ABQxkaXNwbGF5Om5vbmVkGAIFCUdyaWRWaWV3Mg9nZAUJR3JpZFZpZXcxD2dkAHBKIVh3fH2rbiwgkQ7dV38iMda4tjD0mZSM47VhHIw%3D&__VIEWSTATEGENERATOR=4FCC0923&TextBox1=" + mblno + "&Button1=%E6%9F%A5%E8%AF%A2",
Postdata = "__LASTFOCUS=&__EVENTTARGET=&__EVENTARGUMENT=&__VIEWSTATE=%2FwEPDwULLTEwMTA3ODM3MzEPZBYCAgMPZBYKAgsPD2QWAh4Fc3R5bGUFDGRpc3BsYXk6bm9uZWQCEw88KwARAQEQFgAWABYAZAIVDw9kFgIfAAUMZGlzcGxheTpub25lZAIXDzwrABEAZAIbD2QWBAIBDw9kFgIfAAUMZGlzcGxheTpub25lZAIDDw9kFgIfAAUMZGlzcGxheTpub25lZBgCBQlHcmlkVmlldzIPZ2QFCUdyaWRWaWV3MQ9nZNmmDFDfxTd%2FuZdDk8fTvUEhK3v5vIsxkxJW8a5LNuUF&__VIEWSTATEGENERATOR=4FCC0923&TextBox1=" + mblno + "&Button1=%E6%9F%A5%E8%AF%A2",
Method = "POST",//URL 可选项 默认为Get
};
HttpResult resulthtml = http.GetHtml(item);
var viewstatehtml = resulthtml.Html;
viewstatehtml = GetDataHtmlList(viewstatehtml, "__VIEWSTATE", "/>");
viewstatehtml = viewstatehtml.Replace("\"", "");
viewstatehtml = GetDataHtmlList(viewstatehtml, "/", "/>").Trim();
viewstatehtml = "__LASTFOCUS=&__EVENTTARGET=&__EVENTARGUMENT=&__VIEWSTATE=%2F" + viewstatehtml + "&__VIEWSTATEGENERATOR=4FCC0923&TextBox1=" + mblno + "&Button1=%E6%9F%A5%E8%AF%A2";
viewstatehtml = viewstatehtml.Replace("+", "%2B");
viewstatehtml = viewstatehtml.Replace("/", "%2F");
//
var mycookie = resulthtml.Cookie;
var item2 = new HttpItem()
{
URL = "http://www.ssqd.cn/Scfs.aspx",//URL这里都是测试 必需项
Referer = "http://www.ssqd.cn/Scfs.aspx",
Encoding = null,//编码格式utf-8,gb2312,gbk 可选项 默认类会自动识别
Host = "www.ssqd.cn",
UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)",
Accept = "text/html, application/xhtml+xml, */*",// 可选项有默认值
ContentType = "application/x-www-form-urlencoded",
Postdata = viewstatehtml,
Method = "POST",//URL 可选项 默认为Get
};
HttpResult resulthtml2 = http.GetHtml(item2);
var datahtml2 = resulthtml2.Html;
datahtml2 = datahtml2.Replace("images/", "http://www.ssqd.cn/images/");
result.Data = datahtml2;
}
else
{
HttpHelper http = new HttpHelper();
HttpItem item = new HttpItem()
{
URL = "http://www.ssqd.cn/agentui.aspx?bl=" + mblno,//URL这里都是测试 必需项
Encoding = null,//编码格式utf-8,gb2312,gbk 可选项 默认类会自动识别
Host = "www.ssqd.cn:808",
UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)",
Accept = "text/html, application/xhtml+xml, */*",// 可选项有默认值
ContentType = "text/html",
Method = "get",//URL 可选项 默认为Get
};
HttpResult resulthtml = http.GetHtml(item);
resulthtml = http.GetHtml(item);
var ctnall = "";
var datahtml = GetDataHtmlList(resulthtml.Html, "<table>", "</table>");
if (datahtml != "")
{
var i = 1;
MsOpSeaeDetail data = new MsOpSeaeDetail();
while (datahtml.IndexOf("</td></tr>") >= 0)
{
var datalength = datahtml.IndexOf("</td></tr>");
var recdatastr = datahtml.Substring(0, datalength + 10);
datahtml = datahtml.Substring(datalength + 10, datahtml.Length - datalength - 10);
recdatastr = recdatastr.Remove(0, recdatastr.IndexOf("<tr><td>") + 8);
recdatastr = recdatastr.Remove(recdatastr.IndexOf("</td></tr>"), 10);
var fieldnamestr = recdatastr.Substring(1, recdatastr.IndexOf(">") - 1);
if (fieldnamestr == "箱号")
{
data = new MsOpSeaeDetail();
data.BSNO = bsno;//业务编号
data.CTNNUM = 1;//箱量
data.CNTRNO = GetDataHtmlList(recdatastr, "<箱号>", "</箱号>");
}
if (fieldnamestr == "尺寸")
{
ctnall = GetDataHtmlList(recdatastr, "<尺寸>", "</尺寸>");
}
if (fieldnamestr == "箱型")
{
data.CTNALL = ctnall + GetDataHtmlList(recdatastr, "<箱型>", "</箱型>");
}
if (fieldnamestr == "皮重")
{
try
{
data.TAREWEIGHT = Convert.ToDecimal(GetDataHtmlList(recdatastr, "<皮重>", "</皮重>"));
}
catch
{
data.TAREWEIGHT = 0;
}
}
if (fieldnamestr == "总件数")
{
try
{
data.PKGS = Convert.ToInt16(GetDataHtmlList(recdatastr, "<总件数>", "</总件数>"));
}
catch
{
data.PKGS = 0;
}
}
if (fieldnamestr == "重量")
{
try
{
data.KGS = Convert.ToDecimal(GetDataHtmlList(recdatastr, "<重量>", "</重量>"));
}
catch
{
data.KGS = 0;
}
}
if (fieldnamestr == "总尺码")
{
try
{
data.CBM = Convert.ToDecimal(GetDataHtmlList(recdatastr, "<总尺码>", "</总尺码>"));
}
catch
{
data.CBM = 0;
}
}
if (fieldnamestr == "铅封号")
{
try
{
data.SEALNO = GetDataHtmlList(recdatastr, "<铅封号>", "</铅封号>");
}
catch
{ }
}
if (fieldnamestr == "集港时间")
{
bodyList.Add(data);
}
}
}
bodyList = SumBodyList(bodyList);
result.Data = bodyList.ToList();
}
}
catch
{
result.Success = false;
result.Message = "提取数据过程中发生错误,请联系系统管理员!";
}
return result;
}
#endregion
#region 青岛锦恒场站
static public DBResult GetJINHENGCTNList ( string mblno, string bsno, bool isweb = false )
{
var result = new DBResult();
result.Success = true;
var bodyList = new List<MsOpSeaeDetail>();
var bodyList2 = new List<MsOpSeaeDetail>();
var bodyList3 = new List<MsOpSeaeDetail>();
try
{
HttpHelperX2 ShippHttp = new HttpHelperX2();
var refurl = "http://www.sjhlco.com/InfoService/blinfo";
var murl = "http://www.sjhlco.com/InfoService";
var Postdata = "BL_NO=" + mblno + "&x=35&y=10";
var alldatahtml = ShippHttp.GetAndGetHtml(murl, "application/x-www-form-urlencoded", refurl, true, Encoding.UTF8);
alldatahtml = ShippHttp.PostAndGetHtml(refurl, Postdata, "application/x-www-form-urlencoded", refurl, true, Encoding.UTF8);
if (isweb == true)
{
alldatahtml = alldatahtml.Replace("/InfoService/resources/", "http://www.sjhlco.com/InfoService/resources/");
result.Data = alldatahtml;
}
else
{
var Vesseldatahtml = GetDataHtmlList(alldatahtml, "船名<", "</td>");
Vesseldatahtml = GetDataHtmlList(Vesseldatahtml, "]", "(").Trim();
var VoyNodatahtml = GetDataHtmlList(alldatahtml, "航次<", "</td>");
VoyNodatahtml = VoyNodatahtml.Remove(0, VoyNodatahtml.IndexOf("ty1 al_l\">") + 10);
alldatahtml = alldatahtml.Substring(alldatahtml.IndexOf("集装箱信息"));
var datahtml = alldatahtml.Substring(0, alldatahtml.IndexOf("</table>") + 8);
alldatahtml = alldatahtml.Remove(0, alldatahtml.IndexOf("</table>") + 8);
var datahtml2 = alldatahtml.Substring(0, alldatahtml.IndexOf("</table>") + 8);
datahtml = datahtml.Remove(0, datahtml.IndexOf("</tr>") + 5);
if (datahtml != "")
{
var i = 1;
while (datahtml.IndexOf("</tr>") >= 0)
{
var datalength = datahtml.IndexOf("</tr>");
var recdatastr = datahtml.Substring(0, datalength + 5);
datahtml = datahtml.Substring(datalength + 5, datahtml.Length - datalength - 5);
recdatastr = recdatastr.Remove(0, recdatastr.IndexOf("<tr") + 3);
recdatastr = recdatastr.Remove(recdatastr.IndexOf("</tr>"), 5);
var ctnall = "";
var fieldno = 1;
var istrue = false;
if (i != 0)
{
MsOpSeaeDetail data = new MsOpSeaeDetail();
data.BSNO = bsno;//业务编号
data.CTNNUM = 1;//箱量
data.VESSEL = Vesseldatahtml;
data.VOYNO= VoyNodatahtml;
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("<td>") + 4);
if (fieldno == 2)
{
data.CNTRNO = fielddatastr;
}
if (fieldno == 3)
{
ctnall = fielddatastr;
}
if (fieldno == 4)
{
data.CTNALL = ctnall + fielddatastr;
}
if (fieldno == 7)
{
data.SEALNO = fielddatastr;
}
if (fieldno == 12)
{
try
{
data.TAREWEIGHT = Convert.ToDecimal(fielddatastr);
}
catch
{
}
}
fieldno = fieldno + 1;
}
bodyList.Add(data);
}
i = i + 1;
}
}
if (datahtml2 != "")
{
var i = 1;
var isfen = false;
if (datahtml2.IndexOf("分提单号") > 1)
{
isfen = true;
}
var datalength = datahtml2.IndexOf("</tr>");
datahtml2 = datahtml2.Substring(datalength + 5, datahtml2.Length - datalength - 5);
while (datahtml2.IndexOf("</tr>") >= 0)
{
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 ctnall = "";
var fieldno = 1;
if (i != 0)
{
MsOpSeaeDetail data = new MsOpSeaeDetail();
data.BSNO = bsno;//业务编号
data.CTNNUM = 1;//箱量
data.VESSEL = Vesseldatahtml;
data.VOYNO = VoyNodatahtml;
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("<td>") + 4);
if ((!isfen & fieldno == 2) || (isfen & fieldno == 3))
{
data.CNTRNO = fielddatastr;
foreach (var enumValue in bodyList)
{
if (enumValue.CNTRNO == fielddatastr)
{
data.SEALNO = enumValue.SEALNO;
data.CTNALL = enumValue.CTNALL;
data.TAREWEIGHT = enumValue.TAREWEIGHT;
}
}
}
if ((!isfen & fieldno == 3) || (isfen & fieldno == 4))
{
ctnall = fielddatastr;
}
if ((!isfen & fieldno == 4) || (isfen & fieldno == 5))
{
data.CTNALL = ctnall + fielddatastr;
}
if ((!isfen & fieldno == 5) || (isfen & fieldno == 6))
{
data.SEALNO = fielddatastr;
}
if ((!isfen & fieldno == 6) || (isfen & fieldno == 7))
{
try
{
data.PKGS = Convert.ToInt16(fielddatastr.Replace(",", ""));
}
catch
{
}
}
if ((!isfen & fieldno == 7) || (isfen & fieldno == 8))
{
try
{
data.KGS = Convert.ToDecimal(fielddatastr);
}
catch
{
}
}
if ((!isfen & fieldno == 8) || (isfen & fieldno == 9))
{
try
{
data.CBM = Convert.ToDecimal(fielddatastr);
}
catch
{
}
}
if ((!isfen & fieldno == 10) || (isfen & fieldno == 11))
{
try
{
data.TAREWEIGHT = Convert.ToDecimal(fielddatastr);
}
catch
{
}
}
fieldno = fieldno + 1;
}
bodyList2.Add(data);
}
i = i + 1;
}
}
bodyList = SumBodyList(bodyList);
bodyList2 = SumBodyList(bodyList2);
if (bodyList2.Count == 0)
result.Data = bodyList.ToList();
else
result.Data = bodyList2.ToList();
}
}
catch
{
result.Success = false;
result.Message = "提取数据过程中发生错误,请联系系统管理员!";
}
return result;
}
#endregion
#region 外运场站//QD2E441098
static public DBResult GetWAIYUNTNList ( string mblno, string bsno, bool isweb = false )
{
var result = new DBResult();
result.Success = true;
var bodyList = new List<MsOpSeaeDetail>();
var bodyList3 = new List<MsOpSeaeDetail>();
try
{
#region 查询历史数据,当前查询不到
HttpHelper http = new HttpHelper();
HttpItem item = new HttpItem()
{
URL = "http://www.sd.sinotrans.com/CntrYardQuery/QueryByBlnoWLY.aspx?Blno=" + mblno,//URL这里都是测试 必需项
Encoding = null,//编码格式utf-8,gb2312,gbk 可选项 默认类会自动识别
Host = "www.sd.sinotrans.com",
UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)",
Accept = "text/html, application/xhtml+xml, */*",// 可选项有默认值
ContentType = "text/html",
Method = "get",//URL 可选项 默认为Get
};
HttpResult resulthtml = http.GetHtml(item);
if (isweb == true)
{
var datahtml = resulthtml.Html;
datahtml = datahtml.Replace("css/StyleSheet.css", "http://www.sd.sinotrans.com/sdweb/HomePage/CntrYardQuery/css/StyleSheet.css");
datahtml = datahtml.Replace("../../App_Themes/HomePage/HomePage.css", "http://www.sd.sinotrans.com/sdweb/App_Themes/HomePage/HomePage.css");
result.Data = datahtml;
}
else
{
//需求编号SR2017052500003-4
var datahtml3 = GetDataHtmlList(resulthtml.Html, "船舶信息", "</table>");
if (datahtml3 != "" && datahtml3.ToString().IndexOf("No Record...") < 0)
{
#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>") + 4);
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);
if (fieldno == 2)
{
data.VESSEL = fielddatastr;
}
else if (fieldno == 4)
{
data.VOYNO = fielddatastr;
}
fieldno = fieldno + 1;
}
bodyList3.Add(data);
}
i = i + 1;
}
#endregion
}
var datahtml = GetDataHtmlList(resulthtml.Html, "装箱单信息", "</table>");
if (datahtml != "" && datahtml.ToString().IndexOf("No Record...") < 0)
{
#region 装箱单信息
var i = 1;
while (datahtml.IndexOf("</tr>") >= 0)
{
var datalength = datahtml.IndexOf("</tr>");
var recdatastr = datahtml.Substring(0, datalength + 5);
datahtml = datahtml.Substring(datalength + 5, datahtml.Length - datalength - 5);
recdatastr = recdatastr.Remove(0, recdatastr.IndexOf("<tr>") + 4);
recdatastr = recdatastr.Remove(recdatastr.IndexOf("</tr>"), 5);
var fieldno = 1;
var ctnall = "";
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);
if (fieldno == 2)
{
data.CNTRNO = fielddatastr;
foreach (var enumValue in bodyList3)//需求编号SR2017052500003-4
{
data.VESSEL = enumValue.VESSEL;
data.VOYNO = enumValue.VOYNO;
}
}
else if (fieldno == 3)
{
data.SEALNO = fielddatastr;
}
else if (fieldno == 4)
{
ctnall = fielddatastr;
}
else if (fieldno == 5)
{
data.CTNALL = ctnall + fielddatastr;
}
else if (fieldno == 7)
{
try
{
if (fielddatastr.IndexOf(".") > 0)
fielddatastr = fielddatastr.Remove(fielddatastr.IndexOf("."), fielddatastr.Length - fielddatastr.IndexOf("."));
data.PKGS = Convert.ToInt32(fielddatastr);
}
catch
{
data.PKGS = 0;
}
}
else if (fieldno == 8)
{
try
{
data.KGS = Convert.ToDecimal(fielddatastr);
}
catch
{
data.KGS = 0;
}
}
else if (fieldno == 9)
{
try
{
data.CBM = Convert.ToDecimal(fielddatastr);
}
catch
{
data.CBM = 0;
}
}
fieldno = fieldno + 1;
}
bodyList.Add(data);
}
i = i + 1;
}
#endregion
}
else
{
datahtml = GetDataHtmlList(resulthtml.Html, "箱动态信息", "</table>");
if (datahtml != "" && datahtml.ToString().IndexOf("No Record...") < 0)
{
#region 箱动态信息
var i = 1;
while (datahtml.IndexOf("</tr>") >= 0)
{
var datalength = datahtml.IndexOf("</tr>");
var recdatastr = datahtml.Substring(0, datalength + 5);
datahtml = datahtml.Substring(datalength + 5, datahtml.Length - datalength - 5);
recdatastr = recdatastr.Remove(0, recdatastr.IndexOf("<tr>") + 4);
recdatastr = recdatastr.Remove(recdatastr.IndexOf("</tr>"), 5);
var fieldno = 1;
var ctnall = "";
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);
if (fieldno ==2)
{
fielddatastr = fielddatastr.Remove(0, fielddatastr.IndexOf(">") + 1);
data.CNTRNO = fielddatastr;
foreach (var enumValue in bodyList3)//需求编号SR2017052500003-4
{
data.VESSEL = enumValue.VESSEL;
data.VOYNO = enumValue.VOYNO;
}
}
else if (fieldno == 3)
{
ctnall = fielddatastr;
}
else if (fieldno ==4)
{
data.CTNALL = ctnall + fielddatastr;
}
else if (fieldno == 5)
{
data.SEALNO = fielddatastr;
}
else if (fieldno == 6)
{
try
{
data.TAREWEIGHT = Convert.ToDecimal(fielddatastr);
}
catch
{
data.TAREWEIGHT = 0;
}
}
data.PKGS = 0;
data.KGS = 0;
data.CBM = 0;
fieldno = fieldno + 1;
}
bodyList.Add(data);
}
i = i + 1;
}
#endregion
}
datahtml = GetDataHtmlList(resulthtml.Html, "重箱返场信息", "</table>");
if (datahtml != "" && datahtml.ToString().IndexOf("No Record...") < 0)
{
#region 重箱返场信息
var i = 1;
while (datahtml.IndexOf("</tr>") >= 0)
{
var datalength = datahtml.IndexOf("</tr>");
var recdatastr = datahtml.Substring(0, datalength + 5);
datahtml = datahtml.Substring(datalength + 5, datahtml.Length - datalength - 5);
recdatastr = recdatastr.Remove(0, recdatastr.IndexOf("<tr>") + 4);
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);
if (fieldno == 2)
{
data.CNTRNO = fielddatastr;
foreach (var enumValue in bodyList3)//需求编号SR2017052500003-4
{
data.VESSEL = enumValue.VESSEL;
data.VOYNO = enumValue.VOYNO;
}
}
if (fieldno == 3)
{
try
{
if (fielddatastr.IndexOf(".") > 0)
fielddatastr = fielddatastr.Remove(fielddatastr.IndexOf("."), fielddatastr.Length - fielddatastr.IndexOf("."));
data.PKGS = Convert.ToInt32(fielddatastr);
}
catch
{
data.PKGS = 0;
}
}
if (fieldno == 4)
{
try
{
data.KGS = Convert.ToDecimal(fielddatastr);
}
catch
{
data.KGS = 0;
}
}
if (fieldno == 5)
{
try
{
data.CBM = Convert.ToDecimal(fielddatastr);
}
catch
{
data.CBM = 0;
}
}
fieldno = fieldno + 1;
}
bodyList.Add(data);
}
i = i + 1;
}
#endregion
}
}
//
bodyList = SumBodyList(bodyList);
if (bodyList.Count > 0)
{
result.Data = bodyList.ToList();
}
}
#endregion
if (result.Data == null)
{
#region 查询历史数据
HttpHelper http2 = new HttpHelper();
HttpItem item2 = new HttpItem()
{
URL = "http://sd.sinotrans.com/sdweb/HomePage/CntrYardQuery/QueryByBlnoHistory.aspx?Blno=" + mblno,//URL这里都是测试 必需项
Encoding = null,//编码格式utf-8,gb2312,gbk 可选项 默认类会自动识别
Host = "www.sd.sinotrans.com",
UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)",
Accept = "text/html, application/xhtml+xml, */*",// 可选项有默认值
ContentType = "text/html",
Method = "get",//URL 可选项 默认为Get
};
HttpResult resulthtml2 = http2.GetHtml(item2);
if (isweb == true)
{
var datahtml = resulthtml2.Html;
datahtml = datahtml.Replace("css/StyleSheet.css", "http://www.sd.sinotrans.com/sdweb/HomePage/CntrYardQuery/css/StyleSheet.css");
datahtml = datahtml.Replace("../../App_Themes/HomePage/HomePage.css", "http://www.sd.sinotrans.com/sdweb/App_Themes/HomePage/HomePage.css");
result.Data = datahtml;
}
else
{
//需求编号SR2017052500003-4
var datahtml3 = GetDataHtmlList(resulthtml2.Html, "船舶信息", "</table>");
if (datahtml3 != "" && datahtml3.ToString().IndexOf("No Record...") < 0)
{
#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>") + 4);
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);
if (fieldno == 2)
{
data.VESSEL = fielddatastr;
}
else if (fieldno == 4)
{
data.VOYNO = fielddatastr;
}
fieldno = fieldno + 1;
}
bodyList3.Add(data);
}
i = i + 1;
}
#endregion
}
var datahtml = GetDataHtmlList(resulthtml2.Html, "装箱单信息", "</table>");
if (datahtml != "" && datahtml.ToString().IndexOf("No Record...") < 0)
{
#region 装箱单信息
var i = 1;
while (datahtml.IndexOf("</tr>") >= 0)
{
var datalength = datahtml.IndexOf("</tr>");
var recdatastr = datahtml.Substring(0, datalength + 5);
datahtml = datahtml.Substring(datalength + 5, datahtml.Length - datalength - 5);
recdatastr = recdatastr.Remove(0, recdatastr.IndexOf("<tr>") + 4);
recdatastr = recdatastr.Remove(recdatastr.IndexOf("</tr>"), 5);
var fieldno = 1;
var ctnall = "";
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);
if (fieldno == 1)
{
fielddatastr = fielddatastr.Remove(0, fielddatastr.IndexOf(">") + 1);
data.CNTRNO = fielddatastr;
foreach (var enumValue in bodyList3)//需求编号SR2017052500003-4
{
data.VESSEL = enumValue.VESSEL;
data.VOYNO = enumValue.VOYNO;
}
}
else if (fieldno == 2)
{
data.SEALNO = fielddatastr;
}
else if (fieldno == 3)
{
ctnall = fielddatastr;
}
else if (fieldno == 4)
{
data.CTNALL = ctnall + fielddatastr;
}
else if (fieldno == 6)
{
try
{
if (fielddatastr.IndexOf(".") > 0)
fielddatastr = fielddatastr.Remove(fielddatastr.IndexOf("."), fielddatastr.Length - fielddatastr.IndexOf("."));
data.PKGS = Convert.ToInt32(fielddatastr);
}
catch
{
data.PKGS = 0;
}
}
else if (fieldno == 7)
{
try
{
data.KGS = Convert.ToDecimal(fielddatastr);
}
catch
{
data.KGS = 0;
}
}
else if (fieldno == 8)
{
try
{
data.CBM = Convert.ToDecimal(fielddatastr);
}
catch
{
data.CBM = 0;
}
}
fieldno = fieldno + 1;
}
bodyList.Add(data);
}
i = i + 1;
}
#endregion
}
else
{
datahtml = GetDataHtmlList(resulthtml2.Html, "箱动态信息", "</table>");
if (datahtml != "" && datahtml.ToString().IndexOf("No Record...") < 0)
{
#region 箱动态信息
var i = 1;
while (datahtml.IndexOf("</tr>") >= 0)
{
var datalength = datahtml.IndexOf("</tr>");
var recdatastr = datahtml.Substring(0, datalength + 5);
datahtml = datahtml.Substring(datalength + 5, datahtml.Length - datalength - 5);
recdatastr = recdatastr.Remove(0, recdatastr.IndexOf("<tr>") + 4);
recdatastr = recdatastr.Remove(recdatastr.IndexOf("</tr>"), 5);
var fieldno = 1;
var ctnall = "";
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);
if (fieldno == 1)
{
fielddatastr = fielddatastr.Remove(0, fielddatastr.IndexOf(">") + 1);
data.CNTRNO = fielddatastr;
foreach (var enumValue in bodyList3)//需求编号SR2017052500003-4
{
data.VESSEL = enumValue.VESSEL;
data.VOYNO = enumValue.VOYNO;
}
}
else if (fieldno == 2)
{
ctnall = fielddatastr;
}
else if (fieldno == 3)
{
data.CTNALL = ctnall + fielddatastr;
}
else if (fieldno == 4)
{
data.SEALNO = fielddatastr;
}
else if (fieldno == 5)
{
try
{
data.TAREWEIGHT = Convert.ToDecimal(fielddatastr);
}
catch
{
data.TAREWEIGHT = 0;
}
}
data.PKGS = 0;
data.KGS = 0;
data.CBM = 0;
fieldno = fieldno + 1;
}
bodyList.Add(data);
}
i = i + 1;
}
#endregion
}
datahtml = GetDataHtmlList(resulthtml2.Html, "重箱返场信息", "</table>");
if (datahtml != "" && datahtml.ToString().IndexOf("No Record...") < 0)
{
#region 重箱返场信息
var i = 1;
while (datahtml.IndexOf("</tr>") >= 0)
{
var datalength = datahtml.IndexOf("</tr>");
var recdatastr = datahtml.Substring(0, datalength + 5);
datahtml = datahtml.Substring(datalength + 5, datahtml.Length - datalength - 5);
recdatastr = recdatastr.Remove(0, recdatastr.IndexOf("<tr>") + 4);
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);
if (fieldno == 2)
{
data.CNTRNO = fielddatastr;
foreach (var enumValue in bodyList3)//需求编号SR2017052500003-4
{
data.VESSEL = enumValue.VESSEL;
data.VOYNO = enumValue.VOYNO;
}
}
if (fieldno == 3)
{
try
{
if (fielddatastr.IndexOf(".") > 0)
fielddatastr = fielddatastr.Remove(fielddatastr.IndexOf("."), fielddatastr.Length - fielddatastr.IndexOf("."));
data.PKGS = Convert.ToInt32(fielddatastr);
}
catch
{
data.PKGS = 0;
}
}
if (fieldno == 4)
{
try
{
data.KGS = Convert.ToDecimal(fielddatastr);
}
catch
{
data.KGS = 0;
}
}
if (fieldno == 5)
{
try
{
data.CBM = Convert.ToDecimal(fielddatastr);
}
catch
{
data.CBM = 0;
}
}
fieldno = fieldno + 1;
}
bodyList.Add(data);
}
i = i + 1;
}
#endregion
}
}
//
bodyList = SumBodyList(bodyList);
result.Data = bodyList.ToList();
}
#endregion
}
}
catch
{
result.Success = false;
result.Message = "提取数据过程中发生错误,请联系系统管理员!";
}
return result;
}
#endregion
#region 港陆场站
static public DBResult GetGLCZCTNList ( string mblno, string bsno, bool isweb = false )
{
var result = new DBResult();
result.Success = true;
var bodyList = new List<MsOpSeaeDetail>();
try
{
HttpHelper http = new HttpHelper();
HttpItem item = new HttpItem()
{
URL = "http://www.medlog.com.cn/querydata/billquerysearch.aspx",//URL这里都是测试 必需项
Encoding = null,//编码格式utf-8,gb2312,gbk 可选项 默认类会自动识别
Host = "www.medlog.com.cn",
UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)",
Accept = "text/html, application/xhtml+xml, */*",// 可选项有默认值
ContentType = "text/html",
Method = "get",//URL 可选项 默认为Get
};
HttpResult resulthtml = http.GetHtml(item);
var viewstatehtml = resulthtml.Html;
viewstatehtml = GetDataHtmlList(viewstatehtml, "__VIEWSTATE", "/>");
viewstatehtml = viewstatehtml.Replace("\"", "");
viewstatehtml = GetDataHtmlList(viewstatehtml, "/", "/>").Trim();
viewstatehtml = "__VIEWSTATE=%2F" + viewstatehtml + "&ctl00%24Maincontent%24txtBillNo=" + mblno + "&ctl00%24Maincontent%24btnSearch=%E6%9F%A5%E8%AF%A2";
viewstatehtml = viewstatehtml.Replace("+", "%2B");
viewstatehtml = viewstatehtml.Replace("/", "%2F");
var mycookie = resulthtml.Cookie;
item = new HttpItem()
{
URL = "http://www.medlog.com.cn/querydata/billquerysearch.aspx",//URL这里都是测试 必需项
Referer = "http://www.medlog.com.cn/querydata/billquerysearch.aspx",
Encoding = null,//编码格式utf-8,gb2312,gbk 可选项 默认类会自动识别
Cookie = mycookie,
Host = "www.medlog.com.cn",
UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)",
Accept = "text/html, application/xhtml+xml, */*",// 可选项有默认值
ContentType = "application/x-www-form-urlencoded",
//2016-05-10 重新从网站获取Postdata配置信息
Postdata = viewstatehtml,
Method = "POST",//URL 可选项 默认为Get
};
resulthtml = http.GetHtml(item);
if (isweb == true)
{
var datahtml = resulthtml.Html;
datahtml = datahtml.Replace("../css/style.css", "http://www.medlog.com.cn/css/style.css");
datahtml = datahtml.Replace("../Scripts/jquery-easyui-1.3.1/themes/default/easyui.cs", "http://www.medlog.com.cn/Scripts/jquery-easyui-1.3.1/themes/default/easyui.cs");
datahtml = datahtml.Replace("../Scripts/jquery-easyui-1.3.1/themes/icon.css", "http://www.medlog.com.cn/Scripts/jquery-easyui-1.3.1/themes/icon.css");
result.Data = datahtml;
}
else
{
var ctnall = "";
var datahtml = GetDataHtmlList(resulthtml.Html, "实际装货信息", "合计");
if (datahtml != "")
{
#region 实际装货信息
var i = 1;
while (datahtml.IndexOf("</tr>") >= 0)
{
var datalength = datahtml.IndexOf("</tr>");
var recdatastr = datahtml.Substring(0, datalength + 5);
datahtml = datahtml.Substring(datalength + 5, datahtml.Length - datalength - 5);
recdatastr = recdatastr.Remove(0, recdatastr.IndexOf("<tr>") + 4);
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(" ", "");
if (fieldno == 1)
{
fielddatastr = fielddatastr.Remove(0, fielddatastr.IndexOf(">") + 1);
if (fielddatastr == "合计:" || fielddatastr == "暂无相关数据</b>") istrue = false; else istrue = true;
}
if (fieldno == 2)
{
data.CNTRNO = fielddatastr.Trim();
}
if (fieldno == 3)
{
ctnall = fielddatastr.Trim();
}
if (fieldno == 4)
{
data.CTNALL = ctnall + fielddatastr.Trim();
}
if (fieldno == 5)
{
data.SEALNO = fielddatastr.Trim();
}
if (fieldno == 6)
{
try
{
data.PKGS = Convert.ToInt32(fielddatastr);
}
catch
{
data.PKGS = 0;
}
}
if (fieldno == 7)
{
data.KINDPKGS = fielddatastr.Trim();
}
if (fieldno == 8)
{
try
{
data.KGS = Convert.ToDecimal(fielddatastr);
}
catch
{
data.KGS = 0;
}
}
if (fieldno == 9)
{
try
{
data.CBM = Convert.ToDecimal(fielddatastr);
}
catch
{
}
}
fieldno = fieldno + 1;
}
if (istrue)
bodyList.Add(data);
}
i = i + 1;
}
#endregion
}
bodyList = SumBodyList(bodyList);
result.Data = bodyList.ToList();
}
}
catch
{
result.Success = false;
result.Message = "提取数据过程中发生错误,请联系系统管理员!";
}
return result;
}
#endregion
#region 青岛新东方场站
static public DBResult GetXDFCTNList ( string mblno, string bsno, bool isweb = false )
{
var result = new DBResult();
result.Success = true;
var bodyList = new List<MsOpSeaeDetail>();
try
{
HttpHelper http = new HttpHelper();
HttpItem item = new HttpItem()
{
URL = "http://www.qdxdf.net/SystemQuery.aspx",//URL这里都是测试 必需项
Encoding = null,//编码格式utf-8,gb2312,gbk 可选项 默认类会自动识别
Host = "www.qdxdf.net",
UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)",
Accept = "text/html, application/xhtml+xml, */*",// 可选项有默认值
ContentType = "text/html",
Method = "get",//URL 可选项 默认为Get
};
HttpResult resulthtml = http.GetHtml(item);
//
var viewstatehtml = resulthtml.Html;
viewstatehtml = GetDataHtmlList(viewstatehtml, "__VIEWSTATE", "/>");
viewstatehtml = viewstatehtml.Replace("\"", "");
viewstatehtml = GetDataHtmlList(viewstatehtml, "/", "/>").Trim();
viewstatehtml = "__EVENTTARGET=&__EVENTARGUMENT=&__VIEWSTATE=%2F" + viewstatehtml + "&ctl00%24ContentPlaceHolder1%24BillNoTextBox=" + mblno + "&ctl00%24ContentPlaceHolder1%24QuickSearchButton=%E6%9F%A5+%E8%AF%A2";
viewstatehtml = viewstatehtml.Replace("+", "%2B");
viewstatehtml = viewstatehtml.Replace("/", "%2F");
var mycookie = resulthtml.Cookie;
item = new HttpItem()
{
URL = "http://www.qdxdf.net/SystemQuery.aspx",//URL这里都是测试 必需项
Referer = "http://www.qdxdf.net/SystemQuery.aspx",
Encoding = null,//编码格式utf-8,gb2312,gbk 可选项 默认类会自动识别
Cookie = mycookie,
Host = "www.qdxdf.net",
UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)",
Accept = "text/html, application/xhtml+xml, */*",// 可选项有默认值
ContentType = "application/x-www-form-urlencoded",
#region Postdata
//Postdata = "__EVENTTARGET=&__EVENTARGUMENT=&__VIEWSTATE=%2F"
//+"wEPDwUKLTM5ODgwOTM1OA9kFgJmD2QWAgIDD2QWAgIHD2QWKgIBDw8WAh4EVGV4dAUMVEFPT0FLMDAzOTAyZGQCBQ8PFgIeB1Zpc2libGVnZGQCBw8PFgIfAAUQ5LiL6LSn57q45pWw5o2uOmRkAgkPDxYEHwAFDFRBT09BSzAwMzkwMh8BaGRkAgsPDxYCHwAFE%2BmdoOiItueggeWktDogUVFDVDNkZAINDw8WAh8ABRHnrqHoiLnkuro6IOS7u%2BaziWRkAg8PDxYCHwAFFuiBlOezu%2BeUteivnTogODI5ODcwMjlkZAIRDw8WAh8ABR3kvKDnnJ86MDUzMi04Mjk4NzEzMC84Mjk4NzEzMWRkAhMPD2QPEBYBZhYBFgIeDlBhcmFtZXRlclZhbHVlBQxUQU9PQUswMDM5MDIWAWZkZAIVDzwrAA0BAA8WBB4LXyFEYXRhQm91bmRnHgtfIUl0ZW1Db3VudAIBZBYCZg9kFgQCAQ9kFh5mDw8WAh8ABQnmlrDkuprmtLJkZAIBDw8WAh8ABQtYSU4gWUEgWkhPVWRkAgIPDxYCHwAFBTAwOTRFZGQCAw8PFgIfAAUMVEFPT0FLMDAzOTAyZGQCBA8PFgIfAAUGJm5ic3A7ZGQCBQ8PFgIfAAUKICAgMVgyMCdHUGRkAgYPDxYCHwAFAzE0MmRkAgcPDxYCHwAFBzE4MTcuNjBkZAIIDw8WAh8ABQUxNS43NmRkAgkPDxYCHwAFCk9BS0xBTkQsQ0FkZAIKDw8WAh8ABQpPQUtMQU5ELENBZGQCCw8PFgIfAAURMjAxNC83LzE4IDk6MTU6MDBkZAIMDw8WAh8ABRIyMDE0LzcvMTggMTQ6MzA6MDBkZAINDw8WAh8ABRIyMDE0LzcvMjAgMTQ6MzA6MDBkZAIODw8WAh8ABREyMDE0LzcvMTkgMDowMDowMGRkAgIPDxYCHwFoZGQCFw88KwANAgAPFgQfA2cfBAIBZAwUKwAdFggeBE5hbWUFDOaJp%2BihjOaDheWGtR4KSXNSZWFkT25seWgeBFR5cGUZKwIeCURhdGFGaWVsZAUM5omn6KGM5oOF5Ya1FggfBQUJ5o%2BQ5Y2V5Y%2B3HwZoHwcZKwIfCAUJ5o%2BQ5Y2V5Y%2B3FggfBQUG566x5Y%2B3HwZoHwcZKwIfCAUG566x5Y%2B3FggfBQUG5bC656CBHwZoHwcZKwIfCAUG5bC656CBFggfBQUG566x5Z6LHwZoHwcZKwIfCAUG566x5Z6LFggfBQUG5Lu25pWwHwZoHwcZKVtTeXN0ZW0uRGVjaW1hbCwgbXNjb3JsaWIsIFZlcnNpb249Mi4wLjAuMCwgQ3VsdHVyZT1uZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj1iNzdhNWM1NjE5MzRlMDg5HwgFBuS7tuaVsBYIHwUFBumHjemHjx8GaB8HGSsEHwgFBumHjemHjxYIHwUFBuS9k%2Benrx8GaB8HGSsEHwgFBuS9k%2BenrxYIHwUFBuWwgeWPtx8GaB8HGSsCHwgFBuWwgeWPtxYIHwUFEuaMh%2BWumueuseWPt%2Bexu%2BWeix8GaB8HGSsCHwgFEuaMh%2BWumueuseWPt%2Bexu%2BWeixYIHwUFCeeuseajgOeusR8GaB8HGSsCHwgFCeeuseajgOeusRYIHwUFCeWIkuaLqOWPtx8GaB8HGSsCHwgFCeWIkuaLqOWPtxYIHwUFBua4qeW6ph8GaB8HGSsCHwgFBua4qeW6phYIHwUFBua5v%2BW6ph8GaB8HGSsCHwgFBua5v%2BW6phYIHwUFBumAmumjjh8GaB8HGSsCHwgFBumAmumjjhYIHwUFCei9rOWFs%2Bi0px8GaB8HGSsCHwgFCei9rOWFs%2Bi0pxYIHwUFCeWKoOmHjeeusR8GaB8HGSsCHwgFCeWKoOmHjeeusRYIHwUFCeebtOinkueusR8GaB8HGSsCHwgFCeebtOinkueusRYIHwUFCea5v%2BW6pueusR8GaB8HGSsCHwgFCea5v%2BW6pueusRYIHwUFBui2hemrmB8GaB8HGSsEHwgFBui2hemrmBYIHwUFBui2heW3ph8GaB8HGSsEHwgFBui2heW3phYIHwUFBui2heWPsx8GaB8HGSsEHwgFBui2heWPsxYIHwUFDOeJueauiumFjei9vR8GaB8HGSsCHwgFDOeJueauiumFjei9vRYIHwUFD%2BWNsemZqeWTgeetiee6px8GaB8HGSsCHwgFD%2BWNsemZqeWTgeetiee6pxYIHwUFD%2BWbvemZheWNseinhOWPtx8GaB8HGSsCHwgFD%2BWbvemZheWNseinhOWPtxYIHwUFDOmdoOaziueggeWktB8GaB8HGSsCHwgFDOmdoOaziueggeWktBYIHwUFBueuseS4ux8GaB8HGSsCHwgFBueuseS4uxYIHwUFDOaPkOeuseWcsOeCuR8GaB8HGSsCHwgFDOaPkOeuseWcsOeCuRYIHwUFEuaMh%2BWumueuseWPt%2BaXtumXtB8GaB8HGSlcU3lzdGVtLkRhdGVUaW1lLCBtc2NvcmxpYiwgVmVyc2lvbj0yLjAuMC4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkfCAUS5oyH5a6a566x5Y%2B35pe26Ze0FgJmD2QWBAIBD2QWPGYPDxYCHwAFATFkZAIBDw8WAh8ABQbpm4bmuK9kZAICDw8WAh8ABQxUQU9PQUswMDM5MDJkZAIDDw8WAh8ABQtDU0xVMTE1OTYzOGRkAgQPDxYCHwAFAjIwZGQCBQ8PFgIfAAUCR1BkZAIGDw8WAh8ABQMxNDJkZAIHDw8WAh8ABQcxODE3LjYwZGQCCA8PFgIfAAUFMTUuNzZkZAIJDw8WAh8ABQdWMjQ3MDg5ZGQCCg8PFgIfAAUGJm5ic3A7ZGQCCw8PFgIfAAUD5ZCmZGQCDA8PFgIfAAUGJm5ic3A7ZGQCDQ8PFgIfAAUGJm5ic3A7ZGQCDg8PFgIfAAUGJm5ic3A7ZGQCDw8PFgIfAAUGJm5ic3A7ZGQCEA8PFgIfAAUD5ZCmZGQCEQ8PFgIfAAUD5ZCmZGQCEg8PFgIfAAUD5ZCmZGQCEw8PFgIfAAUD5ZCmZGQCFA8PFgIfAAUGJm5ic3A7ZGQCFQ8PFgIfAAUGJm5ic3A7ZGQCFg8PFgIfAAUGJm5ic3A7ZGQCFw8PFgIfAAUGJm5ic3A7ZGQCGA8PFgIfAAUGJm5ic3A7ZGQCGQ8PFgIfAAUGJm5ic3A7ZGQCGg8PFgIfAAUDWERGZGQCGw8PFgIfAAUDQ1NMZGQCHA8PFgIfAAUGJm5ic3A7ZGQCHQ8PFgIfAAUGJm5ic3A7ZGQCAg8PFgIfAWhkZAIZD2QWBgIBDw8WAh8ABT7nlKjnrrHkv6Hmga86ICAgICA8PT0g54K55Ye75Lu25pWw5Y%2Bv5Lul5p%2Bl6K%2Bi5YWl6LSn5piO57uGID09PmRkAgMPDxYCHwFnZGQCBQ88KwANAQAPFgQfA2cfBAIBZBYCZg9kFgQCAQ9kFhpmDw8WAh8ABQExZGQCAQ8PFgIfAAUMVEFPT0FLMDAzOTAyZGQCAg8PFgIfAAULQ1NMVTExNTk2MzhkZAIDDw8WAh8ABQJHUGRkAgQPDxYCHwAFAjIwZGQCBQ8PFgIfAAUHVjI0NzA4OWRkAgYPDxYCHwAFBuWklueCuWRkAgcPZBYCZg8VAgtDU0xVMTE1OTYzOABkAgkPDxYCHwAFB0xVOTgxODVkZAIKDw8WAh8ABRIyMDE0LzcvMTUgMTE6MTM6NDhkZAILDw8WAh8ABRIyMDE0LzcvMTUgMTk6MDA6NDRkZAIMDw8WAh8ABRIyMDE0LzcvMTggMTU6MTU6MTlkZAINDw8WAh8ABRIyMDE0LzcvMjAgMTM6MTY6NDZkZAICDw8WAh8BaGRkAhsPDxYCHwAFDeijheeuseS%2FoeaBrzpkZAIdDw8WAh8ABekCc2VsZWN0IHQuQklMTF9OTyBhcyDmj5DljZXlj7csdC5DTlRSX05PIGFzIOeuseWPtyx0LlNFQUxfTk8gYXMg5bCB5Y%2B3LHQuQ05UUl9UWVBFIGFzIOeuseWeiyx0LlFVQU5USVRZIGFzIOS7tuaVsCx0LldFSUdIVCBhcyDmr5vph40sdC5WT0xVTUUgYXMg5bC656CBLHQuVEVNUEVSQVRVUkUgYXMg5Ya3566x5rip5bqmLCB0LkRSQVVHSFQgYXMg6YCa6aOO5Y%2BjLHQuQkFDS19EQVRFIGFzIOi%2Fm%2BWcuuaXpeacnyx0LkNOVFJfSE9MREVSIGFzIFNPQyx0LlNFQUxfTk8yIGFzIOesrOS6jOWwgeWPtyx0LlNUVUZGX1RZUEUgYXMg56m6566xIGZyb20gVl9XRUJfQ0ZTX1NUVUZGV09SSyB0IHdoZXJlIEJJTExfTk8gPSAnVEFPT0FLMDAzOTAyJ2RkAh8PDxYCHwFnZGQCIQ8PFgIfAWdkZAIjDzwrAA0BAA8WBB8DZx8EAgFkFgJmD2QWBAIBD2QWHmYPDxYCHwAFATFkZAIBDw8WAh8ABQxUQU9PQUswMDM5MDJkZAICDw8WAh8ABQtDU0xVMTE1OTYzOGRkAgMPDxYCHwAFB1YyNDcwODlkZAIEDw8WAh8ABQUyMCdHUGRkAgUPDxYCHwAFAzE0MmRkAgYPDxYCHwAFBzE4MTcuNjBkZAIHDw8WAh8ABQUxNS43NmRkAgkPDxYCHwAFBiZuYnNwO2RkAgoPDxYCHwAFBiZuYnNwO2RkAgsPDxYCHwAFBiZuYnNwO2RkAgwPDxYCHwAFBiZuYnNwO2RkAg0PDxYCHwAFBDIyNTBkZAIODw8WAh8ABQkxMDAxMTg1NDZkZAIPDw8WAh8ABQPmmK9kZAICD2QWBgIFDw8WAh8ABQvlkIjorqE6IDE0MmRkAgYPDxYCHwAFDuWQiOiuoTogMTgxNy42ZGQCBw8PFgIfAAUN5ZCI6K6hOiAxNS43NmRkAiUPPCsAFgIADxYEHg9EYXRhU291cmNlQm91bmRnHg1DYWxsYmFja1N0YXRlBbwFQndJSEFnSUVSR0YwWVFhWUFRQUFBQUFCQUFBQUFRQUFBQUFBQUFBQkFBQUFBQTBBQUFBSjVvK1E1WTJWNVkrM0NlYVBrT1dObGVXUHR3Y0FBQWJucnJIbGo3Y0c1NjZ4NVkrM0J3QUFCdVd3Z2VXUHR3YmxzSUhsajdjSEFBQUc1NjZ4NVo2TEJ1ZXVzZVdlaXdjQUFBYmt1N2JtbGJBRzVMdTI1cFd3QlFBQUJ1YXZtK21IalFibXI1dnBoNDBGQUFBRzViQzY1NkNCQnVXd3V1ZWdnUVVBQUF6bGhyZm5yckhtdUtubHVxWU01WWEzNTY2eDVyaXA1YnFtQndBQUNlbUFtdW1qanVXUG93bnBnSnJwbzQ3bGo2TUhBQUFNNkwrYjVaeTY1cGVsNXB5ZkRPaS9tK1djdXVhWHBlYWNud2dBQUFOVFQwTURVMDlEQndBQURPZXNyT1M2ak9Xd2dlV1B0d3puckt6a3VvemxzSUhsajdjSEFBQUc1Nm02NTY2eEJ1ZXB1dWV1c1FVQUFBQUFBQUFIQUFjQUJ3QUhBQWIvL3djQ0RGUkJUMDlCU3pBd016a3dNZ2NDQzBOVFRGVXhNVFU1TmpNNEJ3SUhWakkwTnpBNE9RY0NCVEl3SjBkUUJRZU9CUU1BeGdJQUFBQUFBQUFBQUFBQUFBSUFCUU1vQmdBQUFBQUFBQUFBQUFBQUFBSUFEQXdJQWdRQWxzUTJkbTdSQ0FjQ0FVNE1EQUlGVTNSaGRHVUhYZ2NOQndBQ0FRY0JBZ0VIQWdJQkJ3TUNBUWNFQWdFSEJRSUJCd1lDQVFjSEFnRUhDQUlCQndrQ0FRY0tBZ0VIQ3dJQkJ3d0NBUWNBQndBSEFBY0FCUUFBQUlBSkFnQUpBZ0FDQUFNSEJBSUFCd0FDQVFjQUJ3QUNBUWNBQndBPWQGD2QQFg1mAgECAgIDAgQCBQIGAgcCCAIJAgoCCwIMFg08KwALAQAWCh4JRmllbGROYW1lBQnmj5DljZXlj7ceCFJlYWRPbmx5aB4SUHJvcGVydGllc0VkaXRUeXBlBQdUZXh0Qm94Hg5SdW50aW1lQ3JlYXRlZGceD0NvbFZpc2libGVJbmRleGY8KwALAQAWCh8LBQbnrrHlj7cfDGgfDQUHVGV4dEJveB8OZx8PAgE8KwALAQAWCh8LBQblsIHlj7cfDGgfDQUHVGV4dEJveB8OZx8PAgI8KwALAQAWCh8LBQbnrrHlnosfDGgfDQUHVGV4dEJveB8OZx8PAgM8KwALAQAWCh8LBQbku7bmlbAfDGgfDQUHVGV4dEJveB8OZx8PAgQ8KwALAQAWCh8LBQbmr5vph40fDGgfDQUHVGV4dEJveB8OZx8PAgU8KwALAQAWCh8LBQblsLrnoIEfDGgfDQUHVGV4dEJveB8OZx8PAgY8KwALAQAWCh8LBQzlhrfnrrHmuKnluqYfDGgfDQUHVGV4dEJveB8OZx8PAgc8KwALAQAWCh8LBQnpgJrpo47lj6MfDGgfDQUHVGV4dEJveB8OZx8PAgg8KwALAQAWCh8LBQzov5vlnLrml6XmnJ8fDGgfDQUIRGF0ZUVkaXQfDmcfDwIJPCsACwEAFgofCwUDU09DHwxoHw0FB1RleHRCb3gfDmcfDwIKPCsACwEAFgofCwUM56ys5LqM5bCB5Y%2B3HwxoHw0FB1RleHRCb3gfDmcfDwILPCsACwEAFgofCwUG56m6566xHwxoHw0FB1RleHRCb3gfDmcfDwIMDxYNAgECAQIBAgECAQIBAgECAQIBAgICAQIBAgEWAgWZAURldkV4cHJlc3MuV2ViLkFTUHhHcmlkVmlldy5HcmlkVmlld0RhdGFUZXh0Q29sdW1uLCBEZXZFeHByZXNzLldlYi5BU1B4R3JpZFZpZXcudjExLjIsIFZlcnNpb249MTEuMi43LjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49Yjg4ZDE3NTRkNzAwZTQ5YQWZAURldkV4cHJlc3MuV2ViLkFTUHhHcmlkVmlldy5HcmlkVmlld0RhdGFEYXRlQ29sdW1uLCBEZXZFeHByZXNzLldlYi5BU1B4R3JpZFZpZXcudjExLjIsIFZlcnNpb249MTEuMi43LjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49Yjg4ZDE3NTRkNzAwZTQ5YWQCKQ8PFgIfAAUJ5paw5Lqa5rSyZGQCKw8PFgIfAAUFMDA5NEVkZAItDw8WAh8ABQxUQU9PQUswMDM5MDJkZBgEBSNjdGwwMCRDb250ZW50UGxhY2VIb2xkZXIxJEdyaWRWaWV3MQ88KwAKAQgCAWQFI2N0bDAwJENvbnRlbnRQbGFjZUhvbGRlcjEkR3JpZFZpZXcyDzwrAAoBCAIBZAUjY3RsMDAkQ29udGVudFBsYWNlSG9sZGVyMSRHcmlkVmlldzMPPCsACgEIAgFkBSNjdGwwMCRDb250ZW50UGxhY2VIb2xkZXIxJEdyaWRWaWV3NA88KwAKAQgCAWQ%2B3gkiFXHdK%2FBHaXhYQFf6Ja8oIw%3D%3D"
//+"&ctl00%24ContentPlaceHolder1%24BillNoTextBox="+mblno+"&ctl00%24ContentPlaceHolder1%24QuickSearchButton=%E6%9F%A5+%E8%AF%A2",
#endregion
//2016-05-10 重新从网站获取Postdata配置信息
Postdata = viewstatehtml,
Method = "POST",//URL 可选项 默认为Get
};
resulthtml = http.GetHtml(item);
if (isweb == true)
{
var datahtml = resulthtml.Html;
datahtml = datahtml.Replace("img/style.css", "http://www.qdxdf.net/img/style.css");
result.Data = datahtml;
}
else
{
var datahtml = GetDataHtmlList(resulthtml.Html, "ctl00_ContentPlaceHolder1_GridView4", "</table>");
var datahtml6 = GetDataHtmlList(resulthtml.Html, "装箱信息", "</table>");
if (datahtml != "")
{
var i = 1;
while (datahtml.IndexOf("</tr>") >= 0)
{
var datalength = datahtml.IndexOf("</tr>");
var recdatastr = datahtml.Substring(0, datalength + 5);
datahtml = datahtml.Substring(datalength + 5, datahtml.Length - datalength - 5);
recdatastr = recdatastr.Remove(0, recdatastr.IndexOf("<tr") + 4);
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);
if (fieldno == 1)
{
fielddatastr = fielddatastr.Remove(0, fielddatastr.IndexOf(">") + 1);
if (fielddatastr == "&nbsp;")
{
istrue = false;
}
else
{
istrue = true;
};
}
if (fieldno == 3 && istrue)
{
data.CNTRNO = fielddatastr;
}
if (fieldno == 4 && istrue)
{
data.SEALNO = fielddatastr;
}
if (fieldno == 5 && istrue)
{
data.CTNALL = fielddatastr.Replace("'", "");
}
if (fieldno == 6 && istrue)
{
try
{
data.PKGS = Convert.ToInt32(fielddatastr);
}
catch
{
data.PKGS = 0;
}
}
if (fieldno == 7 && istrue)
{
try
{
data.KGS = Convert.ToDecimal(fielddatastr);
}
catch
{
data.KGS = 0;
}
}
if (fieldno == 8 && istrue)
{
try
{
data.CBM = Convert.ToDecimal(fielddatastr);
}
catch
{
}
}
fieldno = fieldno + 1;
}
if (istrue)
bodyList.Add(data);
}
i = i + 1;
}
}
bodyList = SumBodyList(bodyList);
result.Data = bodyList.ToList();
}
}
catch
{
result.Success = false;
result.Message = "提取数据过程中发生错误,请联系系统管理员!";
}
return result;
}
#endregion
#region 长荣场站 //需求编号SR2017082500001SR2017090400001 //140701083561
static public DBResult GetCHANGRONGCTNList(string mblno, string bsno, string userid, bool isweb = false)
{
var result = new DBResult();
result.Success = true;
var bodyList = new List<MsOpSeaeDetail>();
try
{
if (userid != "")
{
MsOpSeaeQDPortDataDAL dal = new MsOpSeaeQDPortDataDAL(userid);
List<string> outList;
outList = dal.GetCRYard(mblno);
OpSeaeJGXX_CRModel jgxx = Newtonsoft.Json.JsonConvert.DeserializeObject<OpSeaeJGXX_CRModel>(outList[0].ToString());
var jgxxData = jgxx.resp.list;
OpSeaeXHDT_CRModel xhdt = Newtonsoft.Json.JsonConvert.DeserializeObject<OpSeaeXHDT_CRModel>(outList[1].ToString());
var xhdtData = xhdt.resp.list;
OpSeaeZHXX_CRModel sjzh = Newtonsoft.Json.JsonConvert.DeserializeObject<OpSeaeZHXX_CRModel>(outList[2].ToString());
var sjzhData = sjzh.resp.list;
if (isweb == true)
{
string html = "";
string table1hd = "<p class=\"yardlabel \">集港信息查询</p><br><table id=\"example\" class=\"yardtable \" cellspacing=\"0\" width=\"100%\"><thead><tr><th>序号</th><th>船名(En)</th><th>船名(CH)</th><th>航次</th><th>总单号</th><th>箱型/箱量</th><th>船公司</th><th>目的港</th><th>卸货港</th><th>装船码头</th><th>送货地址</th><th>集港开始时间</th><th>集港结束时间</th></tr></thead><tbody id=\"jgxx\">";
string table1bd = "<tr class='odd'><td valign='top' class='dataTables_empty'>" + jgxxData[0].RN +
"</td><td valign='top' class='dataTables_empty'>" + jgxxData[0].YWCM +
"</td><td valign='top' class='dataTables_empty'>" + jgxxData[0].ZWCM +
"</td><td valign='top' class='dataTables_empty'>" + jgxxData[0].HC +
"</td><td valign='top' class='dataTables_empty'>" + jgxxData[0].XSTDH +
"</td><td valign='top' class='dataTables_empty'>" + jgxxData[0].YXYQ +
"</td><td valign='top' class='dataTables_empty'>" + jgxxData[0].CGSM +
"</td><td valign='top' class='dataTables_empty'>" + jgxxData[0].MDGM +
"</td><td valign='top' class='dataTables_empty'>" + jgxxData[0].XHGM +
"</td><td valign='top' class='dataTables_empty'>" + jgxxData[0].ZCMT +
"</td><td valign='top' class='dataTables_empty'>" + jgxxData[0].SHDZ +
"</td><td valign='top' class='dataTables_empty'>" + jgxxData[0].XYKBSJ +
"</td><td valign='top' class='dataTables_empty'>" + jgxxData[0].XYLBSJ +
"</td></tr>";
string table1end = "<tr class='odd'><td valign='top' colspan='20' class='dataTables_empty'>备注:" + jgxxData[0].BZBZ + "</td></tr></tbody></table>";
string table2hd = "<p class=\"yardlabel \">箱货动态查询</p><table id=\"example\" class=\"yardtable\" cellspacing=\"0\" width=\"100%\"><thead><tr><th>序号</th><th>箱号</th><th>尺寸</th><th>箱型</th><th>铅封号</th><th>内点/外点</th><th>提箱时间</th><th>返场时间</th><th>集港时间</th><th>箱皮重</th><th>车号</th></tr></thead><tbody id=\"xhdt\">";
string table2bd = "";
foreach (var item in xhdtData)
{
string str = "<tr class='odd'><td valign='top' class='dataTables_empty'>" + item.RN
+ "</td><td valign='top' class='dataTables_empty'>" + item.XH
+ "</td><td valign='top' class='dataTables_empty'>" + item.CC
+ "</td><td valign='top' class='dataTables_empty'>" + item.XX
+ "</td><td valign='top' class='dataTables_empty'>" + item.QFH1
+ "</td><td valign='top' class='dataTables_empty'>" + item.NWDBZ
+ "</td><td valign='top' class='dataTables_empty'>" + item.TXSJ
+ "</td><td valign='top' class='dataTables_empty'>" + item.FCSJ
+ "</td><td valign='top' class='dataTables_empty'>" + item.JGSJ
+ "</td><td valign='top' class='dataTables_empty'>" + ""
+ "</td><td valign='top' class='dataTables_empty'>" + item.KCPH
+ "</td></tr>";
table2bd += str;
}
string table2end = "</tbody></table>";
string table3hd = "<p class=\"yardlabel \">实际装货信息查询</p><table id=\"example\" class=\"yardtable\" cellspacing=\"0\" width=\"100%\"><thead><tr><th>序号</th><th>分提单号</th><th>箱号</th><th>尺寸</th><th>箱型</th><th>铅封</th><th>实装件数</th><th>实装重量</th><th>实装尺码</th></tr></thead><tbody id=\"sjzh\">";
string table3bd = "";
foreach (var item in sjzhData)
{
string str = "<tr class='odd'><td valign='top' class='dataTables_empty'>" + item.RN
+ "</td><td valign='top' class='dataTables_empty'>" + item.TDH
+ "</td><td valign='top' class='dataTables_empty'>" + item.XH
+ "</td><td valign='top' class='dataTables_empty'>" + item.CC
+ "</td><td valign='top' class='dataTables_empty'>" + item.XX
+ "</td><td valign='top' class='dataTables_empty'>" + item.QFH1
+ "</td><td valign='top' class='dataTables_empty'>" + item.JS
+ "</td><td valign='top' class='dataTables_empty'>" + item.HZ
+ "</td><td valign='top' class='dataTables_empty'>" + item.TJ
+ "</td></tr>";
table3bd += str;
}
string table3end = "</tbody></table>";
result.Data = table1hd + table1bd + table1end + table2hd + table2bd + table2end + table3hd + table3bd + table3end;
}
else
{
#region 箱货动态查询
foreach (var enumValue in xhdtData)
{
MsOpSeaeDetail data = new MsOpSeaeDetail();
data.BSNO = bsno;//业务编号
data.CTNCODE = enumValue.RN.ToString();
data.VESSEL = jgxxData[0].YWCM;
data.VOYNO = jgxxData[0].HC;
data.CNTRNO = enumValue.XH;
data.SEALNO = enumValue.QFH1;
data.CTNALL = enumValue.CC + enumValue.XX;
data.CTNNUM = 1;
//数据集箱皮重貌似有问题
data.TAREWEIGHT = 0;
data.KGS = 0;
data.PKGS = 0;
data.CBM = 0;
bodyList.Add(data);
}
#endregion
#region 实际装货信息查询
foreach (var enumValue in sjzhData)
{
MsOpSeaeDetail data = new MsOpSeaeDetail();
data.BSNO = bsno;//业务编号
data.CTNCODE = enumValue.RN.ToString();
data.VESSEL = jgxxData[0].YWCM;
data.VOYNO = jgxxData[0].HC;
data.CNTRNO = enumValue.XH;
data.SEALNO = enumValue.QFH1;
data.CTNALL = enumValue.CC + enumValue.XX;
data.CTNNUM = 1;
//data.TAREWEIGHT = 0;
try
{
data.KGS = enumValue.HZ;
}
catch
{
data.KGS = 0;
}
try
{
data.PKGS = enumValue.JS;
}
catch
{
data.PKGS = 0;
}
try
{
data.CBM = enumValue.TJ;
}
catch
{
data.CBM = 0;
}
bodyList.Add(data);
}
#endregion
bodyList = SumBodyList(bodyList);
result.Data = bodyList.ToList();
}
}
else
{
result.Success = false;
result.Message = "登陆状态丢失,请重新登陆!";
}
#region 提取页面中的16-5个数据集
//集港信息查询
//string jgxx = DSWeb.Areas.Mobile.DAL.HttpHelper.HttpPost("http://qect.qingdao-port.com/data.jspx", "pageNo=1&tdh=" + mblno + "&flag=jgxx&pageSize=50");
//var jgxxData = JsonConvert.Deserialize<MsOpSeaeYard_ChangRong_jgxx>(jgxx.Replace("[", "").Replace("]", ""));
//[{"XYKBSJ-集港开始时间":"2017-09-06 16:40:00","HC-航次":"264A","MDGM-目的港":"PHCEB","BZBZ-备注":"","XYLBSJ-集港结束时间":"2017-09-06 17:00:00","RN-序号":1,"XSTDH-总单号":"140701083561","YWCM-船名(En)":"UNI-PROSPER","CGSM-船公司":"EMC","ZCMT-装船码头":"二期","YXYQ-箱型/箱量":"20GP*4","XHGM-卸货港":"XXPN5","ZWCM-船名(CH)":"立昌","SHDZ-送货地址":"三期"}]
//箱货动态查询
//string xhdt = DSWeb.Areas.Mobile.DAL.HttpHelper.HttpPost("http://qect.qingdao-port.com/data.jspx", "pageNo=1&tdh=" + mblno + "&flag=xhdt&pageSize=50");
// var xhdtData = JsonConvert.Deserialize<List<MsOpSeaeYard_ChangRong_xhdt>>(xhdt);
//[{"XX-箱型":"GP","CC-尺寸":"20","XPZ-箱皮重":2300,"TXSJ-提箱时间":"2017-09-03 11:05:26","XH-箱号":"EMCU3841277","RN-序号":1,"KCPH-车号":"LBW8899","QFH1-铅封号":"EMCGZN8287","FCSJ-返场时间":"2017-09-05 15:21:14","JGSJ-集港时间":"","NWDBZ-内点/外点":"外点"}
//,{"XX":"GP","CC":"20","XPZ":2300,"TXSJ":"2017-09-03 13:05:07","XH":"MAGU2469711","RN":2,"KCPH":"LBW8899","QFH1":"EMCGZN7817","FCSJ":"2017-09-05 16:41:13","JGSJ":"","NWDBZ":"外点"},{"XX":"GP","CC":"20","XPZ":2300,"TXSJ":"2017-09-03 13:05:07","XH":"TEMU3687642","RN":3,"KCPH":"LBW8899","QFH1":"EMCGZN7807","FCSJ":"2017-09-05 15:24:38","JGSJ":"","NWDBZ":"外点"},{"XX":"GP","CC":"20","XPZ":2300,"TXSJ":"2017-09-03 11:05:26","XH":"WFHU1426176","RN":4,"KCPH":"LBW8899","QFH1":"EMCGZN8297","FCSJ":"2017-09-05 15:29:44","JGSJ":"","NWDBZ":"外点"}]
//实际装货信息查询
//string sjzh = DSWeb.Areas.Mobile.DAL.HttpHelper.HttpPost("http://qect.qingdao-port.com/data.jspx", "pageNo=1&tdh=" + mblno + "&flag=sjzh&pageSize=50");
//List<MsOpSeaeYard_ChangRong_sjzh> sjzhData = JsonConvert.Deserialize<List<MsOpSeaeYard_ChangRong_sjzh>>(sjzh);
//sjzhData = sjzhData.FindAll(s=>s.TDH!= "合计").ToList();
//[{"HZ-实装重量":25000,"TJ-实装尺码":20,"XX-箱型":"GP","CC-尺寸":"20","TDH-分提单号":"140701083561","XH-箱号":"EMCU3841277","RN-序号":1,"QFH1-铅封":"EMCGZN8287","BZLXM":"","JS-实装件数":1}
//,{"HZ":25000,"TJ":20,"XX":"GP","CC":"20","TDH":"140701083561","XH":"WFHU1426176","RN":2,"QFH1":"EMCGZN8297","BZLXM":"","JS":1},{"HZ":25000,"TJ":20,"XX":"GP","CC":"20","TDH":"140701083561","XH":"TEMU3687642","RN":3,"QFH1":"EMCGZN7807","BZLXM":"","JS":1},{"HZ":25000,"TJ":20,"XX":"GP","CC":"20","TDH":"140701083561","XH":"MAGU2469711","RN":4,"QFH1":"EMCGZN7817","BZLXM":"","JS":1}]
#region 信息太少,暂时不获取
//分票信息查询(信息太少,暂时不获取)
//string fpxx = DSWeb.Areas.Mobile.DAL.HttpHelper.HttpPost("http://qect.qingdao-port.com/data.jspx", "pageNo=1&tdh=140701083561&flag=fpxx&pageSize=10");
//[{"TSZZXQ-装载要求":"","TJ-尺码":"","BZBZ":"","TFL-通风":"","HZ1-放行重量":"","RN-序号":1,"FX-船公司放箱信息":"","JS-件数":1,"LDWD-冷冻温度":"","HZ-重量":108000,"IMO-危险品等级":"","TDH-提单号":"140701083561","GJWGH-联合国危险品编号":"","BGDH-报关单号":"","JS1-放行件数":"","FXSJ-放行时间":"","XFL-箱分类":"加重箱","SDYQ-湿度":""}]
//订舱信息查询(信息太少,暂时不获取)
//string dcxx = DSWeb.Areas.Mobile.DAL.HttpHelper.HttpPost("http://qect.qingdao-port.com/data.jspx", "pageNo=1&tdh=140701083561&flag=dcxx&pageSize=10");
//[{"DQZT-当前状态":"在场","TFL-通风":"","XX-箱型":"GP","XH-箱号":"TEMU3687642","XSGSM-箱公司":"EMC","RN-序号":1,"KZ-空重":"F","SJRGSJ-出场时间":"","LDWD-冷冻温度":"","CC-尺寸":"20","TDH-提单号":"140701083561","QFH1-铅封号":"EMCGZN7807","SDYQ-湿度":"","XFL-箱分类":"","NWDBZ-内外点":"外点"}
//,{"DQZT":"在场","TFL":"","XX":"GP","XH":"MAGU2469711","XSGSM":"EMC","RN":2,"KZ":"F","SJRGSJ":"","LDWD":"","CC":"20","TDH":"140701083561","QFH1":"EMCGZN7817","SDYQ":"","XFL":"","NWDBZ":"外点"},{"DQZT":"在场","TFL":"","XX":"GP","XH":"WFHU1426176","XSGSM":"EMC","RN":3,"KZ":"F","SJRGSJ":"","LDWD":"","CC":"20","TDH":"140701083561","QFH1":"EMCGZN8297","SDYQ":"","XFL":"","NWDBZ":"外点"},{"DQZT":"在场","TFL":"","XX":"GP","XH":"EMCU3841277","XSGSM":"EMC","RN":4,"KZ":"F","SJRGSJ":"","LDWD":"","CC":"20","TDH":"140701083561","QFH1":"EMCGZN8287","SDYQ":"","XFL":"","NWDBZ":"外点"}]
#endregion
#endregion
}
catch (Exception e)
{
result.Success = false;
result.Message = "请求超时,请稍后重试!";
throw e;
}
return result;
}
#endregion
#region 港联荣场站//JWIA604002
static public DBResult GetGLRCTNList(string mblno, string bsno, string userid, bool isweb = false)
{
var result = new DBResult();
result.Success = true;
var bodyList = new List<MsOpSeaeDetail>();
try
{
if (userid != "")
{
MsOpSeaeQDPortDataDAL dal = new MsOpSeaeQDPortDataDAL(userid);
OpSeaeGLRModel glrData = dal.GetGLRYardXhdt(mblno);
var xhzData = glrData.zxdcwyy.xhz;
var sjzhxxData = glrData.zxdcwyy.sjzhxx;
var xhdtData = glrData.zxdcwyy.xhdt;
var mtsData = glrData.zxdcwyy.mts;
if (isweb == true)
{
string html = "";
string table1hd = "<p class=\"yardlabel \">港联荣场站下货纸</p><br><table id=\"example\" class=\"yardtable \" cellspacing=\"0\" width=\"100%\"><thead><tr><th>船名</th><th>航次</th><th>提单号</th><th>件数</th><th>货重</th><th>体积</th><th>主提单</th><th>用箱要求</th><th>放箱</th><th>指定箱号</th><th>登记时间</th><th>冷冻标记</th><th>冷冻温度</th><th>通风量</th><th>湿度</th><th>卸货港</th><th>目的港</th></tr></thead><tbody id=\"xhz\">";
string table1bd = "<tr class='odd'>" +
"</td><td valign='top' class='dataTables_empty'>" + xhzData[0].YWCM +
"</td><td valign='top' class='dataTables_empty'>" + xhzData[0].CKHC +
"</td><td valign='top' class='dataTables_empty'>" + mblno +
"</td><td valign='top' class='dataTables_empty'>" + xhzData[0].JS +
"</td><td valign='top' class='dataTables_empty'>" + xhzData[0].HZ +
"</td><td valign='top' class='dataTables_empty'>" + xhzData[0].TJ +
//"</td><td valign='top' class='dataTables_empty'>" + xhzData[0].FXBZ + 海关审结
//"</td><td valign='top' class='dataTables_empty'>" + xhzData[0].YZCS + 处理审结
// "</td><td valign='top' class='dataTables_empty'>" + xhzData[0].TGYYMC + 退关
"</td><td valign='top' class='dataTables_empty'>" + xhzData[0].XSTDH +
"</td><td valign='top' class='dataTables_empty'>" + xhzData[0].PXYQ +
"</td><td valign='top' class='dataTables_empty'>" + xhzData[0].FX +
//"</td><td valign='top' class='dataTables_empty'>" + xhzData[0].CGMX +单船责任人/电话
"</td><td valign='top' class='dataTables_empty'>" + xhzData[0].ZDXHBZ +
"</td><td valign='top' class='dataTables_empty'>" + xhzData[0].DJRQ +
//"</td><td valign='top' class='dataTables_empty'>" + xhzData[0].WPBZ +危险品标记
//"</td><td valign='top' class='dataTables_empty'>" + xhzData[0].IMO +危险品等级
//"</td><td valign='top' class='dataTables_empty'>" + xhzData[0].GJWGH +国际危标号
"</td><td valign='top' class='dataTables_empty'>" + xhzData[0].LDXBZ +
"</td><td valign='top' class='dataTables_empty'>" + xhzData[0].LDWD +
"</td><td valign='top' class='dataTables_empty'>" + xhzData[0].TFL +
"</td><td valign='top' class='dataTables_empty'>" + xhzData[0].SDYQ +
"</td><td valign='top' class='dataTables_empty'>" + xhzData[0].XHGYM +
"</td><td valign='top' class='dataTables_empty'>" + xhzData[0].MDGYM +
"</td></tr>";
string table1end = "</tbody></table>";
string table2hd = "<p class=\"yardlabel \">箱货动态</p><table id=\"example\" class=\"yardtable\" cellspacing=\"0\" width=\"100%\"><thead><tr><th>提单号</th><th>箱号</th><th>箱型</th><th>尺寸</th><th>封号</th><th>内点/外点</th><th>提箱时间</th><th>提箱车号</th><th>返场时间</th><th>返场车号</th><th>箱皮</th></tr></thead><tbody id=\"xhdt\">";
string table2bd = "";
foreach (var item in xhdtData)
{
string str = "<tr class='odd'>"
+ "</td><td valign='top' class='dataTables_empty'>" + mblno
+ "</td><td valign='top' class='dataTables_empty'>" + item.XH
+ "</td><td valign='top' class='dataTables_empty'>" + item.XX
+ "</td><td valign='top' class='dataTables_empty'>" + item.CC
+ "</td><td valign='top' class='dataTables_empty'>" + item.QFH1
+ "</td><td valign='top' class='dataTables_empty'>" + item.NWDBZ
+ "</td><td valign='top' class='dataTables_empty'>" + item.BXSJ
+ "</td><td valign='top' class='dataTables_empty'>" + item.BXKC
+ "</td><td valign='top' class='dataTables_empty'>" + item.FCSJ
+ "</td><td valign='top' class='dataTables_empty'>" + item.FCKC
+ "</td><td valign='top' class='dataTables_empty'>" + item.XPZ
+ "</td></tr>";
table2bd += str;
}
string table2end = "</tbody></table>";
string table3hd = "<p class=\"yardlabel \">实际装货信息</p><table id=\"example\" class=\"yardtable\" cellspacing=\"0\" width=\"100%\"><thead><tr><th>箱属提单号</th><th>分单号</th><th>箱号</th><th>箱型/th><th>尺寸</th><th>铅封</th><th>实装件数</th><th>包装单位</th><th>实装重量</th><th>实装尺码</th></tr></thead><tbody id=\"sjzh\">";
string table3bd = "";
foreach (var item in sjzhxxData)
{
string str = "<tr class='odd'>"
+ "</td><td valign='top' class='dataTables_empty'>" + item.XSTDH
+ "</td><td valign='top' class='dataTables_empty'>" + item.TDH
+ "</td><td valign='top' class='dataTables_empty'>" + item.XH
+ "</td><td valign='top' class='dataTables_empty'>" + item.XX
+ "</td><td valign='top' class='dataTables_empty'>" + item.CC
+ "</td><td valign='top' class='dataTables_empty'>" + item.QFH1
+ "</td><td valign='top' class='dataTables_empty'>" + item.JS
+ "</td><td valign='top' class='dataTables_empty'>" + item.BZLXM
+ "</td><td valign='top' class='dataTables_empty'>" + item.HZ
+ "</td><td valign='top' class='dataTables_empty'>" + item.TJ
+ "</td></tr>";
table3bd += str;
}
string table3end = "</tbody></table>";
result.Data = table1hd + table1bd + table1end + table2hd + table2bd + table2end + table3hd + table3bd + table3end;
}
else
{
#region 箱货动态查询
int i = 1;
foreach (var enumValue in xhdtData)
{
MsOpSeaeDetail data = new MsOpSeaeDetail();
data.BSNO = bsno;//业务编号
data.CTNCODE = Convert.ToString(i++);
data.VESSEL = xhzData[0].YWCM;
data.VOYNO = xhzData[0].CKHC;
data.CNTRNO = enumValue.XH;
data.SEALNO = enumValue.QFH1;
data.CTNALL = enumValue.CC + enumValue.XX;
data.CTNNUM = 1;
try
{
data.TAREWEIGHT = enumValue.XPZ;
}
catch
{
data.TAREWEIGHT = 0;
}
data.KGS = 0;
data.PKGS = 0;
data.CBM = 0;
bodyList.Add(data);
}
#endregion
#region 实际装货信息查询
i = 1;
foreach (var enumValue in sjzhxxData)
{
MsOpSeaeDetail data = new MsOpSeaeDetail();
data.BSNO = bsno;//业务编号
data.CTNCODE = Convert.ToString(i++);
data.VESSEL = xhzData[0].YWCM;
data.VOYNO = xhzData[0].CKHC;
data.CNTRNO = enumValue.XH;
data.SEALNO = enumValue.QFH1;
data.CTNALL = enumValue.CC + enumValue.XX;
data.CTNNUM = 1;
//data.TAREWEIGHT = 0;
try
{
data.KGS = enumValue.HZ;
}
catch
{
data.KGS = 0;
}
try
{
data.PKGS = enumValue.JS;
}
catch
{
data.PKGS = 0;
}
try
{
data.CBM = enumValue.TJ;
}
catch
{
data.CBM = 0;
}
bodyList.Add(data);
}
#endregion
bodyList = SumBodyList(bodyList);
result.Data = bodyList.ToList();
}
}
else
{
result.Success = false;
result.Message = "登陆状态丢失,请重新登陆!";
}
}
catch (Exception e)
{
result.Success = false;
result.Message = "请求超时,请稍后重试!";
throw e;
}
return result;
}
#endregion
#region 青岛神州行场站//神州场站//COSU6144610680//需求编号SR2017041200006
static public DBResult GetSZXCTNList ( string mblno, string bsno, bool isweb = false )
{
var result = new DBResult();
result.Success = true;
var bodyList = new List<MsOpSeaeDetail>();
var bodyList3 = new List<MsOpSeaeDetail>();
try
{
#region 提取页面
HttpHelper http = new HttpHelper();
HttpItem item = new HttpItem()
{
URL = "http://www.szx.net.cn/querydata/billquerysearch.aspx",//URL这里都是测试 必需项
Encoding = null,//编码格式utf-8,gb2312,gbk 可选项 默认类会自动识别
Host = "www.szx.net.cn",
UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)",
Accept = "text/html, application/xhtml+xml, */*",// 可选项有默认值
ContentType = "application/x-www-form-urlencoded",
#region Postdata
//Postdata = "__VIEWSTATE=%2FwEPDwULLTE3MzY3NTYxNTEPZBYCZg9kFgICAw9kFgICAQ9kFgICAQ8WAh4LXyFJdGVtQ291bnQCBhYMZg9kFgQCAQ8WAh4EVGV4dAU1PGEgIGhyZWY9Ii4uLy4uL0luZGV4LmFzcHgiIHRpdGxlPSLpppbpobUiPummlumhtTwvYT5kAgMPFgIfAGZkAgEPZBYEAgEPFgIfAQViPGEgIGhyZWY9Ii4uLy4uL25ld3MvbWFpbml0ZW0uYXNweD9zaWQ9MjAxMzExMTgwODA2MDU5NjgyNTMiIHRpdGxlPSLlhazlj7jmpoLlhrUiPuWFrOWPuOamguWGtTwvYT5kAgMPFgIfAAIFFgpmD2QWAgIBDxYCHwEFXzxhICBocmVmPSIuLi9OZXdzL21haW5pdGVtLmFzcHg%2Fc2lkPTIwMTMxMTE4MDgwNjA1OTY4MjUzIiB0aXRsZT0i5YWs5Y%2B4566A5LuLIj7lhazlj7jnroDku4s8L2E%2BZAIBD2QWAgIBDxYCHwEFXzxhICBocmVmPSIuLi9OZXdzL21haW5pdGVtLmFzcHg%2Fc2lkPTIwMTMxMTE4MDgyMTM5ODEyOTk4IiB0aXRsZT0i5LyB5Lia5paH5YyWIj7kvIHkuJrmlofljJY8L2E%2BZAICD2QWAgIBDxYCHwEFXjxhICBocmVmPSIuLi9OZXdzL21haW5pdGVtLmFzcHg%2Fc2lkPTIwMTMxMTE4MDgyNzQ2MzQzNzEiIHRpdGxlPSLnu4Tnu4fmnLrmnoQiPue7hOe7h%2BacuuaehDwvYT5kAgMPZBYCAgEPFgIfAQVfPGEgIGhyZWY9Ii4uL05ld3MvbWFpbml0ZW0uYXNweD9zaWQ9MjAxMzExMTgwODMwNTU0Njg3NTkiIHRpdGxlPSLlhazlj7jljobnqIsiPuWFrOWPuOWOhueoizwvYT5kAgQPZBYCAgEPFgIfAQVfPGEgIGhyZWY9Ii4uL05ld3MvSXRlbUxpc3QuYXNweD9zaWQ9MjAxMzExMTgwODMyMjgwNDY4NDkiIHRpdGxlPSLkuqTpgJrmjIfljZciPuS6pOmAmuaMh%2BWNlzwvYT5kAgIPZBYEAgEPFgIfAQViPGEgIGhyZWY9Ii4uLy4uL25ld3MvbWFpbml0ZW0uYXNweD9zaWQ9MjAxMzExMTgwODMzNTIwNDY1NzYiIHRpdGxlPSLlhazlj7jkuJrliqEiPuWFrOWPuOS4muWKoTwvYT5kAgMPFgIfAGZkAgMPZBYEAgEPFgIfAQVgPGEgIGhyZWY9Ii4uLy4uL25ld3MvSXRlbUxpc3QuYXNweD9zaWQ9MjAxMzExMTgwODM5MjA4OTA2IiB0aXRsZT0i6YeH6LSt5oub5qCHIj7ph4fotK3mi5vmoIc8L2E%2BZAIDDxYCHwBmZAIED2QWBAIBDxYCHwEFSzxhICBocmVmPSIuLi8uLi9xdWVyeWRhdGEvSW5kZXguYXNweCIgdGl0bGU9IuWcqOe6v%2BafpeivoiI%2B5Zyo57q%2F5p%2Bl6K%2BiPC9hPmQCAw8WAh8AAgcWDmYPZBYCAgEPFgIfAQVYPGEgIGhyZWY9Ii4uL3F1ZXJ5ZGF0YS9iaWxscXVlcnlzZWFyY2guYXNweCIgdGl0bGU9IuaPkOWNleWPt%2BafpeivoiI%2B5o%2BQ5Y2V5Y%2B35p%2Bl6K%2BiPC9hPmQCAQ9kFgICAQ8WAh8BBUs8YSAgaHJlZj0iLi4vcXVlcnlkYXRhL251bXF1ZXJ5LmFzcHgiIHRpdGxlPSLnkIbotKfmn6Xor6IiPueQhui0p%2BafpeivojwvYT5kAgIPZBYCAgEPFgIfAQVMPGEgIGhyZWY9Ii4uL2h0dHA6Ly8yMjIuMTczLjk1LjE3MDo4MTgwL1ZHTSIgdGl0bGU9IlZHTeaVsOaNriI%2BVkdN5pWw5o2uPC9hPmQCAw9kFgICAQ8WAh8BBV08YSAgaHJlZj0iLi4vcXVlcnlkYXRhL1NlYWNoQ2FyLmFzcHgiIHRpdGxlPSLpnZ7ljY%2Forq7ovabovobmn6Xor6IiPumdnuWNj%2Biurui9pui%2BhuafpeivojwvYT5kAgQPZBYCAgEPFgIfAQVqPGEgIGhyZWY9Ii4uL3F1ZXJ5ZGF0YS9Cb3hOT1NlY2guYXNweCIgdGl0bGU9IuiIueWFrOWPuOWujOiIueaVsOaNruafpeivoiI%2B6Ii55YWs5Y%2B45a6M6Ii55pWw5o2u5p%2Bl6K%2BiPC9hPmQCBQ9kFgICAQ8WAh8BBWE8YSAgaHJlZj0iLi4vcXVlcnlkYXRhL1NlYUludmVudG9yeVNlYXJjaC5hc3B4IiB0aXRsZT0i5Lit5rW36KOF566x5riF5Y2VIj7kuK3mtbfoo4XnrrHmuIXljZU8L2E%2BZAIGD2QWAgIBDxYCHwEFTTxhICBocmVmPSIuLi9xdWVyeWRhdGEvU2hpcFNlYXJjaC5hc3B4IiB0aXRsZT0i5pW06Ii55p%2Bl6K%2BiIj7mlbToiLnmn6Xor6I8L2E%2BZAIFD2QWBAIBDxYCHwEFYjxhICBocmVmPSIuLi8uLi9uZXdzL21haW5pdGVtLmFzcHg%2Fc2lkPTIwMTMxMTE4MDg1MDAyNDM3Mzk5IiB0aXRsZT0i6IGU57O75oiR5LusIj7ogZTns7vmiJHku6w8L2E%2BZAIDDxYCHwACARYCZg9kFgICAQ8WAh8BBV88YSAgaHJlZj0iLi4vTmV3cy9tYWluaXRlbS5hc3B4P3NpZD0yMDEzMTExODA4NTAwMjQzNzM5OSIgdGl0bGU9IuiBlOezu%2BaWueW8jyI%2B6IGU57O75pa55byPPC9hPmRkLxB67o1TuQQcQXH5d3De4ByiivYg%2Fk0SLZHllQRzSEY%3D&ctl00%24Maincontent%24txtBillNo=COSU6144610680&ctl00%24Maincontent%24btnSearch=%E6%9F%A5%E8%AF%A2",
#endregion
Method = "get",//URL 可选项 默认为Get
};
HttpResult resulthtml = http.GetHtml(item);
//
var viewstatehtml = resulthtml.Html;
viewstatehtml = GetDataHtmlList(viewstatehtml, "__VIEWSTATE", "/>");
viewstatehtml = viewstatehtml.Replace("\"", "");
viewstatehtml = GetDataHtmlList(viewstatehtml, "/", "/>").Trim();
viewstatehtml = "__VIEWSTATE=%2F" + viewstatehtml + "&ctl00%24Maincontent%24txtBillNo=" + mblno + "&ctl00%24Maincontent%24btnSearch=%E6%9F%A5%E8%AF%A2";
viewstatehtml = viewstatehtml.Replace("+", "%2B");
viewstatehtml = viewstatehtml.Replace("/", "%2F");
var mycookie = resulthtml.Cookie;// "wglwgtsjsbz3l2jp34vtxyyg";
item = new HttpItem()
{
URL = "http://www.szx.net.cn/querydata/billquerysearch.aspx",//URL这里都是测试 必需项
Referer = "http://www.szx.net.cn/querydata/billquerysearch.aspx",//“http:///www.szx.net.cn/Default.aspx”
Encoding = null,//编码格式utf-8,gb2312,gbk 可选项 默认类会自动识别
Host = "www.szx.net.cn",
UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)",
Accept = "text/html, application/xhtml+xml, */*",// 可选项有默认值
ContentType = "application/x-www-form-urlencoded",
Cookie = mycookie,
//2016-12-13 重新从网站获取Postdata配置信息
Postdata = viewstatehtml,
Method = "POST",//URL 可选项 默认为Get
};
#endregion
resulthtml = http.GetHtml(item);
if (isweb == true)
{
var datahtml = resulthtml.Html;
var viewdatahtml = GetDataHtmlList(datahtml, "value=", "/>");
datahtml=datahtml.Replace(viewdatahtml,"");
datahtml = datahtml.Replace("App_Themes/GridView/StyleSheet.css", "http://www.szx.net.cn/App_Themes/GridView/StyleSheet.css");
datahtml = datahtml.Replace("images/main.css", "http://www.szx.net.cn/images/main.css");
datahtml = datahtml.Replace("images/GridView.css", "http://www.szx.net.cn/images/GridView.css");
datahtml = datahtml.Replace("display: none;", "");//需求编号SR2017061200010
result.Data = datahtml;
return result;
}
else
{
var datahtml3 = GetDataHtmlList(resulthtml.Html, "tbMainData", "</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") + 4);
recdatastr = recdatastr.Remove(recdatastr.IndexOf("</tr>"), 5);
var fieldno = 1;
if (i != 1 && recdatastr.IndexOf("暂无相关数据") < 0)
{
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.Remove(0, fielddatastr.IndexOf("<td>") + 4);
fielddatastr = fielddatastr.Trim().Replace("\r\n", "");
if (fieldno == 1)
{
data.VESSEL = fielddatastr.Substring(0, fielddatastr.IndexOf("/")).Trim();
}
if (fieldno == 2)
{
data.VOYNO = fielddatastr;
}
fieldno = fieldno + 1;
}
bodyList3.Add(data);
}
i = i + 1;
}
#endregion
}
//
var datahtml = GetDataHtmlList(resulthtml.Html, "实际装货信息", "</table>");
if (datahtml != "")
{
#region 实际装货信息
var i = 1;
while (datahtml.IndexOf("</tr>") >= 0)
{
var datalength = datahtml.IndexOf("</tr>");
var recdatastr = datahtml.Substring(0, datalength + 5);
datahtml = datahtml.Substring(datalength + 5, datahtml.Length - datalength - 5);
recdatastr = recdatastr.Remove(0, recdatastr.IndexOf("<tr") + 4);
recdatastr = recdatastr.Remove(recdatastr.IndexOf("</tr>"), 5);
var fieldno = 1;
var istrue = false;
var ctnall = "";
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);
if (fieldno == 1)
{
fielddatastr = fielddatastr.Remove(0, fielddatastr.IndexOf(">") + 1);
if (fielddatastr.IndexOf("合计") > -1 || fielddatastr.IndexOf("暂无相关数据") > -1)
{
istrue = false;
}
else
{
istrue = true;
};
}
if (fieldno == 2 && istrue)
{
data.CNTRNO = fielddatastr.Trim().Replace("\r\n", "");
foreach (var enumValue in bodyList3)
{
data.VESSEL = enumValue.VESSEL;
data.VOYNO = enumValue.VOYNO;
}
}
if (fieldno == 3 && istrue)
{
ctnall = fielddatastr.Trim().Replace("\r\n", "");
}
if (fieldno == 4 && istrue)
{
data.CTNALL = ctnall + fielddatastr.Trim().Replace("\r\n", "");
}
if (fieldno == 5 && istrue)
{
data.SEALNO = fielddatastr.Trim().Replace("\r\n", "");
}
if (fieldno == 6 && istrue)
{
try
{
data.PKGS = Convert.ToInt32(fielddatastr);
}
catch
{
data.PKGS = 0;
}
}
if (fieldno == 8 && istrue)
{
try
{
data.KGS = Convert.ToDecimal(fielddatastr);
}
catch
{
data.KGS = 0;
}
}
if (fieldno == 9 && istrue)
{
try
{
data.CBM = Convert.ToDecimal(fielddatastr);
}
catch
{
}
}
fieldno = fieldno + 1;
}
if (istrue)
bodyList.Add(data);
}
i = i + 1;
}
#endregion
}
if (bodyList.Count==0)
{
bodyList = bodyList3;
}
bodyList = SumBodyList(bodyList);
result.Data = bodyList.ToList();
}
}
catch
{
result.Success = false;
result.Message = "提取数据过程中发生错误,请联系系统管理员!";
}
return result;
}
#endregion
#region 港湾场站//QJEAHDM108717728//需求编号SR2017041200002
static public DBResult GetGANGWANCTNList ( string mblno, string bsno, bool isweb = false )
{
var result = new DBResult();
result.Success = true;
try
{
HttpHelper http = new HttpHelper();
HttpItem item = new HttpItem()
{
URL = "http://www.qdglhwl.com/querydata/BillquerySearchOld.aspx",//URL这里都是测试 必需项
Encoding = null,//编码格式utf-8,gb2312,gbk 可选项 默认类会自动识别
Host = "www.qdglhwl.com",
UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko",
ContentType = "text/html; charset=utf-8",
Method = "get",//URL 可选项 默认为Get
};
HttpResult resulthtml = http.GetHtml(item);
//正则匹配__VIEWSTATE和__EVENTVALIDATION
Regex reg = new Regex("(?<=<input type=\"hidden\" name=\"__VIEWSTATE\" id=\"__VIEWSTATE\" value=\").*(?=\" />)");
var viewstatehtml = "__VIEWSTATE=" + reg.Match(resulthtml.Html).Value;
reg = new Regex("(?<=<input type=\"hidden\" name=\"__EVENTVALIDATION\" id=\"__EVENTVALIDATION\" value=\").*(?=\" />)");
viewstatehtml += "&__EVENTVALIDATION=" + reg.Match(resulthtml.Html).Value;
viewstatehtml += "&ctl00$Maincontent$txtBillNo=" + mblno;
viewstatehtml += "&ctl00$Maincontent$btnSearch=查询";
viewstatehtml = viewstatehtml.Replace("+", "%2B").Replace("/", "%2F");
var mycookie = resulthtml.Cookie;
#region 抓取页面
item = new HttpItem()
{
URL = "http://www.qdglhwl.com/querydata/BillquerySearchOld.aspx",//URL这里都是测试 必需项
Encoding =null,//编码格式utf-8,gb2312,gbk 可选项 默认类会自动识别
Host = "www.qdglhwl.com",
UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)",
Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",// 可选项有默认值
ContentType = "application/x-www-form-urlencoded",
Postdata = viewstatehtml,
Method = "Post",//URL 可选项 默认为Get
Cookie = mycookie
};
#endregion
resulthtml = http.GetHtml(item);
if (isweb == true)
{
var datahtml = resulthtml.Html;
datahtml = datahtml.Replace("css/StyleSheet.css", "http://www.sd.sinotrans.com/sdweb/HomePage/CntrYardQuery/css/StyleSheet.css");
datahtml = datahtml.Replace("../../App_Themes/HomePage/HomePage.css", "http://www.sd.sinotrans.com/sdweb/App_Themes/HomePage/HomePage.css");
result.Data = datahtml;
}
else
{
var bodyList = new List<MsOpSeaeDetail>();
//正则匹配
//获取船名/航次
reg = new Regex(@"<table\s*id=\""tbMainData\""(.|\n)*?</table>");//匹配表格 #tbZHXX
var headhtml = reg.Match(resulthtml.Html).Value;
reg = new Regex(@"<tr\s*class=\""GridCommonItem\""(.|\n)*?</tr>");//匹配数据行 .GridCommonItem
headhtml = reg.Match(headhtml).Value;
headhtml = new Regex(@"(?<=tr)\s*(\w*=\""[\w:#%-;\s_]*\""\s*)*").Replace(headhtml, "");
headhtml = new Regex(@"&nbsp;+|[\r\n\s]*").Replace(headhtml, "");//去掉 nbsp;、换行、空白和回车符
var trhList = headhtml.Split(new string[] { "<tr>", "</tr>" }, StringSplitOptions.RemoveEmptyEntries).ToList();//按tr分组
var tdhList = trhList.Count > 0 ? trhList[0].Split(new string[] { "<td>", "</td>" }, StringSplitOptions.RemoveEmptyEntries).ToList() : new List<string>();//按td分组
//获取数据
reg = new Regex(@"<table\s*id=\""tbZHXX\""(.|\n)*?</table>");//匹配表格 #tbZHXX
var datahtml = reg.Match(resulthtml.Html).Value;
reg = new Regex(@"(<tr\s*class=\""GridCommonItem\""(.|\n)*?</tr>[\s\r\n]*)+");//匹配数据行 .GridCommonItem
datahtml = reg.Match(datahtml).Value;
datahtml = new Regex(@"(?<=tr)\s*(\w*=\""[\w:#%-;\s_]*\""\s*)*").Replace(datahtml, "");
datahtml = new Regex(@"&nbsp;+|[\r\n\s]*").Replace(datahtml, "");//去掉 nbsp;、换行、空白和回车符
var trList = datahtml.Split(new string[] { "<tr>", "</tr>" }, StringSplitOptions.RemoveEmptyEntries).ToList();//按tr分组
foreach (var obj in trList)
{
var tdList = obj.Split(new string[] { "<td>", "</td>" }, StringSplitOptions.RemoveEmptyEntries).ToList();//按td分组
MsOpSeaeDetail data = new MsOpSeaeDetail();
data.BSNO = bsno;//业务编号
data.CTNNUM = 1;//箱量
data.CNTRNO = tdList[1];//箱号
data.CBM = Convert.ToDecimal(tdList[7]);//尺寸
// data.KINDPKGS = tdList[6];
data.CTNALL = tdList[2] + tdList[3];//尺寸+箱型(箱型)
data.KGS = Convert.ToDecimal(tdList[6]); //毛重
data.PKGS = Convert.ToInt32(tdList[5]); //件数
data.VESSEL = tdhList.Count > 0 ? tdhList[0] : "";
data.VESSEL = data.VESSEL.Split('/')[0];
data.VOYNO = tdhList.Count > 0 ? tdhList[1] : "";
data.SEALNO = tdList[4];
//data.TAREWEIGHT = Convert.ToDecimal(tdList[7]); //箱皮重
bodyList.Add(data);
}
bodyList = SumBodyList(bodyList);
var bodyListPi = new List<MsOpSeaeDetail>();
if (true)
{
//取箱货动态数据
reg = new Regex(@"<table\s*id=\""tbXhdt\""(.|\n)*?</table>");//匹配表格 #tbZHXX
var datahtml2 = reg.Match(resulthtml.Html).Value;
reg = new Regex(@"(<tr\s*class=\""GridCommonItem\""(.|\n)*?</tr>[\s\r\n]*)+");//匹配数据行 .GridCommonItem
datahtml2 = reg.Match(datahtml2).Value;
datahtml2 = new Regex(@"(?<=tr)\s*(\w*=\""[\w:#%-;\s_]*\""\s*)*").Replace(datahtml2, "");
datahtml2 = new Regex(@"&nbsp;+|[\r\n\s]*").Replace(datahtml2, "");//去掉 nbsp;、换行、空白和回车符
var trList2 = datahtml2.Split(new string[] { "<tr>", "</tr>" }, StringSplitOptions.RemoveEmptyEntries).ToList();//按tr分组
foreach (var obj in trList2)
{
var tdList2 = obj.Split(new string[] { "</td><td>" }, StringSplitOptions.None).ToList();//按td分组
MsOpSeaeDetail data = new MsOpSeaeDetail();
data.BSNO = bsno;//业务编号
data.CTNNUM = 1;//箱量
data.CNTRNO = tdList2[0].Replace("<td>", "");//箱号
//data.CBM = Convert.ToDecimal(tdList2[7]);//尺寸
// data.KINDPKGS = tdList[6];
data.CTNALL = tdList2[2] + tdList2[1];//尺寸+箱型(箱型)
//data.KGS = Convert.ToDecimal(tdList2[6]); //毛重
//data.PKGS = Convert.ToInt32(tdList2[5]); //件数
data.VESSEL = tdhList.Count > 0 ? tdhList[0] : "";
data.VESSEL = data.VESSEL.Split('/')[0];
data.VOYNO = tdhList.Count > 0 ? tdhList[1] : "";
data.SEALNO = tdList2[3];
data.TAREWEIGHT = Convert.ToDecimal(tdList2[8]); //箱皮重
bodyListPi.Add(data);
}
}
//merge
foreach (var m in bodyList)
{
foreach (var p in bodyListPi)
{
if (m.CNTRNO == p.CNTRNO)
{
m.TAREWEIGHT = p.TAREWEIGHT;
if (m.SEALNO == "" || m.SEALNO == null)
{
m.SEALNO = p.SEALNO;
}
}
}
}
if (bodyList.Count == 0)
{
bodyList = bodyListPi;
}
result.Data = bodyList.ToList();
}
}
catch
{
result.Success = false;
result.Message = "提取数据过程中发生错误,请联系系统管理员!";
}
return result;
}
#endregion`
#region 新霸达场站//FQMSP90141//船名航次为中文,提取时需要从船名航次表中提取英文数据,没有则显示中文船名
static public DBResult GetXINBADACTNList ( string mblno, string bsno, bool isweb = false )
{
var result = new DBResult();
result.Success = true;
//var bodyList = new List<MsOpSeaeDetail>();
//var bodyList3 = new List<MsOpSeaeDetail>();
//try
//{
// var datahtml = MsGetQingdaoPortDAL.GetHtmlData2("http://www.qingdaoportec.net/spcll/spclltdList.action", "btnQueryBill=&tdh=" + mblno);
// if (isweb == true)
// {
// datahtml = datahtml.Replace("/spcll/style.css", "http://www.qingdaoportec.net/spcll/style.css");
// datahtml = datahtml.Replace("/spcll/layout.css", "http://www.qingdaoportec.net/spcll/layout.css");
// datahtml = datahtml.Replace("/spcll/maxheight.js", "http://www.qingdaoportec.net/spcll/maxheight.js");
// datahtml = datahtml.Replace("/gxcz/common/css/Style.css", "http://www.qingdaoportec.net/gxcz/common/css/Style.css");
// datahtml = datahtml.Replace("/gxcz/common/css/Styletit.css", "http://www.qingdaoportec.net/gxcz/common/css/Styletit.css");
// result.Data = datahtml;
// }
// else
// {
// var datahtml3 = GetDataHtmlList(datahtml, "订舱信息", "</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>") + 4);
// 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);
// if (fielddatastr.IndexOf("</td>") > -1)
// {
// fielddatastr = fielddatastr.Remove(fielddatastr.IndexOf("</td>"), 5);
// }
// fielddatastr = fielddatastr.Remove(0, fielddatastr.IndexOf(">") + 1);
// if (fieldno == 1)
// {
// fielddatastr = fielddatastr.Remove(0, fielddatastr.IndexOf(">") + 1);
// fielddatastr = fielddatastr.Remove(0, fielddatastr.IndexOf(">") + 1);
// if (fielddatastr.IndexOf("</a>") > -1)
// {
// fielddatastr = fielddatastr.Remove(fielddatastr.IndexOf("</a>"), 4);
// }
// data.VESSEL = fielddatastr;
// T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
// string sVESSEL = T_ALL_DA.GetStrSQL("VESSEL", "select top 1 isnull(VESSEL,'') as VESSEL from code_vessel where CNAME='" + data.VESSEL.ToString().Trim() + "'");
// data.VESSEL = (sVESSEL == "" ? data.VESSEL.ToString().Trim() : sVESSEL);
// }
// else if (fieldno == 2)
// {
// data.VOYNO = fielddatastr;
// }
// data.KGS = 0; //毛重
// data.PKGS = 0; //件数
// fieldno = fieldno + 1;
// }
// bodyList3.Add(data);
// }
// i = i + 1;
// }
// #endregion
// }
// var datahtml2 = GetDataHtmlList(datahtml, "集货动态", "</table>");
// if (datahtml2 != "")
// {
// #region 集货动态
// var i = 1;
// var ctnall = "";
// 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>") + 4);
// 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);
// if (fielddatastr.IndexOf("</td>") > -1)
// {
// fielddatastr = fielddatastr.Remove(fielddatastr.IndexOf("</td>"), 5);
// }
// fielddatastr = fielddatastr.Remove(0, fielddatastr.IndexOf(">") + 1);
// if (fieldno == 1)
// {
// fielddatastr = fielddatastr.Remove(0, fielddatastr.IndexOf(">") + 1);
// fielddatastr = fielddatastr.Remove(0, fielddatastr.IndexOf(">") + 1);
// if (fielddatastr.IndexOf("</a>") > -1)
// {
// fielddatastr = fielddatastr.Remove(fielddatastr.IndexOf("</a>"), 4);
// }
// data.CNTRNO = fielddatastr;
// foreach (var enumValue in bodyList3)
// {
// data.VESSEL = enumValue.VESSEL;
// data.VOYNO = enumValue.VOYNO;
// }
// }
// else if (fieldno == 2)
// {
// ctnall = fielddatastr;//尺码
// }
// else if (fieldno == 3)
// {
// data.CTNALL = ctnall + fielddatastr;//表现形式
// }
// else if (fieldno == 5)
// {
// data.SEALNO = fielddatastr;//铅封号
// }
// else if (fieldno == 4)
// {
// try
// {
// data.TAREWEIGHT = Convert.ToDecimal(fielddatastr); //箱皮重
// }
// catch
// {
// data.TAREWEIGHT = 0; //箱皮重
// }
// }
// data.KGS = 0; //毛重
// data.PKGS = 0; //件数
// fieldno = fieldno + 1;
// }
// bodyList.Add(data);
// }
// i = i + 1;
// }
// #endregion
// }
// datahtml2 = GetDataHtmlList(datahtml, "实际装货信息", "</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>") + 4);
// 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);
// if (fielddatastr.IndexOf("</td>") > -1)
// {
// fielddatastr = fielddatastr.Remove(fielddatastr.IndexOf("</td>"), 5);
// }
// fielddatastr = fielddatastr.Remove(0, fielddatastr.IndexOf(">") + 1);
// if (fieldno == 1)
// {
// fielddatastr = fielddatastr.Remove(0, fielddatastr.IndexOf(">") + 1);
// fielddatastr = fielddatastr.Remove(0, fielddatastr.IndexOf(">") + 1);
// if (fielddatastr.IndexOf("</a>") > -1)
// {
// fielddatastr = fielddatastr.Remove(fielddatastr.IndexOf("</a>"), 4);
// }
// data.CNTRNO = fielddatastr;
// foreach (var enumValue in bodyList3)
// {
// data.VESSEL = enumValue.VESSEL;
// data.VOYNO = enumValue.VOYNO;
// }
// }
// else if (fieldno == 3)
// {
// try
// {
// data.PKGS = Convert.ToInt32(fielddatastr); //件数
// }
// catch
// {
// data.PKGS = 0; //件数
// }
// }
// else if (fieldno == 4)
// {
// try
// {
// data.KGS = Convert.ToDecimal(fielddatastr); //毛重=整箱重-箱皮重
// }
// catch
// {
// data.KGS = 0; //毛重
// }
// }
// else if (fieldno == 5)
// {
// try
// {
// data.CBM = Convert.ToDecimal(fielddatastr);
// }
// catch
// {
// data.CBM = 0; //毛重
// }
// }
// fieldno = fieldno + 1;
// }
// bodyList.Add(data);
// }
// i = i + 1;
// }
// #endregion
// }
// if (bodyList.Count == 0)
// {
// bodyList = bodyList3;
// }
// bodyList = SumBodyList(bodyList);
// result.Data = bodyList.ToList();
// }
//}
//catch
//{
// result.Success = false;
// result.Message = "提取数据过程中发生错误,请联系系统管理员!";
//}
return result;
}
#endregion
#region 青岛前湾QQCT场站//无船名航次信息//2017-01-24因网址变更页面格式变更等原因需要重新解析提取此网站信息
static public DBResult GetQQCTCTNList ( string mblno, string bsno, bool isweb = false )
{
var result = new DBResult();
result.Success = true;
var bodyList = new List<MsOpSeaeDetail>();
try
{
HttpHelper http = new HttpHelper();
HttpItem item = new HttpItem()
{
//http:///www.qqct.com.cn/dpcxList.jsp
URL = "http://www.qqct.com.cn/cn/yewuxinxi_02_02.aspx?Panel=13&paramstr=strMTJCKHW%3d" + mblno,//URL这里都是测试 必需项
Encoding = Encoding.UTF8,//编码格式utf-8,gb2312,gbk 可选项 默认类会自动识别
Host = "www.qqct.com.cn",
UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)",
Accept = "text/html, application/xhtml+xml, */*",// 可选项有默认值
ContentType = "text/html",
Method = "get",//URL 可选项 默认为Get
};
HttpResult resulthtml = http.GetHtml(item);
if (isweb == true)
{
var datahtml = resulthtml.Html;
datahtml = datahtml.Replace("css_js/cnnetstars.css", "http://www.qqct.com.cn/css_js/cnnetstars.css");
result.Data = datahtml;
}
else
{
var datahtml = GetDataHtmlList(resulthtml.Html, "tableGrid", "</table>");
if (datahtml != "")
{
#region 只有一个Table信息
var i = 1;
while (datahtml.IndexOf("</tr>") >= 0)
{
var datalength = datahtml.IndexOf("</tr>");
var recdatastr = datahtml.Substring(0, datalength + 5);
datahtml = datahtml.Substring(datalength + 5, datahtml.Length - datalength - 5);
recdatastr = recdatastr.Remove(0, recdatastr.IndexOf("<tr>") + 4);
recdatastr = recdatastr.Remove(recdatastr.IndexOf("</tr>"), 5);
var fieldno = 1;
var ctnall = "";
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);
if (fieldno == 1)
{
fielddatastr = fielddatastr.Remove(0, fielddatastr.IndexOf(">") + 1);
data.CNTRNO = fielddatastr;
}
else if (fieldno == 3)
{
data.SEALNO = "";
}
else if (fieldno == 5)
{
data.CTNALL = fielddatastr;
}
else if (fieldno == 11)
{
try
{
data.KGS = Convert.ToDecimal(fielddatastr);
}
catch
{
data.KGS = 0;
}
}
data.PKGS = 0;
data.CBM = 0;
fieldno = fieldno + 1;
}
bodyList.Add(data);
}
i = i + 1;
}
#endregion
}
//
bodyList = SumBodyList(bodyList);
result.Data = bodyList.ToList();
}
}
catch
{
result.Success = false;
result.Message = "提取数据过程中发生错误,请联系系统管理员!";
}
return result;
}
#endregion
#region 青岛润海场站只有一个Table且只有件重尺//NGTAO02000614JP
static public DBResult GetRUNHAICTNList ( string mblno, string bsno, bool isweb = false )
{
var result = new DBResult();
result.Success = true;
var bodyList = new List<MsOpSeaeDetail>();
try
{
HttpHelper http = new HttpHelper();
HttpItem item = new HttpItem()
{
URL = "http://www.qingdaoportec.net/rhtdList.action?billNo=" + mblno,//URL这里都是测试 必需项
Encoding = null,//编码格式utf-8,gb2312,gbk 可选项 默认类会自动识别
Host = "www.qingdaoportec.net",
UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)",
Accept = "text/html, application/xhtml+xml, */*",// 可选项有默认值
ContentType = "text/html",
Method = "get",//URL 可选项 默认为Get
};
HttpResult resulthtml = http.GetHtml(item);
if (isweb == true)
{
var datahtml = resulthtml.Html;
datahtml = datahtml.Replace("/rh/common/css/css.css", "http://www.qingdaoportec.net/rh/common/css/css.css");
datahtml = datahtml.Replace("/rh/common/js/sw.js", "http://www.qingdaoportec.net/rh/common/js/sw.js");
datahtml = datahtml.Replace("/common/js/jquery.js", "http://www.qingdaoportec.net/common/js/jquery.js");
datahtml = datahtml.Replace("/jsp/authImg.jsp", "http://www.qingdaoportec.net/jsp/authImg.jsp");
result.Data = datahtml;
}
else
{
//var datahtml = GetDataHtmlList(resulthtml.Html, "tableGrid", "</table>");
var datahtml = resulthtml.Html;
if (datahtml != "")
{
#region 只有一个Table信息
var htmllength = datahtml.Length;
var startstr = "船名";
var startindex = datahtml.IndexOf(startstr) - 200;
datahtml = datahtml.Substring(startindex + startstr.Length, htmllength - startindex - startstr.Length);
var startindex2 = datahtml.IndexOf("</table>");
if (startindex2 != -1 && startindex2 != 0)
{
datahtml = datahtml.Substring(0, startindex2);
}
//
var i = 1;
while (datahtml.IndexOf("</tr>") >= 0)
{
var datalength = datahtml.IndexOf("</tr>");
var recdatastr = datahtml.Substring(0, datalength + 5);
datahtml = datahtml.Substring(datalength + 5, datahtml.Length - datalength - 5);
recdatastr = recdatastr.Remove(0, recdatastr.IndexOf("<tr>") + 4);
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("&nbsp;", "");
data.CNTRNO = "";
data.SEALNO = "";
data.CTNALL = "";
if (fieldno == 1)
{
fielddatastr = fielddatastr.Remove(0, fielddatastr.IndexOf(">") + 1);
data.VESSEL = fielddatastr;
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
string sVESSEL = T_ALL_DA.GetStrSQL("VESSEL", "select top 1 isnull(VESSEL,'') as VESSEL from code_vessel where CNAME='" + data.VESSEL.ToString().Trim() + "'");
data.VESSEL = (sVESSEL == "" ? data.VESSEL.ToString().Trim() : sVESSEL);
}
if (fieldno == 2)
{
data.VOYNO = fielddatastr;
}
if (fieldno == 4)
{
try
{
data.PKGS = Convert.ToInt32(fielddatastr);
}
catch
{
data.PKGS = 0;
}
}
if (fieldno == 5)
{
try
{
data.KGS = Convert.ToDecimal(fielddatastr);
}
catch
{
data.KGS = 0;
}
}
if (fieldno == 6)
{
try
{
data.CBM = Convert.ToDecimal(fielddatastr);
}
catch
{
data.CBM = 0;
}
}
fieldno = fieldno + 1;
}
bodyList.Add(data);
}
i = i + 1;
}
#endregion
}
//
bodyList = SumBodyList(bodyList);
result.Data = bodyList.ToList();
}
}
catch
{
result.Success = false;
result.Message = "提取数据过程中发生错误,请联系系统管理员!";
}
return result;
}
#endregion
#region 中外运集装箱运输有限公司//SNL7XGJL166056天津箱运//SNL7DLJL226035大连//http://ebusiness.sinolines.com/snlebusiness/TrackingByBlno.aspx
static public DBResult GetZhongWaiYunCTNList(string mblno, string bsno, bool isweb = false)
{
var result = new DBResult();
result.Success = true;
//var bodyList = new List<MsOpSeaeDetail>();
//var bodyList3 = new List<MsOpSeaeDetail>();
//try
//{
// //<input name="ValidateImageButton" id="ValidateImageButton" type="image" src="ValidateImage.aspx">
// //验证码图片http://ebusiness.sinolines.com/snlebusiness/ValidateImage.aspx
// #region 提取页面
// var outcodestr = MsGetZhongWaiYunDAL.GetHtmlData("http://ebusiness.sinolines.com/snlebusiness/TrackingByBlno.aspx", mblno);
// HttpHelper http = new HttpHelper();
// HttpItem item = new HttpItem()
// {
// URL = "http://ebusiness.sinolines.com/snlebusiness/TrackingByBlno.aspx",//URL这里都是测试 必需项
// Encoding = null,//编码格式utf-8,gb2312,gbk 可选项 默认类会自动识别
// Host = "ebusiness.sinolines.com",
// UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko",
// Accept = "text/html, application/xhtml+xml, */*",// 可选项有默认值
// ContentType = "application/x-www-form-urlencoded",
// Method = "get",//URL 可选项 默认为Get
// };
// HttpResult resulthtml = http.GetHtml(item);
// //
// var viewstatehtml = resulthtml.Html;
// viewstatehtml = GetDataHtmlList(viewstatehtml, "__VIEWSTATE", "/>");
// viewstatehtml = viewstatehtml.Replace("\"", "");
// viewstatehtml = GetDataHtmlList(viewstatehtml, "/", "/>").Trim();
// viewstatehtml = "__EVENTTARGET=&__EVENTARGUMENT=&__VIEWSTATE="//%2F
// + viewstatehtml + "&dl_seltype=blno&TbBlno=" + mblno + "&ValidateCodeTXT=" + outcodestr + "&BlnoListRetrieveBT=%E6%9F%A5%E8%AF%A2";
// viewstatehtml = viewstatehtml.Replace("+", "%2B");
// viewstatehtml = viewstatehtml.Replace("/", "%2F");
// var mycookie = resulthtml.Cookie;// "pbzqi4fkorcw5fdgw05rispd";
// item = new HttpItem()
// {
// URL = "http://ebusiness.sinolines.com/snlebusiness/TrackingByBlno.aspx",//URL这里都是测试 必需项
// Referer = "http://ebusiness.sinolines.com/snlebusiness/TrackingByBlno.aspx",//“http:///www.szx.net.cn/Default.aspx”
// Encoding = null,//编码格式utf-8,gb2312,gbk 可选项 默认类会自动识别
// Host = "ebusiness.sinolines.com",
// UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko",
// Accept = "text/html, application/xhtml+xml, */*",// 可选项有默认值
// ContentType = "application/x-www-form-urlencoded",
// Cookie = mycookie,
// Postdata = viewstatehtml,
// Method = "POST",//URL 可选项 默认为Get
// };
// #endregion
// resulthtml = http.GetHtml(item);
// if (isweb == true)
// {
// var datahtml = resulthtml.Html;
// datahtml = datahtml.Replace("App_Themes/GridView/StyleSheet.css", "http://ebusiness.sinolines.com/snlebusiness/jQuery-Autocomplete-Port/content/styles.css");
// datahtml = datahtml.Replace("images/main.css", "http://ebusiness.sinolines.com/snlebusiness/SnlStyles/menu.css");
// datahtml = datahtml.Replace("images/GridView.css", "http://ebusiness.sinolines.com/snlebusiness/SnlStyles/commonctrls.css");
// result.Data = datahtml;
// }
// else
// {
// var datahtml3 = GetDataHtmlList(resulthtml.Html, "tbMainData", "</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") + 4);
// recdatastr = recdatastr.Remove(recdatastr.IndexOf("</tr>"), 5);
// var fieldno = 1;
// if (i != 1 && recdatastr.IndexOf("暂无相关数据") < 0)
// {
// 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.Remove(0, fielddatastr.IndexOf("<td>") + 4);
// fielddatastr = fielddatastr.Trim().Replace("\r\n", "");
// if (fieldno == 1)
// {
// data.VESSEL = fielddatastr.Substring(0, fielddatastr.IndexOf("/")).Trim();
// }
// if (fieldno == 2)
// {
// data.VOYNO = fielddatastr;
// }
// fieldno = fieldno + 1;
// }
// bodyList3.Add(data);
// }
// i = i + 1;
// }
// #endregion
// }
// //
// var datahtml = GetDataHtmlList(resulthtml.Html, "实际装货信息", "</table>");
// if (datahtml != "")
// {
// #region 实际装货信息
// var i = 1;
// while (datahtml.IndexOf("</tr>") >= 0)
// {
// var datalength = datahtml.IndexOf("</tr>");
// var recdatastr = datahtml.Substring(0, datalength + 5);
// datahtml = datahtml.Substring(datalength + 5, datahtml.Length - datalength - 5);
// recdatastr = recdatastr.Remove(0, recdatastr.IndexOf("<tr") + 4);
// recdatastr = recdatastr.Remove(recdatastr.IndexOf("</tr>"), 5);
// var fieldno = 1;
// var istrue = false;
// var ctnall = "";
// 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);
// if (fieldno == 1)
// {
// fielddatastr = fielddatastr.Remove(0, fielddatastr.IndexOf(">") + 1);
// if (fielddatastr.IndexOf("合计") > -1 || fielddatastr.IndexOf("暂无相关数据") > -1)
// {
// istrue = false;
// }
// else
// {
// istrue = true;
// };
// }
// if (fieldno == 2 && istrue)
// {
// data.CNTRNO = fielddatastr.Trim().Replace("\r\n", "");
// foreach (var enumValue in bodyList3)
// {
// data.VESSEL = enumValue.VESSEL;
// data.VOYNO = enumValue.VOYNO;
// }
// }
// if (fieldno == 3 && istrue)
// {
// ctnall = fielddatastr.Trim().Replace("\r\n", "");
// }
// if (fieldno == 4 && istrue)
// {
// data.CTNALL = ctnall + fielddatastr.Trim().Replace("\r\n", "");
// }
// if (fieldno == 5 && istrue)
// {
// data.SEALNO = fielddatastr.Trim().Replace("\r\n", "");
// }
// if (fieldno == 6 && istrue)
// {
// try
// {
// data.PKGS = Convert.ToInt32(fielddatastr);
// }
// catch
// {
// data.PKGS = 0;
// }
// }
// if (fieldno == 8 && istrue)
// {
// try
// {
// data.KGS = Convert.ToDecimal(fielddatastr);
// }
// catch
// {
// data.KGS = 0;
// }
// }
// if (fieldno == 9 && istrue)
// {
// try
// {
// data.CBM = Convert.ToDecimal(fielddatastr);
// }
// catch
// {
// }
// }
// fieldno = fieldno + 1;
// }
// if (istrue)
// bodyList.Add(data);
// }
// i = i + 1;
// }
// #endregion
// }
// if (bodyList.Count == 0)
// {
// bodyList = bodyList3;
// }
// bodyList = SumBodyList(bodyList);
// result.Data = bodyList.ToList();
// }
//}
//catch
//{
// result.Success = false;
// result.Message = "提取数据过程中发生错误,请联系系统管理员!";
//}
return result;
}
#endregion
#region 青岛克/客运场站(未完成,抓取页面总是抓取到跳转的错误页面)//A240013048
static public DBResult GetKEYUNCTNList ( string mblno, string bsno, bool isweb = false )
{
var result = new DBResult();
result.Success = true;
var bodyList = new List<MsOpSeaeDetail>();
try
{
HttpHelper http = new HttpHelper();
HttpItem item = new HttpItem()
{
URL = "http://124.129.1.67:8088/Login.aspx",//URL这里都是测试 必需项
Encoding = Encoding.UTF8,//编码格式utf-8,gb2312,gbk 可选项 默认类会自动识别
Host = "124.129.1.67:8088",
Accept = "text/html, application/xhtml+xml, */*",// 可选项有默认值
UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)",
ContentType = "text/html; charset=utf-8",
Cookie = "ASP.NET_SessionId=tj4yjy452sa2w555kxyjw2m3",//oanzqr2c1klvi0iuuykktmbo
//Postdata = "__EVENTTARGET=LBUserPublicLogin&__EVENTARGUMENT=&__VIEWSTATE=%2FwEPDwUJMzM2ODg0ODc1D2QWAgIDD2QWBAIBD2QWAmYPZBYGAgEPDxYCHgRUZXh0BQvnlKjmiLflkI0gOmRkAgUPDxYCHwAFB%2BWvhueggTpkZAIJDw8WAh8ABQbnmbvlvZVkZAIDDw8WAh8ABRjlhazlhbHmn6Xor6LotKbmiLfpk77mjqVkZGQ%3D&Login1%24UserName=&Login1%24Password=&__EVENTVALIDATION=%2FwEWBgLPqq6lDQKUvNa1DwL666vYDAKnz4ybCALFsbreBgKP3dSIBA%3D%3D",
Method = "get",//URL 可选项 默认为Get
};
HttpResult resulthtml = http.GetHtml(item);
var viewstatehtml = resulthtml.Html;
viewstatehtml = GetDataHtmlList(viewstatehtml, "__VIEWSTATE", "/>");
viewstatehtml = viewstatehtml.Replace("\"", "");
viewstatehtml = GetDataHtmlList(viewstatehtml, "/", "/>").Trim();
var _eventvalidation = resulthtml.Html;
_eventvalidation = GetDataHtmlList(_eventvalidation, "__EVENTVALIDATION", "/>");
_eventvalidation = _eventvalidation.Replace("\"", "");
_eventvalidation = GetDataHtmlList(_eventvalidation, "/", "/>").Trim();
viewstatehtml = "ctl00_TreeView1_ExpandState=enn&ctl00_TreeView1_SelectedNode=&__EVENTTARGET=&__EVENTARGUMENT=&ctl00_TreeView1_PopulateLog=&__VIEWSTATE=%2F" + viewstatehtml + "&ctl00%24ContentPlaceHolder1%24txtTDH=" + mblno + "&ctl00%24ContentPlaceHolder1%24BtnTDH=%E6%9F%A5%E8%AF%A2&__EVENTVALIDATION=%2F" + _eventvalidation;
viewstatehtml = viewstatehtml.Replace("+", "%2B");
viewstatehtml = viewstatehtml.Replace("/", "%2F");
var mycookie = resulthtml.Cookie;
if (resulthtml.Cookie == null)
{
mycookie = "ASP.NET_SessionId=adu3xj55pxcznk451totjc45";
}
var viewstatehtml2 = "__EVENTTARGET=LBUserPublicLogin&__EVENTARGUMENT=&__VIEWSTATE=%2F" + viewstatehtml + "&Login1%24UserName=&Login1%24Password=&__EVENTVALIDATION=%2F" + _eventvalidation;
viewstatehtml2 = viewstatehtml.Replace("+", "%2B");
viewstatehtml2 = viewstatehtml.Replace("/", "%2F");
item = new HttpItem()
{
URL = "http://124.129.1.67:8088/Login.aspx",//URL这里都是测试 必需项
Referer = "http://124.129.1.67:8088/Login.aspx",
Encoding = Encoding.UTF8,//编码格式utf-8,gb2312,gbk 可选项 默认类会自动识别
Cookie = mycookie,
Host = "124.129.1.67:8088",
UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)",
Accept = "text/html, application/xhtml+xml, */*",// 可选项有默认值
ContentType = "application/x-www-form-urlencoded",
//2016-05-10 重新从网站获取Postdata配置信息
//Postdata = "__EVENTTARGET=LBUserPublicLogin&__EVENTARGUMENT=&__VIEWSTATE=%2FwEPDwUJMzM2ODg0ODc1D2QWAgIDD2QWBAIBD2QWAmYPZBYGAgEPDxYCHgRUZXh0BQvnlKjmiLflkI0gOmRkAgUPDxYCHwAFB%2BWvhueggTpkZAIJDw8WAh8ABQbnmbvlvZVkZAIDDw8WAh8ABRjlhazlhbHmn6Xor6LotKbmiLfpk77mjqVkZGQ%3D&Login1%24UserName=&Login1%24Password=&__EVENTVALIDATION=%2FwEWBgLPqq6lDQKUvNa1DwL666vYDAKnz4ybCALFsbreBgKP3dSIBA%3D%3D",
Postdata = viewstatehtml2,
Method = "POST",//URL 可选项 默认为Get
};
resulthtml = http.GetHtml(item);
//ctl00_TreeView1_ExpandState=enn&ctl00_TreeView1_SelectedNode=&__EVENTTARGET=&__EVENTARGUMENT=&ctl00_TreeView1_PopulateLog=&__VIEWSTATE=%2FwEPBRI2MzYxNzMyMTA2MzgyMDcwOTRk&ctl00%24ContentPlaceHolder1%24txtTDH=A240013048&ctl00%24ContentPlaceHolder1%24BtnTDH=%E6%9F%A5%E8%AF%A2&__EVENTVALIDATION=%2FwEWBgKbt5qPCQKizYC%2FCwKEioq3DgKKoomnCQLPit2EBAKD%2B5mLAQ%3D%3D
var viewstatehtml3 = "ctl00_TreeView1_ExpandState=enn&ctl00_TreeView1_SelectedNode=&__EVENTTARGET=&__EVENTARGUMENT=&ctl00_TreeView1_PopulateLog=&__VIEWSTATE=%2F" + viewstatehtml + "&ctl00%24ContentPlaceHolder1%24txtTDH=" + mblno + "&ctl00%24ContentPlaceHolder1%24BtnTDH=%E6%9F%A5%E8%AF%A2&__EVENTVALIDATION=%2F" + _eventvalidation;
viewstatehtml3 = viewstatehtml.Replace("+", "%2B");
viewstatehtml3 = viewstatehtml.Replace("/", "%2F");
item = new HttpItem()
{
///DefaultContent.aspx
///WebResource.axd?d=8Q_LYGQ3ahbLqoTw5CV0Lg1e41aTOlreKY7Iy_M1_wk1&t=635475983166250000
URL = "http://124.129.1.67:8088/QD_CfsExportUsualTDHInfo.aspx?DbName=",//URL这里都是测试 必需项
Referer = "http://124.129.1.67:8088/QD_CfsExportUsualTDHInfo.aspx?DbName=",
Encoding = null,//编码格式utf-8,gb2312,gbk 可选项 默认类会自动识别
Cookie = mycookie,
Host = "124.129.1.67:8088",
//UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)",
UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)",
Accept = "text/html, application/xhtml+xml, */*",// 可选项有默认值
ContentType = "application/x-www-form-urlencoded",
//2016-05-10 重新从网站获取Postdata配置信息
//Postdata = viewstatehtml3,
Postdata = "ctl00_TreeView1_ExpandState=enn&ctl00_TreeView1_SelectedNode=&__EVENTTARGET=&__EVENTARGUMENT=&ctl00_TreeView1_PopulateLog=&__VIEWSTATE=%2FwEPBRI2MzYxNzMyMTA2MzgyMDcwOTRk&ctl00%24ContentPlaceHolder1%24txtTDH=A240013048&ctl00%24ContentPlaceHolder1%24BtnTDH=%E6%9F%A5%E8%AF%A2&__EVENTVALIDATION=%2FwEWBgKbt5qPCQKizYC%2FCwKEioq3DgKKoomnCQLPit2EBAKD%2B5mLAQ%3D%3D",
Method = "POST",//URL 可选项 默认为Get
};
resulthtml = http.GetHtml(item);
if (isweb == true)
{
var datahtml = resulthtml.Html;
datahtml = datahtml.Replace("/App_Themes/Default/css/main.css", "http://124.129.1.67:8088/App_Themes/Default/css/main.css");
result.Data = datahtml;
}
else
{
var datahtml = GetDataHtmlList(resulthtml.Html, "ctl00_ContentPlaceHolder1_GridView4", "</table>");
var datahtml6 = GetDataHtmlList(resulthtml.Html, "装箱信息", "</table>");
if (datahtml != "")
{
var i = 1;
while (datahtml.IndexOf("</tr>") >= 0)
{
var datalength = datahtml.IndexOf("</tr>");
var recdatastr = datahtml.Substring(0, datalength + 5);
datahtml = datahtml.Substring(datalength + 5, datahtml.Length - datalength - 5);
recdatastr = recdatastr.Remove(0, recdatastr.IndexOf("<tr") + 4);
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);
if (fieldno == 1)
{
fielddatastr = fielddatastr.Remove(0, fielddatastr.IndexOf(">") + 1);
if (fielddatastr == "&nbsp;")
{
istrue = false;
}
else
{
istrue = true;
};
}
if (fieldno == 3 && istrue)
{
data.CNTRNO = fielddatastr;
}
if (fieldno == 4 && istrue)
{
data.SEALNO = fielddatastr;
}
if (fieldno == 5 && istrue)
{
data.CTNALL = fielddatastr.Replace("'", "");
}
if (fieldno == 6 && istrue)
{
try
{
data.PKGS = Convert.ToInt32(fielddatastr);
}
catch
{
data.PKGS = 0;
}
}
if (fieldno == 7 && istrue)
{
try
{
data.KGS = Convert.ToDecimal(fielddatastr);
}
catch
{
data.KGS = 0;
}
}
if (fieldno == 8 && istrue)
{
try
{
data.CBM = Convert.ToDecimal(fielddatastr);
}
catch
{
}
}
fieldno = fieldno + 1;
}
if (istrue)
bodyList.Add(data);
}
i = i + 1;
}
}
bodyList = SumBodyList(bodyList);
result.Data = bodyList.ToList();
}
}
catch
{
result.Success = false;
result.Message = "提取数据过程中发生错误,请联系系统管理员!";
}
return result;
}
#endregion
#endregion
#region QQCT单票查询
static public DBResult GetQQCTBILL ( string mblno, string bsno )
{
var result = new DBResult();
result.Success = true;
var bodyList = new List<MsOpSeaeDetail>();
try
{
string cookie = "";
HttpHelper http = new HttpHelper();
HttpItem item = new HttpItem()
{
URL = "http://www.igenzong.com/Port/CNTAO,5,4,1/" + mblno + ".html",
Method = "get",//URL 可选项 默认为Get
ContentType = "application/x-www-form-urlencoded",//返回类型 可选项有默认值
Postdata = "portCode=CNTAO&businessId=5&dockId=4&pageNo=1&queryPara=" + mblno + "&url=/Port/CNTAO,5,4,1/" + mblno + ".html"
};
HttpResult result2 = http.GetHtml(item);
cookie = result2.Cookie;
item = new HttpItem()
{
URL = "http://www.igenzong.com/Port/TraceAjax",
Method = "post",//URL 可选项 默认为Get
ContentType = "application/x-www-form-urlencoded",//返回类型 可选项有默认值
Postdata = "portCode=CNTAO&businessId=5&dockId=4&pageNo=1&queryPara=" + mblno + "&url=/Port/CNTAO,5,4,1/" + mblno + ".html",
Cookie = cookie
};
result2 = http.GetHtml(item);
string html = result2.Html;
//JObject jo = (JObject)JsonConvert.DeserializeObject(html);
//html = jo["Data"].ToString();
html = html.Replace("<td>", "<td>&nbsp").Replace("</td>", "&nbsp</td>");
result.Data = html;
}
catch
{
result.Success = false;
result.Message = "提取数据过程中发生错误,请联系系统管理员!";
}
return result;
}
#endregion
#region QQCTU单票查询//青岛港物流电商平台http://www.qingdao-port.net/PCSLQIL305161107
static public DBResult GetQQCTUBILL ( string mblno, string bsno )
{
var result = new DBResult();
//result.Success = true;
//var bodyList = new List<MsOpSeaeDetail>();
//try
//{
// var datahtml = MsGetQingdaoPortDAL.GetHtmlData("http://www.qingdaoport.net/ywzx/qqctu/qqctuDp.jsp", "tdh=" + mblno);
// //while (datahtml.IndexOf("码头信息") <= 0)
// //{
// // datahtml = MsGetQingdaoPortDAL.GetHtmlData("http://www.qingdaoport.net/ywzx/qqctu/bill_query.jsp", "tdh=" + mblno);
// //}
// datahtml = datahtml.Replace("/common/css/style2009.css", "http://www.qingdaoport.net/common/css/style2009.css");
// datahtml = datahtml.Replace("/common/css/table.css", "http://www.qingdaoport.net/common/css/table.css");
// datahtml = datahtml.Replace("/common/js/common.js", "http://www.qingdaoport.net/common/js/common.js");
// datahtml = datahtml.Replace("/common/js/validation.js", "http://www.qingdaoport.net/common/js/validation.js");
// datahtml = datahtml.Replace("/common/js/date.js", "http://www.qingdaoport.net/common/js/date.js");
// var i = datahtml.IndexOf("<table");
// var j = datahtml.IndexOf("</TBODY>\r\n</TABLE>");
// datahtml = datahtml.Remove(i, j + 20 - i);
// i = datahtml.IndexOf("<form");
// j = datahtml.IndexOf("</form>");
// datahtml = datahtml.Remove(i, j + 7 - i);
// result.Data = datahtml;
//}
//catch
//{
// result.Success = false;
// result.Message = "提取数据过程中发生错误,请联系系统管理员!";
//}
return result;
}
static public DBResult GetQQCTUBILL2(string mblno, string bsno, bool isweb = false)
{
var result = new DBResult();
result.Success = true;
var bodyList = new List<MsOpSeaeDetail>();
try
{
HttpHelper http = new HttpHelper();
HttpItem item = new HttpItem()
{
URL = "http://www.qingdao-port.net/page/login.do",//URL这里都是测试必需项
Encoding = null,//编码格式utf-8,gb2312,gbk可选项默认类会自动识别
Host = "www.qingdao-port.net",
UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko",
Accept = "text/html, application/xhtml+xml, */*",//可选项,有默认值
ContentType = "Content-Type text/html;charset=UTF-8",
Method = "get",//URL可选项 默认为Get
Cookie = "JSESSIONID_QDPORT=de4d9ce2-8e14-4a92-b4ff-31dcf57a58f8; SERVERID=558e5262858a0a0c35661c324250792f|1484536268|1484536002; a5320_pages=1; a5320_times=1",
};
HttpResult resulthtml = http.GetHtml(item);
//
var mycookie = resulthtml.Cookie;// "wglwgtsjsbz3l2jp34vtxyyg";
item = new HttpItem()
{
URL = "http://track.qingdao-port.net/wmdp/logistics/wmdp/queryWmdp?tdhType=ZTDH&jckType=CK&value=PCSLQIL305161107 HTTP/1.1",//URL这里都是测试 必需项
Referer = "http://track.qingdao-port.net/wmdp",//“http:///www.szx.net.cn/Default.aspx”
Encoding = null,//编码格式utf-8,gb2312,gbk 可选项 默认类会自动识别
Host = "track.qingdao-port.net",
UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko",
Accept = "application/json, text/javascript, */*; q=0.01",// 可选项有默认值
ContentType = "application/x-www-form-urlencoded; charset=UTF-8",
Cookie = "JSESSIONID_QDPORT=de4d9ce2-8e14-4a92-b4ff-31dcf57a58f8; SERVERID=e184e28e2e6e6d459c41e8c1b7e3b683|1484537073|1484536994",
//2016-12-13 重新从网站获取Postdata配置信息
Postdata = "qtype=pc",
Method = "POST",//URL 可选项 默认为Get
};
resulthtml = http.GetHtml(item);
if (isweb == true)
{
var datahtml = resulthtml.Html;
datahtml = datahtml.Replace("static/js/layer/skin/default/icon.png", "http://track.qingdao-port.net/static/js/layer/skin/default/icon.png");
//datahtml = datahtml.Replace("images/main.css", "http://221.215.104.14:8084/images/main.css");
//datahtml = datahtml.Replace("images/GridView.css", "http://221.215.104.14:8084/images/GridView.css");
result.Data = datahtml;
}
else
{
result.Success = false;
result.Message = "提取数据过程中发生错误,请联系系统管理员!";
}
}
catch
{
result.Success = false;
result.Message = "提取数据过程中发生错误,请联系系统管理员!";
}
return result;
}
#endregion
#region QQCT、QQCTU海关放行查询
static public DBResult GetQQCTQQCTUBILL ( string mblno, string bsno )
{
var result = new DBResult();
result.Success = true;
//var bodyList = new List<MsOpSeaeDetail>();
//try
//{
// //http:..www.qingdaoport.net/ywzx/qqct/dpcx/hgfx.jsp?val=140600161817&s_type=0&num=80
// var datahtml = MsGetQingdaoPortDAL.GetHtmlData("http://www.qingdaoport.net/ywzx/qqct/dpcx/hgfx.jsp", "val=" + mblno + "&s_type=0");
// //var sss = datahtml.IndexOf("序号");
// //while (datahtml.IndexOf("序号") <= 0 && datahtml.IndexOf(mblno) <= 0)//海关放行信息
// //{
// // datahtml = MsGetQingdaoPortDAL.GetHtmlData("http://www.qingdaoport.net/ywzx/qqct/dpcx/hgfx.jsp", "val=" + mblno + "&s_type=0");
// //}
// datahtml = datahtml.Replace("/common/css/style2009.css", "http://www.qingdaoport.net/common/css/style2009.css");
// datahtml = datahtml.Replace("/common/css/table.css", "http://www.qingdaoport.net/common/css/table.css");
// datahtml = datahtml.Replace("/common/js/common.js", "http://www.qingdaoport.net/common/js/common.js");
// datahtml = datahtml.Replace("/common/js/validation.js", "http://www.qingdaoport.net/common/js/validation.js");
// datahtml = datahtml.Replace("/common/js/date.js", "http://www.qingdaoport.net/common/js/date.js");
// var i = datahtml.IndexOf("<table");
// var j = datahtml.IndexOf("</TBODY>\r\n</TABLE>");
// datahtml = datahtml.Remove(i, j + 20 - i);
// i = datahtml.IndexOf("<form");
// if (i < 0)
// {
// i = datahtml.IndexOf("<FORM");
// }
// j = datahtml.IndexOf("</form>");
// datahtml = datahtml.Remove(i, j + 7 - i);
// result.Data = datahtml;
//}
//catch
//{
// result.Success = false;
// result.Message = "提取数据过程中发生错误,请联系系统管理员!";
//}
return result;
}
#endregion
#region 青岛港单船查询
static public DBResult GetQDVESSEL ( string vessel, string voyno )
{
var result = new DBResult();
result.Success = true;
//var bodyList = new List<MsOpSeaeDetail>();
//try
//{
// var datahtml = MsGetQingdaoPortDAL.GetHtmlData("http://www.qingdaoport.net/ywzx/ship/shipcx.jsp", "vessel_name=" + vessel + "&voyage_number=" + voyno);
// //while (datahtml.IndexOf("码头船期信息") <= 0)
// //{
// // datahtml = MsGetQingdaoPortDAL.GetHtmlData("http://www.qingdaoport.net/ywzx/ship/shipcx.jsp", "vessel_name=" + vessel + "&voyage_number=" + voyno);
// //}
// datahtml = datahtml.Replace("/common/js/jQuery/jquery-1.2.1.pack.js", "http://www.qingdaoport.net/common/js/jQuery/jquery-1.2.1.pack.js");
// datahtml = datahtml.Replace("/common/js/jQuery/jquery.autocomplete.js", "http://www.qingdaoport.net/common/js/jQuery/jquery.autocomplete.js");
// datahtml = datahtml.Replace("/common/js/jQuery/jquery.autocomplete.css", "http://www.qingdaoport.net/common/js/jQuery/jquery.autocomplete.css");
// datahtml = datahtml.Replace("/common/js/common.js", "http://www.qingdaoport.net/common/js/common.js");
// datahtml = datahtml.Replace("/common/css/table.css", "http://www.qingdaoport.net/common/css/table.css");
// datahtml = datahtml.Replace("/common/js/validation.js", "http://www.qingdaoport.net/common/js/validation.js");
// datahtml = datahtml.Replace("/common/js/date.js", "http://www.qingdaoport.net/common/js/date.js");
// var i = datahtml.IndexOf("<table");
// var j = datahtml.IndexOf("</TBODY>\r\n</TABLE>");
// datahtml = datahtml.Remove(i, j + 20 - i);
// i = datahtml.IndexOf("<form");
// j = datahtml.IndexOf("</form>");
// datahtml = datahtml.Remove(i, j + 7 - i);
// result.Data = datahtml;
//}
//catch
//{
// result.Success = false;
// result.Message = "提取数据过程中发生错误,请联系系统管理员!";
//}
return result;
}
#endregion
#region 物流信息网报关状态
static public MsOpSeaeCustomStatus GetNewCustStatus ( List<MsOpSeaeCustomStatus> bodylist )
{
if (bodylist.Count == 1) return bodylist[0];
var newbody = new MsOpSeaeCustomStatus();
var tranbodylist = bodylist;
var i = 1;
foreach (var enumValue in bodylist)
{
var istrue = false;
if (i == 1) newbody = enumValue;
else
{
if (enumValue.ISLOADCLEAR == true && newbody.ISLOADCLEAR != true)
istrue = true;
if (enumValue.ISBILLCLEAR == true && newbody.ISBILLCLEAR != true)
istrue = true;
if (enumValue.ISCUSTOMCLEAR == true && newbody.ISCUSTOMCLEAR != true)
istrue = true;
if (istrue == false && enumValue.LOADCLEARSTR != "")
if (istrue == true) newbody = enumValue;
}
i = i + 1;
}
return newbody;
}
//static public DBResult Get56CDCSTATUSList(string mblno, string bsno)
//{
// var result = new DBResult();
// result.Success = true;
// var bodyList = new List<MsOpSeaeCustomStatus>();
// try
// {
// HttpHelper http = new HttpHelper();
// HttpItem item = new HttpItem()
// {
// URL = "http://cdp.qdcdc.com/CDP/Login.aspx",//URL这里都是测试 必需项
// Referer = "http://cdp.qdcdc.com/CDP/Login.aspx",
// Encoding = null,//编码格式utf-8,gb2312,gbk 可选项 默认类会自动识别
// Host = "56.qdcdc.com",
// UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)",
// Accept = "text/html, application/xhtml+xml, */*",// 可选项有默认值
// ContentType = "application/x-www-form-urlencoded",
// Postdata = "__VIEWSTATE=%2FwEPDwULLTE2NDY3NDYxOTEPFgIeCWF1dGhMZXZlbAIBZGQFDBMiaM5jeSqYOP96II7WoW0oyc%2BSfvVv%2FGIrZ%2FP5bg%3D%3D&__EVENTVALIDATION=%2FwEWAgLO2Kj0DALLr40TnsCiM32qLiMK44G5moITtUwkOOjKlsY5RQB7pzBatDk%3D&user_name=user1&password=88888888&hdSuccess=true",
// Method = "POST",//URL 可选项 默认为Get
// };
// HttpResult resulthtml = http.GetHtml(item);
// var mycookie = resulthtml.Cookie;
// http = new HttpHelper();
// item = new HttpItem()
// {
// URL = "http://cdp.qdcdc.com/CDP/MftQuery/BillExportQuery.aspx",//URL这里都是测试 必需项
// Referer = "http://cdp.qdcdc.com/CDP/MftQuery/BillExportQuery.aspx",
// Encoding = null,//编码格式utf-8,gb2312,gbk 可选项 默认类会自动识别
// Host = "cdp.qdcdc.com",
// Cookie = mycookie,
// UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)",
// Accept = "text/html, application/xhtml+xml, */*",// 可选项有默认值
// ContentType = "application/x-www-form-urlencoded",
// Postdata = "__VIEWSTATE=%2FwEPDwUKLTExMzU1MTk4OGRktjQbcTwrtROJIB0DnKW%2FD24wHlo1MdO2yN13vwaX7GI%3D"
// + "&__EVENTVALIDATION=%2FwEWGAK%2FttbiCQKj%2B6LoDwLooeTACQLu%2F%2Fi7CwLa9PCNDgLp7r6qDgLblJqhCgLV3JG"
// + "HCALkwOjWBQLD2Y%2F%2FAwKYnc6YDwLJ7LFVAuDmrTwCvf3v3AcCluH%2BPgKs37SpCwKqgp2pDQLZ1tnQDQLol%2BuuCQL"
// + "T4ZKcAQKklPGiDwLB043aDwLAkeEVAoba9d8KBTCeVFBSa01eOoxl%2FjKz%2Fc7CpJUHsEtTic89nJEP3hM%3D&txtIMO="
// + "&txtTransportName=&txtVoyageNo=&txtBillNo=" + mblno + "&LinkButtonQuery=%E6%9F%A5%E8%AF%A2&hdSelectRow="
// + "&hdData=&hdCols=%E5%BA%8F%E5%8F%B7%2C%E5%87%BA%E5%8F%A3%E6%8F%90%E5%8D%95%E5%8F%B7%2C%E8%BF%90%E8%BE"
// + "%93%E5%B7%A5%E5%85%B7%E4%BF%A1%E6%81%AF%2C%E6%80%BB%E5%8D%95%2F%E5%88%86%E5%8D%95%2C%E9%A2%84%E9%85%"
// + "8D%E8%88%B1%E5%8D%95%2C%E5%87%BA%E5%8F%A3%E8%BF%90%E6%8A%B5%E6%8A%A5%E5%91%8A%2C%E8%90%BD%E8%B4%A7%E"
// + "6%94%B9%E9%85%8D%E7%8A%B6%E6%80%81%2C%E5%87%BA%E5%8F%A3%E8%A3%85%E8%BD%BD%2C%E5%87%BA%E5%8F%A3%E7%90"
// + "%86%E8%B4%A7%2C%E5%87%BA%E5%8F%A3%E6%8A%A5%E5%85%B3%E7%8A%B6%E6%80%81%2C%E6%8F%90%E5%8D%95%E6%94%BE%"
// + "E8%A1%8C%2C%E8%BD%AC%E5%8F%91%E7%8A%B6%E6%80%81&hdChildHide=&hdColsHide=&hdColSpan=%E6%8F%90%E5%8D%95"
// + "%E5%8F%B7&hdMutiQuery=&hdReturnResult=&hdLoadMarkText=&hdArrivalMarkText=&hdEmptyResult=&hdTalMarkText=&hdBillRelStatus=",
// Method = "POST",//URL 可选项 默认为Get
// };
// resulthtml = http.GetHtml(item);
// resulthtml.Html = resulthtml.Html.Replace("../Css/NewMftQueryStyle.css", "http://56.qdcdc.com/cnm/Css/NewMftQueryStyle.css");
// result.Data = resulthtml.Html;
// var datahtml = GetDataHtmlList(resulthtml.Html, "id=\"tbData\"", "</table>");
// datahtml = datahtml.Remove(datahtml.IndexOf("</tr>"), 5);
// datahtml = datahtml.Remove(0, datahtml.IndexOf(">") + 1);
// if (datahtml != "")
// {
// var i = 1;
// while (datahtml.IndexOf("</tr>") >= 0)
// {
// var datalength = datahtml.IndexOf("</tr>");
// var recdatastr = datahtml.Substring(0, datalength + 5);
// datahtml = datahtml.Substring(datalength + 5, datahtml.Length - datalength - 5);
// recdatastr = recdatastr.Remove(0, recdatastr.IndexOf("<tr") + 3);
// recdatastr = recdatastr.Remove(recdatastr.IndexOf("</tr>"), 5);
// recdatastr = recdatastr.Replace(" ", "");
// recdatastr = recdatastr.Replace("/r/n ", "");
// var fieldno = 1;
// var istrue = false;
// if (i != 1 && i != 2 && (recdatastr.Length > 40))
// {
// MsOpSeaeCustomStatus data = new MsOpSeaeCustomStatus();
// 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(" ", "");
// if (fieldno == 1)
// {
// fielddatastr = fielddatastr.Remove(0, fielddatastr.IndexOf(">") + 1);
// if (fielddatastr == "合计:" || fielddatastr == "<bstyle=\"color:Red\">暂无相关数据</b>") istrue = false; else istrue = true;
// }
// if (fieldno == 11)
// {
// data.PREPAREDSTR = fielddatastr;//箱号
// }
// if (fieldno == 12)
// {
// if (fielddatastr.IndexOf("接受申报") >= 0)
// data.ISPREPARED = true;//箱号
// }
// if (fieldno == 13)
// {
// data.ARRIVALSTR = fielddatastr;//箱号
// }
// if (fieldno == 14)
// {
// if (fielddatastr.IndexOf("运抵正常") >= 0)
// data.ISARRIVAL = true;//箱号
// }
// if (fieldno == 15)
// {
// if (fielddatastr.IndexOf("单证放行") >= 0)
// {
// data.ISCUSTOMCLEAR = true;//箱号
// data.CUSTOMCLEARSTR = fielddatastr.Replace("单证放行", "");
// }
// }
// if (fieldno == 16)
// {
// data.BILLCLEARSTR = fielddatastr;//箱号
// }
// if (fieldno == 17)
// {
// if (fielddatastr.IndexOf("已放行") >= 0)
// data.ISBILLCLEAR = true;//箱号
// }
// if (fieldno == 19)
// {
// data.LOADCLEARSTR = fielddatastr;//箱号
// }
// if (fieldno == 20)
// {
// if (fielddatastr.IndexOf("同意装载") >= 0)
// data.ISLOADCLEAR = true;//箱号
// }
// fieldno = fieldno + 1;
// }
// if (istrue)
// bodyList.Add(data);
// }
// i = i + 1;
// }
// }
// if (bodyList.Count != 0)
// {
// Database db = DatabaseFactory.CreateDatabase();
// using (var conn = db.CreateConnection())
// {
// conn.Open();
// var strSql = new StringBuilder();
// strSql.Append("update op_seae set MANIFESTSTATUS=@MANIFESTSTATUS ");
// strSql.Append(" where BSNO=@BSNO ");
// var cmdupdate =
// db.GetSqlStringCommand(strSql.ToString());
// if (bodyList != null)
// {
// var manifeststatus = bodyList[0];
// if (manifeststatus.ISPREPARED == false)
// {
// }
// else
// {
// var statusref = "无状态";
// var status = "0";
// if (manifeststatus.ISLOADCLEAR)
// {
// status = "5";
// statusref = "装载放行";
// }
// else if (manifeststatus.ISBILLCLEAR)
// {
// status = "4";
// statusref = "提单放行";
// }
// else if (manifeststatus.ISCUSTOMCLEAR)
// {
// status = "3";
// statusref = "报关放行";
// }
// else if (manifeststatus.ISARRIVAL)
// {
// status = "2";
// statusref = "运抵正常";
// }
// else if (manifeststatus.ISPREPARED)
// {
// status = "1";
// statusref = "预配舱单";
// }
// cmdupdate.Parameters.Clear();
// db.AddInParameter(cmdupdate, "@MANIFESTSTATUS", DbType.String, status);
// db.AddInParameter(cmdupdate, "@BSNO", DbType.String, bsno);
// db.ExecuteNonQuery(cmdupdate);
// result.Message = statusref;
// }
// }
// }
// }
// }
// catch
// {
// result.Success = false;
// result.Message = "提取数据过程中发生错误,请联系系统管理员!";
// }
// //result.Data = bodyList.ToList();
// return result;
//}
static public DBResult Get56CDCSTATUSList ( string mblno, string bsno, string path )
{
var result = new DBResult();
result.Success = true;
var bodyList = new List<MsOpSeaeCustomStatus>();
try
{
var filename = path + "\\" + mblno + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".Gif";
HttpHelper http = new HttpHelper();
HttpItem item = new HttpItem()
{
URL = "http://56.qdcdc.com/cnm/MftQuery/BillExportQuery.aspx",//URL这里都是测试 必需项
Referer = "http://56.qdcdc.com/cnm/MftQuery/BillExportQuery.aspx",
Encoding = null,//编码格式utf-8,gb2312,gbk 可选项 默认类会自动识别
Host = "56.qdcdc.com",
UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)",
Accept = "text/html, application/xhtml+xml, */*",// 可选项有默认值
ContentType = "application/x-www-form-urlencoded",
Postdata = "__VIEWSTATE=0%2Fn5%2BwUDXpmFl%2BFsCVpURKPb5zm1AA%2FvEUtQxN1K02VDENqpJ9ravvyGNjEiiY%2BU&"
+ "__EVENTVALIDATION=7uGtbHgy2hzetVvoMh99Kbi8rUuV06n88PcDvmMbdrXld968D3lNSKQdeJCMVZYUemVNqXircWM2NuMc8XOU6W2hrh"
+ "LiKEEh9AORqcthIR%2Bb1JXgLMr9IvVnVt2MjRmJiBsZxs7ZbgLZyGnR1Pk2oYUmPKJThsqyYwG%2FbHA81ZDclrC6arZ96IV7JY0nZGtgt4"
+ "6T77jeOcX8J073kcFVc6BQExZiRs%2BOYX793IZ%2FoBA%3D&txtIMO=&txtTransportName=&txtVoyageNo=&txtBillNo=" + mblno
+ "&LinkButtonQuery=%E6%9F%A5%E8%AF%A2&hdSelectRow=&hdData=&hdCols=%E5%BA%8F%E5%8F%B7%2C%E5%87%BA%E5%8F%A3%E6%8F%90%"
+ "E5%8D%95%E5%8F%B7%2C%E8%BF%90%E8%BE%93%E5%B7%A5%E5%85%B7%E4%BF%A1%E6%81%AF%2C%E6%80%BB%E5%8D%95%2F%E5%88%86%E5%8D%"
+ "95%2C%E9%A2%84%E9%85%8D%E8%88%B1%E5%8D%95%2C%E5%87%BA%E5%8F%A3%E8%BF%90%E6%8A%B5%E6%8A%A5%E5%91%8A%2C%E8%90%BD%E8%"
+ "B4%A7%E6%94%B9%E9%85%8D%E7%8A%B6%E6%80%81%2C%E5%87%BA%E5%8F%A3%E8%A3%85%E8%BD%BD%2C%E5%87%BA%E5%8F%A3%E7%90%86%E8%"
+ "B4%A7%2C%E5%87%BA%E5%8F%A3%E6%8A%A5%E5%85%B3%E7%8A%B6%E6%80%81%2C%E6%8F%90%E5%8D%95%E6%94%BE%E8%A1%8C%2C%E8%BD%AC%"
+ "E5%8F%91%E7%8A%B6%E6%80%81&hdChildHide=&hdColsHide=&hdColSpan=%E6%8F%90%E5%8D%95%E5%8F%B7&hdMutiQuery=&"
+ "hdReturnResult=&hdLoadMarkText=&hdArrivalMarkText=&hdEmptyResult=&hdTalMarkText=&hdBillRelStatus=",
Cookie = "ASP.NET_SessionId=f4vivggkpcitpxrqwvtzmmpz; forums=59088DDE442B9B9FF7985FA130A22DD73763B97C86F960019C4E1AF2C5A05AF0B15C3A0A4EFFBFBC5E0F7873273E6D7BF26A8566ABAC67A0598AC66E75D0934C54BE56E2C6A1F88D496D5385F2894F2E",
Method = "POST",//URL 可选项 默认为Get
};
HttpResult resulthtml = http.GetHtml(item);
var datahtml = resulthtml.Html.Replace("../Css/NewMftQueryStyle.css", "http://56.qdcdc.com/cnm/Css/NewMftQueryStyle.css");
datahtml = datahtml.Replace("../Js/jquery-1.5.2.min.js", "http://56.qdcdc.com/cnm/Js/jquery-1.5.2.min.js");
result.Data = datahtml;
datahtml = GetDataHtmlList(datahtml, "id=\"tbData\"", "</table>");
datahtml = datahtml.Remove(datahtml.IndexOf("</tr>"), 5);
datahtml = datahtml.Remove(0, datahtml.IndexOf(">") + 1);
if (datahtml != "")
{
var i = 1;
while (datahtml.IndexOf("</tr>") >= 0)
{
var datalength = datahtml.IndexOf("</tr>");
var recdatastr = datahtml.Substring(0, datalength + 5);
datahtml = datahtml.Substring(datalength + 5, datahtml.Length - datalength - 5);
recdatastr = recdatastr.Remove(0, recdatastr.IndexOf("<tr") + 3);
recdatastr = recdatastr.Remove(recdatastr.IndexOf("</tr>"), 5);
recdatastr = recdatastr.Replace(" ", "");
recdatastr = recdatastr.Replace("/r/n ", "");
var fieldno = 1;
var istrue = false;
if (i != 1 && i != 2 && (recdatastr.Length > 40))
{
MsOpSeaeCustomStatus data = new MsOpSeaeCustomStatus();
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(" ", "");
if (fieldno == 1)
{
fielddatastr = fielddatastr.Remove(0, fielddatastr.IndexOf(">") + 1);
if (fielddatastr == "合计:" || fielddatastr == "<bstyle=\"color:Red\">暂无相关数据</b>") istrue = false; else istrue = true;
}
if (fieldno == 11)
{
data.PREPAREDSTR = fielddatastr;//箱号
}
if (fieldno == 12)
{
if (fielddatastr.IndexOf("接受申报") >= 0)
data.ISPREPARED = true;//箱号
}
if (fieldno == 13)
{
data.ARRIVALSTR = fielddatastr;//箱号
}
if (fieldno == 14)
{
if (fielddatastr.IndexOf("运抵正常") >= 0)
data.ISARRIVAL = true;//箱号
}
if (fieldno == 15)
{
if (fielddatastr.IndexOf("单证放行") >= 0)
{
data.ISCUSTOMCLEAR = true;//箱号
data.CUSTOMCLEARSTR = fielddatastr.Replace("单证放行", "");
}
}
if (fieldno == 16)
{
data.BILLCLEARSTR = fielddatastr;//箱号
}
if (fieldno == 17)
{
if (fielddatastr.IndexOf("已放行") >= 0)
data.ISBILLCLEAR = true;//箱号
}
if (fieldno == 19)
{
data.LOADCLEARSTR = fielddatastr;//箱号
}
if (fieldno == 20)
{
if (fielddatastr.IndexOf("同意装载") >= 0)
data.ISLOADCLEAR = true;//箱号
}
fieldno = fieldno + 1;
}
if (istrue)
bodyList.Add(data);
}
i = i + 1;
}
}
if (bodyList.Count != 0)
{
Database db = DatabaseFactory.CreateDatabase();
using (var conn = db.CreateConnection())
{
conn.Open();
var strSql = new StringBuilder();
strSql.Append("update op_seae set MANIFESTSTATUS=@MANIFESTSTATUS ");
strSql.Append(" where BSNO=@BSNO ");
var cmdupdate =
db.GetSqlStringCommand(strSql.ToString());
if (bodyList != null)
{
var manifeststatus = bodyList[0];
if (manifeststatus.ISPREPARED == false)
{
}
else
{
var statusref = "无状态";
var status = "0";
if (manifeststatus.ISLOADCLEAR)
{
status = "5";
statusref = "装载放行";
}
else if (manifeststatus.ISBILLCLEAR)
{
status = "4";
statusref = "提单放行";
}
else if (manifeststatus.ISCUSTOMCLEAR)
{
status = "3";
statusref = "报关放行";
}
else if (manifeststatus.ISARRIVAL)
{
status = "2";
statusref = "运抵正常";
}
else if (manifeststatus.ISPREPARED)
{
status = "1";
statusref = "预配舱单";
}
cmdupdate.Parameters.Clear();
db.AddInParameter(cmdupdate, "@MANIFESTSTATUS", DbType.String, status);
db.AddInParameter(cmdupdate, "@BSNO", DbType.String, bsno);
db.ExecuteNonQuery(cmdupdate);
result.Message = statusref;
}
}
}
}
}
catch
{
result.Success = false;
result.Message = "提取数据过程中发生错误,请联系系统管理员!";
}
//result.Data = bodyList.ToList();
return result;
}
static public DBResult Get56CDCSTATUSListProcess ( string mblno, string bsno )
{
var result = new DBResult();
result.Success = true;
var bodyList = new List<MsOpSeaeCustomStatus>();
var createhtml = "<head> <style type=\"text/css\"> .shipmentContain{/**/left:160px;top:9px;width:825px;/*height:22px;*/position:absolute;z-index:1000;/*background-color:#CCC;*/} "
+ ".shipmentContainIdentify{float:left;margin-top:0px;padding-top:8px;padding-left:3px;display:block;width:150px;height:22px;position:absolute;font-size:12px;color:#111;font-family:\"微软雅黑\";left: -3px;top: 9px;}"
+ ".shipmentContain div{width:825px;min-width:815px;height:22px;line-height:22px;margin:0 auto;padding:0px;}"
+ ".shipmentContainContain ul{width:815px;min-width:815px;height:22px;line-height:22px;margin:0 auto;padding:0px;float:left;list-style:none; /*display:block;*/} "
+ ".shipmentContainContain li.frtNode{float:left;margin-top:0px;padding-top:0px;padding-left:0px;display:block;width:25px;height:22px;display:inline-block;}"
+ ".shipmentContainContain li.nextNode{float:left;margin-top:0px;padding-top:0px;padding-left:0px;display:block;width:99px;height:22px;display:inline-block;}"
+ ".shipmentContainContain li.lastNode{float:left;margin-top:0px;padding-top:0px;padding-left:0px;display:block;width:99px;height:22px;display:inline-block;}"
+ ".shipmentContainTextContain span{display:inline-block;/*padding-top:25px;*/font-family:\"Agency FB\";color:#f39700;font-size:12px;position:absolute;top: 34px;}"
+ "</style> </head> ";
try
{
HttpHelper http = new HttpHelper();
HttpItem item = new HttpItem()
{
URL = "http://56.qdcdc.com/cnm/Login.aspx",//URL这里都是测试 必需项
Referer = "http://56.qdcdc.com/cnm/Login.aspx",
Encoding = null,//编码格式utf-8,gb2312,gbk 可选项 默认类会自动识别
Host = "56.qdcdc.com",
UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)",
Accept = "text/html, application/xhtml+xml, */*",// 可选项有默认值
ContentType = "application/x-www-form-urlencoded",
Postdata = "__VIEWSTATE=%2FwEPDwULLTE2NDY3NDYxOTEPFgIeCWF1dGhMZXZlbAIBZGRaqF4SR76vRpKX1Ncvq5it959sl24P"
+ "78o8lgFjhBEoow%3D%3D&__EVENTVALIDATION=%2FwEWAgKunaPBDQLLr40TAUOVolCpWuq5jMb12TE1wUQRzvpzmgO1bc1UtxtDpwk"
+ "%3D&user_name=sdeport&password=66666666&hdSuccess=true",
Method = "POST",//URL 可选项 默认为Get
};
HttpResult resulthtml = http.GetHtml(item);
var mycookie = resulthtml.Cookie;
http = new HttpHelper();
item = new HttpItem()
{
URL = "http://56.qdcdc.com/cnm/MftQuery/BillExportQuery.aspx",//URL这里都是测试 必需项
Referer = "http://56.qdcdc.com/cnm/MftQuery/BillExportQuery.aspx",
Encoding = null,//编码格式utf-8,gb2312,gbk 可选项 默认类会自动识别
Host = "56.qdcdc.com",
Cookie = mycookie,
UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)",
Accept = "text/html, application/xhtml+xml, */*",// 可选项有默认值
ContentType = "application/x-www-form-urlencoded",
Postdata = "__VIEWSTATE=%2FwEPDwUKLTExMzU1MTk4OGRkYAPyyS9HywlEejLmSF9LqKHC8bhlsXVaERiHd97bYiQ%3D&__EVENTVALIDATION="
+ "%2FwEWGAKAldnyBQKj%2B6LoDwLooeTACQLu%2F%2Fi7CwLa9PCNDgLp7r6qDgLblJqhCgLV3JGHCALkwOjWBQLD2Y%2F%2FAwKYnc6YDwLJ7LFV"
+ "AuDmrTwCvf3v3AcCluH%2BPgKs37SpCwKqgp2pDQLZ1tnQDQLol%2BuuCQLT4ZKcAQKklPGiDwLB043aDwLAkeEVAoba9d8K1lBFpQ8mNZ5Dlfij"
+ "IZBQ1bS1RwCIiTyskE9Nc3kpr8k%3D&txtIMO=&txtTransportName=&txtVoyageNo=&txtBillNo=" + mblno + "&LinkButtonQuery=%E6"
+ "%9F%A5%E8%AF%A2&hdSelectRow=&hdData=&hdCols=%E5%BA%8F%E5%8F%B7%2C%E5%87%BA%E5%8F%A3%E6%8F%90%E5%8D%95%E5%8F%B7%2C"
+ "%E8%BF%90%E8%BE%93%E5%B7%A5%E5%85%B7%E4%BF%A1%E6%81%AF%2C%E6%80%BB%E5%8D%95%2F%E5%88%86%E5%8D%95%2C%E9%A2%84%E9%85"
+ "%8D%E8%88%B1%E5%8D%95%2C%E5%87%BA%E5%8F%A3%E8%BF%90%E6%8A%B5%E6%8A%A5%E5%91%8A%2C%E8%90%BD%E8%B4%A7%E6%94%B9%E9%85"
+ "%8D%E7%8A%B6%E6%80%81%2C%E5%87%BA%E5%8F%A3%E8%A3%85%E8%BD%BD%2C%E5%87%BA%E5%8F%A3%E7%90%86%E8%B4%A7%2C%E5%87%BA%E5"
+ "%8F%A3%E6%8A%A5%E5%85%B3%E7%8A%B6%E6%80%81%2C%E6%8F%90%E5%8D%95%E6%94%BE%E8%A1%8C%2C%E8%BD%AC%E5%8F%91%E7%8A%B6%E6"
+ "%80%81&hdChildHide=&hdColsHide=&hdColSpan=%E6%8F%90%E5%8D%95%E5%8F%B7&hdMutiQuery=&hdReturnResult=&hdLoadMarkText"
+ "=&hdArrivalMarkText=&hdEmptyResult=&hdTalMarkText=&hdBillRelStatus=",
Method = "POST",//URL 可选项 默认为Get
};
resulthtml = http.GetHtml(item);
resulthtml.Html = resulthtml.Html.Replace("../Css/NewMftQueryStyle.css", "http://56.qdcdc.com/cnm/Css/NewMftQueryStyle.css");
var datahtml = GetDataHtmlList(resulthtml.Html, "id=\"tbData\"", "</table>");
datahtml = datahtml.Remove(datahtml.IndexOf("</tr>"), 5);
datahtml = datahtml.Remove(0, datahtml.IndexOf(">") + 1);
if (datahtml != "")
{
var i = 1;
while (datahtml.IndexOf("</tr>") >= 0)
{
var datalength = datahtml.IndexOf("</tr>");
var recdatastr = datahtml.Substring(0, datalength + 5);
datahtml = datahtml.Substring(datalength + 5, datahtml.Length - datalength - 5);
recdatastr = recdatastr.Remove(0, recdatastr.IndexOf("<tr") + 3);
recdatastr = recdatastr.Remove(recdatastr.IndexOf("</tr>"), 5);
recdatastr = recdatastr.Replace(" ", "");
recdatastr = recdatastr.Replace("/r/n ", "");
var fieldno = 1;
var istrue = false;
if (i != 1 && i != 2 && (recdatastr.Length > 40))
{
MsOpSeaeCustomStatus data = new MsOpSeaeCustomStatus();
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(" ", "");
if (fieldno == 1)
{
fielddatastr = fielddatastr.Remove(0, fielddatastr.IndexOf(">") + 1);
if (fielddatastr == "合计:" || fielddatastr == "<bstyle=\"color:Red\">暂无相关数据</b>") istrue = false; else istrue = true;
}
if (fieldno == 11)
{
data.PREPAREDSTR = fielddatastr;//箱号
}
if (fieldno == 12)
{
if (fielddatastr.IndexOf("接受申报") >= 0)
data.ISPREPARED = true;//箱号
}
if (fieldno == 13)
{
data.ARRIVALSTR = fielddatastr;//箱号
}
if (fieldno == 14)
{
if (fielddatastr.IndexOf("运抵正常") >= 0)
data.ISARRIVAL = true;//箱号
}
if (fieldno == 15)
{
if (fielddatastr.IndexOf("单证放行") >= 0)
{
data.ISCUSTOMCLEAR = true;//箱号
data.CUSTOMCLEARSTR = fielddatastr.Replace("单证放行", "");
}
}
if (fieldno == 16)
{
data.BILLCLEARSTR = fielddatastr;//箱号
}
if (fieldno == 17)
{
if (fielddatastr.IndexOf("已放行") >= 0)
data.ISBILLCLEAR = true;//箱号
}
if (fieldno == 19)
{
data.LOADCLEARSTR = fielddatastr;//箱号
}
if (fieldno == 20)
{
if (fielddatastr.IndexOf("同意装载") >= 0)
data.ISLOADCLEAR = true;//箱号
}
fieldno = fieldno + 1;
}
if (istrue)
bodyList.Add(data);
}
i = i + 1;
}
}
if (bodyList.Count != 0)
{
Database db = DatabaseFactory.CreateDatabase();
using (var conn = db.CreateConnection())
{
conn.Open();
var strSql = new StringBuilder();
strSql.Append("update op_seae set MANIFESTSTATUS=@MANIFESTSTATUS ");
strSql.Append(" where BSNO=@BSNO ");
var cmdupdate =
db.GetSqlStringCommand(strSql.ToString());
if (bodyList != null)
{
var manifeststatus = bodyList[0];
if (manifeststatus.ISPREPARED == false)
{
}
else
{
var statusref = "无状态";
var status = "0";
if (manifeststatus.ISLOADCLEAR)
{
status = "5";
statusref = "装载放行";
createhtml = "<div class=\"shipmentContainIdentify\"><span style=\"padding-left:3px;width:127px;display:block;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;\"></span></div>";
createhtml += "<div class=\"shipmentContain\">";
createhtml += "<div>";
createhtml += "<span class=\"frtNode\"><img src=\"../../images/frtNodeBlue.jpg\" width=\"25\" height=\"22\" /></span>";
createhtml += "<span style=\"display:inline-block;width:99px;height:22px;\"><img src=\"../../images/nextNodeBlue.jpg\" width=\"99\" height=\"22\" /></span>";
createhtml += "<span style=\"display:inline-block;width:99px;height:22px;\"><img src=\"../../images/nextNodeBlue.jpg\" width=\"99\" height=\"22\" /></span>";
createhtml += "<span style=\"display:inline-block;width:99px;height:22px;\"><img src=\"../../images/nextNodeBlue.jpg\" width=\"99\" height=\"22\" /></span>";
createhtml += "<span style=\"display:inline-block;width:99px;height:22px;\"><img src=\"../../images/nextNodeBlue.jpg\" width=\"99\" height=\"22\" /></span>";
createhtml += "<span style=\"display:inline-block;width:99px;height:22px;\"><img src=\"../../images/nextNodeBlue.jpg\" width=\"99\" height=\"22\" /></span>";
createhtml += "<span style=\"display:inline-block;width:99px;height:22px;\"><img src=\"../../images/lastNodeBlue.jpg\" width=\"99\" height=\"22\" /></span>";
createhtml += "</div>";
createhtml += "</div>";
createhtml += "<div class=\"shipmentContainTextContain\">";
createhtml += "<span style=\"padding-left:135px;\">预配舱单</span>";
createhtml += "<span style=\"padding-left:235px;\">运抵正常</span>";
createhtml += "<span style=\"padding-left:335px;\">报关放行</span>";
createhtml += "<span style=\"padding-left:435px;\">提单放行</span>";
createhtml += "<span style=\"padding-left:535px;\">装载放行</span>";
createhtml += "<span style=\"padding-left:632px;\">&nbsp;</span>";
createhtml += "<span style=\"padding-left:730px;\">&nbsp;</span>";
createhtml += "</div>";
}
else if (manifeststatus.ISBILLCLEAR)
{
status = "4";
statusref = "提单放行";
createhtml = "<div class=\"shipmentContainIdentify\"><span style=\"padding-left:3px;width:127px;display:block;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;\"></span></div>";
createhtml += "<div class=\"shipmentContain\">";
createhtml += "<div>";
createhtml += "<span class=\"frtNode\"><img src=\"../../images/frtNodeBlue.jpg\" width=\"25\" height=\"22\" /></span>";
createhtml += "<span style=\"display:inline-block;width:99px;height:22px;\"><img src=\"../../images/nextNodeBlue.jpg\" width=\"99\" height=\"22\" /></span>";
createhtml += "<span style=\"display:inline-block;width:99px;height:22px;\"><img src=\"../../images/nextNodeBlue.jpg\" width=\"99\" height=\"22\" /></span>";
createhtml += "<span style=\"display:inline-block;width:99px;height:22px;\"><img src=\"../../images/nextNodeBlue.jpg\" width=\"99\" height=\"22\" /></span>";
createhtml += "<span style=\"display:inline-block;width:99px;height:22px;\"><img src=\"../../images/nextNodeBlue.jpg\" width=\"99\" height=\"22\" /></span>";
createhtml += "<span style=\"display:inline-block;width:99px;height:22px;\"><img src=\"../../images/nextNodeEnd.jpg\" width=\"99\" height=\"22\" /></span>";
createhtml += "<span style=\"display:inline-block;width:99px;height:22px;\"><img src=\"../../images/lastNodeGray.jpg\" width=\"99\" height=\"22\" /></span>";
createhtml += "</div>";
createhtml += "</div>";
createhtml += "<div class=\"shipmentContainTextContain\">";
createhtml += "<span style=\"padding-left:135px;\">预配舱单</span>";
createhtml += "<span style=\"padding-left:235px;\">运抵正常</span>";
createhtml += "<span style=\"padding-left:335px;\">报关放行</span>";
createhtml += "<span style=\"padding-left:435px;\">提单放行</span>";
createhtml += "<span style=\"padding-left:535px;\">装载放行</span>";
createhtml += "<span style=\"padding-left:632px;\">&nbsp;</span>";
createhtml += "<span style=\"padding-left:730px;\">&nbsp;</span>";
createhtml += "</div>";
}
else if (manifeststatus.ISCUSTOMCLEAR)
{
status = "3";
statusref = "报关放行";
createhtml = "<div class=\"shipmentContainIdentify\"><span style=\"padding-left:3px;width:127px;display:block;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;\"></span></div>";
createhtml += "<div class=\"shipmentContain\">";
createhtml += "<div>";
createhtml += "<span class=\"frtNode\"><img src=\"../../images/frtNodeBlue.jpg\" width=\"25\" height=\"22\" /></span>";
createhtml += "<span style=\"display:inline-block;width:99px;height:22px;\"><img src=\"../../images/nextNodeBlue.jpg\" width=\"99\" height=\"22\" /></span>";
createhtml += "<span style=\"display:inline-block;width:99px;height:22px;\"><img src=\"../../images/nextNodeBlue.jpg\" width=\"99\" height=\"22\" /></span>";
createhtml += "<span style=\"display:inline-block;width:99px;height:22px;\"><img src=\"../../images/nextNodeBlue.jpg\" width=\"99\" height=\"22\" /></span>";
createhtml += "<span style=\"display:inline-block;width:99px;height:22px;\"><img src=\"../../images/nextNodeEnd.jpg\" width=\"99\" height=\"22\" /></span>";
createhtml += "<span style=\"display:inline-block;width:99px;height:22px;\"><img src=\"../../images/nextNodeGray.jpg\" width=\"99\" height=\"22\" /></span>";
createhtml += "<span style=\"display:inline-block;width:99px;height:22px;\"><img src=\"../../images/lastNodeGray.jpg\" width=\"99\" height=\"22\" /></span>";
createhtml += "</div>";
createhtml += "</div>";
createhtml += "<div class=\"shipmentContainTextContain\">";
createhtml += "<span style=\"padding-left:135px;\">预配舱单</span>";
createhtml += "<span style=\"padding-left:235px;\">运抵正常</span>";
createhtml += "<span style=\"padding-left:335px;\">报关放行</span>";
createhtml += "<span style=\"padding-left:435px;\">提单放行</span>";
createhtml += "<span style=\"padding-left:535px;\">装载放行</span>";
createhtml += "<span style=\"padding-left:632px;\">&nbsp;</span>";
createhtml += "<span style=\"padding-left:730px;\">&nbsp;</span>";
createhtml += "</div>";
}
else if (manifeststatus.ISARRIVAL)
{
status = "2";
statusref = "运抵正常";
createhtml = "<div class=\"shipmentContainIdentify\"><span style=\"padding-left:3px;width:127px;display:block;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;\"></span></div>";
createhtml += "<div class=\"shipmentContain\">";
createhtml += "<div>";
createhtml += "<span class=\"frtNode\"><img src=\"../../images/frtNodeBlue.jpg\" width=\"25\" height=\"22\" /></span>";
createhtml += "<span style=\"display:inline-block;width:99px;height:22px;\"><img src=\"../../images/nextNodeBlue.jpg\" width=\"99\" height=\"22\" /></span>";
createhtml += "<span style=\"display:inline-block;width:99px;height:22px;\"><img src=\"../../images/nextNodeEnd.jpg\" width=\"99\" height=\"22\" /></span>";
createhtml += "<span style=\"display:inline-block;width:99px;height:22px;\"><img src=\"../../images/nextNodeGray.jpg\" width=\"99\" height=\"22\" /></span>";
createhtml += "<span style=\"display:inline-block;width:99px;height:22px;\"><img src=\"../../images/nextNodeGray.jpg\" width=\"99\" height=\"22\" /></span>";
createhtml += "<span style=\"display:inline-block;width:99px;height:22px;\"><img src=\"../../images/nextNodeGray.jpg\" width=\"99\" height=\"22\" /></span>";
createhtml += "<span style=\"display:inline-block;width:99px;height:22px;\"><img src=\"../../images/lastNodeGray.jpg\" width=\"99\" height=\"22\" /></span>";
createhtml += "</div>";
createhtml += "</div>";
createhtml += "<div class=\"shipmentContainTextContain\">";
createhtml += "<span style=\"padding-left:135px;\">预配舱单</span>";
createhtml += "<span style=\"padding-left:235px;\">运抵正常</span>";
createhtml += "<span style=\"padding-left:335px;\">报关放行</span>";
createhtml += "<span style=\"padding-left:435px;\">提单放行</span>";
createhtml += "<span style=\"padding-left:535px;\">装载放行</span>";
createhtml += "<span style=\"padding-left:632px;\">&nbsp;</span>";
createhtml += "<span style=\"padding-left:730px;\">&nbsp;</span>";
createhtml += "</div>";
}
else if (manifeststatus.ISPREPARED)
{
status = "1";
statusref = "预配舱单";
createhtml = "<div class=\"shipmentContainIdentify\"><span style=\"padding-left:3px;width:127px;display:block;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;\"></span></div>";
createhtml += "<div class=\"shipmentContain\">";
createhtml += "<div>";
createhtml += "<span class=\"frtNode\"><img src=\"../../images/frtNodeBlue.jpg\" width=\"25\" height=\"22\" /></span>";
createhtml += "<span style=\"display:inline-block;width:99px;height:22px;\"><img src=\"../../images/nextNodeEnd.jpg\" width=\"99\" height=\"22\" /></span>";
createhtml += "<span style=\"display:inline-block;width:99px;height:22px;\"><img src=\"../../images/nextNodeGray.jpg\" width=\"99\" height=\"22\" /></span>";
createhtml += "<span style=\"display:inline-block;width:99px;height:22px;\"><img src=\"../../images/nextNodeGray.jpg\" width=\"99\" height=\"22\" /></span>";
createhtml += "<span style=\"display:inline-block;width:99px;height:22px;\"><img src=\"../../images/nextNodeGray.jpg\" width=\"99\" height=\"22\" /></span>";
createhtml += "<span style=\"display:inline-block;width:99px;height:22px;\"><img src=\"../../images/nextNodeGray.jpg\" width=\"99\" height=\"22\" /></span>";
createhtml += "<span style=\"display:inline-block;width:99px;height:22px;\"><img src=\"../../images/lastNodeGray.jpg\" width=\"99\" height=\"22\" /></span>";
createhtml += "</div>";
createhtml += "</div>";
createhtml += "<div class=\"shipmentContainTextContain\">";
createhtml += "<span style=\"padding-left:135px;\">预配舱单</span>";
createhtml += "<span style=\"padding-left:235px;\">运抵正常</span>";
createhtml += "<span style=\"padding-left:335px;\">报关放行</span>";
createhtml += "<span style=\"padding-left:435px;\">提单放行</span>";
createhtml += "<span style=\"padding-left:535px;\">装载放行</span>";
createhtml += "<span style=\"padding-left:632px;\">&nbsp;</span>";
createhtml += "<span style=\"padding-left:730px;\">&nbsp;</span>";
createhtml += "</div>";
}
else
{
createhtml = "<div class=\"shipmentContainIdentify\"><span style=\"padding-left:3px;width:127px;display:block;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;\"></span></div>";
createhtml += "<div class=\"shipmentContain\">";
createhtml += "<div>";
createhtml += "<span style=\"display:inline-block;width:25px;height:22px;\"><img src=\"../../images/frtNodeOnly.jpg\" width=\"25\" height=\"22\" /></span>";
createhtml += "<span style=\"display:inline-block;width:99px;height:22px;\"><img src=\"../../images/nextNodeGray.jpg\" width=\"99\" height=\"22\" /></span>";
createhtml += "<span style=\"display:inline-block;width:99px;height:22px;\"><img src=\"../../images/nextNodeGray.jpg\" width=\"99\" height=\"22\" /></span>";
createhtml += "<span style=\"display:inline-block;width:99px;height:22px;\"><img src=\"../../images/nextNodeGray.jpg\" width=\"99\" height=\"22\" /></span>";
createhtml += "<span style=\"display:inline-block;width:99px;height:22px;\"><img src=\"../../images/nextNodeGray.jpg\" width=\"99\" height=\"22\" /></span>";
createhtml += "<span style=\"display:inline-block;width:99px;height:22px;\"><img src=\"../../images/nextNodeGray.jpg\" width=\"99\" height=\"22\" /></span>";
createhtml += "<span style=\"display:inline-block;width:99px;height:22px;\"><img src=\"../../images/lastNodeGray.jpg\" width=\"99\" height=\"22\" /></span>";
createhtml += "</div>";
createhtml += "</div>";
createhtml += "<div class=\"shipmentContainTextContain\">";
createhtml += "<span style=\"padding-left:135px;\">预配舱单</span>";
createhtml += "<span style=\"padding-left:235px;\">运抵正常</span>";
createhtml += "<span style=\"padding-left:335px;\">报关放行</span>";
createhtml += "<span style=\"padding-left:435px;\">提单放行</span>";
createhtml += "<span style=\"padding-left:535px;\">装载放行</span>";
createhtml += "<span style=\"padding-left:632px;\">&nbsp;</span>";
createhtml += "<span style=\"padding-left:730px;\">&nbsp;</span>";
createhtml += "</div>";
}
cmdupdate.Parameters.Clear();
db.AddInParameter(cmdupdate, "@MANIFESTSTATUS", DbType.String, status);
db.AddInParameter(cmdupdate, "@BSNO", DbType.String, bsno);
db.ExecuteNonQuery(cmdupdate);
result.Data = createhtml;
result.Message = statusref;
}
}
}
}
}
catch
{
result.Success = false;
result.Message = "提取数据过程中发生错误,请联系系统管理员!";
}
//if (bodyList.Count > 0)
// result.Data=bodyList[0];
//result.Data=new MsOpSeaeCustomStatus();
return result;
}
#region 更新舱单状态
public static DBResult RefreshManifestStatus(List<MsOpSeae> bodyList)
{
var result = new DBResult();
Database db = DatabaseFactory.CreateDatabase();
using (var conn = db.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
var strSql = new StringBuilder();
strSql.Append("update op_seae set MANIFESTSTATUS=@MANIFESTSTATUS ");
strSql.Append(" where BSNO=@BSNO ");
var cmdupdate =
db.GetSqlStringCommand(strSql.ToString());
if (bodyList != null)
{
foreach (var enumValue in bodyList)
{
var manifeststatus = GetManifestSTATUSList(enumValue.MBLNO, enumValue.BSNO);
if (manifeststatus.ISPREPARED == false)
{
}
else
{
var status = "0";
if (manifeststatus.ISLOADCLEAR)
{
status = "5";
}
else if (manifeststatus.ISBILLCLEAR)
{
status = "4";
}
else if (manifeststatus.ISCUSTOMCLEAR)
{
status = "3";
}
else if (manifeststatus.ISARRIVAL)
{
status = "2";
}
else if (manifeststatus.ISPREPARED)
{
status = "1";
}
cmdupdate.Parameters.Clear();
db.AddInParameter(cmdupdate, "@MANIFESTSTATUS", DbType.String, status);
db.AddInParameter(cmdupdate, "@BSNO", DbType.String, enumValue.BSNO);
db.ExecuteNonQuery(cmdupdate, tran);
}
}
}
tran.Commit();
}
catch (Exception)
{
tran.Rollback();
result.Success = false;
result.Message = "更新出现错误,请重试或联系系统管理员";
return result;
}
}
result.Success = true;
result.Message = "更新成功" + result.Message;
return result;
}
static public MsOpSeaeCustomStatus GetManifestSTATUSList ( string mblno, string bsno )
{
var bodyList = new List<MsOpSeaeCustomStatus>();
try
{
HttpHelper http = new HttpHelper();
HttpItem item = new HttpItem()
{
URL = "http://cdp.qdcdc.com/CDP/Login.aspx",//URL这里都是测试 必需项
Referer = "http://cdp.qdcdc.com/CDP/Login.aspx",
Encoding = null,//编码格式utf-8,gb2312,gbk 可选项 默认类会自动识别
Host = "56.qdcdc.com",
UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)",
Accept = "text/html, application/xhtml+xml, */*",// 可选项有默认值
ContentType = "application/x-www-form-urlencoded",
Postdata = "__VIEWSTATE=%2FwEPDwULLTE2NDY3NDYxOTEPFgIeCWF1dGhMZXZlbAIBZGQFDBMiaM5jeSqYOP96II7WoW0oyc%2BSfvVv%2FGIrZ%2FP5bg%3D%3D&__EVENTVALIDATION=%2FwEWAgLO2Kj0DALLr40TnsCiM32qLiMK44G5moITtUwkOOjKlsY5RQB7pzBatDk%3D&user_name=user1&password=88888888&hdSuccess=true",
Method = "POST",//URL 可选项 默认为Get
};
HttpResult resulthtml = http.GetHtml(item);
var mycookie = resulthtml.Cookie;
http = new HttpHelper();
item = new HttpItem()
{
URL = "http://cdp.qdcdc.com/CDP/MftQuery/BillExportQuery.aspx",//URL这里都是测试 必需项
Referer = "http://cdp.qdcdc.com/CDP/MftQuery/BillExportQuery.aspx",
Encoding = null,//编码格式utf-8,gb2312,gbk 可选项 默认类会自动识别
Host = "cdp.qdcdc.com",
Cookie = mycookie,
UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)",
Accept = "text/html, application/xhtml+xml, */*",// 可选项有默认值
ContentType = "application/x-www-form-urlencoded",
Postdata = "__VIEWSTATE=%2FwEPDwUKLTExMzU1MTk4OGRktjQbcTwrtROJIB0DnKW%2FD24wHlo1MdO2yN13vwaX7GI%3D"
+ "&__EVENTVALIDATION=%2FwEWGAK%2FttbiCQKj%2B6LoDwLooeTACQLu%2F%2Fi7CwLa9PCNDgLp7r6qDgLblJqhCgLV3JG"
+ "HCALkwOjWBQLD2Y%2F%2FAwKYnc6YDwLJ7LFVAuDmrTwCvf3v3AcCluH%2BPgKs37SpCwKqgp2pDQLZ1tnQDQLol%2BuuCQL"
+ "T4ZKcAQKklPGiDwLB043aDwLAkeEVAoba9d8KBTCeVFBSa01eOoxl%2FjKz%2Fc7CpJUHsEtTic89nJEP3hM%3D&txtIMO="
+ "&txtTransportName=&txtVoyageNo=&txtBillNo=" + mblno + "&LinkButtonQuery=%E6%9F%A5%E8%AF%A2&hdSelectRow="
+ "&hdData=&hdCols=%E5%BA%8F%E5%8F%B7%2C%E5%87%BA%E5%8F%A3%E6%8F%90%E5%8D%95%E5%8F%B7%2C%E8%BF%90%E8%BE"
+ "%93%E5%B7%A5%E5%85%B7%E4%BF%A1%E6%81%AF%2C%E6%80%BB%E5%8D%95%2F%E5%88%86%E5%8D%95%2C%E9%A2%84%E9%85%"
+ "8D%E8%88%B1%E5%8D%95%2C%E5%87%BA%E5%8F%A3%E8%BF%90%E6%8A%B5%E6%8A%A5%E5%91%8A%2C%E8%90%BD%E8%B4%A7%E"
+ "6%94%B9%E9%85%8D%E7%8A%B6%E6%80%81%2C%E5%87%BA%E5%8F%A3%E8%A3%85%E8%BD%BD%2C%E5%87%BA%E5%8F%A3%E7%90"
+ "%86%E8%B4%A7%2C%E5%87%BA%E5%8F%A3%E6%8A%A5%E5%85%B3%E7%8A%B6%E6%80%81%2C%E6%8F%90%E5%8D%95%E6%94%BE%"
+ "E8%A1%8C%2C%E8%BD%AC%E5%8F%91%E7%8A%B6%E6%80%81&hdChildHide=&hdColsHide=&hdColSpan=%E6%8F%90%E5%8D%95"
+ "%E5%8F%B7&hdMutiQuery=&hdReturnResult=&hdLoadMarkText=&hdArrivalMarkText=&hdEmptyResult=&hdTalMarkText=&hdBillRelStatus=",
Method = "POST",//URL 可选项 默认为Get
};
resulthtml = http.GetHtml(item);
var datahtml = GetDataHtmlList(resulthtml.Html, "id=\"tbData\"", "</table>");
datahtml = datahtml.Remove(datahtml.IndexOf("</tr>"), 5);
datahtml = datahtml.Remove(0, datahtml.IndexOf(">") + 1);
if (datahtml != "")
{
var i = 1;
while (datahtml.IndexOf("</tr>") >= 0)
{
var datalength = datahtml.IndexOf("</tr>");
var recdatastr = datahtml.Substring(0, datalength + 5);
datahtml = datahtml.Substring(datalength + 5, datahtml.Length - datalength - 5);
recdatastr = recdatastr.Remove(0, recdatastr.IndexOf("<tr") + 3);
recdatastr = recdatastr.Remove(recdatastr.IndexOf("</tr>"), 5);
recdatastr = recdatastr.Replace(" ", "");
recdatastr = recdatastr.Replace("/r/n ", "");
var fieldno = 1;
var istrue = false;
if (i != 1 && i != 2 && (recdatastr.Length > 40))
{
MsOpSeaeCustomStatus data = new MsOpSeaeCustomStatus();
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(" ", "");
if (fieldno == 1)
{
fielddatastr = fielddatastr.Remove(0, fielddatastr.IndexOf(">") + 1);
if (fielddatastr == "合计:" || fielddatastr == "<bstyle=\"color:Red\">暂无相关数据</b>") istrue = false; else istrue = true;
}
if (fieldno == 11)
{
data.PREPAREDSTR = fielddatastr;//箱号
}
if (fieldno == 12)
{
if (fielddatastr.IndexOf("接受申报") >= 0)
data.ISPREPARED = true;//箱号
}
if (fieldno == 13)
{
data.ARRIVALSTR = fielddatastr;//箱号
}
if (fieldno == 14)
{
if (fielddatastr.IndexOf("运抵正常") >= 0)
data.ISARRIVAL = true;//箱号
}
if (fieldno == 15)
{
if (fielddatastr.IndexOf("单证放行") >= 0)
{
data.ISCUSTOMCLEAR = true;//箱号
data.CUSTOMCLEARSTR = fielddatastr.Replace("单证放行", "");
}
}
if (fieldno == 16)
{
data.BILLCLEARSTR = fielddatastr;//箱号
}
if (fieldno == 17)
{
if (fielddatastr.IndexOf("已放行") >= 0)
data.ISBILLCLEAR = true;//箱号
}
if (fieldno == 19)
{
data.LOADCLEARSTR = fielddatastr;//箱号
}
if (fieldno == 20)
{
if (fielddatastr.IndexOf("同意装载") >= 0)
data.ISLOADCLEAR = true;//箱号
}
fieldno = fieldno + 1;
}
if (istrue)
bodyList.Add(data);
}
i = i + 1;
}
}
}
catch
{
}
if (bodyList.Count > 0)
return bodyList[0];
return new MsOpSeaeCustomStatus();
}
#endregion
#endregion
}
}