void MapSerializableEntityToSpool(string tempDir, SpoolObject spoolObj, Spool spool) { spool.Id = spoolObj.Id; spool.IsActive = spoolObj.IsActive; spool.PipeNumber = spoolObj.PipeNumber; spool.Number = spoolObj.Number; spool.Length = spoolObj.Length; spool.IsAvailableToJoint = spoolObj.IsAvailableToJoint; spool.ConstructionStatus = spoolObj.ConstructionStatus; spool.InspectionStatus = spoolObj.InspectionStatus; if (spoolObj.Attachments != null) { if (!Directory.Exists(Directories.TargetPath)) { Directory.CreateDirectory(Directories.TargetPath); DirectoryInfo directoryInfo = new DirectoryInfo(Directories.TargetPath); directoryInfo.Attributes |= FileAttributes.Hidden; } spool.Attachments = new List <Prizm.Domain.Entity.File>(); foreach (var fileObject in spoolObj.Attachments) { Prizm.Domain.Entity.File f = ImportFile(fileObject, spool.Id); CopyAttachment(tempDir, f); } } }
private void addFile_Click(object sender, EventArgs e) { Guid newNameId = Guid.NewGuid(); OpenFileDialog openFileDlg = new OpenFileDialog(); // TODO Save new files position to user settings. openFileDlg.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); if (openFileDlg.ShowDialog() == DialogResult.OK) { FileInfo fileInfo = new FileInfo(openFileDlg.FileName); if (fileInfo.Length / 1024 < viewModel.SizeLimit) { if (!Directory.Exists(Directories.FilesToAttachFolder)) { Directory.CreateDirectory(Directories.FilesToAttachFolder); DirectoryInfo directoryInfo = new DirectoryInfo(Directories.FilesToAttachFolder); DirectoryInfo directoryInfoParent = new DirectoryInfo(Directories.TargetPath); directoryInfo.Attributes |= FileAttributes.Hidden; directoryInfoParent.Attributes |= FileAttributes.Hidden; } string filesToAttachPath = string.Format("{0}{1}{2}", Directories.FilesToAttachFolder, newNameId, fileInfo.Extension); fileInfo.CopyTo(filesToAttachPath); viewModel.FilesToAttach.Add(newNameId.ToString() + fileInfo.Extension, fileInfo.Name); Prizm.Domain.Entity.File newFile = new Prizm.Domain.Entity.File() { FileName = fileInfo.Name, UploadDate = DateTime.Now }; newFile.NewName = filesToAttachPath; viewModel.Files.Add(newFile); } else { XtraMessageBox.Show(Program.LanguageManager.GetString(StringResources.ExternalFiles_FileSizeIsTooBig), Program.LanguageManager.GetString(StringResources.Message_ErrorHeader)); } } }
private void addFile_Click(object sender, EventArgs e) { Guid newNameId = Guid.NewGuid(); OpenFileDialog openFileDlg = new OpenFileDialog(); // TODO Save new files position to user settings. openFileDlg.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); if (openFileDlg.ShowDialog() == DialogResult.OK) { FileInfo fileInfo = new FileInfo(openFileDlg.FileName); if (fileInfo.Length / 1024 < viewModel.SizeLimit) { if (!Directory.Exists(Directories.FilesToAttachFolder)) { Directory.CreateDirectory(Directories.FilesToAttachFolder); DirectoryInfo directoryInfo = new DirectoryInfo(Directories.FilesToAttachFolder); DirectoryInfo directoryInfoParent = new DirectoryInfo(Directories.TargetPath); directoryInfo.Attributes |= FileAttributes.Hidden; directoryInfoParent.Attributes |= FileAttributes.Hidden; } fileInfo.CopyTo(string.Format("{0}{1}{2}", Directories.FilesToAttachFolder, newNameId, fileInfo.Extension)); viewModel.FilesToAttach.Add(newNameId.ToString() + fileInfo.Extension, fileInfo.Name); Prizm.Domain.Entity.File newFile = new Prizm.Domain.Entity.File() { FileName = fileInfo.Name, UploadDate = DateTime.Now }; viewModel.Files.Add(newFile); } else { XtraMessageBox.Show(Program.LanguageManager.GetString(StringResources.ExternalFiles_FileSizeIsTooBig), Program.LanguageManager.GetString(StringResources.Message_ErrorHeader)); } } }
private void viewButton_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e) { Prizm.Domain.Entity.File selectedFile = filesView.GetRow(filesView.FocusedRowHandle) as Prizm.Domain.Entity.File; if (selectedFile != null) { viewModel.SelectedFile = selectedFile; viewModel.ViewFileCommand.Execute(); } }
public FileObject(File file) { this.Id = file.Id; this.IsActive = file.IsActive; this.FileName = file.FileName; this.Description = file.Description; this.UploadDate = file.UploadDate; this.NewName = file.NewName; }
private ReleaseNote ImportReleaseNote(string tempDir, ReleaseNoteObject releaseNoteObj) { if (releaseNoteObj == null) { return(null); } bool isNew = false; ReleaseNote releaseNote = importRepo.ReleaseNoteRepo.Get(releaseNoteObj.Id); if (releaseNote == null) { releaseNote = new ReleaseNote(); isNew = true; } releaseNote.Id = releaseNoteObj.Id; releaseNote.IsActive = releaseNoteObj.IsActive; releaseNote.Number = releaseNoteObj.Number; releaseNote.Shipped = releaseNoteObj.Shipped; releaseNote.Date = releaseNoteObj.Date; if (releaseNoteObj.Attachments != null) { if (!Directory.Exists(Directories.TargetPath)) { Directory.CreateDirectory(Directories.TargetPath); DirectoryInfo directoryInfo = new DirectoryInfo(Directories.TargetPath); directoryInfo.Attributes |= FileAttributes.Hidden; } releaseNote.Attachments = new List <Prizm.Domain.Entity.File>(); foreach (var fileObject in releaseNoteObj.Attachments) { Prizm.Domain.Entity.File f = ImportFile(fileObject, releaseNote.Id); CopyAttachment(tempDir, f); } } if (isNew) { importRepo.ReleaseNoteRepo.Save(releaseNote); } else { importRepo.ReleaseNoteRepo.SaveOrUpdate(releaseNote); } return(releaseNote); }
public void MapSerializableEntityToPipe(string tempDir, PipeObject pipeObj, Pipe pipe) { pipe.Id = pipeObj.Id; pipe.IsActive = pipeObj.IsActive; pipe.Number = pipeObj.Number; pipe.Length = pipeObj.Length; pipe.IsAvailableToJoint = pipeObj.IsAvailableToJoint; pipe.ConstructionStatus = pipeObj.ConstructionStatus; pipe.InspectionStatus = pipeObj.InspectionStatus; pipe.Plate = ImportPlate(pipeObj.Plate); pipe.Mill = pipeObj.Mill; pipe.Diameter = pipeObj.Diameter; pipe.WallThickness = pipeObj.WallThickness; pipe.Weight = pipeObj.Weight; pipe.ProductionDate = pipeObj.ProductionDate; pipe.Type = ImportSizeType(pipeObj.Type); pipe.Railcar = ImportRailcar(pipeObj.Railcar); if (pipeObj.Railcar != null) { pipe.Railcar.ReleaseNote = ImportReleaseNote(tempDir, pipeObj.Railcar.ReleaseNote); } pipe.PurchaseOrder = ImportPurchaseOrder(pipeObj.PurchaseOrder); pipe.Status = pipeObj.Status; if (pipeObj.Spools != null) { foreach (SpoolObject so in pipeObj.Spools) { pipe.Spools.Add(ImportSpool(tempDir, so, pipe)); } } if (pipeObj.Attachments != null) { if (!Directory.Exists(Directories.TargetPath)) { Directory.CreateDirectory(Directories.TargetPath); DirectoryInfo directoryInfo = new DirectoryInfo(Directories.TargetPath); directoryInfo.Attributes |= FileAttributes.Hidden; } pipe.Attachments = new List <Prizm.Domain.Entity.File>(); foreach (var fileObject in pipeObj.Attachments) { Prizm.Domain.Entity.File f = ImportFile(fileObject, pipe.Id); CopyAttachment(tempDir, f, afterConflict); } } }
private void downloadButton_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e) { Prizm.Domain.Entity.File selectedFile = filesView.GetRow(filesView.FocusedRowHandle) as Prizm.Domain.Entity.File; if (selectedFile != null) { viewModel.SelectedFile = selectedFile; SaveFileDialog saveFileDlg = new SaveFileDialog(); saveFileDlg.FileName = selectedFile.FileName; // TODO Save new files position to user settings. saveFileDlg.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); if (saveFileDlg.ShowDialog() == DialogResult.OK) { viewModel.SelectedPath = saveFileDlg.FileName; viewModel.DownloadFileCommand.Execute(); } } }
private IList <Joint> ImportJoints(Manifest manifest, Data data, string tempDir) { IList <Joint> importedJoints = new List <Joint>(); List <JointObject> joints = data.Joints; if (joints == null) { return(importedJoints); } const int PROGRESS_RANGE = 30; if (joints.Count == 0) { progress += PROGRESS_RANGE; FireProgress(progress); return(importedJoints); } int step = PROGRESS_RANGE / joints.Count; foreach (var jointObj in joints) { FireMessage(string.Format(progressMessage, elements--, elementsAll, Program.LanguageManager.GetString(StringResources.JointNewXtraForm_Title))); Joint joint = importRepo.JointRepo.Get(jointObj.Id); bool isNew = false; if (joint == null) { isNew = true; joint = new Joint(); } joint.Id = jointObj.Id; joint.IsActive = jointObj.IsActive; joint.Number = jointObj.Number; joint.NumberKP = jointObj.NumberKP; joint.DistanceFromKP = jointObj.DistanceFromKP; if (jointObj.LoweringDate != DateTime.MinValue) { joint.LoweringDate = jointObj.LoweringDate; } joint.Status = jointObj.Status; joint.GpsLatitude = jointObj.GpsLatitude; joint.GpsLongitude = jointObj.GpsLongitude; joint.GpsHeight = jointObj.GpsHeight; joint.FirstElement = ImportPartData(jointObj.FirstElement, data, tempDir, joint); joint.SecondElement = ImportPartData(jointObj.SecondElement, data, tempDir, joint); if (jointObj.Attachments != null) { if (!Directory.Exists(Directories.TargetPath)) { Directory.CreateDirectory(Directories.TargetPath); DirectoryInfo directoryInfo = new DirectoryInfo(Directories.TargetPath); directoryInfo.Attributes |= FileAttributes.Hidden; } joint.Attachments = new List <Prizm.Domain.Entity.File>(); foreach (var fileObject in jointObj.Attachments) { Prizm.Domain.Entity.File f = ImportFile(fileObject, joint.Id); CopyAttachment(tempDir, f); } } if (isNew) { importRepo.JointRepo.Save(joint); } else { importRepo.JointRepo.SaveOrUpdate(joint); } importedJoints.Add(joint); progress += step; FireProgress(progress); } return(importedJoints); }