void KeepUpdating(ProcResult result) { _updateUI.OnNext(result); GaSortingData = result.Data.GetGaSortingData(); var seq = GaSortingData.Data.GetSortablePool().Sortables.Values.First().GetMap(); Message = StringFuncs.LineFormat(seq); Report.Add($"{GaSortingData.Data.GetCurrentStep()}\t{GaSortingData.Report()}"); }
public async Task <IActionResult> OnPostAsync(CancellationToken cancellationToken) { var ip = this.getIp.GetIp(this.Request); var ipHash = this.ipHasher.Hash(ip); var key = $"{nameof(this.Post)}.{nameof(this.Post.File)}"; this.bannedImageLogger.Log(this.ModelState[key], ip, ipHash); var t = await this.threadService.GetThread(this.Post.ThreadId, Constants.PageSize, cancellationToken).ConfigureAwait(false); return(await t.Match(async thread => { if (!this.ModelState.IsValid) { this.IsAdmin = this.isAdmin.IsAdmin(this.HttpContext); this.Thread = thread; return this.Page().ToIAR(); } else { var trip = tripCodeHasher.Hash(StringFuncs.MapString(this.Post.Name, "anonymous")); var options = OptionsMapper.Map(this.Post.Options); var postId = Guid.NewGuid(); var f = uploadMapper.Map(this.Post.File, postId); var result = await this.postService.Add(postId, this.Post.ThreadId, trip, this.Post.Comment, options.Sage, ipHash, f, cancellationToken); return result.Match( _ => { this.cookieStorage.SetNameCookie(this.Response, this.Post.Name); if (options.NoNoko) { return this.RedirectToPage <BoardModel>(new { boardKey = thread.Board.BoardKey }); } else { return this.RedirectToPage <ThreadModel>(new { boardKey = thread.Board.BoardKey, threadId = this.Post.ThreadId }).ToIAR(); } }, _ => this.RedirectToPage <BannedModel>().ToIAR(), _ => { this.ModelState.AddModelError(string.Empty, "Image count exceeded"); return Page().ToIAR(); }, _ => { this.ModelState.AddModelError(string.Empty, "Post count exceeded"); return Page().ToIAR(); }); } }, () => this.NotFound().ToIART())); }
public async Task <IActionResult> OnPostAsync(string boardKey, string filter, CancellationToken cancellationToken, int pageNumber = 1) { var ip = this.getIp.GetIp(this.Request); var ipHash = this.ipHasher.Hash(ip); this.bannedImageLogger.Log(this.ModelState[nameof(this.Thread.File)], ip, ipHash); var filterOption = NullableMapper.ToOption(filter); var t = await this.threadService.GetOrderedThreads(boardKey, filterOption, Constants.PageSize, pageNumber, cancellationToken); return(await t.Match(async threads => { if (!ModelState.IsValid) { this.Threads = threads; return Page().ToIAR(); } var threadId = Guid.NewGuid(); var postId = Guid.NewGuid(); var trip = tripCodeHasher.Hash(StringFuncs.MapString(this.Thread.Name, "anonymous")); var options = OptionsMapper.Map(this.Thread.Options); var f = uploadMapper.Map(this.Thread.File, postId); var result = await this.postService.AddThread(postId, threadId, this.Thread.BoardId, this.Thread.Subject ?? string.Empty, trip, this.Thread.Comment, options.Sage, ipHash, f, cancellationToken); return result.Match( _ => { this.cookieStorage.SetNameCookie(this.Response, this.Thread.Name); if (options.NoNoko) { return this.RedirectToPage <BoardModel>(new { boardKey = boardKey }).ToIAR(); } else { return this.RedirectToPage <ThreadModel>(new { threadId = threadId }).ToIAR(); } }, _ => this.RedirectToPage <BannedModel>().ToIAR()); }, () => this.NotFound().ToIART())); }
public ReturnClass Send(string toname, string toemail, string fromname, string fromemail, string subject, string body) { SimpleEmailVO VO = new SimpleEmailVO(); ReturnClass outcome = new ReturnClass(true); if (StringFuncs.IsValidEmail(toemail) == true && StringFuncs.IsValidEmail(fromemail)) { VO.ToName = toname; VO.ToEmail = toemail; VO.FromName = fromname; VO.FromEmail = fromemail; VO.Subject = subject; VO.TextBody = body; VO.HtmlBody = body; outcome = Send(VO); } else { outcome.Success = false; outcome.Message = "One or both of the email addresses are invalid."; } return(outcome); }
public static string PrintOverlaps(this SbScratchPad sbScratchPad) { return(StringFuncs.GridFormat(sbScratchPad.Order, sbScratchPad.Order, (r, c) => $"{sbScratchPad.Overlap(r, c).Overlap}")); }
public static string ToCamel(string s) { return(StringFuncs.ToCamel(s)); }
public static string ToSHA1(string s) { return(StringFuncs.ToHexString(HashFuncs.ToSHA1(Encoding.UTF8.GetBytes(s)))); }
public static string ToSHA1(FileInfo file) { return(StringFuncs.ToHexString(HashFuncs.ToSHA1(File.ReadAllBytes(file.FullName)))); }
public static string ToUpper(string s) { return(StringFuncs.ToUpper(s)); }
public static string ToPascal(string s) { return(StringFuncs.ToPascal(s)); }
public void TestGridFormat() { Func <uint, uint, string> f = (r, c) => $"[{r}, {c}]"; Console.WriteLine(StringFuncs.GridFormat(5, 7, f)); }
public ReturnClass Send(SimpleEmailVO VO) { log = new LoggingClass(logfolder); ReturnClass outcome = new ReturnClass(true); if (StringFuncs.IsValidEmail(VO.ToEmail) == true && StringFuncs.IsValidEmail(VO.FromEmail)) { if (loaded == true) { MailAddress toaddress = new MailAddress(VO.ToEmail, VO.ToName); MailAddress fromaddress = new MailAddress(VO.FromEmail, VO.FromName); MailMessage message = new MailMessage(fromaddress, toaddress); message.Subject = VO.Subject; if (VO.IsBodyHtml == true) { message.Body = VO.HtmlBody; } else { message.Body = VO.TextBody; } message.IsBodyHtml = VO.IsBodyHtml; message.Priority = MailPriority.Normal; message.Headers.Add("Return-Path", VO.FromEmail); try { client = new SmtpClient(); if (timeout != 100000) { client.Timeout = timeout; } //client.DeliveryMethod = SmtpDeliveryMethod.Network; //client.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis; //client.DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory; } catch (Exception ex) { outcome.Success = false; outcome.Message = "There was a problem creating the email component [" + ex.Message + "]"; } if (outcome.Success == true) { try { client.Send(message); } catch (SmtpException ex) { log.Log("EmailClass - Error sending email to " + VO.ToName + " :" + ex.StatusCode + " [" + ex.Message + "][" + ex.InnerException + "]", "MHPNET2EmailLib.EmailClass"); outcome.Success = false; outcome.Message = "EmailClass - Email error " + ex.StatusCode + " [" + ex.Message + "]"; } catch (Exception ex) { log.Log("EmailClass - Error sending email to " + VO.ToName + " :" + ex.Message + "[" + ex.InnerException + "]", "MHPNET2EmailLib.EmailClass"); outcome.Success = false; outcome.Message = "EmailClass - Email error [" + ex.Message + "]"; } } } else { outcome.Success = false; outcome.Message = "The mail component can not be created - most probably the mail configuration is incorrect"; } } else { outcome.Success = false; outcome.Message = "One or both of the email addresses are invalid."; } return(outcome); }
public ReturnClass Send(SimpleEmailVO VO, string deliveryemail) { LoggingClass log = new LoggingClass(logfolder); ReturnClass outcome = new ReturnClass(true); AlternateView av1 = null; AlternateView av2 = null; SmtpClient mailSender = new SmtpClient(); if (VO.FromName.Length == 0) { VO.FromName = VO.FromEmail; } if (VO.ToName.Length == 0) { VO.ToName = VO.ToEmail; } if (StringFuncs.IsValidEmail(VO.FromEmail) && StringFuncs.IsValidEmail(VO.ToEmail)) { MailMessage mailMessage = new MailMessage(new MailAddress(VO.FromEmail, VO.FromName), new MailAddress(VO.ToEmail, VO.ToName)); if (StringFuncs.IsValidEmail(deliveryemail)) { mailMessage.DeliveryNotificationOptions = DeliveryNotificationOptions.OnSuccess | DeliveryNotificationOptions.OnFailure | DeliveryNotificationOptions.Delay; mailMessage.Headers.Add("Disposition-Notification-To", deliveryemail); //mailMessage.Headers.Add("Errors-To", Config.EmailerDeliveryEmail); //mailMessage.Headers.Add("Delivered-To", Config.EmailerDeliveryEmail); //mailMessage.Headers.Add("Return-Receipt-Requested", Config.EmailerDeliveryEmail); //mailMessage.Headers.Add("Return-Receipt-To", Config.EmailerDeliveryEmail); //mailMessage.Headers.Add("Read-Receipt-Requested", Config.EmailerDeliveryEmail); //mailMessage.Headers.Add("Read-Receipt-To", Config.EmailerDeliveryEmail); //mailMessage.Headers.Add("X-Confirm-reading-to", Config.EmailerDeliveryEmail); } try { if (VO.HtmlBody.Length > 0) { if (VO.TextBody.Length > 0) { av2 = AlternateView.CreateAlternateViewFromString(VO.TextBody, null, MediaTypeNames.Text.Plain); mailMessage.AlternateViews.Add(av2); av1 = AlternateView.CreateAlternateViewFromString(VO.HtmlBody, Encoding.UTF8, MediaTypeNames.Text.Html); mailMessage.AlternateViews.Add(av1); } else { av1 = AlternateView.CreateAlternateViewFromString(VO.HtmlBody, Encoding.UTF8, MediaTypeNames.Text.Html); mailMessage.AlternateViews.Add(av1); } } else { av2 = AlternateView.CreateAlternateViewFromString(VO.TextBody, null, MediaTypeNames.Text.Plain); mailMessage.AlternateViews.Add(av2); } } catch (Exception ex) { outcome.SetFailureMessage("Error setting email body:" + ex.ToString()); } if (outcome.Success) { try { mailMessage.Subject = VO.Subject; if (VO.HtmlBody.Length > 0) { mailMessage.IsBodyHtml = true; } else { mailMessage.IsBodyHtml = false; } mailMessage.Priority = MailPriority.Normal; if (StringFuncs.IsValidEmail(VO.ReplyToEmail)) { mailMessage.Headers.Add("Return-Path", VO.ReplyToEmail); mailMessage.ReplyTo = new MailAddress(VO.ReplyToEmail, VO.ReplyToEmail); } else { mailMessage.Headers.Add("Return-Path", VO.FromEmail); mailMessage.ReplyTo = new MailAddress(VO.FromEmail, VO.FromName); } mailSender.EnableSsl = UseSSL; } catch (Exception ex) { outcome.SetFailureMessage("Error setting message settings:" + ex.ToString()); } if (outcome.Success) { try { mailSender.Send(mailMessage); } catch (SmtpException ex) { log.Log("EmailClass - Error sending email to " + VO.ToName + " :" + ex.StatusCode + " [" + ex.Message + "][" + ex.InnerException + "]", "MHPNET2EmailLib.EmailClass"); outcome.SetFailureMessage("EmailClass - Email error " + ex.StatusCode + " [" + ex.Message + "]"); } catch (Exception ex) { log.Log("EmailClass - Error sending email to " + VO.ToName + " :" + ex.Message + "[" + ex.InnerException + "]", "MHPNET2EmailLib.EmailClass"); outcome.SetFailureMessage("EmailClass - Email error [" + ex.Message + "]"); } } } } else { outcome.SetFailureMessage("Either the target (" + VO.ToEmail + ") or sender email (" + VO.FromEmail + ")is invalid"); } return(outcome); }
public ReturnClass SendMessages(SimpleEmailVOs VOs) { MailAddress toaddress = null; MailAddress fromaddress = null; MailMessage message = null; log = new LoggingClass(logfolder); ReturnClass outcome = new ReturnClass(true); ReturnClass mailcome = new ReturnClass(true); if (loaded == true) { try { client = new SmtpClient(); } catch (Exception ex) { outcome.Success = false; outcome.Message = "There was a problem creating the email component [" + ex.Message + "]"; } if (UseSSL) { client.EnableSsl = true; } if (outcome.Success == true) { List <SimpleEmailVO> Emails = VOs.Emails; for (int i = 0; i < Emails.Count; i++) { if (StringFuncs.IsValidEmail(Emails[i].ToEmail) == true && StringFuncs.IsValidEmail(Emails[i].FromEmail)) { toaddress = new MailAddress(Emails[i].ToEmail, Emails[i].ToName); fromaddress = new MailAddress(Emails[i].FromEmail, Emails[i].FromName); message = new MailMessage(fromaddress, toaddress); message.Subject = Emails[i].Subject; message.Body = Emails[i].HtmlBody; message.IsBodyHtml = Emails[i].IsBodyHtml; try { client.Send(message); } catch (SmtpException ex) { log.Log("EmailClass - Error sending email to " + Emails[i].ToName + " :" + ex.StatusCode + " [" + ex.Message + "][" + ex.InnerException + "]", "MHPNET2EmailLib.EmailClass"); mailcome.Success = false; mailcome.AddMessage("EmailClass - Email error " + ex.StatusCode + " [" + ex.Message + "][" + ex.InnerException + "]"); } catch (Exception ex) { log.Log("EmailClass - Error sending email to " + Emails[i].ToName + " :" + ex.Message + "", "MHPNET2EmailLib.EmailClass"); mailcome.Success = false; mailcome.AddMessage("EmailClass - Email error [" + ex.Message + "][" + ex.InnerException + "]"); } } else { mailcome.Success = false; mailcome.Message = "One or both of the email addresses are invalid."; } } } if (mailcome.Success == false) { outcome.Success = false; outcome.Message = mailcome.Message; } } else { outcome.Success = false; outcome.Message = "The mail component can not be created - most probably the mail configuration is incorrect"; } return(outcome); }
public ReturnClass Send(SimpleEmailVO VO) { MailAddress toaddress = null; MailAddress fromaddress = null; MailAddress replyaddress = null; MailMessage message = null; log = new LoggingClass(logfolder); ReturnClass outcome = new ReturnClass(true); if (StringFuncs.IsValidEmail(VO.ToEmail) && StringFuncs.IsValidEmail(VO.FromEmail)) { if (loaded == true) { try { toaddress = new MailAddress(VO.ToEmail, VO.ToName); fromaddress = new MailAddress(VO.FromEmail, VO.FromName); message = new MailMessage(fromaddress, toaddress); } catch (Exception ex) { outcome.Success = false; outcome.Message = "There was a problem creating the addresses or message [" + ex.Message + "]"; } if (outcome.Success) { try { message.Subject = VO.Subject; if (VO.IsBodyHtml == true) { message.Body = VO.HtmlBody; } else { message.Body = VO.TextBody; } message.IsBodyHtml = VO.IsBodyHtml; message.Priority = MailPriority.Normal; message.Headers.Add("Return-Path", VO.FromEmail); } catch (Exception ex) { outcome.Success = false; outcome.Message = "There was a problem setting the message parts(priority, return-path) [" + ex.Message + "]"; } } if (outcome.Success) { if (VO.ReplyToEmail.Length > 0 && StringFuncs.IsValidEmail(VO.ReplyToEmail)) { if (VO.ReplyToName.Length > 0) { replyaddress = new MailAddress(VO.ReplyToEmail, VO.ReplyToName); } else { replyaddress = new MailAddress(VO.ReplyToEmail, VO.ReplyToEmail); } message.ReplyTo = replyaddress; } } if (outcome.Success) { try { client = new SmtpClient(); } catch (Exception ex) { outcome.Success = false; outcome.Message = "There was a problem creating the email component [" + ex.Message + "]"; } } if (outcome.Success) { if (UseSSL) { client.EnableSsl = true; } } if (outcome.Success) { try { client.Send(message); } catch (SmtpException ex) { log.Log("EmailClass - Error sending email to " + VO.ToName + " :" + ex.StatusCode + " [" + ex.Message + "][" + ex.InnerException + "]", "MHPNET2EmailLib.EmailClass"); outcome.Success = false; outcome.Message = "EmailClass - Email error " + ex.StatusCode + " [" + ex.Message + "]"; } catch (Exception ex) { log.Log("EmailClass - Error sending email to " + VO.ToName + " :" + ex.Message + "[" + ex.InnerException + "]", "MHPNET2EmailLib.EmailClass"); outcome.Success = false; outcome.Message = "EmailClass - Email error [" + ex.Message + "]"; } } } else { outcome.Success = false; outcome.Message = "The mail component can not be created - most probably the mail configuration is incorrect"; } } else { outcome.Success = false; outcome.Message = "One or both of the email addresses are invalid."; } return(outcome); }