public GdaService(StatelessServiceContext context)
            : base(context)
        {
            this.logger = CloudLoggerFactory.GetLogger(ServiceEventSource.Current, context);

            this.baseLogString = $"{this.GetType()} [{this.GetHashCode()}] =>{Environment.NewLine}";
            Logger.LogDebug($"{baseLogString} Ctor => Logger initialized");

            try
            {
                //LOGIC
                _ = Config.GetInstance(this.Context);

                string debugMessage = $"{baseLogString} Ctor => Configuration initialized.";
                Logger.LogDebug(debugMessage);

                //LOGIC
                this.networkModel = new NetworkModel();

                string infoMessage = $"{baseLogString} Ctor => NetworkModel created.";
                Logger.LogInformation(infoMessage);

                //LOGIC
                this.genericDataAccess   = new GenericDataAccess(networkModel);
                this.nmsTransactionActor = new NmsTransactionActor(networkModel);

                infoMessage = $"{baseLogString} Ctor => Contract providers initialized.";
                Logger.LogInformation(infoMessage);
            }
            catch (Exception e)
            {
                string errMessage = $"{baseLogString} Ctor => Exception caught: {e.Message}.";
                Logger.LogError(errMessage, e);
            }
        }
 public NMSGdaService(StatefulServiceContext context)
     : base(context)
 {
     this.logger = CloudLoggerFactory.GetLogger(ServiceEventSource.Current, context);
     Logger.LogInformation("GdaService Constructor started.");
     this.networkModel      = new NetworkModel(this.StateManager);
     this.genericDataAccess = new GenericDataAccess(networkModel);
     Logger.LogInformation("GdaService finished");
 }
Example #3
0
        public GetRelatedValues()
        {
            InitializeComponent();

            Connection.Connection connection = new Connection.Connection();
            connection.Connect();
            INetworkModelGDAContract proxy = connection.Proxy;

            DataContext = new GetRelatedValuesViewModel(proxy);
        }
Example #4
0
        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);
        }
Example #5
0
 public bool Connect()
 {
     try
     {
         var binding = new NetTcpBinding();
         ChannelFactory <INetworkModelGDAContract> factory = new ChannelFactory <INetworkModelGDAContract>("*");
         proxy = factory.CreateChannel();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
        private async Task <Dictionary <long, ResourceDescription> > GetExtentValues(ModelCode entityType, List <ModelCode> propIds)
        {
            int iteratorId;

            try
            {
                INetworkModelGDAContract gdaClient = NetworkModelGdaClient.CreateClient();
                iteratorId = await gdaClient.GetExtentValues(entityType, propIds);
            }
            catch (Exception e)
            {
                string message = $"GetExtentValues => Entity type: {entityType}, Exception Message: {e.Message}.";
                Logger.LogError(message, e);
                throw e;
            }

            return(await ProcessIterator(iteratorId));
        }
Example #7
0
        public async Task <long> TestGetversion()
        {
            string message = "Get versions method started.";

            Console.WriteLine(message);

            long version = -1;

            try
            {
                networkModelGdaClient = NetworkModelGdaClient.CreateClient();
                version = await networkModelGdaClient.GetVersion();
            }
            catch (Exception e)
            {
                Console.WriteLine($"Get version failed with error: {e.Message}");
            }
            return(version);
        }
Example #8
0
        public async Task <ResourceDescription> GetValues(long globalId)
        {
            string message = "Getting values method started.";

            Console.WriteLine(message);
            //CommonTrace.WriteTrace(CommonTrace.TraceError, message);

            XmlTextWriter       xmlWriter = null;
            ResourceDescription rd        = null;

            try
            {
                short            type       = ModelCodeHelper.ExtractTypeFromGlobalId(globalId);
                List <ModelCode> properties = modelResourcesDesc.GetAllPropertyIds((DMSType)type);

                networkModelGdaClient = NetworkModelGdaClient.CreateClient();
                rd = await networkModelGdaClient.GetValues(globalId, properties);

                xmlWriter            = new XmlTextWriter(Config.Instance.ResultDirecotry + "\\GetValues_Results.xml", Encoding.Unicode);
                xmlWriter.Formatting = Formatting.Indented;
                rd.ExportToXml(xmlWriter);
                xmlWriter.Flush();

                message = "Getting values method successfully finished.";
                Console.WriteLine(message);
                //CommonTrace.WriteTrace(CommonTrace.TraceError, message);
            }
            catch (Exception e)
            {
                message = string.Format("Getting values method for entered id = {0} failed.\n\t{1}", globalId, e.Message);
                Console.WriteLine(message);
                //CommonTrace.WriteTrace(CommonTrace.TraceError, message);
            }
            finally
            {
                if (xmlWriter != null)
                {
                    xmlWriter.Close();
                }
            }

            return(rd);
        }
Example #9
0
        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);
        }
