Exemplo n.º 1
0
        public async Task <ReportCreateSummary> CreateDecommissionWorkHistoryReport(DecommissionWorkHistorySummaryReportArgs args, CancellationToken token)
        {
            if (null == args)
            {
                throw new ArgumentNullException(string.Format(ValidationMsgConstant.IsNullItem, typeof(DecommissionWorkHistorySummaryReportArgs).Name));
            }

            ReportCreateSummary returnItem = await this.CreateWorkHistoryReport <DirectRoutingServiceDirectRemovalSyncServiceEntity, DecommissionWorkHistorySummaryReportArgs>(ReportNameDecommissionWorkflowHistorySummary, args, this.routingServiceDirectRemovalSyncServiceManager.GetManyByDecommissionWorkHistoryReportArgs, this.ScrubDirectRoutingServiceDirectRemovalSyncServiceEntityData, this.UpdateProcessingStepStringDirectRoutingServiceDirectRemovalSyncServiceEntity, token);

            return(returnItem);
        }
Exemplo n.º 2
0
        public async Task <ReportCreateSummary> CreateOnboardWorkHistoryReport(OnboardWorkHistorySummaryReportArgs args, CancellationToken token)
        {
            if (null == args)
            {
                throw new ArgumentNullException(string.Format(ValidationMsgConstant.IsNullItem, typeof(OnboardWorkHistorySummaryReportArgs).Name));
            }

            ReportCreateSummary returnItem = await this.CreateWorkHistoryReport <DirectProvisioningEntity, OnboardWorkHistorySummaryReportArgs>(ReportNameOnboardWorkflowHistorySummary, args, this.provisioningManager.GetManyByOnboardWorkHistoryReportArgs, this.ScrubDirectProvisioningDto, this.UpdateProcessingStepStringDirectProvisioningEntity, token);

            return(returnItem);
        }
Exemplo n.º 3
0
        public async Task <ReportCreateSummary> CreateRenewWorkHistoryReport(RenewWorkHistorySummaryReportArgs args, CancellationToken token)
        {
            if (null == args)
            {
                throw new ArgumentNullException(string.Format(ValidationMsgConstant.IsNullItem, typeof(RenewWorkHistorySummaryReportArgs).Name));
            }

            ReportCreateSummary returnItem = await this.CreateWorkHistoryReport <DirectCertificateRenewalEntity, RenewWorkHistorySummaryReportArgs>(ReportNameRenewWorkflowHistorySummary, args, this.certificateRenewalManager.GetManyByRenewWorkHistoryReportArgs, this.ScrubDirectCertificateRenewalEntityData, this.UpdateProcessingStepStringDirectCertificateRenewalEntity, token);

            return(returnItem);
        }
Exemplo n.º 4
0
        private async Task <ReportCreateSummary> CreateWorkHistoryReport <TEntity, TArgs>(string reportTitle, TArgs args, Func <TArgs, CancellationToken, Task <IEnumerable <TEntity> > > getItemsFunc, Func <IEnumerable <TEntity>, IEnumerable <TEntity> > scrubFunc, Func <IEnumerable <TEntity>, IEnumerable <TEntity> > updateProcessStepStringFunc, CancellationToken token) where TArgs : WorkflowHistoryReportArgsBase
        {
            if (null == args)
            {
                throw new ArgumentNullException(string.Format(ValidationMsgConstant.IsNullItem, typeof(TArgs).Name));
            }

            ReportCreateSummary returnItem = new ReportCreateSummary();

            IEnumerable <TEntity> items = await getItemsFunc(args, token);

            /* get rid of s3nsitiv3 data */
            items = scrubFunc(items);

            items = updateProcessStepStringFunc(items);

            if ((args.ReportOutput & ReportOutputEnum.Xml) != 0 || (args.ReportOutput & ReportOutputEnum.Json) != 0 || (args.ReportOutput & ReportOutputEnum.Html) != 0)
            {
                JsonNeedsSingleRootWorkaround <TEntity> jsonWorkaround = new JsonNeedsSingleRootWorkaround <TEntity>()
                {
                    Title = reportTitle,
                    Items = items.ToList(),
                    ParametersFlattened = args.ToString()
                };

                returnItem.ContainerFolderName = this.GetUserTempPath(jsonWorkaround.Uid);

                string jsonContents = this.ConvertToJson <JsonNeedsSingleRootWorkaround <TEntity> >(jsonWorkaround);

                if ((args.ReportOutput & ReportOutputEnum.Json) != 0)
                {
                    string jsonFileName = this.WriteToTempFile(jsonWorkaround.Uid, jsonContents, FileExtensionJson);
                    returnItem.JsonFileName = jsonFileName;
                }

                XNode  node        = Newtonsoft.Json.JsonConvert.DeserializeXNode(jsonContents, XmlRootElementName);
                string xmlContents = node.ToString();

                if ((args.ReportOutput & ReportOutputEnum.Xml) != 0)
                {
                    string xmlFileName = this.WriteToTempFile(jsonWorkaround.Uid, xmlContents, FileExtensionXml);
                    returnItem.XmlFileName = xmlFileName;
                }

                if ((args.ReportOutput & ReportOutputEnum.Html) != 0)
                {
                    string htmlFileName = this.GetTempFileNameWithExtension(jsonWorkaround.Uid, FileExtensionHtml);

                    XslCompiledTransform xslt = new XslCompiledTransform();
                    xslt.Load(args.XslFullFileName);

                    if ((args.ReportOutput & ReportOutputEnum.Xml) == 0)
                    {
                        using (StringReader sri = new StringReader(xmlContents))
                        {
                            using (XmlReader xri = XmlReader.Create(sri))
                            {
                                using (StringWriter sw = new StringWriter())
                                    //// use OutputSettings of xsl, so it can be output as HTML
                                    using (XmlWriter xwo = XmlWriter.Create(sw, xslt.OutputSettings))
                                    {
                                        xslt.Transform(xri, xwo);
                                        string resultHtml = sw.ToString();
                                        htmlFileName = this.WriteContentsToConcreteFile(resultHtml, htmlFileName);
                                    }
                            }
                        }
                    }
                    else
                    {
                        xslt.Transform(returnItem.XmlFileName, htmlFileName);
                    }

                    returnItem.HtmlFileName = htmlFileName;
                }
            }

            return(returnItem);
        }