public static void WatcherStart(string path, int watcherType = 15, string filter = "*.*", bool isIncludeSub = false)
        {
            FileUtilities.CreateFolder(path);
            FileSystemWatcher watcher = new FileSystemWatcher(path, filter);

            if (((WatcherChangeTypes)watcherType & WatcherChangeTypes.Created) == WatcherChangeTypes.Created)
            {
                watcher.Created += new FileSystemEventHandler(OnCreated);
            }
            if (((WatcherChangeTypes)watcherType & WatcherChangeTypes.Deleted) == WatcherChangeTypes.Deleted)
            {
                watcher.Deleted += new FileSystemEventHandler(OnDeleted);
            }
            if (((WatcherChangeTypes)watcherType & WatcherChangeTypes.Changed) == WatcherChangeTypes.Changed)
            {
                watcher.Changed += new FileSystemEventHandler(OnChanged);
            }
            if (((WatcherChangeTypes)watcherType & WatcherChangeTypes.Renamed) == WatcherChangeTypes.Renamed)
            {
                watcher.Renamed += new RenamedEventHandler(OnRenamed);
            }
            watcher.EnableRaisingEvents = true;
            watcher.NotifyFilter        = NotifyFilters.Attributes | NotifyFilters.CreationTime | NotifyFilters.DirectoryName | NotifyFilters.FileName | NotifyFilters.LastAccess
                                          | NotifyFilters.LastWrite | NotifyFilters.Security | NotifyFilters.Size;
            watcher.IncludeSubdirectories = isIncludeSub;
        }
예제 #2
0
        public bool Create503Message(LogisticsStatus logisticsStatus)
        {
            bool          isSuccess     = true;
            BaseSubscribe baseSubscribe = null;
            XElement      xele          = null;
            XNamespace    ns            = null;

            try
            {
                Logs.Debug("Create503Message Start! OrderNo_" + logisticsStatus.logisticsNo);
                baseSubscribe = GetBaseSubscribe();
                ns            = "http://www.chinaport.gov.cn/ceb";
                xele          = new XElement(ns + "CEB503Message");
                xele.SetAttributeValue(XNamespace.Xmlns + "ceb", ns);
                xele = logisticsStatus.ToXElememt(xele, ns);
                xele = baseSubscribe.ToXElememt(xele, ns);
                FileUtilities.CreateFolder(ConfigurationInfo.PathSend);
                xele.Save(ConfigurationInfo.PathSend + "\\" + logisticsStatus.logisticsNo + "_" + logisticsStatus.logisticsStatus + "_503.xml");
                Logs.Debug("Create503Message End! OrderNo_" + logisticsStatus.logisticsNo);
            }
            catch (Exception ex)
            {
                Logs.Error("Create503Message Exception: " + ex.ToString());
                isSuccess = false;
            }
            return(isSuccess);
        }
예제 #3
0
        public bool CreateMessage601(string logisticsNo)
        {
            bool                 success        = true;
            InventoryHead        inventoryHead  = null;
            List <InventoryList> inventoryLists = null;
            BaseSubscribe        baseSubscribe  = null;
            XElement             xele           = null;
            XNamespace           ns             = null;
            MessageSql           mssql          = null;
            MessageService       msService      = null;

            try
            {
                inventoryHead  = new InventoryHead();
                inventoryLists = new List <InventoryList>();
                baseSubscribe  = new BaseSubscribe();
                mssql          = new MessageSql();
                mssql.QueryDate601(logisticsNo, ref inventoryHead, ref inventoryLists, ref baseSubscribe);
                if (inventoryHead.guid != new Guid())
                {
                    ns   = "http://www.chinaport.gov.cn/ceb";
                    xele = new XElement(ns + "CEB601Message");
                    xele.SetAttributeValue(XNamespace.Xmlns + "ceb", ns);
                    xele = inventoryHead.ToXElememt(xele, ns);
                    foreach (var a in inventoryLists)
                    {
                        xele = a.ToXElememt(xele, ns);
                    }
                    xele = baseSubscribe.ToXElememt(xele, ns);
                    FileUtilities.CreateFolder(ConfigurationInfo.PathSend);
                    xele.Save(ConfigurationInfo.PathSend + "\\" + FileUtilities.GetNewFileName(inventoryHead.orderNo) + "_601.xml");

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

                    msService = new MessageService();
                    msService.DealMessage601(false, true, inventoryHead.guid.ToString(), inventoryHead.copNo, destPath);

                    xele.Save(destPath);
                }
                else
                {
                    Logs.Info("Does not exist in database:" + logisticsNo);
                    success = false;
                }
            }
            catch (Exception ex)
            {
                Logs.Error("Create301Message Exception:" + ex.ToString());
                success = false;
            }
            return(success);
        }
예제 #4
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);
        }