예제 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FileShareDeliverySettings"/> class.
        /// </summary>
        /// <param name="to">The e-mail address that appears on the To line of the e-mail message. Multiple e-mail addresses are separated by semicolons. Required.</param>
        /// <param name="cc">The e-mail address that appears on the Cc line of the e-mail message. Multiple e-mail addresses are separated by semicolons. Optional.</param>
        /// <param name="bcc">The e-mail address that appears on the Bcc line of the e-mail message. Multiple e-mail addresses are separated by semicolons. Optional.</param>
        /// <param name="replyTo">The e-mail address that appears in the Reply-To header of the e-mail message. The value must be a single e-mail address. Optional.</param>
        /// <param name="renderFormat">The name of the rendering extension to use to generate the rendered report. The name must correspond to one of the visible rendering extensions installed on the report server. This value is required if the IncludeReport setting is set to a value of true.<see cref="renderFormat"/></param>
        /// <param name="includeReport">A value that indicates whether to include the report in the e-mail delivery. A value of true indicates that the report is delivered in the body of the e-mail message.</param>
        /// <param name="priority">The priority with which the e-mail message is sent. Valid values are LOW, NORMAL, and HIGH. The default value is NORMAL.</param>
        /// <param name="subject">The text in the subject line of the e-mail message.</param>
        /// <param name="comment">The text included in the body of the e-mail message.</param>
        /// <param name="includeLink">A value that indicates whether to include a link to the report in the body of the e-mail.</param>
        public EmailDeliverySettings(string to, string cc, string bcc, string replyTo
            , ReportOutputType renderFormat, IncludeReport includeReport, EmailPriority priority, string subject, string comment, IncludeLink includeLink)
        {
            // Parameters are passed into the web service using the ExtensionSettings object.
            _extensionSettings.ParameterValues = new ParameterValueOrFieldReference[10];
            _extensionSettings.ParameterValues[0] = new ReportingService.ParameterValue { Name = "TO", Value = to };

            _extensionSettings.ParameterValues[1] = new ReportingService.ParameterValue { Name = "CC", Value = cc };

            _extensionSettings.ParameterValues[2] = new ReportingService.ParameterValue { Name = "BCC", Value = bcc };

            _extensionSettings.ParameterValues[3] = new ReportingService.ParameterValue { Name = "ReplyTo", Value = replyTo };

            _extensionSettings.ParameterValues[4] = new ReportingService.ParameterValue
                                         {Name = "RenderFormat", Value = renderFormat.Format()};

            _extensionSettings.ParameterValues[5] = new ReportingService.ParameterValue
                                                        {Name = "IncludeReport", Value = includeReport.SsrsText()};

            _extensionSettings.ParameterValues[6] = new ReportingService.ParameterValue { Name = "Priority", Value = priority.SsrsText() };

            _extensionSettings.ParameterValues[7] = new ReportingService.ParameterValue { Name = "Subject", Value = subject };

            _extensionSettings.ParameterValues[8] = new ReportingService.ParameterValue { Name = "Comment", Value = comment };

            _extensionSettings.ParameterValues[9] = new ReportingService.ParameterValue { Name = "IncludeLink", Value = includeLink.SsrsText() };

            // The name of the extension as it appears in the report server configuration file. 
            // Valid values are Report Server Email, Report Server DocumentLibrary and Report Server FileShare.
            _extensionSettings.Extension = ExtensionString;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="FileShareDeliverySettings"/> class.
        /// </summary>
        /// <param name="fileName">Name of the file.</param>
        /// <param name="includeFileExtension">if set to <c>true</c> [include file extension].</param>
        /// <param name="path">The URI of the file path.</param>
        /// <param name="renderFormat">The render format. <see cref="renderFormat"/></param>
        /// <param name="userName">Username for access to the network share.</param>
        /// <param name="password">Password for the network share associated with the specified Username.</param>
        /// <param name="writeMode">The write mode of the file. <see cref="WriteMode"/></param>
        public FileShareDeliverySettings(string fileName, bool includeFileExtension, string path
            , ReportOutputType renderFormat, string userName, string password, WriteMode writeMode)
        {
            // Parameters are passed into the web service using the ExtensionSettings object.
            _extensionSettings.ParameterValues = new ParameterValueOrFieldReference[7];
            _extensionSettings.ParameterValues[0] = new ReportingService.ParameterValue { Name = "FILENAME", Value = fileName };

            _extensionSettings.ParameterValues[1] = new ReportingService.ParameterValue
                                         {
                                             Name = "FILEEXTN",
                                             Value = includeFileExtension.ToString(CultureInfo.InvariantCulture)
                                         };

            _extensionSettings.ParameterValues[2] = new ReportingService.ParameterValue { Name = "PATH", Value = GetCleanUriString(path) };

            _extensionSettings.ParameterValues[3] = new ReportingService.ParameterValue { Name = "RENDER_FORMAT", Value = renderFormat.Format() };

            _extensionSettings.ParameterValues[4] = new ReportingService.ParameterValue { Name = "USERNAME", Value = userName };

            _extensionSettings.ParameterValues[5] = new ReportingService.ParameterValue { Name = "PASSWORD", Value = password };

            _extensionSettings.ParameterValues[6] = new ReportingService.ParameterValue
                                         {Name = "WRITEMODE", Value = Convert.ToString(writeMode)};

            // The name of the extension as it appears in the report server configuration file.
            // Valid values are Report Server Email, Report Server DocumentLibrary and Report Server FileShare.
            _extensionSettings.Extension = ExtensionString;
        }
예제 #3
0
        public string Export(string outputFileName, ReportOutputType type)
        {
            try
            {
                outputFileName = string.Format("{0}_{1}",
                                               outputFileName,
                                               DateTime.Now.ToString("yyyyMMddHHmmssff"));

                var exportOption = new ExportOptions();
                exportOption.ExportDestinationType = ExportDestinationType.DiskFile;

                switch (type)
                {
                case ReportOutputType.PDF:
                    outputFileName += ".pdf";
                    exportOption.ExportFormatType = ExportFormatType.PortableDocFormat;
                    break;

                case ReportOutputType.EXCEL:
                    outputFileName += ".xls";
                    exportOption.ExportFormatType    = ExportFormatType.Excel;
                    exportOption.ExportFormatOptions = new ExcelFormatOptions()
                    {
                        ShowGridLines = true
                    };
                    break;

                case ReportOutputType.WORD:
                    outputFileName += ".doc";
                    exportOption.ExportFormatType = ExportFormatType.WordForWindows;

                    break;

                case ReportOutputType.TEXT:
                    outputFileName += ".txt";
                    exportOption.ExportFormatType = ExportFormatType.Text;

                    break;

                default:
                    break;
                }

                exportOption.ExportDestinationOptions = new DiskFileDestinationOptions()
                {
                    DiskFileName = System.IO.Path.Combine(Utils.TEMP_PATH, outputFileName)
                };
                this.report.Export(exportOption);

                return(outputFileName);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #4
0
        private static string GetOutputFileName(ReportRequest request, ReportOutputType outputType)
        {
            string ext    = outputType == ReportOutputType.XML ? ".xml" : ".csv";
            var    outDir = GetOutputDirectory(request);

            if (!Directory.Exists(outDir))
            {
                Directory.CreateDirectory(outDir);
            }
            return(Path.Combine(outDir, Path.GetFileNameWithoutExtension(request.OutputFileName) + ext));
        }
예제 #5
0
        public void GenerateOutput(string dir, ReportOutputType type)
        {
            if (dir.Trim() == "*")
            {
                // '*' indicates current execution directory.
                dir = DirHandler.Instance.CurrentDirectory;
            }

            Output = OutputFactory.Create(type);
            Output.GenerateOutput(dir);
        }
예제 #6
0
 public Settings()
 {
   StorageType storagetype = Configuration.StorageType;
   bool outputenabled = Report.OutputEnabled;
   string outputdir = Report.OutputDir;
   ReportOutputType outputtype = Report.OutputType;
   bool wholefileinextract = Engine.WholeFileInExtract;
   int linesbeforematch = Engine.LinesBeforeMatch;
   int linesaftermatch = Engine.LinesAfterMatch;
   bool insertlinenumbersincodesummary = Engine.InsertLineNumbersInCodeSummary;
 }
예제 #7
0
        public static IOutput Create(ReportOutputType type)
        {
            switch (type)
              {
            case ReportOutputType.Web:   { return new WebOutput(); }
            case ReportOutputType.Excel: { return new ExcelOutput(); }

            default:
              throw new ArgumentException("Invalid report output type specified in the app.config file.");
              }
        }
예제 #8
0
        public void GenerateOutput(string dir, ReportOutputType type)
        {
            if (dir.Trim() == "*")
              {
            // '*' indicates current execution directory.
            dir = DirHandler.Instance.CurrentDirectory;
              }

              Output = OutputFactory.Create(type);
              Output.GenerateOutput(dir);
        }
예제 #9
0
        public static IOutput Create(ReportOutputType type)
        {
            switch (type)
            {
            case ReportOutputType.Web:   { return(new WebOutput()); }

            case ReportOutputType.Excel: { return(new ExcelOutput()); }

            default:
                throw new ArgumentException("Invalid report output type specified in the app.config file.");
            }
        }
예제 #10
0
        private void OutputPage(string URL, ReportOutputType output)
        {
            StringDictionary parameters = new StringDictionary();

            parameters.Add(STR_PositionID, dlistPositions.SelectedValue);

            Control          report;
            StringBuilder    sb = new StringBuilder();
            StringWriter     sw = new StringWriter(sb);
            Html32TextWriter hw = new Html32TextWriter(sw);

            try
            {
                report = LoadControl(URL);
                ((IReportUserControl)report).LoadReport(parameters); //Load the report with parameters

                report.RenderControl(hw);
            }
            catch (Exception ex)
            {
                lblReportStatus.Text = "Report Could Not Be Generated.  Please Try Again"; //Most likely timeout -- try again
                return;
            }

            Response.Clear();

            if (output == ReportOutputType.Word)
            {
                //Control the name that they see
                Response.ContentType = "application/ms-word";
                Response.AddHeader("Content-Disposition", "attachment;filename=" + "file.doc");
                Response.AddHeader("Content-Length", sb.Length.ToString());
                //Response.TransmitFile(file.FullName);
            }
            else if (output == ReportOutputType.Excel)
            {
                //Control the name that they see
                Response.ContentType = "application/ms-excel";
                Response.AddHeader("Content-Disposition", "attachment;filename=" + "Biographical.xls");
                Response.AddHeader("Content-Length", sb.Length.ToString());
            }

            Response.Write(sb.ToString());

            Response.End();
        }
예제 #11
0
        public void GenerateReport(string dir, ReportOutputType type)
        {
            lock (ManagerLock)
              {
            if (string.IsNullOrWhiteSpace(dir))
              throw new ArgumentNullException("dir");

            try
            {
              ((OutputManager)Manager).GenerateOutput(dir, type);
            }
            catch (BaseException baseException)
            {
              throw new OutputComponentException(this, -1, string.Format("Unable to initialize '{0}", GetType().Name), baseException);
            }
              }
        }
예제 #12
0
        public void GenerateReport(string dir, ReportOutputType type)
        {
            lock (ManagerLock)
            {
                if (string.IsNullOrWhiteSpace(dir))
                {
                    throw new ArgumentNullException("dir");
                }

                try
                {
                    ((OutputManager)Manager).GenerateOutput(dir, type);
                }
                catch (BaseException baseException)
                {
                    throw new OutputComponentException(this, -1, string.Format("Unable to initialize '{0}", GetType().Name), baseException);
                }
            }
        }
예제 #13
0
 public static IReportElementExporter CreateElementExporter(ReportOutputType outputType)
 {
     return(_exporters[outputType]);
 }
예제 #14
0
 public static IReportDocument CreateDocument(ReportOutputType outputType)
 {
     return(_documents[outputType]);
 }
예제 #15
0
 public override bool TryGetRenderFormatValue(out ReportOutputType renderFormatValue)
 {
     string renderFormatValueString = (from value in _extensionSettings.ParameterValues
                let paramValue = (ReportingService.ParameterValue)value
                where paramValue.Name == "RenderFormat"
                select paramValue.Value).FirstOrDefault();
     return Enum.TryParse(renderFormatValueString, true, out renderFormatValue);
 }
 public string GenerateReport(DateOnly todayDay, DateOnly previousDay, List <WorkItem> today, List <WorkItem> yesterday, List <User> users, ReportOutputType reportOutputType)
 {
     return(reportOutputType switch
     {
         ReportOutputType.Markdown => GenerateMarkdownReport(previousDay, today, yesterday, users),
         _ => GeneratePlainTextReport(previousDay, today, yesterday)
     });
예제 #17
0
        public static int Main(string[] args)
        {
            if (args == null)
            {
                return(-1);
            }
            if (args.Length < 2)
            {
                return(-1);
            }

            string tmpPath     = args[0];
            string printerPath = args[1];

            if (System.IO.Directory.Exists(tmpPath) == false)
            {
                return(-1);
            }

            if (string.IsNullOrEmpty(printerPath))
            {
                return(-1);
            }

            //string tmpPath = @"C:\TempDev";
            //string printerPath = @"CR_FX DocuCentre-II C2200 PCL 6";

            Utils.TEMP_PATH = tmpPath;

            string rpath = System.IO.Path.Combine(tmpPath, "Report");

            if (System.IO.Directory.Exists(rpath) == false)
            {
                System.IO.Directory.CreateDirectory(rpath);
            }

            rpath = System.IO.Path.Combine(rpath, printerPath);
            if (System.IO.Directory.Exists(rpath) == false)
            {
                return(-1);
            }

            string rrpath = System.IO.Path.Combine(rpath, "Result");

            if (System.IO.Directory.Exists(rrpath) == false)
            {
                System.IO.Directory.CreateDirectory(rrpath);
            }
            string rtpath = System.IO.Path.Combine(rpath, "Temp");

            if (System.IO.Directory.Exists(rtpath) == false)
            {
                System.IO.Directory.CreateDirectory(rtpath);
            }
            string repath = System.IO.Path.Combine(rpath, "Error");

            if (System.IO.Directory.Exists(repath) == false)
            {
                System.IO.Directory.CreateDirectory(repath);
            }

            try
            {
                foreach (System.IO.FileInfo fi in new System.IO.DirectoryInfo(rrpath).GetFiles())
                {
                    if (fi.LastAccessTime < DateTime.Now.AddMonths(-3))
                    {
                        fi.Delete();
                    }
                }
                foreach (System.IO.FileInfo fi in new System.IO.DirectoryInfo(rtpath).GetFiles())
                {
                    if (fi.LastAccessTime < DateTime.Now.AddMonths(-3))
                    {
                        fi.Delete();
                    }
                }
                foreach (System.IO.FileInfo fi in new System.IO.DirectoryInfo(repath).GetFiles())
                {
                    if (fi.LastAccessTime < DateTime.Now.AddMonths(-3))
                    {
                        fi.Delete();
                    }
                }
            }
            catch
            {
            }


            System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(rpath);
            System.IO.FileInfo[]    fs  = dir.GetFiles().OrderBy(x => x.CreationTime).ToArray();
            while (fs.Length > 0)
            {
                System.IO.FileInfo f = fs[0];

                try
                {
                    using (CrystalReportGenerator rpt = new CrystalReportGenerator())
                    {
                        ReportInfo rInfo = null;
                        using (System.IO.StreamReader rd = new System.IO.StreamReader(f.FullName))
                        {
                            rInfo = Newtonsoft.Json.JsonConvert.DeserializeObject <ReportInfo>(rd.ReadLine());
                            rpt.LoadReport(rInfo.TemplatePath);

                            string txt = rd.ReadLine();
                            while (txt != null && txt != "")
                            {
                                string[] sp = txt.Split(";".ToCharArray());
                                if (sp.Length > 0)
                                {
                                    if (sp[0] == "PARAM" && sp.Length >= 2)
                                    {
                                        string data = "";
                                        for (int idx = 1; idx < sp.Length; idx++)
                                        {
                                            if (idx > 1)
                                            {
                                                data += ";";
                                            }
                                            data += sp[idx];
                                        }

                                        ReportParameter p = Newtonsoft.Json.JsonConvert.DeserializeObject <ReportParameter>(data);
                                        if (p != null)
                                        {
                                            rpt.SetParameter(p.Name, p.Value);
                                        }
                                    }
                                    else if (sp[0] == "SOURCE" && sp.Length >= 3)
                                    {
                                        string name = sp[1];

                                        string data = "";
                                        for (int idx = 2; idx < sp.Length; idx++)
                                        {
                                            if (idx > 2)
                                            {
                                                data += ";";
                                            }
                                            data += sp[idx];
                                        }

                                        System.Data.DataTable table = new System.Data.DataTable(name);
                                        using (System.IO.StringReader srd = new System.IO.StringReader(data))
                                        {
                                            table.ReadXml(srd);
                                        }

                                        rpt.SetDataSource(name, table);
                                    }
                                    else if (sp[0] == "SUBSOURCE" && sp.Length >= 4)
                                    {
                                        string sname = sp[1];
                                        string name  = sp[2];

                                        string data = "";
                                        for (int idx = 3; idx < sp.Length; idx++)
                                        {
                                            if (idx > 3)
                                            {
                                                data += ";";
                                            }
                                            data += sp[idx];
                                        }

                                        System.Data.DataTable table = new System.Data.DataTable(name);
                                        using (System.IO.StringReader srd = new System.IO.StringReader(data))
                                        {
                                            table.ReadXml(srd);
                                        }

                                        rpt.SetSubReportDataSource(sname, name, table);
                                    }
                                }

                                txt = rd.ReadLine();
                            }
                        }

                        string           output = null;
                        ReportOutputType type   = (ReportOutputType)rInfo.OutputType;
                        if (type == ReportOutputType.PRINTER)
                        {
                            if (rInfo.PrintCopy == 0)
                            {
                                rInfo.PrintCopy = 1;
                            }

                            rpt.Print(rInfo.PrinterName, rInfo.PrintCopy, rInfo.PrinterPaperSource);
                        }
                        else
                        {
                            output = rpt.Export(rInfo.OutputFileName, type);

                            string rrfpath = System.IO.Path.Combine(rrpath, f.Name);
                            using (System.IO.StreamWriter wr = new System.IO.StreamWriter(rrfpath, true))
                            {
                                wr.WriteLine(output);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Utils.WriteLog(ex);
                }

                int count = 0;
                while (count < 10)
                {
                    try
                    {
                        string dest = System.IO.Path.Combine(rtpath, f.Name);
                        if (System.IO.File.Exists(dest))
                        {
                            System.IO.File.Delete(dest);
                        }

                        f.MoveTo(dest);
                        break;
                    }
                    catch (Exception ex)
                    {
                        Utils.WriteLog(ex);

                        count++;
                        System.Threading.Thread.Sleep(1000);
                    }
                }

                fs = dir.GetFiles().OrderBy(x => x.CreationTime).ToArray();
            }

            return(0);
        }
예제 #18
0
 public abstract bool TryGetRenderFormatValue(out ReportOutputType renderFormatValue);