예제 #1
0
        public IList <Pipe> GetPipesToExport()
        {
            try
            {
                // PipeTestResult result = null;
                // Inspector inspector = null;
                // Certificate certificate = null;
                // var q = session.QueryOver<Pipe>()
                //     .Where(n => ((n.ToExport == true)))
                //     .JoinAlias(r => r.PipeTestResult, () => result, JoinType.LeftOuterJoin)
                //     .JoinAlias(() => result.Inspectors, () => inspector, JoinType.LeftOuterJoin)
                //     .JoinAlias(() => inspector.Certificates, () => certificate, JoinType.LeftOuterJoin)
                //     .TransformUsing(Transformers.DistinctRootEntity)
                //     .List<Pipe>();
                //return q;

                Plate             plate       = null;
                Heat              heat        = null;
                PlateManufacturer plateMan    = null;
                PipeMillSizeType  type        = null;
                PipeTest          tests       = null;
                PipeTestResult    result      = null;
                Inspector         inspector   = null;
                Certificate       certificate = null;
                Project           proj        = null;
                SeamType          seam        = null;
                Spool             spool       = null;
                File              attach      = null;

                var q = session.QueryOver <Pipe>()
                        .Where(n => ((n.ToExport == true)))

                        .JoinAlias(r => r.PipeTestResult, () => result, JoinType.LeftOuterJoin)
                        .JoinAlias(() => result.Inspectors, () => inspector, JoinType.LeftOuterJoin)
                        .JoinAlias(() => inspector.Certificates, () => certificate, JoinType.LeftOuterJoin)

                        .JoinAlias(p => p.Plate, () => plate, JoinType.LeftOuterJoin)
                        .JoinAlias(() => plate.Heat, () => heat, JoinType.LeftOuterJoin)
                        .JoinAlias(() => heat.PlateManufacturer, () => plateMan, JoinType.LeftOuterJoin)

                        .JoinAlias(t => t.Type, () => type, JoinType.LeftOuterJoin)
                        .JoinAlias(() => type.SeamType, () => seam, JoinType.LeftOuterJoin)
                        .JoinAlias(() => type.PipeTests, () => tests, JoinType.LeftOuterJoin)

                        .JoinAlias(t => t.Spools, () => spool, JoinType.LeftOuterJoin)
                        .JoinAlias(t => t.Attachments, () => attach, JoinType.LeftOuterJoin)
                        .JoinAlias(t => t.Project, () => proj, JoinType.LeftOuterJoin)

                        .Fetch(o => o.PurchaseOrder).Eager
                        .Fetch(r => r.Railcar).Eager

                        .TransformUsing(Transformers.DistinctRootEntity)
                        .List <Pipe>();
                return(q);
            }
            catch (GenericADOException ex)
            {
                throw new RepositoryException("GetPipesToExport", ex);
            }
        }
        /// <summary>
        /// Creates predefined pipe test result for all active required availableTests for concrete pipe mill size type
        /// </summary>
        /// <param name="millSizeType"></param>
        public BindingList <PipeTestResult> GetRequired(PipeMillSizeType millSizeType)
        {
            BindingList <PipeTestResult> requiredTestResults = new BindingList <PipeTestResult>();
            var criteria = NHibernate.Criterion.DetachedCriteria
                           .For <PipeTest>()
                           .Add(Restrictions.Eq("FrequencyType", InspectionFrequencyType.R))
                           .Add(Restrictions.Eq("pipeType", millSizeType))
                           .Add(Restrictions.Eq("IsActive", true));
            IList <PipeTest> requiredTests = repoMill.RepoPipeTest.GetByCriteria(criteria);

            GetAvailableTests();
            foreach (var requiredTest in requiredTests)
            {
                PipeTestResult requiredResult = new PipeTestResult()
                {
                    Operation  = requiredTest,
                    IsActive   = true,
                    Status     = PipeTestResultStatus.Scheduled,
                    Pipe       = Pipe,
                    Inspectors = new BindingList <Prizm.Domain.Entity.Inspector>()
                };
                requiredTestResults.Add(requiredResult);
                requiredResult.Order++;
            }
            return(requiredTestResults);
        }
