private void OnReportHTML(object sender, EventArgs e)
        {
            try
            {
                SaveFileDialog dlg = new SaveFileDialog
                {
                    InitialDirectory = Settings.Default.ReportInitialDirectory,
                    FileName         = Path.ChangeExtension(CleanString(Data.SuggestedFileName), "html"),
                    Filter           = Resources.ID_FILTER_HTML,
                    DefaultExt       = "html",
                    ValidateNames    = true
                };

                if (DialogResult.OK == dlg.ShowDialog())
                {
                    // save directory
                    Settings.Default.ReportInitialDirectory = Path.GetDirectoryName(dlg.FileName);
                    // generate report
                    ReporterHtml reporter = new ReporterHtml(
                        Data
                        , ref _rnRoot
                        , Reporter.TemplatePath
                        , dlg.FileName);

                    Process.Start(new ProcessStartInfo(dlg.FileName));
                }
            }
            catch (Exception ex)
            {
                _log.Error(ex.Message);
            }
        }
        private void UpdateReport()
        {
            try
            {
                if (null == _rnRoot)
                {
                    throw new Exception("null == _rnRoot?");
                }
                // generate report
                string htmlFilePath = OutputFilePath;
                Reporter.SetImageSize(cbDefinitionDetail.ImageSize, cbDefinitionLarge.ImageSize);
                Reporter.SetImageHTMLSize(cbHTMLSizeDetail.ImageSize, cbHTMLSizeLarge.ImageSize);
                Reporter.SetFontSizeRatios(cbFontSizeDetail.FontSizeRatio, cbFontSizeLarge.FontSizeRatio);

                // reporter
                ReporterHtml reporter = new ReporterHtml(Data, ref _rnRoot, Reporter.TemplatePath, htmlFilePath);
                // display html
                _webBrowser.Navigate(htmlFilePath, string.Empty, null, string.Empty);
                // update tree view
                FillTree();
            }
            catch (FileNotFoundException ex)
            {
                _log.Error(ex.Message);
            }
            catch (Exception ex)
            {
                _log.Error(ex.ToString());
            }
        }
        private void OnReportHTML(object sender, EventArgs e)
        {
            try
            {
                SaveFileDialog dlg = new SaveFileDialog();
                dlg.InitialDirectory = Properties.Settings.Default.ReportInitialDirectory;
                dlg.FileName         = Path.ChangeExtension(CleanString(Analysis.Name), "html");
                dlg.Filter           = Properties.Resources.ID_FILTER_HTML;
                dlg.DefaultExt       = "html";
                dlg.ValidateNames    = true;

                if (DialogResult.OK == dlg.ShowDialog())
                {
                    // save directory
                    Properties.Settings.Default.ReportInitialDirectory = Path.GetDirectoryName(dlg.FileName);
                    // generate report
                    ReporterHtml reporter = new ReporterHtml(
                        new ReportData(_analysis)
                        , ref _rnRoot
                        , Reporter.TemplatePath
                        , dlg.FileName);

                    Process.Start(new ProcessStartInfo(dlg.FileName));
                }
            }
            catch (Exception ex)
            {
                _log.Error(ex.Message);
            }
        }
        private void ToolsGenerateReport(object sender, EventArgs e)
        {
            try
            {
                FormDefineReport formReport = new FormDefineReport();
                formReport.ProjectName = _analysis.Name;
                if (DialogResult.OK != formReport.ShowDialog())
                    return;
                // selected solution
                SelBoxCaseSolution selSolution = new SelBoxCaseSolution(_doc, _analysis, CurrentSolution);
                ReportData reportData = new ReportData(_analysis, selSolution);

                Reporter.CompanyLogo = string.Empty;
                Reporter.ImageSizeSetting = Reporter.eImageSize.IMAGESIZE_DEFAULT;
                Reporter reporter;
                if (formReport.FileExtension == "doc")
                {
                    // create "MS Word" report file
                    reporter = new ReporterMSWord(
                        reportData
                        , Settings.Default.ReportTemplatePath
                        , formReport.FilePath
                        , new Margins());
                }
                else if (formReport.FileExtension == "html")
                {
                    // create "html" report file
                    reporter = new ReporterHtml(
                        reportData
                        , Settings.Default.ReportTemplatePath
                        , formReport.FilePath);
                }
                else
                    return;

                // open file
                if (formReport.OpenGeneratedFile)
                    Process.Start(new ProcessStartInfo(formReport.FilePath));
            }
            catch (Exception ex)
            {
                _log.Error(ex.ToString());
            }
        }
        private void toolStripButtonReport_Click(object sender, EventArgs e)
        {
            try
            {
                Document doc;
                CasePalletAnalysis analysis;
                CasePalletSolution casePalletSol;
                if (!GenerateProject(out doc, out analysis, out casePalletSol))
                    return;
                SelCasePalletSolution selSolution = new SelCasePalletSolution(doc, analysis, casePalletSol);

                // define report
                FormDefineReport formReport = new FormDefineReport();
                formReport.ProjectName = doc.Name;
                if (DialogResult.OK != formReport.ShowDialog())
                    return;

                Reporter.CompanyLogo = string.Empty;
                Reporter.ImageSizeSetting = Reporter.eImageSize.IMAGESIZE_DEFAULT;
                Reporter reporter;

                ReportData reportData = new ReportData(analysis, selSolution);

                if (formReport.FileExtension == "doc")
                {
                    // create "MS Word" report file
                    reporter = new ReporterMSWord(
                        reportData
                        , Settings.Default.ReportTemplatePath
                        , formReport.FilePath
                        , new Margins());
                }
                else if (formReport.FileExtension == "html")
                {
                    // create "html" report file
                    reporter = new ReporterHtml(
                        reportData
                        , Settings.Default.ReportTemplatePath
                        , formReport.FilePath);
                }
                else
                    return;

                // open file
                if (formReport.OpenGeneratedFile)
                    Process.Start(new ProcessStartInfo(formReport.FilePath));
            }
            catch (Exception ex)
            {
                _log.Error(ex.ToString()); 
            }
        }
