예제 #1
0
 protected void FireConflict(ConflictEventArgs args)
 {
     if (OnConflict != null)
     {
         OnConflict(args);
     }
 }
예제 #2
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);
        }
예제 #3
0
 protected void FireConflict(ConflictEventArgs args)
 {
    if (OnConflict != null)
       OnConflict(args);
 }
예제 #4
0
      private void ConflictDialogCreation(ConflictEventArgs args)
      {
          if (singleConflictDialog == null)
          {
              singleConflictDialog = new ConflictDialog(args.Message);
          }
          else
          {
              singleConflictDialog.SetConflictDialog(args.Message);
          }

          singleConflictDialog.ShowDialog();
          args.Decision = singleConflictDialog.Decision;
          args.ForAll = singleConflictDialog.ForAll;
      }
예제 #5
0
 void importer_OnConflict(ConflictEventArgs args)
 {
     if (this.InvokeRequired)
     {
         this.Invoke(new Action(() => { ConflictDialogCreation(args); }));
     }
     else
     {
         ConflictDialogCreation(args);
     }
 }
예제 #6
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);
        }