private async Task ResumeAfterPrompt(IDialogContext context, IAwaitable <IEnumerable <Attachment> > result) { context.UserData.SetValue(ContextConstants.UserId, context.Activity.From.Id); try { //Connecting to storage var storageAccount = CloudStorageAccount.Parse(ConfigurationManager.AppSettings["AzureWebJobsStorage"]); var tableClient = storageAccount.CreateCloudTableClient(); CloudTable eventTable = tableClient.GetTableReference("Event"); eventTable.CreateIfNotExists(); //Get the Attachment var message = await result; var msg = context.MakeMessage(); msg.Type = ActivityTypes.Typing; await context.PostAsync(msg); var excelName = ""; string destinationContainer = "surveytemplates"; CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient(); var blobContainer = blobClient.GetContainerReference(destinationContainer); blobContainer.CreateIfNotExists(); String newFileName = ""; //Receiving the attachment foreach (Attachment a in message) { try { excelName = a.Name; using (HttpClient httpClient = new HttpClient()) { var responseMessage = await httpClient.GetAsync(a.ContentUrl); var contentLenghtBytes = responseMessage.Content.Headers.ContentLength; var fileByte = await httpClient.GetByteArrayAsync(a.ContentUrl); //Set file name newFileName = context.UserData.GetValue <string>(ContextConstants.UserId) + "_" + DateTime.Now.ToString("MMddyyyy-hhmmss") + "_" + excelName; string sourceUrl = a.ContentUrl; // Set the permissions so the blobs are public. //ON HOLD BlobContainerPermissions permissions = new BlobContainerPermissions { PublicAccess = BlobContainerPublicAccessType.Blob }; blobContainer.SetPermissions(permissions); var newBlockBlob = blobContainer.GetBlockBlobReference(newFileName); try { using (var memoryStream = new System.IO.MemoryStream(fileByte)) { newBlockBlob.UploadFromStream(memoryStream); newBlockBlob.Properties.ContentType = a.ContentType; } newBlockBlob.SetProperties(); } catch (Exception ex) { await context.PostAsync("Something went wrong with uploading, please type \'/ce\' to try again."); context.Done(this); } } } catch (Exception e) { await context.PostAsync("Something went wrong with uploading, please type \'/ce\' to try again."); context.Done(this); } } try { //Opening the Excel File CloudBlockBlob blob = blobContainer.GetBlockBlobReference(newFileName); //Check for unique entity DateTime thisDay = DateTime.Today; String today = FormatDate(thisDay.ToString("d")); var eventCode = GenerateCode(); //After checking that there are no duplicates in generated codes EventEntity eventEntity = new EventEntity(context.UserData.GetValue <string>(ContextConstants.UserId), eventCode); using (HttpClient httpClient = new HttpClient()) { var fileByte = await httpClient.GetByteArrayAsync(blob.Uri.ToString()); try { XSSFWorkbook wb; XSSFSheet sh; using (var memoryStream = new MemoryStream(fileByte)) { wb = new XSSFWorkbook(memoryStream); } sh = (XSSFSheet)wb.GetSheetAt(0); //Check event start date and event name if (sh.GetRow(2).GetCell(1) != null && sh.GetRow(2).GetCell(1).ToString() != "" && sh.GetRow(1).GetCell(1) != null && sh.GetRow(1).GetCell(1).ToString() != "") { //DateTime dateTime; DataFormatter dataFormatter = new DataFormatter(); var date = dataFormatter.FormatCellValue(sh.GetRow(2).GetCell(1)); int totalDays = 1; var error = false; DateTime sDate; DateTime eDate; //Try to parse date in the specified format if (ParseDate(date, thisDay)) { String[] split = date.Split(new Char[] { '/', '-' }); date = split[0].ToString() + '/' + split[1].ToString() + '/' + split[2]; eventEntity.EventStartDate = date; DateTime.TryParseExact(dataFormatter.FormatCellValue(sh.GetRow(2).GetCell(1)), new string[] { "dd/MM/yyyy", "dd-MM-yyyy" }, CultureInfo.InvariantCulture, DateTimeStyles.None, out sDate); //Check Event End Date if (sh.GetRow(3).GetCell(1) != null && sh.GetRow(3).GetCell(1).ToString() != "") { date = dataFormatter.FormatCellValue(sh.GetRow(3).GetCell(1)); if (ParseDate(date, sDate)) { split = date.Split(new Char[] { '/', '-' }); date = split[0].ToString() + '/' + split[1].ToString() + '/' + split[2]; eventEntity.EventEndDate = date; DateTime.TryParseExact(dataFormatter.FormatCellValue(sh.GetRow(3).GetCell(1)), new string[] { "dd/MM/yyyy", "dd-MM-yyyy" }, CultureInfo.InvariantCulture, DateTimeStyles.None, out eDate); totalDays = (eDate - sDate).Days + 1; if (totalDays > 31) { error = true; await context.PostAsync("Sorry, we currently do not support events that have more than 31 days."); await context.PostAsync(msg); await context.PostAsync("Talk to me again if you require my assistance."); context.Done(this); } } else { error = true; await context.PostAsync("Please check your excel file and input an end date in the format specified(dd-mm-yyyy or dd/mm/yyyy) and not before today's date!"); await context.PostAsync(msg); await context.PostAsync("Talk to me again if you require my assistance."); context.Done(this); } } else { eventEntity.EventEndDate = eventEntity.EventStartDate; } //End of Checking Event's End Date //Check Attendance Code 1 Time var startTime = dataFormatter.FormatCellValue(sh.GetRow(4).GetCell(1)); var endTime = dataFormatter.FormatCellValue(sh.GetRow(5).GetCell(1)); var code1 = new List <string>(); var code2 = new List <string>(); if (sh.GetRow(4).GetCell(1) != null && sh.GetRow(4).GetCell(1).ToString() != "" && sh.GetRow(5).GetCell(1) != null && sh.GetRow(5).GetCell(1).ToString() != "") { if (ParseTime(startTime, endTime)) { eventEntity.AttendanceCode1StartTime = startTime; eventEntity.AttendanceCode1EndTime = endTime; for (int i = 0; i < totalDays; i++) { //Generate unique attendanceCode1 code1.Add(GenerateCode()); } } else { error = true; await context.PostAsync("Please check your excel file and valid Attendance Code 1 Start/End Time in the format specified(2359). The end time should not be before the start time."); await context.PostAsync(msg); await context.PostAsync("Talk to me again if you require my assistance."); context.Done(this); } } else if (sh.GetRow(4).GetCell(1).ToString() == "" && sh.GetRow(5).GetCell(1).ToString() == "") { eventEntity.AttendanceCode1StartTime = ""; eventEntity.AttendanceCode1EndTime = ""; } else { error = true; await context.PostAsync("Please check your excel file and valid Attendance Code 1 Start/End Time in the format specified(2359). The end time should not be before the start time."); await context.PostAsync(msg); await context.PostAsync("Talk to me again if you require my assistance."); context.Done(this); } //End of Attendance Code 1 Time //Check Attendance Code 2 Time startTime = dataFormatter.FormatCellValue(sh.GetRow(6).GetCell(1)); endTime = dataFormatter.FormatCellValue(sh.GetRow(7).GetCell(1)); if (sh.GetRow(6).GetCell(1) != null && sh.GetRow(6).GetCell(1).ToString() != "" && sh.GetRow(7).GetCell(1) != null && sh.GetRow(7).GetCell(1).ToString() != "") { if (ParseTime(startTime, endTime)) { eventEntity.AttendanceCode2StartTime = startTime; eventEntity.AttendanceCode2EndTime = endTime; for (int i = 0; i < totalDays; i++) { //Generate unique attendanceCode2 code2.Add(GenerateCode()); } } else { error = true; await context.PostAsync("Please check your excel file and valid Attendance Code 2 Start/End Time in the format specified(2359). The end time should not be before the start time."); await context.PostAsync(msg); await context.PostAsync("Talk to me again if you require my assistance."); context.Done(this); } } else { eventEntity.AttendanceCode2StartTime = ""; eventEntity.AttendanceCode2EndTime = ""; } //End of Attendance Code 2 Time //Check Survey End Date if (sh.GetRow(8).GetCell(1) != null && sh.GetRow(8).GetCell(1).ToString() != "") { date = dataFormatter.FormatCellValue(sh.GetRow(8).GetCell(1)); if (ParseDate(date, sDate)) { split = date.Split(new Char[] { '/', '-' }); date = split[0] + '/' + split[1] + '/' + split[2]; eventEntity.SurveyEndDate = date; } else//Input date is not in the specified format { error = true; await context.PostAsync("Please check your excel file and input a Survey End Date in the format specified(dd-mm-yyyy or dd/mm/yyyy) and not before today's date!"); await context.PostAsync(msg); await context.PostAsync("Talk to me again if you require my assistance."); context.Done(this); } } else { if (eventEntity.EventEndDate != "") { eventEntity.SurveyEndDate = eventEntity.EventEndDate; } else { eventEntity.SurveyEndDate = eventEntity.EventStartDate; } } //End of checking Survey End Date //Check Survey End Time endTime = dataFormatter.FormatCellValue(sh.GetRow(9).GetCell(1)); if (sh.GetRow(9).GetCell(1) != null && sh.GetRow(9).GetCell(1).ToString() != "") { if (ParseTime("0000", endTime)) { eventEntity.SurveyEndTime = endTime; } else { error = true; await context.PostAsync("Please check your excel file and your Survey End Time in the format specified(2359)."); await context.PostAsync(msg); await context.PostAsync("Talk to me again if you require my assistance."); context.Done(this); } } else { eventEntity.SurveyEndTime = "2359"; } //End of Attendance Code 2 Time //Start of Anonymity if (sh.GetRow(11).GetCell(1) != null && sh.GetRow(11).GetCell(1).ToString() != "" && (sh.GetRow(11).GetCell(1).ToString() == "Y" || sh.GetRow(11).GetCell(1).ToString() == "N" || sh.GetRow(11).GetCell(1).ToString() == "Yes" || sh.GetRow(11).GetCell(1).ToString() == "No")) { eventEntity.Anonymous = (sh.GetRow(11).GetCell(1).ToString()); } else { error = true; await context.PostAsync("Please check your excel file and input either Y or N for Anonymity."); await context.PostAsync(msg); await context.PostAsync("Talk to me again if you require my assistance."); context.Done(this); } //End of Anonymity //Start of Email if (sh.GetRow(12).GetCell(1) != null && sh.GetRow(12).GetCell(1).ToString() != "") { try { System.Net.Mail.MailAddress mail = new System.Net.Mail.MailAddress(sh.GetRow(12).GetCell(1).ToString()); eventEntity.Email = (sh.GetRow(12).GetCell(1).ToString()); } catch (FormatException) { error = true; await context.PostAsync("Please check your excel file and input a valid Email address or remove the field."); await context.PostAsync(msg); await context.PostAsync("Talk to me again if you require my assistance."); context.Done(this); } } else { eventEntity.Email = ""; } //End of Email //If the file got no error parsing all the values if (!error) { //Setting eventEntity variables eventEntity.Description = dataFormatter.FormatCellValue(sh.GetRow(10).GetCell(1)); eventEntity.EventName = (sh.GetRow(1).GetCell(1).ToString()); if (sh.GetRow(13).GetCell(1).ToString() != "") { eventEntity.Password = Sha256(sh.GetRow(13).GetCell(1).ToString()); } else { eventEntity.Password = ""; } var survey = new List <QuestionEntity>(); QuestionEntity question = new QuestionEntity(); eventEntity.SurveyCode = GenerateCode(); //retrieving the questions for (int i = 35; i <= sh.LastRowNum; i++) { var answerList = new List <string>(); if (sh.GetRow(i).GetCell(0) != null && sh.GetRow(i).GetCell(0).ToString() != "") { int x = 1; question = new QuestionEntity(eventEntity.SurveyCode, (i - 34).ToString()); question.QuestionText = (sh.GetRow(i).GetCell(0).ToString()); //Retrieving the answer list while (sh.GetRow(i).GetCell(x) != null && sh.GetRow(i).GetCell(x).ToString() != "") { answerList.Add(sh.GetRow(i).GetCell(x).ToString()); x++; } } else { break; } question.AnswerList = JsonConvert.SerializeObject(answerList); survey.Add(question); } //No question is found in excel file if (survey.Count == 0) { await context.PostAsync("Your excel file does not contain any question, please check again! (Read the guidelines in the provided template)"); await context.PostAsync(msg); await context.PostAsync("Talk to me again if you require my assistance."); context.Done(this); } else//Questions were found in excel file, process inserting of event { eventEntity.Survey = JsonConvert.SerializeObject(survey); for (int i = 0; i < totalDays; i++) { if (code1.Count != 0) { eventEntity.AttendanceCode1 = code1[i]; } if (code2.Count != 0) { eventEntity.AttendanceCode2 = code2[i]; } string code = ""; while (true) { code = Guid.NewGuid().ToString().Substring(0, 8); TableOperation retrieveOperation = TableOperation.Retrieve <EventEntity>(context.UserData.GetValue <string>(ContextConstants.UserId), code); TableResult retrievedResult = eventTable.Execute(retrieveOperation); if (retrievedResult.Result == null) { break; } } eventEntity.RowKey = code; eventEntity.Day = (i + 1).ToString(); TableOperation insertOperation1 = TableOperation.InsertOrMerge(eventEntity); eventTable.Execute(insertOperation1); } await context.PostAsync(msg); string eventMsg = "'" + eventEntity.EventName + "' has been created, with a total of " + survey.Count + " questions. \n\n"; eventMsg += "Date: " + eventEntity.EventStartDate + " to " + eventEntity.EventEndDate + "\n\n"; eventMsg += "Attendance Code 1: \n\n"; for (int i = 0; i < code1.Count; i++) { eventMsg += "Day " + (i + 1) + ": " + (code1[i] == null ? "-" : code1[i]) + "\n\n"; } eventMsg += "\n\n" + "Attendance Code 2: \n\n"; for (int i = 0; i < code2.Count; i++) { eventMsg += "Day " + (i + 1) + ": " + (code2[i] == null ? "-" : code2[i]) + "\n\n"; } eventMsg += "\n\n" + "Survey Code: " + eventEntity.SurveyCode + "\n\n\n\n" + "Type /Event to manage your event. Thank you and have a great day ahead!"; await context.PostAsync(eventMsg); bool a = SharedFunction.EmailEvent(eventEntity, context.UserData.GetValue <string>(ContextConstants.Name), survey, code1, code2); context.Done(this); } } } else//Input date is not in the specified format { await context.PostAsync("Please check your excel file and input a date in the format specified(dd-mm-yyyy or dd/mm/yyyy) and not before today's date!"); await context.PostAsync(msg); await context.PostAsync("Talk to me again if you require my assistance."); context.Done(this); } } else { await context.PostAsync("Please check your excel file to see if you have inputted an Event Name and Event Start Date!"); await context.PostAsync(msg); await context.PostAsync("Talk to me again if you require my assistance."); context.Done(this); } } catch (Exception ex) { await context.PostAsync("Sorry there is an error trying to open your file, please type \'/ce\' to try again."); context.Done(this); } } } catch (Exception e) { await context.PostAsync("Sorry there is an error trying to open your file, please type \'/ce\' to try again."); context.Done(this); } } catch (TooManyAttemptsException e) { } }
private async Task ShowEventCardAsync(IDialogContext context, string eventDetail, EventEntity oneEventEntity) { AdaptiveCard card = new AdaptiveCard() { Body = new List <CardElement>() { new Container() { Speak = "<s>Hi, this is your selected Event Details</s>", Items = new List <CardElement>() { new ColumnSet() { Columns = new List <Column>() { new Column() { Size = ColumnSize.Stretch, Items = new List <CardElement>() { new TextBlock() { Text = "Your Selected Event Details", Weight = TextWeight.Bolder, IsSubtle = true }, new TextBlock() { Text = eventDetail, Wrap = true } } } } } } } }, // Buttons Actions = new List <ActionBase>() { new SubmitAction() { Title = "Delete Event", Speak = "<s>Delete Event</s>", DataJson = "{ \"Type\": \"DeleteEvent\" }" }, new ShowCardAction() { Title = "Edit Survey Questions", Speak = "<s>Edit Survey Questions</s>", Card = GetEditSurveyCard(oneEventEntity) } } }; Attachment attachment = new Attachment() { ContentType = AdaptiveCard.ContentType, Content = card }; var reply = context.MakeMessage(); reply.Attachments.Add(attachment); await context.PostAsync(reply, CancellationToken.None); context.Wait(MessageReceivedAsync); }
private async Task MessageReceivedAsync(IDialogContext context, IAwaitable <IMessageActivity> result) { var message = await result; try { EventEntity oneEventEntity = new EventEntity(); bool foundEvent = false; int option = Convert.ToInt32(message.Text); string oneEvent; //Check the option selected exists for the event if (eventDict.TryGetValue(option, out oneEvent)) { cacheOption = option; oneEventEntity = JsonConvert.DeserializeObject <EventEntity>(oneEvent); foundEvent = true; } else //Option is not selected / cannot be found { //however if dialog is run for second times, then it uses the cache option to gather event details if (eventDict.TryGetValue(cacheOption, out oneEvent)) { oneEventEntity = JsonConvert.DeserializeObject <EventEntity>(oneEvent); foundEvent = true; } // Got an Action Submit (Dialog run for second time; action taken for adaptative card buttons) dynamic value = message.Value; string submitType = value.Type.ToString(); switch (submitType) { case "SaveEditSurvey": SaveEditSurvey(context, message.Value, oneEventEntity); await context.PostAsync("Your event's survey has been successfully saved!"); context.Done(this); return; case "DeleteEvent": await DeleteEventCardAsync(context); return; case "YesDeleteEvent": var storageAccount = CloudStorageAccount.Parse(ConfigurationManager.AppSettings["AzureWebJobsStorage"]); var tableClient = storageAccount.CreateCloudTableClient(); CloudTable cloudTable = tableClient.GetTableReference("Event"); cloudTable.CreateIfNotExists(); cloudTable.Execute(TableOperation.Delete(oneEventEntity)); await context.PostAsync("Your event has been successfully deleted!"); context.Done(this); return; case "NoDeleteEvent": await context.PostAsync("Okayy, talk to me again if you need assistance!"); context.Done(this); return; } await context.PostAsync("Your option is out of range! Please enter again or type \"exit\" to exit the conversation."); } //Event found if (foundEvent) { var eventDetail = ""; eventDetail += "Event Name: " + oneEventEntity.EventName + "\n\n"; eventDetail += "Event Date: " + oneEventEntity.EventStartDate + "\n\n"; eventDetail += "Attendance Code 1: " + oneEventEntity.AttendanceCode1 + "\n\n"; eventDetail += "Attendance Code 2: " + oneEventEntity.AttendanceCode2 + "\n\n"; eventDetail += "Survey Code: " + oneEventEntity.RowKey + "\n\n"; //Adaptive Card starts from here await ShowEventCardAsync(context, eventDetail, oneEventEntity); } } catch (Exception) { await context.PostAsync("It seems like your option is not an number. Please enter again or type \"exit\" to exit the conversation."); } }
private async Task MessageReceivedAsync(IDialogContext context, IAwaitable <IMessageActivity> result) { var message = await result; var msg = context.MakeMessage(); msg.Type = ActivityTypes.Typing; await context.PostAsync(msg); var storageAccount = CloudStorageAccount.Parse(ConfigurationManager.AppSettings["AzureWebJobsStorage"]); var tableClient = storageAccount.CreateCloudTableClient(); CloudTable eventTable = tableClient.GetTableReference("Event"); eventTable.CreateIfNotExists(); DateTime thisDay = DateTime.Today; String today = FormatDate(thisDay.ToString("d")); EventEntity eventEntity = null; string codeEntered = ""; if (message.Attachments.FirstOrDefault() != null) { string destinationContainer = "qrcode"; CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient(); var blobContainer = blobClient.GetContainerReference(destinationContainer); blobContainer.CreateIfNotExists(); String newFileName = ""; var a = message.Attachments.FirstOrDefault(); try { using (HttpClient httpClient = new HttpClient()) { var responseMessage = await httpClient.GetAsync(a.ContentUrl); var contentLenghtBytes = responseMessage.Content.Headers.ContentLength; var fileByte = await httpClient.GetByteArrayAsync(a.ContentUrl); newFileName = context.UserData.GetValue <string>(ContextConstants.UserId) + "_" + DateTime.Now.ToString("MMddyyyy-hhmmss") + "_" + "qrcode"; var barcodeReader = new BarcodeReader(); var memoryStream = new MemoryStream(fileByte); string sourceUrl = a.ContentUrl; var barcodeBitmap = (Bitmap)Bitmap.FromStream(memoryStream); var barcodeResult = barcodeReader.Decode(barcodeBitmap); codeEntered = barcodeResult.Text; eventEntity = GetEvent(barcodeResult.Text); memoryStream.Close(); } } catch (Exception e) { Debug.WriteLine(e.ToString()); } } else { codeEntered = message.Text; eventEntity = GetEvent(message.Text); } //Check database if (eventEntity != null) { var eventName = eventEntity.EventName; CloudTable attendanceTable = tableClient.GetTableReference("Attendance"); attendanceTable.CreateIfNotExists(); String filterA = TableQuery.GenerateFilterCondition("SurveyCode", QueryComparisons.Equal, eventEntity.SurveyCode); String filterB = TableQuery.GenerateFilterCondition("RowKey", QueryComparisons.Equal, context.UserData.GetValue <string>(ContextConstants.UserId)); String filterD = TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, eventEntity.RowKey); TableQuery <AttendanceEntity> query = new TableQuery <AttendanceEntity>().Where(TableQuery.CombineFilters(filterA, TableOperators.And, filterB)); TableQuery <AttendanceEntity> todayQuery = new TableQuery <AttendanceEntity>().Where(TableQuery.CombineFilters(TableQuery.CombineFilters(filterA, TableOperators.And, filterB), TableOperators.And, filterD)); var results = attendanceTable.ExecuteQuery(query); var todayResults = attendanceTable.ExecuteQuery(todayQuery); Boolean notDone = true; //Survey Code if (codeEntered == eventEntity.SurveyCode) { if (results != null) { foreach (AttendanceEntity a in results) { if (a.Survey == true) { notDone = false; await context.PostAsync("You have already completed the survey for " + "'" + eventName + "'!"); await context.PostAsync(msg); await context.PostAsync("Talk to me again if you require my assistance."); context.Done(this); } } if (notDone && !ValidPeriod(eventEntity.SurveyEndDate, eventEntity.SurveyEndTime, eventEntity.EventStartDate)) { await context.PostAsync("Sorry, this code is not yet ready for use or have already expired!"); await context.PostAsync(msg); await context.PostAsync("Talk to me again if you require my assistance."); context.Done(this); } } context.UserData.SetValue(ContextConstants.Status, "3"); context.UserData.SetValue(ContextConstants.Survey, eventEntity.Survey); //Attendance Code 1 } else if (codeEntered == eventEntity.AttendanceCode1) { if (todayResults != null) { foreach (AttendanceEntity a in todayResults) { if (a.Morning == true) { notDone = false; await context.PostAsync("You have already registered this attendance for " + "'" + eventName + "'" + " today!"); await context.PostAsync(msg); await context.PostAsync("Talk to me again if you require my assistance."); context.Done(this); } } if (notDone && !ValidTime(eventEntity.AttendanceCode1StartTime, eventEntity.AttendanceCode1EndTime, eventEntity.Day, eventEntity.EventStartDate, eventEntity.EventEndDate)) { await context.PostAsync("Sorry, this code is not yet ready for use or have already expired!"); await context.PostAsync(msg); await context.PostAsync("Talk to me again if you require my assistance."); context.Done(this); } } context.UserData.SetValue(ContextConstants.Status, "1"); }//Attendance code 2 else if (codeEntered == eventEntity.AttendanceCode2) { if (todayResults != null) { foreach (AttendanceEntity a in todayResults) { if (a.Afternoon == true) { notDone = false; await context.PostAsync("You have already registered this attendance for " + "'" + eventName + "'" + " today!"); await context.PostAsync(msg); await context.PostAsync("Talk to me again if you require my assistance."); context.Done(this); } } if (notDone && !ValidTime(eventEntity.AttendanceCode2StartTime, eventEntity.AttendanceCode2EndTime, eventEntity.Day, eventEntity.EventStartDate, eventEntity.EventEndDate)) { await context.PostAsync("Sorry, this code is not yet ready for use or have already expired!"); await context.PostAsync(msg); await context.PostAsync("Talk to me again if you require my assistance."); context.Done(this); } } context.UserData.SetValue(ContextConstants.Status, "2"); } context.UserData.SetValue(ContextConstants.EventCode, eventEntity.RowKey); context.UserData.SetValue(ContextConstants.SurveyCode, eventEntity.SurveyCode); context.UserData.SetValue(ContextConstants.Anonymous, eventEntity.Anonymous); context.UserData.SetValue(ContextConstants.EventName, eventName); context.UserData.SetValue(ContextConstants.Today, today); context.UserData.SetValue(ContextConstants.Description, eventEntity.Description); context.Done(true); } else { await context.PostAsync("I'm sorry, I think you have keyed in the wrong workshop code or have sent an invalid QR Code, let's do this again."); context.Wait(this.MessageReceivedAsync); } }