public static void SendXml(string json)
        {
            DocumentSeriesItemWSO documentSeries = new DocumentSeriesItemWSO();

            documentSeries.DynamicData = JsonConvert.DeserializeObject <List <AttributeWSO> >(json);
            HandleXml insertXml = new HandleXml();

            insertXml.InsertXml(documentSeries);
        }
        public void InsertXml(DocumentSeriesItemWSO keyValue)
        {
            if (_parameterService.GetBoolean("CustomerSatisfactionEnabled"))
            {
                keyValue.IdDocumentSeries = _parameterService.GetInteger("CustomerSatisfactionSeriedId");
            }
            var xml = SerializationHelper.SerializeToString(keyValue);

            MyMaster.Client.Insert(xml);
        }
        static void LinkDataBinding(object sender, EventArgs e)
        {
            HyperLink link = sender as HyperLink;

            if (link == null)
            {
                return;
            }

            var container             = (GridDataItem)link.NamingContainer;
            DocumentSeriesItemWSO wso = container.DataItem as DocumentSeriesItemWSO;

            bool historyEnable;

            if (wso != null)
            {
                link.NavigateUrl = string.Format("~/SeriesItem.aspx?IdSeriesItem={0}{1}", wso.Id,
                                                 bool.TryParse(link.Attributes["historyEnabled"], out historyEnable) ? string.Concat("&history=", historyEnable) : string.Empty);
            }
        }
Example #4
0
        public void ProcessRequest(HttpContext context)
        {
            try
            {
                int    idSeriesItem           = context.Request.QueryString.GetValue <int>("idSeriesItem");
                string serialized             = Client.Consultation(idSeriesItem, true, false, false, false);
                DocumentSeriesItemWSO itemWso = SerializationHelper.SerializeFromString <DocumentSeriesItemWSO>(serialized);

                DocWSO doc = itemWso.MainDocs[0];

                string       xml    = Client.GetMainDocument(idSeriesItem, doc.Id, false);
                DocResultWSO result = SerializationHelper.SerializeFromString <DocResultWSO>(xml);

                byte[] bDocument;
                using (MemoryStream docStream = new MemoryStream(Convert.FromBase64String(result.Docs[0].Stream)))
                {
                    XmlDocument docXml     = new XmlDocument();
                    string      xmlEncoded = string.Empty;
                    try
                    {
                        xmlEncoded = Encoding.Unicode.GetString(Convert.FromBase64String(result.Docs[0].Stream));
                        docXml.LoadXml(xmlEncoded);
                    }
                    catch (Exception ex)
                    {
                        FileLogger.Warn(LoggerName, string.Concat("Errore in deserializzazione XML per la serie con Id ", idSeriesItem, " tramite encoding Unicode. Ignorare il messaggio, si procede alla deserializzazione tramite encoding UTF8."), ex);
                        xmlEncoded = Encoding.UTF8.GetString(Convert.FromBase64String(result.Docs[0].Stream));
                        docXml.LoadXml(xmlEncoded);
                    }
                    bDocument = Encoding.UTF8.GetBytes(docXml.OuterXml);
                }

                ElaborateDocument(context, bDocument, doc.Name);
            }
            catch (Exception ex)
            {
                WriteError(ex);
                throw;
            }
        }
