Example #1
0
        internal Dictionary <string, string> GetCredentials(string environmentId, string itemName)
        {
            Dictionary <string, string> credentialsDic;

            if (CacheUtil.IsCachingEnabled())
            {
                credentialsDic = CredentialsCacheHelper.GetCredentialsCache(environmentId);

                if (credentialsDic != null)
                {
                    return(credentialsDic);
                }
            }

            var result = _httpClient.GetAsync($"{LcsUrl}/DeploymentPortal/GetCredentials/{LcsProjectId}?environmentId={environmentId}&deploymentItemName={itemName}&_={DateTimeOffset.Now.ToUnixTimeSeconds()}").Result;

            result.EnsureSuccessStatusCode();
            var responseBody = result.Content.ReadAsStringAsync().Result;
            var response     = JsonConvert.DeserializeObject <Response>(responseBody);

            if (response.Success && response.Data != null)
            {
                credentialsDic = JsonConvert.DeserializeObject <Dictionary <string, string> >(response.Data.ToString());

                if (CacheUtil.IsCachingEnabled())
                {
                    CredentialsCacheHelper.AddCredentialsCache(environmentId, credentialsDic);
                }

                return(credentialsDic);
            }

            return(null);
        }
Example #2
0
        private void ClearCacheButton_Click(object sender, EventArgs e)
        {
            var result = CredentialsCacheHelper.ClearCache();

            if (result != null)
            {
                MessageBox.Show(string.Format("Error while trying to clear cache, caching disabled.\n {0}", result), "Error");
            }
        }
Example #3
0
 private void SetStoreCacheEnabledDisabled()
 {
     if (CachingEnabledCheckbox.Checked)
     {
         StoreCacheCheckBox.Enabled = true;
     }
     else
     {
         StoreCacheCheckBox.Enabled = false;
         StoreCacheCheckBox.Checked = false;
         CredentialsCacheHelper.DisableCache();
     }
 }