public List <long> TestGetExtentValuesAllTypes() { string message = "Getting extent values for all DMS types started."; Console.WriteLine(message); CommonTrace.WriteTrace(CommonTrace.TraceInfo, message); List <ModelCode> properties = new List <ModelCode>(); List <long> ids = new List <long>(); int iteratorId = 0; int numberOfResources = 1000; DMSType currType = 0; try { foreach (DMSType type in Enum.GetValues(typeof(DMSType))) { currType = type; properties = modelResourcesDesc.GetAllPropertyIds(type); iteratorId = GdaQueryProxy.GetExtentValues(modelResourcesDesc.GetModelCodeFromType(type), properties); int count = GdaQueryProxy.IteratorResourcesLeft(iteratorId); while (count > 0) { List <ResourceDescription> rds = GdaQueryProxy.IteratorNext(numberOfResources, iteratorId); for (int i = 0; i < rds.Count; i++) { ids.Add(rds[i].Id); } count = GdaQueryProxy.IteratorResourcesLeft(iteratorId); } bool ok = GdaQueryProxy.IteratorClose(iteratorId); message = string.Format("Number of {0} in model {1}.", type, ids.Count); Console.WriteLine(message); CommonTrace.WriteTrace(CommonTrace.TraceInfo, message); } message = "Getting extent values for all DMS types successfully ended."; Console.WriteLine(message); CommonTrace.WriteTrace(CommonTrace.TraceInfo, message); } catch (Exception e) { message = string.Format("Getting extent values for all DMS types failed for type {0}.\n\t{1}", currType, e.Message); Console.WriteLine(message); CommonTrace.WriteTrace(CommonTrace.TraceInfo, message); throw; } return(ids); }
public GetExtentValues() { InitializeComponent(); DataContext = this; ClassTypes = new ObservableCollection <ClassTypeViewModel>(); try { tgda = new TestGda(); } catch (Exception ex) { MessageBox.Show(ex.Message, "GetExtentValues", MessageBoxButton.OK, MessageBoxImage.Error); } foreach (DMSType dmsType in Enum.GetValues(typeof(DMSType))) { if (dmsType == DMSType.MASK_TYPE) { continue; } ModelCode dmsTypesModelCode = modelResourcesDesc.GetModelCodeFromType(dmsType); ClassTypes.Add(new ClassTypeViewModel() { ClassType = dmsTypesModelCode }); } SelectedType = null; }
public GetValues() { InitializeComponent(); DataContext = this; GlobalIdentifiers = new ObservableCollection<GlobalIdentifierViewModel>(); try { tgda = new TestGda(); } catch (Exception ex) { MessageBox.Show(ex.Message, "GetValues", MessageBoxButton.OK, MessageBoxImage.Error); } foreach (DMSType dmsType in Enum.GetValues(typeof(DMSType))) { if (dmsType == DMSType.MASK_TYPE) { continue; } ModelCode dmsTypesModelCode = modelResourcesDesc.GetModelCodeFromType(dmsType); tgda.GetExtentValues(dmsTypesModelCode, new List<ModelCode> { ModelCode.IDOBJ_GID }, null).ForEach(g => GlobalIdentifiers.Add(new GlobalIdentifierViewModel() { GID = g, Type = dmsTypesModelCode.ToString(), })); } SelectedGID = null; }
private async Task Initialize() { foreach (DMSType dmsType in Enum.GetValues(typeof(DMSType))) { if (dmsType == DMSType.MASK_TYPE) { continue; } ModelCode dmsTypesModelCode = modelResourcesDesc.GetModelCodeFromType(dmsType); List <long> gids = await tgda.GetExtentValues(dmsTypesModelCode, new List <ModelCode>() { ModelCode.IDOBJ_GID }, null); foreach (long gid in gids) { Dispatcher.Invoke(() => { GlobalIdentifiers.Add(new GlobalIdentifierViewModel() { GID = gid, Type = dmsTypesModelCode.ToString(), }); }); } } }
private async void InitializeGlobalIdentifiers() { using (NetworkModelGDAProxy gdaProxy = proxyFactory.CreateProxy <NetworkModelGDAProxy, INetworkModelGDAContract>(EndpointNames.NetworkModelGDAEndpoint)) { if (gdaProxy == null) { throw new NullReferenceException("InitializeGlobalIdentifiers => NetworkModelGDAProxy is null."); } List <ModelCode> propIds = new List <ModelCode> { ModelCode.IDOBJ_GID }; foreach (DMSType dmsType in Enum.GetValues(typeof(DMSType))) { if (dmsType == DMSType.MASK_TYPE || ignorableTypes.Contains(dmsType)) { continue; } ModelCode dmsTypesModelCode = modelResourcesDesc.GetModelCodeFromType(dmsType); int iteratorId; int resourcesLeft; int numberOfResources = 10000; //TODO: connfigurabilno try { iteratorId = gdaProxy.GetExtentValues(dmsTypesModelCode, propIds); resourcesLeft = gdaProxy.IteratorResourcesLeft(iteratorId); while (resourcesLeft > 0) { List <ResourceDescription> gdaResult = gdaProxy.IteratorNext(numberOfResources, iteratorId); foreach (ResourceDescription rd in gdaResult) { Dispatcher.Invoke(() => { GlobalIdentifiers.Add(new GlobalIDBindingModel() { GID = rd.Id, Type = dmsTypesModelCode.ToString(), }); }); } resourcesLeft = gdaProxy.IteratorResourcesLeft(iteratorId); } gdaProxy.IteratorClose(iteratorId); } catch (Exception e) { string message = string.Format("Getting extent values method failed for {0}.\n\t{1}", dmsTypesModelCode, e.Message); Logger.LogError(message); } } } }
private Task InitializeGlobalIdentifiers() { return(Task.Run(async() => { var gdaClient = NetworkModelGdaClient.CreateClient(); List <ModelCode> propIds = new List <ModelCode> { ModelCode.IDOBJ_GID }; foreach (DMSType dmsType in Enum.GetValues(typeof(DMSType))) { if (dmsType == DMSType.MASK_TYPE || ignorableTypes.Contains(dmsType)) { continue; } ModelCode dmsTypesModelCode = modelResourcesDesc.GetModelCodeFromType(dmsType); int iteratorId; int resourcesLeft; int numberOfResources = 10000; //MODO: connfigurabilno try { iteratorId = await gdaClient.GetExtentValues(dmsTypesModelCode, propIds); resourcesLeft = await gdaClient.IteratorResourcesLeft(iteratorId); while (resourcesLeft > 0) { List <ResourceDescription> gdaResult = await gdaClient.IteratorNext(numberOfResources, iteratorId); foreach (ResourceDescription rd in gdaResult) { Dispatcher.Invoke(() => { GlobalIdentifiers.Add(new GlobalIDBindingModel(rd.Id)); }); } resourcesLeft = await gdaClient.IteratorResourcesLeft(iteratorId); } await gdaClient.IteratorClose(iteratorId); } catch (Exception e) { string message = string.Format("Getting extent values method failed for {0}.\n\t{1}", dmsTypesModelCode, e.Message); Logger.LogError(message); } } })); }
protected ObservableCollection <long> GetGIDs(DMSType modelCode) { string message = "Getting extent values method started."; Console.WriteLine(message); CommonTrace.WriteTrace(CommonTrace.TraceError, message); int iteratorId = 0; List <long> ids = new List <long>(); try { int numberOfResources = 2; int resourcesLeft = 0; List <ModelCode> properties = modelResurcesDesc.GetAllPropertyIds(modelCode); iteratorId = Proxy.GetExtentValues(modelResurcesDesc.GetModelCodeFromType(modelCode), properties); resourcesLeft = Proxy.IteratorResourcesLeft(iteratorId); while (resourcesLeft > 0) { List <ResourceDescription> rds = Proxy.IteratorNext(numberOfResources, iteratorId); for (int i = 0; i < rds.Count; i++) { ids.Add(rds[i].Id); } resourcesLeft = Proxy.IteratorResourcesLeft(iteratorId); } Proxy.IteratorClose(iteratorId); message = "Getting extent values method successfully finished."; Console.WriteLine(message); CommonTrace.WriteTrace(CommonTrace.TraceError, message); } catch (Exception e) { message = string.Format("Getting extent values method failed for {0}.\n\t{1}", modelCode, e.Message); Console.WriteLine(message); CommonTrace.WriteTrace(CommonTrace.TraceError, message); } ObservableCollection <long> gids = new ObservableCollection <long>(ids); return(gids); }
public MainWindow() { InitializeComponent(); try { gda = new GDA(); } catch (Exception ex) { MessageBox.Show(ex.Message, "GDA Exception", MessageBoxButton.OK, MessageBoxImage.Error); } foreach (DMSType dmsType in Enum.GetValues(typeof(DMSType))) { if (dmsType == DMSType.MASK_TYPE) { continue; } ModelCode dmsTypesModelCode = modelResourcesDesc.GetModelCodeFromType(dmsType); DMSTypes.Items.Add(dmsTypesModelCode); gda.GetExtentValues(dmsTypesModelCode, new List <ModelCode> { ModelCode.IDOBJ_GID }, null).ForEach(g => longGids.Add(g)); } longGids.ForEach(g => { GIDs.Items.Add(string.Format("{0:X16}", g)); GIDsRelated.Items.Add(string.Format("{0:X16}", g)); }); selectedGID = -1; selectedDMSType = -1; }
public List <long> GetAllGids() { ModelResourcesDesc modelResourcesDesc = new ModelResourcesDesc(); List <ModelCode> properties = new List <ModelCode>(); List <long> ids = new List <long>(); int iteratorId = 0; int numberOfResources = 1000; DMSType currType = 0; properties.Add(ModelCode.IDOBJ_GID); try { foreach (DMSType type in Enum.GetValues(typeof(DMSType))) { currType = type; if (type != DMSType.MASK_TYPE) { iteratorId = GDAQueryProxy.GetExtentValues(modelResourcesDesc.GetModelCodeFromType(type), properties); int count = GDAQueryProxy.IteratorResourcesLeft(iteratorId); while (count > 0) { List <ResourceDescription> rds = GDAQueryProxy.IteratorNext(numberOfResources, iteratorId); for (int i = 0; i < rds.Count; i++) { ids.Add(rds[i].Id); } count = GDAQueryProxy.IteratorResourcesLeft(iteratorId); } bool ok = GDAQueryProxy.IteratorClose(iteratorId); } } } catch (Exception) { throw; } return(ids); }
private List <ModelCode> NadjiTipove(ModelCode kodProp) { ModelResourcesDesc modResDes = new ModelResourcesDesc(); //List<DMSType> tip = new List<DMSType>(); string[] props = (kodProp.ToString()).Split('_'); props[1] = props[1].TrimEnd('S'); DMSType propertyCode = ModelResourcesDesc.GetTypeFromModelCode(kodProp); ModelCode mc; ModelCodeHelper.GetModelCodeFromString(propertyCode.ToString(), out mc); foreach (ModelCode modelCode in Enum.GetValues(typeof(ModelCode))) { if (String.Compare(props[1], modelCode.ToString()) == 0) { DMSType type = ModelCodeHelper.GetTypeFromModelCode(modelCode); if (type == 0) { tipovi = new List <ModelCode>(); List <DMSType> r = modResDes.GetLeaves(modelCode); foreach (DMSType ff in r) { tipovi.Add(modResDes.GetModelCodeFromType(ff)); } } else { tipovi = new List <ModelCode>(); tipovi.Add(modelCode); } } } return(new List <ModelCode>()); }
public string GetExtentValues(DMSType type, List <ModelCode> props) { int iteratorId = 0; List <long> ids = new List <long>(); string ss = ""; bool gidBool = true; ModelCode modelCode = modelResourcesDesc.GetModelCodeFromType(type); try { int numberOfResources = 2; int resourcesLeft = 0; List <ModelCode> properties = props;// modelResourcesDesc.GetAllPropertyIds(modelCode); if (props.Contains(ModelCode.IDOBJ_GID) == false) { properties.Add(ModelCode.IDOBJ_GID); gidBool = false; } iteratorId = GDAQueryProxy.GetExtentValues(modelCode, properties); resourcesLeft = GDAQueryProxy.IteratorResourcesLeft(iteratorId); ss += String.Format("Items with ModelCode: {0}:\n", modelCode.ToString()); while (resourcesLeft > 0) { List <ResourceDescription> rds = GDAQueryProxy.IteratorNext(numberOfResources, iteratorId); for (int i = 0; i < rds.Count; i++) { ss += String.Format("\tItem with gid: 0x{0:x16}\n", rds[i].Properties.Find(r => r.Id == ModelCode.IDOBJ_GID).AsLong()); foreach (Property p in rds[i].Properties) { if (p.Id == ModelCode.IDOBJ_GID && gidBool == false) { } else { ss += String.Format("\t\t{0} =", p.Id); switch (p.Type) { case PropertyType.Float: ss += String.Format(" {0}:\n", p.AsFloat()); break; case PropertyType.Bool: case PropertyType.Int32: case PropertyType.Int64: case PropertyType.Enum: case PropertyType.EnumVector: //case PropertyType.DateTime: if (p.Id == ModelCode.IDOBJ_GID) { ss += (String.Format("0x{0:x16}\n", p.AsLong())); } else if (p.Type == PropertyType.Enum || p.Type == PropertyType.EnumVector) { switch (p.Id) { case ModelCode.CURVE_STYLE: ss += (String.Format($"{(CurveStyle)p.AsEnum()}\n")); break; case ModelCode.CURVE_XMULTIPLIER: ss += (String.Format($"{(UnitMultiplier)p.AsEnum()}\n")); break; case ModelCode.CURVE_XUNIT: ss += (String.Format($"{(UnitSymbol)p.AsEnum()}\n")); break; case ModelCode.CURVE_Y1MULTIPLIER: ss += (String.Format($"{(UnitMultiplier)p.AsEnum()}\n")); break; case ModelCode.CURVE_Y1UNIT: ss += (String.Format($"{(UnitSymbol)p.AsEnum()}\n")); break; case ModelCode.CURVE_Y2MULTIPLIER: ss += (String.Format($"{(UnitMultiplier)p.AsEnum()}\n")); break; case ModelCode.CURVE_Y2UNIT: ss += (String.Format($"{(UnitSymbol)p.AsEnum()}\n")); break; case ModelCode.CURVE_Y3MULTIPLIER: ss += (String.Format($"{(UnitMultiplier)p.AsEnum()}\n")); break; case ModelCode.CURVE_Y3UNIT: ss += (String.Format($"{(UnitSymbol)p.AsEnum()}\n")); break; case ModelCode.SWITCHINGOPERATION_NEWSTATE: ss += (String.Format($"{(SwichState)p.AsEnum()}\n")); break; case ModelCode.BASICINTERVALSCHEDULE_VALUE2UNIT: ss += (String.Format($"{(UnitSymbol)p.AsEnum()}\n")); break; case ModelCode.BASICINTERVALSCHEDULE_VALUE2MULTIPLIER: ss += (String.Format($"{(UnitMultiplier)p.AsEnum()}\n")); break; case ModelCode.BASICINTERVALSCHEDULE_VALUE1UNIT: ss += (String.Format($"{(UnitSymbol)p.AsEnum()}\n")); break; case ModelCode.BASICINTERVALSCHEDULE_VALUE1MULTIPLIER: ss += (String.Format($"{(UnitMultiplier)p.AsEnum()}\n")); break; } } else { ss += String.Format("{0}\n", p.AsLong()); } break; case PropertyType.DateTime: ss += String.Format("{0}\n", p.AsDateTime()); break; case PropertyType.Reference: ss += (String.Format("0x{0:x16}\n", p.AsReference())); break; case PropertyType.String: if (p.PropertyValue.StringValue == null) { p.PropertyValue.StringValue = String.Empty; } ss += String.Format("{0}\n", p.AsString()); break; case PropertyType.ReferenceVector: if (p.AsLongs().Count > 0) { string s = ""; for (int j = 0; j < p.AsLongs().Count; j++) { s += (String.Format("0x{0:x16},\n", p.AsLongs()[j])); } ss += s; } else { ss += ("empty long/reference vector\n"); } break; default: throw new Exception("Failed to export Resource Description as XML. Invalid property type."); } } } } resourcesLeft = GDAQueryProxy.IteratorResourcesLeft(iteratorId); } GDAQueryProxy.IteratorClose(iteratorId); } catch (Exception) { } return(ss); }
private Dictionary <DMSType, ResourceDescription> CreateResourcesToInsert() { long globalId = 0; ResourceDescription rd = null; List <ModelCode> propertyIDs = null; Dictionary <DMSType, ResourceDescription> updates = new Dictionary <DMSType, ResourceDescription>(new DMSTypeComparer()); #region Create resources foreach (DMSType type in modelResourcesDesc.AllDMSTypes) { if (type != DMSType.MASK_TYPE) { globalId = ModelCodeHelper.CreateGlobalId(0, (short)type, -1); propertyIDs = modelResourcesDesc.GetAllPropertyIds(modelResourcesDesc.GetModelCodeFromType(type)); rd = new ResourceDescription(globalId); foreach (ModelCode propertyId in propertyIDs) { if (!modelResourcesDesc.NotSettablePropertyIds.Contains(propertyId)) { switch (Property.GetPropertyType(propertyId)) { case PropertyType.Bool: rd.AddProperty(new Property(propertyId, true)); break; case PropertyType.Byte: rd.AddProperty(new Property(propertyId, (byte)100)); break; case PropertyType.Int32: rd.AddProperty(new Property(propertyId, (int)4)); break; case PropertyType.Int64: case PropertyType.TimeSpan: case PropertyType.DateTime: rd.AddProperty(new Property(propertyId, (long)101)); break; case PropertyType.Enum: rd.AddProperty(new Property(propertyId, (short)1)); break; case PropertyType.Reference: rd.AddProperty(new Property(propertyId)); break; case PropertyType.Float: rd.AddProperty(new Property(propertyId, (float)10.5)); break; case PropertyType.String: rd.AddProperty(new Property(propertyId, "TestString")); break; case PropertyType.Int64Vector: List <long> longVector = new List <long>(); longVector.Add((long)10); longVector.Add((long)11); longVector.Add((long)12); longVector.Add((long)13); longVector.Add((long)14); longVector.Add((long)15); rd.AddProperty(new Property(propertyId, longVector)); break; case PropertyType.FloatVector: List <float> floatVector = new List <float>(); floatVector.Add((float)11.1); floatVector.Add((float)12.2); floatVector.Add((float)13.3); floatVector.Add((float)14.4); floatVector.Add((float)15.5); rd.AddProperty(new Property(propertyId, floatVector)); break; case PropertyType.EnumVector: List <short> enumVector = new List <short>(); enumVector.Add((short)1); enumVector.Add((short)2); enumVector.Add((short)3); rd.AddProperty(new Property(propertyId, enumVector)); break; case PropertyType.StringVector: List <string> stringVector = new List <string>(); stringVector.Add("TestString1"); stringVector.Add("TestString2"); stringVector.Add("TestString3"); stringVector.Add("TestString4"); rd.AddProperty(new Property(propertyId, stringVector)); break; case PropertyType.Int32Vector: List <int> intVector = new List <int>(); intVector.Add(11); intVector.Add(12); intVector.Add(13); intVector.Add(14); rd.AddProperty(new Property(propertyId, intVector)); break; default: break; } } } updates[type] = rd; } } #endregion Create resources #region Set references //SetPowerTransformerReferences(updates); //SetTransformerWindingReferences(updates); //SetWindingTestRefernces(updates); #endregion Set references return(updates); }
private bool PopulateNmsDataFromServer(ModelResourcesDesc resourcesDesc) { bool success = false; string message = "Getting nms data from server started."; Logger.LogInfo(message); using (NetworkModelGDAProxy nmsProxy = proxyFactory.CreateProxy <NetworkModelGDAProxy, INetworkModelGDAContract>(EndpointNames.NetworkModelGDAEndpoint)) { if (nmsProxy == null) { string errMessage = "NetworkModelGdaClient is null."; Logger.LogWarn(errMessage); throw new NullReferenceException(errMessage); } HashSet <ModelCode> requiredEntityTypes = new HashSet <ModelCode>(); foreach (DMSType dmsType in Enum.GetValues(typeof(DMSType))) { if (dmsType == DMSType.MASK_TYPE) { continue; } ModelCode mc = resourcesDesc.GetModelCodeFromType(dmsType); if (!requiredEntityTypes.Contains(mc)) { requiredEntityTypes.Add(mc); } } List <ModelCode> mrIdProp = new List <ModelCode>() { ModelCode.IDOBJ_MRID }; foreach (ModelCode modelCodeType in requiredEntityTypes) { int iteratorId = 0; int resourcesLeft = 0; int numberOfResources = 10000; //TODO: connfigurabilno try { iteratorId = nmsProxy.GetExtentValues(modelCodeType, mrIdProp); resourcesLeft = nmsProxy.IteratorResourcesLeft(iteratorId); while (resourcesLeft > 0) { List <ResourceDescription> gdaResult = nmsProxy.IteratorNext(numberOfResources, iteratorId); foreach (ResourceDescription rd in gdaResult) { if (rd.Properties[0].Id != ModelCode.IDOBJ_MRID) { continue; } string mrId = rd.Properties[0].PropertyValue.StringValue; if (!MridToPositiveGidFromServer.ContainsKey(mrId)) { MridToPositiveGidFromServer.Add(mrId, rd.Id); } else { throw new NotImplementedException("Method PopulateNmsDataFromServer() -> MridToPositiveGid.ContainsKey(mrId) == true"); } } resourcesLeft = nmsProxy.IteratorResourcesLeft(iteratorId); } nmsProxy.IteratorClose(iteratorId); message = "Getting nms data from server successfully finished."; Logger.LogInfo(message); success = true; } catch (Exception e) { message = string.Format("Getting extent values method failed for {0}.\n\t{1}", modelCodeType, e.Message); Logger.LogError(message); success = false; } } } return(success); }
public string GetExtentValues(DMSType type, List <ModelCode> props) { int iteratorId = 0; List <long> ids = new List <long>(); string ss = ""; bool gidBool = true; ModelCode modelCode = modelResourcesDesc.GetModelCodeFromType(type); try { int numberOfResources = 2; int resourcesLeft = 0; List <ModelCode> properties = props;// modelResourcesDesc.GetAllPropertyIds(modelCode); if (props.Contains(ModelCode.IDOBJ_GID) == false) { properties.Add(ModelCode.IDOBJ_GID); gidBool = false; } iteratorId = GDAQueryProxy.GetExtentValues(modelCode, properties); resourcesLeft = GDAQueryProxy.IteratorResourcesLeft(iteratorId); ss += String.Format("Items with ModelCode: {0}:\n", modelCode.ToString()); while (resourcesLeft > 0) { List <ResourceDescription> rds = GDAQueryProxy.IteratorNext(numberOfResources, iteratorId); for (int i = 0; i < rds.Count; i++) { ss += String.Format("\tItem with gid: 0x{0:x16}\n", rds[i].Properties.Find(r => r.Id == ModelCode.IDOBJ_GID).AsLong()); foreach (Property p in rds[i].Properties) { if (p.Id == ModelCode.IDOBJ_GID && gidBool == false) { } else { ss += String.Format("\t\t{0} =", p.Id); switch (p.Type) { case PropertyType.Float: ss += String.Format(" {0}:\n", p.AsFloat()); break; case PropertyType.Bool: case PropertyType.Int32: case PropertyType.Int64: case PropertyType.Enum: case PropertyType.EnumVector: case PropertyType.DateTime: if (p.Id == ModelCode.IDOBJ_GID) { ss += (String.Format("0x{0:x16}\n", p.AsLong())); } else { ss += String.Format("{0}\n", p.AsLong()); } break; case PropertyType.Reference: ss += (String.Format("0x{0:x16}\n", p.AsReference())); break; case PropertyType.String: if (p.PropertyValue.StringValue == null) { p.PropertyValue.StringValue = String.Empty; } ss += String.Format("{0}\n", p.AsString()); break; case PropertyType.ReferenceVector: if (p.AsLongs().Count > 0) { string s = ""; for (int j = 0; j < p.AsLongs().Count; j++) { s += (String.Format("0x{0:x16},\n", p.AsLongs()[j])); } ss += s; //(sb.ToString(0, sb.Length - 2)); } else { ss += ("empty long/reference vector\n"); } break; default: throw new Exception("Failed to export Resource Description as XML. Invalid property type."); } } } } resourcesLeft = GDAQueryProxy.IteratorResourcesLeft(iteratorId); } GDAQueryProxy.IteratorClose(iteratorId); } catch (Exception) { } return(ss); }