Пример #1
0
        public static void UploadCarrierArrived(C2LP.Assistant.TMSConsole.Model.NodeUpload.MESSAGEDETAIL.DETAIL arriedNodeDetail, string VEHICLENO)
        {
            DateTime dtNow = DateTime.Now;
            //string msg = dtNow.ToString() + ":【签收节点】 ";
            string        xmlResult = string.Empty;
            StringBuilder param     = new StringBuilder();

            try
            {
                Model.NodeUpload.SignOrder.XML    details = new Model.NodeUpload.SignOrder.XML();
                Model.NodeUpload.SignOrder.DETAIL d       = new Model.NodeUpload.SignOrder.DETAIL();
                d.SHIPMENTCODE = GetShipmentCode(arriedNodeDetail.LEGNO);
                Console.WriteLine("SHIPMENTCODE:" + d.SHIPMENTCODE);
                d.CECNO             = arriedNodeDetail.CECNO;
                d.LEGCODE           = arriedNodeDetail.LEGNO;
                d.SHIPDETAILID      = arriedNodeDetail.ECNO;
                d.SIGNTIME          = arriedNodeDetail.TRACKTIME;
                d.VEHICLENO         = VEHICLENO;
                d.SIGNPERSON        = arriedNodeDetail.TRACKPERSON;
                details.CONTENTLIST = new List <Model.NodeUpload.SignOrder.CONTENT>();
                details.CONTENTLIST.Add(new Model.NodeUpload.SignOrder.CONTENT());
                details.CONTENTLIST[0].DETAILLIST = new List <Model.NodeUpload.SignOrder.DETAIL>();
                details.CONTENTLIST[0].DETAILLIST.Add(d);
                _ArrivedXML.MESSAGEHEAD.SENDTIME = dtNow.ToString("yyyy-MM-dd HH:mm:ss");
                _ArrivedXML.MESSAGEHEAD.FILENAME = dtNow.ToString("yyyyMMddHHmmss");
                _ArrivedXML.MESSAGEDETAIL        = "<![CDATA[" + Utility.ParseXMLToString <Model.NodeUpload.SignOrder.XML>(details) + "]]>";
                string xmlRequest = Utility.ParseXMLToString <Model.NodeUpload.XML>(_ArrivedXML).Replace("<", "&lt;").Replace(">", "&gt;");
                param.Append("<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ser=\"http://service.webservice.vtradex.com\" > ");
                param.Append("<soapenv:Header/>");
                param.Append("<soapenv:Body>");
                param.Append("<ser:tmsShipmentQianshouXml>" + xmlRequest + "</ser:tmsShipmentQianshouXml>");
                param.Append("</soapenv:Body>");
                param.Append("</soapenv:Envelope>");
                xmlResult = HTTPHelper.SendHTTPRequest(param.ToString(), "setTmsShipmentQianshou", "tmsShipmentQianshouXml");
                Model.NodeUpload.XML uploadResult = Utility.ParseXMLToObjec <Model.NodeUpload.XML>(xmlResult);
                if (uploadResult.MSGCODE == "0" || string.IsNullOrEmpty(uploadResult.MSGCODE))
                {
                    throw new Exception(" 签收节点上报失败SHIPMENTCODE=" + d.SHIPMENTCODE + "" + " " + uploadResult.MSGCONTENT);
                }
            }
            catch (Exception ex)
            {
                Utility.SaveErrLog(ex.Message, "Arrived");
                throw ex;
            }
            finally
            {
                Utility.SaveXMLRequestAndRespond(param.ToString(), xmlResult, "Arrived", arriedNodeDetail.CECNO + "_" + arriedNodeDetail.LEGNO + "_" + arriedNodeDetail.ECNO);
            }
        }