Example #10
0
        public async Task <UpdateResult> TestApplyDeltaInsert()
        {
            string message = "Apply update method started.";

            Console.WriteLine(message);
            //CommonTrace.WriteTrace(CommonTrace.TraceInfo, message);


            UpdateResult updateResult = null;

            try
            {
                Dictionary <DMSType, ResourceDescription> updates = CreateResourcesToInsert();
                Delta delta = new Delta();

                foreach (ResourceDescription rd in updates.Values)
                {
                    delta.AddDeltaOperation(DeltaOpType.Insert, rd, true);
                }

                networkModelGdaClient = NetworkModelGdaClient.CreateClient();
                updateResult          = await networkModelGdaClient.ApplyUpdate(delta);

                message = "Apply update method finished. \n" + updateResult.ToString();
                Console.WriteLine(message);
                //CommonTrace.WriteTrace(CommonTrace.TraceInfo, message);
            }
            catch (Exception ex)
            {
                message = string.Format("Apply update method failed. {0}\n", ex.Message);

                if (updateResult != null)
                {
                    message += updateResult.ToString();
                }

                Console.WriteLine(message);
                // CommonTrace.WriteTrace(CommonTrace.TraceError, message);
            }

            return(updateResult);
        }
Example #11
0
        public async Task <UpdateResult> TestApplyDeltaDelete(List <long> gids)
        {
            string message = "Testing apply delta delete method started.";

            Console.WriteLine(message);
            //CommonTrace.WriteTrace(CommonTrace.TraceInfo, message);

            UpdateResult updateResult = null;

            try
            {
                Delta delta            = new Delta();
                ResourceDescription rd = null;

                foreach (long gid in gids)
                {
                    rd = new ResourceDescription(gid);
                    delta.AddDeltaOperation(DeltaOpType.Delete, rd, true);
                }

                networkModelGdaClient = NetworkModelGdaClient.CreateClient();
                updateResult          = await networkModelGdaClient.ApplyUpdate(delta);

                message = "Testing apply delta delete method finished. \n" + updateResult.ToString();
                Console.WriteLine(message);
                //CommonTrace.WriteTrace(CommonTrace.TraceInfo, message);
            }
            catch (Exception ex)
            {
                message = string.Format("Testing apply delta delete method failed. {0}\n", ex.Message);

                if (updateResult != null)
                {
                    message += updateResult.ToString();
                }

                Console.WriteLine(message);
                //CommonTrace.WriteTrace(CommonTrace.TraceError, message);
            }

            return(updateResult);
        }
        private async Task <Dictionary <long, ResourceDescription> > ProcessIterator(int iteratorId)
        {
            int resourcesLeft;
            int numberOfResources = 10000;
            Dictionary <long, ResourceDescription> resourceDescriptions;

            try
            {
                INetworkModelGDAContract gdaClient = NetworkModelGdaClient.CreateClient();
                resourcesLeft = await gdaClient.IteratorResourcesTotal(iteratorId);

                resourceDescriptions = new Dictionary <long, ResourceDescription>(resourcesLeft);

                while (resourcesLeft > 0)
                {
                    List <ResourceDescription> resources = await gdaClient.IteratorNext(numberOfResources, iteratorId);

                    foreach (ResourceDescription resource in resources)
                    {
                        resourceDescriptions.Add(resource.Id, resource);
                    }

                    resourcesLeft = await gdaClient.IteratorResourcesLeft(iteratorId);
                }

                await gdaClient.IteratorClose(iteratorId);
            }
            catch (Exception e)
            {
                string message = $"Failed to retrieve all Resourse descriptions with iterator {iteratorId}.";
                Logger.LogError(message, e);
                throw e;
            }

            return(resourceDescriptions);
        }
