private questStatus read(PWTrackerLoggingEntities dbContext, LogId logId, out Quest.Services.Dbio.PWTrackerLogging.Logs log) { // Initialize log = null; try { log = dbContext.Logs.Where(r => r.Id == logId.Id).SingleOrDefault(); if (log == null) { return(new questStatus(Severity.Error, String.Format("ERROR: {0}.{1}: {2}", this.GetType().Name, MethodBase.GetCurrentMethod().Name, String.Format("Id {0} not found", logId.Id)))); } } catch (DbEntityValidationException ex) { // Retrieve the error messages as a list of strings. var errorMessages = ex.EntityValidationErrors.SelectMany(x => x.ValidationErrors).Select(x => x.ErrorMessage); String fullErrorMessage = string.Join("; ", errorMessages); String exceptionMessage = string.Concat(ex.Message, " The DbEntityValidationException errors are: ", fullErrorMessage); return(new questStatus(Severity.Fatal, String.Format("EXCEPTION: {0}.{1}: {2}", this.GetType().Name, MethodBase.GetCurrentMethod().Name, exceptionMessage))); } catch (System.Exception ex) { return(new questStatus(Severity.Fatal, String.Format("EXCEPTION: {0}.{1}: {2}", this.GetType().Name, MethodBase.GetCurrentMethod().Name, ex.InnerException != null ? ex.InnerException.Message : ex.Message))); } return(new questStatus(Severity.Success)); }
private questStatus update(PWTrackerLoggingEntities dbContext, Log log) { // Initialize questStatus status = null; try { // Read the record. LogId logId = new LogId(log.Id); Quest.Services.Dbio.PWTrackerLogging.Logs _log = null; status = read(dbContext, logId, out _log); if (!questStatusDef.IsSuccess(status)) { return(status); } // Update the record. BufferMgr.TransferBuffer(log, _log); dbContext.SaveChanges(); } catch (DbEntityValidationException ex) { // Retrieve the error messages as a list of strings. var errorMessages = ex.EntityValidationErrors.SelectMany(x => x.ValidationErrors).Select(x => x.ErrorMessage); String fullErrorMessage = string.Join("; ", errorMessages); String exceptionMessage = string.Concat(ex.Message, " The DbEntityValidationException errors are: ", fullErrorMessage); return(new questStatus(Severity.Fatal, String.Format("EXCEPTION: {0}.{1}: {2}", this.GetType().Name, MethodBase.GetCurrentMethod().Name, exceptionMessage))); } catch (System.Exception ex) { return(new questStatus(Severity.Fatal, String.Format("EXCEPTION: {0}.{1}: {2}", this.GetType().Name, MethodBase.GetCurrentMethod().Name, ex.InnerException != null ? ex.InnerException.Message : ex.Message))); } return(new questStatus(Severity.Success)); }
public questStatus Read(DbMgrTransaction trans, LogId logId, out Log log) { // Initialize questStatus status = null; log = null; // Perform read. using (PWTrackerLoggingEntities dbContext = new PWTrackerLoggingEntities()) { Quest.Services.Dbio.PWTrackerLogging.Logs _log = null; status = read((PWTrackerLoggingEntities)trans.DbContext, logId, out _log); if (!questStatusDef.IsSuccess(status)) { return(status); } log = new Log(); BufferMgr.TransferBuffer(_log, log); } return(new questStatus(Severity.Success)); }
/*---------------------------------------------------------------------------------------------------------------------------------- * Logs *---------------------------------------------------------------------------------------------------------------------------------*/ private questStatus create(PWTrackerLoggingEntities dbContext, Log log, out LogId logId) { // Initialize logId = null; // Perform create try { Quest.Services.Dbio.PWTrackerLogging.Logs _log = new Quest.Services.Dbio.PWTrackerLogging.Logs(); BufferMgr.TransferBuffer(log, _log); dbContext.Logs.Add(_log); dbContext.SaveChanges(); if (_log.Id == 0) { return(new questStatus(Severity.Error, "Log not created")); } logId = new LogId(_log.Id); } catch (DbEntityValidationException ex) { // Retrieve the error messages as a list of strings. var errorMessages = ex.EntityValidationErrors.SelectMany(x => x.ValidationErrors).Select(x => x.ErrorMessage); String fullErrorMessage = string.Join("; ", errorMessages); String exceptionMessage = string.Concat(ex.Message, " The DbEntityValidationException errors are: ", fullErrorMessage); return(new questStatus(Severity.Fatal, String.Format("EXCEPTION: {0}.{1}: {2}", this.GetType().Name, MethodBase.GetCurrentMethod().Name, exceptionMessage))); } catch (System.Exception ex) { return(new questStatus(Severity.Fatal, String.Format("EXCEPTION: {0}.{1}: {2}", this.GetType().Name, MethodBase.GetCurrentMethod().Name, ex.InnerException != null ? ex.InnerException.Message : ex.Message))); } return(new questStatus(Severity.Success)); }