ResultToFileModel resultToFile = new ResultToFileModel(); try { resultToFile.errors.Add(new ErrorModel { CrDatTime = CommonHandler.ConvertDatetime_UTCtoEST(), LogLevel = LogLevel.Information.ToString(), MsgDetails = "please check your email", SourceMethodName = "Service Initiated" }); } catch (Exception ex) { resultToFile.errors.Add(new ErrorModel { CrDatTime = CommonHandler.ConvertDatetime_UTCtoEST(), LogLevel = LogLevel.Error.ToString(), MsgDetails = ex.Message, SourceMethodName = ex.TargetSite.Name }); string projectLogFolder = Environment.GetEnvironmentVariable("projectLogFolder"); while (ex.InnerException != null) { ex = ex.InnerException; foreach (DictionaryEntry de in ex.Data) { resultToFile.errors.Add(new ErrorModel { CrDatTime = CommonHandler.ConvertDatetime_UTCtoEST(), LogLevel = LogLevel.Error.ToString(), MsgDetails = " Error Description - Key: " + de.Key + " Value: " + de.Value, SourceMethodName = ex.TargetSite.Name, JsonErrMessage = ex.Message }); } } string localFileName = string.Empty; if (resultToFile.errors.Exists(t => t.LogLevel == LogLevel.Error.ToString())) { localFileName = resultToFile.fileNameToSave + "_error." + "csv"; } else { localFileName = resultToFile.fileNameToSave + "_success." + "csv"; } string keyName = projectLogFolder + "/" + localFileName; SendMail.SendMailMessage(keyName); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)