Example #13
0
        private async Task <Dictionary <long, IScadaModelPointItem> > CreatePointItemsFromNetworkModelMeasurements(Dictionary <byte, List <long> > modelChanges)
        {
            Dictionary <long, IScadaModelPointItem> pointItems = new Dictionary <long, IScadaModelPointItem>();

            INetworkModelGDAContract nmsGdaClient = NetworkModelGdaClient.CreateClient();

            int iteratorId;
            int resourcesLeft;
            int numberOfResources = 10000;

            List <ModelCode> props;

            //TOOD: change service contract IModelUpdateNotificationContract to receive types of all changed elements from NMS
            var changedTypesHashSet = new HashSet <ModelCode>();

            foreach (var gids in modelChanges.Values)
            {
                foreach (var gid in gids)
                {
                    ModelCode type = modelResourceDesc.GetModelCodeFromId(gid);
                    changedTypesHashSet.Add(type);
                }
            }

            foreach (ModelCode type in changedTypesHashSet)
            {
                if (type != ModelCode.ANALOG && type != ModelCode.DISCRETE)
                {
                    continue;
                }

                props = modelResourceDesc.GetAllPropertyIds(type);

                try
                {
                    iteratorId = await nmsGdaClient.GetExtentValues(type, props);

                    resourcesLeft = await nmsGdaClient.IteratorResourcesLeft(iteratorId);

                    while (resourcesLeft > 0)
                    {
                        List <ResourceDescription> resources = await nmsGdaClient.IteratorNext(numberOfResources, iteratorId);

                        foreach (ResourceDescription rd in resources)
                        {
                            if (pointItems.ContainsKey(rd.Id))
                            {
                                string message = $"{baseLogString} CreatePointItemsFromNetworkModelMeasurements => Trying to create point item for resource that already exists in model. Gid: 0x{rd.Id:X16}";
                                Logger.LogError(message);
                                throw new ArgumentException(message);
                            }

                            IScadaModelPointItem point;

                            //change service contract IModelUpdateNotificationContract => change List<long> to Hashset<long>
                            if (modelChanges[(byte)DeltaOpType.Update].Contains(rd.Id) || modelChanges[(byte)DeltaOpType.Insert].Contains(rd.Id))
                            {
                                point = CreatePointItemFromResource(rd);
                                pointItems.Add(rd.Id, point);
                            }
                        }

                        resourcesLeft = await nmsGdaClient.IteratorResourcesLeft(iteratorId);
                    }

                    await nmsGdaClient.IteratorClose(iteratorId);
                }
                catch (Exception ex)
                {
                    string errorMessage = $"{baseLogString} CreatePointItemsFromNetworkModelMeasurements => Failed with error: {ex.Message}";
                    Logger.LogError(errorMessage, ex);
                }
            }

            return(pointItems);
        }
Example #14
0
 public AbstractViewModel(INetworkModelGDAContract proxy)
 {
     this.proxy             = proxy;
     this.modelResurcesDesc = new ModelResourcesDesc();
 }
