Inheritance: System.Item
Exemple #1
0
      public JointObject(Joint joint)
      {
         this.Id = joint.Id;
         this.IsActive = joint.IsActive;
         this.Number = joint.Number;
         this.NumberKP = joint.NumberKP;
         this.DistanceFromKP = joint.DistanceFromKP;

         if (joint.LoweringDate != null && joint.LoweringDate.HasValue)
         {
            this.LoweringDate = joint.LoweringDate.Value;
         }

         this.Status = joint.Status;
         this.GpsLatitude = joint.GpsLatitude;
         this.GpsLongitude = joint.GpsLongitude;
         this.GpsHeight = joint.GpsHeight;
         this.FirstElement = joint.FirstElement;
         this.SecondElement = joint.SecondElement;

         if (joint.Attachments != null)
         {
            Attachments = new List<FileObject>();
            foreach (var file in joint.Attachments)
            {
               Attachments.Add(new FileObject(file));
            }
         }
      }
        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());


            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;

            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());
        }
Exemple #3
0
        public void AddJointEdge(construct.Joint joint)
        {
            JointEdge jointEdge = new JointEdge(joint);

            try
            {
                if (piecesVertex.ContainsKey(joint.FirstElement.Id) &&
                    piecesVertex.ContainsKey(joint.SecondElement.Id))
                {
                    jointEdge.PartsVertex.Add(piecesVertex[joint.FirstElement.Id]);
                    jointEdge.PartsVertex.Add(piecesVertex[joint.SecondElement.Id]);

                    piecesVertex[joint.FirstElement.Id].JointsEdge.Add(jointEdge);
                    piecesVertex[joint.SecondElement.Id].JointsEdge.Add(jointEdge);
                }
                else
                {
                    log.Warn(string.Format("The one of requested keys is not in the dictionary of welded parts. Joint #{0}, id:{1}", joint.Number, joint.Id));
                }
            }
            catch (NullReferenceException e)
            {
                log.Error(
                    string.Format("Unable to add the joint #{0}, id:{1} as edge of the pipeline.",
                                  joint.Number, joint.Id));

                throw e;
            }
        }
 private void editButton_Click(object sender, EventArgs e)
 {
     construction.Joint selectedJoint = resultsGridView.GetRow(resultsGridView.FocusedRowHandle) as construction.Joint;
     if (selectedJoint != null)
     {
         viewModel.ChangeJoint(selectedJoint);
     }
     this.Close();
 }
Exemple #5
0
        private string GetWeldDate(construct.Joint joint)
        {
            string strDate = string.Empty;

            var weldResults = joint.JointWeldResults;

            if (weldResults.Count > 0)
            {
                strDate = weldResults.First().Date.Value.ToShortDateString();
            }

            return(strDate);
        }
Exemple #6
0
        public List <PipelineVertex> RemovalExternalComponents(
            construct.Joint startJoint,
            construct.Joint endJoint,
            List <PipelineVertex> path)
        {
            var joints = new construct.Joint[] { startJoint, endJoint };

            var parts = new PipelineVertex[] { path.First(), path.Last() };

            foreach (var part in parts)
            {
                if (part.JointsEdge.Count == 1)
                {
                    path.Remove(part);
                }
                else
                {
                    foreach (var jointEdge in part.JointsEdge)
                    {
                        if (!joints.Contains <construct.Joint>(jointEdge.Data))
                        {
                            foreach (var p in jointEdge.PartsVertex)
                            {
                                if (p != part &&
                                    !path.Contains <PipelineVertex>(p) &&
                                    path.Contains <PipelineVertex>(part))
                                {
                                    path.Remove(part);
                                }
                            }
                        }
                    }
                }
            }

            return(path);
        }
