Esempio n. 1
0
        private void CheckLoginKey()
        {
            AppendVerifyLog("*. LoginKey");
            try
            {
                string endpoint         = dataManager.GetValue(DataManager.Category.ApiGateway, DataManager.Key.Endpoint);
                string accessKey        = logClientConfig.GetValue(LogClient.Category.Api, LogClient.Key.AccessKey);
                string secretKey        = logClientConfig.GetValue(LogClient.Category.Api, LogClient.Key.SecretKey);
                string loginKey         = dataManager.GetValue(DataManager.Category.LoginKey, DataManager.Key.Name);
                bool   isExistsLoginKey = false;

                string action = @"/server/v2/getLoginKeyList";
                List <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> >();
                parameters.Add(new KeyValuePair <string, string>("responseFormatType", "json"));
                SoaCall soaCall  = new SoaCall();
                var     response = AsyncHelpers.RunSync <string>(() => soaCall.WebApiCall(endpoint, RequestType.POST, action, parameters, accessKey, secretKey));

                JsonSerializerSettings options = new JsonSerializerSettings
                {
                    NullValueHandling     = NullValueHandling.Ignore,
                    MissingMemberHandling = MissingMemberHandling.Ignore
                };

                getLoginKeyList getLoginKeyList = JsonConvert.DeserializeObject <getLoginKeyList>(response, options);

                if (getLoginKeyList.getLoginKeyListResponse.returnCode.Equals("0"))
                {
                    foreach (var a in getLoginKeyList.getLoginKeyListResponse.loginKeyList)
                    {
                        if (loginKey.Equals(a.keyName, StringComparison.OrdinalIgnoreCase))
                        {
                            isExistsLoginKey = true;
                            break;
                        }
                    }

                    if (!isExistsLoginKey)
                    {
                        throw new Exception("   LoginKey does not exists in Managemnet Console!");
                    }
                }

                AppendVerifyLog($"   LoginKey Check Result : Success");
            }
            catch (Exception ex)
            {
                AppendVerifyLog(ex.Message);
                AppendVerifyLog("   LoginKey Help Message...");
                AppendVerifyLog("   -----------------------------------------------");
                AppendVerifyLog("   1. Select and save the login key saved in SQL Server DBA Tool or create a new login key.");
                AppendVerifyLog("   -----------------------------------------------");
                throw new Exception("Encryption Key Error!");
            }
        }
Esempio n. 2
0
        private async Task GetLoginKeyList()
        {
            try
            {
                string endpoint = dataManager.GetValue(DataManager.Category.ApiGateway, DataManager.Key.Endpoint);
                string action   = @"/server/v2/getLoginKeyList";
                List <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> >();
                parameters.Add(new KeyValuePair <string, string>("responseFormatType", "json"));
                SoaCall soaCall  = new SoaCall();
                var     task     = soaCall.WebApiCall(endpoint, RequestType.POST, action, parameters, LogClient.Config.Instance.GetValue(Category.Api, Key.AccessKey), LogClient.Config.Instance.GetValue(Category.Api, Key.SecretKey));
                string  response = await task;

                JsonSerializerSettings options = new JsonSerializerSettings
                {
                    NullValueHandling     = NullValueHandling.Ignore,
                    MissingMemberHandling = MissingMemberHandling.Ignore
                };

                getLoginKeyList getLoginKeyList = JsonConvert.DeserializeObject <getLoginKeyList>(response, options);
                if (getLoginKeyList.getLoginKeyListResponse.returnCode.Equals("0"))
                {
                    comboBoxSelectKey.Items.Clear();
                    foreach (var a in getLoginKeyList.getLoginKeyListResponse.loginKeyList)
                    {
                        comboBoxSelectKey.Items.Add(a.keyName);
                    }
                }

                string loginKeyName = dataManager.GetValue(DataManager.Category.LoginKey, DataManager.Key.Name);
                if (loginKeyName.Length == 0)
                {
                    comboBoxSelectKey.SelectedIndex = 0;
                }
                else
                {
                    comboBoxSelectKey.Text = loginKeyName;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }