public void Invoke(IInvocation invocation)
        {
            Exception exception = null;

            for (int i = 0; i < 3; i++)
            {
                try
                {
                    invocation.Proceed();
                    return;
                }
                catch (TException we)
                {
                    exception = we;
                    // we will retry here, since we assume that the failure is trasient
                    logger.Info("Exception occured, attempt #" + (i + 1) + ", retrying...", we);
                }

                // if we are here we got an exception, we will assume this is a
                // trasient situation and wait a bit, hopefully it will clear up
                Thread.Sleep(100);
            }
            if (exception == null)
            {
                return;
            }
            logger.Error("All retries failed", exception);
            ExceptionHelper.PreserveStackTrace(exception);
            throw exception;
        }
 protected void importButton_Click(object sender, EventArgs e)
 {
     if (!Helper.HasImportFiles)
     {
         ImportStatus("No files found for import.");
     }
     else
     {
         var defaultLogger = new DefaultLogger();
         try
         {
             new Importers.Importer(new ImportSettings
             {
                 ImportProductCatalogGroups = importProductCatalogGroups.Checked,
                 ImportProductCatalogs = importProductCatalogs.Checked,
                 ImportProductCategories = importProductCategories.Checked,
                 ImportProducts = importProducts.Checked,
                 ImportMarketingFoundation = importMarketingFoundation.Checked,
                 PerformCleanUp = performCleanUp.Checked,
                 CmsProvider = new SitecoreProvider()
             }, Helper.SyncDataPath, defaultLogger).Import();
         }
         catch (Exception ex)
         {
             defaultLogger.Error(ex, "An unexpected error occurred during import");
         }
         if (defaultLogger.HasError)
             ImportStatus(string.Format("An error occurred - see log file ({0}) for details.",
                 WriteLog("import error", defaultLogger)));
         else
             ImportStatus("Imported completed.");
     }
 }
Esempio n. 3
0
        public override void OnException(ExceptionContext context)
        {
            if (context.Exception is AggregateException)
            {
                AggregateException aggregateException = context.Exception as AggregateException;
                foreach (Exception exception in aggregateException.InnerExceptions)
                {
                    DefaultLogger.Error(exception);
                }
                context.Exception = aggregateException.InnerException;
            }

            if (context.Exception is UnauthorizedAccessException)
            {
                context.HttpContext.Response.StatusCode = 401;
            }
            else
            {
                // Unhandled errors
#if !DEBUG
                var    errorMessage = "An unhandled error occurred.";
                string callStack    = null;
#else
                var    errorMessage = context.Exception.GetBaseException().Message;
                string callStack    = context.Exception.StackTrace;
#endif

                context.HttpContext.Response.StatusCode = 500;
            }
            // handle logging here
            JMResult result = context.HttpContext.RequestServices.GetRequiredService <IExceptionHandler>().HandleException(context.Exception);
            //always return a JSON result
            context.Result = new JsonResult(result);
            base.OnException(context);
        }
Esempio n. 4
0
        static async Task MainAsync()
        {
            try {
                MyShadowsocksController controller = new MyShadowsocksController();

                await controller.Start();
            }catch (Exception ex) {
                DefaultLogger.Error(ex);
            }
        }
Esempio n. 5
0
 /// <summary>
 /// Registers the <paramref name="supervisorClass"/> plugin by <paramref name="name"/> that will serve as the default supervise for all <c>Actor</c>
 /// that are not supervised by a specific supervisor.
 /// </summary>
 /// <param name="stageName">The <c>string</c> of the <c>Stage</c> in which the <paramref name="supervisorClass"/> is be registered.</param>
 /// <param name="name">The <c>string</c> name of the supervisor to register.</param>
 /// <param name="supervisorClass">The <c>Type</c> (which should be a subclass of <c>Actor</c>) to register as a supervisor.</param>
 public void RegisterDefaultSupervisor(string stageName, string name, Type supervisorClass)
 {
     try
     {
         var actualStageName = stageName.Equals("default") ? DefaultStage : stageName;
         var stage           = StageNamed(actualStageName);
         defaultSupervisor = stage.ActorFor <ISupervisor>(Definition.Has(supervisorClass, Definition.NoParameters, name));
     }
     catch (Exception e)
     {
         DefaultLogger.Error($"vlingo-net/actors: World cannot register default supervisor override: {supervisorClass.Name}", e);
     }
 }
        public void Error_RandomString_Void()
        {
            // arrange.

            var test = new DefaultLogger();

            // act.
            test.Error("yay", new Exception(), this);

            // assert.
            Assert.IsNotNull(test);

        }