Exemple #7
0
        private void PipelineTracing()
        {
            try
            {
                usedProductList = new List <PartData>();
                if (joints == null)
                {
                    this.joints = repoJoint.GetJointsForTracing().ToList <construct.Joint>();
                    if (this.joints == null || this.joints.Count <= 0)
                    {
                        log.Warn("Report at Construction: List of Joints is NULL or empty.");
                    }
                }
                if (partDataList == null)
                {
                    var data = repo.GetPipelineElements(SQLProvider.GetQuery(SQLProvider.SQLStatic.GetWeldedParts).ToString());
                    if (data == null || data.Rows.Count <= 0)
                    {
                        log.Warn("Report at Construction: Data Table of Pieces is NULL or empty.");
                    }

                    this.partDataList = this.FormWeldedParts(data);
                }

                graph           = new PipelineGraph(partDataList.Count);
                tracingDataList = new List <TracingData>();

                if (partDataList != null)
                {
                    foreach (var partData in partDataList)
                    {
                        graph.AddPipelineVertex(partData);
                    }
                    foreach (var joint in this.joints)
                    {
                        graph.AddJointEdge(joint);
                    }

                    construct.Joint startJoint = null;
                    construct.Joint endJoint   = null;

                    if (viewModel.TracingMode == TracingModeEnum.TracingByKP &&
                        viewModel.AllKP.Contains(viewModel.StartPK) &&
                        viewModel.AllKP.Contains(viewModel.EndPK))
                    {
                        startJoint = joints.First <construct.Joint>(
                            x => x.NumberKP == viewModel.StartPK && x.DistanceFromKP == joints
                            .Where <construct.Joint>(y => y.NumberKP == viewModel.StartPK)
                            .Min <construct.Joint>(z => z.DistanceFromKP));

                        endJoint = joints.Last <construct.Joint>(
                            x => x.NumberKP == viewModel.EndPK && x.DistanceFromKP == joints
                            .Where <construct.Joint>(y => y.NumberKP == viewModel.EndPK)
                            .Max <construct.Joint>(z => z.DistanceFromKP));
                    }

                    if (endJoint == null && startJoint == null)
                    {
                        startJoint = joints.First <construct.Joint>(x => x.Id == viewModel.StartJoint.Id);
                        endJoint   = joints.First <construct.Joint>(x => x.Id == viewModel.EndJoint.Id);
                    }

                    var paths = graph.Pathfinder(startJoint.FirstElement, endJoint.FirstElement);

                    if (paths.Count != 0)
                    {
                        path = graph.ShortestPath(paths);

                        path = graph.RemovalExternalComponents(startJoint, endJoint, path);

                        for (int i = path.Count - 1; i > 0; --i)
                        {
                            var tracingDataItem = new TracingData(path[i].Data, path[i - 1].Data);

                            var commonJoint = path[i].GetCommonJoint(path[i - 1]);

                            tracingDataItem.JointNumber = commonJoint.Data.Number;
                            tracingDataItem.WeldingDate = GetWeldDate(commonJoint.Data);

                            tracingDataList.Add(tracingDataItem);
                        }

                        for (int i = 0; i < path.Count; ++i)
                        {
                            usedProductList.Add(path[i].Data);
                        }

                        PartData firstElement = partDataList.Where(_ => _.Id == startJoint.FirstElement.Id).FirstOrDefault();

                        PartData secondElement = partDataList.Where(_ => _.Id == endJoint.SecondElement.Id).FirstOrDefault();

                        var firstTracingDataItem = new TracingData(firstElement, path.Last().Data);
                        firstTracingDataItem.JointNumber = startJoint.Number;
                        firstTracingDataItem.WeldingDate = GetWeldDate(startJoint);
                        tracingDataList.Insert(0, firstTracingDataItem);

                        usedProductList.Add(firstElement);

                        var lastTracingDataItem = new TracingData(path.First().Data, secondElement);
                        lastTracingDataItem.JointNumber = endJoint.Number;
                        lastTracingDataItem.WeldingDate = GetWeldDate(endJoint);
                        tracingDataList.Add(lastTracingDataItem);

                        usedProductList.Add(secondElement);

                        PipelineLenghtCalculation();
                    }
                }
                else
                {
                    log.Warn(string.Format("List of Pipeline elements is NULL for construction report type: {0}", viewModel.ReportType));
                }
            }
            catch (RepositoryException ex)
            {
                log.Warn(this.GetType().Name + " | " + ex.ToString());
                notify.ShowWarning(Program.LanguageManager.GetString(StringResources.Notification_Error_Db_Message),
                                   Program.LanguageManager.GetString(StringResources.Notification_Error_Db_Header));
            }
        }
Exemple #8
0
 public JointEdge(construct.Joint data)
 {
     Data        = data;
     PartsVertex = new List <PipelineVertex>();
 }
Exemple #9
0
        public List<PipelineVertex> RemovalExternalComponents(
            construct.Joint startJoint,
            construct.Joint endJoint,
            List<PipelineVertex> path)
        {
            var joints = new construct.Joint[] { startJoint, endJoint };

            var parts = new PipelineVertex[] { path.First(), path.Last() };

            foreach (var part in parts)
            {
                if (part.JointsEdge.Count == 1)
                {
                    path.Remove(part);
                }
                else
                {
                    foreach (var jointEdge in part.JointsEdge)
                    {
                        if (!joints.Contains<construct.Joint>(jointEdge.Data))
                        {
                            foreach (var p in jointEdge.PartsVertex)
                            {
                                if (p != part
                                    && !path.Contains<PipelineVertex>(p)
                                    && path.Contains<PipelineVertex>(part))
                                {
                                    path.Remove(part);
                                }
                            }
                        }
                    }
                }
            }

            return path;
        }
        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());
        }