コード例 #1
0
        protected override void ExportAnalysisSpecific(Analysis analysis)
        {
            var analysisCylinderTruck = analysis as AnalysisCylinderTruck;

            // analysis name
            WSheet.Cells[RowIndex, 2] = analysisCylinderTruck.Name;
            // cylinder
            var cylinderProperties = analysisCylinderTruck.Content as CylinderProperties;

            WSheet.Cells[RowIndex, 2] = cylinderProperties.Name;
            WSheet.Cells[RowIndex, 3] = cylinderProperties.Description;
            WSheet.Cells[RowIndex, 4] = cylinderProperties.RadiusOuter * 2.0;
            WSheet.Cells[RowIndex, 5] = cylinderProperties.Height;
            // truck name
            var truckProperties = analysisCylinderTruck.Container as TruckProperties;

            WSheet.Cells[RowIndex, 6] = truckProperties.Name;
            // solution
            SolutionLayered sol = analysisCylinderTruck.SolutionLay;

            WSheet.Cells[RowIndex, 7]  = sol.ItemCount;
            WSheet.Cells[RowIndex, 8]  = sol.LayerCount;
            WSheet.Cells[RowIndex, 9]  = sol.LayerBoxCount(0);
            WSheet.Cells[RowIndex, 10] = sol.LoadWeight;
            WSheet.Cells[RowIndex, 11] = sol.VolumeEfficiency;
            // image
            InsertImage(analysis, 12);
        }
コード例 #2
0
        protected override void ExportAnalysisSpecific(Analysis analysis)
        {
            var analysisBoxCase = analysis as AnalysisBoxCase;

            // analysis name
            WSheet.Cells[RowIndex, 1] = analysisBoxCase.Name;
            // box
            if (analysisBoxCase.Content is BoxProperties boxProperties)
            {
                WSheet.Cells[RowIndex, 2] = boxProperties.Name;
                WSheet.Cells[RowIndex, 3] = boxProperties.Description;
                WSheet.Cells[RowIndex, 4] = boxProperties.Length;
                WSheet.Cells[RowIndex, 5] = boxProperties.Width;
                WSheet.Cells[RowIndex, 6] = boxProperties.Height;
            }
            // case
            if (analysisBoxCase.Container is BoxProperties caseProperties)
            {
                WSheet.Cells[RowIndex, 7] = caseProperties.Name;
            }
            // solution
            SolutionLayered sol = analysisBoxCase.SolutionLay;

            WSheet.Cells[RowIndex, 8]  = sol.ItemCount;
            WSheet.Cells[RowIndex, 9]  = sol.LayerCount;
            WSheet.Cells[RowIndex, 10] = sol.LayerBoxCount(0);
            WSheet.Cells[RowIndex, 11] = sol.LoadWeight;
            WSheet.Cells[RowIndex, 12] = sol.Weight;
            WSheet.Cells[RowIndex, 13] = sol.VolumeEfficiency;

            InsertImage(analysis, 14);
        }
コード例 #3
0
 protected override void ExportAnalysisSpecific(Analysis analysis)
 {
     // analysis name
     WSheet.Cells[RowIndex, 1] = analysis.Name;
     if (analysis is AnalysisCasePallet analysisCasePallet)
     {
         // case
         if (analysisCasePallet.Content is BoxProperties caseProperties)
         {
             WSheet.Cells[RowIndex, 2] = caseProperties.Name;
             WSheet.Cells[RowIndex, 3] = caseProperties.Description;
             WSheet.Cells[RowIndex, 4] = caseProperties.Length;
             WSheet.Cells[RowIndex, 5] = caseProperties.Width;
             WSheet.Cells[RowIndex, 6] = caseProperties.Height;
         }
         // constraints
         ConstraintSetCasePallet constraintSet = analysisCasePallet.ConstraintSet as ConstraintSetCasePallet;
         WSheet.Cells[RowIndex, 7] = constraintSet.OptMaxHeight.Value;
         // solution
         SolutionLayered sol = analysisCasePallet.SolutionLay;
         WSheet.Cells[RowIndex, 8]  = sol.ItemCount;
         WSheet.Cells[RowIndex, 9]  = sol.LayerCount;
         WSheet.Cells[RowIndex, 10] = sol.LayerBoxCount(0);
         WSheet.Cells[RowIndex, 11] = sol.LoadWeight;
         WSheet.Cells[RowIndex, 12] = sol.Weight;
         WSheet.Cells[RowIndex, 13] = sol.VolumeEfficiency;
     }
     InsertImage(analysis, 14);
 }
