public ViewOrderWindow(int orderId)
        {
            InitializeComponent();
            OrderId = orderId;

            _orderRepo = ServiceResolver.Get().Resolve <IOrderRepository>();
        }
示例#2
0
        async Task <QnaMakerResult> IQnAMakerService.SearchKbAsync(string question)
        {
            var kbId            = settings[QnAMakerKnowledgeBaseId];
            var subscriptionKey = settings[QnAMakerSubscriptionKey];
            var endpoint        = settings[QnAMakerEndPoint];

            //Build the URI
            var uri = new UriBuilder($"{endpoint}/knowledgebases/{kbId}/generateAnswer").Uri;

            var postBody = JsonConvert.SerializeObject(new QnaMakerQuestion
            {
                Question = question
            });

            string responseString;

            log.Debug($"postBody : {postBody}");

            //Send the POST request
            using (var client = ServiceResolver.Get <IWebClient>())
            {
                client.Headers.Add("Content-Type", "application/json");
                client.Headers.Add("Ocp-Apim-Subscription-Key", subscriptionKey);
                responseString = await client.UploadStringTaskAsync(uri, postBody);
            }

            log.Debug($"responseString : {responseString}");

            var result = ConvertResponseFromJson(responseString);

            return(result);
        }
        async Task <MessageResponse> IWatsonConversationService.SendMessage(string message, dynamic context)
        {
            using (var client = ServiceResolver.Get <IWebClient>())
            {
                var credential = settings[WatsonCredential];
                var endpoint   = new UriBuilder(settings[WatsonEndPoint]).Uri;

                client.Headers.Add("Content-Type", "application/json");
                client.Headers.Add("Authorization", $"Basic {credential}");

                dynamic inputContext = context;

                dynamic messageObj = new ExpandoObject();

                messageObj.input      = new ExpandoObject();
                messageObj.input.text = CorrectInputMessage(message);
                messageObj.context    = inputContext;

                var data = JsonConvert.SerializeObject(messageObj);

                log.Debug($"message : {message}");
                log.Debug($"data : {data}");

                var responseMessage = await client.UploadStringTaskAsync(endpoint, data);

                log.Debug($"responseMessage : {responseMessage}");

                return(JsonConvert.DeserializeObject <MessageResponse>(responseMessage));
            }
        }
        IActor IStewardManager.GetActor(IStewardDialogContext context, IConversationData conversationData)
        {
            if (conversationData.IsHandled())
            {
                return(new WatsonActor(context, conversationData));
            }

            if (conversationData.IsAskingForOwner())
            {
                return(new OwnerServiceActor(context
                                             , conversationData
                                             , ServiceResolver.Get <ISettings>()
                                             , ServiceResolver.Get <ILogManager>().GetLogger(typeof(OwnerServiceActor))));
            }

            if (conversationData.IsAskingForServiceCloudCase())
            {
                return(new ServiceCloudCaseActor(context
                                                 , conversationData
                                                 , ServiceResolver.Get <ISettings>()
                                                 , ServiceResolver.Get <ILogManager>().GetLogger(typeof(ServiceCloudCaseActor))));
            }

            return(new QnAMakerActor(context));
        }
示例#5
0
        public AddItemWindow()
        {
            InitializeComponent();

            _productRepo = ServiceResolver.Get().Resolve <IProductRepository>();

            _viewModel  = new AddItemViewModel();
            DataContext = _viewModel;
        }
示例#6
0
        public ViewOrdersWindow()
        {
            InitializeComponent();
            _openOrderWindows = new Dictionary <int, ViewOrderWindow>();

            _orderRepo = ServiceResolver.Get().Resolve <IOrderRepository>();

            _viewModel  = new ViewOrdersViewModel();
            DataContext = _viewModel;
        }
        public ViewProductsWindow()
        {
            InitializeComponent();
            Loaded += OnWindowLoaded;

            _productRepo = ServiceResolver.Get().Resolve <IProductRepository>();

            _viewModel  = new ViewProductsViewModel();
            DataContext = _viewModel;
        }
        public AddressSearchWindow()
        {
            InitializeComponent();

            _addressService = ServiceResolver.Get().Resolve <IAddressLookupService>();

            _viewModel = new AddressSearchViewModel
            {
                Addresses = new List <AddressFindResult.Address>()
            };

            DataContext = _viewModel;
        }
示例#9
0
        async Task IActor.Execute()
        {
            using (var client = ServiceResolver.Get <IWebClient>())
            {
                dynamic data = conversationData[RequestDataName];

                string appName = data.appName;

                await PostAsync("Finding owners of " + appName);

                var endpoint = GetEndPoint(data);

                client.Headers.Add("Content-Type", "application/json");
                client.Headers.Add("Accept", "application/json");

                try
                {
                    string responseMessage = await client.DownloadStringTaskAsync(endpoint);

                    log.Debug($"responseMessage : {responseMessage}");

                    if (string.IsNullOrWhiteSpace(responseMessage))
                    {
                        await PostAsync($"{appName} is not available!");

                        return;
                    }

                    var owners = JsonConvert.DeserializeObject <AppOwner[]>(responseMessage);

                    await PostAsync($"Owners for {appName}");

                    foreach (var owner in owners)
                    {
                        var replyMessage = string.Empty;
                        replyMessage += $"**Name : **\n\n{owner.Name}\n\n\n\n";
                        replyMessage += $"** Email :**\n\n{owner.Email}\n\n\n\n";
                        await PostAsync(replyMessage);
                    }
                }
                catch (WebException webExc)
                {
                    log.Error(webExc.StackTrace);

                    await PostAsync("Sorry! There is something wrong at the moment. Please try again later.");
                }
            }
        }
        async Task IActor.Execute()
        {
            using (var client = ServiceResolver.Get <IWebClient>())
            {
                dynamic data = conversationData[RequestDataName];

                string caseId = data.caseId;

                await PostAsync("Finding case #" + caseId + " information...");

                var endpoint = GetEndPoint(data);

                client.Headers.Add("Content-Type", "application/json");
                client.Headers.Add("Accept", "application/json");

                try
                {
                    string responseMessage = await client.DownloadStringTaskAsync(endpoint);

                    log.Debug($"responseMessage : {responseMessage}");

                    if (string.IsNullOrWhiteSpace(responseMessage))
                    {
                        await PostAsync($"The case #{caseId} is not available!");

                        return;
                    }

                    dynamic anObject = JsonConvert.DeserializeObject <ServiceCloudCase>(responseMessage);

                    var replyMessage = GetReplyMessage(anObject);

                    await PostAsync(replyMessage);
                }
                catch (WebException webExc)
                {
                    log.Error(webExc.StackTrace);

                    await PostAsync("Sorry! There is something wrong at the moment. Please try again later.");
                }
            }
        }
 protected T GetObject <T>()
 {
     return(ServiceResolver.Get <T>());
 }
 protected ILog GetLog(Type type)
 {
     return(ServiceResolver.Get <ILogManager>().GetLogger(type));
 }
示例#13
0
 protected virtual ILog GetLog()
 {
     return(ServiceResolver.Get <ILogManager>().GetLogger(typeof(StewardWatsonDialog)));
 }
示例#14
0
 protected override void OnExit(ExitEventArgs e)
 {
     ServiceResolver.Get().Dispose();
     base.OnExit(e);
 }