/// <summary> /// Method to create Work Label geometry /// </summary> /// <param name="wpGeometry"> WorkPoint geometry</param> /// <param name="tTVfeature"> Tree trimming feature </param> /// <param name="cid">cid</param> private void CreateWorkLabelGeometry(IGTOrientedPointGeometry wpGeometry, IGTKeyObject tTVfeature, short cid) { try { IGTTextPointGeometry iGtTxtPointGeometry = GTClassFactory.Create <IGTTextPointGeometry>(); IGTPoint textPoint = GTClassFactory.Create <IGTPoint>(); textPoint.X = wpGeometry.Origin.X + Convert.ToDouble(m_Arguments.GetArgument(0)); textPoint.Y = wpGeometry.Origin.Y + Convert.ToDouble(m_Arguments.GetArgument(1)); textPoint.Z = 0; iGtTxtPointGeometry.Origin = textPoint; IGTComponent igtComponent = tTVfeature.Components.GetComponent(19006); if (igtComponent.Recordset.RecordCount != 0) { igtComponent.Recordset.MoveLast(); } igtComponent.Recordset.AddNew("G3E_FID", tTVfeature.FID); igtComponent.Recordset.Fields["G3E_FNO"].Value = 190; igtComponent.Recordset.Fields["G3E_CNO"].Value = 19006; igtComponent.Recordset.Fields["G3E_CID"].Value = cid; igtComponent.Geometry = iGtTxtPointGeometry; igtComponent.Recordset.Update(System.Type.Missing, System.Type.Missing); } catch (Exception) { throw; } }
/// <summary> /// SetComponentSum /// </summary> private void SetComponentSum(bool iDelete) { int cno = 0; string componentName = null; ADODB.Recordset rs; try { countANO = Convert.ToInt32(m_GTArguments.GetArgument(0)); rs = DataContext.MetadataRecordset("G3E_ATTRIBUTEINFO_OPTABLE", "G3E_ANO = " + countANO); // rs.Filter = "G3E_ANO = " + countANO; if (rs != null) { if (!(rs.EOF && rs.BOF)) { rs.MoveFirst(); m_countFieldName = Convert.ToString(rs.Fields["G3E_FIELD"].Value); cno = Convert.ToInt32(rs.Fields["g3e_cno"].Value); } } rs = DataContext.MetadataRecordset("G3E_COMPONENTINFO_OPTABLE", "G3E_CNO = " + cno); // rs.Filter = "G3E_CNO = " + cno; if (rs != null) { if (!(rs.EOF && rs.BOF)) { rs.MoveFirst(); componentName = Convert.ToString(rs.Fields["G3E_TABLE"].Value); } } if (!String.IsNullOrEmpty(componentName)) { if (m_gComps[componentName].Recordset != null) { if (m_gComps[componentName].Recordset.RecordCount > 0 || !(m_gComps[componentName].Recordset.EOF && m_gComps[componentName].Recordset.BOF)) { m_gComps[componentName].Recordset.MoveFirst(); if (m_gComps[m_gCompName].Recordset != null) { if (m_gComps[m_gCompName].Recordset.RecordCount > 0 || !(m_gComps[m_gCompName].Recordset.EOF && m_gComps[m_gCompName].Recordset.BOF)) { m_gComps[componentName].Recordset.Fields[m_countFieldName].Value = m_gComps[m_gCompName].Recordset.RecordCount; if (iDelete) { m_gComps[componentName].Recordset.Fields[m_countFieldName].Value = Convert.ToInt16(m_gComps[componentName].Recordset.Fields[m_countFieldName].Value) - 1; } } } } } } } catch (Exception ex) { MessageBox.Show("There is an error in \"Set Component Count\" Funtional Interface \n" + ex.Message, "G/Technology"); } }
/// <summary> /// Method to check if the active FNO is configured in the metadata, and get the default value for the attribute /// </summary> /// <param name="activeFno">FNO</param> /// <param name="attributeValue">Default value that is configured in metadata</param> /// <returns></returns> private void CheckForActiveFnoInValueMap(short activeFno, out string attributeValue) { bool matchFound = false; attributeValue = string.Empty; string valueMap = Convert.ToString(m_Arguments.GetArgument(0)); short noMatchSetDefault = Convert.ToInt16(m_Arguments.GetArgument(1)); string noMatchDefaultValue = Convert.ToString(m_Arguments.GetArgument(2)); try { string[] valueMapPipeArray = valueMap.Split('|'); if (valueMapPipeArray != null) { string[] fNoArray = null; foreach (string item in valueMapPipeArray) { //matchFound = true; fNoArray = item.Split(':')[1].Split(','); matchFound = fNoArray.Contains(activeFno.ToString()); if (matchFound) { attributeValue = item.Split(':')[0]; break; } } if (!matchFound) { if (noMatchSetDefault == -1) { attributeValue = noMatchDefaultValue; } } } } catch (Exception) { throw; } }
public void Execute() { int cnt = 0; ADODB.Recordset rs; try { m_sjobANO = Convert.ToInt32(m_GTArguments.GetArgument(0)); rs = DataContext.MetadataRecordset("G3E_ATTRIBUTEINFO_OPTABLE", "G3E_ANO = " + m_sjobANO + " AND G3E_NAME = 'G3E_JOB'"); // rs.Filter = "G3E_ANO = " + m_sjobANO + " AND G3E_NAME = 'G3E_JOB'"; if (rs != null) { if (!(rs.EOF && rs.BOF)) { rs.MoveFirst(); m_jobFieldName = Convert.ToString(rs.Fields["G3E_FIELD"].Value); } } string sql = "SELECT " + m_jobFieldName + " FROM G3E_JOB WHERE G3E_IDENTIFIER=:1"; rs = DataContext.Execute(sql, out cnt, (int)ADODB.CommandTypeEnum.adCmdText, m_GTDataContext.ActiveJob.ToString()); if (rs != null) { if (!(rs.EOF && rs.BOF)) { rs.MoveFirst(); if (m_gComps[m_gCompName].Recordset != null) { if (m_gComps[m_gCompName].Recordset.RecordCount > 0 || !(m_gComps[m_gCompName].Recordset.EOF && m_gComps[m_gCompName].Recordset.BOF)) { m_gComps[m_gCompName].Recordset.MoveFirst(); m_gComps[m_gCompName].Recordset.Fields[m_gFieldName].Value = rs.Fields[0].Value; } } } } } catch (Exception ex) { MessageBox.Show("There is an error in \"Set Job Attribute on Create\" Funtional Interface \n" + ex.Message, "G/Technology"); } }
public void Validate(out string[] ErrorPriorityArray, out string[] ErrorMessageArray) { ADODB.Recordset rs = null; ADODB.Recordset rsTemp = null; int record = 0; bool hasPhaseAndPosition = true; bool hasUnknownPhasePosition = false; ErrorPriorityArray = null; ErrorMessageArray = 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 = "Phase Position", ValidationInterfaceType = "FI" }; gTValidationLogger = new GTValidationLogger(logEntries); gTValidationLogger.LogEntry("TIMING", "START", "Phase Position Entry", "N/A", ""); } try { List <string> errorMsg = new List <string>(); List <string> errorPriority = new List <string>(); string priority = Convert.ToString(_arguments.GetArgument(0)); ValidationRuleManager validateMsg = new ValidationRuleManager(); IGTApplication gTApplication = GTClassFactory.Create <IGTApplication>(); Recordset commonComponentRs = Components.GetComponent(1).Recordset; commonComponentRs.MoveFirst(); string orientation = Convert.ToString(commonComponentRs.Fields["ORIENTATION_C"].Value); int fNo = Convert.ToInt32(commonComponentRs.Fields["G3E_FNO"].Value); string featureName = Convert.ToString(GetRecordSet(string.Format("select g3e_username NAME from g3e_features_optable where g3e_fno = {0}", fNo)).Fields["NAME"].Value); int fId = Convert.ToInt32(commonComponentRs.Fields["G3E_FID"].Value); bool isFeatureConnected = CheckFeatureConnectivity(fId); ValidatePhaseAndPhasePosition(out hasPhaseAndPosition, out hasUnknownPhasePosition); if (orientation == "OH" && featureName.ToUpper().Contains("PRIMARY") && isFeatureConnected && hasUnknownPhasePosition) { validateMsg.Rule_Id = "PHPS01"; validateMsg.BuildRuleMessage(gTApplication, null); errorPriority.Add(priority); errorMsg.Add(validateMsg.Rule_MSG); //errorMsg.Add("Overhead feature is missing phase position values."); } if (ValidatePhasePositionWithSets()) { validateMsg.Rule_Id = "PHPS02"; validateMsg.BuildRuleMessage(gTApplication, null); errorPriority.Add(priority); errorMsg.Add(validateMsg.Rule_MSG); //errorMsg.Add("Phase Position attributes are not consistent with respect to one another."); } if (_fieldName == "PHASE_POS_C") { string sqlStmt = "Select {0},count({0}) from {1} where g3e_fid={2} and g3e_fno={3} GROUP BY {0} having count({0})>1"; IGTComponent gtComponent = _components[_componentName]; if (gtComponent != null) { rs = gtComponent.Recordset; if (rs != null && rs.RecordCount > 0) { rs.MoveFirst(); if (Convert.ToInt32(rs.Fields["G3e_CID"].Value) == 1) { //JIRA 195- check Duplicate Phase Position rsTemp = _dataContext.Execute(string.Format(sqlStmt, _fieldName, _componentName, rs.Fields["G3e_FID"].Value, rs.Fields["G3e_FNO"].Value), out record, (int)ADODB.CommandTypeEnum.adCmdText, null); if (rsTemp != null && rsTemp.RecordCount > 0) { validateMsg.Rule_Id = "PHPS02"; validateMsg.BuildRuleMessage(gTApplication, null); errorMsg.Add(validateMsg.Rule_MSG); //errorMsg.Add("Feature has duplicate Phase Positions. Phase Position should be unique across all the wires within same conductor."); errorPriority.Add(priority); } } } } if (errorMsg.Count > 0) { ErrorPriorityArray = errorPriority.ToArray(); ErrorMessageArray = errorMsg.ToArray(); } } if (gTValidationLogger != null) { gTValidationLogger.LogEntry("TIMING", "END", "Phase Position Exit", "N/A", ""); } } catch (Exception ex) { MessageBox.Show("Error during Phase position validation FI. " + ex.Message, Caption); } finally { rsTemp = null; } }
public void Validate(out string[] ErrorPriorityArray, out string[] ErrorMessageArray) { ADODB.Recordset rs = null; int[] spanFeatures = { 8, 84, 9, 85, 53, 96, 63, 97 }; Int16 fnoActiveFeature = 0; int owner1ID = 0; int owner2ID = 0; List <string> errorMsg = new List <string>(); List <string> errorPriority = new List <string>(); object[] messArguments = new object[2]; bool passedValidation = true; ErrorPriorityArray = null; ErrorMessageArray = null; string strActiveFeatureState = null; string strOwner1FeatureState = null; string strOwner2FeatureState = 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 = "Ownership Validation", ValidationInterfaceType = "FI", }; gTValidationLogger = new GTValidationLogger(logEntries); gTValidationLogger.LogEntry("TIMING", "START", "Ownership Validation Entry", "N/A", ""); } IGTApplication gTApplication = GTClassFactory.Create <IGTApplication>(); ValidationRuleManager validateMsg = new ValidationRuleManager(); try { IGTComponent gtComponent = m_components[m_componentName]; if (gtComponent != null) { rs = gtComponent.Recordset; if (rs != null && rs.RecordCount > 0) { rs.MoveFirst(); } fnoActiveFeature = Convert.ToInt16(rs.Fields["G3E_FNO"].Value); if ((!(rs.Fields["OWNER1_ID"].Value is DBNull) && Convert.ToInt32(rs.Fields["OWNER1_ID"].Value) > 0)) { owner1ID = Convert.ToInt32(rs.Fields["OWNER1_ID"].Value); } if ((!(rs.Fields["OWNER2_ID"].Value is DBNull) && Convert.ToInt32(rs.Fields["OWNER2_ID"].Value) > 0)) { owner2ID = Convert.ToInt32(rs.Fields["OWNER2_ID"].Value); } if (spanFeatures.Contains <int>(fnoActiveFeature)) { if (owner1ID == owner2ID) { passedValidation = false; } } if (!passedValidation) { validateMsg.Rule_Id = "OWN01"; validateMsg.BuildRuleMessage(gTApplication, null); errorMsg.Add(validateMsg.Rule_MSG); errorPriority.Add(Convert.ToString(m_arguments.GetArgument(0))); } if (!(rs.Fields["FEATURE_STATE_C"].Value is DBNull)) { strActiveFeatureState = (String)rs.Fields["FEATURE_STATE_C"].Value; if (strActiveFeatureState == "INI" || strActiveFeatureState == "CLS" || strActiveFeatureState == "PPI" || strActiveFeatureState == "PPX" || strActiveFeatureState == "ABI" || strActiveFeatureState == "ABX") { CheckOwnerShipStatus(owner1ID, owner2ID, errorMsg, errorPriority, ref strOwner1FeatureState, ref strOwner2FeatureState, gTApplication, validateMsg, strActiveFeatureState); } } ErrorPriorityArray = errorPriority.ToArray(); ErrorMessageArray = errorMsg.ToArray(); } if (gTValidationLogger != null) { gTValidationLogger.LogEntry("TIMING", "END", "Ownership Validation Exit", "N/A", ""); } } catch (Exception ex) { throw new Exception("Error in Ownership Validaiton FI" + ex.Message); } }
public void ProcessCategoryCount(CalledFromDelete p_calledFromDelete) { IGTApplication oApp = GTClassFactory.Create <IGTApplication>(); string placementType = string.Empty; string cuCode = string.Empty; string categroryCodeArgument = Convert.ToString(m_arguments.GetArgument(0)); int anoCount = Convert.ToInt32(m_arguments.GetArgument(1)); string currentCU = string.Empty; try { ADODB.Recordset rs = oApp.DataContext.MetadataRecordset("G3E_ATTRIBUTEINFO_OPTABLE", "g3e_Ano = " + anoCount); Int16 cno = 0; string fieldName = Convert.ToString(rs.Fields["G3E_FIELD"].Value); string categoryCode = string.Empty; if (rs != null) { if (rs.RecordCount > 0) { rs.MoveFirst(); cno = Convert.ToInt16(rs.Fields["g3E_cno"].Value); try { if (m_components.GetComponent(cno) == null) { return; } } catch (Exception) { return; } } } int iCount = 0; if (m_components[m_componentName].Recordset != null) { if (m_components[m_componentName].Recordset.RecordCount > 0) { currentCU = Convert.ToString(m_components[m_componentName].Recordset.Fields["CU_C"].Value); m_components[m_componentName].Recordset.MoveFirst(); while (!m_components[m_componentName].Recordset.EOF) { categoryCode = GetCUCategoryCode(Convert.ToString(m_components[m_componentName].Recordset.Fields["CU_C"].Value), oApp); if (string.Equals(categoryCode, categroryCodeArgument) && m_components[m_componentName].Recordset.Fields["ACTIVITY_C"].Value.ToString() != "R") { iCount = iCount + 1; } m_components[m_componentName].Recordset.MoveNext(); } categoryCode = GetCUCategoryCode(currentCU, oApp); m_components.GetComponent(cno).Recordset.MoveFirst(); if (p_calledFromDelete == CalledFromDelete.Yes && string.Equals(categoryCode, categroryCodeArgument)) { iCount = iCount - 1; } m_components.GetComponent(cno).Recordset.Fields[fieldName].Value = iCount; } } } catch (Exception ex) { MessageBox.Show("Error from Count Ancillaries By Category FI: " + ex.Message, "G/Technology"); } }
private void CopyValuesFromBoundaries(Recordset premiseAttributesRs) { short fNo = 0; int fId = 0; string city = string.Empty; string county = string.Empty; string zipCode = string.Empty; string insideCityLimits = string.Empty; string tmpQry = string.Empty; try { short cityFNO = Convert.ToInt16(m_Arguments.GetArgument(0)); int cityANO = Convert.ToInt32(m_Arguments.GetArgument(1)); short countyFNO = Convert.ToInt16(m_Arguments.GetArgument(2)); int countyANO = Convert.ToInt32(m_Arguments.GetArgument(3)); short zipFNO = Convert.ToInt16(m_Arguments.GetArgument(4)); int zipANO = Convert.ToInt32(m_Arguments.GetArgument(5)); Recordset commonComponentRs = Components.GetComponent(1).Recordset; if (commonComponentRs != null && commonComponentRs.RecordCount > 0) { commonComponentRs.MoveFirst(); fNo = Convert.ToInt16(commonComponentRs.Fields["G3E_FNO"].Value); fId = Convert.ToInt32(commonComponentRs.Fields["G3E_FID"].Value); } short primaryGraphicCno = GetPrimaryGraphicCno(fNo); if (primaryGraphicCno == 0) { return; } IGTKeyObject servicePointFeature = m_DataContext.OpenFeature(fNo, fId); IGTOrientedPointGeometry geometry = (IGTOrientedPointGeometry)servicePointFeature.Components.GetComponent(primaryGraphicCno).Geometry; if (geometry == null) { return; } IGTPoint point = GTClassFactory.Create <IGTPoint>(); point.X = geometry.FirstPoint.X; point.Y = geometry.FirstPoint.Y; // City customBoundaryQuery objCustomBoundaryQuery = new customBoundaryQuery(point, cityFNO); Recordset rs = objCustomBoundaryQuery.PerformPointInPolygon(); if (rs != null && rs.RecordCount > 0) { IGTKeyObject cityFeature = DataContext.OpenFeature(Convert.ToInt16(rs.Fields["G3E_FNO"].Value), Convert.ToInt32(rs.Fields["G3E_FID"].Value)); Recordset tempRs = m_DataContext.MetadataRecordset("G3E_ATTRIBUTEINFO_OPTABLE", "G3E_ANO = " + cityANO); if (tempRs != null && tempRs.RecordCount > 0) { tempRs.MoveFirst(); string field = Convert.ToString(tempRs.Fields["G3E_FIELD"].Value); short cno = 0; if (!string.IsNullOrEmpty(Convert.ToString(tempRs.Fields["G3E_CNO"].Value))) { cno = Convert.ToInt16(tempRs.Fields["G3E_CNO"].Value); } if (!string.IsNullOrEmpty(field)) { if ((string.IsNullOrEmpty(Convert.ToString(premiseAttributesRs.Fields["CITY_C"].Value))) && cno > 0) { Recordset cityRs = cityFeature.Components.GetComponent(cno).Recordset; if (cityRs != null && cityRs.RecordCount > 0) { cityRs.MoveFirst(); city = Convert.ToString(cityRs.Fields[field].Value); } if (!string.IsNullOrEmpty(city)) { //premiseAttributesRs.Fields["CITY_C"].Value = city; m_City = city; //premiseAttributesRs.Fields["INSIDE_CITY_LIMITS_YN"].Value = "Y"; m_CityLimits = "Y"; } } } } } // County objCustomBoundaryQuery = new customBoundaryQuery(point, countyFNO); Recordset rs1 = objCustomBoundaryQuery.PerformPointInPolygon(); if (rs1 != null && rs1.RecordCount > 0) { IGTKeyObject countyFeature = DataContext.OpenFeature(Convert.ToInt16(rs1.Fields["G3E_FNO"].Value), Convert.ToInt32(rs1.Fields["G3E_FID"].Value)); Recordset tempRs1 = m_DataContext.MetadataRecordset("G3E_ATTRIBUTEINFO_OPTABLE", "G3E_ANO = " + countyANO); if (tempRs1 != null && tempRs1.RecordCount > 0) { tempRs1.MoveFirst(); string field = Convert.ToString(tempRs1.Fields["G3E_FIELD"].Value); short cno = 0; if (!string.IsNullOrEmpty(Convert.ToString(tempRs1.Fields["G3E_CNO"].Value))) { cno = Convert.ToInt16(tempRs1.Fields["G3E_CNO"].Value); } if (!string.IsNullOrEmpty(field)) { if ((string.IsNullOrEmpty(Convert.ToString(premiseAttributesRs.Fields["COUNTY_C"].Value))) && cno > 0) { Recordset countyRs = countyFeature.Components.GetComponent(cno).Recordset; if (countyRs != null && countyRs.RecordCount > 0) { countyRs.MoveFirst(); county = Convert.ToString(countyRs.Fields[field].Value); } if (!string.IsNullOrEmpty(county)) { //premiseAttributesRs.Fields["COUNTY_C"].Value = county; m_CountyCode = county; } } } } } // Zip Code objCustomBoundaryQuery = new customBoundaryQuery(point, zipFNO); Recordset rs2 = objCustomBoundaryQuery.PerformPointInPolygon(); if (rs2 != null && rs2.RecordCount > 0) { IGTKeyObject zipCodeFeature = DataContext.OpenFeature(Convert.ToInt16(rs2.Fields["G3E_FNO"].Value), Convert.ToInt32(rs2.Fields["G3E_FID"].Value)); Recordset tempRs2 = m_DataContext.MetadataRecordset("G3E_ATTRIBUTEINFO_OPTABLE", "G3E_ANO = " + zipANO); if (tempRs2 != null && tempRs2.RecordCount > 0) { tempRs2.MoveFirst(); string field = Convert.ToString(tempRs2.Fields["G3E_FIELD"].Value); short cno = 0; if (!string.IsNullOrEmpty(Convert.ToString(tempRs2.Fields["G3E_CNO"].Value))) { cno = Convert.ToInt16(tempRs2.Fields["G3E_CNO"].Value); } if (!string.IsNullOrEmpty(field)) { if ((string.IsNullOrEmpty(Convert.ToString(premiseAttributesRs.Fields["ZIP_C"].Value))) && cno > 0) { Recordset zipRs = zipCodeFeature.Components.GetComponent(cno).Recordset; if (zipRs != null && zipRs.RecordCount > 0) { zipRs.MoveFirst(); zipCode = Convert.ToString(zipRs.Fields[field].Value); } if (!string.IsNullOrEmpty(zipCode)) { //premiseAttributesRs.Fields["ZIP_C"].Value = zipCode; m_ZipCode = zipCode; } } } } try { premiseAttributesRs.Fields["CITY_C"].Value = m_City; premiseAttributesRs.Fields["INSIDE_CITY_LIMITS_YN"].Value = m_CityLimits; premiseAttributesRs.Fields["COUNTY_C"].Value = m_CountyCode; premiseAttributesRs.Fields["ZIP_C"].Value = m_ZipCode; } catch (Exception ex) { if (ex.Message == "Operation was canceled.") { int tmpRecModified = 0; tmpQry = "begin update premise_n set CITY_C = '" + m_City + "', INSIDE_CITY_LIMITS_YN = '" + m_CityLimits + "', COUNTY_C = '" + m_CountyCode + "', ZIP_C = '" + m_ZipCode + "' where g3e_fid = " + premiseAttributesRs.Fields["G3E_FID"].Value.ToString() + " and g3e_cid = " + premiseAttributesRs.Fields["G3E_CID"].Value.ToString() + "; end;"; m_DataContext.Execute(tmpQry, out tmpRecModified, (int)CommandTypeEnum.adCmdText); } else { throw; } } } } catch (Exception) { throw; } }
public void Validate(out string[] ErrorPriorityArray, out string[] ErrorMessageArray) { ADODB.Recordset rs = null; ADODB.Recordset rsTemp = null; int record = 0; bool isPhaseExists = false; ErrorPriorityArray = null; ErrorMessageArray = null; try { List <string> errorMsg = new List <string>(); List <string> errorPriority = new List <string>(); string priority = Convert.ToString(_arguments.GetArgument(0)); Recordset commonComponentRs = Components.GetComponent(1).Recordset; commonComponentRs.MoveFirst(); string orientation = Convert.ToString(commonComponentRs.Fields["ORIENTATION_C"].Value); int fNo = Convert.ToInt32(commonComponentRs.Fields["G3E_FNO"].Value); string featureName = Convert.ToString(GetRecordSet(string.Format("select g3e_username NAME from g3e_feature where g3e_fno = {0}", fNo)).Fields["NAME"].Value); int fId = Convert.ToInt32(commonComponentRs.Fields["G3E_FID"].Value); bool isFeatureConnected = CheckFeatureConnectivity(fId); if (orientation == "OH" && featureName.ToUpper().Contains("PRIMARY") && isFeatureConnected && !CheckPhaseAndPhasePosition(out isPhaseExists)) { errorPriority.Add(priority); errorMsg.Add("Overhead feature is missing phase position values."); } if (CheckPhaseAndPhasePosition(out isPhaseExists)) { if (!isPhaseExists) { errorPriority.Add(priority); errorMsg.Add("Phase Position attributes do not match specified phase."); } } if (ValidatePhasePositionWithSets()) { errorPriority.Add(priority); errorMsg.Add("Phase Position attributes are not consistent with respect to one another."); } if (_fieldName == "PHASE_POS_C") { string sqlStmt = "Select {0},count({0}) from {1} where g3e_fid={2} and g3e_fno={3} GROUP BY {0} having count({0})>1"; //string sqlQuery = "Select listagg(a.{0},',') within group (order by a.PHASE_POS_C) as PhasePosition from {1} a where g3e_fid={2} and not exists (Select vl_key from VL_PHASE_POSITION p where p.vl_key=a.{0})"; IGTComponent gtComponent = _components[_componentName]; if (gtComponent != null) { rs = gtComponent.Recordset; if (rs != null && rs.RecordCount > 0) { rs.MoveFirst(); if (Convert.ToInt32(rs.Fields["G3e_CID"].Value) == 1) { //JIRA 195- check Duplicate Phase Position rsTemp = _dataContext.Execute(string.Format(sqlStmt, _fieldName, _componentName, rs.Fields["G3e_FID"].Value, rs.Fields["G3e_FNO"].Value), out record, (int)ADODB.CommandTypeEnum.adCmdText, null); if (rsTemp != null && rsTemp.RecordCount > 0) { errorMsg.Add("Feature having duplicate Phase Position. Phase Position should be unique across all the wires within same conductor."); errorPriority.Add(priority); } /* * Commneted this code as per Shubham suggestion * * // As per the JIRA 476 - Business Rule Validate Unknown Values in Phase Position * rsTemp = _dataContext.Execute(string.Format(sqlQuery, _fieldName, _componentName, rs.Fields["G3e_FID"].Value), out record, (int)ADODB.CommandTypeEnum.adCmdText, null); * if (rsTemp != null && rsTemp.RecordCount > 0) * { * rsTemp.MoveFirst(); * phasePosition = Convert.ToString(rsTemp.Fields[0].Value); * if (!string.IsNullOrEmpty(phasePosition)) * { * errorMsg.Add("Phase Position " + rsTemp.Fields[0].Value + " are unknown Values"); * errorPriority.Add("P2"); * } * } */ } } } if (errorMsg.Count > 0) { ErrorPriorityArray = errorPriority.ToArray(); ErrorMessageArray = errorMsg.ToArray(); } } } catch (Exception ex) { MessageBox.Show(ex.Message, Caption); } finally { rsTemp = null; } }
public void Execute() { GTClassFactory.Create <IGTApplication>().SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, "Aggregate Phase FI"); IGTComponent activeComponent = Components[ComponentName]; short cNo = 0; string field = string.Empty; string alphabetizedPhase = string.Empty; string alphabetizedOperatedPhase = string.Empty; try { if (activeComponent != null) { //Get the active feature current CID int aCID = Convert.ToInt32(activeComponent.Recordset.Fields["G3E_CID"].Value); if ((aCID != 0)) { int anoPhase = Convert.ToInt32(m_Arguments.GetArgument(0)); int anoPhaseQty = Convert.ToInt32(m_Arguments.GetArgument(1)); int anoPhaseOperated = Convert.ToInt32(m_Arguments.GetArgument(2)); Tuple <string, string> phaseValues = GetAggregatePhaseValue(); Recordset phaseRs = DataContext.MetadataRecordset("G3E_ATTRIBUTEINFO_OPTABLE", "G3E_ANO = " + anoPhase);// GetRecordSet(sqlString); // Update PHASE if (phaseRs.RecordCount > 0) { phaseRs.MoveFirst(); cNo = Convert.ToInt16(phaseRs.Fields["G3E_CNO"].Value); field = Convert.ToString(phaseRs.Fields["G3E_FIELD"].Value); IGTComponent connectivityComponent = Components.GetComponent(cNo); connectivityComponent.Recordset.MoveFirst(); alphabetizedPhase = GetAlphabetizedPhase(phaseValues.Item1); connectivityComponent.Recordset.Fields[field].Value = alphabetizedPhase; } Recordset operatedPhaseRs = DataContext.MetadataRecordset("G3E_ATTRIBUTEINFO_OPTABLE", "G3E_ANO = " + anoPhaseOperated); // Update As-Operated Phase if (operatedPhaseRs.RecordCount > 0) { operatedPhaseRs.MoveFirst(); cNo = Convert.ToInt16(operatedPhaseRs.Fields["G3E_CNO"].Value); field = Convert.ToString(operatedPhaseRs.Fields["G3E_FIELD"].Value); IGTComponent connectivityComponent = Components.GetComponent(cNo); connectivityComponent.Recordset.MoveFirst(); alphabetizedOperatedPhase = GetAlphabetizedPhase(phaseValues.Item2); connectivityComponent.Recordset.Fields[field].Value = alphabetizedOperatedPhase; } // Update PHASE QUANTITY if (anoPhaseQty != 0) { Recordset phaseQuantityRs = DataContext.MetadataRecordset("G3E_ATTRIBUTEINFO_OPTABLE", "G3E_ANO = " + anoPhaseQty); if (phaseQuantityRs.RecordCount > 0) { phaseQuantityRs.MoveFirst(); cNo = Convert.ToInt16(phaseQuantityRs.Fields["G3E_CNO"].Value); field = Convert.ToString(phaseQuantityRs.Fields["G3E_FIELD"].Value); IGTComponent primaryAttributeComponent = Components.GetComponent(cNo); primaryAttributeComponent.Recordset.MoveFirst(); primaryAttributeComponent.Recordset.Fields[field].Value = GetDistinctPhaseCount(alphabetizedPhase); } } } } } catch (Exception ex) { MessageBox.Show("Error during Phase Aggregation FI execution. " + ex.Message, "G/Technology"); } }
private void ProcessSumAndUpdateRs() { short cNo = 0; string field = string.Empty; int attributeValueSum = 0; Recordset bankAttributesRs = null; try { //Calculate attribute value sum IGTComponent component = Components[ComponentName]; ADODB.Recordset kvaResultsRs = component.Recordset; if (kvaResultsRs.RecordCount > 0) { int deletetedValue = string.IsNullOrEmpty(Convert.ToString(kvaResultsRs.Fields["KVA_Q"].Value)) ? 0 : Convert.ToInt32(kvaResultsRs.Fields["KVA_Q"].Value); kvaResultsRs.MoveFirst(); while (!kvaResultsRs.EOF) { attributeValueSum = attributeValueSum + (string.IsNullOrEmpty(Convert.ToString(kvaResultsRs.Fields["KVA_Q"].Value)) ? 0 : Convert.ToInt32(kvaResultsRs.Fields["KVA_Q"].Value)); kvaResultsRs.MoveNext(); } if (m_isDelete) { attributeValueSum = attributeValueSum - deletetedValue; } } //Get the attribute to be updated and update the attribute sum to this attribute string sqlString = string.Format("select g3e_field FIELD, g3e_cno CNO from G3E_ATTRIBUTEINFO_OPTABLE where g3e_ano = {0} ", Convert.ToInt32(m_Arguments.GetArgument(0))); ADODB.Recordset results = GetRecordSet(sqlString); if (results.RecordCount > 0) { results.MoveFirst(); cNo = Convert.ToInt16(results.Fields["CNO"].Value); field = Convert.ToString(results.Fields["FIELD"].Value); } bankAttributesRs = Components.GetComponent(cNo).Recordset; bankAttributesRs.MoveFirst(); bankAttributesRs.Fields[field].Value = attributeValueSum; } catch (Exception) { throw; } }
public void Validate(out string[] ErrorPriorityArray, out string[] ErrorMessageArray) { ErrorMessageArray = null; ErrorPriorityArray = null; List <String> strErrorMsg = new List <String>(); List <String> strErrorPriority = new List <String>(); string ownerType = string.Empty; ValidationRuleManager validateMsg = new ValidationRuleManager(); 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 = "Owning Company", ValidationInterfaceType = "FI", }; gTValidationLogger = new GTValidationLogger(logEntries); gTValidationLogger.LogEntry("TIMING", "START", "Owning Company Entry", "N/A", ""); } try { IGTApplication iGtApplication = GTClassFactory.Create <IGTApplication>(); iGtApplication.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, "Owning Company Validation Started"); string errorPriority = Convert.ToString(m_Arguments.GetArgument(0)); Recordset commonComponentRs = Components.GetComponent(1).Recordset; commonComponentRs.MoveFirst(); short fno = Convert.ToInt16(commonComponentRs.Fields["G3E_FNO"].Value); if (fno != 110) { if (gTValidationLogger != null) { gTValidationLogger.LogEntry("TIMING", "END", "Owning Company Exit", "N/A", ""); } return; } ownerType = Convert.ToString(commonComponentRs.Fields["OWNED_TYPE_C"].Value); if (ownerType == "FOREIGN") { if (string.IsNullOrEmpty(GetOwningCompany())) { validateMsg.Rule_Id = "OWNC01"; validateMsg.BuildRuleMessage(GTClassFactory.Create <IGTApplication>(), null); strErrorMsg.Add(validateMsg.Rule_MSG); strErrorPriority.Add(errorPriority); } } if (ownerType == "COMPANY") { string configuredCompany = GetConfiguredOwningCompany(); if (!Convert.ToString(GetOwningCompany()).ToUpper().Equals(Convert.ToString(configuredCompany).ToUpper())) { object[] messArguments = new object[1]; messArguments[0] = configuredCompany; validateMsg.Rule_Id = "OWNC02"; validateMsg.BuildRuleMessage(GTClassFactory.Create <IGTApplication>(), messArguments); strErrorMsg.Add(validateMsg.Rule_MSG); strErrorPriority.Add(errorPriority); } } iGtApplication.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, "Owning Company Validation Completed"); ErrorMessageArray = strErrorMsg.ToArray(); ErrorPriorityArray = strErrorPriority.ToArray(); if (gTValidationLogger != null) { gTValidationLogger.LogEntry("TIMING", "END", "Owning Company Exit", "N/A", ""); } } catch (Exception ex) { throw new Exception("Error during Owning Company FI validation. " + ex.Message); } }
public void Validate(out string[] ErrorPriorityArray, out string[] ErrorMessageArray) { Regex regex = new Regex("^\\d+'\\d+\"$"); // Regular expression for height format - ex 5'6" ErrorPriorityArray = null; ErrorMessageArray = null; List <string> errorMsg = new List <string>(); List <string> errorPriority = new List <string>(); IGTComponent component = Components[ComponentName]; Recordset componentRecordSet = component.Recordset; ValidationRuleManager validateMsg = new ValidationRuleManager(); 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 = "Height Validation", ValidationInterfaceType = "FI", }; gTValidationLogger = new GTValidationLogger(logEntries); gTValidationLogger.LogEntry("TIMING", "START", "Height Validation Entry", "N/A", ""); } try { if (componentRecordSet != null) { if (componentRecordSet.RecordCount > 0) { m_AttachmentHeight = Convert.ToString(componentRecordSet.Fields[m_FieldName].Value); if (!string.IsNullOrEmpty(m_AttachmentHeight)) { Match match = regex.Match(m_AttachmentHeight); if (match.Success) { if (!CheckHeightRange(m_AttachmentHeight)) { validateMsg.Rule_Id = "HGT01"; validateMsg.BuildRuleMessage(GTClassFactory.Create <IGTApplication>(), null); errorMsg.Add(validateMsg.Rule_MSG); errorPriority.Add(Convert.ToString(m_Arguments.GetArgument(0))); } } else { validateMsg.Rule_Id = "HGT01"; validateMsg.BuildRuleMessage(GTClassFactory.Create <IGTApplication>(), null); errorMsg.Add(validateMsg.Rule_MSG); errorPriority.Add(Convert.ToString(m_Arguments.GetArgument(0))); } } } if (errorMsg.Count > 0) { ErrorPriorityArray = errorPriority.ToArray(); ErrorMessageArray = errorMsg.ToArray(); } } if (gTValidationLogger != null) { gTValidationLogger.LogEntry("TIMING", "END", "Height Validation Exit", "N/A", ""); } } catch (Exception ex) { throw new Exception("Error during Attachment Height Validation" + ex.Message); } }
public void Validate(out string[] ErrorPriorityArray, out string[] ErrorMessageArray) { ErrorMessageArray = null; ErrorPriorityArray = null; short cNo = 0; int deviceRating = 0; List <int> ampsList = null; GTValidationLogger gTValidationLogger = null; IGTComponent comp = Components[ComponentName]; int FID = 0; if (comp != null) { comp.Recordset.MoveFirst(); FID = int.Parse(comp.Recordset.Fields["G3E_FID"].Value.ToString()); } if (new gtLogHelper().CheckIfLoggingIsEnabled()) { LogEntries logEntries = new LogEntries { ActiveComponentName = ComponentName, ActiveFID = FID, ActiveFieldName = FieldName, ActiveFieldValue = Convert.ToString(comp.Recordset.Fields[FieldName].Value), JobID = DataContext.ActiveJob, RelatedComponentName = "N/A", RelatedFID = 0, RelatedFieldName = "N/A", RelatedFieldValue = "N/A", ValidationInterfaceName = "Check Device Rating", ValidationInterfaceType = "FI", }; gTValidationLogger = new GTValidationLogger(logEntries); gTValidationLogger.LogEntry("TIMING", "START", "Check Device Rating Entry", "N/A", ""); } try { List <String> strErrorMsg = new List <String>(); List <String> strErrorPriority = new List <String>(); IGTApplication iGtApplication = GTClassFactory.Create <IGTApplication>(); iGtApplication.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, "Check Device Rating Validation Started"); string errorPriority = Convert.ToString(m_Arguments.GetArgument(0)); short fNo = Convert.ToInt16(Components[ComponentName].Recordset.Fields["G3E_FNO"].Value); ValidationRuleManager validateMsg = new ValidationRuleManager(); IGTComponent loadAnalysisAttributes = Components.GetComponent(32); // Load Analysis Attributes Component if (loadAnalysisAttributes == null) { iGtApplication.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, "Check Device Rating Validation Completed"); if (gTValidationLogger != null) { gTValidationLogger.LogEntry("TIMING", "END", "Check Device Rating Exit", "N/A", ""); } return; } string query = @"SELECT A.G3E_CNO FROM G3E_ATTRIBUTEINFO_OPTABLE A, G3E_FEATURECOMPS_OPTABLE F WHERE A.G3E_FIELD = 'DEVICE_RTG_Q' AND F.G3E_CNO = A.G3E_CNO AND F.G3E_FNO = {0}" ; Recordset resultRs = GetRecordSet(string.Format(query, fNo)); // Get the device rating if (resultRs != null && resultRs.RecordCount > 0) { resultRs.MoveFirst(); cNo = Convert.ToInt16(resultRs.Fields["G3E_CNO"].Value); // CNO for the attribute containing Device rating if (cNo > 0) { Recordset tempRs = Components.GetComponent(cNo).Recordset; if (tempRs != null && tempRs.RecordCount > 0) { tempRs.MoveFirst(); if (!string.IsNullOrEmpty(Convert.ToString(tempRs.Fields["DEVICE_RTG_Q"].Value))) { deviceRating = Convert.ToInt32(tempRs.Fields["DEVICE_RTG_Q"].Value); } } } } if (deviceRating <= 0) { if (gTValidationLogger != null) { gTValidationLogger.LogEntry("TIMING", "END", "Check Device Rating Exit", "N/A", ""); } return; } // Get the Summer Amps and Winter Amps Recordset loadAnalysisAttributesRs = loadAnalysisAttributes.Recordset; if (loadAnalysisAttributesRs != null && loadAnalysisAttributesRs.RecordCount > 0) { ampsList = new List <int>(); loadAnalysisAttributesRs.MoveFirst(); if (!string.IsNullOrEmpty(Convert.ToString(loadAnalysisAttributesRs.Fields["SUMMER_AMPS_A_Q"].Value))) { ampsList.Add(Convert.ToInt32(loadAnalysisAttributesRs.Fields["SUMMER_AMPS_A_Q"].Value)); } if (!string.IsNullOrEmpty(Convert.ToString(loadAnalysisAttributesRs.Fields["SUMMER_AMPS_B_Q"].Value))) { ampsList.Add(Convert.ToInt32(loadAnalysisAttributesRs.Fields["SUMMER_AMPS_B_Q"].Value)); } if (!string.IsNullOrEmpty(Convert.ToString(loadAnalysisAttributesRs.Fields["SUMMER_AMPS_C_Q"].Value))) { ampsList.Add(Convert.ToInt32(loadAnalysisAttributesRs.Fields["SUMMER_AMPS_C_Q"].Value)); } if (!string.IsNullOrEmpty(Convert.ToString(loadAnalysisAttributesRs.Fields["WINTER_AMPS_A_Q"].Value))) { ampsList.Add(Convert.ToInt32(loadAnalysisAttributesRs.Fields["WINTER_AMPS_A_Q"].Value)); } if (!string.IsNullOrEmpty(Convert.ToString(loadAnalysisAttributesRs.Fields["WINTER_AMPS_B_Q"].Value))) { ampsList.Add(Convert.ToInt32(loadAnalysisAttributesRs.Fields["WINTER_AMPS_B_Q"].Value)); } if (!string.IsNullOrEmpty(Convert.ToString(loadAnalysisAttributesRs.Fields["WINTER_AMPS_C_Q"].Value))) { ampsList.Add(Convert.ToInt32(loadAnalysisAttributesRs.Fields["WINTER_AMPS_C_Q"].Value)); } if (ampsList != null && ampsList.Count > 0 && ampsList.Max() > deviceRating) { validateMsg.Rule_Id = "DRTG01"; validateMsg.BuildRuleMessage(GTClassFactory.Create <IGTApplication>(), null); strErrorMsg.Add(validateMsg.Rule_MSG); strErrorPriority.Add(errorPriority); } } iGtApplication.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, "Check Device Rating Validation Completed"); ErrorMessageArray = strErrorMsg.ToArray(); ErrorPriorityArray = strErrorPriority.ToArray(); if (gTValidationLogger != null) { gTValidationLogger.LogEntry("TIMING", "END", "Check Device Rating Exit", "N/A", ""); } } catch (Exception ex) { throw new Exception("Error during Check Device Rating FI validation. " + ex.Message); } }