예제 #3
0
        public IList <Pipe> GetStored()
        {
            try
            {
                PipeTestResult result      = null;
                Inspector      inspector   = null;
                Certificate    certificate = null;
                Coat           coat        = null;
                Weld           weld        = null;
                Spool          spool       = null;

                var q = session.QueryOver <Pipe>()
                        .Where(n => ((n.Status == PipeMillStatus.Stocked) && (n.IsActive == true) && n.Railcar == null))
                        .JoinAlias(r => r.PipeTestResult, () => result, JoinType.LeftOuterJoin)
                        .JoinAlias(() => result.Inspectors, () => inspector, JoinType.LeftOuterJoin)
                        .JoinAlias(() => inspector.Certificates, () => certificate, JoinType.LeftOuterJoin)
                        .JoinAlias(r => r.Coats, () => coat, JoinType.LeftOuterJoin)
                        .JoinAlias(r => r.Welds, () => weld, JoinType.LeftOuterJoin)
                        .JoinAlias(r => r.Spools, () => spool, JoinType.LeftOuterJoin)
                        .TransformUsing(Transformers.DistinctRootEntity)
                        .List <Pipe>();

                return(q);
            }
            catch (GenericADOException ex)
            {
                throw new RepositoryException("GetStored", ex);
            }
        }
예제 #4
0
        public IList <Pipe> GetPipesToExport()
        {
            try
            {
                //Pipe p = null;
                //PipeTestResult ptr = null;
                //Inspector ins = null;

                //var q = session
                //   .QueryOver<Pipe>(() => p)
                //   .Left.JoinAlias(() => p.PipeTestResult, () => ptr)
                //   .Left.JoinAlias(() => ptr.Inspectors, () => ins)
                //   .Where(_ => _.ToExport)
                //   .List<Pipe>();
                PipeTestResult result      = null;
                Inspector      inspector   = null;
                Certificate    certificate = null;
                var            q           = session.QueryOver <Pipe>()
                                             .Where(n => ((n.ToExport == true)))
                                             .JoinAlias(r => r.PipeTestResult, () => result, JoinType.LeftOuterJoin)
                                             .JoinAlias(() => result.Inspectors, () => inspector, JoinType.LeftOuterJoin)
                                             .JoinAlias(() => inspector.Certificates, () => certificate, JoinType.LeftOuterJoin)
                                             .TransformUsing(Transformers.DistinctRootEntity)
                                             .List <Pipe>();
                return(q);
            }
            catch (GenericADOException ex)
            {
                throw new RepositoryException("GetPipesToExport", ex);
            }
        }
예제 #5
0
        public void SetupForm(
            IList <PipeTest> tests,
            IList <Inspector> inspectors,
            PipeTestResult current,
            IList <EnumWrapper <PipeTestResultStatus> > statuses)
        {
            GetInspectionViewModel(tests, inspectors, current, statuses);

            date.Properties.NullDate = DateTime.MinValue;
            date.Properties.NullText = string.Empty;

            if (current != null)
            {
                ChangeFact();
                code.Properties.ReadOnly = true;
                code.Text = viewModel.Code;
                this.Text = current.Operation.Code + " - " + current.Operation.Name;
            }
            else
            {
                code.Properties.ReadOnly = false;
                code.Properties.Items.Clear();
                foreach (var item in viewModel.Tests)
                {
                    code.Properties.Items.Add(item.Code);
                }

                this.Text = "Добавление контрольной операции";
            }
        }
        public void SetupForm(
            IList<PipeTest> tests,
            IList<Inspector> inspectors,
            PipeTestResult current,
            IList<EnumWrapper<PipeTestResultStatus>> statuses,
            IList<PipeTestResult> pipeTestResults)
        {
            this.pipeTestResults = pipeTestResults;
            GetInspectionViewModel(tests, inspectors, current, statuses);

            date.Properties.NullDate = DateTime.MinValue;
            date.Properties.NullText = string.Empty;

            factLimit.SetFloatMask(Constants.DigitsBeforeDecimalPoint);

            if(current != null)
            {
                ChangeFact();
                code.Properties.ReadOnly = true;
                code.Text = viewModel.Code;
                this.Text = current.Operation.Code + " - " + current.Operation.Name;
            }
            else
            {
                code.Properties.ReadOnly = false;
                code.Properties.Items.Clear();
                foreach(var item in viewModel.Tests)
                {
                    code.Properties.Items.Add(item.Code);
                }

                this.Text = "Добавление контрольной операции";
            }
        }
        public void SetupViewModelState(
            IList <PipeTest> tests,
            IList <Inspector> inspectors,
            PipeTestResult current,
            IList <EnumWrapper <PipeTestResultStatus> > statuses)
        {
            this.availableTests = tests.Where(_ => _.IsActive).OrderBy(_ => _.Code).ToList <PipeTest>();
            this.inspectors     = inspectors;
            this.statuses       = statuses;
            if (current == null)
            {
                TestResult           = new PipeTestResult();
                TestResult.Operation = new PipeTest();
                TestResult.Status    = PipeTestResultStatus.Scheduled;
                this.status          = TestResult.Status;
                this.factBool        = false;
                this.date            = DateTime.Now;
                this.factLimit       = string.Empty;
                this.factString      = null;

                if (this.availableTests != null && this.availableTests.Count > 0)
                {
                    TestResult.Operation = this.availableTests[0];
                }
            }
            else
            {
                TestResult = current;
                switch (current.Operation.ResultType)
                {
                case PipeTestResultType.Boolean:
                    factBool = (current.Value != null && current.Value.Equals("True")) ? true : false;
                    break;

                case PipeTestResultType.String:
                    factString = current.Value;
                    break;

                case PipeTestResultType.Diapason:
                    factLimit = current.Value;
                    break;

                case PipeTestResultType.Undefined:
                    break;

                default:
                    break;
                }

                date = (current.Date == null) ? DateTime.Now : current.Date.Value;

                status = current.Status;
            }
            if (testResult.Value == null)
            {
                testResult.Value = string.Empty;
            }
        }