Пример #2
0
        /// <summary>
        /// 暂时忽略掉的关系
        /// </summary>
        //private List<int> _ignoreTempRelationList = new List<int>();

        #region Logink正式环境
        private void _bw_DoWork(object sender, DoWorkEventArgs e)
        {
            DateTime      dtNow     = DateTime.Now;
            string        msg       = dtNow.ToString() + ":【节点上报】 ";
            string        xmlResult = string.Empty;
            RelationModel relation  = new RelationModel();

            try
            {
                List <string> senderCodeList = null;
                M_TMSNode     loginkNode     = null;
                if (Utility._LinkType == "2")
                {
                    senderCodeList = TMSOrderServer.GetAllLoginkSenderCode();
                    if (senderCodeList.Count == 0)
                    {
                        msg += "没有配置通过运管平台交换数据的上游发货单位";
                        return;
                    }
                }
                Model.NodeUpload.MESSAGEDETAIL.XML details = NodeUploadServer.GetFirstWaitUploadNode(senderCodeList, ref loginkNode, out relation);

                if (relation != null && relation.Id != 0)
                {
                    msg += string.Format("Relation【{0}】 Number【{1}】 CustomerId【{3}】 当前上报节点Id【{2}】 ", relation.RelationId, relation.Number, relation.CurrentUploadNodeId, relation.CustomerId);
                }
                if (details == null)
                {
                    if (relation != null && relation.Id != 0)                  // && !_ignoreTempRelationList.Contains(relation.Id))
                    {
                        NodeUploadServer.UpdateHandleTime(relation.Id, false); //_ignoreTempRelationList.Add(relation.Id);
                    }
                    msg += "暂无需要上报的节点";
                    return;
                }
                //运管平台上报
                if (senderCodeList != null)
                {
                    string nodeXml      = Utility.ParseXMLToString(loginkNode);
                    string receiverCode = TMSOrderServer.GetAllLoginkSenderCode(relation.CustomerId.ToString())[0];
                    LoginkHelp.Send(Utility._SecurityURL, Utility._TransportURL, Utility._MyCode, Utility._MyPwd, receiverCode, nodeXml, ActionType.LOGINK_CN_TRANSPORT_PREBOOKING);
                    msg += "上报成功 Receiver[" + receiverCode + "]";
                    bool isArrived = false;
                    if (details.CONTENTLIST[0].DETAILLIST[0].TRACKTYPE == "18")//正常签收
                    {
                        isArrived = true;
                        msg      += " 当前为签收节点 ";
                    }
                    bool isUpdate = NodeUploadServer.UpdateCurrentUploadNodeId(relation, isArrived, senderCodeList);
                    Utility.SaveXMLRequestAndRespond(nodeXml, string.Empty, "Node", relation.RelationId);
                    msg += isUpdate ? "更新当前上报节点成功" : "更新当前上报节点失败";
                    return;
                }
                #region 大华东供应链节点上报处理
                _UploadXML.MESSAGEHEAD.SENDTIME = dtNow.ToString("yyyy-MM-dd HH:mm:ss");
                _UploadXML.MESSAGEHEAD.FILENAME = dtNow.ToString("yyyyMMddHHmmss");
                _UploadXML.MESSAGEDETAIL        = "<![CDATA[" + Utility.ParseXMLToString <Model.NodeUpload.MESSAGEDETAIL.XML>(details) + "]]>";
                string xmlRequest = Utility.ParseXMLToString <Model.NodeUpload.XML>(_UploadXML).Replace("<", "&lt;").Replace(">", "&gt;");
                Utility.AddLogText("上传前:" + xmlRequest);
                StringBuilder param = new StringBuilder();
                param.Append("<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ser=\"http://service.webservice.vtradex.com\" > ");
                param.Append("<soapenv:Header/>");
                param.Append("<soapenv:Body>");
                param.Append("<ser:tmsShipmentInTransitXml>" + xmlRequest + "</ser:tmsShipmentInTransitXml>");
                param.Append("</soapenv:Body>");
                param.Append("</soapenv:Envelope>");
                xmlResult = HTTPHelper.SendHTTPRequest(param.ToString(), "tmsShipmentInTransitXml", "tmsShipmentInTransitXml");
                Model.NodeUpload.XML uploadResult = Utility.ParseXMLToObjec <Model.NodeUpload.XML>(xmlResult);
                if (uploadResult.MSGCODE == "0" || string.IsNullOrEmpty(uploadResult.MSGCODE))
                {
                    msg += "上报失败" + " " + uploadResult.MSGCONTENT;
                }
                else if (uploadResult.MSGCODE == "1")
                {
                    msg += "上报成功 ";
                    try
                    {
                        bool isArrived = false;
                        if (details.CONTENTLIST[0].DETAILLIST[0].TRACKTYPE == "18")//正常签收
                        {
                            isArrived = true;
                            msg      += " 当前为签收节点 ";
                        }
                        bool isUpdate = NodeUploadServer.UpdateCurrentUploadNodeId(relation, isArrived, senderCodeList);
                        msg += isUpdate ? "更新当前上报节点成功" : "更新当前上报节点失败";
                        if (isArrived && isUpdate)
                        {
                            UploadCarrierArrived(details.CONTENTLIST[0].DETAILLIST[0], relation.CurrentUploadDataTime);
                        }
                    }
                    catch (Exception ex1)
                    {
                        msg += ex1.Message;
                    }
                }
                Utility.SaveXMLRequestAndRespond(param.ToString(), xmlResult, "Node", relation.RelationId);
                #endregion
            }
            catch (Exception ex)
            {
                msg += ex.Message;
                Utility.SaveErrLog(ex.Message, "Node");
                if (!ex.Message.Contains("重新开始") && !ex.Message.Contains("成功"))
                {
                    if (relation != null)
                    {
                        NodeUploadServer.UpdateHandleTime(relation.Id, false);
                    }
                    SendEmail(new Exception(msg));
                }
            }
            finally
            {
                Console.WriteLine(msg.Replace("\n", ""));
            }
        }
        /// <summary>
        /// 暂时忽略掉的关系
        /// </summary>
        //private List<long> _ignoreTempRelationList = new List<long>();


        #region Logink正式环境
        private void _bw_DoWork(object sender, DoWorkEventArgs e)
        {
            DateTime      dtNow     = DateTime.Now;
            string        msg       = dtNow.ToString() + ":【订单温湿度上报】 ";
            string        xmlResult = string.Empty;
            RelationModel relation  = new RelationModel();

            try
            {
                List <string>    senderCodeList = null;
                List <M_TMSData> loginkData     = null;
                if (Utility._LinkType == "2")
                {
                    senderCodeList = TMSOrderServer.GetAllLoginkSenderCode();
                    if (senderCodeList.Count == 0)
                    {
                        msg += "没有配置通过运管平台交换数据的上游发货单位";
                        return;
                    }
                }
                XML details = DataUploadServer.GetNextWaitUploadDatas(senderCodeList, ref loginkData, out relation);
                if (relation != null && relation.Id != 0)
                {
                    msg += string.Format("R【{0}】 O【{1}】 N【{2}】 T【{3}】", relation.RelationId, relation.Number, relation.CurrentUploadDataNodeId, relation.CurrentUploadDataTime);
                }
                if (details == null)
                {
                    if (relation != null && relation.Id != 0)                    // && !_ignoreTempRelationList.Contains(relation.Id))
                    {
                        DataUploadServer.UpdateHandleTHTime(relation.Id, false); //_ignoreTempRelationList.Add(relation.Id);
                    }
                    msg += "没有新的节点数据[relationId:" + relation.Id + "]";
                    return;
                }
                //运管平台上报
                if (senderCodeList != null)
                {
                    string dataXml      = Utility.ParseXMLToString(loginkData);
                    string receiverCode = TMSOrderServer.GetAllLoginkSenderCode()[0];
                    LoginkHelp.Send(Utility._SecurityURL, Utility._TransportURL, Utility._MyCode, Utility._MyPwd, receiverCode, dataXml, ActionType.LOGINK_CN_TRANSPORT_PREBOOKING);
                    msg += "上报成功 Receiver[" + receiverCode + "]";
                    bool isUpdate = DataUploadServer.UpdataUploadDataNode(relation);//, ref _ignoreTempRelationList);
                    Utility.SaveXMLRequestAndRespond(dataXml, string.Empty, "Temperature", relation.RelationId);
                    msg += isUpdate ? "更新进度成功" : "更新进度失败";
                    return;
                }
                _UploadXML.MESSAGEHEAD.SENDTIME = dtNow.ToString("yyyy-MM-dd HH:mm:ss");
                _UploadXML.MESSAGEHEAD.FILENAME = dtNow.ToString("yyyyMMddHHmmss");
                _UploadXML.MESSAGEDETAIL        = "<![CDATA[" + Utility.ParseXMLToString <Model.NodeDataUpload.XML>(details) + "]]>";
                string        xmlRequest = Utility.ParseXMLToString <Model.NodeUpload.XML>(_UploadXML).Replace("<", "&lt;").Replace(">", "&gt;");
                StringBuilder param      = new StringBuilder();
                param.Append("<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ser=\"http://service.webservice.vtradex.com\" > ");
                param.Append("<soapenv:Header/>");
                param.Append("<soapenv:Body>");
                param.Append("<ser:temperatureXml1>" + xmlRequest + "</ser:temperatureXml1>");
                param.Append("</soapenv:Body>");
                param.Append("</soapenv:Envelope>");
                xmlResult = HTTPHelper.SendHTTPRequest(param.ToString(), "getTmsShipmentTemperature", "temperatureXml1");
                Model.NodeUpload.XML uploadResult = Utility.ParseXMLToObjec <Model.NodeUpload.XML>(xmlResult, param.ToString());
                if (uploadResult.MSGCODE == "0" || string.IsNullOrEmpty(uploadResult.MSGCODE))
                {
                    msg += "上报失败 " + uploadResult.MSGCONTENT;
                }
                else if (uploadResult.MSGCODE == "1")
                {
                    msg += "上报成功 ";
                    try
                    {
                        msg += DataUploadServer.UpdataUploadDataNode(relation) ? "更新进度成功." : "更新进度失败.";
                    }
                    catch (Exception ex1)
                    {
                        msg += ex1.Message;
                    }
                }
                Utility.SaveXMLRequestAndRespond(param.ToString(), xmlResult, "Temperature", relation.RelationId);
            }
            catch (Exception ex)
            {
                msg += ex.Message;
                Utility.SaveErrLog(ex.Message, "Temperature");
                //if (relation.Id != 0 )//&& _ignoreTempRelationList.Contains(relation.Id) == false)
                //    DataUploadServer.UpdateHandleTHTime(relation.Id, false); //_ignoreTempRelationList.Add(relation.Id);
                if (relation != null && relation.CurrentUploadDataNodeId != -1)
                {
                    if (!ex.Message.Contains("重新开始") && !ex.Message.Contains("成功") && !ex.Message.Contains("没有新的载体温湿度"))
                    {
                        DataUploadServer.UpdateHandleTHTime(relation.Id, false);
                        SendEmail(new Exception(msg));
                    }
                }
            }
            finally
            {
                Console.WriteLine(msg.Replace("\n", ""));
            }
        }
