示例#1
0
        public static ResponseSet GenerateResponseSet(ResponseSetType type, Survey survey)
        {
            ResponseSet set = new ResponseSet();

            set.ID       = rand.Next(0, 1000);
            set.SurveyID = survey.ID;
            set.SystemID = LoginViewModelTest.SERVER_PATH;
            set.Name     = rand.Next(0, 1000).ToString();
            switch (type)
            {
            case ResponseSetType.Completed:
                set.IsCompleted = true;
                break;

            case ResponseSetType.InProgress:
                set.IsCompleted = false;
                set.IsSubmitted = false;
                break;

            case ResponseSetType.Submitted:
                set.IsSubmitted = true;
                break;

            default:
                break;
            }

            set.UserID = Membership.CurrentUser.ID;
            return(set);
        }
        public void PostCallanalysisresponsesetsTest()
        {
            // TODO: add unit test for the method 'PostCallanalysisresponsesets'
            ResponseSet body     = null; // TODO: replace null with proper value
            var         response = instance.PostCallanalysisresponsesets(body);

            Assert.IsInstanceOf <ResponseSet> (response, "response is ResponseSet");
        }
        public void PutCallanalysisresponsesetsCallanalysissetIdTest()
        {
            // TODO: add unit test for the method 'PutCallanalysisresponsesetsCallanalysissetId'
            string      callAnalysisSetId = null; // TODO: replace null with proper value
            ResponseSet body     = null;          // TODO: replace null with proper value
            var         response = instance.PutCallanalysisresponsesetsCallanalysissetId(callAnalysisSetId, body);

            Assert.IsInstanceOf <ResponseSet> (response, "response is ResponseSet");
        }
示例#4
0
 private void SaveResponseSetExecute()
 {
     this.IsPageEnabled = false;
     this.isSaveStarted = true;
     this.SaveResponseSetCommand.RaiseCanExecuteChanged();
     this.currentResponseSet    = this.responseSetGovernor.CreateNewResponseSetWithAnswers(Categories, CurrentSurvey.ID, this.ResponseSetName);
     this.currentResponsesSetId = this.currentResponseSet.ID;
     NavigationProvider.RootFrame.RemoveBackEntry();
     this.UploadToService();
 }
示例#5
0
        private void SaveRecord()
        {
            ResponseSet current = (ResponseSet)bs.Current;

            if (current.RespSetName == "0") // new wording created by this form
            {
                // insert into table
                DBAction.InsertResponseSet(current);
                Dirty = false;
            }
            else if (Dirty) // existing study edited
            {
                DBAction.UpdateResponseSet(current);
                Dirty = false;
            }
        }
        private void DeleteResponseSetExecute(ResponseSet selectedResponseSet)
        {
            this.BusyCount++;
            bool isDeleted = this.responseRepository.DeleteResponseSet(selectedResponseSet.ID);

            if (isDeleted)
            {
                IEnumerable <ResponseSet> top = null;
                IEnumerable <ResponseSet> all = null;
                switch (this.currentType)
                {
                case ResponseSetsType.Saved:
                    top = this.responseRepository.GetTopSavedResponseSetsForUser(Membership.CurrentUser.ID, TOP_COUNT);
                    all = this.responseRepository.GetSavedResponseSetsForUser(Membership.CurrentUser.ID);
                    break;

                case ResponseSetsType.Submitted:
                    top = this.responseRepository.GetTopSubmittedResponseSetsForUser(Membership.CurrentUser.ID, TOP_COUNT);
                    all = this.responseRepository.GetSubmittedResponseSetsForUser(Membership.CurrentUser.ID);
                    break;
                }

                if (Locator.SurveyDetailsStatic.CurrentSurvey != null && Locator.SurveyDetailsStatic.CurrentSurvey.ID != 0 && Locator.SurveyDetailsStatic.CurrentSurvey.ID == selectedResponseSet.SurveyID)
                {
                    Locator.SurveyDetailsStatic.Refresh();
                }

                this.TopResponses       = new ObservableCollection <ResponseSet>(top);
                this.allResponses       = new ObservableCollection <ResponseSet>(all);
                this.DisplayedResponses = this.allResponses;
#if !UNIT_TEST
                MessageBox.Show((Application.Current.Resources["LanguageStrings"] as LanguageStrings).RESPOSE_DELETED);
#else
                RaiseTestCompleted("RESPONSE_DELETED");
#endif
            }
            else
            {
                MessageBox.Show((Application.Current.Resources["LanguageStrings"] as LanguageStrings).ERROR_RESPONSE_DELETE);
            }

            Locator.NavigationStatic.NavigateToQuestionsCommand.RaiseCanExecuteChanged();
            this.BusyCount--;
        }
