private static void Print(string method , string msg) { ErrorLogs.PrintError("ProductService" , method , msg); }
public bool AddErrorLog(string className, string methodName, string message, string innerException) { try { ErrorLogs log = new ErrorLogs(); log.ClassName = className; log.MethodName = methodName; log.Message = message; log.InnerException = innerException; log.LogDate = DateTime.Now; DBModel.ErrorLogs.Add(log); int result = DBModel.SaveChanges(); if (result > 0) { return(true); } else { return(false); } } catch (Exception ex) { return(false); } }
private static void Print(string method , string msg) { ErrorLogs.PrintError("CategoryService" , method , msg); }
private void LogDbEntityValidationException(DbEntityValidationException ex) { var errorMessage = new StringBuilder(); foreach (var entityValidationError in ex.EntityValidationErrors) { errorMessage.AppendLine( $"Entity of type \"{entityValidationError.Entry.Entity.GetType().Name}\" in state \"{entityValidationError.Entry.State}\" has the following validation errors:"); foreach (var ve in entityValidationError.ValidationErrors) { errorMessage.AppendLine( $" - Property: \"{ve.PropertyName}\", Value: \"{entityValidationError.Entry.CurrentValues.GetValue<object>(ve.PropertyName)}\", Error: \"{ve.ErrorMessage}\""); } } var log = new ErrorLogs { Message = errorMessage.ToString(), CallStack = ex.StackTrace, Date = DateTime.Now, Source = ex.Source }; _context.ErrorLogs.Add(log); _context.SaveChanges(); }
public async Task <object> Save([FromBody] ErrorLogs ErrorLog) { try { EFHelper <ErrorLogs> eFHelper = new EFHelper <ErrorLogs>(); ErrorLog.ApplyTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); eFHelper.Add(ErrorLog); //钉钉推送超管 string[] SaIds = System.Configuration.ConfigurationManager.AppSettings["administrator"].Split(','); DingTalkServersController dingTalkServersController = new DingTalkServersController(); foreach (var SaId in SaIds) { await dingTalkServersController.sendOaMessage(SaId, "报错反馈", "系统报错", "eapp://util/errorPage/errorPage"); } return(new NewErrorModel() { error = new Error(0, "保存成功!", "") { }, }); } catch (Exception ex) { throw ex; } }
private void RefreshErrorLogs(IEnumerable <ErrorLogEntity> logs) { foreach (var log in logs) { ErrorLogs.Insert(0, new ErrorLogModel(log)); } }
public frmStocks() { _errorLogs = new ErrorLogs(); _repoProduct = new ProductRepo(); _repoStock = new StockRepo(); InitializeComponent(); }
public Login() { // _errorLogs = new ErrorLogs(); _repoLogin = new LoginRepo(); _crypt = new Cryptography(); InitializeComponent(); }
public frmRegistration() { _errorLogs = new ErrorLogs(); _userTypeRepo = new UserTypeRepo(); _repoLogin = new LoginRepo(); _crypt = new Cryptography(); InitializeComponent(); }
private static void SaveLog(LogData logData) { if (logData.LogClassification == LogClassificationTypes.Error) { ErrorLogs.Add(logData); } Logs.Add(logData); }
public void AddLog(ErrorLogModel errorLogModel) { ErrorLogs _errorLogs = new ErrorLogs(); _errorLogs = Mapper.Map <ErrorLogModel, ErrorLogs>(errorLogModel); _context.ErrorLogs.Add(_errorLogs); _context.SaveChanges(); }
public ErrorLogs GetWorkflowErrors() { ErrorLogCriteriaFilter filter = new ErrorLogCriteriaFilter(); filter.AddRegularFilter(ErrorLogFields.Date, Comparison.GreaterOrEquals, DateTime.Now.Date); ErrorLogs errorLogs = _server.GetErrorLogs(_server.GetErrorProfile("All").ID, filter); return(errorLogs); }
public frmInvoice() { _errorLogs = new ErrorLogs(); _repoProduct = new ProductRepo(); _repoInvoice = new InvoiceRepo(); _repoStock = new StockRepo(); _vmInvoice = new InvoiceViewModel(); InitializeComponent(); }
public async Task <GenericResponseModel <AccountResetPasswordModel> > ResetPassword(Guid id) { return(await Task.Run(async() => { AccountResetPasswordModel details = new AccountResetPasswordModel(); try { ErrorCode = "800.94"; if (id == Guid.Empty) { ErrorCode = "800.941"; throw new Exception("Invalid reference parameter"); } Account account = await accountService.AccountResetPassword(id); string token = account.RoleId.ToString() + "-" + account.DateUpdated.Value.ToString("yyddMM") + "_" + Checker.NumberExtractor(account.Id.ToString()) + "-" + account.AccountInformationId.ToString(); string url = appConfigManager.AppSetting <string>("AdminResetPasswordURL", true, new AppConfigSettingsModel { Value = "https:\\\\localhost:9909\\Admin\\Token\\ForgotPassword?userAccess=", Group = "Admin" }); url += token; bool isSend = await accountService.AccountEmail(account, "XPay.World Reset Password", url); details = new AccountResetPasswordModel { Username = account.Username, IsSend = isSend, IsChange = true, Message = "Success" }; } catch (Exception ex) { string message = ex.Message + (!string.IsNullOrEmpty(ex.InnerException.Message) && ex.Message != ex.InnerException.Message ? " Reason : " + ex.InnerException.Message : string.Empty); ErrorDetails.Add(message); ErrorMessage = message; MethodBase methodBase = MethodBase.GetCurrentMethod(); StackTrace trace = new StackTrace(ex, true); string sourceFile = trace.GetFrame(0).GetFileName(); await ErrorLogs.Write(new ErrorLogsModel { Application = Assembly.GetExecutingAssembly().GetName().Name, Controller = GetType().Name, CurrentAction = methodBase.Name.Split('>')[0].TrimStart('<'), ErrorCode = ErrorCode, Message = message, SourceFile = sourceFile, LineNumber = trace.GetFrame(0).GetFileLineNumber(), StackTrace = ex.ToString(), Method = methodBase.Name.Split('>')[0].TrimStart('<') }, ex); details = new AccountResetPasswordModel { IsSend = false, Message = message, IsChange = false, Username = string.Empty }; } return new GenericResponseModel <AccountResetPasswordModel>() { Code = string.IsNullOrEmpty(ErrorMessage) ? Utilities.Enums.CodeStatus.Success : Utilities.Enums.CodeStatus.Error, CodeStatus = string.IsNullOrEmpty(ErrorMessage) ? Utilities.Enums.CodeStatus.Success.ToString() : Utilities.Enums.CodeStatus.Error.ToString(), ReferenceObject = string.IsNullOrEmpty(ErrorMessage) ? details : null, ErrorMessage = string.IsNullOrEmpty(ErrorMessage) ? null : new ErrorMessage { Details = ErrorDetails, ErrNumber = ErrorCode, Message = ErrorMessage } }; })); }
public async Task <GenericResponseModel <RoleModel> > Save([FromBody] RoleModel viewModel) { return(await Task.Run(async() => { Role role = new Role(); ErrorCode = "800.4"; try { var roles = Service.GetAll().ToList(); if (roles != null) { if (roles.Count > 0) { if (roles.Where(a => a.Name.ToLower() == viewModel.Name.ToLower()).FirstOrDefault() != null) { ErrorCode = "800.41"; throw new Exception(viewModel.Name + " was already exist!"); } } } role = new Role { Name = viewModel.Name, Order = viewModel.Order }; role = await Service.SaveReturnAsync(role); viewModel.Id = role.Id; viewModel.DateCreated = role.DateCreated; } catch (Exception ex) { string message = ex.Message + (ex.InnerException != null && !string.IsNullOrEmpty(ex.InnerException.Message) && ex.Message != ex.InnerException.Message ? " Reason : " + ex.InnerException.Message : string.Empty); ErrorDetails.Add(message); ErrorMessage = message; MethodBase m = MethodBase.GetCurrentMethod(); StackTrace trace = new StackTrace(ex, true); string sourceFile = trace.GetFrame(0).GetFileName(); await ErrorLogs.Write(new ErrorLogsModel { Application = Assembly.GetExecutingAssembly().GetName().Name, Controller = GetType().Name, CurrentAction = m.Name.Split('>')[0].TrimStart('<'), ErrorCode = ErrorCode, Message = message, SourceFile = sourceFile, LineNumber = trace.GetFrame(0).GetFileLineNumber(), StackTrace = ex.ToString(), Method = m.Name.Split('>')[0].TrimStart('<') }, ex); } return new GenericResponseModel <RoleModel>() { Code = string.IsNullOrEmpty(ErrorMessage) ? Utilities.Enums.CodeStatus.Success : Utilities.Enums.CodeStatus.Error, CodeStatus = string.IsNullOrEmpty(ErrorMessage) ? Utilities.Enums.CodeStatus.Success.ToString() : Utilities.Enums.CodeStatus.Error.ToString(), ReferenceObject = string.IsNullOrEmpty(ErrorMessage) ? viewModel : null, ErrorMessage = string.IsNullOrEmpty(ErrorMessage) ? null : new ErrorMessage { Details = ErrorDetails, ErrNumber = ErrorCode, Message = ErrorMessage } }; })); }
/// <summary> /// For inserting exceptions in the ErrorLogs table /// </summary> /// <param name="ex"></param> /// <param name="controllerName"></param> /// <param name="methodName"></param> public void InsertExceptionDetails(Exception ex, string controllerName, string methodName) { ErrorLogs objErrorLogs = new ErrorLogs(); objErrorLogs.CreatedDate = DateTime.Now; objErrorLogs.ErrorFrom = "ControllerName: " + controllerName + ", MethodName: " + methodName + ""; objErrorLogs.ErrorMessage = ex.Message; objErrorLogs.InnerException = (!string.IsNullOrEmpty(Convert.ToString(ex.InnerException)) ? ex.InnerException.ToString() : ""); dbContext.ErrorLogs.Add(objErrorLogs); dbContext.SaveChanges(); }
void Start() { Instance = this; btnClose.onClick.AddListener(Btn_Close); Hide(true); Tracer.OnTraceError += (message) => { audioMan.Play(SFX_UI.Invalid); Show(message == null ? "*null*" : message.ToString()); }; }
protected void Page_Load(object sender, EventArgs e) { try { //get the signed document from echo sign and send info to tandem api if (Session["childKey"] != null && Session["pifXML"] != null) { string childKey = Session["childKey"].ToString(); EchoSignDocumentService17PortTypeClient ES = new EchoSignDocumentService17PortTypeClient(); GetFormDataResult sss = ES.getFormData(ConfigurationManager.AppSettings["APIKey"], childKey); string[] latestDoc = sss.formDataCsv.ToString().Split(','); byte[] data = ES.getLatestDocument(ConfigurationManager.AppSettings["APIKey"], latestDoc[14].Replace("\"", "").Replace("\n", "")); string base64String; base64String = System.Convert.ToBase64String(data, 0, data.Length); XmlDocument doc = new XmlDocument(); doc.LoadXml(Session["pifXML"].ToString()); doc.SelectSingleNode("descendant::Document/SignedDocument/Content").InnerText = base64String; TandemIntegrationClient objClient = new TandemIntegrationClient(); string msg = objClient.ReceiveXMLMessage(doc.OuterXml.Replace("<?xml version=\"1.0\" encoding=\"utf-8\"?>", "")); if (msg.ToLower() == "success") { thanksMSG.Visible = true; } else { errorMsg.Visible = true; lblError.Text = "Error processing your request. Please try after some time."; ErrorLogs.SendErrorMail(msg, Request.Url.ToString()); } } else { errorMsg.Visible = true; } Session.Clear(); Session.Abandon(); } catch (Exception ex) { errorMsg.Visible = true; lblError.Text = "Error processing your request. Please try after some time."; if ((ex is System.Threading.ThreadAbortException)) { return; } else { ErrorLogs.SendErrorMail(ex.Message, Request.Url.ToString()); } } }
public static async Task <ErrorLogs> LogError(BitcornContext dbContext, Exception e, string code = null) { var logEntry = new ErrorLogs(); logEntry.Message = e.Message; logEntry.Application = "BITCORNService"; logEntry.Code = code; logEntry.StackTrace = e.StackTrace; logEntry.Timestamp = DateTime.Now; dbContext.ErrorLogs.Add(logEntry); await dbContext.SaveChangesAsync(); return(logEntry); }
public override void OnException(ExceptionContext context) { var errorSummary = new ErrorLogs { ErrorCode = StatusCodes.Status500InternalServerError, Message = "Exception: " + context.Exception.Message + " occurred in " + context.ActionDescriptor }; _log.LogError(errorSummary.Message); context.Result = new JsonResult(errorSummary) { StatusCode = StatusCodes.Status500InternalServerError }; }
public async Task <bool> AddError(Exception objEx) { StackTrace stackTrace = new StackTrace(); ErrorLogs errorLogs = new ErrorLogs { ErrorLog = objEx.ToString(), FunctionName = stackTrace.GetFrame(1).GetMethod().Name, ModuleName = "BLL/" + this.GetType().Name, }; this.unitOfWork.ErrorLogsRepository.Insert(errorLogs); await this.unitOfWork.SaveChangeAsync(); return(true); }
public void LogMe() { try { ErrorLogs err = new ErrorLogs(); err.CreateDate = DateTime.Now; err.UserLoginID = LoginUserID; err.LogMsg = LogMessage; ErrorLogsRepo errRepo = new ErrorLogsRepo(); errRepo.Insert(err); } catch (Exception ex) { } }
public void LogError(string errorName, string ErrorValue, string ErrorCode) { using (var Context = new IgorMarkivMessengerDBEntities()) { ErrorLogs errorLogs = new ErrorLogs { errorName = errorName, errorValue = ErrorValue, errorCode = ErrorCode, DateTime = DateTime.UtcNow }; Context.ErrorLogs.Add(errorLogs); Context.SaveChanges(); } }
public async Task <bool> Post([FromBody] ErrorLogs data) { try { _dbContext.ErrorLogs.Add(data); await _dbContext.SaveAsync(); return(true); } catch (Exception e) { await BITCORNLogger.LogError(_dbContext, e, null); return(false); } }
public async Task <GenericResponseModel <AccountForgotPasswordValidationModel> > ForgotPasswordValidation([FromUri] string token) { return(await Task.Run(async() => { var validateModel = new AccountForgotPasswordValidationModel(); try { ErrorCode = "800.91"; var response = await accountService.ForgotPasswordTokenValidator(token); response.Item1.Password = string.Empty; validateModel = new AccountForgotPasswordValidationModel { Username = response.Item1.Username, IsValidated = response.Item2, Message = response.Item3 }; } catch (Exception ex) { string message = ex.Message + (!string.IsNullOrEmpty(ex.InnerException.Message) && ex.Message != ex.InnerException.Message ? " Reason : " + ex.InnerException.Message : string.Empty); ErrorDetails.Add(message); ErrorMessage = message; MethodBase methodBase = MethodBase.GetCurrentMethod(); StackTrace trace = new StackTrace(ex, true); string sourceFile = trace.GetFrame(0).GetFileName(); await ErrorLogs.Write(new ErrorLogsModel { Application = Assembly.GetExecutingAssembly().GetName().Name, Controller = GetType().Name, CurrentAction = methodBase.Name.Split('>')[0].TrimStart('<'), ErrorCode = ErrorCode, Message = message, SourceFile = sourceFile, LineNumber = trace.GetFrame(0).GetFileLineNumber(), StackTrace = ex.ToString(), Method = methodBase.Name.Split('>')[0].TrimStart('<') }, ex); validateModel = new AccountForgotPasswordValidationModel { Username = string.Empty, IsValidated = false, Message = message }; } return new GenericResponseModel <AccountForgotPasswordValidationModel>() { Code = string.IsNullOrEmpty(ErrorMessage) ? Utilities.Enums.CodeStatus.Success : Utilities.Enums.CodeStatus.Error, CodeStatus = string.IsNullOrEmpty(ErrorMessage) ? Utilities.Enums.CodeStatus.Success.ToString() : Utilities.Enums.CodeStatus.Error.ToString(), ReferenceObject = string.IsNullOrEmpty(ErrorMessage) ? validateModel : null, ErrorMessage = string.IsNullOrEmpty(ErrorMessage) ? null : new ErrorMessage { Details = ErrorDetails, ErrNumber = ErrorCode, Message = ErrorMessage } }; })); }
public override void OnException(ExceptionContext context) { var errorSummary = new ErrorLogs { ErrorCode = StatusCodes.Status500InternalServerError, Message = "Exception: " + context.Exception.Message + "Error occurred in " + context.ActionDescriptor, CreateTimestamp = DateTime.Now.ToString(CultureInfo.InvariantCulture) }; _log.LogError(errorSummary.Message); // _errorLogs.InsertOne(errorSummary,_errorLogsCollection); context.Result = new JsonResult(errorSummary) { StatusCode = StatusCodes.Status500InternalServerError }; }
private void RetryProcess() { bool newVersion = base.GetBoolProperty(Constants.SOProperties.ErrorLog.TryNewVersion); int procInstId = base.GetIntProperty(Constants.SOProperties.ErrorLog.ProcessInstanceId, true); base.ServiceBroker.Service.ServiceObjects[0].Properties.InitResultTable(); DataTable results = base.ServiceBroker.ServicePackage.ResultTable; WorkflowManagementServer mngServer = new WorkflowManagementServer(); using (mngServer.CreateConnection()) { mngServer.Open(BaseAPIConnectionString); ErrorProfile all = mngServer.GetErrorProfiles()[0]; ErrorLogCriteriaFilter errorfilter = new ErrorLogCriteriaFilter(); errorfilter.AddRegularFilter(ErrorLogFields.ProcInstID, Comparison.Equals, procInstId); ErrorLogs errors = mngServer.GetErrorLogs(all.ID, errorfilter); if (errors.Count != 1) { throw new ApplicationException(string.Format("Could not retrieve process (with id: {0}). Got {1} results.", procInstId, errors.Count)); } int errorId = errors[0].ID; if (newVersion) { int newVersionNumber = 0; ProcessInstanceCriteriaFilter procFilter = new ProcessInstanceCriteriaFilter(); procFilter.AddRegularFilter(ProcessInstanceFields.ProcInstID, Comparison.Equals, procInstId); ProcessInstances procs = mngServer.GetProcessInstancesAll(procFilter); Processes procesVersions = mngServer.GetProcessVersions(procs[0].ProcSetID); foreach (Process proc in procesVersions) { if (proc.VersionNumber > newVersionNumber) { newVersionNumber = proc.VersionNumber; } } mngServer.SetProcessInstanceVersion(procInstId, newVersionNumber); } mngServer.RetryError(procInstId, errorId, string.Format("Process Retry using {0}", base.ServiceBroker.Service.ServiceObjects[0].Name)); } }
private void LogException(Exception ex) { if (ex != null) { try { var exceptionId = 0; var log = new ErrorLogs { Message = ex.Message, CallStack = ex.StackTrace ?? "", Date = DateTime.Now, Source = ex.Source, ParentErrorId = null }; _context.ErrorLogs.Add(log); _context.SaveChanges(); exceptionId = log.Id; while (ex.InnerException != null) { ex = ex.InnerException; var childrenLog = new ErrorLogs { Message = ex.Message, CallStack = ex.StackTrace, Date = DateTime.Now, Source = ex.Source, ParentErrorId = exceptionId }; _context.ErrorLogs.Add(childrenLog); _context.SaveChanges(); exceptionId = childrenLog.Id; } } catch (Exception) { throw; } } }
private void GetErrors() { string profile = base.GetStringProperty(Constants.SOProperties.ErrorLog.Profile); if (string.IsNullOrEmpty(profile)) { profile = "All"; } base.ServiceBroker.Service.ServiceObjects[0].Properties.InitResultTable(); DataTable results = base.ServiceBroker.ServicePackage.ResultTable; WorkflowManagementServer mngServer = this.ServiceBroker.K2Connection.GetConnection <WorkflowManagementServer>(); using (mngServer.Connection) { ErrorProfile prof = mngServer.GetErrorProfile(profile); if (prof == null) { throw new Exception(string.Format(Resources.ProfileNotFound, profile)); } ErrorLogs errors = mngServer.GetErrorLogs(prof.ID); foreach (ErrorLog e in errors) { DataRow r = results.NewRow(); r[Constants.SOProperties.ErrorLog.ProcessInstanceId] = e.ProcInstID; r[Constants.SOProperties.ErrorLog.ProcessName] = e.ProcessName; r[Constants.SOProperties.ErrorLog.Folio] = e.Folio; r[Constants.SOProperties.ErrorLog.ErrorDescription] = e.Description; r[Constants.SOProperties.ErrorLog.ErrorItem] = e.ErrorItemName; r[Constants.SOProperties.ErrorLog.ErrorDate] = e.ErrorDate; r[Constants.SOProperties.ErrorLog.ErrorId] = e.ID; r[Constants.SOProperties.ErrorLog.TypeDescription] = e.TypeDescription; r[Constants.SOProperties.ErrorLog.ExecutingProcId] = e.ExecutingProcID; r[Constants.SOProperties.ErrorLog.StackTrace] = e.StackTrace; results.Rows.Add(r); } } }
/* * SendSpyOpToChannel * * Purpose: * This method handles incomming SpyOps as well as !cty.op bot command to send Countries Spy Op Data to the Channel requested * */ public async void SendSpyOpToChannel(SpyOpInfo op, Channel chan) { try { if (chan == null) { await frmDiscordBot.Bot.channels.chanSpyops.SendMessage(op.GetSpyOpMessage()); } else { await chan.SendMessage(op.GetSpyOpMessage()); } // TO DO: // Later we can add relation detection, if relation is detected display a warnign message to user. } catch (Exception c) { ErrorLogs.SaveErrorToXML(new BotError(c)); } }
internal void FetchErrorLogs(ErrorLogs ErrorLog, SafeDataReader dr) { ErrorLog.UserName = dr.GetString("UserName"); ErrorLog.PageName = dr.GetString("PageName"); ErrorLog.ErrorTime = dr.GetDateTime("ErrorTime").ToString("dd MMM yyyy hh:mm:ss tt"); ErrorLog.Browser = dr.GetString("Browser"); ErrorLog.IPAddress = dr.GetString("IPAddress"); ErrorLog.ErrorMessage = dr.GetString("ErrorMessage"); }
/// <summary> /// Created By : Pavan /// Created Date : 30 June 2015 /// Modified By : /// Modified Date : /// </summary> /// <returns>Error Log List</returns> public static List<ErrorLogs> GetErrorLogs() { List<ErrorLogs> ErrLogs = new List<ErrorLogs>(); System.Diagnostics.StackFrame stackFrame = new System.Diagnostics.StackFrame(); System.Reflection.MethodBase methodBase = stackFrame.GetMethod(); log.Debug("Start: " + methodBase.Name); var reader = SqlHelper.ExecuteReader(ConnectionUtility.GetConnectionString(), CommandType.StoredProcedure, "SPGetErrorLogDetails"); var safe = new SafeDataReader(reader); while (reader.Read()) { var ErrorLog = new ErrorLogs(); ErrorLog.FetchErrorLogs(ErrorLog, safe); ErrLogs.Add(ErrorLog); } log.Debug("End: " + methodBase.Name); return ErrLogs; }