コード例 #1
0
        public async Task <string> DisconfigureApplication([FromBody] JObject content, String primaryCluster, String secondaryCluster)
        {
            bool successfullyRemoved = true;

            JArray        applicationData    = (JArray)content["ApplicationList"];
            List <string> applicationDataObj = JsonConvert.DeserializeObject <List <string> >(applicationData.ToString());

            FabricClient         fabricClient  = new FabricClient();
            ServicePartitionList partitionList = fabricClient.QueryManager.GetPartitionListAsync(new Uri("fabric:/SFAppDRTool/RestoreService")).Result;

            foreach (Partition partition in partitionList)
            {
                var             int64PartitionInfo   = partition.PartitionInformation as Int64RangePartitionInformation;
                long            lowKey               = (long)int64PartitionInfo?.LowKey;
                IRestoreService restoreServiceClient = ServiceProxy.Create <IRestoreService>(new Uri("fabric:/SFAppDRTool/RestoreService"), new ServicePartitionKey(lowKey));
                try
                {
                    string applicationRemoved = await restoreServiceClient.DisconfigureApplication(applicationDataObj[0], primaryCluster, secondaryCluster);

                    if (applicationRemoved == null)
                    {
                        successfullyRemoved = false;
                    }
                }
                catch (Exception ex)
                {
                    ServiceEventSource.Current.Message("Web Service: Exception Disconfiguring Application {0}", ex);
                    throw;
                }
            }
            if (successfullyRemoved)
            {
                return(applicationDataObj[0]);
            }
            return(null);
        }