|
@@ -11,6 +11,7 @@ using System.Windows.Documents;
|
|
|
using System.Windows.Forms;
|
|
|
using System.Windows.Input;
|
|
|
using System.Windows.Media;
|
|
|
+using com.sun.tools.javac.file;
|
|
|
using Comal.Classes;
|
|
|
using InABox.Clients;
|
|
|
using InABox.Configuration;
|
|
@@ -18,6 +19,7 @@ using InABox.Core;
|
|
|
using InABox.DynamicGrid;
|
|
|
using InABox.WPF;
|
|
|
using net.sf.mpxj.phoenix.schema.phoenix5;
|
|
|
+using Syncfusion.Compression.Zip;
|
|
|
using Syncfusion.Data.Extensions;
|
|
|
using Syncfusion.UI.Xaml.Grid;
|
|
|
using Syncfusion.UI.Xaml.TreeGrid;
|
|
@@ -682,6 +684,11 @@ namespace PRSDesktop
|
|
|
// MileStoneMenu.Items.Add(managefiles);
|
|
|
// }
|
|
|
|
|
|
+ MileStoneMenu.Items.Add(new Separator());
|
|
|
+ MenuItem export = new MenuItem { Header = "Export Files" };
|
|
|
+ export.Click += (o, args) => ExportFiles(milestones);
|
|
|
+ MileStoneMenu.Items.Add(export);
|
|
|
+
|
|
|
MileStoneMenu.Items.Add(new Separator());
|
|
|
MenuItem delete = new MenuItem { Header = "Delete MileStone" };
|
|
|
delete.Click += (o, args) => DeleteMileStone(milestones);
|
|
@@ -693,6 +700,68 @@ namespace PRSDesktop
|
|
|
|
|
|
}
|
|
|
|
|
|
+ private void ExportFiles(CoreRow[] milestones)
|
|
|
+ {
|
|
|
+
|
|
|
+ SaveFileDialog sfd = new SaveFileDialog();
|
|
|
+ sfd.Filter = "Compressed Files (*.zip)|*.zip";
|
|
|
+ sfd.AddExtension = true;
|
|
|
+ if (sfd.ShowDialog() != DialogResult.OK)
|
|
|
+ return;
|
|
|
+ Progress.ShowModal("Exporting Files", (progress) =>
|
|
|
+ {
|
|
|
+
|
|
|
+ progress.Report("Getting File Links");
|
|
|
+ var milestoneids = milestones.Select(r => r.Get<JobDocumentSetMileStone, Guid>(c => c.ID)).ToArray();
|
|
|
+ var links = new Client<JobDocumentSetMileStoneFile>().Query(
|
|
|
+ new Filter<JobDocumentSetMileStoneFile>(c => c.EntityLink.ID).InList(milestoneids),
|
|
|
+ new Columns<JobDocumentSetMileStoneFile>(x => x.EntityLink.ID)
|
|
|
+ .Add(x=>x.EntityLink.DocumentSet.Code)
|
|
|
+ .Add(x=>x.EntityLink.Type.Code)
|
|
|
+ .Add(x=>x.EntityLink.Revision)
|
|
|
+ .Add(x=>x.EntityLink.Status)
|
|
|
+ .Add(x => x.DocumentLink.ID)
|
|
|
+ .Add(x=>x.DocumentLink.FileName)
|
|
|
+ );
|
|
|
+
|
|
|
+
|
|
|
+ Syncfusion.Compression.Zip.ZipArchive zip = new Syncfusion.Compression.Zip.ZipArchive();
|
|
|
+ int i = 0;
|
|
|
+ foreach (var row in links.Rows)
|
|
|
+ {
|
|
|
+ i++;
|
|
|
+ String code = row.Get<JobDocumentSetMileStoneFile, String>(c => c.EntityLink.DocumentSet.Code);
|
|
|
+ String filename = Path.GetFileNameWithoutExtension(row.Get<JobDocumentSetMileStoneFile, String>(c => c.DocumentLink.FileName));
|
|
|
+ String extension = Path.GetExtension(row.Get<JobDocumentSetMileStoneFile, String>(c => c.DocumentLink.FileName));
|
|
|
+ String type = $"{row.Get<JobDocumentSetMileStoneFile,String>(c=>c.EntityLink.Type.Code)} {row.Get<JobDocumentSetMileStoneFile,String>(c=>c.EntityLink.Revision)}".Trim();
|
|
|
+ var status = row.Get<JobDocumentSetMileStoneFile, JobDocumentSetMileStoneStatus>(c => c.EntityLink.Status);
|
|
|
+ filename = $"{code}/{filename} {type} ({status}){extension}";
|
|
|
+
|
|
|
+ progress.Report($"Processing {i} of {links.Rows.Count} files");
|
|
|
+
|
|
|
+ Guid docid = row.Get<JobDocumentSetMileStoneFile, Guid>(c => c.DocumentLink.ID);
|
|
|
+
|
|
|
+ var data = new Client<Document>().Query(
|
|
|
+ new Filter<Document>(x => x.ID).IsEqualTo(docid),
|
|
|
+ new Columns<Document>(x=>x.ID).Add(x => x.Data)
|
|
|
+ ).Rows.Select(r=>r.Get<Document,byte[]>(c=>c.Data)).FirstOrDefault();
|
|
|
+
|
|
|
+ if (data != null)
|
|
|
+ {
|
|
|
+ var item = new ZipArchiveItem(zip, filename, new MemoryStream(data), true, FileAttributes.Normal);
|
|
|
+ zip.AddItem(item);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ progress.Report("Closing archive");
|
|
|
+ zip.Save(sfd.FileName);
|
|
|
+ zip.Close();
|
|
|
+
|
|
|
+ });
|
|
|
+ MessageBox.Show("All Done!");
|
|
|
+ }
|
|
|
+
|
|
|
private void ShowHideDetailsColumn(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
_settings.DetailsVisible = !_settings.DetailsVisible;
|