Esempio n. 7
0
        public static void Error(object message)
        {
            switch (LogEngineType)
            {
            case LogEngineTypeEnum.DefaultLogger:
                DefaultLogger.Error(message);
                break;

            case LogEngineTypeEnum.FlashLogger:
                FlashLogger.Error(message);
                break;
            }
        }
Esempio n. 8
0
 /// <summary>
 /// Registers the<paramref name="supervisorClass"/> plugin by <paramref name="name"/> that will supervise all <c>Actor</c> that implement the <paramref name="supervisedProtocol"/>.
 /// </summary>
 /// <param name="stageName">The <c>string</c> of the <c>Stage</c> in which the <paramref name="supervisorClass"/> is be registered.</param>
 /// <param name="name">The <c>string</c> name of the supervisor to register.</param>
 /// <param name="supervisedProtocol">The protocol for which the supervisor will supervise.</param>
 /// <param name="supervisorClass">The <c>Type</c> (which should be a subclass of <c>Actor</c>) to register as a supervisor.</param>
 public void RegisterCommonSupervisor(string stageName, string name, Type supervisedProtocol, Type supervisorClass)
 {
     try
     {
         var actualStageName = stageName.Equals("default") ? DefaultStage : stageName;
         var stage           = StageNamed(actualStageName);
         var common          = stage.ActorFor <ISupervisor>(Definition.Has(supervisorClass, Definition.NoParameters, name));
         stage.RegisterCommonSupervisor(supervisedProtocol, common);
     }
     catch (Exception e)
     {
         DefaultLogger.Error($"vlingo-net/actors: World cannot register common supervisor: {supervisedProtocol.Name}", e);
     }
 }
Esempio n. 9
0
        public JMResult HandleException(Exception e)
        {
            DefaultLogger.Error(e);
            string code = "System";

            if (e is JMException)
            {
                code = (e as JMException).Code;
            }

            JMResult            result = null;
            ResultConfiguration resultConfiguration = resultConfigurationsStaticDataProvider.GetResultConfiguration(code);

            if (resultConfiguration != null)
            {
                result = new JMResult
                {
                    RedirectionInfo = new JMRedirectionInfo
                    {
                        RedirectionParameter = resultConfiguration.RedirectionParameter,
                        RedirectionType      = resultConfiguration.RedirectionType
                    },
                    Errors = new JMResultItem[]
                    {
                        new JMResultItem
                        {
                            Code    = code,
                            Message = resultConfiguration.ResultMessages.FirstOrDefault(e => e.Culture == CultureInfo.CurrentCulture.Name)?.Content
                        }
                    }
                };
            }
            else
            {
                result = new JMResult
                {
                    Errors = new JMResultItem[]
                    {
                        new JMResultItem
                        {
                            Code    = code,
                            Message = e.Message
                        }
                    }
                };
            }

            return(result);
        }
        public virtual ItemSet[] QueryItems(string tfsUrl, ICredentials credentials, VersionSpec version, ItemSpec[] items)
        {
            return(WrapWebException(delegate
            {
                Repository webSvc = CreateProxy(tfsUrl, credentials);
                ItemSet[] result = webSvc.QueryItems(null, null, items, version, DeletedState.NonDeleted, ItemType.Any, true);
                if (result[0].Items.Length == 0)
                {
                    // Check if no items returned due to no permissions.
                    var badPath = false;
                    try
                    {
                        webSvc.QueryHistory(null, null, items[0], version, null, VersionSpec.First, version, 1, false, false, false);
                    }
                    catch (SoapException)
                    {
                        // For TFS08 and earlier, QueryHistory faults for bad path.
                        badPath = true;
                    }

                    if (!badPath && !string.IsNullOrEmpty(Configuration.ReadAllUserName))
                    {
                        try
                        {
                            Repository readAllWebSvc = CreateProxy(tfsUrl, new NetworkCredential(Configuration.ReadAllUserName, Configuration.ReadAllUserPassword, Configuration.ReadAllUserDomain));
                            ItemSet[] readAllResult = readAllWebSvc.QueryItems(null, null, items, version, DeletedState.NonDeleted, ItemType.Any, true);
                            if (readAllResult[0].Items.Length == 0)
                            {
                                badPath = true;
                            }
                        }
                        catch (Exception ex)
                        {
                            logger.Error("Error connecting with read all account " + Configuration.ReadAllUserName, ex);
                        }
                    }

                    if (!badPath)
                    {
                        throw new NetworkAccessDeniedException();
                    }
                }
                return result;
            }));
        }
