Exemple #1
0
 public void LogErrorToDb(ErrorLogProp errorProp)
 {
     try
     {
         CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "Called {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));
         ErrorLogDAL objErrorLogDAL = new ErrorLogDAL();
         objErrorLogDAL.LogErrorToDb(errorProp);
     }
     catch (Exception e)
     {
         CommonDAL.logger.LogError(typeof(string), e);
     }
     finally
     {
         CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "Called {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));
     }
 }
Exemple #2
0
 public static void LogErrorToDb(Exception ex)
 {
     try
     {
         ErrorLogProp errorProp = new ErrorLogProp();
         System.Diagnostics.StackTrace trace = new System.Diagnostics.StackTrace(ex, true);
         //string message = ex.GetType().ToString()+ex.StackTrace.ToString();
         errorProp.Message      = string.Format("{0}: {1} \n{2}", ex.GetType().ToString(), ex.Message, ex.StackTrace.ToString());
         errorProp.Logger       = trace.GetFrame(0).GetMethod().ReflectedType.FullName;
         errorProp.Thread       = trace.FrameCount.ToString();
         errorProp.SystemMac    = string.Format("PC Name: {0}   Mac Address: {1}", Environment.MachineName, GetMACAddress());
         errorProp.BuildVersion = ConfigurationManager.AppSettings["CurrentApplicationVersion"].ToString();
         _serviceInstance.LogErrorToDb(errorProp);
     }
     catch (Exception e)
     {
     }
 }
Exemple #3
0
        public void LogErrorToDb(ErrorLogProp errorProp)
        {
            try
            {
                using (PortStorageEntities objAppWorksEntities = new PortStorageEntities())
                {
                    CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "Called {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));

                    objAppWorksEntities.ErrorLogs.Add(new ErrorLog {
                        SystemMac = errorProp.SystemMac, DateTime = DateTime.Now, Message = errorProp.Message, Level = "ERROR", Logger = errorProp.Logger, Thread = errorProp.Thread, BuildVersion = errorProp.BuildVersion
                    });
                    objAppWorksEntities.SaveChanges();
                }
            }
            catch (Exception e)
            {
                CommonDAL.logger.LogError(typeof(string), e);
            }
            finally
            {
                CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "End {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));
            }
        }