Esempio n. 1
0
        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 = ProxyToNMServiceFabric.InvokeWithRetry(client => client.Channel.GetExtentValues(modelResourcesDesc.GetModelCodeFromType(type), properties));
                    int count = ProxyToNMServiceFabric.InvokeWithRetry(client => client.Channel.IteratorResourcesLeft(iteratorId));

                    while (count > 0)
                    {
                        List <ResourceDescription> rds = ProxyToNMServiceFabric.InvokeWithRetry(client => client.Channel.IteratorNext(numberOfResources, iteratorId));

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

                        count = ProxyToNMServiceFabric.InvokeWithRetry(client => client.Channel.IteratorResourcesLeft(iteratorId));
                    }

                    bool ok = ProxyToNMServiceFabric.InvokeWithRetry(client => client.Channel.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 ResourceDescription GetValues(long globalId)
        {
            string message = "Getting values method started.";

            //Console.WriteLine(message);
            CommonTrace.WriteTrace(CommonTrace.TraceError, message);
            ResourceDescription rd = null;

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

                rd = ProxyToNMServiceFabric.InvokeWithRetry(c => c.Channel.GetValues(globalId, properties));

                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);
            }

            return(rd);
        }
        public List <ResourceDescription> GetExtentValuesExtended(ModelCode modelCode)
        {
            string message = "Getting extent values extended method started.";

            //Console.WriteLine(message);
            CommonTrace.WriteTrace(CommonTrace.TraceError, message);
            int iteratorId = 0;
            List <ResourceDescription> resourceDescriptions = new List <ResourceDescription>();

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

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

                iteratorId    = ProxyToNMServiceFabric.InvokeWithRetry(c => c.Channel.GetExtentValues(modelCode, properties));
                resourcesLeft = ProxyToNMServiceFabric.InvokeWithRetry(c => c.Channel.IteratorResourcesLeft(iteratorId));

                while (resourcesLeft > 0)
                {
                    List <ResourceDescription> rds = ProxyToNMServiceFabric.InvokeWithRetry(c => c.Channel.IteratorNext(numberOfResources, iteratorId));

                    for (int i = 0; i < rds.Count; i++)
                    {
                        ResourceDescription rd = new ResourceDescription();
                        rd.Id         = rds[i].Id;
                        rd.Properties = rds[i].Properties;
                        resourceDescriptions.Add(rd);
                    }

                    resourcesLeft = ProxyToNMServiceFabric.InvokeWithRetry(c => c.Channel.IteratorResourcesLeft(iteratorId));
                }

                ProxyToNMServiceFabric.InvokeWithRetry(c => c.Channel.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);
            }

            return(resourceDescriptions);
        }
Esempio n. 4
0
        public 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>();
            int         numberOfResources = 50;

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

                int iteratorId    = ProxyToNMServiceFabric.InvokeWithRetry(client => client.Channel.GetRelatedValues(sourceGlobalId, properties, association));
                int resourcesLeft = ProxyToNMServiceFabric.InvokeWithRetry(client => client.Channel.IteratorResourcesLeft(iteratorId));

                while (resourcesLeft > 0)
                {
                    List <ResourceDescription> rds = ProxyToNMServiceFabric.InvokeWithRetry(client => client.Channel.IteratorNext(numberOfResources, iteratorId));

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

                    resourcesLeft = ProxyToNMServiceFabric.InvokeWithRetry(client => client.Channel.IteratorResourcesLeft(iteratorId));
                }

                ProxyToNMServiceFabric.InvokeWithRetry(client => client.Channel.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);
            }

            return(resultIds);
        }
Esempio n. 5
0
        public 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);
                }

                updateResult = ProxyToNMServiceFabric.InvokeWithRetry(client => client.Channel.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);
        }
Esempio n. 6
0
        public 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);
                }

                updateResult = ProxyToNMServiceFabric.InvokeWithRetry(client => client.Channel.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);
        }
 public Delta GetFixedDelta(Delta d)
 {
     return(ProxyToNMServiceFabric.InvokeWithRetry(client => client.Channel.GetFixedDelta(d)));
 }