コード例 #1
0
        private bool rapairOperationValidator(object sender, DevExpress.XtraGrid.Views.Base.ValidateRowEventArgs e)
        {
            GridView        gv = sender as GridView;
            JointWeldResult jointWeldResult = gv.GetRow(e.RowHandle) as JointWeldResult;

            if (jointWeldResult.Operation == null)
            {
                gv.SetColumnError(repairTypeGridColumn, Program.LanguageManager.GetString(StringResources.Validation_ValueRequired));
                e.Valid = false;
            }
            else if (jointWeldResult.Date == null)
            {
                gv.SetColumnError(repairDateGridColumn, Program.LanguageManager.GetString(StringResources.Validation_ValueRequired));
                e.Valid = false;
            }
            else if (jointWeldResult.Operation.Type == JointOperationType.Weld && jointWeldResult.Welders.Count == 0)
            {
                gv.SetColumnError(weldersGridColumn, Program.LanguageManager.GetString(StringResources.Validation_ValueRequired));
                e.Valid = false;
            }
            else if (!jointWeldResult.IsCompleted)
            {
                gv.SetColumnError(completedGridColumn, Program.LanguageManager.GetString(StringResources.Validation_ValueRequired));
                e.Valid = false;
            }
            return(e.Valid);
        }
コード例 #2
0
        private void repairOperationsView_InitNewRow(object sender, InitNewRowEventArgs e)
        {
            GridView view = sender as GridView;

            if (view.IsValidRowHandle(e.RowHandle))
            {
                currentJointWeldResult          = view.GetRow(e.RowHandle) as JointWeldResult;
                currentJointWeldResult.IsActive = true;
                currentJointWeldResult.Joint    = viewModel.Joint;
                viewModel.Joint.JointWeldResults.Add(currentJointWeldResult);
            }
        }
コード例 #3
0
        private void weldersPopupContainerEdit_Popup(object sender, EventArgs e)
        {
            repairOperationsView.ClearSelection();

            if (repairOperationsView.IsValidRowHandle(repairOperationsView.FocusedRowHandle))
            {
                JointWeldResult jointWeldResult = repairOperationsView.GetRow(repairOperationsView.FocusedRowHandle) as JointWeldResult;
                if (jointWeldResult != null)
                {
                    weldersSelectionControl.SelectWelders(jointWeldResult.Welders);
                }
            }
        }
コード例 #4
0
        private void weldersPopupContainerEdit_CloseUp(object sender, CloseUpEventArgs e)
        {
            if (repairOperationsView.IsValidRowHandle(repairOperationsView.FocusedRowHandle))
            {
                IList <Welder>  selectedWelders = weldersSelectionControl.SelectedWelders;
                JointWeldResult jointWeldResult = repairOperationsView.GetRow(repairOperationsView.FocusedRowHandle) as JointWeldResult;

                if (jointWeldResult != null)
                {
                    jointWeldResult.Welders.Clear();
                    foreach (Welder w in selectedWelders)
                    {
                        jointWeldResult.Welders.Add(w);
                    }
                }
            }
        }
コード例 #5
0
        private void weldersPopupContainerEdit_QueryPopUp(object sender, CancelEventArgs e)
        {
            JointWeldResult weld =
                repairOperationsView.GetRow(repairOperationsView.FocusedRowHandle) as JointWeldResult;

            if (weld == null || (weld != null && weld.Date == null))
            {
                repairOperationsView.SetColumnError(
                    repairOperationsView.VisibleColumns[1],
                    Program.LanguageManager.GetString(StringResources.DateFirst));

                e.Cancel = true;
            }
            else
            {
                weldersSelectionControl.weldDate = weld.Date ?? DateTime.Now.Date;
            }
        }
コード例 #6
0
        private void repairOperationsView_ValidateRow(object sender, DevExpress.XtraGrid.Views.Base.ValidateRowEventArgs e)
        {
            GridView        gv = sender as GridView;
            JointWeldResult jointWeldResult = gv.GetRow(e.RowHandle) as JointWeldResult;

            if (jointWeldResult.Operation == null)
            {
                gv.SetColumnError(repairTypeGridColumn, Program.LanguageManager.GetString(StringResources.Validation_ValueRequired));
                e.Valid = false;
            }
            if (jointWeldResult.Date == null)
            {
                gv.SetColumnError(repairDateGridColumn, Program.LanguageManager.GetString(StringResources.Validation_ValueRequired));
                e.Valid = false;
            }
            if (jointWeldResult.Operation.Type == JointOperationType.Weld && jointWeldResult.Welders.Count == 0)
            {
                gv.SetColumnError(weldersGridColumn, Program.LanguageManager.GetString(StringResources.Validation_ValueRequired));
                e.Valid = false;
            }
            jointStatus.EditValue = viewModel.JointConstructionStatus;
        }