예제 #8
0
        private PipeTestResult DoRowDoubleClick(GridView view, Point pt)
        {
            PipeTestResult row  = null;
            GridHitInfo    info = view.CalcHitInfo(pt);

            if (info.InRow || info.InRowCell)
            {
                row = (PipeTestResult)view.GetRow(info.RowHandle);
            }
            return(row);
        }
        public InspectionAddEditXtraForm(
            IList<PipeTest> tests, 
            IList<Inspector> inspectors, 
            PipeTestResult current,
            IList<EnumWrapper<PipeTestResultStatus>> statuses,
            IList<PipeTestResult> pipeTestResults)
        {
            InitializeComponent();

            this.SetupForm(tests, inspectors, current, statuses, pipeTestResults);
        }
예제 #10
0
        public List <ReleaseNote> SearchReleasesAllCreteria(string number, DateTime startDate, DateTime endDate, string pipeNumber, string railcar, string certificate, string reciver)
        {
            try
            {
                ReleaseNote    note      = null;
                Railcar        car       = null;
                Pipe           pipe      = null;
                PipeTestResult result    = null;
                Inspector      inspector = null;
                Certificate    cert      = null;

                var s = session.QueryOver <ReleaseNote>(() => note)
                        .JoinAlias(() => note.Railcars, () => car, JoinType.LeftOuterJoin)
                        .JoinAlias(() => car.Pipes, () => pipe, JoinType.LeftOuterJoin)
                        .JoinAlias(() => pipe.PipeTestResult, () => result, JoinType.LeftOuterJoin)
                        .JoinAlias(() => result.Inspectors, () => inspector, JoinType.LeftOuterJoin)
                        .JoinAlias(() => inspector.Certificates, () => cert, JoinType.LeftOuterJoin)
                        .TransformUsing(Transformers.DistinctRootEntity);

                if (!string.IsNullOrWhiteSpace(pipeNumber))
                {
                    s.WhereRestrictionOn(() => pipe.Number).IsInsensitiveLike(pipeNumber, MatchMode.Start);
                }

                if (!string.IsNullOrWhiteSpace(railcar))
                {
                    s.WhereRestrictionOn(() => car.Number).IsInsensitiveLike(railcar, MatchMode.Start);
                }
                if (!string.IsNullOrWhiteSpace(number))
                {
                    s.WhereRestrictionOn(x => x.Number).IsInsensitiveLike(number, MatchMode.Start);
                }
                if (!string.IsNullOrWhiteSpace(certificate))
                {
                    s.WhereRestrictionOn(() => car.Certificate).IsInsensitiveLike(certificate, MatchMode.Start);
                }
                if (!string.IsNullOrWhiteSpace(reciver))
                {
                    s.WhereRestrictionOn(() => car.Destination).IsInsensitiveLike(reciver, MatchMode.Start);
                }
                if (startDate != DateTime.MinValue && endDate != DateTime.MinValue)
                {
                    s.WhereRestrictionOn(x => x.Date).IsBetween(startDate).And(endDate.AddHours(23).AddMinutes(59).AddSeconds(59));
                }
                var list = new List <ReleaseNote>(s.List <ReleaseNote>().OrderBy(x => x.Number));

                return(list);
            }
            catch (GenericADOException ex)
            {
                throw new RepositoryException("SearchReleasesAllCreteria", ex);
            }
        }
        public InspectionAddEditViewModel(IList <PipeTest> tests, IList <Inspector> inspectors,
                                          PipeTestResult current, IList <Main.Common.EnumWrapper <PipeTestResultStatus> > statuses)
        {
            this.cannedMessageRepo = Program.Kernel.Get <ICannedMessageRepository>();

            this.cannedMessageStrings = cannedMessageRepo.GetAll()
                                        .Where <CannedMessage>(x => x.Language == Program.LanguageManager.CurrentCulture.Name)
                                        .Select <CannedMessage, string>(y => y.Text).ToList <string>();


            this.SetupViewModelState(tests, inspectors, current, statuses);
        }
        public InspectionAddEditViewModel(IList<PipeTest> tests, IList<Inspector> inspectors,
            PipeTestResult current, IList<Main.Common.EnumWrapper<PipeTestResultStatus>> statuses)
        {
            this.cannedMessageRepo = Program.Kernel.Get<ICannedMessageRepository>();

            this.cannedMessageStrings = cannedMessageRepo.GetAll()
                .Where<CannedMessage>(x => x.Language == Program.LanguageManager.CurrentCulture.Name)
                .Select<CannedMessage, string>(y => y.Text).ToList<string>();


            this.SetupViewModelState(tests, inspectors, current, statuses);
        }