Пример #4
0
        private void _bw_DoWork(object sender, DoWorkEventArgs e)
        {
            DateTime dtNow     = DateTime.Now;
            string   msg       = dtNow.ToString() + ":【同步TMS运单】 ";
            bool     addResult = false;
            string   xmlResult = string.Empty;

            try
            {
                StringBuilder param = new StringBuilder();
                param.Append("<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ser=\"http://service.webservice.vtradex.com\" > ");
                param.Append("<soapenv:Header/>");
                param.Append("<soapenv:Body>");
                param.Append("<ser:shipmentXml>" + Utility._SecretKey + "</ser:shipmentXml>");
                param.Append("</soapenv:Body>");
                param.Append("</soapenv:Envelope>");
                xmlResult = HTTPHelper.SendHTTPRequest(param.ToString(), "shipmentXml", "shipmentXml");

                XML result = Utility.ParseXMLToObjec <XML>(xmlResult);
                if (result.MSGCODE != null)
                {
                    msg      += result.MSGCONTENT;
                    addResult = true;
                }
                else
                {
                    msg += result.MESSAGEHEAD.FILENAME + " " + result.MESSAGEHEAD.FILEFUNCTION + " ";
                    if (result.MESSAGEHEAD.FILEFUNCTION == "ADD")
                    {
                        Utility.AddLogText("-------------------------------------------------");
                        Utility.AddLogText("同步TMS运单");
                        addResult = TMSOrderServer.AddTMSOrders(result._MESSAGEDETAIL);
                        msg      += addResult ? "同步成功" : "同步失败";
                        Utility.AddLogText(addResult ? "同步成功" : "同步失败");
                        Utility.AddLogText("-------------------------------------------------");
                        Utility.SaveXMLRequestAndRespond(param.ToString(), xmlResult, "Order", "n");
                    }
                    else
                    {
                        msg += "不处理";
                    }
                }
            }
            catch (Exception ex)
            {
                msg += ex.Message + " ";
                Utility.SaveErrLog(ex.Message, "Order");
                Utility.AddLogText(string.Format("_bw_DoWork-SyncTMSOrder:{0}", ex.Message));
            }
            finally
            {
                if (!addResult && !string.IsNullOrEmpty(xmlResult))
                {
                    string filePath = Utility.SaveXMLFile(xmlResult, dtNow);
                    if (filePath != string.Empty)
                    {
                        msg += "订单内容已保存到[" + filePath + "]";
                    }
                    SendEmail(new Exception(msg), filePath);
                }
                Console.WriteLine(msg.Replace("\n", ""));
            }
        }