Example #1
0
        public static void DealWith501(XElement xElement, string path)
        {
            ReceiptSql     sqlserver = null;
            MessageService msService = null;

            try
            {
                IEnumerable <XElement> eles = xElement.Elements().First().Elements();
                string guid          = eles.Where(e => e.Name.LocalName == "guid").First().Value;
                string billNo        = eles.Where(e => e.Name.LocalName == "billNo").First().Value;
                string orderNoFake   = eles.Where(e => e.Name.LocalName == "orderNo").First().Value;
                string logisticsNo   = eles.Where(e => e.Name.LocalName == "logisticsNo").First().Value;
                string weigth        = eles.Where(e => e.Name.LocalName == "weight").First().Value;
                string freight       = eles.Where(e => e.Name.LocalName == "freight").First().Value;
                string logisticsCode = eles.Where(e => e.Name.LocalName == "logisticsCode").First().Value;

                if (!MessageControl.CheckNeedSendLogistics(logisticsCode))
                {
                    sqlserver = new ReceiptSql();
                    sqlserver.Operate501(orderNoFake, billNo, weigth, freight);

                    string destPath = FileUtilities.GetNewFolderName(true, ConfigurationInfo.PathBackUp, "501") + "\\" + FileUtilities.GetNewFileName(orderNoFake) + ".xml";

                    msService = new MessageService();
                    bool success = msService.DealMessage501(true, false, guid, orderNoFake, logisticsNo, destPath);
                    if (!success)
                    {
                        destPath = FileUtilities.GetNewFolderName(true, ConfigurationInfo.PathBackUpError, "501") + "\\" + FileUtilities.GetNewFileName(orderNoFake) + ".xml";
                    }

                    CacheInfo cache601 = CacheInfo.SetCacheInfo("601", Utilities.SetArrayList(logisticsNo, logisticsCode));
                    cache601.createTime = DateTime.Now.AddMinutes(1);
                    MessageCache.AddMessageCache("601_" + logisticsNo, cache601);

                    FileUtilities.FileMove(path, destPath);
                }
            }
            catch (Exception ex)
            {
                BackUpForError(path);
                Logs.Error("DealWith501 Exception: " + ex.ToString());
            }
        }
Example #2
0
        public bool CreateMessage301(string orderNo)
        {
            bool             success       = true;
            OrderHead        orderHead     = null;
            List <OrderList> orderLists    = null;
            XElement         xele          = null;
            XNamespace       ns            = null;
            MessageSql       mssql         = null;
            string           logisticsNo   = null;
            string           logisticsCode = null;
            MessageService   msService     = null;

            try
            {
                orderHead  = new OrderHead();
                orderLists = new List <OrderList>();
                mssql      = new MessageSql();
                mssql.QueryData301(orderNo, ref orderHead, ref orderLists, ref logisticsNo, ref logisticsCode);
                if (orderHead.guid != new Guid())
                {
                    ns   = "http://www.chinaport.gov.cn/ceb";
                    xele = new XElement(ns + "CEB301Message");
                    xele.SetAttributeValue(XNamespace.Xmlns + "ceb", ns);
                    xele = orderHead.ToXElememt(xele, ns);
                    foreach (var a in orderLists)
                    {
                        xele = a.ToXElememt(xele, ns);
                    }
                    FileUtilities.CreateFolder(ConfigurationInfo.PathSend);

                    string destPath = FileUtilities.GetNewFolderName(true, ConfigurationInfo.PathBackUp, "301") + "\\" + FileUtilities.GetNewFileName(orderNo) + ".xml";

                    msService = new MessageService();
                    success   = msService.DealMessage301(orderNo, orderHead.orderNo, logisticsNo, false, true, orderHead.guid.ToString(), destPath, logisticsCode);
                    if (!success)
                    {
                        destPath = FileUtilities.GetNewFolderName(true, ConfigurationInfo.PathBackUpError, "301") + "\\" + FileUtilities.GetNewFileName(orderNo) + ".xml";
                    }
                    xele.Save(ConfigurationInfo.PathSend + "\\" + FileUtilities.GetNewFileName(orderNo) + ".xml");
                    xele.Save(destPath);
                    if (CheckNeedSendLogistics(logisticsCode))
                    {
                        MessageCache.AddMessageCache("501_" + orderHead.orderNo, CacheInfo.SetCacheInfo("501", Utilities.SetArrayList(orderHead.orderNo, logisticsCode)));
                        CacheInfo cache503R = CacheInfo.SetCacheInfo("503R", Utilities.SetArrayList(logisticsNo, logisticsCode));
                        cache503R.createTime = DateTime.Now.AddMinutes(1);
                        MessageCache.AddMessageCache("503R_" + logisticsNo, cache503R);
                        CacheInfo cache601 = CacheInfo.SetCacheInfo("601", Utilities.SetArrayList(logisticsNo, logisticsCode));
                        cache601.createTime = DateTime.Now.AddMinutes(2);
                        MessageCache.AddMessageCache("601_" + logisticsNo, cache601);
                    }
                }
                else
                {
                    Logs.Info("Does not exist in database: " + orderNo);
                    success = false;
                }
            }
            catch (Exception ex)
            {
                Logs.Error("Create301Message Exception:" + ex.ToString());
                success = false;
            }
            return(success);
        }