Inheritance: Part
        public void TestSaveInspectionTestResults()
        {
            var session = new Mock<ISession>();
            var notify = new Mock<IUserNotify>();
            var repoInspector = new Mock<IInspectorRepository>();
            var repoPipe = new Mock<IPipeRepository>();
            var repoSpool =  new Mock<ISpoolRepository>();
            var repoComponent = new Mock<IComponentRepository>();
            var repoInspectionTestResult = new Mock<IInspectionTestResultRepository>();
            var modifiableView = new Mock<IModifiable>();
            var ctx = new Mock<ISecurityContext>();

            Mock<IPartInspectionRepository> repos = new Mock<IPartInspectionRepository>();
            repos.SetupGet(_ => _.RepoComponent).Returns(repoComponent.Object);
            repos.SetupGet(_ => _.RepoInspectionTestResult).Returns(repoInspectionTestResult.Object);
            repos.SetupGet(_ => _.RepoInspector).Returns(repoInspector.Object);
            repos.SetupGet(_ => _.RepoPipe).Returns(repoPipe.Object);
            repos.SetupGet(_ => _.RepoSpool).Returns(repoSpool.Object);

            List<InspectionTestResult> list = new List<InspectionTestResult>() { new InspectionTestResult(){ Inspectors = new List<Inspector>() { new Inspector() } } };
            var viewModel = new PartInspectionViewModel(session.Object, repos.Object, notify.Object, ctx.Object);
            viewModel.ModifiableView = modifiableView.Object;
            Pipe part = new Pipe() { InspectionTestResults = list};
            repos.Setup(_ => _.RepoPipe.Get(It.IsAny<Guid>())).Returns(part);

            Main.Forms.Parts.Search.Part notConverted = new Main.Forms.Parts.Search.Part()
            {
                Id = part.Id,
                Type = new EnumWrapper<PartType>(PartType.Pipe)
            };
            repoInspectionTestResult.Setup(_ => _.GetByPartId(notConverted.Id)).Returns(list);
            viewModel.SelectedElement = notConverted;
            var command = new SaveInspectionTestResultsCommand(repoInspectionTestResult.Object, viewModel, notify.Object, ctx.Object);
           
            command.Execute();

            repoInspectionTestResult.Verify(_ => _.BeginTransaction(), Times.Once());
            repoInspectionTestResult.Verify(_ => _.SaveOrUpdate(It.IsAny<InspectionTestResult>()), Times.AtLeastOnce());

        }
Beispiel #2
0
      public PipeObject(Pipe pipe)
      {
         this.Id = pipe.Id;
         this.IsActive = pipe.IsActive;
         this.Number = pipe.Number;
         this.Length = pipe.Length;
         this.IsAvailableToJoint = pipe.IsAvailableToJoint;
         this.ConstructionStatus = pipe.ConstructionStatus;
         this.InspectionStatus = pipe.InspectionStatus;
         this.Plate = pipe.Plate;
         this.Mill = pipe.Mill;
         this.Diameter = pipe.Diameter;
         this.WallThickness = pipe.WallThickness;
         this.Weight = pipe.Weight;
         this.ProductionDate = pipe.ProductionDate;
         this.Type = pipe.Type;
         this.Railcar = pipe.Railcar;
         this.PurchaseOrder = pipe.PurchaseOrder;
         this.Status = pipe.Status;

         if (pipe.Spools != null)
         {
            this.Spools = new List<SpoolObject>();
            foreach (var spool in pipe.Spools)
            {
               this.Spools.Add(new SpoolObject(spool));
            }
         }

         if (pipe.Attachments != null)
         {
            this.Attachments = new List<FileObject>();
            foreach (var attach in pipe.Attachments)
            {
               this.Attachments.Add(new FileObject(attach));
            }
         }
      }
