public ProjectFileHandler(List <PrintItem> projectFiles)
        {
            if (projectFiles != null)
            {
                project = new Project();

                foreach (PrintItem item in projectFiles)
                {
                    if (sourceFiles.ContainsKey(item.FileLocation))
                    {
                        sourceFiles[item.FileLocation].ItemQuantity = sourceFiles[item.FileLocation].ItemQuantity + 1;
                    }
                    else
                    {
                        string fileNameOnly = Path.GetFileName(item.FileLocation);
                        if (addedFileNames.Contains(fileNameOnly))
                        {
                            StyledMessageBox.ShowMessageBox(null, string.Format("Duplicate file name found but in a different folder '{0}'. This part will not be added to the collection.\n\n{1}", fileNameOnly, item.FileLocation), "Duplicate File");
                            continue;
                        }

                        addedFileNames.Add(fileNameOnly);

                        ManifestItem manifestItem = new ManifestItem();
                        manifestItem.ItemQuantity = 1;
                        manifestItem.Name         = item.Name;
                        manifestItem.FileName     = Path.GetFileName(item.FileLocation);

                        sourceFiles.Add(item.FileLocation, manifestItem);
                    }
                }
                List <ManifestItem> manifestFiles = sourceFiles.Values.ToList();
                project.ProjectFiles = manifestFiles;
            }
        }
 private static async void CopyFileToTempFolder(ManifestItem item)
 {
     try
     {
         var streamInterface = item.PrintItem as ILibraryAssetStream;
         using (var streamAndLength = await streamInterface.GetStream(null))
         {
             using (var outputStream = File.OpenWrite(Path.Combine(archiveStagingFolder, item.FileName)))
             {
                 streamAndLength.Stream.CopyTo(outputStream);
             }
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
 }
        public ProjectFileHandler(IEnumerable <ILibraryAssetStream> sourceItems)
        {
            if (sourceItems != null)
            {
                project = new Project();

                foreach (var item in sourceItems)
                {
                    if (sourceFiles.ContainsKey(item.ID))
                    {
                        sourceFiles[item.ID].ItemQuantity += 1;
                    }
                    else
                    {
                        if (addedFileNames.Contains(item.ID))
                        {
                            StyledMessageBox.ShowMessageBox(
                                string.Format("Duplicate file name found but in a different folder '{0}'. This part will not be added to the collection.\n\n{1}", item.Name, item.ID),
                                "Duplicate File");
                            continue;
                        }

                        addedFileNames.Add(item.ID);

                        var manifestItem = new ManifestItem()
                        {
                            ItemQuantity = 1,
                            Name         = item.Name,
                            FileName     = item.Name,
                            PrintItem    = item
                        };
                        sourceFiles.Add(item.ID, manifestItem);
                    }
                }

                project.ProjectFiles = sourceFiles.Values.ToList();
            }
        }
		public ProjectFileHandler(List<PrintItem> projectFiles)
		{
			if (projectFiles != null)
			{
				project = new Project();

				foreach (PrintItem item in projectFiles)
				{
					if (sourceFiles.ContainsKey(item.FileLocation))
					{
						sourceFiles[item.FileLocation].ItemQuantity = sourceFiles[item.FileLocation].ItemQuantity + 1;
					}
					else
					{
						string fileNameOnly = Path.GetFileName(item.FileLocation);
						if (addedFileNames.Contains(fileNameOnly))
						{
							StyledMessageBox.ShowMessageBox(null, string.Format("Duplicate file name found but in a different folder '{0}'. This part will not be added to the collection.\n\n{1}", fileNameOnly, item.FileLocation), "Duplicate File");
							continue;
						}

						addedFileNames.Add(fileNameOnly);

						ManifestItem manifestItem = new ManifestItem();
						manifestItem.ItemQuantity = 1;
						manifestItem.Name = item.Name;
						manifestItem.FileName = Path.GetFileName(item.FileLocation);

						sourceFiles.Add(item.FileLocation, manifestItem);
					}
				}
				List<ManifestItem> manifestFiles = sourceFiles.Values.ToList();
				project.ProjectFiles = manifestFiles;
			}
		}