public AddPipelineVertex ( Prizm.Domain.Entity.Construction partData ) : void | ||
partData | Prizm.Domain.Entity.Construction | |
리턴 | void |
private void PipelineTracing() { graph = new PipelineGraph(viewModel.PartDataList.Count); tracingDataList = new List <TracingData>(); if (viewModel.PartDataList != null) { foreach (var partData in viewModel.PartDataList) { graph.AddPipelineVertex(partData); } foreach (var joint in viewModel.Joints) { graph.AddJointEdge(joint); } var paths = graph.Pathfinder( viewModel.StartJoint.FirstElement, viewModel.EndJoint.FirstElement); if (paths.Count != 0) { path = graph.ShortestPath(paths); path = graph.RemovalExternalComponents( viewModel.StartJoint, viewModel.EndJoint, path); for (int i = path.Count - 1; i > 0; --i) { var tracingDataItem = new TracingData() { FirstPartNumber = path[i].Data.Number, FirstPartTypeDescription = path[i].Data.PartTypeDescription, FirstPartLength = path[i].Data.Length, SecondPartNumber = path[i - 1].Data.Number, SecondPartTypeDescription = path[i - 1].Data.PartTypeDescription, SecondPartLength = path[i - 1].Data.Length }; var commonJoint = path[i].GetCommonJoint(path[i - 1]); tracingDataItem.JointNumber = commonJoint.Data.Number; tracingDataItem.WeldingDate = commonJoint.Data .JointWeldResults.First().Date.Value.ToShortDateString(); tracingDataList.Add(tracingDataItem); } PipelineLenghtCalculation(); } } else { log.Warn(string.Format("List of Pipeline elements is NULL for construction report type: {0}", viewModel.ReportType)); } }
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)); } }
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)); } }