예제 #1
0
        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);
        }
예제 #2
0
 private void btnSkip_Click(object sender, EventArgs e)
 {
     decision = ConflictDecision.Skip;
 }
예제 #3
0
 private void btnPostpone_Click(object sender, EventArgs e)
 {
     decision = ConflictDecision.Postpone;
 }
예제 #4
0
 public void  SetConflictDialog(string msg)
 {
     this.decision          = ConflictDecision.Undefined;
     this.chkForAll.Checked = false;
     lblDesc.Text           = msg;
 }
예제 #5
0
 private void btnReplace_Click(object sender, EventArgs e)
 {
     decision = ConflictDecision.Replace;
 }
예제 #6
0
 private void btnPostpone_Click(object sender, EventArgs e)
 {
    decision = ConflictDecision.Postpone;
 }
예제 #7
0
 private void btnSkip_Click(object sender, EventArgs e)
 {
    decision = ConflictDecision.Skip;
 }
예제 #8
0
 private void btnReplace_Click(object sender, EventArgs e)
 {
    decision = ConflictDecision.Replace;
 }
예제 #9
0
 public void  SetConflictDialog(string msg)
 {
     this.decision = ConflictDecision.Undefined;
     this.chkForAll.Checked = false;
     lblDesc.Text = msg;
 }
예제 #10
0
파일: DataImporter.cs 프로젝트: horba/prizm
        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);
        }