コード例 #4
0
        protected override void ExportAnalysisSpecific(Analysis analysis)
        {
            var analysisCylinderPallet = analysis as AnalysisCylinderPallet;

            // analysis name
            WSheet.Cells[RowIndex, 1] = analysisCylinderPallet.Name;
            // cylinder
            var cylinderProperties = analysisCylinderPallet.Content as CylinderProperties;

            WSheet.Cells[RowIndex, 2] = cylinderProperties.Name;
            WSheet.Cells[RowIndex, 3] = cylinderProperties.Description;
            WSheet.Cells[RowIndex, 4] = cylinderProperties.RadiusOuter * 2.0;
            WSheet.Cells[RowIndex, 5] = cylinderProperties.Height;
            // pallet name
            var palletProperties = analysisCylinderPallet.Container as PalletProperties;

            WSheet.Cells[RowIndex, 6] = palletProperties.Name;
            // constraint set
            ConstraintSetPackablePallet constraintSet = analysisCylinderPallet.ConstraintSet as ConstraintSetPackablePallet;

            WSheet.Cells[RowIndex, 7] = constraintSet.OptMaxHeight.Value;
            // solution
            SolutionLayered sol = analysisCylinderPallet.SolutionLay;

            WSheet.Cells[RowIndex, 8]  = sol.ItemCount;
            WSheet.Cells[RowIndex, 9]  = sol.LayerCount;
            WSheet.Cells[RowIndex, 10] = sol.LayerBoxCount(0);
            WSheet.Cells[RowIndex, 11] = sol.LoadWeight;
            WSheet.Cells[RowIndex, 12] = sol.Weight;
            WSheet.Cells[RowIndex, 13] = sol.VolumeEfficiency;

            InsertImage(analysis, 14);
        }