Example #5
0
        public void InitializeExport(IList <DocumentSeriesItemWSO> itemWsos, IList <ArchiveAttributeWSO> archiveAttributeWsos)
        {
            CsvFields.Clear();
            ArchiveAttribute.Clear();

            ArchiveAttribute = archiveAttributeWsos;
            if (this._parameters.ExportDocuments)
            {
                ArchiveAttribute.Add(new ArchiveAttributeWSO()
                {
                    Description = "DocumentName"
                });
                ArchiveAttribute.Add(new ArchiveAttributeWSO()
                {
                    Description = "DocumentType"
                });
            }

            if (!itemWsos.Any())
            {
                return;
            }

            foreach (var itemWso in itemWsos)
            {
                var seriesToCsv = new SeriesToCsvFields();
                seriesToCsv.Object          = itemWso.Subject;
                seriesToCsv.PublicationDate = itemWso.PublishingDate;
                seriesToCsv.IdSeries        = itemWso.IdDocumentSeries;
                seriesToCsv.IdSubsection    = itemWso.IdDocumentSeriesSubsection;

                foreach (var data in ArchiveAttribute)
                {
                    var value    = string.Empty;
                    var keyExist = itemWso.DynamicData.Any(x => x.Key.Eq(data.Name));
                    if (keyExist)
                    {
                        value =
                            itemWso.DynamicData.Where(x => x.Key.Eq(data.Name)).Select(s => s.Value).SingleOrDefault();
                    }

                    if (ExporterHelper.EnumTipoProcedimento.Eq(data.Name))
                    {
                        value = ExporterHelper.GetTipoProcedimento(value);
                    }

                    var dict = new KeyValuePair <string, object>(data.Description, value);

                    seriesToCsv.DynamicData.Add(dict);
                }

                if (this._parameters.ExportDocuments)
                {
                    DocumentSeriesItemWSO fullItem = this.WsSeriesConnector.GetFullItemWso(itemWso.Id);

                    fullItem.MainDocs.ForEach((x) =>
                    {
                        SeriesToCsvFields clone           = seriesToCsv.DeepClone();
                        clone.DynamicData["DocumentName"] = x.Name;
                        clone.DynamicData["DocumentType"] = "Documento Principale";
                        CsvFields.Add(clone);
                    });

                    fullItem.AnnexedDocs.ForEach((x) =>
                    {
                        SeriesToCsvFields clone           = seriesToCsv.DeepClone();
                        clone.DynamicData["DocumentName"] = x.Name;
                        clone.DynamicData["DocumentType"] = "Annesso";
                        CsvFields.Add(clone);
                    });

                    if (fullItem.MainDocs.Count == 0 && fullItem.AnnexedDocs.Count == 0)
                    {
                        CsvFields.Add(seriesToCsv);
                    }
                }
                else
                {
                    CsvFields.Add(seriesToCsv);
                }
            }
        }
