/// <summary>
        /// Description : Update hostpool details associated with tenant
        /// </summary>
        /// <param name="deploymenturl">RD Broker Url</param>
        /// <param name="accessToken"> Access Token</param>
        /// <param name="rdMgmtHostPool">Hostpool Class</param>
        /// <returns></returns>
        public JObject UpdateHostPool(string deploymentUrl, string accessToken, JObject rdMgmtHostPool)
        {
            try
            {
                //call rest api to update hostpool -- july code bit

                if (rdMgmtHostPool["loadBalancerType"] != null)
                {
                    rdMgmtHostPool["loadBalancerType"] = Convert.ToInt32(rdMgmtHostPool["loadBalancerType"]);
                }
                if (rdMgmtHostPool["assignmentType"] != null)
                {
                    rdMgmtHostPool["assignmentType"] = Convert.ToInt32(rdMgmtHostPool["assignmentType"]);
                }


                var content = new StringContent(JsonConvert.SerializeObject(rdMgmtHostPool), Encoding.UTF8, "application/json");
                HttpResponseMessage response = CommonBL.PatchAsync(deploymentUrl, accessToken, "/RdsManagement/V1/TenantGroups/" + rdMgmtHostPool["tenantGroupName"].ToString() + "/Tenants/" + rdMgmtHostPool["tenantName"].ToString() + "/HostPools/" + rdMgmtHostPool["hostPoolName"].ToString(), content).Result;
                string strJson = response.Content.ReadAsStringAsync().Result;
                if (response.IsSuccessStatusCode)
                {
                    poolResult.Add("isSuccess", true);
                    poolResult.Add("message", "Hostpool '" + rdMgmtHostPool["hostPoolName"] + "' has been updated successfully.");
                }
                else if ((int)response.StatusCode == 429)
                {
                    poolResult.Add("isSuccess", false);
                    poolResult.Add("message", strJson + " Please try again later.");
                }
                else
                {
                    if (!string.IsNullOrEmpty(strJson))
                    {
                        poolResult.Add("isSuccess", false);
                        poolResult.Add("message", CommonBL.GetErrorMessage(strJson));
                    }
                    else
                    {
                        poolResult.Add("isSuccess", false);
                        poolResult.Add("message", "Hostpool '" + rdMgmtHostPool["hostPoolName"].ToString() + "' has not been updated. Please try it later again.");
                    }
                }
            }
            catch (Exception ex)
            {
                poolResult.Add("isSuccess", false);
                poolResult.Add("message", "Hostpool '" + rdMgmtHostPool["hostPoolName"].ToString() + "' has not been updated." + ex.Message.ToString() + " Please try it later again.");
            }
            return(poolResult);
        }
 public JObject EditRemoteApp(string deploymentUrl, string accessToken, JObject rdMgmtRemoteApp)
 {
     try
     {
         //call rest api to publish remote appgroup app
         var content = new StringContent(JsonConvert.SerializeObject(rdMgmtRemoteApp), Encoding.UTF8, "application/json");
         HttpResponseMessage response = CommonBL.PatchAsync(deploymentUrl, accessToken, "/RdsManagement/V1/TenantGroups/" + rdMgmtRemoteApp["tenantGroupName"].ToString() + "/Tenants/" + rdMgmtRemoteApp["tenantName"].ToString() + "/HostPools/" + rdMgmtRemoteApp["hostPoolName"].ToString() + "/AppGroups/" + rdMgmtRemoteApp["appGroupName"].ToString() + "/RemoteApps/" + rdMgmtRemoteApp["remoteAppName"].ToString(), content).Result;
         string strJson = response.Content.ReadAsStringAsync().Result;
         if (response.IsSuccessStatusCode)
         {
             if (response.StatusCode == HttpStatusCode.OK)
             {
                 appResult.Add("isSuccess", true);
                 appResult.Add("message", "Remote app '" + rdMgmtRemoteApp["remoteAppName"].ToString() + "' has been updated successfully.");
             }
         }
         else if ((int)response.StatusCode == 429)
         {
             appResult.Add("isSuccess", false);
             appResult.Add("message", strJson + " Please try again later.");
         }
         else
         {
             if (!string.IsNullOrEmpty(strJson))
             {
                 appResult.Add("isSuccess", false);
                 appResult.Add("message", CommonBL.GetErrorMessage(strJson));
             }
             else
             {
                 appResult.Add("isSuccess", false);
                 appResult.Add("message", "Remote app '" + rdMgmtRemoteApp["remoteAppName"].ToString() + "' has not been updated. Please try it later again.");
             }
         }
     }
     catch (Exception ex)
     {
         appResult.Add("isSuccess", false);
         appResult.Add("message", "Remote app '" + rdMgmtRemoteApp["remoteAppName"].ToString() + "' has not been updated." + ex.Message.ToString() + " Please try it later again.");
     }
     return(appResult);
 }
