public static async Task <ValidateResult> ValidateWebAddress(NewWebsiteRequest state, object value) { var asString = value as string; var result = new ValidateResult() { IsValid = false, Value = value }; if (!string.IsNullOrEmpty(asString)) { var extracted = CMSFormRequest.ExtractWebAddress(asString); if (string.IsNullOrEmpty(extracted)) { result.Value = string.Empty; result.Feedback = "That is not a valid web Address. Please enter a valid URL."; } else { result.Value = extracted; result.IsValid = true; } } return(result); }
private async Task CMSFormComplete(IDialogContext context, IAwaitable <CMSFormRequest> result) { CMSFormRequest cmsRequest = null; try { cmsRequest = await result; } catch (OperationCanceledException) { await context.PostAsync("You Cancelled the form!"); return; } if (cmsRequest != null) { RootDialog.SendEmail(); await context.PostAsync("A request for CMS Account is successfuly raised. You will receive a confirmation email."); await context.PostAsync("Is there anything else I can help you with?"); } else { await context.PostAsync("Form returned empty response!"); } context.Wait(MessageReceivedAsync); }
public static async Task <ValidateResult> ValidateWebAddress(CMSFormRequest state, object value) { var asString = value as string; var result = new ValidateResult() { IsValid = false, Value = value }; if (!string.IsNullOrEmpty(asString)) { //you could make a call to LUIS here, but does not seem necessary for email address validation var extracted = ExtractWebAddress(asString); if (string.IsNullOrEmpty(extracted)) { result.Value = string.Empty; result.Feedback = "That is not a valid web Address. Please enter a valid URL."; } else { result.Value = extracted; result.IsValid = true; } } return(result); }
public static async Task <ValidateResult> ValidateDepartment(CMSFormRequest state, object value) { var comparisonString = value as string; var result = new ValidateResult() { IsValid = true, Value = value }; string uri = "https://departments.documents.azure.com:443/"; string key = ConfigurationManager.AppSettings["DocumentDbKey"]; DocumentClient client; SqlQuerySpec query = new SqlQuerySpec("SELECT d.longname FROM departments d WHERE d.url = @comparisonString OR d.longname = @comparisonString"); query.Parameters = new SqlParameterCollection(); query.Parameters.Add(new SqlParameter("@comparisonString", comparisonString.ToLower())); client = new DocumentClient(new Uri(uri), key); foreach (var dept in client.CreateDocumentQuery(UriFactory.CreateDocumentCollectionUri("departments", "departments"), query)) { if (dept == null) { result.Value = comparisonString; } else { result.Value = dept.longname; return(result); } } return(result); }
public async Task AfterCMSFormComplete(IDialogContext context, IAwaitable <CMSFormRequest> result) { CMSFormRequest cmsRequest = null; try { cmsRequest = await result; } catch (OperationCanceledException) { await context.PostAsync("You Cancelled the form!"); return; } if (cmsRequest != null) { context.PrivateConversationData.SetValue("ProfileComplete", true); context.PrivateConversationData.SetValue("FullName", cmsRequest.FullName); context.PrivateConversationData.SetValue("Department", cmsRequest.Department); context.PrivateConversationData.SetValue("UserEmail", cmsRequest.userEmail); context.PrivateConversationData.SetValue("WebAddress", cmsRequest.WebAddress); if (cmsRequest.PhoneNumber == null) { context.PrivateConversationData.SetValue("Phone", ""); } else { context.PrivateConversationData.SetValue("Phone", cmsRequest.PhoneNumber); } if (cmsRequest.ExtraNotes == null) { context.PrivateConversationData.SetValue("ExtraNotes", ""); } else { context.PrivateConversationData.SetValue("ExtraNotes", cmsRequest.ExtraNotes); } context.PrivateConversationData.SetValue("SupervisorName", cmsRequest.SupervisorName); context.PrivateConversationData.SetValue("SupervisorEmail", cmsRequest.SupervisorEmail); BasicLuisDialog.SendEmail(cmsRequest, null); await context.PostAsync("A request for CMS Account is successfuly raised. You will receive a confirmation email."); Fullname_lan = cmsRequest.FullName; Department_lan = cmsRequest.Department; UserEmail_lan = cmsRequest.userEmail; PromptDialog.Choice( context: context, resume: AfterFurtherAssistance, prompt: "Do you still require help with this issue? ", options: (IEnumerable <YesOrNo>)Enum.GetValues(typeof(YesOrNo)), retry: "Please select one of the choices.", promptStyle: PromptStyle.Auto ); } else { await context.PostAsync("Form returned empty response!"); } }