Example #6
0
 private void DocumentTreeView_SolutionReportHtmlClicked(object sender, AnalysisTreeViewEventArgs eventArg)
 {
     try
     {
         // build output file path
         string outputFilePath = Path.ChangeExtension(Path.GetTempFileName(), "html");
         // getting current culture
         string cultAbbrev = System.Globalization.CultureInfo.CurrentCulture.ThreeLetterWindowsLanguageName;
         // build report
         ReportData reportObject = new ReportData(
                 eventArg.Analysis, eventArg.SelSolution
                 , eventArg.CylinderAnalysis, eventArg.SelCylinderPalletSolution
                 , eventArg.HCylinderAnalysis, eventArg.SelHCylinderPalletSolution
                 , eventArg.BoxCaseAnalysis, eventArg.SelBoxCaseSolution
                 , eventArg.BoxCasePalletAnalysis, eventArg.SelBoxCasePalletSolution
                 , eventArg.PackPalletAnalysis, eventArg.SelPackPalletSolution
                 );
         Reporter.CompanyLogo = Properties.Settings.Default.CompanyLogoPath;
         Reporter.ImageSizeSetting = (Reporter.eImageSize)Properties.Settings.Default.ReporterImageSize;
         ReporterHtml reporter = new ReporterHtml(
             reportObject
             , Settings.Default.ReportTemplatePath
             , outputFilePath);
         // logging
         _log.Debug(string.Format("Saved report to {0}", outputFilePath));
         // open resulting report
         DocumentSB parentDocument = eventArg.Document as DocumentSB;
         DockContentReport dockContent = CreateOrActivateHtmlReport(reportObject, outputFilePath);
     }
     catch (Exception ex)
     {
         _log.Error(ex.ToString());
     }
 }