Ejemplo n.º 1
0
        public async Task <IEnumerable <string> > Get()
        {
            long camerasCount = 0;
            // The Random number is because we have two partitions and
            // we are simply going to randomize the requests.
            Random rnd = new Random();

            try
            {
                // This is the partition logic required to access
                // the partitioned StatefulService in the back-end.
                long randomNumber = rnd.Next(0, 2);
                Microsoft.ServiceFabric.Services.Client.ServicePartitionKey partKey = new Microsoft.ServiceFabric.Services.Client.ServicePartitionKey(randomNumber);
                ICameras cameras = ServiceProxy.Create <ICameras>(backEndServiceUri, partKey, Microsoft.ServiceFabric.Services.Communication.Client.TargetReplicaSelector.Default, null);

                camerasCount = await cameras.GetCamerasCountAsync();
            }
            catch (Exception exc)
            {
                System.Diagnostics.Trace.WriteLine(String.Format("Error: {0}", exc.Message));
            }

            System.Diagnostics.Trace.WriteLine(String.Format(" Camera Count: {0}", camerasCount));
            return(new string[] { camerasCount.ToString() });
        }
Ejemplo n.º 2
0
        public async Task <IEnumerable <string> > Get()
        {
            long camerasCount = 0;

            try
            {
                Microsoft.ServiceFabric.Services.Client.ServicePartitionKey partKey = new Microsoft.ServiceFabric.Services.Client.ServicePartitionKey(0);
                ICameras cameras = ServiceProxy.Create <ICameras>(backEndServiceUri, partKey, Microsoft.ServiceFabric.Services.Communication.Client.TargetReplicaSelector.Default, null);

                camerasCount = await cameras.GetCamerasCountAsync();
            }
            catch (Exception exc)
            {
                System.Diagnostics.Trace.WriteLine(String.Format("Error: {0}", exc.Message));
            }

            System.Diagnostics.Trace.WriteLine(String.Format(" Camera Count: {0}", camerasCount));
            return(new string[] { camerasCount.ToString() });
        }