Exemplo n.º 1
0
        public IEnumerable <DocumentTable> GetTables()
        {
            var table = new PdfPTable(3)
            {
                WidthPercentage = 100
            };

            table.SetWidths(Widths.Split(',').Select(int.Parse).ToArray());

            table.DefaultCell.BackgroundColor = new GrayColor(0.9f);
            table.DefaultCell.SetLeading(15, 0);
            table.DefaultCell.Padding = 5.0f;

            var titles = Titles.Split(',');

            table.AddCell(new Phrase(titles[0], PdfFonts.Bold));
            table.AddCell(new Phrase(titles[1], PdfFonts.Bold));
            table.AddCell(new Phrase(titles[2], PdfFonts.Bold));

            table.HeaderRows = 1;
            table.DefaultCell.BackgroundColor = BaseColor.WHITE;

            foreach (var rel in GetAllSafety())
            {
                table.AddCell(new Phrase(rel.Safety.Description, PdfFonts.Normal));
                table.AddCell(new Phrase(rel.Location, PdfFonts.Normal));

                if (rel.Safety.Image != null)
                {
                    var fullName = string.Format(@"{0}\{1}", RootDirectory, rel.Safety.Image.Path);

                    try
                    {
                        var image = Image.GetInstance(fullName);
                        image.ScaleToFit(Math.Min(150, image.Width), Math.Min(150, image.Height));

                        var cell = new PdfPCell(image)
                        {
                            HorizontalAlignment = Element.ALIGN_CENTER,
                            VerticalAlignment   = Element.ALIGN_MIDDLE,
                            Padding             = 5.0f
                        };

                        table.AddCell(cell);
                    }
                    catch
                    {
                        table.AddCell(new Phrase("BILDET " + fullName + " IKKE FUNNET!"));
                    }
                }
                else
                {
                    table.AddCell("");
                }
            }

            return(new List <DocumentTable> {
                new DocumentTable("", table)
            });
        }
Exemplo n.º 2
0
        public IEnumerable <DocumentTable> GetTables()
        {
            var table = new PdfPTable(4)
            {
                WidthPercentage = 100
            };

            var titles = Titles.Split(',');

            table.SetWidths(Widths.Split(',').Select(int.Parse).ToArray());

            table.DefaultCell.BackgroundColor   = new GrayColor(0.9f);
            table.DefaultCell.VerticalAlignment = Element.ALIGN_MIDDLE;

            table.AddCell(new Phrase(titles[0], PdfFonts.Bold));
            table.AddCell(new Phrase(titles[1], PdfFonts.Bold));
            table.AddCell(new Phrase(titles[2], PdfFonts.Bold));
            table.AddCell(new Phrase(titles[3], PdfFonts.Bold));

            table.DefaultCell.BackgroundColor   = BaseColor.WHITE;
            table.DefaultCell.VerticalAlignment = Element.ALIGN_TOP;

            var attachments = GetAttachments(Role).ToList();

            attachments.Sort(delegate(IFileRelation f1, IFileRelation f2)
            {
                if (f1.Vendor != null && f2.Vendor != null)
                {
                    return(f1.Vendor.Name == f2.Vendor.Name ?
                           String.Compare(f1.Name, f2.Name, StringComparison.Ordinal) :
                           String.Compare(f1.Vendor.Name, f2.Vendor.Name, StringComparison.Ordinal));
                }

                if (f1.Vendor == null && f2.Vendor != null)
                {
                    return(-1);
                }

                return(1);
            });

            foreach (var attachment in attachments)
            {
                AddAttachmentRow(attachment, table);
            }

            return(new List <DocumentTable> {
                new DocumentTable("", table)
            });
        }
Exemplo n.º 3
0
 public string[] ParseTitles()
 {
     return(Titles.Split(SplitDelimiter));
 }