Esempio n. 11
0
 public void OnTransportDataReceived(RealtimeTransportData data)
 {
     try
     {
         _wrappedListener.OnTransportDataReceived(data);
     }
     catch (Exception e)
     {
         DefaultLogger.Error("Test transport factor on receive error ", e);
     }
     try
     {
         _afterMessage(_handler.ParseRealtimeData(data));
     }
     catch (Exception ex)
     {
         DefaultLogger.Error("Error handling afterMessage helper.", ex);
     }
 }
Esempio n. 12
0
            public void OnTransportDataReceived(RealtimeTransportData data)
            {
                ProtocolMessage msg = null;

                try
                {
                    msg = _handler.ParseRealtimeData(data);
                    ProtocolMessagesReceived.Add(msg);

                    if (_wrappedTransport.BlockReceiveActions.Contains(msg.Action))
                    {
                        return;
                    }

                    if (_wrappedTransport.BeforeDataProcessed != null)
                    {
                        _wrappedTransport.BeforeDataProcessed?.Invoke(msg);
                        data = _handler.GetTransportData(msg);
                    }
                }
                catch (Exception ex)
                {
                    DefaultLogger.Error("Error handling beforeMessage helper.", ex);
                }

                try
                {
                    _wrappedListener?.OnTransportDataReceived(data);
                }
                catch (Exception e)
                {
                    DefaultLogger.Error("Test transport factory on receive error ", e);
                }

                try
                {
                    _wrappedTransport.AfterDataReceived?.Invoke(msg);
                }
                catch (Exception ex)
                {
                    DefaultLogger.Error("Error handling afterMessage helper.", ex);
                }
            }
        public BehaviorTree Build(out string err, out NodeBase node)
        {
            while (this.stack.Count > 1)
            {
                this.EndCurrent();
            }

            BehaviorTree behaviorTree = CreatorUtils.NewBehaviorTree(stack.Pop());

            if (behaviorTree.Validate(out err, out node))
            {
                return(behaviorTree);
            }
            else
            {
                DefaultLogger logger = new DefaultLogger();
                logger.Error(err);
                return(null);
            }
        }
