Exemplo n.º 1
0
        private void InsertEntity(ResourceDescription rd)
        {
            string message = string.Empty;

            if (rd == null)
            {
                LogHelper.Log(LogTarget.File, LogService.AORCache2PC, " ERROR - 2PC AORCacheModel.cs - ");
                throw new ArgumentNullException();
            }

            long   globalId = rd.Id;
            string mrid     = rd.Properties[0].PropertyValue.StringValue;

            if (EntityExists(globalId, mrid))
            {
                message = String.Format("Failed to insert value because entity already exists in network model.");
                LogHelper.Log(LogTarget.File, LogService.AORCache2PC, " ERROR - AORCacheModel.cs - " + message);
                throw new Exception(message);
            }

            DMSType type = (DMSType)ModelCodeHelper.ExtractTypeFromGlobalId(globalId);

            switch (type)
            {
            case DMSType.AOR_AREA:
                //AORCachedArea newAorArea = new AORCachedArea(rd.Id);
                //newAorArea.ConvertFromRD(rd);
                //aorAreasCopy.Add(newAorArea); // vrati se
                break;

            case DMSType.AOR_GROUP:
                AORGroup newAorGroup = new AORGroup(rd.Id);
                newAorGroup.ConvertFromRD(rd);
                aorGroupsCopy.Add(newAorGroup);
                break;

            case DMSType.AOR_USER:
                break;

            case DMSType.AOR_AGAGGREGATOR:
                break;

            default:
                break;
            }
        }
Exemplo n.º 2
0
        public List <AORGroup> GetAORGroups()
        {
            int             iteratorId        = 0;
            List <long>     ids               = new List <long>();
            List <AORGroup> aorAORGroupValues = new List <AORGroup>();

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

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

                iteratorId    = GdaQueryProxy.GetExtentValues(ModelCode.AOR_GROUP, 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);
                        AORGroup aorGroupValue = new AORGroup(rds[i].Id);
                        aorAORGroupValues.Add(aorGroupValue.ConvertFromRD(rg));
                    }

                    resourcesLeft = GdaQueryProxy.IteratorResourcesLeft(iteratorId);
                }

                GdaQueryProxy.IteratorClose(iteratorId);

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

            return(aorAORGroupValues);
        }
Exemplo n.º 3
0
        public List <AORGroup> GetGroupsForAgr(long groupGid)
        {
            List <AORGroup> resultIds = new List <AORGroup>();

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

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

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

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

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

                    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 related values method  failed for sourceGlobalId = {0} and association (propertyId = {1}, type = {2}). Reason: {3}", groupGid, association.PropertyId, association.Type, e.Message);
                Console.WriteLine(message);
                CommonTrace.WriteTrace(CommonTrace.TraceError, message);
            }

            return(resultIds);
        }