protected override void Initialize()
        {
            var dataService = Container.Resolve <IDataService>();

            var view  = new InteractiveReport();
            var model = new InteractiveReportViewModel(dataService);

            view.ViewModel = model;

            MasterView = view;
        }
Beispiel #2
0
        public void ProcessTaskReports(CSTask task)
        {
            Dictionary <string, int> answersMap         = new Dictionary <string, int>();
            List <double>            listOfAnswersIndex = new List <double>();
            Dictionary <int, int>    answersIncentive   = null;
            List <InteractiveReport> listResports       = new List <InteractiveReport>();
            InteractiveReport        intReport          = null;
            IncentiveAssigned        incentive          = null;
            int    index      = 1;
            object taskReward = null;
            string txId       = null;

            //creates association between answer Index and answerId
            //this will allow to sort the answers to calculate the z-score modified
            foreach (TaskAnswer answer in task.InteractiveTask.Answers)
            {
                answersMap.Add(answer.AnswerId, index);
                index++;
            }

            foreach (string reportID in task.ReportsID.Values.ToList())
            {
                //get report from repository
                intReport = RepositoryRemote.GetInteractiveReportsByID(reportID);
                //add the first report result
                if (answersMap.ContainsKey(intReport.Result.AnswerId))
                {
                    listOfAnswersIndex.Add(answersMap[intReport.Result.AnswerId]);
                }
                listResports.Add(intReport);
            }
            if (listOfAnswersIndex.Count == 0)
            {
                Log.Debug("No Answers to Process");
                return;
            }
            //get for each answer its reward value
            answersIncentive = DataQualityProcess(listOfAnswersIndex);
            incentive        = this.IncentiveScheme.Incentive.CompleteTaskIncentive();
            foreach (InteractiveReport report in listResports)
            {
                index = answersMap[report.Result.AnswerId];
                incentive.IncentiveQty = answersIncentive[index];

                this.IncentiveScheme.RewardUser(report.UserID, incentive, out taskReward, out txId);
                this.RepositoryRemote.SaveReportReward(task.TaskID, report.ReportID, (Dictionary <string, string>)taskReward, txId);
            }
        }