Example #1
0
        private void InitializeAppResources()
        {
            try
            {
                this.oApp = GTClassFactory.Create <IGTApplication>();

                if (this.oApp == null)
                {
                    CommandUtilities.LogMessage(oDiag, "GTAssetTracker.InitializeResources", "IGTApplicationError", "Cannot initialize IGTApplication.");
                    DoExit();
                }

                SetStatusBarText("Initializing...");

                this.oMap = oApp.ActiveMapWindow;
                if (this.oMap == null)
                {
                    CommandUtilities.LogMessage(oDiag, "GTAssetTracker.InitializeResources", "MapWindowError", "There is no active map window.");
                    throw new Exception("IGTMapWindow");
                }

                oDisplay = oMap.DisplayService;
                if (oDisplay == null)
                {
                    CommandUtilities.LogMessage(oDiag, "GTAssetTracker.InitializeResources", "DisplayService", "No display service for the active map window.");
                    throw new Exception("IGTDisplayService");
                }

                this.oDC = oApp.DataContext;
                if (this.oDC == null)
                {
                    CommandUtilities.LogMessage(oDiag, "GTAssetTracker.InitializeResources", "DataContextError", "No data context was obtained from IGTApplication.");
                    throw new Exception("IGTDataContext");
                }

                this.oLocate = this.oMap.LocateService;
                if (this.oLocate == null)
                {
                    CommandUtilities.LogMessage(oDiag, "GTAssetTracker.InitializeResources", "IGTLocateService", "No IGTLocateService was obtained from IGTMapWindow.");
                    throw new Exception("IGTLocateService");
                }

                this.oRelationService             = GTClassFactory.Create <IGTRelationshipService>();
                this.oRelationService.DataContext = this.oDC;

                this.oGenParams = new GTSysGenParam();
                if (!CommandUtilities.GetSysGeneralParameters(this.oDC, this.oDiag, ref this.oGenParams))
                {
                    throw new Exception("No General Parameters have been defined.");
                }

                this.oActiveList          = new List <GTActiveStreetLight>();
                this.oActiveStructureList = new List <GTActiveStructure>();

                SetStatusBarText("Initialized.");
            }
            catch (Exception ex)
            {
                CommandUtilities.LogException(oDiag, "GTAssetTracker.InitializeResources", ex);
                throw ex;
            }
        }