Example #6
0
        private void Initialize()
        {
            string resultFinder = SerializationHelper.SerializeToString(Finder);

            btnAllPublishedSeries.PostBackUrl = string.Concat("SeriesGrid.aspx?idSeries=", IdSeries, "&noFilter=true", (MyMaster.HistoryEnable ? "&history=" + MyMaster.StoricoEnabled : ""));

            string seriesName = SeriesWso.Name;

            if (IdSubSection.HasValue)
            {
                seriesName = string.Concat(seriesName, " - ", SeriesWso.DocumentSeriesSubsections.Single(ss => ss.Id == IdSubSection.Value).Description);
            }

            if (ShowSeriesCountDetails)
            {
                if (SeriesPreviewConfiguration.PriorityEnabled && PrioritySeriesResultCount > 0)
                {
                    lblSeriesName.Text = string.Format("{0} ({1} {2} di cui {3} in Primo Piano)", seriesName, TotalSeriesResultCount,
                                                       TotalSeriesResultCount == 1 ? "elemento" : "elementi", PrioritySeriesResultCount);
                }
                else
                {
                    lblSeriesName.Text = string.Format("{0} ({1} {2})", seriesName, TotalSeriesResultCount,
                                                       TotalSeriesResultCount == 1 ? "elemento" : "elementi");
                }
            }
            else
            {
                lblSeriesName.Text = seriesName.ToString();
            }


            if (!String.IsNullOrEmpty(MyMaster.GoogleAnalyticsCode))
            {
                AnalyticsReportService reportService = new AnalyticsReportService(MyMaster.GoogleReportingService);
                var dimensions = new List <Dimension> {
                    new Dimension {
                        Name = "ga:pagePath"
                    }
                };
                var metrics = new List <Metric> {
                    new Metric {
                        Expression = "ga:pageviews"
                    }
                };

                lblAnalyticsCounter.Visible = true;
                lblAnalyticsCounter.Text    = "Numero di visite: " + reportService.GetVisitorsCount(HttpContext.Current.Request.Url.PathAndQuery,
                                                                                                    MyMaster.AnalyticsStartDate,
                                                                                                    MyMaster.AnalyticsIDView,
                                                                                                    dimensions,
                                                                                                    metrics);
            }


            DocumentSeriesHeader headerItem = Singleton.Instance.DocumentSeriesHeaders.SingleOrDefault(t => t.IdSeries.HasValue && t.IdSeries.Value.Equals(IdSeries));

            if (IdSubSection.HasValue)
            {
                headerItem = Singleton.Instance.DocumentSeriesHeaders.SingleOrDefault(t => t.IdSeries.HasValue && t.IdSeries.Value.Equals(IdSeries) && t.IdSubSection.HasValue && t.IdSubSection.Value.Equals(IdSubSection.Value));
            }
            lblHeader.Text = headerItem != null ? headerItem.Header : string.Empty;

            inYear.NumberFormat.DecimalDigits  = 0;
            inYear.NumberFormat.GroupSeparator = string.Empty;

            dynamicDataPlaceHolder.Visible = !SimpleSearchEnable;
            btnSearchType.Visible          = SimpleSearchEnable;
            btnSearchType.Text             = "Ricerca avanzata";
            btnAllPublishedSeries.Visible  = !ShowAllItems;

            btnSearch.PostBackUrl = string.Format("{0}?IdSeries={1}{2}{3}", btnSearch.PostBackUrl, IdSeries, IdSubSection.HasValue ? "&IdSubSection=" + IdSubSection : "", (MyMaster.HistoryEnable ? "&history=" + MyMaster.StoricoEnabled : ""));

            var grid = GridPlaceHolder.FindControl(DocumentSeriesRadGrid.DefaultControlId) as RadGrid;

            switch (TotalSeriesResultCount)
            {
            case 0:
                pnlPreviewSeries.Visible = false;
                btnSearch.Enabled        = OneDocumentSeriesItemEnable ? false : true;
                break;

            case 1:
                pnlPreviewSeries.Visible = true;
                btnSearch.Enabled        = OneDocumentSeriesItemEnable ? false : true;
                string serializedItems = MyMaster.StoricoEnabled ? MyMaster.Client.SearchRetired(resultFinder, true) : MyMaster.Client.Search(resultFinder, true);
                MyMaster.Client.Close();
                DocumentSeriesItemResultWSO items = SerializationHelper.SerializeFromString <DocumentSeriesItemResultWSO>(serializedItems);

                if (grid == null)
                {
                    return;
                }
                grid.VirtualItemCount = TotalSeriesResultCount;

                hlLastModifiedSeries.Visible  = false;
                hlPriority.Visible            = false;
                lblLastModifiedSeries.Visible = false;
                lblPriority.Visible           = false;
                DocumentSeriesItemWSO currentItem = items.DocumentSeriesItems.First();
                pnlPreviewSeries.Visible = SeriesPreviewConfiguration.LatestSeriesEnabled || SeriesPreviewConfiguration.PriorityEnabled;
                if (SeriesPreviewConfiguration.LatestSeriesEnabled)
                {
                    DateTime?lastUpdateDate = (currentItem.PublishingDate > currentItem.LastChangedDate || !currentItem.LastChangedDate.HasValue) ? currentItem.PublishingDate : currentItem.LastChangedDate;
                    lblLastModifiedSeries.Visible = true;
                    lblLastModifiedSeries.Text    = string.Format("Informazioni recenti ({0:dd/MM/yyyy})", lastUpdateDate);
                }

                if (SeriesPreviewConfiguration.PriorityEnabled && currentItem.Priority.HasValue && currentItem.Priority.Value)
                {
                    lblPriority.Visible = true;
                    lblPriority.Text    = "In Primo Piano";
                }
                break;

            default:
                pnlPreviewSeries.Visible      = SeriesPreviewConfiguration.PriorityEnabled || SeriesPreviewConfiguration.LatestSeriesEnabled;
                lblPriority.Visible           = false;
                lblLastModifiedSeries.Visible = false;
                hlLastModifiedSeries.Visible  = false;
                hlPriority.Visible            = false;
                if (SeriesPreviewConfiguration.LatestSeriesEnabled)
                {
                    DocumentSeriesItemResultWSO latestItemResult = SerializationHelper.SerializeFromString <DocumentSeriesItemResultWSO>(SerializedLatestSeriesResult);
                    DocumentSeriesItemWSO       latestItem       = latestItemResult.DocumentSeriesItems.First();
                    DateTime?lastUpdateDate = (latestItem.PublishingDate > latestItem.LastChangedDate || !latestItem.LastChangedDate.HasValue) ? latestItem.PublishingDate : latestItem.LastChangedDate;
                    hlLastModifiedSeries.Visible = true;
                    hlLastModifiedSeries.Text    = string.Format("Informazioni recenti ({0:dd/MM/yyyy})", lastUpdateDate);
                    if ((!SeriesPreviewConfiguration.PriorityEnabled || PrioritySeriesResultCount == 0 || DefaultViewSeries == ViewSerieLatestSeries) && grid != null)
                    {
                        BindLatestItem();
                    }
                }

                if (SeriesPreviewConfiguration.PriorityEnabled && PrioritySeriesResultCount > 0)
                {
                    // DocumentSeriesItemResultWSO priorityItems = SerializationHelper.SerializeFromString<DocumentSeriesItemResultWSO>(SerializedPriorityResult);
                    hlPriority.Visible = true;
                    hlPriority.Text    = "In Primo Piano";
                    if (grid == null)
                    {
                        return;
                    }
                    if (DefaultViewSeries == ViewSeriePriority || DefaultViewSeries == "")
                    {
                        BindPriority();
                    }
                }
                break;
            }
        }
Example #7
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);
        }