示例#7
0
        private void UploadToServiceExecute(ResponseSet selectedResponseSet)
        {
            if (InternetChecker.IsInernetActive)
            {
                if (!selectedResponseSet.IsCompleted)
                {
                    var messageBoxResult = MessageBox.Show(NOT_COMPLETED_RESPONSE_TEXT, string.Empty, MessageBoxButton.OKCancel);
                    if (messageBoxResult == MessageBoxResult.OK)
                    {
                        this.BusyCount++;
                        if (selectedResponseSet.ID == this.currentResponsesSetId)
                        {
                            this.IsPageEnabled = false;
                        }

                        this.responseSetGovernor.UploadResponseSetToServer(selectedResponseSet.ID, this.OnUploadToServiceCompleted);
                    }
                }
                else
                {
                    this.BusyCount++;
                    if (selectedResponseSet.ID == this.currentResponsesSetId)
                    {
                        this.IsPageEnabled = false;
                    }

                    this.responseSetGovernor.UploadResponseSetToServer(selectedResponseSet.ID, this.OnUploadToServiceCompleted);
                }
            }
            else
            {
                MessageBox.Show(NETWORK_UNAVAILABLE_TEXT);
                this.IsPageEnabled = true;
                Locator.SavedResponsesStatic.RefresheExecute();
                Locator.SubmittedResponsesStatic.RefresheExecute();
                if (NavigationProvider.CurrentSource.OriginalString.Contains(Constants.SURVEY_DETAILS_PAGE))
                {
                    Locator.SurveyDetailsStatic.Refresh();
                }
            }

            Locator.NavigationStatic.NavigateToQuestionsCommand.RaiseCanExecuteChanged();
        }
示例#8
0
        public static async System.Threading.Tasks.Task <string> MessageHandler(string inputStr)
        {
            string response = String.Empty;

            // Convert input string to FaqLuis Model
            LuisObject faqLuis = await LuisService.ParseFaqInput(inputStr);

            if (faqLuis.topScoringIntent != null)
            {
                switch (faqLuis.topScoringIntent.intent)
                {
                case "FaqQuery":
                    response = await FaqService.FaqQueryProcessor(faqLuis.topScoringIntent);

                    break;

                case "Assistance":
                    response = ResponseSet.GetRandomResponse(ResponseSet.Assistance);
                    break;

                case "DirectAddress":

                    response = await DirectAddressHandler(inputStr);

                    break;

                case "Farewell":
                    response = ResponseSet.GetRandomResponse(ResponseSet.Farewells);
                    break;

                case "Politeness":
                    response = ResponseSet.GetRandomResponse(ResponseSet.Emojis);
                    break;

                //- Could not place request
                default:
                    response = ResponseSet.GetRandomResponse(ResponseSet.Nones);
                    break;
                }
            }
            return(response);
        }
示例#9
0
        private void LoadContent(object sender, DoWorkEventArgs e)
        {
            if (pageParameters != null && pageParameters.ContainsKey(SURVEY_ID_STRING))
            {
                int surveyId = int.Parse(pageParameters[SURVEY_ID_STRING]);
                this.currentSurvey = this.surveyRepository.GetSurveyByID(surveyId);
                this.categories    = new ObservableCollection <Category>(this.currentSurvey.Category);
            }

            if (pageParameters != null && pageParameters.ContainsKey(RESPONSESET_ID_STRING))
            {
                this.currentResponsesSetId = int.Parse(pageParameters[RESPONSESET_ID_STRING]);
                this.currentSurvey         = this.surveyRepository.GetSurveyByResponseSetID(currentResponsesSetId);
                this.currentResponseSet    = this.responseSetRepository.GetResponseSetForUserByID(this.currentResponsesSetId);
                this.isSaveButtonVisible   = !this.currentResponseSet.IsSubmitted;
                this.categories            = new ObservableCollection <Category>(this.currentSurvey.Category);
            }

            if (pageParameters != null && pageParameters.ContainsKey(OPEN_DUPLICATE))
            {
                this.isSaveButtonVisible = bool.Parse(pageParameters[OPEN_DUPLICATE]);
            }

            SyncContext.Post((parameter) =>
            {
                responseSetGovernor.PopulateCategoriesQuestionsWithResponseSetAnswers(this.categories, currentResponsesSetId);

                var questionsCollection = categories.SelectMany(c => c.Question);
                this.AllItemsCount      = questionsCollection.Count();

                foreach (var question in questionsCollection)
                {
                    question.UpdateDependentQuestionsData();
                }

                this.IsSaveButtonVisible = this.isSaveButtonVisible;
                this.CurrentSurvey       = this.currentSurvey;
                this.Categories          = this.categories;
                this.BusyCount--;
                Locator.NavigationStatic.NavigateToSaveResponsesCommand.RaiseCanExecuteChanged();
            }, null);
        }
