public void Execute()
        {
            try
            {
                viewModel.Admin.Name         = viewModel.Name;
                viewModel.Admin.PasswordHash = PasswordEncryptor.EncryptPassword(viewModel.Password);
                viewModel.Admin.IsActive     = true;
                viewModel.Project.IsActive   = true;
                if (viewModel.Project.WorkstationType != Domain.Entity.Setup.WorkstationType.Mill)
                {
                    viewModel.MillPipeNumberMask = string.Empty;
                }

                firstSetupRepo.BeginTransaction();
                firstSetupRepo.RoleRepo.Save(viewModel.SuperUser);
                firstSetupRepo.UserRepo.Save(viewModel.Admin);
                firstSetupRepo.ProjectRepo.Save(viewModel.Project);
                firstSetupRepo.Commit();
                firstSetupRepo.RoleRepo.Evict(viewModel.SuperUser);
                firstSetupRepo.UserRepo.Evict(viewModel.Admin);
                firstSetupRepo.ProjectRepo.Evict(viewModel.Project);
                viewModel.IsSaved = true;

                var seeder = new InnitialDataSeeder(viewModel);
                seeder.Seed(Program.IsSeed);
            }
            catch (RepositoryException ex)
            {
                log.Error(ex.Message);
            }
        }
Beispiel #2
0
        private bool SeedRequired()
        {
            firstSetupRepo.BeginTransaction();
            #region SeamTypes
            seamTypes = new List <SeamType>
            {
                new SeamType {
                    Name = "Бесшовный", IsActive = true
                },
                new SeamType {
                    Name = "Прямой", IsActive = true
                },
                new SeamType {
                    Name = "Спиралевидный", IsActive = true
                },
            };
            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]
                },
                new PipeMillSizeType
                {
                    Type      = "1500 X 100500 X 50 - Прямой",
                    IsActive  = true,
                    Length    = 9090,
                    Diameter  = 1212,
                    Thickness = 12,
                    SeamType  = seamTypes[1]
                },
            };
            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,
                    IsRequired  = true
                },

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                new PipeTest
                {
                    Code        = "41",
                    Name        = "Складирование",
                    Category    = categories[0],
                    ControlType = PipeTestControlType.Monitor,
                    ResultType  = PipeTestResultType.Boolean,
                    pipeType    = types[0],
                    IsActive    = true,
                    IsRequired  = true
                },
                #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,
                    IsRequired  = true
                },

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            #region --- CannedMessage ---

            try
            {
                string   fileName = Path.Combine(Directories.Seeding, "defectList.txt");
                string[] lines    = System.IO.File.ReadAllLines(fileName, Encoding.Default);

                var cannedMessageList = new List <CannedMessage>(lines.Length);

                for (int i = 0; i < lines.LongLength; ++i)
                {
                    string[] tmp = lines[i].Split('\t');

                    cannedMessageList.Add(new CannedMessage {
                        Language = tmp[0], IdDefect = tmp[1], Text = tmp[2]
                    });
                }

                firstSetupRepo.BeginTransaction();
                cannedMessageList.ForEach(s => firstSetupRepo.CannedMessageRepo.Save(s));
                firstSetupRepo.Commit();
                cannedMessageList.ForEach(s => firstSetupRepo.CannedMessageRepo.Evict(s));
            }
            catch (Exception e)
            {
                log.Warn(string.Format("The file specified in path was not found or path is in an invalid format: {0}", e.Message));
            }

            #endregion // --- CannedMessage ---


            return(false);
        }
Beispiel #3
0
        private bool SeedRequired()
        {
            try
            {
                firstSetupRepo.BeginTransaction();
                #region PipeTestCategory

                Category category = new Category {
                    Name = "Измерение длины", IsActive = true, Fixed = true, ResultType = "int", Type = FixedCategory.Length
                };
                firstSetupRepo.CategoryRepo.Save(category);

                #endregion
                firstSetupRepo.Commit();


                firstSetupRepo.BeginTransaction();
                #region Joint weld operation

                JointOperation weldOperation = new JointOperation()
                {
                    IsActive   = true,
                    IsRequired = true,
                    Type       = JointOperationType.Weld,
                    Name       = "Сварка стыка"
                };
                firstSetupRepo.JointOperationRepo.Save(weldOperation);

                #endregion
                firstSetupRepo.Commit();

                #region --- CannedMessage ---

                try
                {
                    string   fileName = Path.Combine(Directories.Seeding, "defectList.txt");
                    string[] lines    = System.IO.File.ReadAllLines(fileName, Encoding.Default);

                    var cannedMessageList = new List <CannedMessage>(lines.Length);

                    for (int i = 0; i < lines.LongLength; ++i)
                    {
                        string[] tmp = lines[i].Split('\t');

                        cannedMessageList.Add(new CannedMessage {
                            Language = tmp[0], IdDefect = tmp[1], Text = tmp[2]
                        });
                    }

                    firstSetupRepo.BeginTransaction();
                    cannedMessageList.ForEach(s => firstSetupRepo.CannedMessageRepo.Save(s));
                    firstSetupRepo.Commit();
                    cannedMessageList.ForEach(s => firstSetupRepo.CannedMessageRepo.Evict(s));
                }
                catch (Exception e)
                {
                    log.Warn(string.Format("The file specified in path was not found or path is in an invalid format: {0}", e.Message));
                }

                #endregion // --- CannedMessage ---
            }
            catch (RepositoryException ex)
            {
                log.Warn(this.GetType().Name + " | " + ex.ToString());
            }
            return(false);
        }