Exemplo n.º 4
0
        public IEnumerable <DocumentTable> GetTables()
        {
            var table = new PdfPTable(17)
            {
                WidthPercentage = 100
            };

            table.SetWidths(Widths.Split(',').Select(int.Parse).ToArray());

            var titles = Titles.Split(',');

            table.DefaultCell.Rowspan         = 2;
            table.DefaultCell.BackgroundColor = new GrayColor(0.9f);

            table.AddCell(new Phrase(titles[0], PdfFonts.SmallBold));
            table.AddCell(new Phrase(titles[1], PdfFonts.SmallBold));
            table.AddCell(new Phrase(titles[2], PdfFonts.SmallBold));

            table.DefaultCell.Rotation          = 90;
            table.DefaultCell.VerticalAlignment = Element.ALIGN_MIDDLE;
            table.AddCell(new Phrase(titles[3], PdfFonts.SmallBold));

            table.DefaultCell.Rotation            = 0;
            table.DefaultCell.Rowspan             = 1;
            table.DefaultCell.Colspan             = 8;
            table.DefaultCell.HorizontalAlignment = Element.ALIGN_CENTER;
            table.AddCell(new Phrase(titles[4], PdfFonts.SmallBold));

            table.DefaultCell.Colspan             = 2;
            table.DefaultCell.HorizontalAlignment = Element.ALIGN_LEFT;
            table.DefaultCell.VerticalAlignment   = Element.ALIGN_TOP;
            table.AddCell(new Phrase(titles[5], PdfFonts.SmallBold));

            table.DefaultCell.Colspan = 1;
            table.DefaultCell.Rowspan = 2;
            table.AddCell(new Phrase(titles[6], PdfFonts.SmallBold));
            table.AddCell(new Phrase(titles[7], PdfFonts.SmallBold));
            table.AddCell(new Phrase(titles[8], PdfFonts.SmallBold));

            table.DefaultCell.Rotation          = 90;
            table.DefaultCell.Rowspan           = 1;
            table.DefaultCell.VerticalAlignment = Element.ALIGN_MIDDLE;
            table.AddCell(new Phrase(titles[9], PdfFonts.TinyBold));
            table.AddCell(new Phrase(titles[10], PdfFonts.TinyBold));
            table.AddCell(new Phrase(titles[11], PdfFonts.TinyBold));
            table.AddCell(new Phrase(titles[12], PdfFonts.TinyBold));
            table.AddCell(new Phrase(titles[13], PdfFonts.TinyBold));
            table.AddCell(new Phrase(titles[14], PdfFonts.TinyBold));
            table.AddCell(new Phrase(titles[15], PdfFonts.TinyBold));
            table.AddCell(new Phrase(titles[16], PdfFonts.TinyBold));

            table.AddCell(new Phrase(titles[17], PdfFonts.SmallBold));
            table.AddCell(new Phrase(titles[18], PdfFonts.SmallBold));

            table.HeaderRows = 2;

            table.DefaultCell.Rotation        = 0;
            table.DefaultCell.BackgroundColor = BaseColor.WHITE;

            var maintenances = GetAllMaintenance();

            var enumerable = maintenances as IList <Maintenance> ?? maintenances.ToList();

            foreach (var maintenance in enumerable)
            {
                AddMaintenanceRow(maintenance, table);
            }

            table.DefaultCell.Colspan = 17;
            table.AddCell(" ");

            table.DefaultCell.Colspan             = 4;
            table.DefaultCell.HorizontalAlignment = Element.ALIGN_LEFT;
            table.AddCell(new Phrase(Info, PdfFonts.Small));

            table.DefaultCell.Colspan             = 1;
            table.DefaultCell.Rotation            = 90;
            table.DefaultCell.HorizontalAlignment = Element.ALIGN_CENTER;
            table.DefaultCell.VerticalAlignment   = Element.ALIGN_MIDDLE;

            table.AddCell(new Phrase("24", PdfFonts.Tiny));
            table.AddCell(new Phrase("168", PdfFonts.Tiny));
            table.AddCell(new Phrase("336", PdfFonts.Tiny));
            table.AddCell(new Phrase("720", PdfFonts.Tiny));
            table.AddCell(new Phrase("2160", PdfFonts.Tiny));
            table.AddCell(new Phrase("4320", PdfFonts.Tiny));
            table.AddCell(new Phrase("8640", PdfFonts.Tiny));
            table.AddCell(new Phrase(">8640", PdfFonts.Tiny));

            table.DefaultCell.Colspan = 5;
            table.AddCell("");

            table.DefaultCell.Rotation = 0;

            var vendors = enumerable
                          .Select(m => m.Vendor)
                          .Where(v => v != null)
                          .Distinct()
                          .OrderBy(v => v.Name);

            foreach (var vendor in vendors)
            {
                var abbreviation = GetVendorAbbreviation(vendor);

                table.DefaultCell.Colspan             = 16;
                table.DefaultCell.HorizontalAlignment = Element.ALIGN_LEFT;
                table.AddCell(new Phrase(abbreviation + " = " + vendor.Name + "  " + Info2, PdfFonts.SmallBold));

                table.DefaultCell.Colspan             = 1;
                table.DefaultCell.HorizontalAlignment = Element.ALIGN_CENTER;
                table.AddCell(GetVendorLink(vendor));
            }

            return(new List <DocumentTable> {
                new DocumentTable("", table)
            });
        }