コード例 #7
0
        public IList <Joint> GetJointsForTracing()
        {
            try
            {
                JointWeldResult weldResult = null;
                JointTestResult testResult = null;
                List <Welder>   welders    = null;

                return
                    (session.QueryOver <Joint>()
                     .Where(x => x.IsActive == true && x.FirstElement != null && x.SecondElement != null && x.Status != JointStatus.Withdrawn)
                     .JoinAlias(j => j.JointWeldResults, () => weldResult, JoinType.LeftOuterJoin)
                     .JoinAlias(() => weldResult.Welders, () => welders, JoinType.LeftOuterJoin)
                     .JoinAlias(j => j.JointTestResults, () => testResult, JoinType.LeftOuterJoin)
                     .TransformUsing(Transformers.DistinctRootEntity)
                     .List <Joint>());
            }
            catch (GenericADOException ex)
            {
                throw new RepositoryException("GetJointsForTracing", ex);
            }
        }
コード例 #8
0
        public void TestJointNewEdit()
        {
            var modifiableView      = new Mock <IModifiable>();
            var notify              = new Mock <IUserNotify>();
            var repoJoint           = new Mock <IJointRepository>();
            var repoJointTestResult = new Mock <IJointTestResultRepository>();
            var repoJointWeldResult = new Mock <IJointWeldResultRepository>();
            var repoJointOperation  = new Mock <IJointOperationRepository>();
            var repoInspector       = new Mock <IInspectorRepository>();
            var repoWelder          = new Mock <IWelderRepository>();
            var repoAdo             = new Mock <IMillReportsRepository>();
            var securityCtx         = new Mock <ISecurityContext>();
            var repoSpool           = new Mock <ISpoolRepository>();
            var repoPipe            = new Mock <IPipeRepository>();
            var repoComponent       = new Mock <IComponentRepository>();

            var joint = new Prizm.Domain.Entity.Construction.Joint()
            {
                Status = Domain.Entity.Construction.JointStatus.Withdrawn
            };
            BindingList <JointOperation> operations = new BindingList <JointOperation>();

            Mock <IConstructionRepository> repoConstruction = new Mock <IConstructionRepository>();

            repoConstruction.SetupGet(_ => _.RepoJoint).Returns(repoJoint.Object);
            repoConstruction.SetupGet(_ => _.RepoJointTestResult).Returns(repoJointTestResult.Object);
            repoConstruction.SetupGet(_ => _.RepoJointWeldResult).Returns(repoJointWeldResult.Object);
            repoConstruction.SetupGet(_ => _.RepoJointOperation).Returns(repoJointOperation.Object);
            repoConstruction.SetupGet(_ => _.RepoInspector).Returns(repoInspector.Object);
            repoConstruction.SetupGet(_ => _.RepoWelder).Returns(repoWelder.Object);
            repoConstruction.SetupGet(_ => _.RepoSpool).Returns(repoSpool.Object);
            repoConstruction.SetupGet(_ => _.RepoPipe).Returns(repoPipe.Object);
            repoConstruction.SetupGet(_ => _.RepoComponent).Returns(repoComponent.Object);
            repoJointOperation.Setup(_ => _.GetControlOperations()).Returns(operations);
            repoJointOperation.Setup(_ => _.GetRepairOperations()).Returns(operations);
            repoJoint.Setup(_ => _.GetActiveByNumber(joint)).Returns(new List <Prizm.Domain.Entity.Construction.Joint>());
            repoSpool.Setup(_ => _.Get(It.IsAny <Guid>())).Returns(new Domain.Entity.Construction.Spool());
            repoAdo.Setup(x => x.GetPipelineElements()).Returns(new System.Data.DataTable());

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

            var viewModel = new JointNewEditViewModel(repoConstruction.Object, notify.Object, Guid.Empty, repoAdo.Object, securityCtx.Object);

            viewModel.Joint          = joint;
            viewModel.FirstElement   = new PartData();
            viewModel.SecondElement  = new PartData();
            viewModel.ModifiableView = modifiableView.Object;
            var validatable = new Mock <IValidatable>();

            validatable.Setup(x => x.Validate()).Returns(true);
            viewModel.ValidatableView    = validatable.Object;
            viewModel.Joint.LoweringDate = DateTime.Now;
            viewModel.Joint.Number       = string.Empty;

            var welder     = new Welder();
            var weldResult = new JointWeldResult();

            weldResult.Welders.Add(welder);
            weldResult.IsCompleted = true;

            viewModel.JointWeldResults.Add(weldResult);


            var command = new SaveJointCommand(repoConstruction.Object, viewModel, notify.Object, securityCtx.Object);

            command.Execute();
            repoConstruction.Verify(_ => _.BeginTransaction(), Times.Once());
            repoJoint.Verify(_ => _.SaveOrUpdate(It.IsAny <Prizm.Domain.Entity.Construction.Joint>()), Times.Once());
            repoConstruction.Verify(_ => _.Commit(), Times.Once());
            repoJoint.Verify(_ => _.Evict(It.IsAny <Prizm.Domain.Entity.Construction.Joint>()), Times.Once());
        }