private void submissionStatus_HyperlinkClicked(object sender, BrightIdeasSoftware.HyperlinkClickedEventArgs e) { if (e.Model.GetType() != typeof(SubmissionMessage)) { return; } SubmissionMessage list = (SubmissionMessage)e.Model; if (e.Column == unameSUB) { if (LocalDatabase.ContainsUser(list.uname)) { Interactivity.ShowUserStat(list.uname); } else { if (MessageBox.Show("Add \"" + list.uname + "\" to your favorite list?", "Add User", MessageBoxButtons.YesNo) == DialogResult.No) { return; } RegistryAccess.AddUserid(list.uname, list.uid.ToString()); Interactivity.ShowUserStat(list.uname); } } }
public async Task Run([TimerTrigger("*/10 * * * * *")] TimerInfo myTimer, ILogger log) { Stopwatch runStopwatch = new Stopwatch(); runStopwatch.Start(); string runId = Guid.NewGuid().ToString(); log.LogInformation($"TimersSubmissionConsumer function executing: {runId}"); ServiceBusReceiver serviceBusReceiver = _submissionServiceBusService.SubmissionServiceBusClient.CreateReceiver("submission"); var messages = await _submissionServiceBusService.ReceiveMessagesAsync(serviceBusReceiver); log.LogInformation($"Received message count: {messages.Count} : {runId}"); foreach (var message in messages) { Stopwatch stopStopwatch = new Stopwatch(); stopStopwatch.Start(); await serviceBusReceiver.RenewMessageLockAsync(message); SubmissionMessage submissionMessage = DeserializeQueueItem(log, Encoding.UTF8.GetString(message.Body)); if (submissionMessage == null) { await serviceBusReceiver.DeadLetterMessageAsync(message); continue; } // Get Stop Stop stop = await GetStop(log, submissionMessage.StopId, runId); if (stop == null) { log.LogWarning($"Failed to find stop: {submissionMessage.StopId} : {runId}"); await serviceBusReceiver.AbandonMessageAsync(message); // allows for retry to occur. continue; } DateTime dateSubmitted = DateTime.UtcNow; // Get File Name string fileName = GetFileName(log, submissionMessage.SubmissionId, dateSubmitted, stop.Ori, stop.Id, runId); log.LogInformation($"Using filename: {fileName} : {runId}"); if (fileName == null) { await serviceBusReceiver.AbandonMessageAsync(message); // allows for retry to occur. continue; } // Get Doj Stop DojStop dojStop = GetDojStop(log, stop, runId); if (dojStop == null) { // if the cast error fails report, retry the message if (!await HandledDojCastError(log, stop, dateSubmitted, fileName, submissionMessage.SubmissionId, runId)) { await serviceBusReceiver.AbandonMessageAsync(message); // allows for retry to occur. continue; } else { await serviceBusReceiver.CompleteMessageAsync(message); // message complete continue; } } //Get File Bytes byte[] bytes = GetFileBytes(log, dojStop, runId); if (bytes == null) { log.LogWarning($"Failed to get file contents: {dojStop.LEARecordID} : {runId}"); await serviceBusReceiver.AbandonMessageAsync(message); // allows for retry to occur. continue; } //Upload Blob if (!await UploadBlob(log, bytes, fileName, stop.Id, runId)) { log.LogWarning($"Failed to upload blob: {stop.Id} : {runId}"); await serviceBusReceiver.AbandonMessageAsync(message); // allows for retry to occur. continue; } if (!await UploadSftpFile(log, bytes, fileName, stop.Id, runId, stop)) { log.LogWarning($"Failed to upload to FTP: {stop.Id} : {runId}"); await RemoveBlob(log, fileName, stop.Id, runId); // delete the blob to clean up the failed run await serviceBusReceiver.AbandonMessageAsync(message); // allows for retry to occur. continue; } if (!await HandleDojSubmitSuccess(log, stop, dateSubmitted, submissionMessage.SubmissionId, fileName, runId)) { log.LogWarning($"Failed to handle doj submit success: {stop.Id} : {runId}"); RemoveSftpFile(log, fileName, stop.Id, runId); // remove the file from the SFTP server so it doesnt get duplicated. await serviceBusReceiver.AbandonMessageAsync(message); // allows for retry to occur. continue; } await serviceBusReceiver.CompleteMessageAsync(message); // message complete stopStopwatch.Stop(); log.LogInformation($"Finished processing STOP : {stop.Id} : {stopStopwatch.ElapsedMilliseconds} : {runId}"); } runStopwatch.Stop(); log.LogInformation($"TimersSubmissionConsumer finished: {runStopwatch.ElapsedMilliseconds} : {runId}"); }
private void submissionStatus_FormatCell(object sender, BrightIdeasSoftware.FormatCellEventArgs e) { if (e.Model == null) { return; } //get two properties that are used later Verdict ver; string uname; if (typeof(SubmissionMessage) == e.Model.GetType()) { SubmissionMessage js = (SubmissionMessage)e.Model; ver = (Verdict)js.ver; uname = js.uname; } else { UserSubmission js = (UserSubmission)e.Model; ver = (Verdict)js.ver; uname = js.uname; } //change backcolor of items with known user name if (!(_curSubType == SubViewType.UsersSub || _curSubType == SubViewType.Comapre)) { if (uname == RegistryAccess.DefaultUsername) { for (int i = 0; i < e.Item.SubItems.Count; ++i) { e.Item.SubItems[i].BackColor = Color.Turquoise; } } else if (LocalDatabase.ContainsUser(uname)) { for (int i = 0; i < e.Item.SubItems.Count; ++i) { e.Item.SubItems[i].BackColor = Color.LightBlue; } } } //format other cells string font = "Segoe UI"; float size = 9.0F; FontStyle style = FontStyle.Regular; Color fore = Color.Black; if (e.Column == sidSUB) { font = "Consolas"; fore = Color.Teal; size = 8.5F; } else if (e.Column == unameSUB) { fore = Color.Navy; style = FontStyle.Italic; } else if (e.Column == fullnameSUB) { font = "Segoe UI Semibold"; } else if (e.Column == runSUB) { fore = Color.SlateBlue; } else if (e.Column == subtimeSUB) { fore = Color.Maroon; } else if (e.Column == rankSUB) { fore = Color.Navy; font = "Segoe UI Semibold"; } else if (e.Column == verSUB) { font = "Segoe UI"; fore = Functions.GetVerdictColor(ver); style = FontStyle.Bold; } else if (e.Column == lanSUB) { style = FontStyle.Bold; fore = Color.Navy; } else { return; } e.SubItem.ForeColor = fore; e.SubItem.Font = new Font(font, size, style); }