示例#10
0
        public ResponseSet CreateNewResponseSetWithAnswers(System.Collections.Generic.IEnumerable <DataAccessModels.Category> categories, int surveyID, string responseSetName)
        {
            var responseSet = new ResponseSet
            {
                DateSaved   = DateTime.Now,
                IsSubmitted = false,
                SurveyID    = surveyID,
                UserID      = Membership.CurrentUser.ID,
                SystemID    = GenerateUniqueID(),
                Name        = responseSetName,
                IsCompleted = false,
                Progress    = 0,
            };

            using (var responseSetRepository = new ResponseSetRepository())
            {
                responseSetRepository.AddResponseSetToDB(responseSet);
            }

            return(UpdateResponseSetWithAnswers(categories, responseSet.ID));
        }
示例#11
0
 // Constructor: When a ChatBot is instantiated, it creates a ResponseSet
 public Chatbot()
 {
     this._responses = new ResponseSet();
     Console.WriteLine("Responses assigned to bot");
 }
示例#12
0
        // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

        public static async Task <string> DirectAddressHandler(string inputStr)
        {
            string response = String.Empty;

            // Convert input string to FaqLuis Model
            LuisObject directAddressLuis = await LuisService.ParseDirectAddressInput(inputStr);

            if (directAddressLuis.topScoringIntent != null)
            {
                switch (directAddressLuis.topScoringIntent.intent)
                {
                //- Questions abot how the bot is doing
                case "Feeling":
                    response = ResponseSet.SegwayFromResponse(ResponseSet.Feeling);
                    break;

                //- The bot's past or family
                case "Origin":
                    response = ResponseSet.SegwayFromResponse(ResponseSet.Origin);
                    break;

                //- Age, name, stuff you'd find on a Driver License
                case "Personal":
                    response = ResponseSet.SegwayFromResponse(ResponseSet.Personal);
                    break;

                //- Responses to confessions of love
                case "Affectionate":
                    response = ResponseSet.SegwayFromResponse(ResponseSet.Affectionate);
                    break;

                //- What the bot likes to do off the clock
                case "Hobbies":
                    response = ResponseSet.SegwayFromResponse(ResponseSet.Hobbies);
                    break;

                //- Speculation
                case "Future":
                    response = ResponseSet.SegwayFromResponse(ResponseSet.Future);
                    break;

                //- Hostility expressed toward the bot
                case "Adversarial":
                    response = ResponseSet.SegwayFromResponse(ResponseSet.Adversarial);
                    break;

                //- Questions about other bots and companies
                case "Robots":
                    response = ResponseSet.SegwayFromResponse(ResponseSet.Robots);
                    break;

                //- Questions bout the bot's gender
                case "Gender":
                    response = ResponseSet.SegwayFromResponse(ResponseSet.Gender);
                    break;

                //- Questions about faith and spirituality
                case "Religion":
                    response = ResponseSet.SegwayFromResponse(ResponseSet.Religion);
                    break;

                //- Could not place
                default:
                    response = ResponseSet.SegwayFromResponse(ResponseSet.DirectAddress);
                    break;
                }
            }
            return(response);
        }
示例#13
0
 public void AddResponseSetToDB(ResponseSet responseSet)
 {
     _context.ResponseSet.InsertOnSubmit(responseSet);
     _context.SubmitChanges();
 }
 public void Init()
 {
     instance = new ResponseSet();
 }
示例#15
0
        public async Task <JsonRpcParamsResponse> Exec(JsonRpcQuery request)
        {
            if (this._client == null)
            {
                if (!await this.Connect())
                {
                    throw new WebSocketException("Connection Refused.");
                }
            }

            var isQuery = (request is JsonRpcQueryRequest);
            var resTask = default(Task <JsonRpcParamsResponse>);

            if (isQuery)
            {
                var id     = ((JsonRpcQueryRequest)request).Id;
                var resSet = new ResponseSet();
                resTask = resSet.ResponseTask;

                if (!this._responseDictionary.TryAdd(id, resSet))
                {
                    throw new ThreadStateException("ResponseSet Cannot Registered.");
                }
            }
            else
            {
                resTask = Task <JsonRpcParamsResponse> .Run(() =>
                {
                    return(new JsonRpcParamsResponse());
                });
            }

            try
            {
                var sendJson = JsonConvert.SerializeObject(request);
                var bytes    = Encoding.UTF8.GetBytes(sendJson);
                var segment  = new ArraySegment <byte>(bytes);

                await this._client.SendAsync(
                    segment,
                    WebSocketMessageType.Text,
                    true,
                    CancellationToken.None
                    );
            }
            catch (Exception ex)
            {
                var response = new JsonRpcParamsResponse()
                {
                    Error = ex
                };
                if (request is JsonRpcQueryRequest)
                {
                    response.Id = ((JsonRpcQueryRequest)request).Id;
                }

                return(response);
            }

            return(await resTask);
        }