コード例 #1
0
        public void InsertXml(DocumentSeriesItemWSO keyValue)
        {
            if (_parameterService.GetBoolean("CustomerSatisfactionEnabled"))
            {
                keyValue.IdDocumentSeries = _parameterService.GetInteger("CustomerSatisfactionSeriedId");
            }
            var xml = SerializationHelper.SerializeToString(keyValue);

            MyMaster.Client.Insert(xml);
        }
コード例 #2
0
        private List <ReportModel> GenerateReport(DateTime reportDate)
        {
            int    idDocumentSeriesItem = _parameterService.GetInteger("CustomerSatisfactionSeriedId");
            string dynamicDataXml       = MyMaster.Client.GetDocumentSeriesItem(idDocumentSeriesItem, false, false, false, false, false);
            DocumentSeriesItemWSO documentSeriesItemWSO
                = SerializationHelper.SerializeFromString <DocumentSeriesItemWSO>(dynamicDataXml);

            int year = reportDate.Month == 1
               ? reportDate.AddYears(-1).Year
               : reportDate.Year;

            List <AttributeWSO> attributeWSOs = new List <AttributeWSO>();

            foreach (AttributeWSO attributeWSO in documentSeriesItemWSO.DynamicData)
            {
                attributeWSOs.Add(attributeWSO);
            }

            List <ReportModel> reports = new List <ReportModel>();
            IEnumerable <IGrouping <string, AttributeWSO> > rep = attributeWSOs.GroupBy(x => x.Key);
            Dictionary <string, IOrderedEnumerable <KeyValuePair <string, int> > > keyValuePairs = new Dictionary <string, IOrderedEnumerable <KeyValuePair <string, int> > >();

            foreach (IGrouping <string, AttributeWSO> item in rep)
            {
                string question = item.Key;
                IOrderedEnumerable <KeyValuePair <string, int> > answers =
                    item.GroupBy(x => x.Value)
                    .ToDictionary(y => y.Key, y => y.Count())
                    .OrderByDescending(z => z.Value);
                keyValuePairs.Add(question, answers);
            }
            foreach (KeyValuePair <string, IOrderedEnumerable <KeyValuePair <string, int> > > question in keyValuePairs)
            {
                List <ResponseModel> responseModels = new List <ResponseModel>();
                foreach (KeyValuePair <string, int> answer in question.Value)
                {
                    string response = answer.Key;
                    switch (question.Key)
                    {
                    case "conoscenzaDiQuestaDelSito":
                    {
                        response = Enum.Parse(typeof(ConoscenzaDiQuestaDelSito), answer.Key).DescriptionAttr();
                        break;
                    }

                    case "frequenzaConsulta":
                    {
                        response = Enum.Parse(typeof(FrequenzaConsulta), answer.Key).DescriptionAttr();
                        break;
                    }

                    case "motivoHaConsultato":
                    {
                        response = Enum.Parse(typeof(MotivoHaConsultato), answer.Key).DescriptionAttr();
                        break;
                    }

                    case "favoritoAccessoAlleInformazioni":
                    {
                        response = Enum.Parse(typeof(FavoritoAccessoAlleInformazioni), answer.Key).DescriptionAttr();
                        break;
                    }

                    case "qualitàDiQuestaSezione":
                    {
                        response = Enum.Parse(typeof(QualitàDiQuestaSezione), answer.Key).DescriptionAttr();
                        break;
                    }

                    case "fasciaDiEtà":
                    {
                        response = Enum.Parse(typeof(FasciaDiEtà), answer.Key).DescriptionAttr();
                        break;
                    }

                    case "attualeOccupazione":
                    {
                        response = Enum.Parse(typeof(AttualeOccupazione), answer.Key).DescriptionAttr();
                        break;
                    }

                    case "titoloDiStudio":
                    {
                        response = Enum.Parse(typeof(TitoloDiStudio), answer.Key).DescriptionAttr();
                        break;
                    }

                    case "doveRisiede":
                    {
                        response = Enum.Parse(typeof(DoveRisiede), answer.Key).DescriptionAttr();
                        break;
                    }
                    }
                    float percentage = answer.Value * 100 / question.Value.Sum(x => x.Value);
                    responseModels.Add(new ResponseModel
                    {
                        Response           = response,
                        PercentageResponse = percentage + "%"
                    });
                }
                reports.Add(new ReportModel
                {
                    Question  = Enum.Parse(typeof(TranslateQuestions), question.Key).DescriptionAttr(),
                    Responses = responseModels
                });
            }
            return(reports);
        }