/// <summary>
 /// Deprecated Method for adding a new object to the ErrorLogs EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToErrorLogs(ErrorLog errorLog)
 {
     base.AddObject("ErrorLogs", errorLog);
 }
Exemple #2
0
        private static void WriteEntryEventLog(string LocationName, string MethodName, string ErroMessage, Exception ex, bool SendSMSAlert, bool SendEmailAlert, EventLogEntryType type = EventLogEntryType.Error)
        {
            try
            {
                String Message = "";
                Message += ex + "<BR>";
                while (ex != null && ex.InnerException != null)
                {
                    ex = ex.InnerException;
                    Message += ex + "<BR>";
                }


                ErrorLog Log = new ErrorLog
                                   {
                                       LogId = Guid.NewGuid(),
                                       Location = LocationName,
                                       MethodName = MethodName,
                                       ErrorDescription = ErroMessage + "<***\r\n***>" + Message,
                                       ErrorType = (int)type,
                                       LogDateTime = DateTime.Now
                                   };
                WriteErrorToDB(Log);
                ConsolWrite(ex, ErroMessage, ConsoleColor.Green);

                if (SendSMSAlert)
                {
                    //foreach (var number in eChargeCardAdminNumbers)
                     //   SMSMagfaHelper.SendSMS(number, "خطا در سيستم شارژ" + ErroMessage);
                }

                if (SendEmailAlert)
                {
                    SendEmail("*****@*****.**", eChargeCardAdminEmails, "پيام هشداري سيستم ",Log.ErrorDescription);
                }
            }
            catch
            {
            }
        }
 /// <summary>
 /// Create a new ErrorLog object.
 /// </summary>
 /// <param name="logId">Initial value of the LogId property.</param>
 /// <param name="location">Initial value of the Location property.</param>
 /// <param name="methodName">Initial value of the MethodName property.</param>
 /// <param name="errorDescription">Initial value of the ErrorDescription property.</param>
 /// <param name="errorType">Initial value of the ErrorType property.</param>
 /// <param name="logDateTime">Initial value of the LogDateTime property.</param>
 public static ErrorLog CreateErrorLog(global::System.Guid logId, global::System.String location, global::System.String methodName, global::System.String errorDescription, global::System.Int32 errorType, global::System.DateTime logDateTime)
 {
     ErrorLog errorLog = new ErrorLog();
     errorLog.LogId = logId;
     errorLog.Location = location;
     errorLog.MethodName = methodName;
     errorLog.ErrorDescription = errorDescription;
     errorLog.ErrorType = errorType;
     errorLog.LogDateTime = logDateTime;
     return errorLog;
 }
Exemple #4
0
 private static void WriteErrorToDB(ErrorLog log)
 {
     string cnnString = CreateEntitiesConnectionString();
     using (BMIKidsEntities ctx = new BMIKidsEntities(cnnString))
     {
         ctx.ErrorLogs.AddObject(log);
         ctx.SaveChanges();
         ctx.AcceptAllChanges();
     }
 }