public ActionResult UploadResult() { UploadStatus status = SlickUpload.GetUploadStatus(); decimal totalCount = (decimal)status.GetUploadedFiles().Count; if (status != null && status.State == UploadState.Complete && 0 < totalCount) { //Post Processing Step: Update Screen to 0% Done UpdateProgressBarOnScreen(status, 0, false); //At this point, we know the file has been uploaded to the server //I think we can just kick off an async process to do the rest. ProcessTask processTask = new ProcessTask(this.PostProcessVideo); processTask.BeginInvoke(status, totalCount, null, processTask); UpdateProgressBarOnScreen(status, COMPLETE_PERCENTAGE, true); } else { ErrorLogRepository errorRepos = new ErrorLogRepository(); errorRepos.SaveErrorToDB(null, "Video upload had issues. Upload Status = " + status.State.ToString() + " totalCount = " + totalCount.ToString() + ": " + Environment.NewLine + status.Reason + Environment.NewLine + status.ErrorMessage, User.Identity.Name); return(View("UploadFiles", new VideoUploadFilesViewModel(User.Identity.Name, status))); } return(RedirectToAction("UploadPending", new { contentLength = status.ContentLength })); }
public async Task GivenSaveErrorLog_WhenCorrectDataReceived_ThenShouldPersistLog() { var options = SqliteInMemory.CreateOptions <LoggingDbContext>(); await using var context = new LoggingDbContext(options); { await context.Database.EnsureCreatedAsync(); context.SeedSingleErrorLog(); var errorLog = new ErrorLog { ErrorMessage = "Test ErrorCode Message", MessageType = "ErrorLog", Timestamp = DateTime.Now, UserId = "1010101" }; var currentErrorLogCount = context.ErrorLogs.Count(); var errorLogRepository = new ErrorLogRepository(context); await errorLogRepository.SaveErrorLog(errorLog); var updatedErrorLogCount = context.ErrorLogs.Count(); Assert.Equal(currentErrorLogCount + 1, updatedErrorLogCount); } }
public override void OnException(ExceptionContext filterContext) { Exception ex = filterContext.Exception; ErrorLogRepository errorRepository = new ErrorLogRepository(); errorRepository.SaveErrorToDB(ex, ex.Message + (ex.InnerException != null ? Environment.NewLine + ex.InnerException.Message : ""), filterContext.HttpContext.User.Identity.Name); base.OnException(filterContext); }
public UnitOfWork() { _context = new OptiekDbContext(); Addresses = new AddressRepository(_context); Companies = new CompanyRepository(_context); Customers = new CustomerRepository(_context); ErrorLogs = new ErrorLogRepository(_context); Invoices = new InvoiceRepository(_context); InvoiceRules = new InvoiceRuleRepository(_context); }
private async Task AlterTableAsync(string tableName, IList <TableColumn> tableColumns, string pluginId, IList <string> dropColumnNames = null) { try { await _settingsManager.Database.AlterTableAsync(tableName, GetRealTableColumns(tableColumns), dropColumnNames); } catch (Exception ex) { await ErrorLogRepository.AddErrorLogAsync(pluginId, ex, string.Empty); } }
public UnitOfWork(LascarizadorDbContext context) { _context = context; Clients = new ClientRepository(_context); CardBrands = new CardBrandRepository(_context); CardTypes = new CardTypeRepository(_context); Cards = new CardRepository(_context); Transactions = new TransactionRepository(_context); TransactionTypes = new TransactionTypeRepository(_context); TransactionLogs = new TransactionLogRepository(_context); ErrorLogs = new ErrorLogRepository(_context); }
public UnitOfWork() { _context = new EventerDbContext(); ActivityLogRepository = new ApiActivityLogRepository(_context); CategoryRepository = new CategoryRepository(_context); CityRepository = new CityRepository(_context); ClientRepository = new ClientRepository(_context); ErrorLogRepository = new ErrorLogRepository(_context); EventRepository = new EventRepository(_context); RefreshTokenRepository = new RefreshTokenRepository(_context); StateRepository = new StateRepository(_context); }
public UnitOfWork(ApplicationDbContext context, IFileHandlerRepository fileHandlerRepository) { _context = context; MembersRepository = new MembersRepository(context); MessagesRepository = new MessagesRepository(context); RelationsRepository = new RelationsRepository(context); EventTracerRepository = new EventTracerRepository(context); ErrorLogRepository = new ErrorLogRepository(context); AnonymousHubDataRepository = new AnonymousHubDataRepository(); MemberHubDataRepository = new MemberHubDataRepository(); VideoHubDataRepository = new VideoHubDataRepository(); ImageRepository = new ImageRepository(fileHandlerRepository); }
public void Login() { MessengerDbContext context = new MessengerDbContext(); UserRepository userRepo = new UserRepository(context); ErrorLogRepository errorRepo = new ErrorLogRepository(context); AuthController controller = new AuthController(userRepo, errorRepo); var res = controller.Login(new LoginModel() { UserName = "******", Password = "******" }); Assert.IsType <OkObjectResult>(res); }
// ReSharper disable once UnusedMember.Global public void Post(ErrorLogCreateRequest request) { Guard.AgainstEmpty(request.Application); Guard.AgainstEmpty(request.Provider); Guard.AgainstEmpty(request.ProviderId); Guard.IsTrue(r => string.IsNullOrWhiteSpace(r.ErrorMessage) == false || string.IsNullOrWhiteSpace(r.StackTrace), request); var existingUser = UserHelpers.GetExistingUser(request, UserRepository); ErrorLogRepository.Add(new ErrorLog { Application = request.Application, Message = request.ErrorMessage, StackTrace = request.StackTrace, Provider = existingUser.Provider, ProviderId = existingUser.ProviderId }); }
/// <summary> /// /// </summary> /// <param name="log"></param> /// <returns></returns> public int Update(ErrorLogModel log) { if (log == null) { return(CoreConstants.NullLogResponse); } if (string.IsNullOrWhiteSpace(log.Id)) { return(CoreConstants.EmptyLogIdResponse); } var emptystring = Guid.Empty.ToString(); if (log.Id == emptystring) { return(CoreConstants.EmptyGuidLogIdResponse); } emptystring = emptystring.Replace("-", string.Empty); if (log.Id == emptystring) { return(CoreConstants.EmptyGuidLogIdResponse); } var result = -1; var entity = default(ErrorLogEntity); using (var repo = new ErrorLogRepository <ErrorLogEntity>()) { entity = repo.FirstOrDefault(q => q.Id == log.Id); if (entity != null && entity != default(ErrorLogEntity)) { SimpleMapper.MapTo(log, entity); repo.Update(entity); result = repo.SaveChanges(); } } return(result); }
/// <summary> /// /// </summary> /// <param name="startTimestamp"></param> /// <param name="endTimestamp"></param> /// <returns></returns> public IEnumerable <ErrorLogModel> GetLogs(long?startTimestamp, long?endTimestamp) { var results = (new ErrorLogModel[] { }).AsEnumerable(); var start = startTimestamp.GetValueOrDefault(); var end = endTimestamp.GetValueOrDefault(); List <ErrorLogEntity> entities; using (var repo = new ErrorLogRepository <ErrorLogEntity>()) { entities = repo .GetAll(q => ((q.LogTimeUnixTimestamp >= start || start == 0) && (q.LogTimeUnixTimestamp <= end || end == 0)), asNoTracking: true) .ToList() ?? new List <ErrorLogEntity>(); } results = SimpleMapper.MapList <ErrorLogEntity, ErrorLogModel>(entities).AsEnumerable(); return(results); }
[Fact] public async Task GivenGetAllErrorLogs_WhenCalled_ThenShouldReturnAllErrorLogs() { var options = SqliteInMemory.CreateOptions <LoggingDbContext>(); await using var context = new LoggingDbContext(options); { await context.Database.EnsureCreatedAsync(); context.SeedErrorLogs(); var errorLogCount = context.ErrorLogs.Count(); var errorLogRepository = new ErrorLogRepository(context); var logs = await errorLogRepository.GetAllErrorLogs(); Assert.NotNull(logs); Assert.Equal(errorLogCount, logs.Count); Assert.IsType <List <ErrorLog> >(logs); } }
private async Task <(bool IsSuccess, Exception Ex)> CreateTableAsync(string tableName, IList <TableColumn> tableColumns, string pluginId, bool isContentTable) { try { await _settingsManager.Database.CreateTableAsync(tableName, tableColumns); } catch (Exception ex) { await ErrorLogRepository.AddErrorLogAsync(pluginId, ex, string.Empty); return(false, ex); } if (isContentTable) { try { await _settingsManager.Database.CreateIndexAsync(tableName, $"IX_{tableName}_General", $"{nameof(Content.Top)} DESC", $"{nameof(Content.Taxis)} DESC", $"{nameof(Content.Id)} DESC"); } catch (Exception ex) { await ErrorLogRepository.AddErrorLogAsync(pluginId, ex, string.Empty); return(false, ex); } try { await _settingsManager.Database.CreateIndexAsync(tableName, $"IX_{tableName}_Taxis", $"{nameof(Content.Taxis)} DESC"); } catch (Exception ex) { await ErrorLogRepository.AddErrorLogAsync(pluginId, ex, string.Empty); return(false, ex); } } return(true, null); }
/// <summary> /// /// </summary> /// <param name="oid"></param> /// <returns></returns> public ErrorLogModel GetById(string oid) { var result = default(ErrorLogModel); if (string.IsNullOrWhiteSpace(oid) || oid == Guid.Empty.ToString() || oid == Guid.Empty.ToString().Replace("-", string.Empty)) { return(result); } ErrorLogEntity entity = null; using (var repo = new ErrorLogRepository <ErrorLogEntity>()) { entity = repo .FirstOrDefault(q => q.Id == oid, asNoTracking: true); } result = SimpleMapper.Map <ErrorLogEntity, ErrorLogModel>(entity); return(result); }
/// <summary> /// /// </summary> /// <param name="log"></param> /// <returns></returns> public string Save(ErrorLogModel log) { if (log == null) { #if DEBUG log = new ErrorLogModel(); #else return("null"); #endif } var logId = log?.Id ?? string.Empty; var emptyGuid = Guid.Empty.ToString(); if (string.IsNullOrWhiteSpace(logId) || logId == emptyGuid || logId == emptyGuid.Replace("-", string.Empty)) { log.Id = Guid.NewGuid().ToString(); } if (!log.LogTime.HasValue) { log.LogTime = DateTime.Now; log.LogTimeUnixTimestamp = log.LogTime.Value.Ticks; } log.CreatedOn = DateTime.Now; log.CreatedOnUnixTimestamp = log.CreatedOn.Ticks; var entity = SimpleMapper.Map <ErrorLogModel, ErrorLogEntity>(log); using (var repo = new ErrorLogRepository <ErrorLogEntity>()) { repo.Add(entity); repo.SaveChanges(); } return(entity.Id); }
public ErrorLogService() { this.repo = new ErrorLogRepository(); }
/// <summary> /// Default constructor. Does nothing /// </summary> public StoredProcedure() : this(String.Empty, string.Empty, new List <StoredProcedureParameter>(), String.Empty) { _errorLogDAL = new ErrorLogRepository(); }
internal static MailMessage GenerateMessageEmail(MessageRecipient msgRecip) { Console.WriteLine(String.Format("Sending an e-mail to {0} at {1}{2}", msgRecip.Profile.FirstName, msgRecip.Profile.Email, Environment.NewLine)); try { MailMessage mail = new MailMessage(); string firstName = msgRecip.Message.AppUser.Profile.FirstName; string lastName = msgRecip.Message.AppUser.Profile.LastName; if (!String.IsNullOrEmpty(firstName) && !String.IsNullOrEmpty(lastName)) { mail.From = new MailAddress("*****@*****.**", string.Format("{0} {1}", firstName, lastName)); } if (!string.IsNullOrEmpty(msgRecip.Profile.Email)) { mail.To.Add(msgRecip.Profile.Email); } if (!string.IsNullOrEmpty(msgRecip.Profile.EmailAlternate)) { mail.To.Add(msgRecip.Profile.EmailAlternate); } mail.Subject = "You Have a Viternus Message Waiting for You"; mail.IsBodyHtml = false; StringBuilder body = new StringBuilder(); body.Append("Dear "); body.Append(String.IsNullOrEmpty(msgRecip.Profile.FirstName) ? "Recipient" : msgRecip.Profile.FirstName); body.Append(","); body.Append(Environment.NewLine); body.Append(Environment.NewLine); body.Append("A message awaits you on the Viternus website, at the link below:"); body.Append(Environment.NewLine); body.Append(Environment.NewLine); body.Append("(Click the link to view the message)"); body.Append(Environment.NewLine); body.Append(@"http://www.Viternus.com/Message/ViewMessageFromUrl/" + msgRecip.Id); body.Append(Environment.NewLine); body.Append(Environment.NewLine); body.Append("This message has been sent by "); if (String.IsNullOrEmpty(firstName) && String.IsNullOrEmpty(lastName)) { body.Append(msgRecip.Message.AppUser.UserName); } else { body.Append(firstName); body.Append(" "); body.Append(lastName); } body.Append(". The message is not urgent, but he/she requests you view it at your earliest convenience. If you are not "); if (String.IsNullOrEmpty(msgRecip.Profile.FirstName) && String.IsNullOrEmpty(msgRecip.Profile.LastName)) { body.Append("the owner of this email address"); } else { body.Append(msgRecip.Profile.FirstName); body.Append(" "); body.Append(msgRecip.Profile.LastName); } body.Append(", then please disregard this message."); body.Append(Environment.NewLine); body.Append(Environment.NewLine); body.Append("Thank you,"); body.Append(Environment.NewLine); body.Append("Viternus Webmaster"); mail.Body = body.ToString(); return(mail); } catch (Exception ex) { Console.WriteLine("Error" + Environment.NewLine + ex.Message + Environment.NewLine + ex.StackTrace); ErrorLogRepository errorRepos = new ErrorLogRepository(); errorRepos.SaveErrorToDB(ex, "GenerateMessageMail failed", String.Empty); return(null); } }
public void Add(ErrorLogModel errorLogModel) { IErrorLogRepository errorLogRepo = new ErrorLogRepository(); errorLogRepo.Add(MappingExtensions.MapTo <ErrorLogModel, ErrorLog>(errorLogModel)); }
public ErrorLogService() { _dbContext = new DataContext(); this.repo = new ErrorLogRepository(_dbContext); }
public void addErrorLog(ERROR_LOG errorLog, BRContext db) { ErrorLogRepository ur = new ErrorLogRepository(db); ur.insert(errorLog); }
public List <ERROR_LOG> findAll(BRContext db) { ErrorLogRepository ur = new ErrorLogRepository(db); return(ur.selectAll()); }
internal static MailMessage GenerateInnerCircleRequestEmail(InnerCircle trustee) { Console.WriteLine(String.Format("Sending an e-mail to {0} at {1}{2}", trustee.Profile.FirstName, trustee.Profile.Email, Environment.NewLine)); try { MailMessage mail = new MailMessage(); string firstName = trustee.AppUser.Profile.FirstName; string lastName = trustee.AppUser.Profile.LastName; if (!String.IsNullOrEmpty(firstName) && !String.IsNullOrEmpty(lastName)) { mail.From = new MailAddress("*****@*****.**", string.Format("{0} {1}", firstName, lastName)); } if (!string.IsNullOrEmpty(trustee.Profile.Email)) { mail.To.Add(trustee.Profile.Email); } if (!string.IsNullOrEmpty(trustee.Profile.EmailAlternate)) { mail.To.Add(trustee.Profile.EmailAlternate); } mail.Subject = "You have been designated as a trustee"; mail.IsBodyHtml = false; StringBuilder body = new StringBuilder(); body.Append("Dear "); body.Append(String.IsNullOrEmpty(trustee.Profile.FirstName) ? "Trustee" : trustee.Profile.FirstName); body.Append(","); body.Append(Environment.NewLine); body.Append(Environment.NewLine); body.Append(firstName); body.Append(" "); body.Append(lastName); body.Append(" listed you as a Trustee in the Inner Circle."); body.Append(Environment.NewLine); body.Append(Environment.NewLine); body.Append("With this designation comes the following responsibility:"); body.Append(Environment.NewLine); body.Append(Environment.NewLine); body.Append("- Immediate Action Required: Create your free account on Viternus.com"); body.Append(Environment.NewLine); body.Append("- Immediate Action Required: Accept the responsiblity of being a trustee"); body.Append(Environment.NewLine); body.Append("- Future Action Required: Should something happen to " + firstName + ", such as incapacitation or death, log in and notify Viternus via the 'I am a Trustee' link."); body.Append(Environment.NewLine); body.Append(Environment.NewLine); body.Append(Environment.NewLine); //TODO: Right now we always assume the Inner Circle member needs a new account body.Append("To fulfill your responsibility, click the link below and create your account:"); body.Append(Environment.NewLine); body.Append(@"http://www.Viternus.com/Account/Register?email=" + trustee.Profile.Email + "&userName="******"&ReturnUrl=%2fInnerCircle%2fMember"); body.Append(Environment.NewLine); body.Append(Environment.NewLine); body.Append("Thank you,"); body.Append(Environment.NewLine); body.Append("Viternus Webmaster"); mail.Body = body.ToString(); return(mail); } catch (Exception ex) { Console.WriteLine("Error" + Environment.NewLine + ex.Message + Environment.NewLine + ex.StackTrace); ErrorLogRepository errorRepos = new ErrorLogRepository(); errorRepos.SaveErrorToDB(ex, "GenerateInnerCircleRequestEmail failed", String.Empty); return(null); } }