Example #15
0
        public async Task <List <long> > GetRelatedValues(long sourceGlobalId, Association association)
        {
            string message = "Getting related values method started.";

            Console.WriteLine(message);
            //CommonTrace.WriteTrace(CommonTrace.TraceError, message);

            List <long> resultIds = new List <long>();


            XmlTextWriter xmlWriter         = null;
            int           numberOfResources = 2;

            try
            {
                List <ModelCode> properties = new List <ModelCode>();
                //properties.Add(ModelCode.IDOBJ_DESCRIPTION);
                properties.Add(ModelCode.IDOBJ_MRID);
                properties.Add(ModelCode.IDOBJ_NAME);

                networkModelGdaClient = NetworkModelGdaClient.CreateClient();
                int iteratorId = await networkModelGdaClient.GetRelatedValues(sourceGlobalId, properties, association);

                int resourcesLeft = await networkModelGdaClient.IteratorResourcesLeft(iteratorId);

                xmlWriter            = new XmlTextWriter(Config.Instance.ResultDirecotry + "\\GetRelatedValues_Results.xml", Encoding.Unicode);
                xmlWriter.Formatting = Formatting.Indented;

                while (resourcesLeft > 0)
                {
                    networkModelGdaClient = NetworkModelGdaClient.CreateClient();
                    List <ResourceDescription> rds = await networkModelGdaClient.IteratorNext(numberOfResources, iteratorId);

                    for (int i = 0; i < rds.Count; i++)
                    {
                        resultIds.Add(rds[i].Id);
                        rds[i].ExportToXml(xmlWriter);
                        xmlWriter.Flush();
                    }

                    resourcesLeft = await networkModelGdaClient.IteratorResourcesLeft(iteratorId);
                }

                networkModelGdaClient = NetworkModelGdaClient.CreateClient();
                await networkModelGdaClient.IteratorClose(iteratorId);

                message = "Getting related values method successfully finished.";
                Console.WriteLine(message);
                // CommonTrace.WriteTrace(CommonTrace.TraceError, message);
            }
            catch (Exception e)
            {
                message = string.Format("Getting related values method  failed for sourceGlobalId = {0} and association (propertyId = {1}, type = {2}). Reason: {3}", sourceGlobalId, association.PropertyId, association.Type, e.Message);
                Console.WriteLine(message);
                //CommonTrace.WriteTrace(CommonTrace.TraceError, message);
            }
            finally
            {
                if (xmlWriter != null)
                {
                    xmlWriter.Close();
                }
            }

            return(resultIds);
        }
        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);
        }
Example #17
0
 public GetExtentValuesViewModel(INetworkModelGDAContract proxy) : base(proxy)
 {
     this.LoadValues = new GetExtentValuesCommand(this);
 }
Example #18
0
        public async Task <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);

                    networkModelGdaClient = NetworkModelGdaClient.CreateClient();
                    iteratorId            = await networkModelGdaClient.GetExtentValues(modelResourcesDesc.GetModelCodeFromType(type), properties);

                    int count = await networkModelGdaClient.IteratorResourcesLeft(iteratorId);

                    while (count > 0)
                    {
                        networkModelGdaClient = NetworkModelGdaClient.CreateClient();
                        List <ResourceDescription> rds = await networkModelGdaClient.IteratorNext(numberOfResources, iteratorId);

                        for (int i = 0; i < rds.Count; i++)
                        {
                            ids.Add(rds[i].Id);
                        }

                        count = await networkModelGdaClient.IteratorResourcesLeft(iteratorId);
                    }

                    networkModelGdaClient = NetworkModelGdaClient.CreateClient();
                    bool ok = await networkModelGdaClient.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);
        }
Example #19
0
        public async Task <List <long> > GetExtentValues(ModelCode modelCode)
        {
            string message = "Getting extent values method started.";

            Console.WriteLine(message);
            //CommonTrace.WriteTrace(CommonTrace.TraceError, message);

            XmlTextWriter xmlWriter  = null;
            int           iteratorId = 0;
            List <long>   ids        = new List <long>();

            try
            {
                int numberOfResources = 2;
                int resourcesLeft     = 0;

                List <ModelCode> properties = modelResourcesDesc.GetAllPropertyIds(modelCode);

                networkModelGdaClient = NetworkModelGdaClient.CreateClient();
                iteratorId            = await networkModelGdaClient.GetExtentValues(modelCode, properties);

                resourcesLeft = await networkModelGdaClient.IteratorResourcesLeft(iteratorId);


                xmlWriter            = new XmlTextWriter(Config.Instance.ResultDirecotry + "\\GetExtentValues_Results.xml", Encoding.Unicode);
                xmlWriter.Formatting = Formatting.Indented;

                while (resourcesLeft > 0)
                {
                    networkModelGdaClient = NetworkModelGdaClient.CreateClient();
                    List <ResourceDescription> rds = await networkModelGdaClient.IteratorNext(numberOfResources, iteratorId);

                    for (int i = 0; i < rds.Count; i++)
                    {
                        ids.Add(rds[i].Id);
                        rds[i].ExportToXml(xmlWriter);
                        xmlWriter.Flush();
                    }

                    resourcesLeft = await networkModelGdaClient.IteratorResourcesLeft(iteratorId);
                }
                networkModelGdaClient = NetworkModelGdaClient.CreateClient();
                await networkModelGdaClient.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);
            }
            finally
            {
                if (xmlWriter != null)
                {
                    xmlWriter.Close();
                }
            }

            return(ids);
        }
Example #20
0
        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);
        }