public static bool AddInformationLogInDataBase(InformationLog data, IdentifyClass userId = null, IdentifyClass dataId = null) { try { LogUserData logData = new LogUserData(data, dataId, userId); LogUserDataRoot logDataRoot = new LogUserDataRoot(logData); var res = logDataRoot.Save(); if (res.Status == OperationStatusEnum.Failed) { return(false); } return(true); } catch (Exception ex) { try { AddInformationLogInFile(new InformationLog(ex)); AddInformationLogInFile(data, userId, dataId); return(false); } catch (Exception ex2) { return(false); } } }
protected static void AddStaticExceptionData(Exception ex, IdentifyClass dataId = null) { if (_staticExceptionDataList == null) { _staticExceptionDataList = new List <Exception>(); } _staticExceptionDataList.Add(ex); ThisAppContext.AddLogInDb(ex, dataId); }
public static bool AddInformationLogInFile(InformationLog data, IdentifyClass userId = null, IdentifyClass dataId = null) { try { if (data == null) { return(false); } if (!Directory.Exists(GetApplicationLogFileRoot())) { return(false); } var fileAddress = GetApplicationLogFileRoot() + "/" + GetLogFileName() + ".MCMSLog"; var message = ""; message += "UserId : " + (userId?.ToString() ?? "NULL") + Environment.NewLine; message += "dataId : " + (dataId?.ToString() ?? "NULL") + Environment.NewLine; message += "----------------- Message Header -----------------------" + Environment.NewLine; message += data.PrintLong() + Environment.NewLine; message += "----------------- Message Body -----------------------" + Environment.NewLine; message += "->->-> " + data.SerializeObject().Replace(InformationLog.Seprator, "." + Environment.NewLine + "->->-> ") + Environment.NewLine; message += "----------------- End Of Message ----------------------" + Environment.NewLine; using (var writer = new StreamWriter(fileAddress, true)) { writer.Write(message); } return(true); } catch (Exception ex) { return(false); } }