예제 #13
0
 private void inspectorsPopupContainerEdit_Popup(object sender, EventArgs e)
 {
     inspectionsGridView.ClearSelection();
     if (inspectionsGridView.IsValidRowHandle(inspectionsGridView.FocusedRowHandle))
     {
         PipeTestResult pipeTestResult = inspectionsGridView.GetRow(inspectionsGridView.FocusedRowHandle) as PipeTestResult;
         if (pipeTestResult != null)
         {
             inspectorSelectionControl.SelectInspectors(pipeTestResult.Inspectors);
         }
     }
 }
        public void SetupViewModelState(
            IList<PipeTest> tests, 
            IList<Inspector> inspectors, 
            PipeTestResult current, 
            IList<EnumWrapper<PipeTestResultStatus>> statuses)
        {
            this.availableTests = tests.Where(_ => _.IsActive).OrderBy(_ => _.Code).ToList<PipeTest>();
            this.inspectors = inspectors;
            this.statuses = statuses;
            if (current == null)
            {
                TestResult = new PipeTestResult();
                TestResult.Operation = new PipeTest();
                TestResult.Status = PipeTestResultStatus.Scheduled;
                this.status = TestResult.Status;
                this.factBool = false;
                this.date = DateTime.Now;
                this.factLimit = string.Empty;
                this.factString = null;

                if (this.availableTests != null && this.availableTests.Count > 0)
                    TestResult.Operation = this.availableTests[0];
            }
            else
            {
                TestResult = current;
                switch (current.Operation.ResultType)
                {
                    case PipeTestResultType.Boolean:
                        factBool = (current.Value != null && current.Value.Equals("True")) ? true : false;
                        break;
                    case PipeTestResultType.String:
                        factString = current.Value;
                        break;
                    case PipeTestResultType.Diapason:
                        factLimit = current.Value;
                        break;
                    case PipeTestResultType.Undefined:
                        break;
                    default:
                        break;
                }

                date = (current.Date == null) ? DateTime.Now : current.Date.Value;

                status = current.Status;
            }
            if (testResult.Value == null)
            {
                testResult.Value = string.Empty;
            }
        }
        public InspectionAddEditXtraForm(
            IList<PipeTest> tests, 
            IList<Inspector> inspectors, 
            PipeTestResult current,
            IList<EnumWrapper<PipeTestResultStatus>> statuses,
            IList<PipeTestResult> pipeTestResults,
            bool isNew,
            List<KeyValuePair<string, object>> listOfInspectors)
        {
            InitializeComponent();

            this.SetupForm(tests, inspectors, current, statuses, pipeTestResults, isNew, listOfInspectors);
        }
        public InspectionAddEditXtraForm(
            IList <PipeTest> tests,
            IList <Inspector> inspectors,
            PipeTestResult current,
            IList <EnumWrapper <PipeTestResultStatus> > statuses,
            IList <PipeTestResult> pipeTestResults,
            bool isNew,
            List <KeyValuePair <string, object> > listOfInspectors)
        {
            InitializeComponent();

            this.SetupForm(tests, inspectors, current, statuses, pipeTestResults, isNew, listOfInspectors);
        }
예제 #17
0
        private void inspectionsGridView_InitNewRow(object sender, InitNewRowEventArgs e)
        {
            GridView view = sender as GridView;

            if (view.IsValidRowHandle(e.RowHandle))
            {
                currentTestResult             = view.GetRow(e.RowHandle) as PipeTestResult;
                currentTestResult.IsActive    = true;
                currentTestResult.Pipe        = viewModel.Pipe;
                currentTestResult.Order       = viewModel.PipeTestResults.Max(test => test.Order) + 1;
                viewModel.Pipe.PipeTestResult = viewModel.PipeTestResults;
            }
        }
