Example #1
0
 /// <summary>
 /// Informations the specified MSG.
 /// </summary>
 /// <param name="msg">The MSG.</param>
 /// <param name="values">The values.</param>
 public static void Info(object msg, params object[] values)
 {
     Task.Factory.StartNew(async() =>
     {
         await Task.Delay(100);
         try
         {
             string finalResult = string.Empty;
             foreach (var item in values)
             {
                 finalResult += item.GetType().Name + "=" + JsonConvert.SerializeObject(item);
             }
             Log.Info("WCF - " + msg + ", " + finalResult);
         }
         catch (Exception exception)
         {
             Guid handlingInstanceId      = Guid.NewGuid();
             BusinessExceptionError model = new BusinessExceptionError()
             {
                 ActivityID               = handlingInstanceId,
                 Message                  = exception.Message,
                 StackTrace               = exception.StackTrace,
                 InnerExceptionMessage    = exception.InnerException != null ? exception.InnerException.Message : string.Empty,
                 InnerExceptionStackTrace = exception.InnerException != null ? exception.InnerException.StackTrace : string.Empty
             };
             ErrorLogging.LogError("Logger.Info", "HandleException", "Error ID:" + handlingInstanceId, exception);
         }
     });
 }
Example #2
0
 /// <summary>
 /// Handles the exception.
 /// </summary>
 /// <param name="exception">The exception.</param>
 /// <param name="handlingInstanceId">The handling instance id.</param>
 /// <returns>exception object</returns>
 public Exception HandleException(Exception exception, Guid handlingInstanceId)
 {
     if (exception != null)
     {
         //Explicitly add Logging/ErrorLog ExceptionSheilding
         BusinessExceptionError model = new BusinessExceptionError()
         {
             ActivityID               = handlingInstanceId,
             Message                  = exception.Message,
             StackTrace               = exception.StackTrace,
             InnerExceptionMessage    = exception.InnerException != null ? exception.InnerException.Message : string.Empty,
             InnerExceptionStackTrace = exception.InnerException != null ? exception.InnerException.StackTrace : string.Empty
         };
         ErrorLogging.LogError(GetType().Name, "HandleException", "Error ID:" + handlingInstanceId, exception);
         return(new FaultContractWrapperException(model, handlingInstanceId));
     }
     else
     {
         return(exception);
     }
 }
Example #3
0
 /// <summary>
 /// Calls the specified delegate function.
 /// </summary>
 /// <param name="delegateFunction">The delegate function.</param>
 /// <param name="taskDelay">The task delay.</param>
 /// <param name="isAsync">if set to <c>true</c> [is asynchronous].</param>
 /// <returns>
 /// Task Object
 /// </returns>
 public static Task Call(Action <object> delegateFunction, int taskDelay = 100, bool isAsync = true)
 {
     // BELDataAccessLayer helper = new BELDataAccessLayer();
     isAsync = BELDataAccessLayer.Instance.GetConfigVariable("AllowAsync").ToLower().Equals("true") ? isAsync : false;
     if (isAsync)
     {
         return(Task.Factory.StartNew(async() =>
         {
             await Task.Delay(taskDelay);
             try
             {
                 delegateFunction(new object());
             }
             catch (Exception exception)
             {
                 Guid handlingInstanceId = Guid.NewGuid();
                 BusinessExceptionError model = new BusinessExceptionError()
                 {
                     ActivityID = handlingInstanceId,
                     Message = exception.Message,
                     StackTrace = exception.StackTrace,
                     InnerExceptionMessage = exception.InnerException != null ? exception.InnerException.Message : string.Empty,
                     InnerExceptionStackTrace = exception.InnerException != null ? exception.InnerException.StackTrace : string.Empty
                 };
                 ErrorLogging.LogError(delegateFunction.GetType().Name, "HandleException", "Error ID:" + handlingInstanceId, exception);
             }
         }));
     }
     else
     {
         if (delegateFunction != null)
         {
             delegateFunction(new object());
         }
         return(null);
     }
 }