private void ProcessAfterEstablish(string p_protectivedeviceIDUserName) { string stRelatedFeatureState = null; try { IGTKeyObject oRelatedKeyObject = null; short iFNORelated = Convert.ToInt16(RelatedComponents[RelatedComponentName].Recordset.Fields["G3E_FNO"].Value); int iFIDRelated = Convert.ToInt32(RelatedComponents[RelatedComponentName].Recordset.Fields["G3E_FID"].Value); oRelatedKeyObject = DataContext.OpenFeature(iFNORelated, iFIDRelated); if (p_protectivedeviceIDUserName == "PROTECTIVE_DEVICE_FID") { if (oRelatedKeyObject.Components["COMMON_N"] != null && oRelatedKeyObject.Components["COMMON_N"].Recordset != null && oRelatedKeyObject.Components["COMMON_N"].Recordset.RecordCount > 0) { ActiveComponents["COMMON_N"].Recordset.MoveFirst(); stRelatedFeatureState = Convert.ToString(ActiveComponents["COMMON_N"].Recordset.Fields["FEATURE_STATE_C"].Value); } if (stRelatedFeatureState == "PPI" && stRelatedFeatureState == "ABI") { return; } } FeatureProperties oRelated = new FeatureProperties(oRelatedKeyObject, m_sRelatedComponentName, ""); m_oActiveComponents[m_sActiveComponentName].Recordset.Fields[p_protectivedeviceIDUserName].Value = oRelated.ProtectiveDeviceIDToSet; } catch (Exception ex) { throw ex; } }
internal FeatureResult(string name, FeatureProperties properties, string id, string type) { Name = name; Properties = properties; Id = id; Type = type; }
public void AfterEstablish() { try { string strFeatureState = null; IGTKeyObject oActiveKeyObject = null; IGTKeyObject oRelatedKeyObject = null; short iFNOActive = Convert.ToInt16(ActiveComponents[ActiveComponentName].Recordset.Fields["G3E_FNO"].Value); short iFNORelated = Convert.ToInt16(RelatedComponents[RelatedComponentName].Recordset.Fields["G3E_FNO"].Value); int iFIDActive = Convert.ToInt32(ActiveComponents[ActiveComponentName].Recordset.Fields["G3E_FID"].Value); int iFIDRelated = Convert.ToInt32(RelatedComponents[RelatedComponentName].Recordset.Fields["G3E_FID"].Value); oActiveKeyObject = DataContext.OpenFeature(iFNOActive, iFIDActive); oRelatedKeyObject = DataContext.OpenFeature(iFNORelated, iFIDRelated); FeatureProperties oActiveFeature = new FeatureProperties(oActiveKeyObject, m_sActiveComponentName, ""); FeatureProperties oRelatedFeature = new FeatureProperties(oRelatedKeyObject, m_sRelatedComponentName, ""); if (oRelatedFeature.UpstreamNode != 0 && oRelatedFeature.UpstreamNode == oActiveFeature.DownStreamNode) //Affected Feature is U/S of related feature { return; } if (ActiveComponents["COMMON_N"] != null && ActiveComponents["COMMON_N"].Recordset != null && ActiveComponents["COMMON_N"].Recordset.RecordCount > 0) { ActiveComponents["COMMON_N"].Recordset.MoveFirst(); strFeatureState = Convert.ToString(ActiveComponents["COMMON_N"].Recordset.Fields["FEATURE_STATE_C"].Value); } if (strFeatureState != null && (strFeatureState == "PPI" || strFeatureState == "ABI")) { ProcessAfterEstablish("PP_PROTECTIVE_DEVICE_FID"); } if (strFeatureState != null && strFeatureState != "PPI" && strFeatureState != "ABI" && ActiveComponents[ActiveComponentName] != null && ActiveComponents[ActiveComponentName].Recordset != null && ActiveComponents[ActiveComponentName].Recordset.RecordCount > 0 && ActiveComponents[ActiveComponentName].Recordset.Fields["PROTECTIVE_DEVICE_FID"].Value.GetType() == typeof(DBNull)) { ProcessAfterEstablish("PROTECTIVE_DEVICE_FID"); } } catch (Exception ex) { MessageBox.Show("Error in raiProtectiveDeviceID relationship attribute interface" + ex.Message); } }
public static ColorInfo ToColorInfo(this FeatureProperties properties, float opacityAdjust = 1f) { var fillColor = ToARGB(properties.FillColor, properties.FillOpacity, opacityAdjust); var strokeColor = ToARGB(properties.StrokeColor, properties.StrokeOpacity, opacityAdjust); if (!int.TryParse(properties.StrokeWidth, out var strokeWidth)) { strokeWidth = 1; } return(new ColorInfo { FillColor = fillColor, StrokeColor = strokeColor, StrokeWidth = strokeWidth }); }
public void Save(string key, VectorQuadTile tile) { var ro = new FeatureCollection(); var crs = new NamedCRS("EPSG:" + Config.Settings.Map.SpatialReferenceSystemIdentifier); ro.CRS = crs; foreach (var omg in tile.Områder) { var område = omg.Område; IGeometryObject geometry = GeoJsonGeometry.FromDotSpatial(omg.Geometry); var props = new Dictionary <string, object> { { "category", område.Category }, { "name", område.Name }, { "number", område.Number }, { "value", område.Value }, { "type", område.Type.ToString() }, { "kind", område.kind } }; var feature = new Feature(geometry, props) { Id = område.AreaId.ToString() }; var fp = new FeatureProperties { nin = område.kind }; if (område.Number == 0) { throw new Exception("Område mangler nummer."); } ro.Features.Add(feature); } var fullPath = GetFullPath(key); var fullPathSingleDir = GetFullPath(key.Replace("/", "_")); var settings = GetJsonSerializerSettings(); File.WriteAllText(fullPath, JsonConvert.SerializeObject(ro, settings)); //File.WriteAllText(fullPathSingleDir, JsonConvert.SerializeObject(ro, settings)); //var serializer = new DataContractJsonSerializer(typeof(VectorQuadTile), CreateDataContractJsonSerializerSettings()); //using (Stream stream = File.Create(fullPath + ".adf")) // serializer.WriteObject(stream, tile); }
internal static FeatureData DeserializeFeatureData(JsonElement element) { Optional <FeatureProperties> properties = default; ResourceIdentifier id = default; string name = default; ResourceType type = default; SystemData systemData = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("properties")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } properties = FeatureProperties.DeserializeFeatureProperties(property.Value); continue; } if (property.NameEquals("id")) { id = new ResourceIdentifier(property.Value.GetString()); continue; } if (property.NameEquals("name")) { name = property.Value.GetString(); continue; } if (property.NameEquals("type")) { type = new ResourceType(property.Value.GetString()); continue; } if (property.NameEquals("systemData")) { systemData = JsonSerializer.Deserialize <SystemData>(property.Value.ToString()); continue; } } return(new FeatureData(id, name, type, systemData, properties.Value)); }
/// <summary> /// Method to return true or false depending upon whether Related Feature is Down Stream of the affected feature /// </summary> /// <param name="p_affectedFeature"></param> /// <param name="p_relatedFeature"></param> /// <returns></returns> public bool?IsRelatedFeatureDownstream(FeatureProperties p_affectedFeature, FeatureProperties p_relatedFeature) { bool?bReturn = null; if ((p_relatedFeature.UpstreamNode == p_affectedFeature.UpstreamNode) || (p_relatedFeature.DownStreamNode == p_affectedFeature.DownStreamNode)) //This is the case of parallel branches where both are connected to U/S node { bReturn = null; } else if (p_relatedFeature.DownStreamNode != 0 && p_relatedFeature.DownStreamNode == p_affectedFeature.UpstreamNode) //Affected Feature is D/S of related feature { bReturn = false; } else if (p_relatedFeature.UpstreamNode != 0 && p_relatedFeature.UpstreamNode == p_affectedFeature.DownStreamNode) //Affected Feature is U/S of related feature { bReturn = true; } return(bReturn); }
public override void OnFieldDoubleClick(ShapeField field, DiagramPointEventArgs e) { string property_Name = this.ModelElement.GetProperties()["Name"].GetValue(this.ModelElement.GetProperties()["Name"]).ToString(); FeatureKind property_Kind = (FeatureKind)this.ModelElement.GetProperties()["Kind"].GetValue(this.ModelElement.GetProperties()["Kind"]); string property_Condition = this.ModelElement.GetProperties()["Condition"].GetValue(this.ModelElement.GetProperties()["Condition"]).ToString(); string property_Constraint = this.ModelElement.GetProperties()["Constraint"].GetValue(this.ModelElement.GetProperties()["Constraint"]).ToString(); string property_Requirements = this.ModelElement.GetProperties()["Requirements"].GetValue(this.ModelElement.GetProperties()["Requirements"]).ToString(); FeatureProperties featureProperties = new FeatureProperties(); featureProperties.NameTextBox.Text = property_Name; featureProperties.ConditionTextBox.Text = property_Condition; featureProperties.ConstraintTextBox.Text = property_Constraint; featureProperties.RequirementsTextBox.Text = property_Requirements; featureProperties.KindComboBox.Text = property_Kind.ToString(); if (featureProperties.ShowDialog() == DialogResult.OK) { this.ModelElement.GetProperties()["Name"].SetValue(this.ModelElement.GetProperties()["Name"], featureProperties.NameTextBox.Text); switch (featureProperties.KindComboBox.Text) { case "Mandatory": this.ModelElement.GetProperties()["Kind"].SetValue(this.ModelElement.GetProperties()["Kind"], FeatureKind.Mandatory); break; case "Optional": this.ModelElement.GetProperties()["Kind"].SetValue(this.ModelElement.GetProperties()["Kind"], FeatureKind.Optional); break; case "FeatureSetFeature": this.ModelElement.GetProperties()["Kind"].SetValue(this.ModelElement.GetProperties()["Kind"], FeatureKind.FeatureSetFeature); break; } this.ModelElement.GetProperties()["Condition"].SetValue(this.ModelElement.GetProperties()["Condition"], featureProperties.ConditionTextBox.Text); this.ModelElement.GetProperties()["Constraint"].SetValue(this.ModelElement.GetProperties()["Constraint"], featureProperties.ConstraintTextBox.Text); this.ModelElement.GetProperties()["Requirements"].SetValue(this.ModelElement.GetProperties()["Requirements"], featureProperties.RequirementsTextBox.Text); } }
internal static FeatureData DeserializeFeatureResult(JsonElement element) { Optional <string> name = default; Optional <FeatureProperties> properties = default; Optional <ResourceIdentifier> id = default; Optional <string> type = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("name")) { name = property.Value.GetString(); continue; } if (property.NameEquals("properties")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } properties = FeatureProperties.DeserializeFeatureProperties(property.Value); continue; } if (property.NameEquals("id")) { id = new ResourceIdentifier(property.Value.GetString()); continue; } if (property.NameEquals("type")) { type = property.Value.GetString(); continue; } } return(new FeatureData(name.Value, properties.Value, id.Value, type.Value)); }
internal FeatureData(string name, FeatureProperties properties, string id, string type) : base(id, name, type) { Properties = properties; }
internal FeatureData(ResourceIdentifier id, string name, ResourceType type, SystemData systemData, FeatureProperties properties) : base(id, name, type, systemData) { Properties = properties; }
internal FeatureData(string name, FeatureProperties properties, ResourceIdentifier id, string type) : base(id, name, type) { Properties = properties; }
private void ProcessValidate(ref List <string> lstPriority, ref List <string> lstErrors) { String sRelatedFeatureName = string.Empty; string sActiveFeatureName = string.Empty; string errorMessage = string.Empty; try { ValidateFeatureConditions oValidation = new ValidateFeatureConditions(); short iFNORelated = 0; short iFNOActive = 0; int iFIDRelated = 0; int iFIDActive = 0; IGTKeyObject oActiveKeyObject = null; IGTKeyObject oRelatedKeyObject = null; iFNOActive = Convert.ToInt16(ActiveComponents[ActiveComponentName].Recordset.Fields["G3E_FNO"].Value); iFNORelated = Convert.ToInt16(RelatedComponents[RelatedComponentName].Recordset.Fields["G3E_FNO"].Value); iFIDActive = Convert.ToInt32(ActiveComponents[ActiveComponentName].Recordset.Fields["G3E_FID"].Value); iFIDRelated = Convert.ToInt32(RelatedComponents[RelatedComponentName].Recordset.Fields["G3E_FID"].Value); //We do not want to validate against the Network Secondary Features either active nor related if ((m_SecondaryFNOs.Contains(iFNOActive) && IsNetworkFeature(iFIDActive, iFNOActive)) || (m_SecondaryFNOs.Contains(iFNORelated) && IsNetworkFeature(iFIDRelated, iFNORelated))) { return; } oActiveKeyObject = DataContext.OpenFeature(iFNOActive, iFIDActive); oRelatedKeyObject = DataContext.OpenFeature(iFNORelated, iFIDRelated); FeatureProperties oActiveFeature = new FeatureProperties(oActiveKeyObject, m_sActiveComponentName, ""); FeatureProperties oRelatedFeature = new FeatureProperties(oRelatedKeyObject, m_sRelatedComponentName, ""); bool?isRelatedFeatureDownStreamNullable = oValidation.IsRelatedFeatureDownstream(oActiveFeature, oRelatedFeature); if (isRelatedFeatureDownStreamNullable == null) { return; //Parallel branches, no need to validate } bool isRelatedFeatureDownStream = isRelatedFeatureDownStreamNullable == true ? true : false; int oActiveProtectioDeviceID = oActiveFeature.ProtectioDeviceID.Equals(DBNull.Value) ? 0 : Convert.ToInt32(oActiveFeature.ProtectioDeviceID); int oRelatedProtectioDeviceID = oRelatedFeature.ProtectioDeviceID.Equals(DBNull.Value) ? 0 : Convert.ToInt32(oRelatedFeature.ProtectioDeviceID); if (oActiveFeature.IsProtectiveDevice && !oActiveFeature.IsBussedTransformer && isRelatedFeatureDownStream) { if (oRelatedProtectioDeviceID != oActiveFeature.FID) { lstErrors.Add("Connected Protective Device ID does not match this protective device’s FID."); lstPriority.Add(Priority); return; } else { return; } } if (oActiveFeature.IsBussedTransformer && isRelatedFeatureDownStream) { if (oRelatedProtectioDeviceID != oActiveFeature.ProtectiveDeviceIDToSet) { lstErrors.Add("Connected Protective Device ID does not match this protective device’s Tie Transformer ID."); lstPriority.Add(Priority); return; } else { return; } } if (oRelatedFeature.IsProtectiveDevice && !oRelatedFeature.IsBussedTransformer && !isRelatedFeatureDownStream) { if (oActiveProtectioDeviceID != oRelatedFeature.FID) { lstErrors.Add("Protective Device ID does not match the connected protective device’s FID."); lstPriority.Add(Priority); return; } else { return; } } if (oRelatedFeature.IsBussedTransformer && !isRelatedFeatureDownStream) { if (oActiveProtectioDeviceID != oRelatedFeature.ProtectiveDeviceIDToSet) { lstErrors.Add("Protective Device ID does not match the connected protective device’s Tie Transformer ID."); lstPriority.Add(Priority); return; } else { return; } } if (oActiveProtectioDeviceID != oRelatedProtectioDeviceID) { lstErrors.Add("Protective Device ID does not agree with connected feature."); lstPriority.Add(Priority); return; } else if (oActiveProtectioDeviceID == oRelatedProtectioDeviceID) { return; } } catch (Exception) { throw; } }