Exemplo n.º 5
0
        public IEnumerable <DocumentTable> GetTables()
        {
            var table = new PdfPTable(9)
            {
                WidthPercentage = 100
            };

            table.SetWidths(Widths.Split(',').Select(int.Parse).ToArray());
            table.DefaultCell.BackgroundColor = new GrayColor(0.9f);

            var titles = Titles.Split(',');

            table.AddCell(new Phrase(titles[0], PdfFonts.Bold));
            table.AddCell(new Phrase(titles[1], PdfFonts.Bold));
            table.AddCell(new Phrase(titles[2], PdfFonts.Bold));
            table.AddCell(new Phrase(titles[3], PdfFonts.Bold));
            table.AddCell(new Phrase(titles[4], PdfFonts.Bold));
            table.AddCell(new Phrase(titles[5], PdfFonts.Bold));
            table.AddCell(new Phrase(titles[6], PdfFonts.Bold));
            table.AddCell(new Phrase(titles[7], PdfFonts.Bold));
            table.AddCell(new Phrase(titles[8], PdfFonts.Bold));

            table.HeaderRows = 1;

            table.DefaultCell.BackgroundColor = BaseColor.WHITE;

            foreach (var file in Documentation.Project.Files
                     .Where(f => f.Role == FileRole.Spantech && f.IncludeInManual)
                     .Select(f => f.File))
            {
                ExtractDataFromCsv(file.GetPath());
            }

            FilterSpantechData();

            foreach (var row in _parts
                     .OrderBy(p => p.ProjectNumber)
                     .ThenBy(p => p.Drawing)
                     .ThenBy(p => p.PartNumber))
            {
                table.AddCell(new Phrase(row.ProjectNumber, PdfFonts.Normal));
                table.AddCell(new Phrase(row.PartNumber, PdfFonts.Normal));
                table.AddCell(new Phrase(row.PartDesc, PdfFonts.Normal));
                table.AddCell(new Phrase(row.PartDescNo, PdfFonts.Normal));

                var r      = row;
                var manual = new UnitOfWork().FileRepository.Get(m => m.Name == r.Drawing.Replace(".pdf", "")).SingleOrDefault();

                if (manual != null)
                {
                    table.AddCell(new Anchor(new Phrase(row.Drawing, PdfFonts.Link))
                    {
                        Reference = manual.GetPath()
                    });
                }
                else
                {
                    table.AddCell(new Phrase(row.Drawing, PdfFonts.Normal));
                }

                table.AddCell(new Phrase(row.Unit, PdfFonts.Normal));
                table.AddCell(new Phrase(row.TotalAmount.ToString("0.#"), PdfFonts.Normal));
                table.AddCell(new Phrase(row.SpareAmount, PdfFonts.Normal));
                table.AddCell(new Phrase(row.ConveyorWidth, PdfFonts.Normal));
            }

            return(new List <DocumentTable> {
                new DocumentTable("", table)
            });
        }
