Пример #1
0
        public void Run()
        {
            if (_threadCmd != ThreadCmd.Stop)
            {
                try
                {
                    LogWrite("RunCallback begin");
                    RunCallback();
                    LogWrite("RunCallback end");

                    if (_messageService != null)
                    {
                        _messageService.AddOrUpdate("ServiceStatus", _threadName, "Success", null, Core.Models.Calls.MessageStatus.Success);
                    }
                }
                catch (Exception ex)
                {
                    _logger.Info("Run", ex);

                    if (_messageService != null)
                    {
                        _messageService.AddOrUpdate("ServiceStatus",
                                                    _threadName,
                                                    "Service processing error",
                                                    new ExceptionMessageData()
                        {
                            Message = ExceptionHelper.GetAllMessages(ex)
                        },
                                                    Core.Models.Calls.MessageStatus.Error);
                    }
                }

                SetTimer();
            }
        }
Пример #2
0
        public void Run()
        {
            try
            {
                Init();

                while (_threadCmd != ThreadCmd.Stop)
                {
                    try
                    {
                        //LogWrite("RunCallback begin");
                        RunCallback();
                        //LogWrite("RunCallback end");

                        if (_messageService != null)
                        {
                            _messageService.AddOrUpdate("ServiceStatus", _threadName, "Success", null, Core.Models.Calls.MessageStatus.Success);
                        }
                    }
                    catch (Exception ex)
                    {
                        _logger.Fatal("Run." + _threadName, ex);

                        if (_messageService != null)
                        {
                            _messageService.AddOrUpdate("ServiceStatus",
                                                        _threadName,
                                                        "Service processing error",
                                                        new ExceptionMessageData()
                            {
                                Message = ExceptionHelper.GetAllMessages(ex)
                            },
                                                        Core.Models.Calls.MessageStatus.Error);
                        }

                        if (_emailService != null)
                        {
                            _emailService.SendSystemEmailToAdmin("Fail." + _threadName, "Details: " + ExceptionHelper.GetAllMessages(ex));
                        }
                    }
                    if (_callbackInterval.HasValue)
                    {
                        _eventState.WaitOne(_callbackInterval.Value);
                    }
                }
            }
            finally
            {
                Finish();
            }
        }