public ReportData( CasePalletAnalysis palletAnalysis, SelCasePalletSolution selSolution , CylinderPalletAnalysis cylinderPalletAnalysis, SelCylinderPalletSolution selCylinderPalletSolution , HCylinderPalletAnalysis hCylinderPalletAnalysis, SelHCylinderPalletSolution selHCylinderPalletSolution , BoxCaseAnalysis boxCaseAnalysis, SelBoxCaseSolution selBoxCaseSolution , BoxCasePalletAnalysis caseAnalysis, SelBoxCasePalletSolution selCaseSolution , PackPalletAnalysis packPalletAnalysis, SelPackPalletSolution selPackPalletSolution ) { // case/pallet analysis _palletAnalysis = palletAnalysis; _selSolution = selSolution; // box/case/pallet analysis _caseAnalysis = caseAnalysis; _selCaseSolution = selCaseSolution; // Cylinder analysis _cylinderPalletAnalysis = cylinderPalletAnalysis; _selCylinderPalletSolution = selCylinderPalletSolution; // HCylinder analysis _hCylinderPalletAnalysis = hCylinderPalletAnalysis; _selHCylinderPalletSolution = selHCylinderPalletSolution; // Box case analysis _boxCaseAnalysis = boxCaseAnalysis; _selBoxCaseSolution = selBoxCaseSolution; // Pack pallet analysis _packPalletAnalysis = packPalletAnalysis; _selPackPalletSolution = selPackPalletSolution; }
/// <summary> /// Check if database already contains a similar pallet solution for a specific case /// </summary> /// <returns>true if a solution with same pallet + case dimensions exists</returns> public bool AlreadyHasSimilarSolution(SelCasePalletSolution selSolution) { List <PalletSolutionDesc> similarDescList = _palletSolutionList.FindAll( delegate(PalletSolutionDesc desc) { return(desc.MatchesKeyAndCaseDimensions(new PalletSolutionDesc(this, selSolution.Solution, ""))); } ); return(similarDescList.Count > 0); }
/// <summary> /// Truck analysis /// </summary> /// <param name="document">Parent document</param> /// <param name="analysis">Parent pallet analysis</param> /// <param name="selSolution">Parent selected solution</param> /// <param name="truckProperties">TruckProperties item</param> /// <param name="constraintSet">Constraint set</param> public TruckAnalysis( Document document , CasePalletAnalysis analysis , SelCasePalletSolution selSolution , TruckProperties truckProperties , TruckConstraintSet constraintSet) : base(document) { Name = truckProperties.Name; _analysis = analysis; _selSolution = selSolution; this.TruckProperties = truckProperties; _constraintSet = constraintSet; }
/// <summary> /// Truck analysis /// </summary> /// <param name="document">Parent document</param> /// <param name="analysis">Parent pallet analysis</param> /// <param name="selSolution">Parent selected solution</param> /// <param name="truckProperties">TruckProperties item</param> /// <param name="constraintSet">Constraint set</param> public TruckAnalysis( Document document , CasePalletAnalysis analysis , SelCasePalletSolution selSolution , TruckProperties truckProperties , TruckConstraintSet constraintSet) : base(document) { Name = truckProperties.Name; _analysis = analysis; _selSolution = selSolution; this.TruckProperties = truckProperties; _constraintSet = constraintSet; }
public void UnSelectSolution(SelCasePalletSolution selSolution) { if (null == selSolution) { return; // this solution not selected } // remove from list _selectedSolutions.Remove(selSolution); ParentDocument.RemoveItem(selSolution); // fire event if (null != SolutionSelectionRemoved) { SolutionSelectionRemoved(this, selSolution); } // set document modified (not analysis, otherwise selected solutions are erased) ParentDocument.Modify(); }
public void SelectSolutionBySol(CasePalletSolution sol) { if (HasSolutionSelected(sol)) { return; } // instantiate new SelSolution SelCasePalletSolution selSolution = new SelCasePalletSolution(ParentDocument, this, sol); // insert in list _selectedSolutions.Add(selSolution); // fire event if (null != SolutionSelected) { SolutionSelected(this, selSolution); } // set document modified (not analysis, otherwise selected solutions are erased) ParentDocument.Modify(); }
/// <summary> /// Constructor /// </summary> public ECTAnalysis( Document document , CasePalletAnalysis analysis , SelCasePalletSolution selSolution) : base(document) { _analysis = analysis; _selSolution = selSolution; // get a cardboard quality foreach (string skey in McKeeFormula.CardboardQualityDictionary.Keys) { _qualityData = McKeeFormula.CardboardQualityDictionary[skey]; break; } // get a _printSurface value foreach (string skey in McKeeFormula.PrintCoefDictionary.Keys) { _printSurface = skey; break; } }
/// <summary> /// Constructor /// </summary> public ECTAnalysis( Document document , CasePalletAnalysis analysis , SelCasePalletSolution selSolution) : base(document) { _analysis = analysis; _selSolution = selSolution; // get a cardboard quality foreach (string skey in McKeeFormula.CardboardQualityDictionary.Keys) { _qualityData = McKeeFormula.CardboardQualityDictionary[skey]; break; } // get a _printSurface value foreach (string skey in McKeeFormula.PrintCoefDictionary.Keys) { _printSurface = skey; break; } }
public void SelectSolutionByIndex(int index) { if (index < 0 || index > _solutions.Count) { return; // no solution with this index } if (HasSolutionSelected(index)) { return; // solution already selected } // instantiate new SelSolution SelCasePalletSolution selSolution = new SelCasePalletSolution(ParentDocument, this, _solutions[index]); // insert in list _selectedSolutions.Add(selSolution); // fire event if (null != SolutionSelected) { SolutionSelected(this, selSolution); } // set document modified (not analysis, otherwise selected solutions are erased) ParentDocument.Modify(); }
/// <summary> /// Append new solution descriptor /// </summary> /// <param name="desc"></param> public void Append(SelCasePalletSolution selSolution, string name, bool keepSimilarSolutions) { Document document = selSolution.Analysis.ParentDocument; CasePalletSolution sol = selSolution.Solution; CasePalletAnalysis analysis = sol.Analysis; // instantiate new descriptor PalletSolutionDesc desc = new PalletSolutionDesc(this, sol, name); // remove similar solutions if (!keepSimilarSolutions) { RemoveByKeyAndCaseDimensions(desc); } // save solution as stb file document.WriteSolution(selSolution, desc.FullFilePath); _palletSolutionList.Add(desc); _palletSolutionList.Sort(); if (null != SolutionAppended) { SolutionAppended(this, new PalletSolutionEventArgs(desc)); } Save(); }
public void SaveCasePalletSolution(CasePalletAnalysis analysis, CasePalletSolution sol, SelCasePalletSolution selSolution, bool unique, XmlElement solutionsElt, XmlDocument xmlDoc) { // Solution XmlElement solutionElt = xmlDoc.CreateElement("Solution"); solutionsElt.AppendChild(solutionElt); // title XmlAttribute titleAttribute = xmlDoc.CreateAttribute("Title"); titleAttribute.Value = sol.Title; solutionElt.Attributes.Append(titleAttribute); // homogeneousLayers ? XmlAttribute homogeneousLayersAttribute = xmlDoc.CreateAttribute("HomogeneousLayers"); homogeneousLayersAttribute.Value = sol.HasHomogeneousLayers ? "true" : "false"; solutionElt.Attributes.Append(homogeneousLayersAttribute); // limit XmlAttribute limitReached = xmlDoc.CreateAttribute("LimitReached"); limitReached.Value = string.Format("{0}", (int)sol.LimitReached); solutionElt.Attributes.Append(limitReached); // layers XmlElement layersElt = xmlDoc.CreateElement("Layers"); solutionElt.AppendChild(layersElt); foreach (ILayer layer in sol) { BoxLayer boxLayer = layer as BoxLayer; if (null != boxLayer) Save(boxLayer, layersElt, xmlDoc); InterlayerPos interlayerPos = layer as InterlayerPos; if (null != interlayerPos) { // Interlayer XmlElement interlayerElt = xmlDoc.CreateElement("Interlayer"); layersElt.AppendChild(interlayerElt); // ZLow XmlAttribute zlowAttribute = xmlDoc.CreateAttribute("ZLow"); zlowAttribute.Value = string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}", interlayerPos.ZLow); interlayerElt.Attributes.Append(zlowAttribute); } } // Is selected ? if (null != selSolution) { // selected attribute XmlAttribute selAttribute = xmlDoc.CreateAttribute("Selected"); selAttribute.Value = "true"; solutionElt.Attributes.Append(selAttribute); // truck analyses XmlElement truckAnalysesElt = xmlDoc.CreateElement("TruckAnalyses"); solutionElt.AppendChild(truckAnalysesElt); foreach (TruckAnalysis truckAnalysis in selSolution.TruckAnalyses) Save(truckAnalysis, unique, truckAnalysesElt, xmlDoc); // ect analyses XmlElement ectAnalysesElt = xmlDoc.CreateElement("EctAnalyses"); solutionElt.AppendChild(ectAnalysesElt); foreach (ECTAnalysis ectAnalysis in selSolution.EctAnalyses) Save(ectAnalysis, unique, ectAnalysesElt, xmlDoc); } }
public void WriteSolution(SelCasePalletSolution selSolution, string filePath) { try { // retrieve solution CasePalletSolution sol = selSolution.Solution; // retrieve analysis CasePalletAnalysis analysis = sol.Analysis; // instantiate XmlDocument XmlDocument xmlDoc = new XmlDocument(); // let's add the XML declaration section XmlNode xmlnode = xmlDoc.CreateNode(XmlNodeType.XmlDeclaration, "", ""); xmlDoc.AppendChild(xmlnode); // create Document (root) element XmlElement xmlRootElement = xmlDoc.CreateElement("Document"); xmlDoc.AppendChild(xmlRootElement); // name XmlAttribute xmlDocNameAttribute = xmlDoc.CreateAttribute("Name"); xmlDocNameAttribute.Value = _name; xmlRootElement.Attributes.Append(xmlDocNameAttribute); // description XmlAttribute xmlDocDescAttribute = xmlDoc.CreateAttribute("Description"); xmlDocDescAttribute.Value = _description; xmlRootElement.Attributes.Append(xmlDocDescAttribute); // author XmlAttribute xmlDocAuthorAttribute = xmlDoc.CreateAttribute("Author"); xmlDocAuthorAttribute.Value = _author; xmlRootElement.Attributes.Append(xmlDocAuthorAttribute); // dateCreated XmlAttribute xmlDateCreatedAttribute = xmlDoc.CreateAttribute("DateCreated"); xmlDateCreatedAttribute.Value = string.Format("{0}", _dateCreated); xmlRootElement.Attributes.Append(xmlDateCreatedAttribute); // create ItemProperties element XmlElement xmlItemPropertiesElt = xmlDoc.CreateElement("ItemProperties"); xmlRootElement.AppendChild(xmlItemPropertiesElt); BoxProperties boxProperties = sol.Analysis.BProperties as BoxProperties; if (null != boxProperties) Save(boxProperties, xmlItemPropertiesElt, xmlDoc); BundleProperties bundleProperties = sol.Analysis.BProperties as BundleProperties; if (null != bundleProperties) Save(bundleProperties, xmlItemPropertiesElt, xmlDoc); PalletProperties palletProperties = sol.Analysis.PalletProperties as PalletProperties; if (null != palletProperties) Save(palletProperties, xmlItemPropertiesElt, xmlDoc); InterlayerProperties interlayerProperties = sol.Analysis.InterlayerProperties as InterlayerProperties; if (null != interlayerProperties) Save(interlayerProperties, xmlItemPropertiesElt, xmlDoc); if (null != selSolution && selSolution.TruckAnalyses.Count > 0) { TruckProperties truckProperties = selSolution.TruckAnalyses[0].TruckProperties; if (null != truckProperties) Save(truckProperties, xmlItemPropertiesElt, xmlDoc); } // create Analyses element XmlElement xmlAnalysesElt = xmlDoc.CreateElement("Analyses"); xmlRootElement.AppendChild(xmlAnalysesElt); SaveCasePalletAnalysis(sol.Analysis, sol, selSolution, xmlAnalysesElt, xmlDoc); // finally save XmlDocument xmlDoc.Save(filePath); } catch (Exception ex) { _log.Error(ex.ToString()); throw ex; } }
public void OnTruckAnalysisRemoved(Document doc, CasePalletAnalysis analysis, SelCasePalletSolution selectedSolution, TruckAnalysis truckAnalysis) { }
public void SaveCasePalletAnalysis(CasePalletAnalysis analysis, CasePalletSolution sol, SelCasePalletSolution selSolution, XmlElement parentElement, XmlDocument xmlDoc) { // create analysis element XmlElement xmlAnalysisElt = xmlDoc.CreateElement("AnalysisPallet"); parentElement.AppendChild(xmlAnalysisElt); // Name XmlAttribute analysisNameAttribute = xmlDoc.CreateAttribute("Name"); analysisNameAttribute.Value = analysis.Name; xmlAnalysisElt.Attributes.Append(analysisNameAttribute); // Description XmlAttribute analysisDescriptionAttribute = xmlDoc.CreateAttribute("Description"); analysisDescriptionAttribute.Value = analysis.Description; xmlAnalysisElt.Attributes.Append(analysisDescriptionAttribute); // BoxId XmlAttribute boxIdAttribute = xmlDoc.CreateAttribute("BoxId"); boxIdAttribute.Value = string.Format("{0}", analysis.BProperties.Guid); xmlAnalysisElt.Attributes.Append(boxIdAttribute); // PalletId XmlAttribute palletIdAttribute = xmlDoc.CreateAttribute("PalletId"); palletIdAttribute.Value = string.Format("{0}", analysis.PalletProperties.Guid); xmlAnalysisElt.Attributes.Append(palletIdAttribute); // InterlayerId if (null != analysis.InterlayerProperties) { XmlAttribute interlayerIdAttribute = xmlDoc.CreateAttribute("InterlayerId"); interlayerIdAttribute.Value = string.Format("{0}", analysis.InterlayerProperties.Guid); xmlAnalysisElt.Attributes.Append(interlayerIdAttribute); } if (null != analysis.InterlayerPropertiesAntiSlip) { XmlAttribute interlayerIdAttribute = xmlDoc.CreateAttribute("InterlayerAntiSlipId"); interlayerIdAttribute.Value = string.Format("{1}", analysis.InterlayerPropertiesAntiSlip.Guid); xmlAnalysisElt.Attributes.Append(interlayerIdAttribute); } // ### // ConstraintSet bool bundleAnalysis = (analysis.ConstraintSet.GetType() == typeof(BundlePalletConstraintSet)); XmlElement constraintSetElement = xmlDoc.CreateElement(bundleAnalysis ? "ConstraintSetBundle" : "ConstraintSetBox"); XmlAttribute alignedLayersAttribute = xmlDoc.CreateAttribute("AlignedLayersAllowed"); alignedLayersAttribute.Value = string.Format("{0}", analysis.ConstraintSet.AllowAlignedLayers); constraintSetElement.Attributes.Append(alignedLayersAttribute); XmlAttribute alternateLayersAttribute = xmlDoc.CreateAttribute("AlternateLayersAllowed"); alternateLayersAttribute.Value = string.Format("{0}", analysis.ConstraintSet.AllowAlternateLayers); constraintSetElement.Attributes.Append(alternateLayersAttribute); if (!bundleAnalysis) { // allowed box positions XmlAttribute allowedAxisAttribute = xmlDoc.CreateAttribute("AllowedBoxPositions"); HalfAxis.HAxis[] axes = { HalfAxis.HAxis.AXIS_X_P, HalfAxis.HAxis.AXIS_Y_P, HalfAxis.HAxis.AXIS_Z_P }; string allowedAxes = string.Empty; foreach (HalfAxis.HAxis axis in axes) if (analysis.ConstraintSet.AllowOrthoAxis(axis)) { if (!string.IsNullOrEmpty(allowedAxes)) allowedAxes += ","; allowedAxes += HalfAxis.ToString(axis); } allowedAxisAttribute.Value = allowedAxes; constraintSetElement.Attributes.Append(allowedAxisAttribute); } // allowed layer patterns XmlAttribute allowedPatternAttribute = xmlDoc.CreateAttribute("AllowedPatterns"); allowedPatternAttribute.Value = analysis.ConstraintSet.AllowedPatternString; constraintSetElement.Attributes.Append(allowedPatternAttribute); // stop criterions if (analysis.ConstraintSet.UseMaximumHeight) { XmlAttribute maximumHeightAttribute = xmlDoc.CreateAttribute("MaximumHeight"); maximumHeightAttribute.Value = string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}", analysis.ConstraintSet.MaximumHeight); constraintSetElement.Attributes.Append(maximumHeightAttribute); } if (analysis.ConstraintSet.UseMaximumNumberOfCases) { XmlAttribute maximumNumberOfItems = xmlDoc.CreateAttribute("ManimumNumberOfItems"); maximumNumberOfItems.Value = string.Format("{0}", analysis.ConstraintSet.MaximumNumberOfItems); constraintSetElement.Attributes.Append(maximumNumberOfItems); } if (analysis.ConstraintSet.UseMaximumPalletWeight) { XmlAttribute maximumPalletWeight = xmlDoc.CreateAttribute("MaximumPalletWeight"); maximumPalletWeight.Value = string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}", analysis.ConstraintSet.MaximumPalletWeight); constraintSetElement.Attributes.Append(maximumPalletWeight); } if (analysis.ConstraintSet.UseMaximumWeightOnBox) { XmlAttribute maximumWeightOnBox = xmlDoc.CreateAttribute("MaximumWeightOnBox"); maximumWeightOnBox.Value = string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}", analysis.ConstraintSet.MaximumWeightOnBox); constraintSetElement.Attributes.Append(maximumWeightOnBox); } // overhang / underhang XmlAttribute overhangX = xmlDoc.CreateAttribute("OverhangX"); overhangX.Value = string.Format("{0}", analysis.ConstraintSet.OverhangX); constraintSetElement.Attributes.Append(overhangX); XmlAttribute overhangY = xmlDoc.CreateAttribute("OverhangY"); overhangY.Value = string.Format("{0}", analysis.ConstraintSet.OverhangY); constraintSetElement.Attributes.Append(overhangY); // number of solutions to keep if (analysis.ConstraintSet.UseNumberOfSolutionsKept) { XmlAttribute numberOfSolutionsKept = xmlDoc.CreateAttribute("NumberOfSolutions"); numberOfSolutionsKept.Value = "1"; constraintSetElement.Attributes.Append(numberOfSolutionsKept); } xmlAnalysisElt.AppendChild(constraintSetElement); // ### // Solutions XmlElement solutionsElt = xmlDoc.CreateElement("Solutions"); xmlAnalysisElt.AppendChild(solutionsElt); SaveCasePalletSolution(analysis, sol, selSolution, true /* unique */, solutionsElt, xmlDoc ); }
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()); } }
void onSolutionSelectionChanged(CasePalletAnalysis analysis, SelCasePalletSolution selSolution) { UpdateSelectButtonText(); UpdateGridCheckBoxes(); }
public void OnNewTruckAnalysisCreated(Document doc, CasePalletAnalysis analysis, SelCasePalletSolution selSolution, TruckAnalysis truckAnalysis) { CreateOrActivateViewTruckAnalysis(truckAnalysis); }
private ECTAnalysis LoadECTAnalysis(XmlElement eltEctAnalysis, SelCasePalletSolution selSolution) { string name = eltEctAnalysis.Attributes["Name"].Value; string description = eltEctAnalysis.Attributes["Description"].Value; ECTAnalysis ectAnalysis = selSolution.CreateNewECTAnalysis(name, description); // Cardboard foreach (XmlNode node in eltEctAnalysis.ChildNodes) { if (string.Equals(node.Name, "Cardboard", StringComparison.CurrentCultureIgnoreCase)) { string cardboardName = string.Empty, profile = string.Empty; double thickness = 0.0, ect = 0.0, stiffnessX = 0.0, stiffnessY = 0.0; XmlElement eltCardboard = node as XmlElement; if (eltCardboard.HasAttribute("Name")) cardboardName = eltCardboard.Attributes["Name"].Value; if (eltCardboard.HasAttribute("Thickness")) thickness = UnitsManager.ConvertLengthFrom(double.Parse(eltCardboard.Attributes["Thickness"].Value), _unitSystem); if (eltCardboard.HasAttribute("ECT")) ect = double.Parse(eltCardboard.Attributes["ECT"].Value); if (eltCardboard.HasAttribute("StiffnessX")) stiffnessX = double.Parse(eltCardboard.Attributes["StiffnessX"].Value); if (eltCardboard.HasAttribute("StiffnessY")) stiffnessY = double.Parse(eltCardboard.Attributes["StiffnessY"].Value); ectAnalysis.Cardboard = new EdgeCrushTest.McKeeFormula.QualityData(name, profile, thickness, ect, stiffnessX, stiffnessY); } } // CaseType if (eltEctAnalysis.HasAttribute("CaseType")) ectAnalysis.CaseType = eltEctAnalysis.Attributes["CaseType"].Value; // PrintSurface if (eltEctAnalysis.HasAttribute("PrintSurface")) ectAnalysis.PrintSurface = eltEctAnalysis.Attributes["PrintSurface"].Value; // McKeeFormulaMode if (eltEctAnalysis.HasAttribute("McKeeFormulaMode")) ectAnalysis.McKeeFormulaText = eltEctAnalysis.Attributes["McKeeFormulaMode"].Value; return ectAnalysis; }
public NodeTag(NodeType type, Document document, CasePalletAnalysis analysis, SelCasePalletSolution selSolution, ECTAnalysis ectAnalysis) { _type = type; _document = document; _itemProperties = null; _casePalletAnalysis = analysis; _selSolution = selSolution; _ectAnalysis = ectAnalysis; }
public void SelectSolutionBySol(CasePalletSolution sol) { if (HasSolutionSelected(sol)) return; // instantiate new SelSolution SelCasePalletSolution selSolution = new SelCasePalletSolution(ParentDocument, this, sol); // insert in list _selectedSolutions.Add(selSolution); // fire event if (null != SolutionSelected) SolutionSelected(this, selSolution); // set document modified (not analysis, otherwise selected solutions are erased) ParentDocument.Modify(); }
private void onPalletAnalysisSolutionSelectionRemoved(CasePalletAnalysis analysis, SelCasePalletSolution selSolution) { // retrieve parent document Document doc = analysis.ParentDocument; // get node TreeNode selSolutionNode = FindNode(null, new NodeTag(NodeTag.NodeType.NT_CASEPALLETANALYSISSOLUTION, doc, analysis, selSolution)); // test if (null == selSolutionNode) { _log.Error(string.Format("Failed to find a valid tree node for selSolution {0}", selSolution.Name)); return; } // remove node Nodes.Remove(selSolutionNode); }
private void onPalletAnalysisSolutionSelected(CasePalletAnalysis analysis, SelCasePalletSolution selSolution) { // retrieve parent document Document doc = analysis.ParentDocument; // get parent node TreeNode parentNode = FindNode(null, new NodeTag(NodeTag.NodeType.NT_CASEPALLETANALYSIS, doc, analysis)); if (null == parentNode) throw new Exception("Failed to locate Analysis (NT_CASEPALLETANALYSIS) node..."); // insert selected solution node TreeNode nodeSelSolution = new TreeNode(selSolution.Name, 15, 15); nodeSelSolution.Tag = new NodeTag(NodeTag.NodeType.NT_CASEPALLETANALYSISSOLUTION, doc, analysis, selSolution); parentNode.Nodes.Add(nodeSelSolution); // expand tree nodes parentNode.Expand(); }
public void OnECTAnalysisRemoved(Document doc, CasePalletAnalysis analysis, SelCasePalletSolution selectedSolution, ECTAnalysis ectAnalysis) { }
internal void NotifyOnNewTruckAnalysisCreated(CasePalletAnalysis analysis, SelCasePalletSolution selSolution, TruckAnalysis truckAnalysis) { foreach (IDocumentListener listener in _listeners) listener.OnNewTruckAnalysisCreated(this, analysis, selSolution, truckAnalysis); }
/// <summary> /// handles truck analysis removal : removed truck analysis node from /// </summary> public void OnTruckAnalysisRemoved(Document doc, CasePalletAnalysis analysis, SelCasePalletSolution selSolution, TruckAnalysis truckAnalysis) { // get node TreeNode truckAnalysisNode = FindNode(null, new NodeTag(NodeTag.NodeType.NT_TRUCKANALYSIS, doc, analysis, selSolution, truckAnalysis)); // test if (null == truckAnalysisNode) { _log.Warn(string.Format("Failed to find a valid tree node for truck analysis {0}", truckAnalysis.Name)); return; } // remove node Nodes.Remove(truckAnalysisNode); }
internal void NotifyOnTruckAnalysisRemoved(SelCasePalletSolution selSolution, TruckAnalysis truckAnalysis) { foreach (IDocumentListener listener in _listeners) listener.OnTruckAnalysisRemoved(this, selSolution.Analysis, selSolution, truckAnalysis); }
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()); }
private TruckAnalysis LoadTruckAnalysis(XmlElement eltTruckAnalysis, SelCasePalletSolution selSolution) { string sName = eltTruckAnalysis.Attributes["Name"].Value; string sDescription = eltTruckAnalysis.Attributes["Description"].Value; string sTruckId = eltTruckAnalysis.Attributes["TruckId"].Value; TruckConstraintSet constraintSet = new TruckConstraintSet(); List<TruckSolution> solutions = new List<TruckSolution>(); List<int> selectedIndices = new List<int>(); foreach (XmlNode node in eltTruckAnalysis.ChildNodes) { // load constraint set if (string.Equals(node.Name, "ConstraintSet", StringComparison.CurrentCultureIgnoreCase)) constraintSet = LoadTruckConstraintSet(node as XmlElement); // load solutions else if (string.Equals(node.Name, "Solutions", StringComparison.CurrentCultureIgnoreCase)) { int indexSol = 0; foreach (XmlNode solutionNode in node.ChildNodes) { XmlElement eltSolution = solutionNode as XmlElement; solutions.Add(LoadTruckSolution(eltSolution)); // is solution selected ? if (null != eltSolution.Attributes["Selected"] && string.Equals("true", eltSolution.Attributes["Selected"].Value, StringComparison.CurrentCultureIgnoreCase)) selectedIndices.Add(indexSol); ++indexSol; } } } TruckAnalysis truckAnalysis = selSolution.CreateNewTruckAnalysis( sName , sDescription , GetTypeByGuid(new Guid(sTruckId)) as TruckProperties , constraintSet , solutions); foreach (int index in selectedIndices) truckAnalysis.SelectedSolutionIndex = index; return truckAnalysis; }
public ReportData(CasePalletAnalysis palletAnalysis, SelCasePalletSolution selSolution) { _palletAnalysis = palletAnalysis; _selSolution = selSolution; }
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()); } }
public void SelectSolutionByIndex(int index) { if (index < 0 || index > _solutions.Count) return; // no solution with this index if (HasSolutionSelected(index)) return; // solution already selected // instantiate new SelSolution SelCasePalletSolution selSolution = new SelCasePalletSolution(ParentDocument, this, _solutions[index]); // insert in list _selectedSolutions.Add(selSolution); // fire event if (null != SolutionSelected) SolutionSelected(this, selSolution); // set document modified (not analysis, otherwise selected solutions are erased) ParentDocument.Modify(); }
public NodeTag(NodeType type, Document doc, BoxCasePalletAnalysis caseAnalysis, ItemBase itemProperties) { _type = type; _document = doc; _boxCasePalletAnalysis = caseAnalysis; _itemProperties = itemProperties; _selSolution = null; }
public void UnSelectSolution(SelCasePalletSolution selSolution) { if (null == selSolution) return; // this solution not selected // remove from list _selectedSolutions.Remove(selSolution); ParentDocument.RemoveItem(selSolution); // fire event if (null != SolutionSelectionRemoved) SolutionSelectionRemoved(this, selSolution); // set document modified (not analysis, otherwise selected solutions are erased) ParentDocument.Modify(); }
/// <summary> /// handles new truck analysis created /// </summary> public void OnNewTruckAnalysisCreated(Document doc, CasePalletAnalysis analysis, SelCasePalletSolution selSolution, TruckAnalysis truckAnalysis) { // get parent node TreeNode parentNode = FindNode(null, new NodeTag(NodeTag.NodeType.NT_CASEPALLETANALYSISSOLUTION, doc, analysis, selSolution)); // insert truckAnalysis node TreeNode nodeTruckAnalysis = new TreeNode(truckAnalysis.Name, 16, 16); nodeTruckAnalysis.Tag = new NodeTag(NodeTag.NodeType.NT_TRUCKANALYSIS, doc, analysis, selSolution, truckAnalysis); parentNode.Nodes.Add(nodeTruckAnalysis); // expand parent tree node parentNode.Expand(); }
public void OnNewECTAnalysisCreated(Document doc, CasePalletAnalysis analysis, SelCasePalletSolution selSolution, ECTAnalysis ectAnalysis) { }