コード例 #1
0
        private async Task <CaseDetails> GetCustomerContactAsync(String cxmEndPoint, String cxmAPIKey, String caseReference, String taskToken)
        {
            CaseDetails caseDetails = new CaseDetails();
            HttpClient  cxmClient   = new HttpClient();

            cxmClient.BaseAddress = new Uri(cxmEndPoint);
            String             requestParameters = "key=" + cxmAPIKey;
            HttpRequestMessage request           = new HttpRequestMessage(HttpMethod.Get, "/api/service-api/norbert/case/" + caseReference + "?" + requestParameters);

            try
            {
                HttpResponseMessage response = cxmClient.SendAsync(request).Result;
                if (response.IsSuccessStatusCode)
                {
                    HttpContent responseContent = response.Content;
                    String      responseString  = responseContent.ReadAsStringAsync().Result;
                    JObject     caseSearch      = JObject.Parse(responseString);
                    caseDetails.customerContact = (String)caseSearch.SelectToken("values.enquiry_details");
                }
                else
                {
                    await SendFailureAsync("Getting case details for " + caseReference, response.StatusCode.ToString());

                    Console.WriteLine("ERROR : GetCustomerContactAsyncc : " + request.ToString());
                    Console.WriteLine("ERROR : GetCustomerContactAsync : " + response.StatusCode.ToString());
                }
            }
            catch (Exception error)
            {
                await SendFailureAsync("Getting case details for " + caseReference, error.Message);

                Console.WriteLine("ERROR : GetCustomerContactAsync : " + error.StackTrace);
            }
            return(caseDetails);
        }
コード例 #2
0
        private async Task <String> GetCaseDetailsAsync()
        {
            String cxmServiceArea = null;

            CaseDetails caseDetails = await GetCustomerContactAsync(cxmEndPoint, cxmAPIKey, caseReference, taskToken);

            try
            {
                if (!String.IsNullOrEmpty(caseDetails.customerContact))
                {
                    String response = await GetIntentFromLexAsync(caseDetails.customerContact);

                    if (!String.IsNullOrEmpty(response))
                    {
                        Console.WriteLine("Service : " + response);
                        switch (response)
                        {
                        case "Feedback":
                            cxmServiceArea = "customer_feedback_nbc_feedback";
                            break;

                        case "EnvironmentalHealth":
                            cxmServiceArea = "environmental_health";
                            break;

                        case "Events":
                            cxmServiceArea = "events";
                            break;

                        case "GeneralEnquiries":
                            cxmServiceArea = "general_enquiries";
                            break;

                        case "HousingCustomerServices":
                            cxmServiceArea = "housing_customer_services";
                            break;

                        case "HousingRepairs":
                            cxmServiceArea = "housing_repairs";
                            break;

                        case "Streetcare":
                            cxmServiceArea = "streetcare_services_waste_and_recycling_grounds_maintenance";
                            break;

                        default:
                            cxmServiceArea = "general_enquiries";
                            await SendFailureAsync("Unexpected Intent Returned : " + response, "GetCaseDetailsAsync");

                            Console.WriteLine("ERROR : Unexpected Intent Returned : " + response);
                            break;
                        }
                    }
                    else
                    {
                        cxmServiceArea = "general_enquiries";
                    }
                }
            }
            catch (Exception error)
            {
                cxmServiceArea = "general_enquiries";
                await SendFailureAsync(error.Message, "GetCaseDetailsAsync");

                Console.WriteLine("ERROR : GetCaseDetailsAsync :  " + error.Message);
            }
            return(cxmServiceArea);
        }