예제 #18
0
        private void EditInspections(BindingList <PipeTest> tests, PipeTestResult row, IList <Inspector> insp, BindingList <EnumWrapper <PipeTestResultStatus> > status)
        {
            if (IsEditMode)
            {
                var editForm = GetInspectionForm(tests, insp, row, status);

                editForm.ShowDialog();
                IsModified = true;
                inspections.RefreshDataSource();
                viewModel.GetLengthFromOperation();
                pipeLength.Refresh();
                weight.Refresh();
            }
        }
예제 #19
0
        private void inspectionsGridView_CustomColumnDisplayText(object sender, CustomColumnDisplayTextEventArgs e)
        {
            if (e.Column.Name == inspectionResultGridColumn.Name && e.Value != null)
            {
                PipeTestResultStatus result;
                if (Enum.TryParse <PipeTestResultStatus>(e.Value.ToString(), out result))
                {
                    e.DisplayText = (result == PipeTestResultStatus.Undefined) ? "" :localizedAllPipeTestResultStatus[(int)result - 1]; //-1 because we skip 0
                }
            }

            if (e.Column.Name == expectedResultGridColumn.Name)
            {
                PipeTestResult pipeTestResult = inspectionsGridView.GetRow(e.ListSourceRowIndex) as PipeTestResult;
                if (pipeTestResult != null &&
                    pipeTestResult.Operation.ResultType == PipeTestResultType.Boolean)
                {
                    if (pipeTestResult.Operation.BoolExpected)
                    {
                        e.DisplayText = Program.LanguageManager.GetString(StringResources.Yes);
                    }
                    else
                    {
                        e.DisplayText = Program.LanguageManager.GetString(StringResources.No);
                    }
                }
            }

            if (e.Column.Name == valueGridColumn.Name)
            {
                bool tmpResult;

                PipeTestResult pipeTestResult = inspectionsGridView.GetRow(e.ListSourceRowIndex) as PipeTestResult;

                if (pipeTestResult != null &&
                    bool.TryParse(e.DisplayText, out tmpResult) &&
                    pipeTestResult.Operation.ResultType == PipeTestResultType.Boolean)
                {
                    if (tmpResult)
                    {
                        e.DisplayText = Program.LanguageManager.GetString(StringResources.Yes);
                    }
                    else
                    {
                        e.DisplayText = Program.LanguageManager.GetString(StringResources.No);
                    }
                }
            }
        }
예제 #20
0
        private void inspectorsPopupContainerEdit_QueryPopUp(object sender, CancelEventArgs e)
        {
            PipeTestResult pipeTestResult = inspectionsGridView.GetRow(inspectionsGridView.FocusedRowHandle) as PipeTestResult;

            if (pipeTestResult == null || (pipeTestResult != null && pipeTestResult.Date == null))
            {
                inspectionsGridView.SetColumnError(inspectionsGridView.VisibleColumns[6],
                                                   Program.LanguageManager.GetString(StringResources.DateFirst));
                e.Cancel = true;
            }
            else
            {
                inspectorSelectionControl.inspectionDate = pipeTestResult.Date;
            }
        }
예제 #21
0
        private InspectionAddEditXtraForm GetInspectionForm(
            BindingList <PipeTest> tests,
            IList <Inspector> inspectors,
            PipeTestResult row,
            IList <EnumWrapper <PipeTestResultStatus> > statuses)
        {
            if (inspectionForm == null)
            {
                inspectionForm = new InspectionAddEditXtraForm(tests, inspectors, row, statuses);
            }
            else
            {
                inspectionForm.SetupForm(tests, inspectors, row, statuses);
            }

            return(inspectionForm);
        }
        private InspectionAddEditViewModel GetInspectionViewModel(
            IList <PipeTest> tests,
            IList <Inspector> inspectors,
            PipeTestResult current,
            IList <EnumWrapper <PipeTestResultStatus> > statuses)
        {
            if (viewModel == null)
            {
                viewModel = new InspectionAddEditViewModel(tests, inspectors, current, statuses);
            }
            else
            {
                viewModel.SetupViewModelState(tests, inspectors, current, statuses);
            }

            return(viewModel);
        }
        private InspectionAddEditViewModel GetInspectionViewModel(
            IList<PipeTest> tests,
            IList<Inspector> inspectors,
            PipeTestResult current,
            IList<EnumWrapper<PipeTestResultStatus>> statuses)
        {
            if(viewModel == null)
            {
                viewModel = new InspectionAddEditViewModel(tests, inspectors, current, statuses);
            }
            else
            {
                viewModel.SetupViewModelState(tests, inspectors, current, statuses);
            }

            return viewModel;
        }
