/// <summary> /// /// </summary> /// <param name="ErrorPriorityArray"></param> /// <param name="ErrorMessageArray"></param> public void Validate(out string[] ErrorPriorityArray, out string[] ErrorMessageArray) { ErrorPriorityArray = null; ErrorMessageArray = null; string activeFeatureState = null; short numberofNodes = 0; int node1 = 0; int node2 = 0; string errorPriorityUnconnected = Convert.ToString(Arguments.GetArgument(0)); string errorPrioritySelf = Convert.ToString(Arguments.GetArgument(1)); string errorPrioritySharedOwner = Convert.ToString(Arguments.GetArgument(2)); ValidationRuleManager validateMsg = new ValidationRuleManager(); object[] messArguments = new object[1]; List <string> errorMessage = new List <string>(); List <string> errorPriority = new List <string>(); IGTKeyObject activeFeature = GTClassFactory.Create <IGTKeyObject>(); IGTKeyObjects relatedFeatures = GTClassFactory.Create <IGTKeyObjects>(); IGTGeometry primaryGeometry = null; GTValidationLogger gTValidationLogger = null; IGTComponent comp = Components[ComponentName]; int FID = 0; string fieldValue = string.Empty; if (comp != null && comp.Recordset != null && comp.Recordset.RecordCount > 0) { FID = int.Parse(comp.Recordset.Fields["G3E_FID"].Value.ToString()); fieldValue = Convert.ToString(comp.Recordset.Fields[FieldName].Value); } if (new gtLogHelper().CheckIfLoggingIsEnabled()) { LogEntries logEntries = new LogEntries { ActiveComponentName = ComponentName, ActiveFID = FID, ActiveFieldName = FieldName, ActiveFieldValue = fieldValue, JobID = DataContext.ActiveJob, RelatedComponentName = "N/A", RelatedFID = 0, RelatedFieldName = "N/A", RelatedFieldValue = "N/A", ValidationInterfaceName = "Connectivity Validation", ValidationInterfaceType = "FI", }; gTValidationLogger = new GTValidationLogger(logEntries); gTValidationLogger.LogEntry("TIMING", "START", "Connectivity Validation Entry", "N/A", ""); } GTClassFactory.Create <IGTApplication>().SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, "ConnectionValidation FI Started"); try { activeFeature = DataContext.OpenFeature(Convert.ToInt16(Components[ComponentName].Recordset.Fields[ATTRIB_FNO].Value), Convert.ToInt32(Components[ComponentName].Recordset.Fields[ATTRIB_FID].Value)); if (CheckValidFeatures(activeFeature.FNO)) { relatedFeatures = GetRelatedFeatures(activeFeature, cRNO); GetNumberOfNodes(activeFeature, ref numberofNodes); GetPrimaryGeometry(activeFeature, ref primaryGeometry); /*Gets active Feature attributes*/ if (activeFeature.Components.GetComponent(cCNO).Recordset.RecordCount > 0) { activeFeature.Components.GetComponent(cCNO).Recordset.MoveFirst(); node1 = Convert.ToInt32(activeFeature.Components.GetComponent(cCNO).Recordset.Fields[ATTRIB_NODE1].Value == DBNull.Value ? 0 : activeFeature.Components.GetComponent(cCNO).Recordset.Fields[ATTRIB_NODE1].Value); node2 = Convert.ToInt32(activeFeature.Components.GetComponent(cCNO).Recordset.Fields[ATTRIB_NODE2].Value == DBNull.Value ? 0 : activeFeature.Components.GetComponent(cCNO).Recordset.Fields[ATTRIB_NODE2].Value); activeFeature.Components.GetComponent(oCNO).Recordset.MoveFirst(); activeFeatureState = Convert.ToString(activeFeature.Components.GetComponent(oCNO).Recordset.Fields[ATTRIB_FEATURE_STATE].Value); } //Feature in Feature State in (PPI, PPR, PPA, INI, CLS, ABI, ABR) must be connected. if (CheckFeatureState(activeFeatureState) && CheckNotOwnedByPrimarySwitchGear(activeFeature)) { if ((numberofNodes == 1 && node1 == 0 && node2 == 0) || (numberofNodes == 2 && (node1 == 0 || node2 == 0))) { messArguments[0] = activeFeatureState; validateMsg.Rule_Id = "CONN01"; validateMsg.BuildRuleMessage(GTClassFactory.Create <IGTApplication>(), messArguments); errorMessage.Add(validateMsg.Rule_MSG); errorPriority.Add(errorPriorityUnconnected); } } //Feature may not be connected to itself. if ((numberofNodes == 2) && node1 != 0 && node1 == node2) { validateMsg.Rule_Id = "CONN02"; validateMsg.BuildRuleMessage(GTClassFactory.Create <IGTApplication>(), null); errorMessage.Add(validateMsg.Rule_MSG); errorPriority.Add(errorPrioritySelf); } // Feature is a point feature and feature owner not in the set of connected owners if (primaryGeometry != null && primaryGeometry.Type == "OrientedPointGeometry") { int noMatchingOwnerCnt = 0; GetActiveAndRelatedFeaturesOwners(activeFeature, relatedFeatures, ref noMatchingOwnerCnt); for (int i = 1; i <= noMatchingOwnerCnt; i++) { validateMsg.Rule_Id = "CONN03"; validateMsg.BuildRuleMessage(GTClassFactory.Create <IGTApplication>(), null); errorMessage.Add(validateMsg.Rule_MSG); errorPriority.Add(errorPrioritySharedOwner); } } //Feature is a Service Line and not connected to exactly one Service Point if (activeFeature.FNO == 54)//FNO == 54, is Service Line { int count = 0; for (int i = 0; i < relatedFeatures.Count; i++) { if (relatedFeatures[i].FNO == 55) //FNO == 55, is Service Point FNO { count++; } } if (count != 1) { validateMsg.Rule_Id = "CONN04"; validateMsg.BuildRuleMessage(GTClassFactory.Create <IGTApplication>(), null); errorMessage.Add(validateMsg.Rule_MSG); errorPriority.Add(errorPriorityUnconnected); } } //Feature is a Primary Conductor Node or Secondary Conductor Node and Type = DEAD END and not connected to exactly one other feature if (activeFeature.FNO == 10 || activeFeature.FNO == 162) //FNO == 10, is Primary Conductor Node; FNO == 162, is Secondary Conductor Node { string conductorNodeType = GetConductorNodeType(activeFeature); string relatedFeatureState = string.Empty; IGTKeyObjects oKeyObjects = GTClassFactory.Create <IGTKeyObjects>(); if (!String.IsNullOrEmpty(conductorNodeType)) { if (conductorNodeType.ToUpper() == "DEADEND") { int iCount = 0; foreach (IGTKeyObject item in relatedFeatures) { //Check if the related feature belong to valid feature state item.Components.GetComponent(oCNO).Recordset.MoveFirst(); //This is common component recordset so no harm in moving to first relatedFeatureState = Convert.ToString(item.Components.GetComponent(oCNO).Recordset.Fields["FEATURE_STATE_C"].Value); if (relatedFeatureState.Equals("PPI") || relatedFeatureState.Equals("ABI") || relatedFeatureState.Equals("PPX") || relatedFeatureState.Equals("ABX") || relatedFeatureState.Equals("INI") || relatedFeatureState.Equals("CLS")) { iCount = iCount + 1; } } if (iCount > 1 && (activeFeatureState.Equals("PPI") || activeFeatureState.Equals("ABI") || activeFeatureState.Equals("INI") || activeFeatureState.Equals("CLS"))) { validateMsg.Rule_Id = "CONN05"; validateMsg.BuildRuleMessage(GTClassFactory.Create <IGTApplication>(), null); errorMessage.Add(validateMsg.Rule_MSG); errorPriority.Add(errorPriorityUnconnected); } } } } //Feature is a Street Light and Owner Type = COMPANY and not connected. if (activeFeature.FNO == 56) { activeFeature.Components.GetComponent(oCNO).Recordset.MoveFirst(); string ownerType = Convert.ToString(activeFeature.Components.GetComponent(oCNO).Recordset.Fields["OWNED_TYPE_C"].Value); if (!String.IsNullOrEmpty(ownerType)) { if (ownerType.ToUpper() == "COMPANY" && node1 == 0 && node2 == 0) { validateMsg.Rule_Id = "CONN06"; validateMsg.BuildRuleMessage(GTClassFactory.Create <IGTApplication>(), null); errorMessage.Add(validateMsg.Rule_MSG); errorPriority.Add(errorPriorityUnconnected); } } } //Removal of this feature will cause downstream features to be disconnected. if (numberofNodes == 2 && CheckForRemovalActiveFeatureState(activeFeatureState)) //Active feature Feature State in (PPR, PPA, ABR, ABA) { List <IGTKeyObject> loadFeatures = new List <IGTKeyObject>(); List <IGTKeyObject> sharedLoadFeatures = new List <IGTKeyObject>(); List <IGTKeyObject> parallelFeatures = new List <IGTKeyObject>(); ConnectivityFactory oFactory = new ConnectivityHelperFactory(); GetLoadsFeatures(ref loadFeatures, activeFeature, oFactory); GetSharedLoadsFeatures(ref sharedLoadFeatures, activeFeature, oFactory); GetParallelFeatures(ref parallelFeatures, activeFeature, oFactory); if (loadFeatures.Count > 0 && sharedLoadFeatures.Count == 0 && parallelFeatures.Count == 0) //Affected feature has one or more “loads” and Affected features has zero “parallel sources” { validateMsg.Rule_Id = "CONN07"; validateMsg.BuildRuleMessage(GTClassFactory.Create <IGTApplication>(), null); errorMessage.Add(validateMsg.Rule_MSG); errorPriority.Add(errorPriorityUnconnected); } } if (errorMessage.Count > 0) { ErrorPriorityArray = errorPriority.ToArray(); ErrorMessageArray = errorMessage.ToArray(); } GTClassFactory.Create <IGTApplication>().SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, "ConnectionValidation FI Completed"); if (gTValidationLogger != null) { gTValidationLogger.LogEntry("TIMING", "END", "Connectivity Validation Exit", "N/A", ""); } } } catch (Exception ex) { throw new Exception("Error from Connection Validation FI: " + ex.Message); } }
/// <summary> /// Validate /// </summary> /// <param name="ErrorPriorityArray"></param> /// <param name="ErrorMessageArray"></param> public void Validate(out string[] ErrorPriorityArray, out string[] ErrorMessageArray) { GTValidationLogger gTValidationLogger = null; IGTComponent comp = Components[ComponentName]; int FID = 0; string fieldValue = string.Empty; if (comp != null && comp.Recordset != null && comp.Recordset.RecordCount > 0) { FID = int.Parse(comp.Recordset.Fields["G3E_FID"].Value.ToString()); fieldValue = Convert.ToString(comp.Recordset.Fields[FieldName].Value); } if (new gtLogHelper().CheckIfLoggingIsEnabled()) { LogEntries logEntries = new LogEntries { ActiveComponentName = ComponentName, ActiveFID = FID, ActiveFieldName = FieldName, ActiveFieldValue = fieldValue, JobID = DataContext.ActiveJob, RelatedComponentName = "N/A", RelatedFID = 0, RelatedFieldName = "N/A", RelatedFieldValue = "N/A", ValidationInterfaceName = "Phase Agreement", ValidationInterfaceType = "FI" }; gTValidationLogger = new GTValidationLogger(logEntries); gTValidationLogger.LogEntry("TIMING", "START", "Phase Agreement Entry", "N/A", ""); } ErrorPriorityArray = null; ErrorMessageArray = null; IGTKeyObject affectedFeatureKeyObject = GTClassFactory.Create <IGTKeyObject>(); IGTKeyObjects relatedFeaturesKeyObjects = GTClassFactory.Create <IGTKeyObjects>(); List <char> downstreamPhaseList = new List <char>(); List <char> upstreamPhaseList = new List <char>(); List <char> insidePhaseList = new List <char>(); List <char> parallelPhaseList = new List <char>(); List <char> outsidePhaseList = new List <char>(); List <string> errorMessage = new List <string>(); List <string> errorPriority = new List <string>(); GTClassFactory.Create <IGTApplication>().SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, "Phase Agreement FI"); try { if (!CheckAffectedFeatureIsSecondary()) // Check for affected feature is secondary or not { if (m_affectedConnectivityRs.RecordCount > 0) { m_affectedConnectivityRs.MoveFirst(); m_aNode1 = Convert.ToInt32(m_affectedConnectivityRs.Fields[ATTRIB_NODE1].Value == DBNull.Value ? 0.0 : m_affectedConnectivityRs.Fields[ATTRIB_NODE1].Value); m_aNode2 = Convert.ToInt32(m_affectedConnectivityRs.Fields[ATTRIB_NODE2].Value == DBNull.Value ? 0.0 : m_affectedConnectivityRs.Fields[ATTRIB_NODE2].Value); if (m_aNode1 != 0 || m_aNode2 != 0) { m_activeFeaturePhase = Convert.ToString(m_affectedConnectivityRs.Fields[ATTRIB_PHASE].Value); affectedFeatureKeyObject = DataContext.OpenFeature(Convert.ToInt16(Components[ComponentName].Recordset.Fields[ATTRIB_FNO].Value), Convert.ToInt32(Components[ComponentName].Recordset.Fields[ATTRIB_FID].Value)); // Gets the related features of affected feature. relatedFeaturesKeyObjects = GetRelatedFeatures(affectedFeatureKeyObject, m_cRNO); GetNumberOfNodes(affectedFeatureKeyObject); if (m_numberofNodes == 2) { ConnectivityFactory connecFactory = new ConnectivityHelperFactory(); //Collects phase list of parallel features of affected feature. GetParallelFeaturesPhaseList(affectedFeatureKeyObject, connecFactory, ref parallelPhaseList); //Collects phase list of Upstream features of affected feature. GetUpstreamFeaturesPhaseList(affectedFeatureKeyObject, connecFactory, ref upstreamPhaseList); //Collects phase list of DownStream features of affected feature. GetDownStreamFeaturesPhaseList(affectedFeatureKeyObject, connecFactory, ref downstreamPhaseList); //Collects phase list of Inside features of affected feature. GetInsideFeaturesPhaseList(affectedFeatureKeyObject, connecFactory, ref insidePhaseList); //Collects phase list of Outside features of affected feature. GetOutsideFeaturesPhaseList(affectedFeatureKeyObject, connecFactory, ref outsidePhaseList); } //Validates the Phase values based on different conditions ValidatePhase(outsidePhaseList, insidePhaseList, parallelPhaseList, upstreamPhaseList, downstreamPhaseList, relatedFeaturesKeyObjects, affectedFeatureKeyObject.FNO, ref errorPriority, ref errorMessage); if (errorMessage.Count > 0) { ErrorPriorityArray = errorPriority.ToArray(); ErrorMessageArray = errorMessage.ToArray(); } } } } if (gTValidationLogger != null) { gTValidationLogger.LogEntry("TIMING", "END", "Phase Agreement Exit", "N/A", ""); } } catch (Exception ex) { throw new Exception("Error during Phase agreement Validation" + ex.Message); } finally { downstreamPhaseList = null; upstreamPhaseList = null; insidePhaseList = null; outsidePhaseList = null; } }