public async Task <int> ProcessMessagesAsync() { if (_asyncActions != null & _asyncActions.Count > 0) { var theQueue = await(new QueueClient(_queueName, _storageAccount)).GetQueueAsync(); await theQueue.FetchAttributesAsync(); var msgCount = theQueue.ApproximateMessageCount; if (msgCount > 0) { var idx = 0; while (idx <= msgCount - 1) { var msg = await theQueue.GetMessageAsync(); if (msg != null) { ServicesContainer.Get <IWaitingPanel>().Wait(ResStrConst.ProcessItem("Message"), msg.Id); if (await ProcessBlobMsgAsync(msg)) { await theQueue.DeleteMessageAsync(msg); idx += 1; } else { break; } } else { break; } } SPC.ServicesContainer.Get <IAlert>().Alert($"Processed {msgCount} messages."); return(idx); } else { SPC.ServicesContainer.Get <IAlert>().Alert("No message to process!!!".Translate()); } } else { SPC.ServicesContainer.Get <IAlert>().Alert("No processing actions defined".Translate()); } // End If return(0); }
/// <summary> /// Override to register services /// </summary> protected override void RegisterServices() { var logger = ServicesContainer.Get <ILogger>(); logger.Info("Welcome to use Bom tool"); logger.Info("Begin to register services"); this.ServicesContainer.Bind <ExcelReader>(true); this.ServicesContainer.Bind <ExcelWriter>(true); this.ServicesContainer.Bind <HistoryEntry>(true); this.ServicesContainer.Bind <PdfDataGenerator>(true); this.ServicesContainer.Bind <PdfPreviewer>(true); }
void IWaitingPanel.Wait(string Title, string Message) { ServicesContainer.Get <ILogService>().Log("AzureInvoice", "Index", Title, "Create", $".:| {Title}: {Message}"); Console.WriteLine($".:| {Title}: {Message}"); }
void IWaitingPanel.Done() { ServicesContainer.Get <ILogService>().Log("Done", "", "", "", ""); Console.WriteLine("Done"); }