Example #1
0
        /// <summary>
        /// Returns all AOR Areas with full information
        /// </summary>
        /// <param name="areaGid"></param>
        /// <returns></returns>
        public List <AORCachedGroup> GetAORGroupsWithSmInfo()        // LEFT TO DO
        {
            int  iteratorId    = 0;
            int  resourcesLeft = 0;
            long gid           = 0;   // vrati se

            int         numberOfResources = 500;
            Association association       = new Association(ModelCode.AOR_GROUP_SYNCMACHINES, 0, false);

            List <AORGroup>           aorGroups    = GetAORGroups();
            List <AORCachedGroup>     resultIds    = new List <AORCachedGroup>(aorGroups.Count);
            List <SynchronousMachine> syncMachines = null;

            try
            {
                List <ModelCode> properties = modelResourcesDesc.GetAllPropertyIds(ModelCode.SYNCMACHINE);

                foreach (var aorGroup in aorGroups)
                {
                    iteratorId    = GdaQueryProxy.GetRelatedValues(aorGroup.GlobalId, properties, association);
                    resourcesLeft = GdaQueryProxy.IteratorResourcesLeft(iteratorId);
                    syncMachines  = new List <SynchronousMachine>(aorGroup.SynchronousMachines.Count);

                    while (resourcesLeft > 0)
                    {
                        List <ResourceDescription> rds = GdaQueryProxy.IteratorNext(numberOfResources, iteratorId);

                        foreach (ResourceDescription rd in rds)
                        {
                            SynchronousMachine tempSM = new SynchronousMachine(rd.Id);
                            syncMachines.Add(tempSM.ConvertFromRD(rd));
                        }

                        resourcesLeft = GdaQueryProxy.IteratorResourcesLeft(iteratorId);
                    }
                    resultIds.Add(new AORCachedGroup(aorGroup.Name, syncMachines));
                }

                GdaQueryProxy.IteratorClose(iteratorId);

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

            return(resultIds);
        }
Example #2
0
        public List <SynchronousMachine> GetAllDERs()
        {
            int         iteratorId = 0;
            List <long> ids        = new List <long>();
            List <SynchronousMachine> syncMachines = new List <SynchronousMachine>();

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

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

                iteratorId    = GdaQueryProxy.GetExtentValues(ModelCode.SYNCMACHINE, properties);
                resourcesLeft = GdaQueryProxy.IteratorResourcesLeft(iteratorId);

                while (resourcesLeft > 0)
                {
                    List <ResourceDescription> rds = GdaQueryProxy.IteratorNext(numberOfResources, iteratorId);

                    for (int i = 0; i < rds.Count; i++)
                    {
                        var rg = GdaQueryProxy.GetValues(rds[i].Id, properties);
                        SynchronousMachine syncMachine = new SynchronousMachine(rds[i].Id);
                        syncMachines.Add(syncMachine.ConvertFromRD(rg));
                    }

                    resourcesLeft = GdaQueryProxy.IteratorResourcesLeft(iteratorId);
                }

                GdaQueryProxy.IteratorClose(iteratorId);

                CommonTrace.WriteTrace(CommonTrace.TraceError, "Getting extent values method successfully finished.");
            }
            catch (Exception e)
            {
                string message = string.Format("Getting extent values method failed for {0}.\n\t{1}", ModelCode.SYNCMACHINE, e.Message);
                Console.WriteLine(message);
                CommonTrace.WriteTrace(CommonTrace.TraceError, message);
            }

            return(syncMachines);
        }
Example #3
0
        private List <SynchronousMachine> GetSynchronousMachineForSubstations(List <Substation> substations)
        {
            List <SynchronousMachine> resultIds = new List <SynchronousMachine>();

            int         numberOfResources = 500;
            Association association       = new Association(ModelCode.EQCONTAINER_EQUIPMENTS, 0, false);

            try
            {
                List <ModelCode> properties = modelResourcesDesc.GetAllPropertyIds(ModelCode.SYNCMACHINE);

                foreach (Substation substation in substations)
                {
                    int iteratorId    = GdaQueryProxy.GetRelatedValues(substation.GlobalId, properties, association);
                    int resourcesLeft = GdaQueryProxy.IteratorResourcesLeft(iteratorId);

                    while (resourcesLeft > 0)
                    {
                        List <ResourceDescription> rds = GdaQueryProxy.IteratorNext(numberOfResources, iteratorId);

                        foreach (ResourceDescription rd in rds)
                        {
                            SynchronousMachine synchronousMachine = new SynchronousMachine(rd.Id);
                            resultIds.Add(synchronousMachine.ConvertFromRD(rd));
                        }

                        resourcesLeft = GdaQueryProxy.IteratorResourcesLeft(iteratorId);
                    }

                    GdaQueryProxy.IteratorClose(iteratorId);
                }
                CommonTrace.WriteTrace(CommonTrace.TraceError, "Getting extent values method successfully finished.");
            }
            catch (Exception)
            {
                //string message = string.Format("Getting related values method  failed for sourceGlobalId = {0} and association (propertyId = {1}, type = {2}). Reason: {3}", regionGid, association.PropertyId, association.Type, e.Message);
                //Console.WriteLine(message);
                //CommonTrace.WriteTrace(CommonTrace.TraceError, message);
            }

            return(resultIds);
        }
Example #4
0
        public List <SynchronousMachine> GetSyncMachinesForAreaGroupGid(long areaGid)
        {
            List <SynchronousMachine> resultIds = new List <SynchronousMachine>();

            int         numberOfResources = 500;
            Association association       = new Association(ModelCode.AOR_GROUP_SYNCMACHINES, 0, false);

            try
            {
                List <ModelCode> properties = modelResourcesDesc.GetAllPropertyIds(ModelCode.SYNCMACHINE);

                int iteratorId    = GdaQueryProxy.GetRelatedValues(areaGid, properties, association);
                int resourcesLeft = GdaQueryProxy.IteratorResourcesLeft(iteratorId);

                while (resourcesLeft > 0)
                {
                    List <ResourceDescription> rds = GdaQueryProxy.IteratorNext(numberOfResources, iteratorId);

                    foreach (ResourceDescription rd in rds)
                    {
                        SynchronousMachine tempSM = new SynchronousMachine(rd.Id);
                        resultIds.Add(tempSM.ConvertFromRD(rd));
                    }

                    resourcesLeft = GdaQueryProxy.IteratorResourcesLeft(iteratorId);
                }

                GdaQueryProxy.IteratorClose(iteratorId);

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

            return(resultIds);
        }
Example #5
0
        public SynchronousMachine GetSyncMachineByGid(long gid)
        {
            SynchronousMachine syncMachine = null;

            try
            {
                List <ModelCode> properties = modelResourcesDesc.GetAllPropertyIds(ModelCode.SYNCMACHINE);

                ResourceDescription rd = GdaQueryProxy.GetValues(gid, properties);
                syncMachine = new SynchronousMachine(rd.Id);
                syncMachine.ConvertFromRD(rd);
                CommonTrace.WriteTrace(CommonTrace.TraceError, "Getting extent values method successfully finished.");
            }
            catch (Exception e)
            {
                string message = string.Format("Getting extent values method failed for {0}.\n\t{1}", ModelCode.SYNCMACHINE, e.Message);
                Console.WriteLine(message);
                CommonTrace.WriteTrace(CommonTrace.TraceError, message);
            }

            return(syncMachine);
        }