Пример #1
0
        private void ProcessReportSolution(reportSolution rSol)
        {
            // create document
            Document doc = new Document(rSol.reportParameters.name, rSol.reportParameters.description, rSol.reportParameters.author, DateTime.Now, null);
            // load analysis
            CasePalletAnalysis analysis = LoadPalletAnalysis(doc, rSol.solutionRef.analysisId);

            if (null == analysis)
            {
                return;
            }
            // compute solutions
            treeDiM.StackBuilder.Engine.CasePalletSolver solver = new treeDiM.StackBuilder.Engine.CasePalletSolver();
            solver.ProcessAnalysis(analysis);
            // retrieve wanted solution
            List <Basics.CasePalletSolution> solutions = analysis.Solutions;

            if (rSol.solutionRef.index >= solutions.Count)
            {
                throw new Exception(string.Format("Analysis {0} has no solution with index {1}", analysis.Name, rSol.solutionRef.index));
            }
            Basics.CasePalletSolution sol = solutions[(int)rSol.solutionRef.index];
            // selected solution
            SelCasePalletSolution selSolution = new SelCasePalletSolution(doc, analysis, sol);
            // generate report
            ReporterMSWord reporter = new ReporterMSWord(new ReportData(analysis, selSolution)
                                                         , rSol.reportParameters.templateFilePath, rSol.reportParameters.outputPath, new Margins());
        }
Пример #2
0
        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());
            }
        }
Пример #3
0
        private void ToolsGenerateReport(object sender, EventArgs e)
        {
            try
            {
                FormDefineReport formReport = new FormDefineReport();
                formReport.ProjectName = _analysis.Name;
                if (DialogResult.OK != formReport.ShowDialog())
                {
                    return;
                }
                // selected solution
                SelCasePalletSolution selSolution = new SelCasePalletSolution(null, _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());
            }
        }
Пример #4
0
        static void Main(string[] args)
        {
            ILog log = LogManager.GetLogger(typeof(Program));

            XmlConfigurator.Configure();

            try
            {
                // check arguments
                if (args.Length != 1)
                {
                    log.Info("No command argument. Exiting...");
                    return;
                }
                if (!File.Exists(args[0]))
                {
                    log.Info(string.Format("File {0} could not be found. Exiting...", args[0]));
                    return;
                }

                string filePath = args[0];
                // load document
                Document doc = new Document(filePath, new DocumentListenerLog());
                // get first analysis
                List <CasePalletAnalysis> analyses = doc.Analyses;
                if (analyses.Count == 0)
                {
                    log.Info("Document has no analysis -> Exiting...");
                    return;
                }
                // build output file path
                string         outputFilePath = Path.ChangeExtension(Path.GetTempFileName(), "doc");
                string         templatePath   = @"..\..\..\treeDiM.StackBuilder.Reporting\ReportTemplates\";
                ReporterMSWord reporter       = new ReporterMSWord(
                    new ReportData(analyses[0], analyses[0].GetSelSolutionBySolutionIndex(0))
                    , templatePath, outputFilePath, new Margins());
                Console.WriteLine("Saved report to: {0}", outputFilePath);

                // Display resulting report in Word
                Process.Start(new ProcessStartInfo(outputFilePath));
            }
            catch (Exception ex)
            {
                log.Error(ex.ToString());
            }
        }
Пример #5
0
        private void GenerateResult(
            string name, string description
            , double length, double width, double height
            , double?weight
            , PalletProperties palletProperties
            , ref int stackCount, ref double loadWeight, ref double totalWeight
            , ref double stackEfficiency
            , ref string stackImagePath)
        {
            stackCount     = 0;
            totalWeight    = 0.0;
            stackImagePath = string.Empty;

            // generate case
            BoxProperties bProperties = new BoxProperties(null, length, width, height);

            bProperties.ID.SetNameDesc(name, description);
            if (weight.HasValue)
            {
                bProperties.SetWeight(weight.Value);
            }
            bProperties.SetColor(Color.Chocolate);
            bProperties.TapeWidth = new OptDouble(true, Math.Min(UnitsManager.ConvertLengthFrom(50.0, UnitsManager.UnitSystem.UNIT_METRIC1), 0.5 * width));
            bProperties.TapeColor = Color.Beige;

            Graphics3DImage graphics = null;

            if (GenerateImage || GenerateImageInFolder)
            {
                // generate image path
                stackImagePath = Path.Combine(Path.ChangeExtension(Path.GetTempFileName(), "png"));

                if (GenerateImageInFolder)
                {
                    stackImagePath = Path.ChangeExtension(Path.Combine(Path.Combine(DirectoryPathImages, name)), "png");
                }

                graphics = new Graphics3DImage(new Size(ImageSize, ImageSize))
                {
                    FontSizeRatio  = Settings.Default.FontSizeRatio,
                    CameraPosition = Graphics3D.Corner_0
                };
            }

            // compute analysis
            ConstraintSetCasePallet constraintSet = new ConstraintSetCasePallet();

            constraintSet.SetAllowedOrientations(new bool[] { !AllowOnlyZOrientation, !AllowOnlyZOrientation, true });
            constraintSet.SetMaxHeight(new OptDouble(true, PalletMaximumHeight));
            constraintSet.Overhang = Overhang;

            SolverCasePallet solver   = new SolverCasePallet(bProperties, palletProperties);
            List <Analysis>  analyses = solver.BuildAnalyses(constraintSet, false);

            if (analyses.Count > 0)
            {
                Analysis analysis = analyses[0];
                stackCount      = analysis.Solution.ItemCount;
                loadWeight      = analysis.Solution.LoadWeight;
                totalWeight     = analysis.Solution.Weight;
                stackEfficiency = analysis.Solution.VolumeEfficiency;

                if (stackCount <= StackCountMax)
                {
                    if (GenerateImage || GenerateImageInFolder)
                    {
                        ViewerSolution sv = new ViewerSolution(analysis.Solution);
                        sv.Draw(graphics, Transform3D.Identity);
                        graphics.Flush();
                    }
                    if (GenerateReport)
                    {
                        ReportData inputData      = new ReportData(analysis);
                        string     outputFilePath = Path.ChangeExtension(Path.Combine(DirectoryPathReports, string.Format("Report_{0}_on_{1}", analysis.Content.Name, analysis.Container.Name)), "doc");

                        ReportNode rnRoot   = null;
                        Margins    margins  = new Margins();
                        Reporter   reporter = new ReporterMSWord(inputData, ref rnRoot, Reporter.TemplatePath, outputFilePath, margins);
                    }
                }
            }
            if (GenerateImage)
            {
                Bitmap bmp = graphics.Bitmap;
                bmp.Save(stackImagePath, System.Drawing.Imaging.ImageFormat.Png);
            }
        }
