示例#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;
            }
        }
示例#2
0
        public static bool GetSysGeneralParameters(IGTDataContext _odc, GTDiagnostics _odiag, ref GTSysGenParam _gp)
        {
            bool bSuccess = false;

            try
            {
                string    sSqlSysGP      = "SELECT ID, SUBSYSTEM_NAME, SUBSYSTEM_COMPONENT, PARAM_NAME, PARAM_VALUE, PARAM_DESC FROM SYS_GENERALPARAMETER WHERE SUBSYSTEM_NAME = 'ASSET_HISTORY_TRACKING'";
                Recordset rsGeneralParam = CommandUtilities.ExecuteQuery(_odc, sSqlSysGP, _odiag);

                if (rsGeneralParam == null)
                {
                    CommandUtilities.LogMessage(_odiag, "GetGeneralParameters", "GeneralParameter", "Nothing returned from SYS_GENERALPARAMETER."); return(bSuccess);
                }

                string sThreshold          = CommandUtilities.Get_Recordset_Value(rsGeneralParam, "PARAM_VALUE", "PARAM_NAME", "StreetLightMovementThreshold", _odiag);
                string sHistoricalSymbol   = CommandUtilities.Get_Recordset_Value(rsGeneralParam, "PARAM_VALUE", "PARAM_NAME", "StreetLightHistoricalSymbol", _odiag);
                string sHistoricalLine     = CommandUtilities.Get_Recordset_Value(rsGeneralParam, "PARAM_VALUE", "PARAM_NAME", "StreetLightHistoricalLine", _odiag);
                string sHistoricalStacking = CommandUtilities.Get_Recordset_Value(rsGeneralParam, "PARAM_VALUE", "PARAM_NAME", "StreetLightHistoricalStacking", _odiag);
                string sANOx = Get_Recordset_Value(rsGeneralParam, "PARAM_VALUE", "PARAM_NAME", "ANO_OGGX", _odiag);
                string sANOy = Get_Recordset_Value(rsGeneralParam, "PARAM_VALUE", "PARAM_NAME", "ANO_OGGY", _odiag);
                string sANOz = Get_Recordset_Value(rsGeneralParam, "PARAM_VALUE", "PARAM_NAME", "ANO_OGGZ", _odiag);

                if (!string.IsNullOrEmpty(sThreshold))
                {
                    _gp.MovementThreshold = Convert.ToInt32(sThreshold);
                }
                if (!string.IsNullOrEmpty(sHistoricalSymbol))
                {
                    _gp.HistoricalSymbol = Convert.ToInt32(sHistoricalSymbol);
                }
                if (!string.IsNullOrEmpty(sHistoricalSymbol))
                {
                    _gp.HistoricalLine = Convert.ToInt32(sHistoricalLine);
                }
                if (!string.IsNullOrEmpty(sHistoricalStacking))
                {
                    _gp.HistoricalStacking = Convert.ToInt32(sHistoricalStacking);
                }
                if (!string.IsNullOrEmpty(sANOx))
                {
                    _gp.ANO_X = Convert.ToInt32(sANOx);
                }
                else
                {
                    _gp.ANO_X = 108;
                }

                if (!string.IsNullOrEmpty(sANOy))
                {
                    _gp.ANO_Y = Convert.ToInt32(sANOy);
                }
                else
                {
                    _gp.ANO_Y = 109;
                }

                if (!string.IsNullOrEmpty(sANOz))
                {
                    _gp.ANO_Z = Convert.ToInt32(sANOz);
                }
                else
                {
                    _gp.ANO_Z = 110;
                }

                rsGeneralParam.Close();
                rsGeneralParam = null;
                bSuccess       = true;
            }
            catch (Exception ex)
            {
                CommandUtilities.LogException(_odiag, "GTAssetTracker.GetSysGeneralParameters", ex);
                throw ex;
            }

            return(bSuccess);
        }