예제 #24
0
        private void inspectorsPopupContainerEdit_CloseUp(object sender, DevExpress.XtraEditors.Controls.CloseUpEventArgs e)
        {
            if (inspectionsGridView.IsValidRowHandle(inspectionsGridView.FocusedRowHandle))
            {
                IList <Inspector> selectedInspectors = inspectorSelectionControl.SelectedInspectors;
                PipeTestResult    pipeTestResult     = inspectionsGridView.GetRow(inspectionsGridView.FocusedRowHandle) as PipeTestResult;
                if (pipeTestResult == null)
                {
                    return;
                }

                pipeTestResult.Inspectors.Clear();
                foreach (Inspector i in selectedInspectors)
                {
                    pipeTestResult.Inspectors.Add(i);
                }
            }
        }
예제 #25
0
        public IList <Pipe> GetReleasedNotePipe(Guid Id)
        {
            try
            {
                IList <Pipe> pipeList = new List <Pipe>();
                ReleaseNote  note     = null;
                Railcar      car      = null;
                Pipe         pipe     = null;

                PipeTestResult result    = null;
                Inspector      inspector = null;
                Certificate    cert      = null;

                var s = session.QueryOver <ReleaseNote>(() => note)
                        .Where(n => ((n.Id == Id)))
                        .JoinAlias(() => note.Railcars, () => car, JoinType.LeftOuterJoin)
                        .JoinAlias(() => car.Pipes, () => pipe, JoinType.LeftOuterJoin)
                        //.JoinAlias(() => pipe.PipeTestResult, () => result, JoinType.LeftOuterJoin)
                        //.JoinAlias(() => result.Inspectors, () => inspector, JoinType.LeftOuterJoin)
                        //.JoinAlias(() => inspector.Certificates, () => cert, JoinType.LeftOuterJoin)
                        .TransformUsing(Transformers.DistinctRootEntity);

                var listReleaseNote = new List <ReleaseNote>(s.List <ReleaseNote>());
                foreach (ReleaseNote n in listReleaseNote)
                {
                    foreach (Prizm.Domain.Entity.Mill.Railcar r in n.Railcars)
                    {
                        foreach (Pipe p in r.Pipes)
                        {
                            pipeList.Add(p);
                        }
                    }
                }

                return(pipeList);
            }
            catch (GenericADOException ex)
            {
                throw new RepositoryException("Get pipes from Release note", ex);
            }
        }
        public void SetupForm(
            IList <PipeTest> tests,
            IList <Inspector> inspectors,
            PipeTestResult current,
            IList <EnumWrapper <PipeTestResultStatus> > statuses,
            IList <PipeTestResult> pipeTestResults,
            bool isNew,
            List <KeyValuePair <string, object> > listOfInspectors)
        {
            this.pipeTestResults = pipeTestResults;
            GetInspectionViewModel(tests, inspectors, current, statuses);
            this.listOfInspectors    = listOfInspectors;
            this.isNew               = isNew;
            date.Properties.NullDate = DateTime.MinValue;
            date.Properties.NullText = string.Empty;

            factLimit.SetFloatMask(Constants.DigitsBeforeDecimalPoint);

            if (current != null)
            {
                ChangeFact();
                code.Properties.ReadOnly = true;
                code.Text = viewModel.Code;
                this.Text = current.Operation.Code + " - " + current.Operation.Name;
            }
            else
            {
                code.Properties.ReadOnly = false;
                code.Properties.Items.Clear();
                foreach (var item in viewModel.Tests)
                {
                    code.Properties.Items.Add(item.Code);
                }

                this.Text = "Добавление контрольной операции";
            }
        }
예제 #27
0
        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;
        }
예제 #28
0
        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);
        }
예제 #29
0
        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 void EditInspections(BindingList<PipeTest> tests, PipeTestResult row, IList<Inspector> insp, BindingList<EnumWrapper<PipeTestResultStatus>> status)
        {
            if (IsEditMode)
            {
                if (row.Status == PipeTestResultStatus.Scheduled)
                {
                    var editForm = GetInspectionForm(tests, insp, row, status);
                    row.Order = viewModel.PipeTestResultsMaxOrder();
                    editForm.ShowDialog();
                    IsModified = true;
                    inspections.RefreshDataSource();
                    viewModel.GetLengthFromOperation();
                    pipeLength.Refresh();
                    weight.Refresh();

                    AddRepeatedInspections(row);
                }
                else
                {
                    Program.MainForm.ShowInfo
                        (Program.LanguageManager.GetString(StringResources.InspectionAddEditXtraForm_InspectionTestCompleted),
                        Program.LanguageManager.GetString(StringResources.InspectionAddEditXtraForm_InspectionTestCompletedHeader));
                }
            }

            if (viewModel != null)
            {
                viewModel.CheckStatus();
            }
        }