Exemplo n.º 6
0
        public IEnumerable <DocumentTable> GetTables()
        {
            var table = new PdfPTable(8)
            {
                WidthPercentage = 100
            };

            table.SetWidths(Widths.Split(',').Select(int.Parse).ToArray());

            table.DefaultCell.Padding         = 3.0f;
            table.DefaultCell.BackgroundColor = new GrayColor(0.9f);

            var titles = Titles.Split(',');

            table.AddCell(new Phrase(titles[1], PdfFonts.Bold));
            table.AddCell(new Phrase(titles[0], PdfFonts.Bold));
            table.AddCell(new Phrase(titles[2], PdfFonts.Bold));
            table.AddCell(new Phrase(titles[3], PdfFonts.Bold));
            table.AddCell(new Phrase(titles[4], PdfFonts.Bold));
            table.AddCell(new Phrase(titles[5], PdfFonts.Bold));
            table.AddCell(new Phrase(titles[6], PdfFonts.Bold));
            table.AddCell(new Phrase(Documentation.Project.ProjectNumber, PdfFonts.Bold));

            table.HeaderRows = 1;
            table.DefaultCell.BackgroundColor = BaseColor.WHITE;

            var vendors = new List <Vendor>();

            foreach (var rel in Documentation.Project.Components.Where(rel => rel.Component is Component && rel.IncludeInManual)
                     .OrderBy(rel => rel.Component.Vendor != null ? rel.Component.Vendor.Name : "")
                     .ThenBy(rel => rel.Component.Category != null ? rel.Component.Category.Name : "")
                     .ThenBy(rel => rel.Component.Name))
            {
                table.AddCell(GetVendorLink(rel.Component.Vendor));
                table.AddCell(new Phrase(rel.Component.Category != null ? GetCategoryPath(rel.Component.Category) : "", PdfFonts.Normal));
                table.AddCell(new Phrase(rel.Component.Name, PdfFonts.Normal));
                table.AddCell(new Phrase(rel.Component.Description, PdfFonts.Normal));

                if (rel.Component.Image != null)
                {
                    var fullName = string.Format(@"{0}\{1}", RootDirectory, rel.Component.Image.Path);

                    try
                    {
                        var image = Image.GetInstance(fullName);
                        image.ScaleToFit(Math.Min(100, image.Width), Math.Min(100, image.Height));

                        var cell = new PdfPCell(image)
                        {
                            HorizontalAlignment = Element.ALIGN_CENTER,
                            VerticalAlignment   = Element.ALIGN_MIDDLE,
                            Padding             = 5.0f
                        };

                        table.AddCell(cell);
                    }
                    catch
                    {
                        table.AddCell(new Phrase("BILDET " + fullName + " IKKE FUNNET!"));
                    }
                }
                else
                {
                    table.AddCell("");
                }

                table.AddCell(new Phrase(rel.Count.ToString(CultureInfo.InvariantCulture), PdfFonts.Normal));
                table.AddCell(new Phrase(rel.SpareParts.ToString(CultureInfo.InvariantCulture), PdfFonts.Normal));
                table.AddCell(new Phrase(rel.Info, PdfFonts.Normal));

                if (rel.Component.Vendor != null)
                {
                    vendors.Add(rel.Component.Vendor);
                }
            }

            vendors = vendors.Distinct().OrderBy(v => v.Name).ToList();

            foreach (var vendor in vendors)
            {
                var abbreviation = GetVendorAbbreviation(vendor);

                table.DefaultCell.Colspan             = 7;
                table.DefaultCell.HorizontalAlignment = Element.ALIGN_LEFT;
                table.AddCell(new Phrase(abbreviation + " = " + vendor.Name + "  " + Info, PdfFonts.SmallBold));

                table.DefaultCell.Colspan             = 1;
                table.DefaultCell.HorizontalAlignment = Element.ALIGN_CENTER;
                table.AddCell(GetVendorLink(vendor));
            }

            return(new List <DocumentTable> {
                new DocumentTable("", table)
            });
        }