Exemple #1
0
        public async Task <IActionResult> Post()
        {
            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.AddCameraAsync();
            }
            catch (Exception exc)
            {
                System.Diagnostics.Trace.WriteLine(String.Format("Error: {0}", exc.Message));
            }

            System.Diagnostics.Trace.WriteLine(String.Format(" Camera Count: {0}", camerasCount));

            return(this.Ok(String.Format("Count: {0}", camerasCount.ToString())));
        }
Exemple #2
0
        public async Task <IActionResult> Post()
        {
            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.AddCameraAsync();
            }
            catch (Exception exc)
            {
                System.Diagnostics.Trace.WriteLine(String.Format("Error: {0}", exc.Message));
            }

            System.Diagnostics.Trace.WriteLine(String.Format(" Camera Count: {0}", camerasCount));

            return(this.Ok(String.Format("Count: {0}", camerasCount.ToString())));
        }