コード例 #1
0
ファイル: freightsyncsvc.cs プロジェクト: jpheary/Argix08
 //Interface
 public FreightSyncSvc()
 {
     //Constructor
     try {
         SQLData.FreightSyncDays = FreightSyncSvc.SyncDaysMax;
         SQLData.DBConnection    = FreightSyncSvc.SQLConnection;
         this.mSQLData           = new SQLData();
         this.mAS400Data         = new AS400Data(FreightSyncSvc.AS400Connection, FreightSyncSvc.AS400Login);
     }
     catch (ApplicationException ex) { throw ex; }
     catch (Exception ex) { throw new ApplicationException("Failed to create new FreightSyncSvc instance.", ex); }
 }
コード例 #2
0
ファイル: freightsyncsvc.cs プロジェクト: jpheary/Argix08
        public DateTime GetLastRefresh()
        {
            //Get date and time of last refresh
            DateTime dt = DateTime.Now;

            try {
                //On/off switch
                if (FreightSyncSvc.AS400Login == "")
                {
                    dt = DateTime.Now;
                }
                else
                {
                    dt = SQLData.GetLastRefresh();
                }
            }
            catch (ApplicationException ex) { throw ex; }
            catch (Exception ex) { throw new ApplicationException("Unexpected error while requesting last refresh date and time.", ex); }
            return(dt);
        }
コード例 #3
0
ファイル: freightsyncsvc.cs プロジェクト: jpheary/Argix08
        public void SyncFreight(SyncType syncType)
        {
            //Sync all freight
            int date = 0; int time = 0;

            //On/off switch
            if (!AS400Sync || FreightSyncSvc.AS400Login == "")
            {
                return;
            }

            switch (syncType)
            {
            case SyncType.All:
                try {
                    //Get latest date\time from the local Freight table
                    SQLData.GetLastUpdatedDateTime(ref date, ref time);

                    //Fetch data from AS400 Freight table; and create a typed FreightSyncDS dataset which will
                    //be used to update LAN Freight table
                    FreightSyncDS dsUpdates = this.mAS400Data.GetFreight(date, time);
                    foreach (FreightSyncDS.FreightSyncDSTableRow row in dsUpdates.FreightSyncDSTable.Rows)
                    {
                        if (this.mSQLData.ReadFreight(row.ID).Tables[TBL_FREIGHTSYNC].Rows.Count > 0)
                        {
                            this.mSQLData.UpdateFreight(row);
                        }
                        else
                        {
                            this.mSQLData.CreateFreight(row);
                        }
                    }
                }
                catch (ApplicationException ex) { throw ex; }
                catch (Exception ex) { throw new ApplicationException(EX_FREIGHT_SYNC_FAILED, ex); }

                try {
                    //Check AS400 for deleted freight; if found, then delete from local Freight table
                    FreightSyncDS dsDeletes = this.mAS400Data.GetDeletedFreight(date, time);
                    foreach (FreightSyncDS.FreightSyncDSTableRow row in dsDeletes.FreightSyncDSTable.Rows)
                    {
                        this.mSQLData.DeleteFreight(row.ID);
                    }
                }
                catch (ApplicationException ex) { throw ex; }
                catch (Exception ex) { throw new ApplicationException(EX_FREIGHT_DELETE_SYNC_FAILED, ex); }
                break;

            case SyncType.Unsorted:
                try {
                    //Fetch data from AS400 Freight table and create a typed FreightSyncDS dataset which will be used to update LAN Freight table
                    FreightSyncDS dsUnsorted = this.mAS400Data.GetUnsortedFreight();
                    foreach (FreightSyncDS.FreightSyncDSTableRow row in dsUnsorted.FreightSyncDSTable.Rows)
                    {
                        if (this.mSQLData.ReadFreight(row.ID).Tables[TBL_FREIGHTSYNC].Rows.Count > 0)
                        {
                            this.mSQLData.UpdateFreight(row);
                        }
                        else
                        {
                            this.mSQLData.CreateFreight(row);
                        }
                    }
                }
                catch (ApplicationException ex) { throw ex; }
                catch (Exception ex) { throw new ApplicationException(EX_FREIGHT_UNSORT_SYNC_FAILED, ex); }
                break;
            }
        }