コード例 #5
0
        private void UpdateGrid()
        {
            try
            {
                // sanity check
                if (gridSolution.ColumnsCount < 2)
                {
                    return;
                }
                // remove all existing rows
                gridSolution.Rows.Clear();
                // *** IViews
                // captionHeader
                SourceGrid.Cells.Views.RowHeader        captionHeader   = new SourceGrid.Cells.Views.RowHeader();
                DevAge.Drawing.VisualElements.RowHeader veHeaderCaption = new DevAge.Drawing.VisualElements.RowHeader();
                veHeaderCaption.BackColor   = Color.SteelBlue;
                veHeaderCaption.Border      = DevAge.Drawing.RectangleBorder.NoBorder;
                captionHeader.Background    = veHeaderCaption;
                captionHeader.ForeColor     = Color.Black;
                captionHeader.Font          = new Font("Arial", GridFontSize, FontStyle.Bold);
                captionHeader.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter;
                // viewRowHeader
                SourceGrid.Cells.Views.RowHeader        viewRowHeader = new SourceGrid.Cells.Views.RowHeader();
                DevAge.Drawing.VisualElements.RowHeader backHeader    = new DevAge.Drawing.VisualElements.RowHeader
                {
                    BackColor = Color.LightGray,
                    Border    = DevAge.Drawing.RectangleBorder.NoBorder
                };
                viewRowHeader.Background = backHeader;
                viewRowHeader.ForeColor  = Color.Black;
                viewRowHeader.Font       = new Font("Arial", GridFontSize, FontStyle.Regular);
                // viewNormal
                CellBackColorAlternate viewNormal = new CellBackColorAlternate(Color.LightBlue, Color.White);
                // ***

                SolutionLayered solution = _analysis.Solution as SolutionLayered;

                SourceGrid.Cells.RowHeader rowHeader;
                int iRow = -1;
                // pallet caption
                gridSolution.Rows.Insert(++iRow);
                rowHeader = new SourceGrid.Cells.RowHeader(Resources.ID_PALLET)
                {
                    ColumnSpan = 2,
                    View       = captionHeader
                };
                gridSolution[iRow, 0] = rowHeader;
                // layer #
                gridSolution.Rows.Insert(++iRow);
                rowHeader = new SourceGrid.Cells.RowHeader(Resources.ID_LAYERNUMBER)
                {
                    View = viewRowHeader
                };
                gridSolution[iRow, 0] = rowHeader;
                gridSolution[iRow, 1] = new SourceGrid.Cells.Cell(solution.LayerCount);
                // interlayer #
                if (solution.InterlayerCount > 0)
                {
                    gridSolution.Rows.Insert(++iRow);
                    rowHeader             = new SourceGrid.Cells.RowHeader(Resources.ID_INTERLAYERNUMBER);
                    rowHeader.View        = viewRowHeader;
                    gridSolution[iRow, 0] = rowHeader;
                    gridSolution[iRow, 1] = new SourceGrid.Cells.Cell(solution.InterlayerCount);
                }
                // *** Item # (Recursive count)
                Packable content   = _analysis.Content;
                int      itemCount = solution.ItemCount;
                int      number    = 1;
                do
                {
                    itemCount *= number;
                    gridSolution.Rows.Insert(++iRow);
                    rowHeader = new SourceGrid.Cells.RowHeader(string.Format("{0} #", content.DetailedName))
                    {
                        View = viewRowHeader
                    };
                    gridSolution[iRow, 0] = rowHeader;
                    gridSolution[iRow, 1] = new SourceGrid.Cells.Cell(itemCount);
                }while (null != content && content.InnerContent(ref content, ref number));
                // ***
                // outer dimensions
                BBox3D bboxGlobal = solution.BBoxGlobal;
                // ---
                gridSolution.Rows.Insert(++iRow);
                rowHeader = new SourceGrid.Cells.RowHeader(
                    string.Format(Resources.ID_OUTERDIMENSIONS, Environment.NewLine, UnitsManager.LengthUnitString))
                {
                    View = viewRowHeader
                };
                gridSolution[iRow, 0] = rowHeader;
                gridSolution[iRow, 1] = new SourceGrid.Cells.Cell(
                    string.Format(CultureInfo.InvariantCulture, "{0:0.#} x {1:0.#} x {2:0.#}", bboxGlobal.Length, bboxGlobal.Width, bboxGlobal.Height));
                // load dimensions
                BBox3D bboxLoad = solution.BBoxLoad;
                // ---
                gridSolution.Rows.Insert(++iRow);
                rowHeader = new SourceGrid.Cells.RowHeader(
                    string.Format(Resources.ID_LOADDIMENSIONS, Environment.NewLine, UnitsManager.LengthUnitString))
                {
                    View = viewRowHeader
                };
                gridSolution[iRow, 0] = rowHeader;
                gridSolution[iRow, 1] = new SourceGrid.Cells.Cell(
                    string.Format(CultureInfo.InvariantCulture, "{0:0.#} x {1:0.#} x {2:0.#}", bboxLoad.Length, bboxLoad.Width, bboxLoad.Height));
                // net weight
                if (solution.HasNetWeight)
                {
                    gridSolution.Rows.Insert(++iRow);
                    rowHeader = new SourceGrid.Cells.RowHeader(
                        string.Format(Resources.ID_NETWEIGHT_WU, UnitsManager.MassUnitString));
                    rowHeader.View        = viewRowHeader;
                    gridSolution[iRow, 0] = rowHeader;
                    gridSolution[iRow, 1] = new SourceGrid.Cells.Cell(
                        string.Format(CultureInfo.InvariantCulture, "{0:0.#}", solution.NetWeight));
                }
                // load weight
                gridSolution.Rows.Insert(++iRow);
                rowHeader = new SourceGrid.Cells.RowHeader(
                    string.Format(Resources.ID_LOADWEIGHT_WU, UnitsManager.MassUnitString))
                {
                    View = viewRowHeader
                };
                gridSolution[iRow, 0] = rowHeader;
                gridSolution[iRow, 1] = new SourceGrid.Cells.Cell(
                    string.Format(CultureInfo.InvariantCulture, "{0:0.#}", solution.LoadWeight));
                // total weight
                gridSolution.Rows.Insert(++iRow);
                rowHeader = new SourceGrid.Cells.RowHeader(
                    string.Format(Resources.ID_TOTALWEIGHT_WU, UnitsManager.MassUnitString))
                {
                    View = viewRowHeader
                };
                gridSolution[iRow, 0] = rowHeader;
                gridSolution[iRow, 1] = new SourceGrid.Cells.Cell(
                    string.Format(CultureInfo.InvariantCulture, "{0:0.#}", solution.Weight));
                // volume efficiency
                gridSolution.Rows.Insert(++iRow);
                rowHeader = new SourceGrid.Cells.RowHeader(Resources.ID_VOLUMEEFFICIENCY)
                {
                    View = viewRowHeader
                };
                gridSolution[iRow, 0] = rowHeader;
                gridSolution[iRow, 1] = new SourceGrid.Cells.Cell(
                    string.Format(CultureInfo.InvariantCulture, "{0:0.#}", solution.VolumeEfficiency));

                int noLayerTypesUsed = solution.NoLayerTypesUsed;

                // ### layers : begin
                for (int i = 0; i < solution.Layers.Count; ++i)
                {
                    List <int> layerIndexes = solution.LayerTypeUsed(i);
                    if (0 == layerIndexes.Count)
                    {
                        continue;
                    }

                    // layer caption
                    gridSolution.Rows.Insert(++iRow);
                    rowHeader             = new SourceGrid.Cells.RowHeader(solution.LayerCaption(i));
                    rowHeader.ColumnSpan  = 2;
                    rowHeader.View        = captionHeader;
                    gridSolution[iRow, 0] = rowHeader;

                    // *** Item # (recursive count)
                    content   = _analysis.Content;
                    itemCount = solution.LayerBoxCount(i);
                    number    = 1;
                    do
                    {
                        itemCount *= number;

                        gridSolution.Rows.Insert(++iRow);
                        rowHeader = new SourceGrid.Cells.RowHeader(
                            string.Format("{0} #", content.DetailedName));
                        rowHeader.View        = viewRowHeader;
                        gridSolution[iRow, 0] = rowHeader;
                        gridSolution[iRow, 1] = new SourceGrid.Cells.Cell(itemCount);
                    }while (null != content && content.InnerContent(ref content, ref number));
                    // ***

                    // layer weight
                    gridSolution.Rows.Insert(++iRow);
                    rowHeader             = new SourceGrid.Cells.RowHeader(string.Format(Resources.ID_WEIGHT_WU, UnitsManager.MassUnitString));
                    rowHeader.View        = viewRowHeader;
                    gridSolution[iRow, 0] = rowHeader;
                    gridSolution[iRow, 1] = new SourceGrid.Cells.Cell(
                        string.Format(CultureInfo.InvariantCulture, "{0:0.#}", solution.LayerWeight(i)));
                    // layer space
                    gridSolution.Rows.Insert(++iRow);
                    rowHeader             = new SourceGrid.Cells.RowHeader("Spaces");
                    rowHeader.View        = viewRowHeader;
                    gridSolution[iRow, 0] = rowHeader;
                    gridSolution[iRow, 1] = new SourceGrid.Cells.Cell(
                        string.Format(CultureInfo.InvariantCulture, "{0:0.#}", solution.LayerMaximumSpace(i)));
                }
                // ### layers : end

                gridSolution.AutoSizeCells();
                gridSolution.Columns.StretchToFit();
                gridSolution.AutoStretchColumnsToFitWidth = true;
                gridSolution.Invalidate();
            }
            catch (Exception ex)
            {
                _log.Error(ex.ToString());
            }
        }
