|
@@ -19,11 +19,17 @@ using InABox.Core;
|
|
|
using InABox.DynamicGrid;
|
|
|
using InABox.WPF;
|
|
|
using net.sf.mpxj.phoenix.schema.phoenix5;
|
|
|
+using org.omg.CORBA;
|
|
|
using Syncfusion.Compression.Zip;
|
|
|
using Syncfusion.Data.Extensions;
|
|
|
using Syncfusion.UI.Xaml.Grid;
|
|
|
using Syncfusion.UI.Xaml.TreeGrid;
|
|
|
using Syncfusion.UI.Xaml.TreeGrid.Helpers;
|
|
|
+using Syncfusion.Windows.Controls.Grid;
|
|
|
+using Syncfusion.XlsIO;
|
|
|
+using Color = System.Drawing.Color;
|
|
|
+using Environment = System.Environment;
|
|
|
+using GridSelectionChangedEventArgs = Syncfusion.UI.Xaml.Grid.GridSelectionChangedEventArgs;
|
|
|
using JobDocumentSetFolder = Comal.Classes.JobDocumentSetFolder;
|
|
|
using MessageBox = System.Windows.MessageBox;
|
|
|
using UserControl = System.Windows.Controls.UserControl;
|
|
@@ -1665,5 +1671,125 @@ namespace PRSDesktop
|
|
|
if (set != null)
|
|
|
EditDocumentSets(new Guid[] { set.ID });
|
|
|
}
|
|
|
+
|
|
|
+ private void Export_OnClick(object sender, RoutedEventArgs e)
|
|
|
+ {
|
|
|
+ var engine = new ExcelEngine();
|
|
|
+ var application = engine.Excel;
|
|
|
+ var workbook = application.Workbooks.Create(1);
|
|
|
+ workbook.Version = ExcelVersion.Excel2007;
|
|
|
+
|
|
|
+ var sheet = workbook.Worksheets[0];
|
|
|
+ sheet.Name = "Document Register";
|
|
|
+
|
|
|
+ int iRow = 1;
|
|
|
+ int iCol = 1;
|
|
|
+
|
|
|
+ SetHeader(sheet, iRow, iCol++, "Document Number", 40, false, false);
|
|
|
+ SetHeader(sheet, iRow, iCol++, "Description", 80, false, false);
|
|
|
+
|
|
|
+ SetHeader(sheet, iRow, iCol++, "Discipline", 15, true, false);
|
|
|
+ SetHeader(sheet, iRow, iCol++, "Type", 15, true, false);
|
|
|
+ SetHeader(sheet, iRow, iCol++, "Category", 15, true, false);
|
|
|
+ SetHeader(sheet, iRow, iCol++, "ITP Area", 15, true, false);
|
|
|
+
|
|
|
+ Dictionary<String, int> blkmap = new Dictionary<string, int>();
|
|
|
+
|
|
|
+ foreach (var key in _types.Keys)
|
|
|
+ {
|
|
|
+ var _type = _types[key];
|
|
|
+ SetHeader(sheet, iRow, iCol, _type.Code, 5, true, true);
|
|
|
+ sheet.Range[iRow, iCol].Text = _type.Code;
|
|
|
+ int iCount = _types[key].Columns.Count;
|
|
|
+ if (iCount > 1)
|
|
|
+ sheet.Range[iRow, iCol, iRow, iCol + iCount - 1].Merge();
|
|
|
+ foreach (var col in _type.Columns)
|
|
|
+ {
|
|
|
+ sheet.SetColumnWidth(iCol,5);
|
|
|
+ blkmap[col] = iCol++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ iRow++;
|
|
|
+ foreach (var node in _documentsets.Nodes)
|
|
|
+ {
|
|
|
+ var desc = Serialization.Deserialize<JobDocumentSetDescriptionBlock>(node.Description);
|
|
|
+ CoreRow row = Data.Rows.FirstOrDefault(r => r.Get<JobDocumentSet, Guid>(c => c.ID) == desc.ID);
|
|
|
+ if (row != null)
|
|
|
+ {
|
|
|
+ iCol = 1;
|
|
|
+ SetContent(sheet, iRow, iCol++, desc.Code, false, false, System.Drawing.Color.Transparent);
|
|
|
+ SetContent(sheet, iRow, iCol++, desc.Description, false, true, System.Drawing.Color.Transparent);
|
|
|
+
|
|
|
+ SetContent(sheet, iRow, iCol++, row.Get<JobDocumentSet, String>(c => c.Discipline.Description), true, false, System.Drawing.Color.Transparent);
|
|
|
+ SetContent(sheet, iRow, iCol++, row.Get<JobDocumentSet, String>(c => c.Type.Description), true, false, System.Drawing.Color.Transparent);
|
|
|
+ SetContent(sheet, iRow, iCol++, row.Get<JobDocumentSet, String>(c => c.Category.Description), true, false, System.Drawing.Color.Transparent);
|
|
|
+ SetContent(sheet, iRow, iCol++, row.Get<JobDocumentSet, String>(c => c.Area.Description), true, false, System.Drawing.Color.Transparent);
|
|
|
+
|
|
|
+ foreach (var key in node.Blocks.Keys)
|
|
|
+ {
|
|
|
+ if (!String.IsNullOrWhiteSpace(node.Blocks[key]))
|
|
|
+ {
|
|
|
+ var block = Serialization.Deserialize<JobDocumentSetMileStoneBlock>(node.Blocks[key]);
|
|
|
+ iCol = blkmap[$"Blocks[{key}]"];
|
|
|
+ var color = JobDocumentSetMileStoneConverter.StatusColors[block.Status];
|
|
|
+ var status = String.IsNullOrWhiteSpace(block.Revision) ? "--" : block.Revision;
|
|
|
+ SetContent(sheet, iRow, iCol, status, true, false, color);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ iRow++;
|
|
|
+ }
|
|
|
+
|
|
|
+ sheet.UsedRange.BorderAround();
|
|
|
+ sheet.UsedRange.BorderInside();
|
|
|
+ sheet.UsedRange.AutofitRows();
|
|
|
+ foreach (var row in sheet.UsedRange.Rows)
|
|
|
+ {
|
|
|
+ row.RowHeight += 5;
|
|
|
+ row.VerticalAlignment = ExcelVAlign.VAlignCenter;
|
|
|
+ }
|
|
|
+
|
|
|
+ var dlg = new SaveFileDialog();
|
|
|
+ dlg.Filter = "Excel Files (*.xlsx)|*.xlsx";
|
|
|
+ dlg.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
|
|
|
+ dlg.FileName = string.Format("Document Register {0:yyyy-MM-dd hh-mm-ss}.xlsx", DateTime.Now);
|
|
|
+ if (dlg.ShowDialog() == DialogResult.OK)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ workbook.SaveAs(dlg.FileName, ExcelSaveType.SaveAsXLS);
|
|
|
+ Process.Start(new ProcessStartInfo(dlg.FileName) { UseShellExecute = true });
|
|
|
+ }
|
|
|
+ catch (Exception e2)
|
|
|
+ {
|
|
|
+ MessageBox.Show("Error saving spreadsheet!\n\n" + e2.Message);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void SetContent(IWorksheet sheet, int row, int col, string text, bool center, bool wrap, Color? color)
|
|
|
+ {
|
|
|
+ var range = sheet.Range[row, col];
|
|
|
+ range.Text = text;
|
|
|
+ range.WrapText = wrap;
|
|
|
+ if (center)
|
|
|
+ range.CellStyle.HorizontalAlignment = ExcelHAlign.HAlignCenter;
|
|
|
+ if (color != null)
|
|
|
+ range.CellStyle.Color = color.Value;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void SetHeader(IWorksheet sheet, int row, int col, string text, double width, bool center, bool rotate)
|
|
|
+ {
|
|
|
+ var range = sheet.Range[row, col];
|
|
|
+ range.Text = text;
|
|
|
+ range.CellStyle.Color = System.Drawing.Color.Silver;
|
|
|
+ sheet.SetColumnWidth(col,width);
|
|
|
+ if (center)
|
|
|
+ range.CellStyle.HorizontalAlignment = ExcelHAlign.HAlignCenter;
|
|
|
+ if (rotate)
|
|
|
+ range.CellStyle.Rotation = 90;
|
|
|
+ }
|
|
|
}
|
|
|
}
|