Esempio n. 1
0
        public override bool Execute()
        {
            if (string.IsNullOrEmpty(ReportDefinitionFileName))
            {
                Log.LogMessage($"There were no any item passed to {nameof(ReportPersianRendererTask)}. So nothing happened!");
                return(true);
            }

            ReportDefinitionFileName = Path.GetFullPath(ReportDefinitionFileName);
            OutputFileName           = Path.GetFullPath(OutputFileName);

            Log.LogMessage(MessageImportance.Normal, "Correcting report path is: \"" + ReportDefinitionFileName + "\"");
            Log.LogMessage(MessageImportance.Normal, "Corrected report will be saved on: \"" + OutputFileName + "\"");

            try
            {
                PersianRenderer.CorrectReportDefinition(ReportDefinitionFileName, OutputFileName, IgnoreGlobalVariables, ConvertSlashBetweenDigitsToDecimalSepratorParameter);
                Log.LogMessage("Corrected Report file saved successfully.");
                return(true);
            }
            catch (System.Exception x)
            {
                Log.LogErrorFromException(new System.Exception($"An error occured during the execution of {nameof(ReportPersianRendererTask)} task. The requested report file is \"{ReportDefinitionFileName}\" and the requested outputfile is \"{OutputFileName}\". The inner exception is: {x.ToString()}", x));
                return(false);
            }
        }
Esempio n. 2
0
        private static MemoryStream LoadReportDefinition(XDocument xDoc, string subReportPath, Action <string, Stream> subReportLoader, ReportCorrectionMode reportCorrectionMode)
        {
            bool ignoreGlobalVariables = true;
            bool convertSlashBetweenDigitsToDecimalSepratorParameter = true;

            var stream = new MemoryStream();

            XNamespace ns   = xDoc.Root.Name.Namespace;
            XNamespace rdNs = xDoc.Root.Attributes().Where(o => o.Name.LocalName == "rd").First().Value;

            //1st: handle sub reports
            foreach (var subReport in xDoc.Descendants(ns + "Subreport").Descendants(ns + "ReportName"))
            {
                string subReportFileName = subReport.Value + ".rdlc";
                subReportLoader(subReport.Value, LoadReportDefinition(subReportPath, subReportFileName, subReportLoader, reportCorrectionMode));
            }

            //2nd : do correction
            if (reportCorrectionMode == ReportCorrectionMode.HmFontsCorrection)
            {
                PersianRenderer.CorrectHmFonts(xDoc, ignoreGlobalVariables, convertSlashBetweenDigitsToDecimalSepratorParameter);
            }

            //4th: return processed file
            xDoc.Save(stream);
            xDoc            = null;
            stream.Position = 0;//we should call this!! unless the report throw an exception!
            return(stream);
        }