private IList <Pipe> ImportPipes(Manifest manifest, List <PipeObject> pipes, string tempDir) { IList <Pipe> importedPipes = new List <Pipe>(); const int PROGRESS_RANGE = 30; if (pipes.Count == 0) { progress += PROGRESS_RANGE; FireProgress(progress); return(importedPipes); } int step = PROGRESS_RANGE / pipes.Count; ConflictDecision decision = ConflictDecision.Undefined; bool forAll = false; if (currentStation == WorkstationType.Master && importedStation == WorkstationType.Construction) { decision = ConflictDecision.Replace; forAll = true; } Project currentProject = importRepo.ProjectRepo.GetSingle(); foreach (var pipeObj in pipes) { FireMessage(string.Format(progressMessage, elements--, elementsAll, Program.LanguageManager.GetString(StringResources.PartTypePipe))); Pipe pipe = importRepo.PipeRepo.Get(pipeObj.Id); if (pipe == null) { pipe = new Pipe(); MapSerializableEntityToPipe(tempDir, pipeObj, pipe); pipe.ToExport = currentProject.WorkstationType == WorkstationType.Master && manifest.WorkstationType == WorkstationType.Mill; importRepo.PipeRepo.Save(pipe); importedPipes.Add(pipe); progress += step; FireProgress(progress); } else { if (decision == ConflictDecision.Undefined || !forAll) { ConflictEventArgs args = new ConflictEventArgs(); args.Message = string.Format(Program.LanguageManager.GetString(StringResources.Import_Conflict), pipeObj.Number); FireConflict(args); decision = args.Decision; forAll = args.ForAll; } ConflictFileName f = new ConflictFileName(pipeObj.Id.ToString(), pipeObj.Number); string folderName = f.FolderName; string conflictDir = Path.Combine(Directories.Conflicts, folderName); switch (decision) { case ConflictDecision.Skip: if (Directory.Exists(conflictDir)) { Directory.Delete(conflictDir, true); } break; case ConflictDecision.Replace: Pipe existingPipe = importRepo.PipeRepo.Get(pipeObj.Id); if (afterConflict) { MapSerializableEntityToPipe(conflictDir, pipeObj, existingPipe); } else { MapSerializableEntityToPipe(tempDir, pipeObj, existingPipe); } importRepo.PipeRepo.SaveOrUpdate(existingPipe); importedPipes.Add(existingPipe); if (Directory.Exists(conflictDir)) { Directory.Delete(conflictDir, true); } break; case ConflictDecision.Postpone: Dump(pipeObj, manifest.PortionID, tempDir); break; } NotificationService.Instance.PostponeConflictManager.RefreshNotifications(); progress += step; FireProgress(progress); } } return(importedPipes); }
private void btnSkip_Click(object sender, EventArgs e) { decision = ConflictDecision.Skip; }
private void btnPostpone_Click(object sender, EventArgs e) { decision = ConflictDecision.Postpone; }
public void SetConflictDialog(string msg) { this.decision = ConflictDecision.Undefined; this.chkForAll.Checked = false; lblDesc.Text = msg; }
private void btnReplace_Click(object sender, EventArgs e) { decision = ConflictDecision.Replace; }
private IList <Pipe> ImportPipes(Manifest manifest, List <PipeObject> pipes, string tempDir) { IList <Pipe> importedPipes = new List <Pipe>(); const int PROGRESS_RANGE = 30; if (pipes.Count == 0) { progress += PROGRESS_RANGE; FireProgress(progress); return(importedPipes); } int step = PROGRESS_RANGE / pipes.Count; ConflictDecision decision = ConflictDecision.Undefined; bool forAll = false; foreach (var pipeObj in pipes) { Pipe pipe = importRepo.PipeRepo.Get(pipeObj.Id); if (pipe == null) { pipe = new Pipe(); MapSerializableEntityToPipe(tempDir, pipeObj, pipe); Project currentProject = importRepo.ProjectRepo.GetSingle(); pipe.ToExport = currentProject.WorkstationType == WorkstationType.Master && manifest.WorkstationType == WorkstationType.Mill; importRepo.PipeRepo.Save(pipe); importedPipes.Add(pipe); progress += step; FireProgress(progress); } else { if (decision == ConflictDecision.Undefined || !forAll) { ConflictEventArgs args = new ConflictEventArgs(); args.Message = string.Format(Program.LanguageManager.GetString(StringResources.Import_Conflict), pipeObj.Number); FireConflict(args); decision = args.Decision; forAll = args.ForAll; } switch (decision) { case ConflictDecision.Skip: break; case ConflictDecision.Replace: Pipe existingPipe = importRepo.PipeRepo.Get(pipeObj.Id); MapSerializableEntityToPipe(tempDir, pipeObj, existingPipe); importRepo.PipeRepo.SaveOrUpdate(existingPipe); importedPipes.Add(existingPipe); break; case ConflictDecision.Postpone: Dump(pipeObj, manifest.PortionID, tempDir); CreateNotification(pipeObj); break; } progress += step; FireProgress(progress); } } return(importedPipes); }