public async static Task <byte[]> GetImage(string SFURL, CitrixApplicationInfo Application) { HttpClient _client = new HttpClient(); string _imageResource = (SFURL.EndsWith("/")) ? string.Format("{0}", Application.AppIconUrl) : string.Format("/{0}", Application.AppIconUrl); string _imageResourceUrl = string.Format("{0}{1}", SFURL, _imageResource); StringContent _bodyContent = new StringContent(""); HttpResponseMessage _imageResp = await _client.GetAsync(_imageResourceUrl); var imageBytes = await _imageResp.Content.ReadAsByteArrayAsync(); return(imageBytes); }
public async static Task <byte[]> GetImage(string WebURL, CitrixApplicationInfo Application) { string SFURL = WebURL; bool IsSSL = false; if (SFURL.ToLower().IndexOf("https:") != -1) { IsSSL = true; } else { IsSSL = false; } var _image = await GetImageFromStorefront(SFURL, Application); return(_image); }
private async static Task <byte[]> GetImageFromStorefront(string SFURL, CitrixApplicationInfo Application) { CookieContainer _cookieContainer = new CookieContainer(); Cookie _aspnetSessionIdCookie = new Cookie("ASP.NET_SessionId", Application.Auth.SessionID, Application.Auth.CookiePath, Application.Auth.CookieHost); Cookie _csrfTokenCookie = new Cookie("CsrfToken", Application.Auth.CSRFToken, Application.Auth.CookiePath, Application.Auth.CookieHost); Cookie _authIDCookie = new Cookie("CtxsAuthId", Application.Auth.AuthToken, Application.Auth.CookiePath, Application.Auth.CookieHost); _cookieContainer.Add(_aspnetSessionIdCookie); _cookieContainer.Add(_csrfTokenCookie); _cookieContainer.Add(_authIDCookie); HttpClientHandler _clientHandler = new HttpClientHandler(); _clientHandler.CookieContainer = _cookieContainer; HttpClient _client = new HttpClient(_clientHandler); _client.BaseAddress = new Uri(Application.Auth.StorefrontUrl); string _postResourceUrl = (SFURL.EndsWith("/")) ? "Resources/List" : "/Resources/List"; string _resourcesURL = SFURL + _postResourceUrl; _client.DefaultRequestHeaders.Add("Csrf-Token", Application.Auth.CSRFToken); _client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("image/png")); string _imageResource = (SFURL.EndsWith("/")) ? string.Format("{0}", Application.AppIconUrl) : string.Format("/{0}", Application.AppIconUrl); string _imageResourceUrl = string.Format("{0}{1}", SFURL, _imageResource); StringContent _bodyContent = new StringContent(""); HttpResponseMessage _imageResp = await _client.GetAsync(_imageResourceUrl); byte[] imageBytes = null; Debug.WriteLine("StatusCode:" + _imageResp.StatusCode); if (_imageResp.StatusCode == System.Net.HttpStatusCode.OK) { imageBytes = await _imageResp.Content.ReadAsByteArrayAsync(); } return(imageBytes); }
public async static Task <CitrixApplicationInfo> GetResource(string WebURL, CitrixAuthCredential Creds, bool UseSSL, string ApplicationName) { string SFURL = WebURL; bool IsSSL = false; if (SFURL.ToLower().IndexOf("https:") != -1) { IsSSL = true; } else { IsSSL = false; } var _resources = await GetResourcesFromStoreFront(SFURL, Creds, UseSSL); CitrixApplicationInfo _app = _resources.Find(a => a.AppTitle == ApplicationName); return(_app); }
public async static Task <byte[]> GetImage(string Server, string WebLocation, CitrixApplicationInfo Application, bool IsSSL) { string SFURL = null; if (WebLocation.StartsWith("/")) { WebLocation = WebLocation.Substring(1, WebLocation.Length - 1); } if (IsSSL) { SFURL = string.Format("https://{0}/{1}", Server, WebLocation); } else { SFURL = string.Format("http://{0}/{1}", Server, WebLocation); } var _image = await GetImageFromStorefront(SFURL, Application); return(_image); }
public async static Task <CitrixApplicationInfo> GetResource(string Server, string WebLocation, CitrixAuthCredential Creds, bool UseSSL, string ApplicationName) { string SFURL = null; if (WebLocation.StartsWith("/")) { WebLocation = WebLocation.Substring(1, WebLocation.Length - 1); } if (UseSSL) { SFURL = string.Format("https://{0}/{1}", Server, WebLocation); } else { SFURL = string.Format("http://{0}/{1}", Server, WebLocation); } var _resources = await GetResourcesFromStoreFront(SFURL, Creds, UseSSL); CitrixApplicationInfo _app = _resources.Find(a => a.AppTitle == ApplicationName); return(_app); }
public async static Task <string> RetreiveICA(string Server, string WebLocation, CitrixAuthCredential Creds, CitrixApplicationInfo AppInfo, bool UseSSL) { string SFURL = null; if (WebLocation.StartsWith("/")) { WebLocation = WebLocation.Substring(1, WebLocation.Length - 1); } if (UseSSL) { SFURL = string.Format("https://{0}/{1}/{2}", Server, WebLocation, AppInfo.AppLaunchURL); } else { SFURL = string.Format("http://{0}/{1}/{2}", Server, WebLocation, AppInfo.AppLaunchURL); } var _ica = await GetICAFromStoreFront(SFURL, Creds, UseSSL); return(_ica); }
public async static Task <string> RetreiveICA(string WebURL, CitrixAuthCredential Creds, CitrixApplicationInfo AppInfo) { string SFURL = string.Format("{0}/{1}", WebURL, AppInfo.AppLaunchURL); bool IsSSL = false; if (SFURL.ToLower().IndexOf("https:") != -1) { IsSSL = true; } else { IsSSL = false; } var _ica = await GetICAFromStoreFront(SFURL, Creds, IsSSL); return(_ica); }
public async static Task <List <CitrixApplicationInfo> > GetResourcesFromStoreFront(string SFURL, CitrixAuthCredential Creds, bool UseSSL) { List <CitrixApplicationInfo> _applicationList = new List <CitrixApplicationInfo>(); CookieContainer _cookieContainer = new CookieContainer(); Cookie _aspnetSessionIdCookie = new Cookie("ASP.NET_SessionId", Creds.SessionID, Creds.CookiePath, Creds.CookieHost); Cookie _csrfTokenCookie = new Cookie("CsrfToken", Creds.CSRFToken, Creds.CookiePath, Creds.CookieHost); Cookie _authIDCookie = new Cookie("CtxsAuthId", Creds.AuthToken, Creds.CookiePath, Creds.CookieHost); Uri _cookieUri = new Uri(SFURL); _cookieContainer.Add(_cookieUri, _aspnetSessionIdCookie); _cookieContainer.Add(_cookieUri, _csrfTokenCookie); _cookieContainer.Add(_cookieUri, _authIDCookie); HttpClientHandler _clientHandler = new HttpClientHandler(); _clientHandler.CookieContainer = _cookieContainer; System.Net.Http.HttpClient _client = new System.Net.Http.HttpClient(_clientHandler); //_client.BaseAddress = new Uri(SFURL); string _postResource = (SFURL.EndsWith("/")) ? "Resources/List" : "/Resources/List"; string _postResourceUrl = string.Format("{0}{1}", SFURL, _postResource); if (UseSSL) { _client.DefaultRequestHeaders.Add("X-Citrix-IsUsingHTTPS", "Yes"); } else { _client.DefaultRequestHeaders.Add("X-Citrix-IsUsingHTTPS", "No"); } _client.DefaultRequestHeaders.Add("Csrf-Token", Creds.CSRFToken); _client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); StringContent _bodyContent = new StringContent(""); HttpResponseMessage _listResourcesResp = await _client.PostAsync(_postResourceUrl, _bodyContent); if (_listResourcesResp.StatusCode == HttpStatusCode.OK) { string _resourcesJSON = await _listResourcesResp.Content.ReadAsStringAsync(); //check for the authorized object. // "{\"unauthorized\": true}" JObject _resourcesBase = JObject.Parse(_resourcesJSON); JArray _resources = (JArray)_resourcesBase["resources"]; foreach (var _resource in _resources) { CitrixApplicationInfo _appInfo = new CitrixApplicationInfo(); _appInfo.AppTitle = _resource["name"].ToString(); try { _appInfo.AppDesc = _resource["description"].ToString(); } catch (Exception e) { _appInfo.AppDesc = ""; } _appInfo.AppIconUrl = _resource["iconurl"].ToString(); _appInfo.AppLaunchURL = _resource["launchurl"].ToString(); _appInfo.ID = _resource["id"].ToString(); _applicationList.Add(_appInfo); } } return(_applicationList); }