Пример #1
0
        static void Main(string[] args)
        {
            ReadGDSQueue objGDSQScanner = null;

            ///////Add settings in Azure table
            GDSServiceConfig objServiceConfig = new GDSServiceConfig();
            ///////Validate Configuration settings


            IRoboticsLogger objFileLogger = RoboticsLoggerFactory.GetRoboticsLogger(RoboticsLoggerEnum.FileLogger,
                                                                                    objServiceConfig.LocalLogPath, string.Empty, string.Empty);

            IMsgQProvider _objCloudLoggingQ = CloudObjectFactory.GetMsgQProvider(objServiceConfig.CloudProvider,
                                                                                 objServiceConfig.CloudLoggingQName,
                                                                                 objServiceConfig.ConnectionString);

            var logServiceStartMsg = LoggingMsgComposer.GetServiceStartLogMsg(objServiceConfig.ServiceName);

            _objCloudLoggingQ.AddMsgToLoggingQ(logServiceStartMsg);

            while (true)
            {
                try
                {
                    ///////read settings from Azure table and referesh the settings
                    objGDSQScanner = new ReadGDSQueue(objServiceConfig, objFileLogger, _objCloudLoggingQ);
                    objGDSQScanner.ScanGDSQueue();
                }
                catch (Exception ex)
                {
                    try
                    {
                        LogMsg logMsg = LoggingMsgComposer.GetLogMsg(RoboticsLogLevelEnum.Error,
                                                                     "Parent Block: " + Constants.OUTER_CATCH_BLOCK_ERROR_MSG + Environment.NewLine +
                                                                     ex.Message + Environment.NewLine + ex.StackTrace,
                                                                     objServiceConfig.ServiceName, objServiceConfig.GalQNumber);
                        _objCloudLoggingQ.AddMsgToLoggingQ(logMsg);
                    }
                    catch (Exception innerEx)
                    {
                        //LOG into local file
                        try
                        {
                            objFileLogger.WriteLog(RoboticsLogLevelEnum.Error,
                                                   LoggingMsgComposer.GetStringLogMsg("Parent Block: " + Constants.OUTER_CATCH_BLOCK_ERROR_MSG +
                                                                                      Environment.NewLine + innerEx.Message + Environment.NewLine + innerEx.StackTrace,
                                                                                      objServiceConfig.ServiceName, objServiceConfig.GalQNumber));
                        }
                        catch { /* SUPPRESS EXCEPTTION TO RESTART THE FLOW AFTER DELAY */ }
                    }
                }
                finally
                {
                    objGDSQScanner = null;
                }

                Thread.Sleep(1000 * objServiceConfig.DelayInterval);
            }
        }
Пример #2
0
        public void ScanGDSQueue()
        {
            int currentQKnt = 0;

            try
            {
                #region GET QUEUE COUNT
                try
                {
                    currentQKnt = _gdsPro.GetQCount(_qNumber, _pcc);
                }
                catch (Exception ex)
                {
                    currentQKnt = 0;
                    LogMsg logMsg = LoggingMsgComposer.GetLogMsg(RoboticsLogLevelEnum.Error,
                                                                 Constants.Q_COUNT_ERROR_MSG + Environment.NewLine + ex.Message,
                                                                 _serviceName, _qNumber);
                    _objCloudLoggingQ.AddMsgToLoggingQ(logMsg);
                }
                #endregion

                if (currentQKnt > 0)
                {
                    ReadQueuePNRMsg currentPNR  = null;
                    ReadQueuePNRMsg previousPNR = null;

                    //READ QUEUE
                    currentPNR = _gdsPro.ReadQueue(_qNumber, string.Empty, _msgTemplate);

                    //TRAVERSE GAL QUEUE TO REMOVE PNR AND ADD TO AZURE Q
                    for (int i = 0; i < currentQKnt; i++)
                    {
                        if (currentPNR != null && !string.IsNullOrEmpty(currentPNR.Recloc))
                        {
                            currentPNR.PCC       = _pcc;
                            currentPNR.FromQueue = _qNumber;
                            currentPNR.StartTime = DateTime.Now;

                            previousPNR = null;
                            previousPNR = currentPNR.DeepClone();

                            //_pnrMovementMsg = string.Format(_pnrMovementMsg,

                            // REMOVE CURRENT PNR AND READ NEXT
                            currentPNR = _gdsPro.RemoveNGetNextPNRMsg(string.Empty, _msgTemplate);

                            if (_objDestinationCloudQ != null)
                            {
                                //PUSH MSG INTO AZURE QUEUE (/////IF IT FAILS THEN ADD PNR BACK TO GAL QUEUE/////)
                                _objDestinationCloudQ.AddPNRToCloudQ(previousPNR);
                            }

                            //ADD MESSAGE TO LOGGING QUEUE
                            _pnrMovementMsg = string.Format(_pnrMovementMsg, previousPNR.Recloc);
                            LogMsg logMsg = LoggingMsgComposer.GetLogMsg(RoboticsLogLevelEnum.Info, _pnrMovementMsg, _serviceName, _qNumber);
                            _objCloudLoggingQ.AddMsgToLoggingQ(logMsg);
                        }
                        else
                        {
                            break;
                        }

                        currentQKnt = currentQKnt - 1;
                    }

                    try { _gdsPro.CloseSession(string.Empty); } catch { }
                }
            }
            catch (Exception ex)
            {
                //LOG EXECEPTION (/////// RESOLVE ISSUE OF SESSION OUT)
                if (_gdsPro != null)
                {
                    try { _gdsPro.CloseSession(string.Empty); } catch (Exception SessionCloseEx) { }
                }

                try
                {
                    LogMsg logMsg = LoggingMsgComposer.GetLogMsg(RoboticsLogLevelEnum.Error,
                                                                 Constants.OUTER_CATCH_BLOCK_ERROR_MSG + Environment.NewLine +
                                                                 ex.Message + Environment.NewLine +
                                                                 ex.StackTrace, _serviceName, _qNumber);

                    _objCloudLoggingQ.AddMsgToLoggingQ(logMsg);
                }
                catch (Exception innerEx)
                {
                    //LOG into local file
                    _roboticsLogger.WriteLog(RoboticsLogLevelEnum.Error,
                                             LoggingMsgComposer.GetLogMsg(RoboticsLogLevelEnum.Error,
                                                                          Constants.OUTER_CATCH_BLOCK_ERROR_MSG + Environment.NewLine +
                                                                          innerEx.Message + Environment.NewLine +
                                                                          innerEx.StackTrace, _serviceName, _qNumber).ToString());
                }
            }
        }