internal void AddRedlineLayer(RedlineLayer layer, string fdoProvider) { var fsId = GetRegistryFeatureSource(); MgFeatureCommandCollection commands = new MgFeatureCommandCollection(); MgPropertyCollection insertVals = new MgPropertyCollection(); MgStringProperty regId = new MgStringProperty("ResourceId", layer.FeatureSource); MgStringProperty ldfId = new MgStringProperty("LayerDefinition", layer.LayerDefinition); MgStringProperty name = new MgStringProperty("Name", layer.Name); MgStringProperty provider = new MgStringProperty("FdoProvider", fdoProvider); MgInt32Property geomTypes = new MgInt32Property("GeometryTypes", layer.GeometryTypes); MgInt32Property styleType = new MgInt32Property("StyleType", (int)layer.StyleType); insertVals.Add(regId); insertVals.Add(ldfId); insertVals.Add(name); insertVals.Add(provider); insertVals.Add(geomTypes); insertVals.Add(styleType); MgInsertFeatures insert = new MgInsertFeatures("Default:MarkupRegistry", insertVals); commands.Add(insert); MgPropertyCollection result = _featSvc.UpdateFeatures(fsId, commands, false); MgFeatureProperty insertResult = result.GetItem(0) as MgFeatureProperty; if (insertResult != null) { MgFeatureReader fr = insertResult.GetValue(); fr.Close(); } }
public void Execute(IPlatformFactory factory, ITestLogger logger) { MgStringProperty sp = new MgStringProperty("TestStringName", "TestStringValue"); Assert.AreEqual("TestStringValue", sp.Value); Assert.AreEqual("TestStringName", sp.Name); }
public void Execute(IPlatformFactory factory, ITestLogger logger) { MgStringProperty prop1 = new MgStringProperty("prop1", "val1"); MgStringProperty prop2 = new MgStringProperty("prop2", "val2"); MgStringProperty prop3 = new MgStringProperty("prop3", "val3"); MgStringProperty prop4 = new MgStringProperty("prop4", "val4"); MgStringPropertyCollection coll = new MgStringPropertyCollection(); coll.Add(prop1); coll.Add(prop2); coll.Remove(prop3); coll.Remove(coll[1]); Assert.AreEqual(1, coll.Count); coll.Add(prop3); coll[1] = prop2; coll.Insert(2, prop3); Assert.AreEqual(2, coll.IndexOf(prop3)); coll.Add(prop4); string txt = ""; foreach (MgStringProperty prop in coll) { txt += "[" + prop.GetName() + "]"; } Assert.AreEqual("[prop1][prop2][prop3][prop4]", txt); }
MgPropertyCollection MakePoint(String name, double x, double y, MgWktReaderWriter wktReaderWriter, MgAgfReaderWriter agfReaderWriter) { MgPropertyCollection propertyCollection = new MgPropertyCollection(); MgStringProperty nameProperty = new MgStringProperty("NAME", name); propertyCollection.Add(nameProperty); MgGeometry geometry = wktReaderWriter.Read("POINT XY (" + x + " " + y + ")"); MgByteReader geometryByteReader = agfReaderWriter.Write(geometry); MgGeometryProperty geometryProperty = new MgGeometryProperty("GEOM", geometryByteReader); propertyCollection.Add(geometryProperty); return(propertyCollection); }
internal void UpdateRedlineText(string text, int[] ids) { MgMapBase map = _viewer.GetMap(); MgLayerCollection layers = map.GetLayers(); MgLayerBase redlineLayer = layers.GetItem(_layer.SystemName); //HACK: Workaround FeatId leaky abstraction in SHP provider MgClassDefinition cls = redlineLayer.GetClassDefinition(); MgPropertyDefinitionCollection idProps = cls.GetIdentityProperties(); MgPropertyDefinition idProp = idProps.GetItem(0); redlineLayer.ForceRefresh(); //This lib doesn't reference mg-desktop so the convenience APIs aren't available to us //Gotta go the old verbose route List <string> filters = new List <string>(); foreach (int id in ids) { filters.Add(idProp.Name + " = " + id); } string updateFilter = string.Join(" OR ", filters.ToArray()); MgFeatureCommandCollection commands = new MgFeatureCommandCollection(); MgPropertyCollection updateValues = new MgPropertyCollection(); MgStringProperty updateProp = new MgStringProperty(RedlineSchemaFactory.TEXT_NAME, text); updateValues.Add(updateProp); MgUpdateFeatures update = new MgUpdateFeatures(redlineLayer.FeatureClassName, updateValues, updateFilter); commands.Add(update); MgPropertyCollection result = redlineLayer.UpdateFeatures(commands); MgInt32Property updateResult = result.GetItem(0) as MgInt32Property; MgStringProperty errorResult = result.GetItem(0) as MgStringProperty; if (errorResult != null) { throw new Exception(errorResult.GetValue()); } _viewer.RefreshMap(); }
private void InsertRedlineGeometry(string text, MgGeometry geom, RedlineAction onRedlineAdded) { MgPropertyCollection feature = new MgPropertyCollection(); MgByteReader agf = _agfRW.Write(geom); MgGeometryProperty geomProp = new MgGeometryProperty(RedlineSchemaFactory.GEOM_NAME, agf); feature.Add(geomProp); MgStringProperty strProp = new MgStringProperty(RedlineSchemaFactory.TEXT_NAME, text); feature.Add(strProp); MgMapBase map = _viewer.GetMap(); MgLayerCollection layers = map.GetLayers(); MgLayerBase redlineLayer = layers.GetItem(_layer.SystemName); MgClassDefinition cls = redlineLayer.GetClassDefinition(); MgPropertyDefinitionCollection idProps = cls.GetIdentityProperties(); MgPropertyDefinition idProp = idProps.GetItem(0); redlineLayer.ForceRefresh(); //This lib doesn't reference mg-desktop so the convenience APIs aren't available to us //Gotta go the old verbose route MgFeatureCommandCollection commands = new MgFeatureCommandCollection(); MgInsertFeatures insert = new MgInsertFeatures(redlineLayer.FeatureClassName, feature); commands.Add(insert); MgPropertyCollection result = redlineLayer.UpdateFeatures(commands); //Insert result is a MgFeatureProperty containing an MgFeatureReader MgFeatureProperty insertResult = result.GetItem(0) as MgFeatureProperty; MgStringProperty errorResult = result.GetItem(0) as MgStringProperty; if (insertResult != null) { var reader = insertResult.GetValue(); int inserted = 0; int?id = null; try { if (reader.ReadNext()) { inserted++; id = reader.GetInt32(idProp.Name); } } catch (MgException ex) { ex.Dispose(); } finally { reader.Close(); } if (inserted > 0) { _viewer.RefreshMap(); onRedlineAdded(id, text); } } else if (errorResult != null) { throw new Exception(errorResult.GetValue()); } }
internal static void Populate(MgPropertyCollection props, IMutableRecord record) { for (int i = 0; i < record.FieldCount; i++) { var pt = record.GetPropertyType(i); string name = record.GetName(i); if (record.IsNull(i)) { switch (pt) { case PropertyValueType.Blob: { var propVal = new MgBlobProperty(name, null); propVal.SetNull(true); props.Add(propVal); } break; case PropertyValueType.Boolean: { var propVal = new MgBooleanProperty(name, false); propVal.SetNull(true); props.Add(propVal); } break; case PropertyValueType.Byte: { var propVal = new MgByteProperty(name, 0); propVal.SetNull(true); props.Add(propVal); } break; case PropertyValueType.Clob: { var propVal = new MgClobProperty(name, null); propVal.SetNull(true); props.Add(propVal); } break; case PropertyValueType.DateTime: { var propVal = new MgDateTimeProperty(name, null); propVal.SetNull(true); props.Add(propVal); } break; case PropertyValueType.Double: { var propVal = new MgDoubleProperty(name, 0.0); propVal.SetNull(true); props.Add(propVal); } break; case PropertyValueType.Geometry: { var propVal = new MgGeometryProperty(name, null); propVal.SetNull(true); props.Add(propVal); } break; case PropertyValueType.Int16: { var propVal = new MgInt16Property(name, 0); propVal.SetNull(true); props.Add(propVal); } break; case PropertyValueType.Int32: { var propVal = new MgInt32Property(name, 0); propVal.SetNull(true); props.Add(propVal); } break; case PropertyValueType.Int64: { var propVal = new MgInt64Property(name, 0L); propVal.SetNull(true); props.Add(propVal); } break; case PropertyValueType.Single: { var propVal = new MgSingleProperty(name, 0.0f); propVal.SetNull(true); props.Add(propVal); } break; case PropertyValueType.String: { var propVal = new MgStringProperty(name, ""); propVal.SetNull(true); props.Add(propVal); } break; default: throw new NotSupportedException(); } } else { switch (pt) { case PropertyValueType.Blob: { var bytes = record.GetBlob(i); var br = new MgByteSource(bytes, bytes.Length); var bv = new MgBlobProperty(name, br.GetReader()); props.Add(bv); } break; case PropertyValueType.Boolean: { props.Add(new MgBooleanProperty(name, record.GetBoolean(i))); } break; case PropertyValueType.Byte: { props.Add(new MgByteProperty(name, record.GetByte(i))); } break; case PropertyValueType.Clob: { var bytes = record.GetBlob(i); var br = new MgByteSource(bytes, bytes.Length); var bv = new MgClobProperty(name, br.GetReader()); props.Add(bv); } break; case PropertyValueType.DateTime: { var dt = record.GetDateTime(i); var mdt = new MgDateTime((short)dt.Year, (short)dt.Month, (short)dt.Day, (short)dt.Hour, (short)dt.Minute, (short)dt.Second, dt.Millisecond * 1000); props.Add(new MgDateTimeProperty(name, mdt)); } break; case PropertyValueType.Double: { props.Add(new MgDoubleProperty(name, record.GetDouble(i))); } break; case PropertyValueType.Geometry: { MgByteReader agf = GeomConverter.GetAgf(record.GetGeometry(i)); props.Add(new MgGeometryProperty(name, agf)); } break; case PropertyValueType.Int16: { props.Add(new MgInt16Property(name, record.GetInt16(i))); } break; case PropertyValueType.Int32: { props.Add(new MgInt32Property(name, record.GetInt32(i))); } break; case PropertyValueType.Int64: { props.Add(new MgInt64Property(name, record.GetInt64(i))); } break; case PropertyValueType.Single: { props.Add(new MgSingleProperty(name, record.GetSingle(i))); } break; case PropertyValueType.String: { props.Add(new MgStringProperty(name, record.GetString(i))); } break; default: throw new NotSupportedException(); } } } }
public void StringPropertyCollection() { MgStringProperty prop1 = new MgStringProperty("prop1", "val1"); MgStringProperty prop2 = new MgStringProperty("prop2", "val2"); MgStringProperty prop3 = new MgStringProperty("prop3", "val3"); MgStringProperty prop4 = new MgStringProperty("prop4", "val4"); MgStringPropertyCollection coll = new MgStringPropertyCollection(); coll.Add(prop1); coll.Add(prop2); coll.Remove(prop3); coll.Remove(coll[1]); Assert.AreEqual(1, coll.Count); coll.Add(prop3); coll[1] = prop2; coll.Insert(2, prop3); Assert.AreEqual(2, coll.IndexOf(prop3)); coll.Add(prop4); string txt = ""; foreach (MgStringProperty prop in coll) { txt += "[" + prop.GetName() + "]"; } Assert.AreEqual("[prop1][prop2][prop3][prop4]", txt); }
//---------------------------------------------------------------------------------------- // �� �ܣ� ���ڴ�������ݣ�x��y�������ռ��Ҫ������ // // �� �ߣ� // // // �� �ڣ�2007.05.# // //----------------------------------------------------------------------------------------- public MgPropertyCollection MakePoint(string name, double x, double y) { MgPropertyCollection propertyCollection = new MgPropertyCollection(); MgStringProperty nameProperty = new MgStringProperty("NAME", name); propertyCollection.Add(nameProperty); MgWktReaderWriter wktReaderWriter = new MgWktReaderWriter(); MgAgfReaderWriter agfReaderWriter = new MgAgfReaderWriter(); MgGeometry geometry = wktReaderWriter.Read("POINT XY (" + x.ToString() + " " + y.ToString() + ")"); MgByteReader geometryByteReader = agfReaderWriter.Write(geometry); MgGeometryProperty geometryProperty = new MgGeometryProperty("GEOM", geometryByteReader); propertyCollection.Add(geometryProperty); return propertyCollection; }
private void InsertRedlineGeometry(string text, MgGeometry geom, RedlineAction onRedlineAdded) { MgPropertyCollection feature = new MgPropertyCollection(); MgByteReader agf = _agfRW.Write(geom); MgGeometryProperty geomProp = new MgGeometryProperty(RedlineSchemaFactory.GEOM_NAME, agf); feature.Add(geomProp); MgStringProperty strProp = new MgStringProperty(RedlineSchemaFactory.TEXT_NAME, text); feature.Add(strProp); MgMapBase map = _viewer.GetMap(); MgLayerCollection layers = map.GetLayers(); MgLayerBase redlineLayer = layers.GetItem(_layer.SystemName); MgClassDefinition cls = redlineLayer.GetClassDefinition(); MgPropertyDefinitionCollection idProps = cls.GetIdentityProperties(); MgPropertyDefinition idProp = idProps.GetItem(0); redlineLayer.ForceRefresh(); //This lib doesn't reference mg-desktop so the convenience APIs aren't available to us //Gotta go the old verbose route MgFeatureCommandCollection commands = new MgFeatureCommandCollection(); MgInsertFeatures insert = new MgInsertFeatures(redlineLayer.FeatureClassName, feature); commands.Add(insert); MgPropertyCollection result = redlineLayer.UpdateFeatures(commands); //Insert result is a MgFeatureProperty containing an MgFeatureReader MgFeatureProperty insertResult = result.GetItem(0) as MgFeatureProperty; MgStringProperty errorResult = result.GetItem(0) as MgStringProperty; if (insertResult != null) { var reader = insertResult.GetValue(); int inserted = 0; int? id = null; try { if (reader.ReadNext()) { inserted++; id = reader.GetInt32(idProp.Name); } } catch (MgException ex) { ex.Dispose(); } finally { reader.Close(); } if (inserted > 0) { _viewer.RefreshMap(); onRedlineAdded(id, text); } } else if (errorResult != null) { throw new Exception(errorResult.GetValue()); } }
internal void UpdateRedlineText(string text, int[] ids) { MgMapBase map = _viewer.GetMap(); MgLayerCollection layers = map.GetLayers(); MgLayerBase redlineLayer = layers.GetItem(_layer.SystemName); //HACK: Workaround FeatId leaky abstraction in SHP provider MgClassDefinition cls = redlineLayer.GetClassDefinition(); MgPropertyDefinitionCollection idProps = cls.GetIdentityProperties(); MgPropertyDefinition idProp = idProps.GetItem(0); redlineLayer.ForceRefresh(); //This lib doesn't reference mg-desktop so the convenience APIs aren't available to us //Gotta go the old verbose route List<string> filters = new List<string>(); foreach (int id in ids) { filters.Add(idProp.Name + " = " + id); } string updateFilter = string.Join(" OR ", filters.ToArray()); MgFeatureCommandCollection commands = new MgFeatureCommandCollection(); MgPropertyCollection updateValues = new MgPropertyCollection(); MgStringProperty updateProp = new MgStringProperty(RedlineSchemaFactory.TEXT_NAME, text); updateValues.Add(updateProp); MgUpdateFeatures update = new MgUpdateFeatures(redlineLayer.FeatureClassName, updateValues, updateFilter); commands.Add(update); MgPropertyCollection result = redlineLayer.UpdateFeatures(commands); MgInt32Property updateResult = result.GetItem(0) as MgInt32Property; MgStringProperty errorResult = result.GetItem(0) as MgStringProperty; if (errorResult != null) { throw new Exception(errorResult.GetValue()); } _viewer.RefreshMap(); }
internal void AddRedlineLayer(RedlineLayer layer, string fdoProvider) { var fsId = GetRegistryFeatureSource(); MgFeatureCommandCollection commands = new MgFeatureCommandCollection(); MgPropertyCollection insertVals = new MgPropertyCollection(); MgStringProperty regId = new MgStringProperty("ResourceId", layer.FeatureSource); MgStringProperty ldfId = new MgStringProperty("LayerDefinition", layer.LayerDefinition); MgStringProperty name = new MgStringProperty("Name", layer.Name); MgStringProperty provider = new MgStringProperty("FdoProvider", fdoProvider); MgInt32Property geomTypes = new MgInt32Property("GeometryTypes", layer.GeometryTypes); MgInt32Property styleType = new MgInt32Property("StyleType", (int)layer.StyleType); insertVals.Add(regId); insertVals.Add(ldfId); insertVals.Add(name); insertVals.Add(provider); insertVals.Add(geomTypes); insertVals.Add(styleType); MgInsertFeatures insert = new MgInsertFeatures("Default:MarkupRegistry", insertVals); commands.Add(insert); MgPropertyCollection result = _featSvc.UpdateFeatures(fsId, commands, false); MgFeatureProperty insertResult = result.GetItem(0) as MgFeatureProperty; if (insertResult != null) { MgFeatureReader fr = insertResult.GetValue(); fr.Close(); } }
public void StringProperty() { MgStringProperty sp = new MgStringProperty("TestStringName", "TestStringValue"); Assert.AreEqual("TestStringValue", sp.Value); Assert.AreEqual("TestStringName", sp.Name); Assert.AreEqual(MgPropertyType.String, sp.PropertyType); }
public MgProperty GenerateProperty() { MgProperty prop = null; if (IsReadOnly || IsIdentity || !IsUpdated) return null; switch (PropertyType) { case MgPropertyType.Boolean: bool val = new bool(); if (!bool.TryParse(Value.ToString(), out val)) { throw new InvalidOperationException(string.Format("<b>{0}</b> - נתון אינו תקין", Alias)); } prop = new MgBooleanProperty(Name, val); break; case MgPropertyType.Byte: byte val2 = new byte(); if (!byte.TryParse(Value.ToString(), out val2)) { throw new InvalidOperationException(string.Format("<b>{0}</b> - נתון אינו תקין", Alias)); } prop = new MgByteProperty(Name, val2); break; case MgPropertyType.Double: double val3 = new double(); if (!double.TryParse(Value.ToString(), out val3)) { throw new InvalidOperationException(string.Format("<b>{0}</b> חייב להיות מספר", Alias)); } prop = new MgDoubleProperty(Name, val3); break; case MgPropertyType.Int16: short val4 = new short(); if (!short.TryParse(Value.ToString(), out val4)) { throw new InvalidOperationException(string.Format("<b>{0}</b> חייב להיות מספר", Alias)); } prop = new MgInt16Property(Name, val4); break; case MgPropertyType.Int32: int val5 = new int(); if (!int.TryParse(Value.ToString(), out val5)) { throw new InvalidOperationException(string.Format("<b>{0}</b> חייב להיות מספר", Alias)); } prop = new MgInt32Property(Name, val5); break; case MgPropertyType.Int64: long val6 = new long(); if (!long.TryParse(Value.ToString(), out val6)) { throw new InvalidOperationException(string.Format("<b>{0}</b> חייב להיות מספר", Alias)); } prop = new MgInt64Property(Name, val6); break; case MgPropertyType.DateTime: MgDateTime dt = new MgDateTime(); short day, month, year; if (Alias == "תאריך עדכון" || Alias == "עדכון אחרון") { Value = DateTime.Now.ToString("dd/MM/yyyy"); } string[] arrDT = Value.ToString().Split('/'); if (!short.TryParse(arrDT[0], out day) || !short.TryParse(arrDT[1], out month) || !short.TryParse(arrDT[2], out year)) { throw new InvalidOperationException(string.Format("<b>{0}</b> פורמת תאריך שגוי", Alias)); } dt.Day = day; dt.Month = month; dt.Year = year; prop = new MgDateTimeProperty(Name, dt); break; case MgPropertyType.String: string val7 = ""; val7 = Value.ToString(); prop = new MgStringProperty(Name, val7); break; default: break; } return prop; }