예제 #31
0
 private void inspectionsGridView_InitNewRow(object sender, InitNewRowEventArgs e)
 {
     GridView view = sender as GridView;
     if(view.IsValidRowHandle(e.RowHandle))
     {
         currentTestResult = view.GetRow(e.RowHandle) as PipeTestResult;
         currentTestResult.IsActive = true;
         currentTestResult.Pipe = viewModel.Pipe;
         currentTestResult.Order = viewModel.PipeTestResults.Max(test => test.Order) + 1;
         viewModel.Pipe.PipeTestResult = viewModel.PipeTestResults;
     }
 }
예제 #32
0
        private void AddRepeatedInspections(PipeTestResult pipeTestResult)
        {
            if (pipeTestResult.Status != PipeTestResultStatus.Accepted
                    && pipeTestResult.Status != PipeTestResultStatus.Scheduled)
            {
                var insp = (List<Inspector>)viewModel.listOfInspectors.Where(_ => _.Key == pipeTestResult.Operation.Code).FirstOrDefault().Value;
                List<Inspector> inspectors = new List<Inspector>();
                if (insp != null)
                {
                    inspectors.AddRange(insp);
                }
                viewModel.PipeTestResults.Add(new PipeTestResult()
                {
                    Pipe = viewModel.Pipe,
                    Status = PipeTestResultStatus.Scheduled,
                    Operation = pipeTestResult.Operation,
                    Order = viewModel.PipeTestResultsMaxOrder()+1,
                    Inspectors = inspectors
                });

                foreach (var operation in pipeTestResult.Operation.RepeatedInspections.Where<PipeTest>(x => x.IsActive))
                {
                    if (!viewModel.PipeTestResults.Any<PipeTestResult>(x => x.Operation.Code == operation.Code
                            && x.Status == PipeTestResultStatus.Scheduled))
                    {
                        var repeatedInsp = (List<Inspector>)viewModel.listOfInspectors.Where(_ => _.Key == operation.Code).FirstOrDefault().Value;
                        List<Inspector> repeatedInspectors = new List<Inspector>();
                        if (repeatedInsp != null)
                        {
                            repeatedInspectors.AddRange(repeatedInsp);
                        }

                        viewModel.PipeTestResults.Add(new PipeTestResult()
                        {
                            Pipe = viewModel.Pipe,
                            Status = PipeTestResultStatus.Scheduled,
                            Operation = operation,
                            Order = viewModel.PipeTestResultsMaxOrder() + 1,
                            Inspectors = repeatedInspectors
                        });
                    }
                }
            }
        }
예제 #33
0
        private InspectionAddEditXtraForm GetInspectionForm(
            BindingList<PipeTest> tests,
            IList<Inspector> inspectors,
            PipeTestResult row,
            IList<EnumWrapper<PipeTestResultStatus>> statuses,
            bool isNew,
            List<KeyValuePair<string, object>> listOfInspectors = null)
        {
            if(inspectionForm == null)
            {
                inspectionForm = new InspectionAddEditXtraForm(tests, inspectors, row, statuses, viewModel.PipeTestResults, isNew, viewModel.listOfInspectors);
            }
            else
            {
                inspectionForm.SetupForm(tests, inspectors, row, statuses, viewModel.PipeTestResults, isNew, listOfInspectors);
            }

            return inspectionForm;
        }