Beispiel #3
0
 public void NewSpool()
 {
     Spool = new Prizm.Domain.Entity.Construction.Spool();
     Spool.Number = string.Empty;
     Spool.InspectionTestResults = new BindingList<InspectionTestResult>();
     Spool.Pipe = new Pipe();
     Spool.ConstructionStatus = PartConstructionStatus.Pending;
     Spool.InspectionStatus = PartInspectionStatus.Pending;
     Spool.IsAvailableToJoint = true;
     Pipe = new Pipe();
     if(this.FilesFormViewModel != null)
     {
         this.FilesFormViewModel.Files = null;
     }
 }
 public IPipeNotifier CreateNotifier(Pipe pipeInitialState)
 {
     return PipeNotificationInfo.Create(this, pipeInitialState);
 }
 private void ProcessNROForPipeSizeType(Guid sizeTypeId, Pipe pipe, NROWhatToDo what)
 {
     foreach (Guid id in manager.cache.EnumerateOperationsForSizeType(sizeTypeId))
     {
         if (what != NROWhatToDo.Add)
         {
             manager.cache.RemoveUnits(id, ChooseUnit(manager.cache.GetMeasure(id)));
         }
         if (what != NROWhatToDo.Remove)
         {
             manager.cache.AddUnits(id, ChooseUnit(manager.cache.GetMeasure(id), pipe));
         }
         
         UpdateNotification(id);
     }
 }
 private decimal ChooseUnit(FrequencyMeasure measure, Pipe pipe = null)
 {
     decimal ret = 0;
     switch (measure)
     {
         case FrequencyMeasure.Meters:
             ret =pipe == null ? initialPipeLength : pipe.Length;
             break;
         case FrequencyMeasure.Tons:
             ret = pipe == null ? initialPipeWeight : pipe.Weight;
             break;
         case FrequencyMeasure.Pipes:
             ret = 1;
             break;
         default:
             log.Error("Notifications: unrecognized type of unit at ChooseUnit: " + measure);
             break;
     }
     return ret;
 }
 private void SavePipeState(Pipe pipeState)
 {
     if (pipeState.Type != null)
     {
         this.initialPipeSizeTypeId = pipeState.Type.Id;
         this.initialPipeLength = pipeState.Length;
         this.initialPipeWeight = pipeState.Weight;
         this.initialPipeTestResult.AddRange(pipeState.PipeTestResult);
     }
     if (pipeState.PipeTestResult != null)
     {
         this.initialNROList.AddRange(GetNROInfoListFromPipeTestResultList(pipeState.PipeTestResult));
         this.initialTestResultList.AddRange(GetInitialTestResult((pipeState.PipeTestResult)));
     }
 }
 public static PipeNotificationInfo Create(NotRequiredOperationManager manager, Pipe pipeInitialState)
 {
     PipeNotificationInfo info = new PipeNotificationInfo(manager);
     info.SavePipeState(pipeInitialState);
     return info;
 }
 private void SavePipeState(Pipe pipeState)
 {
     if (pipeState.Type != null)
     {
         this.initialPipeSizeTypeId = pipeState.Type.Id;
         initialSelectiveInfo.AddRange(GetTestResultInfoListFromPipeTestResultList(pipeState.PipeTestResult));
     }
 }
        public void TestMillPipeNewEdit()
        {
            var modifiableView = new Mock<IModifiable>();

            var repoPipe = new Mock<IPipeRepository>();
            var notify = new Mock<IUserNotify>();
            var repoPlate = new Mock<IPlateRepository>();
            var repoHeat = new Mock<IHeatRepository>();
            var repoWeld = new Mock<IWeldRepository>();
            var repoPipeType = new Mock<IMillPipeSizeTypeRepository>();
            var repoPurchaseOrder = new Mock<IPurchaseOrderRepository>();
            var repoWelder = new Mock<IWelderRepository>();
            var repoPipeTestResult = new Mock<IPipeTestResultRepository>();
            var repoPipeTest = new Mock<IPipeTestRepository>();
            var repoInspector = new Mock<IInspectorRepository>();
            var repoProject = new Mock<IProjectRepository>();
            var ctx = new Mock<ISecurityContext>();
            var pipe = new Pipe();

            repoPipe.Setup(x => x.GetActiveByNumber(pipe)).Returns(new List<Pipe>());
            repoProject.Setup(x => x.GetSingle()).Returns(new Project() { IsNative = true});
            repoPipeTest.Setup(x => x.GetByCriteria(It.IsAny<NHibernate.Criterion.DetachedCriteria>())).Returns(new List<PipeTest>());

            Mock<IMillRepository> millRepos = new Mock<IMillRepository>();
            millRepos.SetupGet(_ => _.RepoPipe).Returns(repoPipe.Object);
            millRepos.SetupGet(_ => _.RepoPlate).Returns(repoPlate.Object);
            millRepos.SetupGet(_ => _.RepoHeat).Returns(repoHeat.Object);
            millRepos.SetupGet(_ => _.RepoWeld).Returns(repoWeld.Object);
            millRepos.SetupGet(_ => _.RepoPipeType).Returns(repoPipeType.Object);
            millRepos.SetupGet(_ => _.RepoPurchaseOrder).Returns(repoPurchaseOrder.Object);
            millRepos.SetupGet(_ => _.WelderRepo).Returns(repoWelder.Object);
            millRepos.SetupGet(_ => _.RepoPipeTestResult).Returns(repoPipeTestResult.Object);
            millRepos.SetupGet(_ => _.RepoPipeTest).Returns(repoPipeTest.Object);
            millRepos.SetupGet(_ => _.RepoInspector).Returns(repoInspector.Object);
            millRepos.SetupGet(_ => _.RepoProject).Returns(repoProject.Object);

            modifiableView.SetupGet(x => x.IsModified).Returns(false);



            var viewModel = new MillPipeNewEditViewModel(
                millRepos.Object,
                Guid.Empty, 
                notify.Object,
                ctx.Object);
            var validatable = new Mock<IValidatable>();
            validatable.Setup(x => x.Validate()).Returns(true);
            viewModel.ValidatableView = validatable.Object;
            viewModel.Pipe = pipe;
            viewModel.ModifiableView = modifiableView.Object;

            var command = new NewSavePipeCommand(
                viewModel, 
                millRepos.Object, 
                notify.Object,
                ctx.Object);

            command.Execute();

            millRepos.Verify(_ => _.BeginTransaction(), Times.Once());
            repoPipe.Verify(_ => _.SaveOrUpdate(It.IsAny<Pipe>()), Times.Once());
            millRepos.Verify(_ => _.Commit(), Times.Once());
            repoPipe.Verify(_ => _.Evict(It.IsAny<Pipe>()), Times.Once());
        }
        private bool SeedOptional()
        {
            //Required seed hasn't been performed for Master worksration type, but data are used in optional seed
            if (viewModel.Project.WorkstationType == WorkstationType.Master)
            {
                SeedRequired();
            }

            firstSetupRepo.BeginTransaction();
            #region PlateManufacturers
            PlateManufacturer[] plateManufacturers = 
            {
                new PlateManufacturer {Name = "Алапаевский металлургический завод", IsActive = true, IsNative = true, Project = viewModel.Project},
                new PlateManufacturer {Name = "Альметьевский трубный завод", IsActive = true, IsNative = true, Project = viewModel.Project},
                new PlateManufacturer {Name = "Борский трубный завод", IsActive = true, IsNative = true, Project = viewModel.Project},
                new PlateManufacturer {Name = "Волжский трубный завод", IsActive = true, IsNative = true, Project = viewModel.Project},
                new PlateManufacturer {Name = "Волгоградский трубный завод", IsActive = true, IsNative = true, Project = viewModel.Project},
                new PlateManufacturer {Name = "Гурьевский металлургический завод", IsActive = true, IsNative = true, Project = viewModel.Project},
                new PlateManufacturer {Name = "Завод Точлит", IsActive = true}
            };
            Array.ForEach(plateManufacturers, s => firstSetupRepo.PlateManRepo.Save(s));
            #endregion
            firstSetupRepo.Commit();
            firstSetupRepo.BeginTransaction();
            #region Heat
            List<Heat> heats = new List<Heat>();
            for(int i = 0; i < HEATCOUNT; i++)
            {
                heats.Add
                    (
                    new Heat ()
                    {
                        Number = RndString(8),
                        SteelGrade = RndString(6),
                        PlateManufacturer = plateManufacturers[rnd.Next(plateManufacturers.Length - 1)],
                        IsActive = true                      
                    }
                    );
                firstSetupRepo.HeatRepo.Save(heats[i]);
            }

            #endregion
            firstSetupRepo.Commit();
            firstSetupRepo.BeginTransaction();
            #region PurchaseOrder
            List<PurchaseOrder> orders = new List<PurchaseOrder>
            {
                new PurchaseOrder {Number = RndString(5),Date = DateTime.Now.AddMonths(-rnd.Next(10)),IsActive=true},
                new PurchaseOrder {Number = RndString(5),Date = DateTime.Now.AddMonths(-rnd.Next(10)),IsActive=true},
                new PurchaseOrder {Number = RndString(5),Date = DateTime.Now.AddMonths(-rnd.Next(10)),IsActive=true},
                new PurchaseOrder {Number = RndString(5),Date = DateTime.Now.AddMonths(-rnd.Next(10)),IsActive=true},
                new PurchaseOrder {Number = RndString(5),Date = DateTime.Now.AddMonths(-rnd.Next(10)),IsActive=true}
            };
            orders.ForEach(s => firstSetupRepo.PurchaseRepo.Save(s));
            #endregion
            firstSetupRepo.Commit();
            firstSetupRepo.BeginTransaction();
            #region MillPipe
            List<Pipe> pipes = new List<Pipe>();
            for(int i = 0; i < PIPECOUNT; i++)
            {
                var plate = new Plate
                    {
                        Number = RndString(8),
                        Thickness = rnd.Next(2000),
                        Heat = heats[rnd.Next(heats.Count - 1)],
                        IsActive = true
                    };
                firstSetupRepo.PlateRepo.Save(plate);

                var pipe = new Pipe
                {
                    Number = RndString(8),
                    Plate = plate,
                    Mill = viewModel.MillName,
                    Diameter = types[0].Diameter,
                    WallThickness = types[0].Thickness,
                    Type = types[rnd.Next(1)],
                    PurchaseOrder = orders[orders.Count - 1],
                    Project = viewModel.Project,
                    Status = PipeMillStatus.Produced,
                    ProductionDate = DateTime.Now.AddDays(-rnd.Next(20)),
                    IsActive = true
                };
                pipe.RecalculateWeight();

                var results = new List<PipeTestResult>();
                foreach(var item in tests.Where(x => x.pipeType == pipe.Type))
                {
                    var testResult = new PipeTestResult
                    {
                        Operation = item,
                        Pipe = pipe,
                        Status = PipeTestResultStatus.Scheduled
                    };
                    results.Add(testResult);
                    firstSetupRepo.PipeTestResultRepo.Save(testResult);
                }
                pipe.PipeTestResult = results;
                pipes.Add(pipe);
                if(pipes.Count % 2 == 0)
                {
                    foreach(var item in pipe.PipeTestResult)
                    {
                        item.Status = PipeTestResultStatus.Accepted;
                        if(item.Operation.Category.Type == FixedCategory.Length)
                        {
                            item.Value = PIPELENGHT.ToString();
                        }
                    }
                    pipe.Length = PIPELENGHT;
                    pipe.Status = PipeMillStatus.Stocked;
                    pipe.ConstructionStatus = PartConstructionStatus.Pending;
                    pipe.IsAvailableToJoint = true;
                    pipe.ToExport = true;
                    pipe.WallThickness = 12;
                    pipe.RecalculateWeight();

                }


                firstSetupRepo.PipeRepo.Save(pipe);
            };
            #endregion
            firstSetupRepo.Commit();
            firstSetupRepo.BeginTransaction();
            #region Inspector
            List<Inspector> inspectors = new List<Inspector>();
            for(int i = 0; i < INSPECTORCOUNT; i++)
            {
                var insp = new Inspector
                    {
                        Name = new PersonName
                        {
                            FirstName = RndName(fNames),
                            LastName = RndName(lNames),
                            MiddleName = RndName(mNames),
                        },
                        IsActive = true
                    };
                insp.Certificates = CreateInspectorCertificates(insp, inspetorCertTypes);
                inspectors.Add(insp);
                firstSetupRepo.InspectorRepo.Save(insp);
            }
            #endregion
            firstSetupRepo.Commit();
            firstSetupRepo.BeginTransaction();
            #region Welder
            List<Welder> welders = new List<Welder>();

            for(int i = 0; i < WELDERCOUNT; i++)
            {
                var welder = new Welder
                    {
                        Grade = rnd.Next(6),
                        Name = new PersonName
                        {
                            FirstName = RndName(fNames),
                            LastName = RndName(lNames),
                            MiddleName = RndName(mNames),
                        },
                        Stamp = RndString(12),
                        Certificate = new Certificate
                        {
                            Number = RndString(14),
                            ExpirationDate = DateTime.Now.AddDays(rnd.Next(60)),
                            IsActive = true
                        },
                        IsActive = true
                    };
                welders.Add(welder);
                firstSetupRepo.WelderRepo.Save(welder);
            }
            #endregion
            firstSetupRepo.Commit();
            firstSetupRepo.BeginTransaction();
            #region ComponentType
            ComponentType[] componentTypes = 
            {
                new ComponentType{Name = "Заглушка",ConnectorsCount = 1, IsActive = true},
                new ComponentType{Name = "Переходник",ConnectorsCount = 2, IsActive = true},
                new ComponentType{Name = "Т - Соединение",ConnectorsCount = 3, IsActive = true},
                new ComponentType{Name = "Тройник",ConnectorsCount = 3, IsActive = true}
            };
            foreach(var item in componentTypes)
            {
                firstSetupRepo.ComponentTypeRepo.Save(item);
            }
            #endregion
            firstSetupRepo.Commit();
            firstSetupRepo.BeginTransaction();
            #region Component
            List<Domain.Entity.Construction.Component> components = new List<Domain.Entity.Construction.Component>();

            foreach(var type in componentTypes)
            {
                for(int i = 0; i < COMPONENTCOUNT; i++)
                {
                    var component = CreateComponent(type);
                    firstSetupRepo.ComponentRepo.Save(component);
                    components.Add(component);
                }
            }

            #endregion
            firstSetupRepo.Commit();
            firstSetupRepo.BeginTransaction();
            #region Release
            List<Prizm.Domain.Entity.Mill.ReleaseNote> releases = new List<Prizm.Domain.Entity.Mill.ReleaseNote>();
            for(int i = 0; i < RELEASECOUNT; i++)
            {
                Prizm.Domain.Entity.Mill.ReleaseNote release = new Prizm.Domain.Entity.Mill.ReleaseNote
                {
                    Number = RndString(10),
                    Shipped = false,
                    Date = DateTime.Now.AddDays(-rnd.Next(10)),
                    IsActive = true
                };
                release.Railcars = CreateRailcars(rnd.Next(2, 5));
                firstSetupRepo.ReleaseRepo.Save(release);
            }
            #endregion
            firstSetupRepo.Commit();

            return false;
        }
        private bool SeedOptional()
        {
            //Required seed hasn't been performed for Master worksration type, but data are used in optional seed
            if (viewModel.Project.WorkstationType == WorkstationType.Master)
            {
                SeedRequired();
            }
            firstSetupRepo.BeginTransaction();
            #region SeamTypes
            seamTypes = new List<SeamType>
            {
                new SeamType{Name = "Бесшовный", IsActive = true, IsNative = true, Project = viewModel.Project},
                new SeamType{Name = "Прямой", IsActive = true, IsNative = true, Project = viewModel.Project},
                new SeamType{Name = "Спиралевидный", IsActive = true, IsNative = true, Project = viewModel.Project},
            };
            foreach (var item in seamTypes)
            {
                firstSetupRepo.SeemTypeRepo.Save(item);
            }
            #endregion
            firstSetupRepo.Commit();

            firstSetupRepo.BeginTransaction();
            #region InspectorCertificateTypes
            inspetorCertTypes = new List<InspectorCertificateType>
            {
                new InspectorCertificateType {Name = "Покрытия (Coating)",IsActive = true},
                new InspectorCertificateType {Name = "РК (RT)",IsActive = true},
                new InspectorCertificateType {Name = "ВИК (VT)",IsActive = true},
                new InspectorCertificateType {Name = "УК (UT)",IsActive = true},
                new InspectorCertificateType {Name = "НАКС (Welding Engineer)",IsActive = true},
                new InspectorCertificateType {Name = "МК (MT)",IsActive = true}
            };
            inspetorCertTypes.ForEach(s => firstSetupRepo.CertificateTypeRepo.Save(s));
            #endregion
            firstSetupRepo.Commit();

            firstSetupRepo.BeginTransaction();
            #region PipeMillSyzeType
            types = new List<PipeMillSizeType>
            {
                new PipeMillSizeType
                {
                    Type = "1500 X 100500 X 50 - бесшовный",
                    IsActive = true,
                    Length = 9090,
                    Diameter = 1212,
                    Thickness = 12,
                    SeamType = seamTypes[0],
                    IsNative = true,
                    Project = viewModel.Project
                },
                new PipeMillSizeType
                {
                    Type = "1500 X 100500 X 50 - Прямой",
                    IsActive = true,
                    Length = 9090,
                    Diameter = 1212,
                    Thickness = 12,
                    SeamType = seamTypes[1],
                    IsNative = true,
                    Project = viewModel.Project
                },
            };
            types.ForEach(s => firstSetupRepo.SizeTypeRepo.Save(s));
            #endregion
            firstSetupRepo.Commit();

            firstSetupRepo.BeginTransaction();
            #region PipeTestCategory
            categories = new List<Category>
            {
                #region creating pipe test category
                new Category { Name = "Категория - 1", Fixed = false, Type = FixedCategory.Undefined, IsActive = true},
                new Category { Name = "Категория - 2", Fixed = false, Type = FixedCategory.Undefined, IsActive = true},
                new Category { Name = "Измерение длины", IsActive = true , Fixed=true, ResultType="int", Type=FixedCategory.Length},
                new Category { Name = "Контроль сварки", IsActive = true, Fixed = true, ResultType = "int", Type = FixedCategory.Weld },
                new Category { Name = "Контроль внешнего покрытия", IsActive = true, Fixed = true, ResultType = "int", Type = FixedCategory.ExternalCoat },
                new Category { Name = "Контроль внутреннего покрытия", IsActive = true, Fixed = true, ResultType = "int", Type = FixedCategory.InternalCoat }
	            #endregion
            };
            foreach (var category in categories)
            {
                firstSetupRepo.CategoryRepo.Save(category);
            }
            #endregion
            firstSetupRepo.Commit();

            firstSetupRepo.BeginTransaction();
            #region PipeTest
            tests = new List<PipeTest>
            {
                #region creating pipetests for first pipe size type
                new PipeTest 
                {
                    Code = "01",
                    Name = "Входной контроль листа",
                    Category = categories[0],
                    ControlType = PipeTestControlType.Monitor,
                    ResultType = PipeTestResultType.Boolean,
                    pipeType = types[0],
                    IsActive = true,
                    FrequencyType = InspectionFrequencyType.R
                },

                new PipeTest 
                {
                    Code = "02",
                    Name = "Сварка технологического шва",
                    Category = categories[3],
                    ControlType = PipeTestControlType.Monitor,
                    ResultType = PipeTestResultType.Boolean,
                    pipeType = types[0],
                    IsActive = true,
                    FrequencyType = InspectionFrequencyType.R
                },

                new PipeTest 
                {
                    Code = "03",
                    Name = "Сварка наружного шва",
                    Category = categories[3],
                    ControlType = PipeTestControlType.Monitor,
                    ResultType = PipeTestResultType.Boolean,
                    pipeType = types[0],
                    IsActive = true,
                    FrequencyType = InspectionFrequencyType.R
                },

                new PipeTest 
                {
                    Code = "04",
                    Name = "Сварка внутреннего шва",
                    Category = categories[3],
                    ControlType = PipeTestControlType.Monitor,
                    ResultType = PipeTestResultType.Boolean,
                    pipeType = types[0],
                    IsActive = true,
                    FrequencyType = InspectionFrequencyType.R
                },

                new PipeTest 
                {
                    Code = "05",
                    Name = "Экспандирование",
                    Category = categories[0],
                    ControlType = PipeTestControlType.Review,
                    ResultType = PipeTestResultType.Boolean,
                    pipeType = types[0],
                    IsActive = true,
                    FrequencyType = InspectionFrequencyType.R
                },

                new PipeTest 
                {
                    Code = "06",
                    Name = "Обработка торцов",
                    Category = categories[0],
                    ControlType = PipeTestControlType.Monitor,
                    ResultType = PipeTestResultType.Boolean,
                    pipeType = types[0],
                    IsActive = true,
                    FrequencyType = InspectionFrequencyType.R
                },

                new PipeTest 
                {
                    Code = "07",
                    Name = "Гидроиспытание",
                    Category = categories[0],
                    ControlType = PipeTestControlType.Witness,
                    ResultType = PipeTestResultType.Boolean,
                    pipeType = types[0],
                    IsActive = true,
                    FrequencyType = InspectionFrequencyType.R
                },

                new PipeTest 
                {
                    Code = "08",
                    Name = "Рентген сварного шва",
                    Category = categories[1],
                    ControlType = PipeTestControlType.Witness,
                    ResultType = PipeTestResultType.String,
                    pipeType = types[0],
                    IsActive = true,
                    FrequencyType = InspectionFrequencyType.R
                },

                new PipeTest 
                {
                    Code = "09",
                    Name = "АУЗК сварного шва",
                    Category = categories[1],
                    ControlType = PipeTestControlType.Witness,
                    ResultType = PipeTestResultType.String,
                    pipeType = types[0],
                    IsActive = true,
                    FrequencyType = InspectionFrequencyType.R
                },

                new PipeTest 
                {
                    Code = "10",
                    Name = "РУЗК концов сварного шва",
                    Category = categories[1],
                    ControlType = PipeTestControlType.Witness,
                    ResultType = PipeTestResultType.String,
                    pipeType = types[0],
                    IsActive = true,
                    FrequencyType = InspectionFrequencyType.R
                },

                new PipeTest 
                {
                    Code = "11",
                    Name = "МПК фаски",
                    Category = categories[1],
                    ControlType = PipeTestControlType.Monitor,
                    ResultType = PipeTestResultType.String,
                    pipeType = types[0],
                    IsActive = true,
                    FrequencyType = InspectionFrequencyType.R
                },

                new PipeTest 
                {
                    Code = "12",
                    Name = "Наружный диаметр",
                    Category = categories[1],
                    ControlType = PipeTestControlType.Witness,
                    ResultType = PipeTestResultType.Diapason,
                    MinExpected = 1217,
                    MaxExpected = 1221,
                    pipeType = types[0],
                    IsActive = true,
                    FrequencyType = InspectionFrequencyType.R
                },

                new PipeTest 
                {
                    Code = "13",
                    Name = "Длина трубы",
                    Category = categories[2],
                    ControlType = PipeTestControlType.Monitor,
                    ResultType = PipeTestResultType.Diapason,
                    MinExpected = 9000,
                    MaxExpected = 12400,
                    pipeType = types[0],
                    IsActive = true,
                    FrequencyType = InspectionFrequencyType.R
                },

                new PipeTest 
                {
                    Code = "21",
                    Name = "Нанесение наружного покрытия",
                    Category = categories[4],
                    ControlType = PipeTestControlType.Monitor,
                    ResultType = PipeTestResultType.Boolean,
                    pipeType = types[0],
                    IsActive = true,
                    FrequencyType = InspectionFrequencyType.R
                },

                new PipeTest 
                {
                    Code = "31",
                    Name = "Нанесение внутреннего покрытия",
                    Category = categories[5],
                    ControlType = PipeTestControlType.Monitor,
                    ResultType = PipeTestResultType.Boolean,
                    pipeType = types[0],
                    IsActive = true,
                    FrequencyType = InspectionFrequencyType.R
                },

                new PipeTest 
                {
                    Code = "41",
                    Name = "Складирование",
                    Category = categories[0],
                    ControlType = PipeTestControlType.Monitor,
                    ResultType = PipeTestResultType.Boolean,
                    pipeType = types[0],
                    IsActive = true,
                    FrequencyType = InspectionFrequencyType.R
                }, 
	            #endregion

                #region creating pipetests for second pipe size type
                new PipeTest 
                {
                    Code = "01",
                    Name = "Входной контроль листа",
                    Category = categories[0],
                    ControlType = PipeTestControlType.Monitor,
                    ResultType = PipeTestResultType.Boolean,
                    pipeType = types[1],
                    IsActive = true,
                    FrequencyType = InspectionFrequencyType.R
                },

                new PipeTest 
                {
                    Code = "02",
                    Name = "Сварка технологического шва",
                    Category = categories[3],
                    ControlType = PipeTestControlType.Monitor,
                    ResultType = PipeTestResultType.Boolean,
                    pipeType = types[1],
                    IsActive = true,
                    FrequencyType = InspectionFrequencyType.R
                },

                new PipeTest 
                {
                    Code = "03",
                    Name = "Сварка наружного шва",
                    Category = categories[3],
                    ControlType = PipeTestControlType.Monitor,
                    ResultType = PipeTestResultType.Boolean,
                    pipeType = types[1],
                    IsActive = true,
                    FrequencyType = InspectionFrequencyType.R
                },

                new PipeTest 
                {
                    Code = "04",
                    Name = "Сварка внутреннего шва",
                    Category = categories[3],
                    ControlType = PipeTestControlType.Monitor,
                    ResultType = PipeTestResultType.Boolean,
                    pipeType = types[1],
                    IsActive = true,
                    FrequencyType = InspectionFrequencyType.R
                },

                new PipeTest 
                {
                    Code = "05",
                    Name = "Экспандирование",
                    Category = categories[0],
                    ControlType = PipeTestControlType.Review,
                    ResultType = PipeTestResultType.Boolean,
                    pipeType = types[1],
                    IsActive = true,
                    FrequencyType = InspectionFrequencyType.R
                },

                new PipeTest 
                {
                    Code = "06",
                    Name = "Обработка торцов",
                    Category = categories[0],
                    ControlType = PipeTestControlType.Monitor,
                    ResultType = PipeTestResultType.Boolean,
                    pipeType = types[1],
                    IsActive = true,
                    FrequencyType = InspectionFrequencyType.R
                },

                new PipeTest 
                {
                    Code = "07",
                    Name = "Гидроиспытание",
                    Category = categories[0],
                    ControlType = PipeTestControlType.Witness,
                    ResultType = PipeTestResultType.Boolean,
                    pipeType = types[1],
                    IsActive = true,
                    FrequencyType = InspectionFrequencyType.R
                },

                new PipeTest 
                {
                    Code = "08",
                    Name = "Рентген сварного шва",
                    Category = categories[1],
                    ControlType = PipeTestControlType.Witness,
                    ResultType = PipeTestResultType.String,
                    pipeType = types[1],
                    IsActive = true,
                    FrequencyType = InspectionFrequencyType.R
                },

                new PipeTest 
                {
                    Code = "09",
                    Name = "АУЗК сварного шва",
                    Category = categories[1],
                    ControlType = PipeTestControlType.Witness,
                    ResultType = PipeTestResultType.String,
                    pipeType = types[1],
                    IsActive = true,
                    FrequencyType = InspectionFrequencyType.R
                },

                new PipeTest 
                {
                    Code = "10",
                    Name = "РУЗК концов сварного шва",
                    Category = categories[1],
                    ControlType = PipeTestControlType.Witness,
                    ResultType = PipeTestResultType.String,
                    pipeType = types[1],
                    IsActive = true,
                    FrequencyType = InspectionFrequencyType.R
                },

                new PipeTest 
                {
                    Code = "11",
                    Name = "МПК фаски",
                    Category = categories[1],
                    ControlType = PipeTestControlType.Monitor,
                    ResultType = PipeTestResultType.String,
                    pipeType = types[1],
                    IsActive = true,
                    FrequencyType = InspectionFrequencyType.R
                },

                new PipeTest 
                {
                    Code = "12",
                    Name = "Наружный диаметр",
                    Category = categories[1],
                    ControlType = PipeTestControlType.Witness,
                    ResultType = PipeTestResultType.Diapason,
                    MinExpected = 1217,
                    MaxExpected = 1221,
                    pipeType = types[1],
                    IsActive = true,
                    FrequencyType = InspectionFrequencyType.R
                },

                new PipeTest 
                {
                    Code = "13",
                    Name = "Длина трубы",
                    Category = categories[2],
                    ControlType = PipeTestControlType.Monitor,
                    ResultType = PipeTestResultType.Diapason,
                    MinExpected = 9000,
                    MaxExpected = 12400,
                    pipeType = types[1],
                    IsActive = true,
                    FrequencyType = InspectionFrequencyType.R
                },

                new PipeTest 
                {
                    Code = "21",
                    Name = "Нанесение наружного покрытия",
                    Category = categories[4],
                    ControlType = PipeTestControlType.Monitor,
                    ResultType = PipeTestResultType.Boolean,
                    pipeType = types[1],
                    IsActive = true,
                    FrequencyType = InspectionFrequencyType.R
                },

                new PipeTest 
                {
                    Code = "31",
                    Name = "Нанесение внутреннего покрытия",
                    Category = categories[5],
                    ControlType = PipeTestControlType.Monitor,
                    ResultType = PipeTestResultType.Boolean,
                    pipeType = types[1],
                    IsActive = true,
                    FrequencyType = InspectionFrequencyType.R
                },

                new PipeTest 
                {
                    Code = "41",
                    Name = "Складирование",
                    Category = categories[0],
                    ControlType = PipeTestControlType.Monitor,
                    ResultType = PipeTestResultType.Boolean,
                    pipeType = types[1],
                    IsActive = true,
                    FrequencyType = InspectionFrequencyType.R
                } 
                #endregion
            };

            foreach (var test in tests)
            {
                firstSetupRepo.TestRepo.Save(test);
            }
            #endregion
            firstSetupRepo.Commit();

            firstSetupRepo.BeginTransaction();
            #region PlateManufacturers
            PlateManufacturer[] plateManufacturers = 
            {
                new PlateManufacturer {Name = "Алапаевский металлургический завод", IsActive = true, IsNative = true, Project = viewModel.Project},
                new PlateManufacturer {Name = "Альметьевский трубный завод", IsActive = true, IsNative = true, Project = viewModel.Project},
                new PlateManufacturer {Name = "Борский трубный завод", IsActive = true, IsNative = true, Project = viewModel.Project},
                new PlateManufacturer {Name = "Волжский трубный завод", IsActive = true, IsNative = true, Project = viewModel.Project},
                new PlateManufacturer {Name = "Волгоградский трубный завод", IsActive = true, IsNative = true, Project = viewModel.Project},
                new PlateManufacturer {Name = "Гурьевский металлургический завод", IsActive = true, IsNative = true, Project = viewModel.Project},
                new PlateManufacturer {Name = "Завод Точлит", IsActive = true}
            };
            Array.ForEach(plateManufacturers, s => firstSetupRepo.PlateManRepo.Save(s));
            #endregion
            firstSetupRepo.Commit();
            firstSetupRepo.BeginTransaction();
            #region Heat
            List<Heat> heats = new List<Heat>();
            for(int i = 0; i < HEATCOUNT; i++)
            {
                heats.Add
                    (
                    new Heat ()
                    {
                        Number = RndString(8),
                        SteelGrade = RndString(6),
                        PlateManufacturer = plateManufacturers[rnd.Next(plateManufacturers.Length - 1)],
                        IsActive = true                      
                    }
                    );
                firstSetupRepo.HeatRepo.Save(heats[i]);
            }

            #endregion
            firstSetupRepo.Commit();
            firstSetupRepo.BeginTransaction();
            #region PurchaseOrder
            List<PurchaseOrder> orders = new List<PurchaseOrder>
            {
                new PurchaseOrder {Number = RndString(5),Date = DateTime.Now.AddMonths(-rnd.Next(10)),IsActive=true},
                new PurchaseOrder {Number = RndString(5),Date = DateTime.Now.AddMonths(-rnd.Next(10)),IsActive=true},
                new PurchaseOrder {Number = RndString(5),Date = DateTime.Now.AddMonths(-rnd.Next(10)),IsActive=true},
                new PurchaseOrder {Number = RndString(5),Date = DateTime.Now.AddMonths(-rnd.Next(10)),IsActive=true},
                new PurchaseOrder {Number = RndString(5),Date = DateTime.Now.AddMonths(-rnd.Next(10)),IsActive=true}
            };
            orders.ForEach(s => firstSetupRepo.PurchaseRepo.Save(s));
            #endregion
            firstSetupRepo.Commit();
            firstSetupRepo.BeginTransaction();
            #region MillPipe
            List<Pipe> pipes = new List<Pipe>();
            for(int i = 0; i < PIPECOUNT; i++)
            {
                var plate = new Plate
                    {
                        Number = RndString(8),
                        Thickness = rnd.Next(2000),
                        Heat = heats[rnd.Next(heats.Count - 1)],
                        IsActive = true
                    };
                firstSetupRepo.PlateRepo.Save(plate);

                var pipe = new Pipe
                {
                    Number = RndString(8),
                    Plate = plate,
                    Mill = viewModel.MillName,
                    Diameter = types[0].Diameter,
                    WallThickness = types[0].Thickness,
                    Type = types[rnd.Next(1)],
                    PurchaseOrder = orders[orders.Count - 1],
                    Project = viewModel.Project,
                    Status = PipeMillStatus.Produced,
                    ProductionDate = DateTime.Now.AddDays(-rnd.Next(20)),
                    IsActive = true
                };
                pipe.RecalculateWeight();

                var results = new List<PipeTestResult>();
                foreach(var item in tests.Where(x => x.pipeType == pipe.Type))
                {
                    var testResult = new PipeTestResult
                    {
                        Operation = item,
                        Pipe = pipe,
                        Status = PipeTestResultStatus.Scheduled
                    };
                    results.Add(testResult);
                    firstSetupRepo.PipeTestResultRepo.Save(testResult);
                }
                pipe.PipeTestResult = results;
                pipes.Add(pipe);
                if(pipes.Count % 2 == 0)
                {
                    foreach(var item in pipe.PipeTestResult)
                    {
                        item.Status = PipeTestResultStatus.Accepted;
                        if(item.Operation.Category.Type == FixedCategory.Length)
                        {
                            item.Value = PIPELENGHT.ToString();
                        }
                    }
                    pipe.Length = PIPELENGHT;
                    pipe.Status = PipeMillStatus.Stocked;
                    pipe.ConstructionStatus = PartConstructionStatus.Pending;
                    pipe.IsAvailableToJoint = true;
                    pipe.ToExport = true;
                    pipe.WallThickness = 12;
                    pipe.RecalculateWeight();

                }


                firstSetupRepo.PipeRepo.Save(pipe);
            };
            #endregion
            firstSetupRepo.Commit();
            firstSetupRepo.BeginTransaction();
            #region Inspector
            List<Inspector> inspectors = new List<Inspector>();
            for(int i = 0; i < INSPECTORCOUNT; i++)
            {
                var insp = new Inspector
                    {
                        Name = new PersonName
                        {
                            FirstName = RndName(fNames),
                            LastName = RndName(lNames),
                            MiddleName = RndName(mNames),
                        },
                        IsActive = true
                    };
                insp.Certificates = CreateInspectorCertificates(insp, inspetorCertTypes);
                inspectors.Add(insp);
                firstSetupRepo.InspectorRepo.Save(insp);
            }
            #endregion
            firstSetupRepo.Commit();
            firstSetupRepo.BeginTransaction();
            #region Welder
            List<Welder> welders = new List<Welder>();

            for(int i = 0; i < WELDERCOUNT; i++)
            {
                var welder = new Welder
                    {
                        Grade = rnd.Next(6),
                        Name = new PersonName
                        {
                            FirstName = RndName(fNames),
                            LastName = RndName(lNames),
                            MiddleName = RndName(mNames),
                        },
                        Stamp = RndString(12),
                        Certificate = new Certificate
                        {
                            Number = RndString(14),
                            ExpirationDate = DateTime.Now.AddDays(rnd.Next(60)),
                            IsActive = true
                        },
                        IsActive = true
                    };
                welders.Add(welder);
                firstSetupRepo.WelderRepo.Save(welder);
            }
            #endregion
            firstSetupRepo.Commit();
            firstSetupRepo.BeginTransaction();
            #region ComponentType
            ComponentType[] componentTypes = 
            {
                new ComponentType{Name = "Заглушка",ConnectorsCount = 1, IsActive = true},
                new ComponentType{Name = "Переходник",ConnectorsCount = 2, IsActive = true},
                new ComponentType{Name = "Т - Соединение",ConnectorsCount = 3, IsActive = true},
                new ComponentType{Name = "Тройник",ConnectorsCount = 3, IsActive = true}
            };
            foreach(var item in componentTypes)
            {
                firstSetupRepo.ComponentTypeRepo.Save(item);
            }
            #endregion
            firstSetupRepo.Commit();
            firstSetupRepo.BeginTransaction();
            #region Component
            List<Domain.Entity.Construction.Component> components = new List<Domain.Entity.Construction.Component>();

            foreach(var type in componentTypes)
            {
                for(int i = 0; i < COMPONENTCOUNT; i++)
                {
                    var component = CreateComponent(type);
                    firstSetupRepo.ComponentRepo.Save(component);
                    components.Add(component);
                }
            }

            #endregion
            firstSetupRepo.Commit();
            firstSetupRepo.BeginTransaction();
            #region Release
            List<Prizm.Domain.Entity.Mill.ReleaseNote> releases = new List<Prizm.Domain.Entity.Mill.ReleaseNote>();
            for(int i = 0; i < RELEASECOUNT; i++)
            {
                Prizm.Domain.Entity.Mill.ReleaseNote release = new Prizm.Domain.Entity.Mill.ReleaseNote
                {
                    Number = RndString(10),
                    Shipped = false,
                    Date = DateTime.Now.AddDays(-rnd.Next(10)),
                    IsActive = true
                };
                release.Railcars = CreateRailcars(rnd.Next(2, 5));
                firstSetupRepo.ReleaseRepo.Save(release);
            }
            #endregion
            firstSetupRepo.Commit();

            return false;
        }