public MessageResult ProcessTimerTick() { var relevantInboxes = new HashSet <string> { "sqlcomparesupport", "sqldatacomparesupport", "sqlsdksupport", "sqlcomparecoreteam" }; var result = new List <Response>(); Email email; while (m_Queue.TryDequeue(out email)) { Trace.WriteLine("Inspecting email " + email.Subject); if (!email.IsFirstEmailInConversation) { Trace.WriteLine("Skipping reply to a previously-seen email ..."); continue; } var relevantRecipients = email.RecipientEmails .Where(recipient => relevantInboxes.Any(recipient.Contains)) .ToList(); if (!relevantRecipients.Any()) { Trace.WriteLine("Skipping non-team-relevant email ..."); continue; } var asEscalation = EmailParser.TryGetZendeskEscalation(email.HtmlBody); if (asEscalation != null) { result.Add(new Response(string.Format("New support escalation for {0}\n**{1}**\n{2}", asEscalation.Id, email.Subject, email.FormattedBody), m_ChannelToPostEmailsTo, m_OutlookLogo)); m_LabelPrinter.PrintLabel(asEscalation.Id + ": " + email.Subject, new List <string> { m_ZendeskLogo }); } else { result.Add(new Response(string.Format("New email sent to {0}\n**{1}**\n{2}", relevantRecipients.First(), email.Subject, email.FormattedBody), m_ChannelToPostEmailsTo, m_OutlookLogo)); m_LabelPrinter.PrintLabel(email.Subject, email.FormattedBody, new List <string> { m_OutlookLogo }); } } if (!String.IsNullOrWhiteSpace(m_ChannelToPostEmailsTo)) { return(new MessageResult(result)); } return(MessageResult.Empty); }
public IActionResult PrintCustomLabel(PrintLabelRequest request) { var stream = new MemoryStream(); var image = _labelPrinter.PrintLabel(request.Lines, new PrinterOptions(request.LabelSource, request.LabelName, request.GenerateImageOnly, request.ShowDiagnostic)); image.Save(stream, ImageFormat.Png); stream.Seek(0, SeekOrigin.Begin); return(new FileStreamResult(stream, "image/png")); }
public async Task <IActionResult> PrintPartAsync([FromQuery] PrintPartRequest request) { var part = await _partService.GetPartAsync(request.PartNumber); if (part == null) { return(NotFound()); } var stream = new MemoryStream(); var image = _labelPrinter.PrintLabel(new LabelContent { Part = part }, new PrinterOptions(request.GenerateImageOnly)); image.Save(stream, ImageFormat.Png); stream.Seek(0, SeekOrigin.Begin); return(new FileStreamResult(stream, "image/png")); }
private MessageResult PrintGithubPullRequest(Command command, GithubReference githubRef) { var user = githubRef.User ?? defaultGithubUser; var repo = githubRef.Repo; var prNum = githubRef.Issue; var pr = githubApi.PullRequest(user, repo, prNum).Result; var title = string.Format("#{0}: {1}", prNum, pr.title); var avatarUrl = pr.user.avatar_url; var images = new List <string> { "https://assets-cdn.github.com/images/modules/logos_page/GitHub-Mark.png", avatarUrl, string.Format("https://api.qrserver.com/v1/create-qr-code/?data=https://github.com/{0}/{1}/pull/{2}", user, repo, prNum), }; var response = labelPrinter.PrintLabel(title, images); return(Response.ToMessage(command, response.Substring(0, Math.Min(response.Length, 50)))); }