Esempio n. 14
0
 public static void AddLogonHistory(AuthenticationContext context, AuthenticationResult result)
 {
     if (context.UserID != 0)
     {
         VpUserLogonHistory history = new VpUserLogonHistory();
         history.UserID           = context.UserID;
         history.ChannelID        = context.ChannelID;
         history.InitialSessionID = context.InitialSessionID;
         history.IP          = context.ClientIp;
         history.LogonType   = (int)context.TransactionHeader.Customer.LogonType;
         history.LoginResult = (short)(result != null ? result.Result.GetHashCode() : LoginResultEnum.Undefined.GetHashCode());
         string logonBrowser = context.LogonBrowser;
         if (!string.IsNullOrEmpty(logonBrowser))
         {
             if (logonBrowser.Length > 255)
             {
                 logger.Error(string.Format("Max LogonBrowser length (255) is reached for following UserAgent : {0} \n InitialSessionId : {1} \n UserID: {2}", logonBrowser, context.InitialSessionID, context.UserID));
                 logonBrowser = logonBrowser.Substring(0, 255);
             }
         }
         if (string.IsNullOrEmpty(ConfigurationParametersPresenter.Instance["AllowedLoginTypesForLogonBrowserLogging"]) ||
             ConfigurationParametersPresenter.Instance["AllowedLoginTypesForLogonBrowserLogging"].Split(',').ToList().Contains(history.LoginResult.ToString()))
         {
             history.LogonBrowser = logonBrowser;
         }
         history.LoginDate           = DateTime.Now;
         history.IsLogonDeviceMobile = Utils.IsMobileBrowser(context.LogonBrowser);
         if (LoggingManager.AsyncLoggingEnabled && ConfigurationParametersPresenter.Instance["UserLogonHistoryAsyncLoggingEnabled"].ToBoolean())
         {
             QueueHelper.Enqueue(history, ConfigReader.DefaultLogMessageQueuePath);
         }
         else
         {
             using (VeriBranchDataEntities dataEntities = new VeriBranchDataEntities())
             {
                 dataEntities.VpUserLogonHistory.Add(history);
                 dataEntities.SaveChanges();
             }
         }
     }
 }
Esempio n. 15
0
        public string Post([FromBody] RequestPayload requestMessage)
        {
            try
            {
                contextProvider.SetContext(requestMessage.Context);
                FlowConfiguration configuration = flowConfigurationProvider.GetConfiguration(requestMessage.Action);
                ValidationHelper.ExecuteValidations(configuration, requestMessage.Request);
                BaseResponse    response        = flowProvider.ExecuteFlow(serviceProvider, requestMessage.Action, requestMessage.Request);
                ResponsePayload responseMessage = new ResponsePayload
                {
                    Context  = contextProvider.GetContext(),
                    Response = response
                };

                return(responseMessage.ToJson());
            }
            catch (Exception e)
            {
                try
                {
                    JMResult result  = serviceProvider.GetRequiredService <IExceptionHandler>().HandleException(e);
                    Context  context = contextProvider.GetContext();
                    context.ActiveResult = result;
                    return(new ResponsePayload
                    {
                        Context = context,
                        Response = null
                    }.ToJson());
                }
                catch (Exception innerException)
                {
                    DefaultLogger.Error(innerException);
                    return(new ResponsePayload().ToJson());
                }
            }
        }
 protected void btnExport_OnClick(object sender, EventArgs e)
 {
     var defaultLogger = new DefaultLogger();
     DownloadStatus(null);
     try
     {
         new Exporters.Exporter(new ExportSettings
         {
             ExportProducts = cbExportProducts.Checked,
             CmsProvider = new SitecoreProvider()
         }, Helper.SyncDataPath, defaultLogger).Export();
     }
     catch (Exception ex)
     {
         defaultLogger.Error(ex, "An unexpected error occurred during export");
     }
     if (defaultLogger.HasError)
     {
         ExportStatus(string.Format("An error occorred - see log file ({0}) for details.",
             WriteLog("export error", defaultLogger)));
     }
     else
         ExportStatus("Export completed.");
 }
 private void LogError(Guid guid, Exception e)
 {
     logger.Error("Error on handling request. Error id: " + guid + Environment.NewLine + e.ToString(), e);
 }
Esempio n. 18
0
 /// <summary>
 /// redis类库错误
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private static void MuxerInternalError(Object sender, InternalErrorEventArgs e)
 {
     _consoleLogger.Error("InternalError:Message" + e.Exception.Message);
 }