コード例 #6
0
        public void ExportAnalysesToExcel()
        {
            // open excel file
            Microsoft.Office.Interop.Excel.Application xlApp = new Microsoft.Office.Interop.Excel.Application
            {
                Visible       = true,
                DisplayAlerts = false
            };
            Workbooks xlWorkBooks           = xlApp.Workbooks;
            Workbook  xlWorkBook            = xlWorkBooks.Add(Type.Missing);
            Worksheet xlWorkSheetCasePallet = xlWorkBook.Worksheets.get_Item(1);

            // create header
            xlWorkSheetCasePallet.Cells[1, 1]  = "Analysis name";
            xlWorkSheetCasePallet.Cells[1, 2]  = "Case name";
            xlWorkSheetCasePallet.Cells[1, 3]  = "Case description";
            xlWorkSheetCasePallet.Cells[1, 4]  = "Ext. length";
            xlWorkSheetCasePallet.Cells[1, 5]  = "Ext. width";
            xlWorkSheetCasePallet.Cells[1, 6]  = "Ext. height";
            xlWorkSheetCasePallet.Cells[1, 7]  = "Max pallet height";
            xlWorkSheetCasePallet.Cells[1, 8]  = "Solution case count";
            xlWorkSheetCasePallet.Cells[1, 9]  = "Layers";
            xlWorkSheetCasePallet.Cells[1, 10] = "Cases per layer";
            xlWorkSheetCasePallet.Cells[1, 11] = "Load weight";
            xlWorkSheetCasePallet.Cells[1, 12] = "Weight";
            xlWorkSheetCasePallet.Cells[1, 13] = "Volume efficiency";
            xlWorkSheetCasePallet.Cells[1, 14] = "Image";

            Range headerRange = xlWorkSheetCasePallet.get_Range("A1", "N1");

            headerRange.Font.Bold = true;
            xlWorkSheetCasePallet.Columns.AutoFit();


            // *** get all users from Azure database and write them down
            int iRowCasePallet = 2;

            foreach (var analysis in Analyses)
            {
                try
                {
                    if (analysis is AnalysisCasePallet analysisCasePallet)
                    {
                        // analysis name
                        xlWorkSheetCasePallet.Cells[iRowCasePallet, 1] = analysisCasePallet.Name;
                        // case
                        BoxProperties caseProperties = analysisCasePallet.Content as BoxProperties;
                        xlWorkSheetCasePallet.Cells[iRowCasePallet, 2] = caseProperties.Name;
                        xlWorkSheetCasePallet.Cells[iRowCasePallet, 3] = caseProperties.Description;
                        xlWorkSheetCasePallet.Cells[iRowCasePallet, 4] = caseProperties.Length;
                        xlWorkSheetCasePallet.Cells[iRowCasePallet, 5] = caseProperties.Width;
                        xlWorkSheetCasePallet.Cells[iRowCasePallet, 6] = caseProperties.Height;
                        // constraints
                        ConstraintSetCasePallet constraintSet = analysisCasePallet.ConstraintSet as ConstraintSetCasePallet;
                        xlWorkSheetCasePallet.Cells[iRowCasePallet, 7] = constraintSet.OptMaxHeight.Value;
                        // solution
                        SolutionLayered sol = analysisCasePallet.SolutionLay;
                        xlWorkSheetCasePallet.Cells[iRowCasePallet, 8]  = sol.ItemCount;
                        xlWorkSheetCasePallet.Cells[iRowCasePallet, 9]  = sol.LayerCount;
                        xlWorkSheetCasePallet.Cells[iRowCasePallet, 10] = sol.LayerBoxCount(0);
                        xlWorkSheetCasePallet.Cells[iRowCasePallet, 11] = sol.LoadWeight;
                        xlWorkSheetCasePallet.Cells[iRowCasePallet, 12] = sol.Weight;
                        xlWorkSheetCasePallet.Cells[iRowCasePallet, 13] = sol.VolumeEfficiency;

                        var stackImagePath = Path.Combine(Path.ChangeExtension(Path.GetTempFileName(), "png"));
                        var graphics       = new Graphics3DImage(new Size(768, 768))
                        {
                            FontSizeRatio  = 0.01f,
                            CameraPosition = Graphics3D.Corner_0
                        };
                        using (ViewerSolution sv = new ViewerSolution(analysisCasePallet.SolutionLay))
                            sv.Draw(graphics, Transform3D.Identity);
                        graphics.Flush();
                        Bitmap bmp = graphics.Bitmap;
                        bmp.Save(stackImagePath, System.Drawing.Imaging.ImageFormat.Png);
                        Range imageCell = (Range)xlWorkSheetCasePallet.Cells[iRowCasePallet, 14];
                        imageCell.RowHeight   = 128;
                        imageCell.ColumnWidth = 24;
                        xlWorkSheetCasePallet.Shapes.AddPicture(stackImagePath,
                                                                LinkToFile: MsoTriState.msoFalse, SaveWithDocument: MsoTriState.msoCTrue,
                                                                Left: imageCell.Left + 1, Top: imageCell.Top + 1, Width: imageCell.Width - 2, Height: imageCell.Height - 2);

                        ++iRowCasePallet;
                    }
                    else if (analysis is AnalysisBoxCase analysisBoxCase)
                    {
                    }
                    else if (analysis is AnalysisCaseTruck analysisCaseTruck)
                    {
                    }
                    else if (analysis is AnalysisCylinderPallet analysisCylinderPallet)
                    {
                    }
                    else if (analysis is AnalysisCylinderCase analysisCylinderCase)
                    {
                    }
                    else if (analysis is AnalysisCylinderTruck analysisCylinderTruck)
                    {
                    }
                }
                catch (Exception ex)
                {
                    _log.Error(ex.ToString());
                }
            }
        }