Пример #3
0
 /// <summary>
 /// Description : Update tenant information
 /// </summary>
 /// <param name="deploymenturl">RD Broker Url</param>
 /// <param name="accessToken">Access Token</param>
 /// <param name="rdMgmtTenant">Tenant Class</param>
 /// <returns></returns>
 public JObject UpdateTenant(string deploymenturl, string accessToken, JObject rdMgmtTenant)
 {
     try
     {
         //call rest api to update tenant -- july code bit
         var content = new StringContent(JsonConvert.SerializeObject(rdMgmtTenant), Encoding.UTF8, "application/json");
         HttpResponseMessage response = CommonBL.PatchAsync(deploymenturl, accessToken, "/RdsManagement/V1/TenantGroups/" + rdMgmtTenant["tenantGroupName"].ToString() + "/Tenants/" + rdMgmtTenant["tenantName"].ToString(), content).Result;
         string strJson = response.Content.ReadAsStringAsync().Result;
         if (response.IsSuccessStatusCode)
         {
             tenantResult.Add("isSuccess", true);
             tenantResult.Add("message", "Tenant '" + rdMgmtTenant["tenantName"] + "' has been updated successfully.");
         }
         else if ((int)response.StatusCode == 429)
         {
             tenantResult.Add("isSuccess", false);
             tenantResult.Add("message", strJson + " Please try again later.");
         }
         else
         {
             if (!string.IsNullOrEmpty(strJson))
             {
                 tenantResult.Add("isSuccess", false);
                 tenantResult.Add("message", CommonBL.GetErrorMessage(strJson));
             }
             else
             {
                 tenantResult.Add("isSuccess", false);
                 tenantResult.Add("message", "Tenant '" + rdMgmtTenant["tenantName"] + "' has not been updated. Please try again later.");
             }
         }
     }
     catch (Exception ex)
     {
         tenantResult.Add("isSuccess", false);
         tenantResult.Add("message", "Tenant " + rdMgmtTenant["tenantName"] + " has not been updated." + ex.Message.ToString() + " Please try again later.");
     }
     return(tenantResult);
 }
Пример #4
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="deploymentUrl"></param>
 /// <param name="accessToken"></param>
 /// <param name="rdMgmtSessionHost"></param>
 /// <returns></returns>
 public JObject ChangeDrainMode(string deploymentUrl, string accessToken, JObject rdMgmtSessionHost)
 {
     try
     {
         //call rest service to update Sesssion host -- july code bit
         var content = new StringContent(JsonConvert.SerializeObject(rdMgmtSessionHost), Encoding.UTF8, "application/json");
         HttpResponseMessage response = CommonBL.PatchAsync(deploymentUrl, accessToken, "/RdsManagement/V1/TenantGroups/" + rdMgmtSessionHost["tenantGroupName"].ToString() + "/Tenants/" + rdMgmtSessionHost["tenantName"].ToString() + "/HostPools/" + rdMgmtSessionHost["hostPoolName"].ToString() + "/SessionHosts/" + rdMgmtSessionHost["sessionHostName"].ToString(), content).Result;
         string strJson = response.Content.ReadAsStringAsync().Result;
         if (response.IsSuccessStatusCode)
         {
             hostResult.Add("isSuccess", true);
             hostResult.Add("message", "'Allow new Session' is set to " + rdMgmtSessionHost["allowNewSession"] + " for " + rdMgmtSessionHost["sessionHostName"].ToString() + "'.");
         }
         else if ((int)response.StatusCode == 429)
         {
             hostResult.Add("isSuccess", false);
             hostResult.Add("message", strJson + " Please try again later.");
         }
         else
         {
             if (!string.IsNullOrEmpty(strJson))
             {
                 hostResult.Add("isSuccess", false);
                 hostResult.Add("message", CommonBL.GetErrorMessage(strJson));
             }
             else
             {
                 hostResult.Add("isSuccess", false);
                 hostResult.Add("message", "Failed to set 'Allow new Session' for '" + rdMgmtSessionHost["sessionHostName"].ToString() + "'. Please try it again later.");
             }
         }
     }
     catch (Exception ex)
     {
         hostResult.Add("isSuccess", false);
         hostResult.Add("message", "Failed to set 'Allow new Session' for '" + rdMgmtSessionHost["sessionHostName"].ToString() + "'. " + ex.Message.ToString() + " Please try it again later.");
     }
     return(hostResult);
 }