예제 #34
0
        private void EditInspections(BindingList<PipeTest> tests, PipeTestResult row, IList<Inspector> insp, BindingList<EnumWrapper<PipeTestResultStatus>> status)
        {
            if (IsEditMode)
            {
                if (row.Status == PipeTestResultStatus.Scheduled)
                {
                    int index = viewModel.listOfInspectors.IndexOf(new KeyValuePair<string, object>(row.Operation.Code, row.Inspectors));

                    var editForm = GetInspectionForm(tests, insp, row, status, false, viewModel.listOfInspectors);
                    row.Order = viewModel.PipeTestResultsMaxOrder();
                    editForm.ShowDialog();
                    IsModified = true;
                    inspections.RefreshDataSource();
                    viewModel.GetLengthFromOperation();
                    pipeLength.Refresh();
                    weight.Refresh();

                    if (index >= 0 && index < viewModel.listOfInspectors.Count())
                    {
                        viewModel.listOfInspectors.RemoveAt(index);
                    }
                    
                    viewModel.listOfInspectors.
                        Add(new KeyValuePair<string, object>(row.Operation.Code, row.Inspectors));

                    AddRepeatedInspections(row);

                }
                else
                {
                    Program.MainForm.ShowInfo
                        (Program.LanguageManager.GetString(StringResources.InspectionAddEditXtraForm_InspectionTestCompleted),
                        Program.LanguageManager.GetString(StringResources.InspectionAddEditXtraForm_InspectionTestCompletedHeader));
                }
            }

            if (viewModel != null)
            {
                viewModel.CheckStatus();
            }
        }
        private InspectionAddEditXtraForm GetInspectionForm(
            BindingList<PipeTest> tests,
            IList<Inspector> inspectors,
            PipeTestResult row,
            IList<EnumWrapper<PipeTestResultStatus>> statuses)
        {
            if(inspectionForm == null)
            {
                inspectionForm = new InspectionAddEditXtraForm(tests, inspectors, row, statuses, viewModel.PipeTestResults);
            }
            else
            {
                inspectionForm.SetupForm(tests, inspectors, row, statuses, viewModel.PipeTestResults);
            }

            return inspectionForm;
        }
        private void AddRepeatedInspections(PipeTestResult pipeTestResult)
        {
            if (pipeTestResult.Status != PipeTestResultStatus.Accepted
                    && pipeTestResult.Status != PipeTestResultStatus.Scheduled)
            {
                viewModel.PipeTestResults.Add(new PipeTestResult()
                {
                    Pipe = viewModel.Pipe,
                    Status = PipeTestResultStatus.Scheduled,
                    Operation = pipeTestResult.Operation,
                    Order = viewModel.PipeTestResultsMaxOrder()+1
                });

                foreach (var operation in pipeTestResult.Operation.RepeatedInspections.Where<PipeTest>(x => x.IsActive))
                {
                    if (!viewModel.PipeTestResults.Any<PipeTestResult>(x => x.Operation.Code == operation.Code
                            && x.Status == PipeTestResultStatus.Scheduled))
                    {
                        viewModel.PipeTestResults.Add(new PipeTestResult()
                        {
                            Pipe = viewModel.Pipe,
                            Status = PipeTestResultStatus.Scheduled,
                            Operation = operation,
                            Order = viewModel.PipeTestResultsMaxOrder() + 1
                        });
                    }
                }
            }
        }
예제 #37
0
        public InspectionAddEditXtraForm(IList <PipeTest> tests, IList <Inspector> inspectors, PipeTestResult current, IList <EnumWrapper <PipeTestResultStatus> > statuses)
        {
            InitializeComponent();

            this.SetupForm(tests, inspectors, current, statuses);
        }
 /// <summary>
 /// Creates predefined pipe test result for all active required availableTests for concrete pipe mill size type
 /// </summary>
 /// <param name="millSizeType"></param>
 public BindingList<PipeTestResult> GetRequired(PipeMillSizeType millSizeType)
 {
     BindingList<PipeTestResult> requiredTestResults = new BindingList<PipeTestResult>();
     var criteria = NHibernate.Criterion.DetachedCriteria
         .For<PipeTest>()
         .Add(Restrictions.Eq("FrequencyType", InspectionFrequencyType.R))
         .Add(Restrictions.Eq("pipeType", millSizeType))
         .Add(Restrictions.Eq("IsActive", true));
     IList<PipeTest> requiredTests = repoMill.RepoPipeTest.GetByCriteria(criteria);
     GetAvailableTests();
     foreach(var requiredTest in requiredTests)
     {
         PipeTestResult requiredResult = new PipeTestResult()
         {
             Operation = requiredTest,
             IsActive = true,
             Status = PipeTestResultStatus.Scheduled,
             Pipe = Pipe,
             Inspectors = new BindingList<Prizm.Domain.Entity.Inspector>()
         };
         requiredTestResults.Add(requiredResult);
         requiredResult.Order++;
     }
     return requiredTestResults;
 }
예제 #39
0
        private bool SeedOptional()
        {
            firstSetupRepo.BeginTransaction();
            #region PlateManufacturers
            PlateManufacturer[] plateManufacturers =
            {
                new PlateManufacturer {
                    Name = "Алапаевский металлургический завод", IsActive = true
                },
                new PlateManufacturer {
                    Name = "Альметьевский трубный завод", IsActive = true
                },
                new PlateManufacturer {
                    Name = "Борский трубный завод", IsActive = true
                },
                new PlateManufacturer {
                    Name = "Волжский трубный завод", IsActive = true
                },
                new PlateManufacturer {
                    Name = "Волгоградский трубный завод", IsActive = true
                },
                new PlateManufacturer {
                    Name = "Гурьевский металлургический завод", IsActive = true
                },
                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)),
                    ToExport       = true,
                    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 % 4 == 0)
                {
                    foreach (var item in pipe.PipeTestResult)
                    {
                        item.Status = PipeTestResultStatus.Passed;
                    }
                    pipe.Status             = PipeMillStatus.Stocked;
                    pipe.ConstructionStatus = PartConstructionStatus.Pending;
                    pipe.IsAvailableToJoint = true;
                }


                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);
        }