public SignInSheetViewModel(string eventKey) { this.SignInSheetState = default(SignInSheetState); using (EventsContext context = new EventsContext()) { var eventItem = context.Events.SingleOrDefault(e => e.EventKey == eventKey); this.Event = eventItem; if (this.Event.SignInDocumentUrl == PROCESSING_URI) { this.SignInSheetState = SignInSheetState.SignInDocumentProcessing; } else if (!String.IsNullOrEmpty(this.Event.SignInDocumentUrl)) { this.SignInSheetState = SignInSheetState.SignInDocumentAlreadyExists; } else { QueueMessage message = new QueueMessage { EventId = eventItem.Id, MessageType = QueueMessageType.SignIn }; string messageString = JsonConvert.SerializeObject(message); GenerateSignInSheetTableStorage(context, eventItem, messageString); } } }
private void HandleMessage(QueueMessage message) { switch (message.MessageType) { case QueueMessageType.SignIn: HandleSignInMessage(message); break; } }
private void GenerateSignInSheetServiceBus(EventsContext context, Event eventItem, QueueMessage message) { eventItem.SignInDocumentUrl = PROCESSING_URI; context.SaveChanges(); this.Event = eventItem; this.SignInSheetState = SignInSheetState.SignInDocumentProcessing; }
private void GenerateSignInSheetServiceBus(EventsContext context, Event eventItem, QueueMessage message) { QueueClient client = QueueClient.CreateFromConnectionString(serviceBusConnectionString, signInQueueName); BrokeredMessage queueMessage = new BrokeredMessage(message); client.Send(queueMessage); eventItem.SignInDocumentUrl = PROCESSING_URI; context.SaveChanges(); this.Event = eventItem; this.SignInSheetState = SignInSheetState.SignInDocumentProcessing; }
private void HandleSignInMessage(QueueMessage message) { using (EventsContext context = new EventsContext()) { var eventItem = context.Events.SingleOrDefault(e => e.Id == message.EventId); IEnumerable<string> names = _tableHelper.GetRegistrantNames(eventItem.EventKey); using (MemoryStream stream = _documentGenerator.CreateSignInDocument(eventItem.Title, names)) { Uri documentUrl = _blobHelper.CreateBlob(stream, eventItem.EventKey); eventItem.SignInDocumentUrl = documentUrl.AbsoluteUri; } context.SaveChanges(); } }