Пример #6
0
        private void GenerateResult(
            string name
            , double length, double width, double height
            , double?weight
            , ref int stackCount, ref double stackWeight, ref double stackEfficiency
            , ref string stackImagePath)
        {
            stackCount     = 0;
            stackWeight    = 0.0;
            stackImagePath = string.Empty;

            // generate case
            BoxProperties bProperties = new BoxProperties(null, length, width, height);

            if (weight.HasValue)
            {
                bProperties.SetWeight(weight.Value);
            }
            bProperties.SetColor(Color.Chocolate);
            bProperties.TapeWidth = new OptDouble(true, Math.Min(50.0, 0.5 * width));
            bProperties.TapeColor = Color.Beige;

            Graphics3DImage graphics = null;

            if (GenerateImage || GenerateImageInFolder)
            {
                // generate image path
                stackImagePath = Path.Combine(Path.ChangeExtension(Path.GetTempFileName(), "png"));

                if (GenerateImageInFolder)
                {
                    stackImagePath = Path.ChangeExtension(Path.Combine(Path.Combine(DirectoryPathImages, name)), "png");
                }

                graphics = new Graphics3DImage(new Size(ImageSize, ImageSize))
                {
                    FontSizeRatio  = this.FontSizeRatio,
                    CameraPosition = Graphics3D.Corner_0
                };
            }

            // compute analysis
            if (0 == Mode)
            {
                ConstraintSetCasePallet constraintSet = new ConstraintSetCasePallet();
                constraintSet.SetAllowedOrientations(new bool[] { !AllowOnlyZOrientation, !AllowOnlyZOrientation, true });
                constraintSet.SetMaxHeight(new OptDouble(true, PalletMaximumHeight));

                SolverCasePallet       solver   = new SolverCasePallet(bProperties, PalletProperties, constraintSet);
                List <AnalysisLayered> analyses = solver.BuildAnalyses(false);
                if (analyses.Count > 0)
                {
                    AnalysisLayered analysis = analyses[0];
                    stackCount      = analysis.Solution.ItemCount;
                    stackWeight     = analysis.Solution.Weight;
                    stackEfficiency = analysis.Solution.VolumeEfficiency;

                    if (stackCount <= StackCountMax)
                    {
                        if (GenerateImage || GenerateImageInFolder)
                        {
                            ViewerSolution sv = new ViewerSolution(analysis.Solution as SolutionLayered);
                            sv.Draw(graphics, Transform3D.Identity);
                            graphics.Flush();
                        }
                        if (GenerateReport)
                        {
                            ReportDataAnalysis inputData      = new ReportDataAnalysis(analysis);
                            string             outputFilePath = Path.ChangeExtension(Path.Combine(Path.GetDirectoryName(OutputFilePath), string.Format("Report_{0}_on_{1}", analysis.Content.Name, analysis.Container.Name)), "doc");

                            ReportNode rnRoot   = null;
                            Margins    margins  = new Margins();
                            Reporter   reporter = new ReporterMSWord(inputData, ref rnRoot, Reporter.TemplatePath, outputFilePath, margins);
                        }
                    }
                }
            }
            else
            {
                BoxProperties container = new BoxProperties(null, TruckLength, TruckWidth, TruckHeight, TruckLength, TruckWidth, TruckHeight);
                Color         lblue     = Color.LightBlue;
                container.SetAllColors(new Color[] { lblue, lblue, lblue, lblue, lblue, lblue });
                container.SetWeight(0.0);
                ConstraintSetBoxCase constraintSet = new ConstraintSetBoxCase(container);
                constraintSet.SetAllowedOrientations(new bool[] { !AllowOnlyZOrientation, !AllowOnlyZOrientation, true });

                SolverBoxCase          solver   = new SolverBoxCase(bProperties, container, constraintSet);
                List <AnalysisLayered> analyses = solver.BuildAnalyses(false);
                if (analyses.Count > 0)
                {
                    AnalysisLayered analysis = analyses[0];
                    stackCount  = analysis.Solution.ItemCount;
                    stackWeight = analysis.Solution.Weight;

                    if ((GenerateImage || GenerateImageInFolder) && stackCount <= StackCountMax)
                    {
                        ViewerSolution sv = new ViewerSolution(analysis.Solution as SolutionLayered);
                        sv.Draw(graphics, Transform3D.Identity);
                        graphics.Flush();
                    }
                }
            }
            if (GenerateImage)
            {
                Bitmap bmp = graphics.Bitmap;
                bmp.Save(stackImagePath, System.Drawing.Imaging.ImageFormat.Png);
            }
        }