bool Get(INetworkModelGDAContract nms) { Dictionary <DMSType, List <ModelCode> > typeToPropertiesMap = ModelResourcesDesc.GetTypeToPropertiesMap(); Dictionary <DMSType, List <ModelCode> > typeToPropertiesMapMeas = new Dictionary <DMSType, List <ModelCode> >(2) { { DMSType.Analog, typeToPropertiesMap[DMSType.Analog] }, { DMSType.Discrete, typeToPropertiesMap[DMSType.Discrete] } }; List <IdentifiedObject> inserted = new List <IdentifiedObject>(insertedGids.Count); List <IdentifiedObject> updated = new List <IdentifiedObject>(updatedGids.Count); List <ResourceDescription> result; int iterator = nms.GetMultipleValues(insertedGids, typeToPropertiesMapMeas, true); do { result = nms.IteratorNext(iteratorCount, iterator, true); if (result == null) { return(false); } foreach (ResourceDescription rd in result) { inserted.Add(IdentifiedObject.Create(rd, true)); } }while(result.Count >= iteratorCount); nms.IteratorClose(iterator); iterator = nms.GetMultipleValues(updatedGids, typeToPropertiesMapMeas, true); do { result = nms.IteratorNext(iteratorCount, iterator, true); if (result == null) { return(false); } foreach (ResourceDescription rd in result) { updated.Add(IdentifiedObject.Create(rd, true)); } }while(result.Count >= iteratorCount); nms.IteratorClose(iterator); Inserted = inserted; Updated = updated; Deleted = deletedGids; return(true); }
IdentifiedObject InsertEntity(ResourceDescription rd) { if (rd == null) { return(null); } DMSType type = ModelCodeHelper.GetTypeFromGID(rd.Id); Container container; if (!containers.TryGetValue(type, out container) || container.Contains(rd.Id)) { return(null); } IdentifiedObject io = IdentifiedObject.Create(rd); if (io == null) { return(null); } foreach (Property prop in rd.Properties.Values) { if (prop.Type == PropertyType.Reference) { long targetGID = ((ReferenceProperty)prop).Value; if (targetGID == 0) { continue; } IdentifiedObject target; Container targetContainer; if (!TryGetEntity(targetGID, out target, out targetContainer)) { return(null); } target = target.Clone(); target.AddTargetReference(prop.Id, io.GID); targetContainer.Set(target); } } containers[type].Add(io); return(io); }
bool Get(INetworkModelGDAContract nms) { Dictionary <DMSType, List <ModelCode> > typeToPropertiesMap = ModelResourcesDesc.GetTypeToPropertiesMap(); DMSType[] types = ModelResourcesDesc.TypeIdsInInsertOrder; Dictionary <DMSType, Dictionary <long, IdentifiedObject> > containers = new Dictionary <DMSType, Dictionary <long, IdentifiedObject> >(types.Length); foreach (DMSType type in types) { Dictionary <long, IdentifiedObject> container = new Dictionary <long, IdentifiedObject>(); int iterator = nms.GetExtentValues(type, typeToPropertiesMap[type], false); if (iterator < 0) { return(false); } List <ResourceDescription> result; do { result = nms.IteratorNext(iteratorCount, iterator, false); if (result == null) { return(false); } foreach (ResourceDescription rd in result) { IdentifiedObject io = rd == null ? null : IdentifiedObject.Create(rd, true); container.Add(io.GID, io); } }while(result.Count >= iteratorCount); nms.IteratorClose(iterator); containers.Add(type, container); } Containers = containers; return(true); }
bool Get(INetworkModelGDAContract nms) { Dictionary <DMSType, List <ModelCode> > typeToPropertiesMap = ModelResourcesDesc.GetTypeToPropertiesMap(); if (insertedGids == null || updatedGids == null || deletedGids == null) { List <IdentifiedObject> inserted = new List <IdentifiedObject>(); DMSType[] types = ModelResourcesDesc.TypeIdsInInsertOrder; foreach (DMSType type in types) { int iterator = nms.GetExtentValues(type, typeToPropertiesMap[type], false); if (iterator < 0) { return(false); } List <ResourceDescription> result; do { result = nms.IteratorNext(iteratorCount, iterator, false); if (result == null) { return(false); } foreach (ResourceDescription rd in result) { if (rd == null) { continue; } inserted.Add(IdentifiedObject.Create(rd, true)); } }while(result.Count >= iteratorCount); nms.IteratorClose(iterator); Inserted = inserted; Updated = new List <IdentifiedObject>(0); Deleted = new List <long>(0); } } else { List <IdentifiedObject> inserted = new List <IdentifiedObject>(insertedGids.Count); List <IdentifiedObject> updated = new List <IdentifiedObject>(updatedGids.Count); List <ResourceDescription> result; int iterator = nms.GetMultipleValues(insertedGids, typeToPropertiesMap, true); do { result = nms.IteratorNext(iteratorCount, iterator, true); if (result == null) { return(false); } foreach (ResourceDescription rd in result) { if (rd == null) { continue; } inserted.Add(IdentifiedObject.Create(rd, true)); } }while(result.Count >= iteratorCount); nms.IteratorClose(iterator); iterator = nms.GetMultipleValues(updatedGids, typeToPropertiesMap, true); do { result = nms.IteratorNext(iteratorCount, iterator, true); if (result == null) { return(false); } foreach (ResourceDescription rd in result) { if (rd == null) { continue; } updated.Add(IdentifiedObject.Create(rd, true)); } }while(result.Count >= iteratorCount); nms.IteratorClose(iterator); Inserted = inserted; Updated = updated; Deleted = deletedGids; } return(true); }
bool Get(INetworkModelGDAContract nms) { Dictionary <long, Analog> analogs = new Dictionary <long, Analog>(); Dictionary <long, Discrete> discretes = new Dictionary <long, Discrete>(); Dictionary <long, Recloser> reclosers = new Dictionary <long, Recloser>(); Dictionary <long, Terminal> terminals = new Dictionary <long, Terminal>(); Dictionary <long, EnergyConsumer> energyConsumers = new Dictionary <long, EnergyConsumer>(); Dictionary <DMSType, List <ModelCode> > typeToPropertiesMap = ModelResourcesDesc.GetTypeToPropertiesMap(); List <ResourceDescription> result; int iterator = nms.GetExtentValues(DMSType.Analog, typeToPropertiesMap[DMSType.Analog], false); do { result = nms.IteratorNext(iteratorCount, iterator, false); if (result == null) { return(false); } foreach (ResourceDescription rd in result) { analogs.Add(rd.Id, (Analog)IdentifiedObject.Create(rd, true)); } }while(result.Count >= iteratorCount); nms.IteratorClose(iterator); iterator = nms.GetExtentValues(DMSType.Discrete, typeToPropertiesMap[DMSType.Discrete], false); do { result = nms.IteratorNext(iteratorCount, iterator, false); if (result == null) { return(false); } foreach (ResourceDescription rd in result) { discretes.Add(rd.Id, (Discrete)IdentifiedObject.Create(rd, true)); } }while(result.Count >= iteratorCount); nms.IteratorClose(iterator); iterator = nms.GetExtentValues(DMSType.EnergyConsumer, typeToPropertiesMap[DMSType.EnergyConsumer], false); do { result = nms.IteratorNext(iteratorCount, iterator, false); if (result == null) { return(false); } foreach (ResourceDescription rd in result) { energyConsumers.Add(rd.Id, (EnergyConsumer)IdentifiedObject.Create(rd, true)); } }while(result.Count >= iteratorCount); nms.IteratorClose(iterator); iterator = nms.GetExtentValues(DMSType.Recloser, typeToPropertiesMap[DMSType.Recloser], false); do { result = nms.IteratorNext(iteratorCount, iterator, false); if (result == null) { return(false); } foreach (ResourceDescription rd in result) { reclosers.Add(rd.Id, (Recloser)IdentifiedObject.Create(rd, true)); } }while(result.Count >= iteratorCount); nms.IteratorClose(iterator); List <long> terminalGIDs = new List <long>(reclosers.Count * 2); foreach (Recloser r in reclosers.Values) { for (int i = 0; i < r.Terminals.Count; ++i) { terminalGIDs.Add(r.Terminals[i]); } } iterator = nms.GetMultipleValues(terminalGIDs, typeToPropertiesMap, false); do { result = nms.IteratorNext(iteratorCount, iterator, false); if (result == null) { return(false); } foreach (ResourceDescription rd in result) { if (terminals.ContainsKey(rd.Id)) { continue; } terminals.Add(rd.Id, (Terminal)IdentifiedObject.Create(rd, true)); } }while(result.Count >= iteratorCount); nms.IteratorClose(iterator); Analogs = analogs; Discretes = discretes; Reclosers = reclosers; Terminals = terminals; EnergyConsumers = energyConsumers; return(true); }