private IDictionary<string, byte[]> GenerateFile(ReportNode report, string name, string format) { var source = new GroupMessage(null, null, PX.Common.Mail.MailSender.MessageAddressee.Empty, PX.Common.Mail.MailSender.MessageContent.Empty, null, format, MessageRelationship.Empty, ReportAttachment.Empty); var message = new PX.Reports.Mail.Message(source, report, null); var attachments = message.Attachments; if (attachments == null) return null; var result = new Dictionary<string, byte[]>(attachments.Count); var index = 0; foreach (var item in attachments) { var filename = item.Name; if (!string.IsNullOrEmpty(name)) { filename = name; if (index++ > 0) filename += " (" + index.ToString() + ")"; } if (!System.IO.Path.HasExtension(item.Name)) { var ext = MimeTypes.GetExtension(item.MimeType); if (ext != null) filename = System.IO.Path.GetFileNameWithoutExtension(filename) + ext; } result.Add(filename, item.ToArray()); } return result; }
public override void update() { CswNbtMetaDataObjectClass ReportOC = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( CswEnumNbtObjectClass.ReportClass ); foreach( CswNbtObjClassReport ReportNode in ReportOC.getNodes( false, true, false, true ) ) { if( "Location Codes" == ReportNode.ReportName.Text ) { ReportNode.SQL.Text = @"select lscode,location,name,Location || ' > ' || name pathname, type from ( select barcode lscode,name,location,'building' type from building union select barcode lscode,name,location,'room' type from room union select barcode lscode,name,location,'cabinet' type from cabinet union select barcode lscode, name, location, 'floor' type from floor union select barcode lscode, name, location, 'shelf' type from shelf union select barcode lscode, name, location, 'box' type from box ) x where name is not null and location is not null and lower(location || ' > ' || name) like lower(trim('{LocationBegins}') || '%') order by lower(location), lower(name)"; ReportNode.postChanges( false ); } } } // update()
public SPShowData(ReportNode rp) : base(rp) { AddMenuItem("General", "Show Data", delegate { Plot(); }); }
public IEnumerable <CRSMEmail> Send() { PXReportTools.InitReportParameters(_report, _parameters, SettingsProvider.Instance.Default); ReportNode reportNode = ReportProcessor.ProcessReport(_report); reportNode.SendMailMode = true; return(SendMessages(MailAccountId, reportNode, Format, AdditionalRecipents, NotificationID)); }
public override void update() { // Add (demo) to Lab 1 Deficiencies Report CswNbtMetaDataObjectClass ReportOC = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( NbtObjectClass.ReportClass ); foreach( CswNbtObjClassReport ReportNode in ReportOC.getNodes( false, false ) ) { if( ReportNode.ReportName.Text == "Lab 1 Deficiencies" ) { ReportNode.ReportName.Text = "Lab 1 Deficiencies (demo)"; ReportNode.postChanges( false ); } } } //Update()
/// <summary> /// Builds the root entity. /// </summary> /// <param name="node">The root node.</param> /// <param name="context">The context.</param> /// <returns>Entity.</returns> /// <exception cref="System.Exception">Unknown report node type.</exception> internal static Entity BuildReportNode(ReportNode node, FromEntityContext context) { if (node == null) { throw new ArgumentNullException(nameof(node)); } if (context == null) { throw new ArgumentNullException(nameof(context)); } Entity structuredQueryEntity; if (node.Is <AggregateReportNode>()) { structuredQueryEntity = BuildAggregateReportNode(node.As <AggregateReportNode>(), context); } else if (node.Is <RelationshipReportNode>()) { structuredQueryEntity = BuildRelationshipReportNode(node.As <RelationshipReportNode>(), context); } else if (node.Is <CustomJoinReportNode>( )) { structuredQueryEntity = BuildCustomJoinReportNode(node.As <CustomJoinReportNode>( ), context); } else if (node.Is <DerivedTypeReportNode>()) { structuredQueryEntity = BuildDerivedTypeReportNode(node.As <DerivedTypeReportNode>(), context); } else if (node.Is <ResourceReportNode>()) { structuredQueryEntity = BuildResourceReportNode(node.As <ResourceReportNode>(), context); } else { throw new Exception("Unknown report node type. " + node.GetType().Name); } if (node.RelatedReportNodes != null && node.RelatedReportNodes.Count > 0) { structuredQueryEntity.RelatedEntities = new List <Entity>(node.RelatedReportNodes.Select(relatedReportNode => BuildReportNode(relatedReportNode, context)).Where(entity => entity != null)); } if (structuredQueryEntity != null) { // Only valid nodes get placed into the ReportNodeToEntityMap // (but ReportNodeMap may contain invalid nodes for historical reasons) context.ReportNodeToEntityMap[node.Id] = structuredQueryEntity; } return(structuredQueryEntity); }
private void addToReportTreeView(ReportNode node, ReportNode parent) { if (null == parent) { trvReports.Nodes.Add(node); } else { parent.Nodes.Add(node); } node.Children.Where(c => c.Contains(txtReports.Text)) .ToList() .ForEach(n => addToReportTreeView(n, node)); }
private static IEnumerable <Message> GetMessages(ReportNode report) { { var mailSource = new Dictionary <GroupMessage, PX.Reports.Mail.Message>(); foreach (MailSettings message in report.Groups.Select(g => g.MailSettings)) { if (message != null && message.ShouldSerialize() && !mailSource.ContainsKey(message)) { mailSource.Add(message, new PX.Reports.Mail.Message(message, report, message)); } } return(mailSource.Values); } }
public override List <NextGenLab.Chart.ChartData> OnPlot(ReportNode rp) { DataForm df = new DataForm(rp); Form f = rp.MDIContainer; if (f.IsMdiContainer) { f.Invoke(new SetMdiContainer(SetMDICont), f, df); } else { df.Show(); } return(null); }
private static IEnumerable <Message> GetMessages(ReportNode report) { { var mailSource = new Dictionary <GroupMessage, PX.Reports.Mail.Message>(); foreach (GroupNode group in report.Groups) { GroupMessage message = group.MailSettings; if (group.MailSettings != null && group.MailSettings.ShouldSerialize() && !mailSource.ContainsKey(message)) { mailSource.Add(message, new PX.Reports.Mail.Message(message, report, message)); } } return(mailSource.Values); } }
private IDictionary <string, byte[]> GenerateFile(ReportNode report, string name, string format) { var source = new GroupMessage(null, null, PX.Common.Mail.MailSender.MessageAddressee.Empty, PX.Common.Mail.MailSender.MessageContent.Empty, null, format, MessageRelationship.Empty, ReportAttachment.Empty); var message = new PX.Reports.Mail.Message(source, report, null); var attachments = message.Attachments; if (attachments == null) { return(null); } var result = new Dictionary <string, byte[]>(attachments.Count); var index = 0; foreach (var item in attachments) { var filename = item.Name; if (!string.IsNullOrEmpty(name)) { filename = name; if (index++ > 0) { filename += " (" + index.ToString() + ")"; } } if (!System.IO.Path.HasExtension(item.Name)) { var ext = MimeTypes.GetExtension(item.MimeType); if (ext != null) { filename = System.IO.Path.GetFileNameWithoutExtension(filename) + ext; } } result.Add(filename, item.ToArray()); } return(result); }
private static IEnumerable <EPActivity> SendMessages(int?accountId, ReportNode report, string format, IEnumerable <NotificationRecipient> additionalRecipents, Int32?TemplateID) { List <EPActivity> result = new List <EPActivity>(); Exception ex = null; foreach (Message message in GetMessages(report)) { try { result.AddRange(Send(accountId, message, format, additionalRecipents, TemplateID)); } catch (Exception e) { PXTrace.WriteError(e); ex = e; } } if (ex != null) { throw ex; } return(result); }
/// <summary> /// Populates the analyser type for column. /// </summary> /// <param name="report">The report.</param> /// <param name="entityType">The resource type returned if the analyser refers to a resource expression.</param> /// <param name="reportExpression">The report expression.</param> /// <param name="reportAnalyserColumn">The report analyser column.</param> private static void PopulateAnalyserTypeForColumn(Report report, EntityType entityType, ReportExpression reportExpression, ReportAnalyserColumn reportAnalyserColumn) { reportAnalyserColumn.AnalyserType = reportAnalyserColumn.Type.GetDisplayName(); if (reportExpression.Is <StructureViewExpression>()) { reportAnalyserColumn.AnalyserType = StructureLevelsType.DisplayName; reportAnalyserColumn.DefaultOperator = Structured.ConditionType.AnyBelowStructureLevel; var expression = reportExpression.As <StructureViewExpression>(); var resReportNode = expression.StructureViewExpressionSourceNode.As <ResourceReportNode>(); var eType = resReportNode.ResourceReportNodeType; reportAnalyserColumn.TypeId = eType.Id; return; } if (!reportExpression.Is <NodeExpression>()) { return; } NodeExpression nodeExpression = reportExpression.As <NodeExpression>(); if (!nodeExpression.SourceNode.Is <ResourceReportNode>()) { return; } bool isNameColumnForType = false; if (reportExpression.Is <FieldExpression>()) { var fieldExpression = reportExpression.As <FieldExpression>(); if (fieldExpression.FieldExpressionField.Alias != "core:name") { return; } long sourceId = fieldExpression.SourceNode != null ? fieldExpression.SourceNode.Id : 0; long rootId = report.RootNode != null ? report.RootNode.Id : 0; isNameColumnForType = (sourceId == rootId) && (sourceId != 0); } reportAnalyserColumn.IsNameColumnForType = isNameColumnForType; ResourceReportNode resourceReportNode = nodeExpression.SourceNode.As <ResourceReportNode>( ); RelationshipReportNode relationshipReportNode = nodeExpression.SourceNode.As <RelationshipReportNode>( ); if (entityType == null) { // Need to be able accept entityType as an argument, e.g. if it is from a script column // But also need to be able to read it from the node, e.g. if it is the root name column. Messed up. entityType = resourceReportNode.ResourceReportNodeType; if (entityType == null) { return; } } ResourceExpression resourceExpression = reportExpression.As <ResourceExpression>(); // Handle "Type" types //if the resource type is "Type", add current parent node type and descendant types' id as filtered entity ids (bug 24859) //Update: only the forward relationship is "isOfType", the "type" list will be restricted. (bug 27862) if (entityType.Alias == "core:type" && relationshipReportNode?.FollowRelationship?.Alias == "core:isOfType" ) { AggregateReportNode parentAggregatedNode = resourceReportNode.ParentAggregatedNode; ReportNode parentReportNode = parentAggregatedNode != null ? parentAggregatedNode.GroupedNode : resourceReportNode.ParentReportNode; ResourceReportNode parentResourceReportNode = parentReportNode != null?parentReportNode.As <ResourceReportNode>() : null; if (parentResourceReportNode != null && parentResourceReportNode.ResourceReportNodeType != null) { reportAnalyserColumn.FilteredEntityIds = PerTenantEntityTypeCache.Instance.GetDescendantsAndSelf( parentResourceReportNode.ResourceReportNodeType.Id).ToArray(); } } // Handle "User" and "Person" types if (PerTenantEntityTypeCache.Instance.IsDerivedFrom(entityType.Id, "core:person") || PerTenantEntityTypeCache.Instance.IsDerivedFrom(entityType.Id, "core:userAccount")) { // If this is a relationship or calc then make it as a user inline relationship otherwise a simple user string. reportAnalyserColumn.AnalyserType = nodeExpression.SourceNode.Is <FieldExpression>( ) ? "UserString" : "UserInlineRelationship"; return; } // Treat the root 'Name' column like a lookup, so we get the 'Any Of', 'Any Except' options. if (isNameColumnForType) { reportAnalyserColumn.AnalyserType = "InlineRelationship"; reportAnalyserColumn.TypeId = entityType.Id; } }
/// <summary> /// ReportHtml : generate html report /// </summary> public ReporterHtml(ReportData inputData, ref ReportNode rnRoot, string templatePath, string outpuFilePath) { BuildAnalysisReport(inputData, ref rnRoot, templatePath, outpuFilePath); }
public override void update() { #region NodeTypes CswNbtMetaDataNodeType ReportGroupPermNT = _createPermissionNT( CswEnumNbtObjectClass.ReportGroupPermissionClass, "Report Group Permission" ); CswNbtMetaDataNodeType MailReportGroupPermNT = _createPermissionNT( CswEnumNbtObjectClass.MailReportGroupPermissionClass, "Mail Report Group Permission" ); CswNbtMetaDataNodeType ReportGroupNT = _createGroupNT( CswEnumNbtObjectClass.ReportGroupClass, "Report Group", CswNbtObjClassReportGroup.PropertyName.Reports ); CswNbtMetaDataNodeType MailReportGroupNT = _createGroupNT( CswEnumNbtObjectClass.MailReportGroupClass, "Mail Report Group", CswNbtObjClassMailReportGroup.PropertyName.MailReports ); CswNbtMetaDataObjectClass InvGrpPermOC = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( CswEnumNbtObjectClass.InventoryGroupPermissionClass ); _CswNbtSchemaModTrnsctn.MetaData.makeMissingNodeTypeProps();//For some reason this is needed here or else the following code will throw an ORNI on a full master reset foreach( CswNbtMetaDataNodeType InvGrpPermNT in InvGrpPermOC.getNodeTypes() ) { _setPermissionPropFilters( InvGrpPermNT ); } #endregion NodeTypes #region Permission Group Nodes CswNbtObjClassReportGroup DefaultReportGroup = _CswNbtSchemaModTrnsctn.Nodes.makeNodeFromNodeTypeId( ReportGroupNT.NodeTypeId, CswEnumNbtMakeNodeOperation.MakeTemp ); DefaultReportGroup.Name.Text = "Default Report Group"; DefaultReportGroup.IsTemp = false; DefaultReportGroup.postChanges( false ); CswNbtMetaDataObjectClass ReportOC = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( CswEnumNbtObjectClass.ReportClass ); foreach( CswNbtObjClassReport ReportNode in ReportOC.getNodes( false, false ) ) { ReportNode.ReportGroup.RelatedNodeId = DefaultReportGroup.NodeId; ReportNode.postChanges( false ); } CswNbtObjClassMailReportGroup DefaultMailReportGroup = _CswNbtSchemaModTrnsctn.Nodes.makeNodeFromNodeTypeId( MailReportGroupNT.NodeTypeId, CswEnumNbtMakeNodeOperation.MakeTemp ); DefaultMailReportGroup.Name.Text = "Default Mail Report Group"; DefaultMailReportGroup.IsTemp = false; DefaultMailReportGroup.postChanges( false ); CswNbtMetaDataObjectClass MailReportOC = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( CswEnumNbtObjectClass.MailReportClass ); foreach( CswNbtObjClassMailReport MailReportNode in MailReportOC.getNodes( false, false ) ) { MailReportNode.MailReportGroup.RelatedNodeId = DefaultMailReportGroup.NodeId; MailReportNode.postChanges( false ); } #endregion Permission Group Nodes #region Inventory Group Permission Nodes CswNbtMetaDataNodeType InventoryGroupNT = InvGrpPermOC.FirstNodeType; if( null != InventoryGroupNT ) { CswNbtMetaDataNodeTypeProp PermissionGroupNTP = InventoryGroupNT.getNodeTypePropByObjectClassProp( CswNbtPropertySetPermission.PropertyName.PermissionGroup ); if( null != PermissionGroupNTP ) { PermissionGroupNTP.PropName = CswNbtPropertySetPermission.PropertyName.PermissionGroup; } } foreach( CswNbtObjClassInventoryGroupPermission InvGrpPermNode in InvGrpPermOC.getNodes( false, false ) ) { InvGrpPermNode.ApplyToAllWorkUnits.Checked = CswEnumTristate.False; InvGrpPermNode.ApplyToAllRoles.Checked = CswEnumTristate.False; InvGrpPermNode.PermissionGroup.RefreshNodeName(); InvGrpPermNode.postChanges( false ); } CswNbtMetaDataObjectClass InvGrpOC = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( CswEnumNbtObjectClass.InventoryGroupClass ); foreach( CswNbtObjClassInventoryGroup InvGrpNode in InvGrpOC.getNodes( false, false ) ) { if( InvGrpNode.Name.Text == "Default Inventory Group" && null != InventoryGroupNT ) { CswNbtObjClassInventoryGroupPermission WildCardInventoryGroupPermission = _CswNbtSchemaModTrnsctn.Nodes.makeNodeFromNodeTypeId( InventoryGroupNT.NodeTypeId, CswEnumNbtMakeNodeOperation.DoNothing ); WildCardInventoryGroupPermission.ApplyToAllRoles.Checked = CswEnumTristate.True; WildCardInventoryGroupPermission.ApplyToAllWorkUnits.Checked = CswEnumTristate.True; WildCardInventoryGroupPermission.PermissionGroup.RelatedNodeId = InvGrpNode.NodeId; WildCardInventoryGroupPermission.View.Checked = CswEnumTristate.True; WildCardInventoryGroupPermission.Edit.Checked = CswEnumTristate.True; WildCardInventoryGroupPermission.Dispense.Checked = CswEnumTristate.False; WildCardInventoryGroupPermission.Dispose.Checked = CswEnumTristate.False; WildCardInventoryGroupPermission.Request.Checked = CswEnumTristate.False; WildCardInventoryGroupPermission.Undispose.Checked = CswEnumTristate.False; WildCardInventoryGroupPermission.WorkUnit.RelatedNodeId = null; WildCardInventoryGroupPermission.WorkUnit.RefreshNodeName(); WildCardInventoryGroupPermission.WorkUnit.SyncGestalt(); WildCardInventoryGroupPermission.postChanges( false ); } } //This is now being handled as part of creating the Default Group nodes /*CswNbtObjClassReportGroupPermission WildCardReportGroupPermission = _CswNbtSchemaModTrnsctn.Nodes.makeNodeFromNodeTypeId( ReportGroupPermNT.NodeTypeId, CswEnumNbtMakeNodeOperation.DoNothing ); WildCardReportGroupPermission.ApplyToAllRoles.Checked = CswEnumTristate.True; WildCardReportGroupPermission.ApplyToAllWorkUnits.Checked = CswEnumTristate.True; WildCardReportGroupPermission.PermissionGroup.RelatedNodeId = DefaultReportGroup.NodeId; WildCardReportGroupPermission.View.Checked = CswEnumTristate.True; WildCardReportGroupPermission.Edit.Checked = CswEnumTristate.True; WildCardReportGroupPermission.postChanges( false ); CswNbtObjClassMailReportGroupPermission WildCardMailReportGroupPermission = _CswNbtSchemaModTrnsctn.Nodes.makeNodeFromNodeTypeId( MailReportGroupPermNT.NodeTypeId, CswEnumNbtMakeNodeOperation.DoNothing ); WildCardMailReportGroupPermission.ApplyToAllRoles.Checked = CswEnumTristate.True; WildCardMailReportGroupPermission.ApplyToAllWorkUnits.Checked = CswEnumTristate.True; WildCardMailReportGroupPermission.PermissionGroup.RelatedNodeId = DefaultMailReportGroup.NodeId; WildCardMailReportGroupPermission.View.Checked = CswEnumTristate.True; WildCardMailReportGroupPermission.Edit.Checked = CswEnumTristate.True; WildCardMailReportGroupPermission.postChanges( false );*/ #endregion Inventory Group Permission Nodes } // update()
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); } }
private void DeleteReport(ReportNode reportNode) { var deleteReportCommand = commandFactory.CreateDeleteReportCommand(reportNode.FileName); taskManager.QueueTask(deleteReportCommand); }
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); } }
private void GenerateResult( string name, string description , double length, double width, double height, double?weight , PalletProperties palletProperties, Vector2D overhang , ref int stackCount , ref int layerCount, ref int byLayerCount , ref double loadWeight, ref double totalWeight , ref double stackEfficiency , ref string stackImagePath) { stackCount = 0; totalWeight = 0.0; stackImagePath = string.Empty; // generate case var 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; // generate image path if (GenerateImage) { stackImagePath = Path.Combine(Path.ChangeExtension(Path.GetTempFileName(), "png")); } else if (GenerateImageInFolder) { stackImagePath = Path.ChangeExtension(Path.Combine(DirectoryPathImages, name), "png"); } Graphics3DImage graphics = null; if (GenerateImage || GenerateImageInFolder) { graphics = new Graphics3DImage(new Size(ImageSize, ImageSize)) { FontSizeRatio = 0.01F, CameraPosition = Graphics3D.Corner_0 }; } // compute analysis ConstraintSetCasePallet constraintSet = new ConstraintSetCasePallet(); constraintSet.SetAllowedOrientations(new[] { !AllowOnlyZOrientation, !AllowOnlyZOrientation, true }); constraintSet.SetMaxHeight(new OptDouble(true, MaxPalletHeight)); constraintSet.Overhang = overhang; SolverCasePallet solver = new SolverCasePallet(bProperties, palletProperties, constraintSet); List <AnalysisLayered> analyzes = solver.BuildAnalyses(false); if (analyzes.Count > 0) { var analysis = analyzes[0]; stackCount = analysis.Solution.ItemCount; loadWeight = analysis.Solution.LoadWeight; totalWeight = analysis.Solution.Weight; stackEfficiency = analysis.Solution.VolumeEfficiency; if (analysis.Solution is SolutionLayered solutionLayered) { layerCount = solutionLayered.LayerCount; if (solutionLayered.Layers.Count > 0) { byLayerCount = solutionLayered.Layers[0].BoxCount; } } if (stackCount <= StackCountMax) { if (GenerateImage || GenerateImageInFolder) { var sv = new ViewerSolution(analysis.SolutionLay); sv.Draw(graphics, Transform3D.Identity); graphics.Flush(); } if (GenerateReport) { var inputData = new ReportDataAnalysis(analysis); string outputFilePath = Path.ChangeExtension(Path.Combine(DirectoryPathReports, $"Report_{analysis.Content.Name}_on_{analysis.Container.Name}"), "pdf"); var rnRoot = new ReportNode(Resources.ID_REPORT); var margins = new Margins(); //Reporter reporter = new ReporterMSWord(inputData, ref rnRoot, Settings.Default.ReportTemplatePath/*Reporter.TemplatePath*/, outputFilePath, margins); Reporter.SetFontSizeRatios(0.015F, 0.05F); Reporter reporter = new ReporterPDF(inputData, ref rnRoot, Reporter.TemplatePath, outputFilePath); } } } if (GenerateImage || GenerateImageInFolder) { var bmp = graphics.Bitmap; bmp.Save(stackImagePath, System.Drawing.Imaging.ImageFormat.Png); } }
private static void CheckFieldColumn <TArg>(ReportColumn column, string colName, string fieldName, ReportNode node) where TArg : class, IEntity { Assert.AreEqual(colName, column.Name, "Col name"); Assert.IsTrue(column.ColumnIsHidden == false, "Is hidden"); Assert.IsTrue(column.ColumnExpression.Is <FieldExpression>(), "Is field expr"); Assert.IsTrue(column.ColumnExpression.ReportExpressionResultType.Is <TArg>(), "Correct column type"); var nameExpr = column.ColumnExpression.As <FieldExpression>(); Assert.AreEqual(fieldName, nameExpr.FieldExpressionField.Name, "Correct field"); Assert.AreEqual(node.Id, nameExpr.SourceNode.Id); }
private static void CheckResourceExprColumn(ReportColumn column, string colName, ReportNode node, string expectedTypeName) { Assert.AreEqual(colName, column.Name, "Col name"); Assert.IsTrue(column.ColumnIsHidden == false, "Is hidden"); Assert.IsTrue(column.ColumnExpression.Is <EDC.ReadiNow.Model.ResourceExpression>(), "Is res expr"); Assert.IsTrue(column.ColumnExpression.ReportExpressionResultType.Is <ResourceArgument>()); var nameExpr = column.ColumnExpression.As <EDC.ReadiNow.Model.ResourceExpression>(); Assert.AreEqual(node.Id, nameExpr.SourceNode.Id); var resourceArg = column.ColumnExpression.ReportExpressionResultType.As <ResourceArgument>(); Assert.IsNotNull(resourceArg.ConformsToType, "Conforms to type"); Assert.AreEqual(expectedTypeName, resourceArg.ConformsToType.Name, "Conforms to type"); }
private static void CheckScriptColumn <TArg>(ReportColumn column, string colName, string script, ReportNode node) where TArg : class, IEntity { Assert.AreEqual(colName, column.Name, "Col name"); Assert.IsTrue(column.ColumnIsHidden == false, "Is hidden"); Assert.IsTrue(column.ColumnExpression.Is <EDC.ReadiNow.Model.ScriptExpression>(), "Is script expr"); Assert.IsTrue(column.ColumnExpression.ReportExpressionResultType.Is <TArg>()); var nameExpr = column.ColumnExpression.As <EDC.ReadiNow.Model.ScriptExpression>(); Assert.IsTrue(nameExpr.ReportScript == script); Assert.AreEqual(node.Id, nameExpr.SourceNode.Id); }