public async override void SendData() { List <PerfmonTypeA> ListPerfmonTypeA = GetPerfmonData(); string json = JsonConvert.SerializeObject(ListPerfmonTypeA); log.Warn(EndPointUrl); log.Warn(json); // auth 인증의 경우 //Task<string> response = asyncCall.WebApiCall( // EndPointUrl, // LogClient.GetPostType.POST, // @"/api/lazylog/perfmon", // json, // config.GetValue(Category.WebApi, Key.AccessKey), // config.GetValue(Category.WebApi, Key.SecretKey)); //string responseString = await response; //log.Warn(responseString); // noauth 의 경우 Task <string> response = new SoaCall().WebApiCall( EndPointUrl, RequestType.POST, @"/api/lazylog/perfmon2", json); string responseString = await response; log.Warn(responseString); }
private async Task <int> LogLevelQuery() { int returnValue = 0; try { var postParams = new List <KeyValuePair <string, string> >(); postParams.Add(new KeyValuePair <string, string>("AppName", Config.Instance.GetValue(Category.Config, Key.AppName))); postParams.Add(new KeyValuePair <string, string>("ClientIpAddress", Config.Instance.LocalIp)); postParams.Add(new KeyValuePair <string, string>("Guid", Config.Instance.GUID)); if (!ConfigLogType.Equals("Local", StringComparison.OrdinalIgnoreCase)) { SoaCall asyncCall = new SoaCall(); var task = asyncCall.WebApiCall(config.Url(RequestUrlType.LOG), RequestType.POST, @"Api/Log/LogLevelQuery", postParams, config.GetValue(Category.Config, Key.AccessKey), config.GetValue(Category.Config, Key.SecretKey)); string t = await task; returnValue = int.Parse(t.Replace("\"", "")); nlog.Info(string.Format("return LogLevelQuery Result : {0}", returnValue)); } else { returnValue = 3; } } catch (Exception ex) { nlog.Error("{0},{1}", ex.Message, ex.StackTrace); returnValue = 0; } return(returnValue); }
private async Task GetAccessControlGroupList() { try { string endpoint = dataManager.GetValue(DataManager.Category.ApiGateway, DataManager.Key.Endpoint); string action = @"/server/v2/getAccessControlGroupList"; 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 }; if (response.Contains("responseError")) { hasError hasError = JsonConvert.DeserializeObject <hasError>(response, options); throw new Exception(hasError.responseError.returnMessage); } else { getAccessControlGroupList getAccessControlGroupList = JsonConvert.DeserializeObject <getAccessControlGroupList>(response, options); if (getAccessControlGroupList.getAccessControlGroupListResponse.returnCode.Equals("0")) { comboBoxACG1.Items.Clear(); comboBoxACG2.Items.Clear(); comboBoxACG3.Items.Clear(); comboBoxACG4.Items.Clear(); comboBoxACG5.Items.Clear(); foreach (var a in getAccessControlGroupList.getAccessControlGroupListResponse.accessControlGroupList) { var item = new accessControlGroup { accessControlGroupConfigurationNo = a.accessControlGroupConfigurationNo, accessControlGroupName = a.accessControlGroupName, accessControlGroupDescription = a.accessControlGroupDescription, isDefault = a.isDefault, createDate = a.createDate }; comboBoxACG1.Items.Add(item); comboBoxACG2.Items.Add(item); comboBoxACG3.Items.Add(item); comboBoxACG4.Items.Add(item); comboBoxACG5.Items.Add(item); } } } } catch (Exception) { throw; } comboBoxZone.SelectedIndex = 0; }
public static async Task <List <serverInstance> > GetServerInstanceList(List <string> instanceNoList) { try { DataManager dataManager = DataManager.Instance; List <serverInstance> serverInstances = new List <serverInstance>(); string endpoint = dataManager.GetValue(DataManager.Category.ApiGateway, DataManager.Key.Endpoint); string action = @"/server/v2/getServerInstanceList"; List <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> >(); parameters.Add(new KeyValuePair <string, string>("responseFormatType", "json")); int i = 0; foreach (var instanceNo in instanceNoList) { i++; string serverInstanceNoListKey = "serverInstanceNoList." + i; string serverInstanceNoListValue = instanceNo; parameters.Add(new KeyValuePair <string, string>(serverInstanceNoListKey, serverInstanceNoListValue)); } 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 }; if (response.Contains("responseError")) { hasError hasError = JsonConvert.DeserializeObject <hasError>(response, options); throw new Exception(hasError.responseError.returnMessage); } else { getServerInstanceList getServerInstanceList = JsonConvert.DeserializeObject <getServerInstanceList>(response, options); if (getServerInstanceList.getServerInstanceListResponse.returnCode.Equals("0")) { serverInstances.Clear(); foreach (var a in getServerInstanceList.getServerInstanceListResponse.serverInstanceList) { serverInstances.Add(a); } if (getServerInstanceList.getServerInstanceListResponse.totalRows == 0) { throw new Exception("server not founds"); } } return(serverInstances); } } catch (Exception) { throw; } }
private async Task LoginKeyReloadAsync() { try { LoginKeyItems = new ObservableCollection <loginKey>(); 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")) { LoginKeyItems.Clear(); foreach (var a in getLoginKeyList.getLoginKeyListResponse.loginKeyList) { LoginKeyItems.Add(new loginKey { fingerprint = a.fingerprint, keyName = a.keyName, createDate = a.createDate, }); } } string loginKeyName = dataManager.GetValue(DataManager.Category.LoginKey, DataManager.Key.Name); foreach (var key in LoginKeyItems) { if (key.keyName.Equals(loginKeyName)) { SelectedLoginKey = key; } } } catch (Exception ex) { var menuItem = mConfigListDesignModel.Items.Single(x => x.Number == "C2"); menuItem.ProfilePictureRGB = "5c5c5c"; await IoC.UI.ShowMessage(new MessageBoxDialogViewModel { Title = "ERROR", Message = ex.Message, OkText = "OK" }); } }
private async Task GetZoneList(string regionNo) { try { string endpoint = dataManager.GetValue(DataManager.Category.ApiGateway, DataManager.Key.Endpoint); string action = @"/server/v2/getZoneList"; List <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> >(); parameters.Add(new KeyValuePair <string, string>("responseFormatType", "json")); parameters.Add(new KeyValuePair <string, string>("regionNo", regionNo)); 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 }; comboBoxZone.InvokeIfRequired(s => { if (response.Contains("responseError")) { hasError hasError = JsonConvert.DeserializeObject <hasError>(response, options); throw new Exception(hasError.responseError.returnMessage); } else { getZoneList getZoneList = JsonConvert.DeserializeObject <getZoneList>(response, options); if (getZoneList.getZoneListResponse.returnCode.Equals("0")) { s.Items.Clear(); foreach (var a in getZoneList.getZoneListResponse.zoneList) { var item = new zone { zoneNo = a.zoneNo, zoneName = a.zoneName, zoneCode = a.zoneCode, zoneDescription = a.zoneDescription, regionNo = a.regionNo }; s.Items.Add(item); } } } s.SelectedIndex = 0; }); } catch (Exception) { throw; } }
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!"); } }
private async Task CreateLoginKeyAndFileSave(string path, string loginKeyName) { try { string privateKey = string.Empty; if (loginKeyName.Length < 3) { throw new Exception("The minimum length of the login key is three characters."); } string endpoint = dataManager.GetValue(DataManager.Category.ApiGateway, DataManager.Key.Endpoint); string action = @"/server/v2/createLoginKey"; List <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> >(); parameters.Add(new KeyValuePair <string, string>("responseFormatType", "json")); parameters.Add(new KeyValuePair <string, string>("keyName", loginKeyName)); 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 }; if (response.Contains("responseError")) { hasError hasError = JsonConvert.DeserializeObject <hasError>(response, options); throw new Exception(hasError.responseError.returnMessage); } else { createLoginKey createLoginKey = JsonConvert.DeserializeObject <createLoginKey>(response, options); if (createLoginKey.createLoginKeyResponse.returnCode.Equals("0")) { privateKey = createLoginKey.createLoginKeyResponse.privateKey; } if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } File.WriteAllText(Path.Combine(path, loginKeyName + ".pem"), privateKey); } } catch (Exception) { var menuItem = mConfigListDesignModel.Items.Single(x => x.Number == "C2"); menuItem.ProfilePictureRGB = "5c5c5c"; throw; } }
private void Send() { lock (Lock) { List <LogDataArgs> permitLogLists = new List <LogDataArgs>(); try { int logLevel = LogLevelQuery().Result; //int logLevel = LogLevelQuery(); foreach (var a in buffer) { if ((int)a.Level >= logLevel) { permitLogLists.Add(a); } } if (permitLogLists.Count > 0) { AppLog joyLog = new AppLog { AppName = Config.Instance.GetValue(Category.Config, Key.AppName), GUID = Config.Instance.GUID, ClientIpAddress = Config.Instance.LocalIp, LogData = permitLogLists }; var jsonLog = JsonConvert.SerializeObject(joyLog); nlog.Info(jsonLog); if (!ConfigLogType.Equals("Local", StringComparison.OrdinalIgnoreCase)) { SoaCall asyncCall = new SoaCall(); Task <string> t = asyncCall.WebApiCall(config.Url(RequestUrlType.LOG), RequestType.POST, @"Api/Log", jsonLog.ToString(), config.GetValue(Category.Config, Key.AccessKey), config.GetValue(Category.Config, Key.SecretKey)); t.Wait(); } } } catch (Exception ex) { nlog.Error(string.Format("{0}, {1}", ex.Message, ex.StackTrace)); } finally { buffer.Clear(); permitLogLists.Clear(); firstReceiveTime = DateTime.Now; currentDataCnt = 0; } } }
private async Task Execute() { try { ControlHelpers.ButtonStatusChange(buttonExecute, "Requested"); string cmdText = string.Empty; if (fastColoredTextBoxTemplate.SelectedText.Length > 0) { cmdText = fastColoredTextBoxTemplate.SelectedText; } else { cmdText = fastColoredTextBoxTemplate.Text; } List <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> >(); var dict = JsonConvert.DeserializeObject <Dictionary <string, string> >(cmdText); foreach (var a in dict) { parameters.Add(new KeyValuePair <string, string>(a.Key.ToString(), a.Value.ToString())); } SoaCall soaCall = new SoaCall(); Task <string> task = null; if (textBoxEndPoint.Text.Contains("kms") || comboBoxScriptTemplates.Text.Contains("mssql")) // if (textBoxEndPoint.Text.Contains("kms") ) { task = soaCall.WebApiCall(textBoxEndPoint.Text, RequestType.POST, comboBoxScriptTemplates.Text, cmdText, textBoxAccessKey.Text, textBoxSecretKey.Text); } else { task = soaCall.WebApiCall(textBoxEndPoint.Text, RequestType.POST, comboBoxScriptTemplates.Text, parameters, textBoxAccessKey.Text, textBoxSecretKey.Text); } string response = await task; JToken jt = JToken.Parse(response); fastColoredTextBoxResult.Text = jt.ToString(Newtonsoft.Json.Formatting.Indented); } catch (Exception) { throw; } finally { ControlHelpers.ButtonStatusChange(buttonExecute, "Execute"); } }
public async override void SendData() { log.Warn("PerfmonWebApiCallTypeB SendData B"); log.Warn(EndPointUrl); string json = GetPerfmonData(); Task <string> response = new SoaCall().WebApiCallNpot( EndPointUrl, json, npot_auth ); string responseString = await response; log.Warn(responseString); }
private async Task ChangeLoadBalancedServerInstances(string loadBalancerInstanceNo, string masterServerInstanceNo) { try { log.Warn($"ChangeLoadBalancedServerInstances() loadBalancerInstanceNo : {loadBalancerInstanceNo}, masterServerInstanceNo : {masterServerInstanceNo}"); string endpoint = config.GetValue(Category.ApiGateway, Key.Endpoint); string action = @"/loadbalancer/v2/changeLoadBalancedServerInstances"; List <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> >(); parameters.Add(new KeyValuePair <string, string>("responseFormatType", "json")); parameters.Add(new KeyValuePair <string, string>("loadBalancerInstanceNo", loadBalancerInstanceNo)); parameters.Add(new KeyValuePair <string, string>("serverInstanceNoList.1", masterServerInstanceNo)); SoaCall soaCall = new SoaCall(); var task = soaCall.WebApiCall(endpoint , RequestType.POST , action , parameters , LogClient.Config.Instance.GetValue( LogClient.Category.Api, LogClient.Key.AccessKey) , LogClient.Config.Instance.GetValue( LogClient.Category.Api, LogClient.Key.SecretKey) ); string response = await task; log.Warn($"ChangeLoadBalancedServerInstances() response : {response}"); JsonSerializerSettings options = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore, MissingMemberHandling = MissingMemberHandling.Ignore }; if (response.Contains("responseError")) { hasError hasError = JsonConvert.DeserializeObject <hasError>(response, options); throw new Exception(hasError.responseError.returnMessage); } changeLoadBalancedServerInstances changeLoadBalancedServerInstances = JsonConvert.DeserializeObject <changeLoadBalancedServerInstances>(response, options); if (changeLoadBalancedServerInstances.changeLoadBalancedServerInstancesResponse.returnCode.Equals("0")) { log.Warn("change load balancer requested"); } } catch (Exception) { throw; } }
private void buttonGetCiphertext_Click(object sender, EventArgs e) { try { if (textBoxKey.Text.Trim().Length == 0) { throw new Exception("key is null. Please enter key"); } if (textBoxKeyTag.Text.Trim().Length == 0) { throw new Exception("keytag is empty. Please enter keytag"); } var kmsEncrypteParameters = new { plaintext = TranString.EncodeBase64(textBoxKey.Text) }; var jt = JToken.Parse(JsonConvert.SerializeObject(kmsEncrypteParameters)); string parameters = jt.ToString(Newtonsoft.Json.Formatting.Indented); SoaCall asyncCall = new SoaCall(); var response = AsyncHelpers.RunSync <string>(() => asyncCall.WebApiCall( @"https://kms.apigw.ntruss.com", RequestType.POST, @"/keys/v2/" + textBoxKeyTag.Text + @"/encrypt", parameters, textBoxAccessKey.Text.Trim(), textBoxSecretKey.Text.Trim(), 5)); JsonSerializerSettings options = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore, MissingMemberHandling = MissingMemberHandling.Ignore }; if (!response.Contains("SUCCESS")) { throw new Exception(response); } KmsEncryptResponse KmsEncryptResponse = JsonConvert.DeserializeObject <KmsEncryptResponse>(response, options); textBoxCiphertext.Text = KmsEncryptResponse.data.ciphertext; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private async Task DeleteBlockStorageInstances(string storageInstanceNo) { try { string endpoint = dataManager.GetValue(DataManager.Category.ApiGateway, DataManager.Key.Endpoint); string action = @"/server/v2/deleteBlockStorageInstances"; List <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> >(); parameters.Add(new KeyValuePair <string, string>("responseFormatType", "json")); parameters.Add(new KeyValuePair <string, string>("blockStorageInstanceNoList.1", storageInstanceNo)); 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 }; if (response.Contains("responseError")) { hasError hasError = JsonConvert.DeserializeObject <hasError>(response, options); throw new Exception(hasError.responseError.returnMessage); } else { deleteBlockStorageInstances deleteBlockStorageInstances = JsonConvert.DeserializeObject <deleteBlockStorageInstances>(response, options); if (deleteBlockStorageInstances.deleteBlockStorageInstancesResponse.returnCode.Equals("0")) { if (deleteBlockStorageInstances.deleteBlockStorageInstancesResponse.totalRows == 0) { MessageBox.Show("storage not founds"); } else { MessageBox.Show("deleted"); } } } } catch (Exception) { throw; } }
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); } }
private void SendToCla(string json) { try { if (json.Trim() != "") { log.Warn("SendToCla"); string response = new SoaCall().WebApiCallCla( EndPointUrl, json, BaseTableName ); log.Warn(response); } } catch (Exception ex) { log.Error(string.Format("{0}, {1}", ex.Message, ex.StackTrace)); } }
private async void SendToNpot(string json) { try { if (json.Trim() != "") { log.Warn("SendToNpot"); Task <string> response = new SoaCall().WebApiCallNpot( EndPointUrl, json, config.GetValue(Category.NPOT, Key.AuthInfo) ); string responseString = await response; log.Warn(responseString); } } catch (Exception ex) { log.Error(string.Format("{0}, {1}", ex.Message, ex.StackTrace)); } }
public async Task <string> Execute(string cmd, string cmdType, string cmdText, CsLib.RequestType type, string endPoint, string action, string accessKey, string secretKey, int timeoutSec = 0) { var json = new { cmd = cmd, cmdType = cmdType, cmdText = TranString.EncodeBase64Unicode(cmdText) }; string responseString = string.Empty; try { string jsonCmd = JsonConvert.SerializeObject(json); Task <string> response = new SoaCall().WebApiCall( endPoint, type, action, jsonCmd, accessKey, secretKey, timeoutSec ); string temp = await response; if (temp.Length > 0) { JToken jt = JToken.Parse(temp); responseString = jt.ToString(Newtonsoft.Json.Formatting.Indented); } else { responseString = "response is empty..."; } } catch (Exception) { throw; } return(responseString); }
private async Task pushLicenseData(SqlServerLicenseData sld) { try { string endpoint = config.GetValue(Category.ApiGateway, Key.Endpoint); string action = @"/mssql/v2/pushLicenseData"; JToken jt = JToken.Parse(JsonConvert.SerializeObject(sld)); string parameters = jt.ToString(Newtonsoft.Json.Formatting.Indented); SoaCall soaCall = new SoaCall(); var task = soaCall.WebApiCall(endpoint , RequestType.POST , action , parameters , LogClient.Config.Instance.GetValue( LogClient.Category.Api, LogClient.Key.AccessKey) , LogClient.Config.Instance.GetValue( LogClient.Category.Api, LogClient.Key.SecretKey) ); string response = await task; log.Warn($"pushLicenseData() response : {response}"); JsonSerializerSettings options = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore, MissingMemberHandling = MissingMemberHandling.Ignore }; if (response.Contains("responseError")) { hasError hasError = JsonConvert.DeserializeObject <hasError>(response, options); throw new Exception(hasError.responseError.returnMessage); } } catch (Exception ex) { log.Error(string.Format("{0}, {1}", ex.Message, ex.StackTrace)); } }
protected async void SendToGeneralRepository(string json, string action) { try { if (json.Trim() != "") { log.Warn("SendToGeneralRepository"); Task <string> response = new SoaCall().WebApiCall( EndPointUrl, RequestType.POST, action, json ); string responseString = await response; log.Warn(responseString); } } catch (Exception ex) { log.Error(string.Format("{0}, {1}", ex.Message, ex.StackTrace)); } }
public async Task RestCall() { try { StatusChange("requested.."); string endpoint = dataManager.GetValue(DataManager.Category.ApiGateway, DataManager.Key.Endpoint); string action = Action; List <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> >(); var dict = JsonConvert.DeserializeObject <Dictionary <string, string> >(Command); foreach (var a in dict) { parameters.Add(new KeyValuePair <string, string>(a.Key.ToString(), a.Value.ToString())); } 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; if (response.Length > 0) { JToken jt = JToken.Parse(response); response = jt.ToString(Newtonsoft.Json.Formatting.Indented); } else { response = "resonse is empty..."; } fastColoredTextBoxResult.Text = response; StatusChange("Execute"); } catch (Exception) { throw; } }
private async void buttonLogin_Click(object sender, EventArgs e) { try { buttonLogin.Enabled = false; 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(textBoxApiGatewayEndpoint.Text, RequestType.POST, @"/server/v2/getRegionList", parameters, textBoxAccessKey.Text, textBoxSecretKey.Text); string response = await task; JsonSerializerSettings options = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore, MissingMemberHandling = MissingMemberHandling.Ignore }; if (response.Contains("responseError")) { hasError hasError = JsonConvert.DeserializeObject <hasError>(response, options); throw new Exception(hasError.responseError.returnMessage); } if (response.Contains("error")) { authError authError = JsonConvert.DeserializeObject <authError>(response, options); throw new Exception(authError.error.message); } getRegionList getRegionList = JsonConvert.DeserializeObject <getRegionList>(response, options); if (!getRegionList.getRegionListResponse.returnCode.Equals("0")) { MessageBox.Show(response); } if (checkBoxSave.Checked) { dataManager.SetValue(DataManager.Category.Login, DataManager.Key.IsSaveKeyYn, "Y"); logClientConfig.SetValue(LogClient.Category.Api, LogClient.Key.AccessKey, textBoxAccessKey.Text.Trim()); logClientConfig.SetValue(LogClient.Category.Api, LogClient.Key.SecretKey, textBoxSecretKey.Text.Trim()); dataManager.SaveUserData(); logClientConfig.SaveLogClientData(); } else { dataManager.SetValue(DataManager.Category.Login, DataManager.Key.IsSaveKeyYn, "N"); logClientConfig.SetValue(LogClient.Category.Api, LogClient.Key.AccessKey, ""); logClientConfig.SetValue(LogClient.Category.Api, LogClient.Key.SecretKey, ""); logClientConfig.SaveLogClientData(); logClientConfig.SetValue(LogClient.Category.Api, LogClient.Key.AccessKey, textBoxAccessKey.Text.Trim()); logClientConfig.SetValue(LogClient.Category.Api, LogClient.Key.SecretKey, textBoxSecretKey.Text.Trim()); dataManager.SaveUserData(); } Hide(); FormMain formMain = new FormMain(); formMain.FormClosed += (s, args) => this.Close(); formMain.Show(); } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { buttonLogin.Enabled = true; } }
private async void buttonStorageCreate_Click(object sender, EventArgs e) { try { int checkBoxCount = 0; string serverInstanceNo = string.Empty; foreach (DataGridViewRow item in dgvServerList.Rows) { if (bool.Parse(item.Cells["CheckBox"].Value.ToString())) { checkBoxCount++; serverInstanceNo = item.Cells["InstanceNo"].Value.ToString(); } } if (checkBoxCount != 1) { throw new Exception("select one server"); } DialogResult result = MessageBox.Show("Do you really want to run?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result != DialogResult.Yes) { return; } ControlHelpers.ButtonStatusChange(buttonStorageCreate, "Requested"); await GetBlockStorageInfoLoad(); string endpoint = dataManager.GetValue(DataManager.Category.ApiGateway, DataManager.Key.Endpoint); string action = @"/server/v2/createBlockStorageInstance"; List <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> >(); parameters.Add(new KeyValuePair <string, string>("responseFormatType", "json")); parameters.Add(new KeyValuePair <string, string>("blockStorageName", textBoxStorageName.Text)); parameters.Add(new KeyValuePair <string, string>("blockStorageSize", textBoxStorageSize.Text)); parameters.Add(new KeyValuePair <string, string>("blockStorageDescription", textBoxDescription.Text)); parameters.Add(new KeyValuePair <string, string>("serverInstanceNo", serverInstanceNo)); parameters.Add(new KeyValuePair <string, string>("diskDetailTypeCode", comboBoxType.Text)); 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 }; if (response.Contains("responseError")) { hasError hasError = JsonConvert.DeserializeObject <hasError>(response, options); throw new Exception(hasError.responseError.returnMessage); } else { createBlockStorageInstance createBlockStorageInstance = JsonConvert.DeserializeObject <createBlockStorageInstance>(response, options); if (createBlockStorageInstance.createBlockStorageInstanceResponse.returnCode.Equals("0")) { if (createBlockStorageInstance.createBlockStorageInstanceResponse.totalRows == 0) { MessageBox.Show("server not founds"); } else { MessageBox.Show("Successfully requested storage creation. Press Reload button and mount when Status and Operation status are ATTAC NULL."); } } } await GetBlockStorageInfoLoad(); } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { ControlHelpers.ButtonStatusChange(buttonStorageCreate, "Create"); } }
public string GetCryptionKey(string getCryptionKey, string getCryptionKeyUrl, string accessKey, string SecretKey) { if (getCryptionKey.Equals("Local", StringComparison.OrdinalIgnoreCase)) { return(GetValue(Category.Encryption, Key.LocalCryptionKey)); } else if (getCryptionKey.Equals("NcpKms", StringComparison.OrdinalIgnoreCase)) { for (int i = 0; i <= 3; i++) { try { string _keytag = GetValue(Category.Encryption, Key.KeyTag).Trim(); string _ciphertext = GetValue(Category.Encryption, Key.Ciphertext).Trim(); if (_keytag.Length == 0) { throw new Exception("keytag is empty. Please enter keytag"); } if (_ciphertext.Length == 0) { throw new Exception("ciphertext is empty. Please enter ciphertext"); } var kmsDecrypteParameters = new { ciphertext = _ciphertext }; var jt = JToken.Parse(JsonConvert.SerializeObject(kmsDecrypteParameters)); string parameters = jt.ToString(Newtonsoft.Json.Formatting.Indented); SoaCall asyncCall = new SoaCall(); var response = AsyncHelpers.RunSync <string>(() => asyncCall.WebApiCall( @"https://kms.apigw.ntruss.com", RequestType.POST, @"/keys/v2/" + _keytag + @"/decrypt", parameters, GetValue(Category.Api, Key.AccessKey), GetValue(Category.Api, Key.SecretKey), 5)); JsonSerializerSettings options = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore, MissingMemberHandling = MissingMemberHandling.Ignore }; if (!response.Contains("SUCCESS")) { throw new Exception(response); } KmsDecryptResponse KmsDecryptResponse = JsonConvert.DeserializeObject <KmsDecryptResponse>(response, options); return(TranString.DecodeBase64(KmsDecryptResponse.data.plaintext)); } catch (Exception ex) { Debug.WriteLine($"ncpkms not ready!, Message : {ex.Message}"); } Thread.Sleep(2000); } } else // (getCryptionKey.Equals("RemoteKeyServer", StringComparison.OrdinalIgnoreCase)) { for (int i = 0; i <= 3; i++) { try { SoaCall asyncCall = new SoaCall(); var key = AsyncHelpers.RunSync <string>(() => asyncCall.WebApiCall( GetValue(Category.Encryption, Key.GetCryptionKeyUrl), RequestType.GET, @"/Api/GetCryptionKey", GetValue(Category.Api, Key.AccessKey), GetValue(Category.Api, Key.SecretKey), 5)); key = TranString.DecodeBase64((key.Replace("\"", ""))); return(key); } catch (Exception ex) { Debug.WriteLine($"KeyServer not ready!, Message : {ex.Message}"); } Thread.Sleep(2000); } } throw new Exception("GET KEY ERROR"); }
private async Task LoginAsync(object parameter) { await RunCommandAsync(() => LoginIsRunning, async() => { try { var SecretKey = (parameter as IHavePassword).SecurePassword.Unsecure(); 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, @"/server/v2/getRegionList", parameters, AccessKey, SecretKey); string response = await task; JsonSerializerSettings options = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore, MissingMemberHandling = MissingMemberHandling.Ignore }; if (response.Contains("responseError")) { hasError hasError = JsonConvert.DeserializeObject <hasError>(response, options); throw new Exception(hasError.responseError.returnMessage); } if (response.Contains("error")) { authError authError = JsonConvert.DeserializeObject <authError>(response, options); throw new Exception(authError.error.message); } getRegionList getRegionList = JsonConvert.DeserializeObject <getRegionList>(response, options); if (!getRegionList.getRegionListResponse.returnCode.Equals("0")) { throw new Exception(response); } if (IsSave) { dataManager.SetValue(DataManager.Category.Login, DataManager.Key.IsSaveKeyYn, "Y"); logClientConfig.SetValue(LogClient.Category.Api, LogClient.Key.AccessKey, AccessKey.Trim()); logClientConfig.SetValue(LogClient.Category.Api, LogClient.Key.SecretKey, SecretKey.Trim()); dataManager.SaveUserData(); logClientConfig.SaveLogClientData(); } else { dataManager.SetValue(DataManager.Category.Login, DataManager.Key.IsSaveKeyYn, "N"); logClientConfig.SetValue(LogClient.Category.Api, LogClient.Key.AccessKey, ""); logClientConfig.SetValue(LogClient.Category.Api, LogClient.Key.SecretKey, ""); logClientConfig.SaveLogClientData(); logClientConfig.SetValue(LogClient.Category.Api, LogClient.Key.AccessKey, AccessKey.Trim()); logClientConfig.SetValue(LogClient.Category.Api, LogClient.Key.SecretKey, SecretKey.Trim()); dataManager.SaveUserData(); } IoC.Get <ApplicationViewModel>().GoToPage(ApplicationPage.ObjectStorage); } catch (Exception ex) { await IoC.UI.ShowMessage(new MessageBoxDialogViewModel { Title = "ERROR", Message = ex.Message, OkText = "OK" }); } }); }
private async Task InstallAsync() { await RunCommandAsync(() => InstallIsRunning, async() => { try { { var m = new MessageBoxDialogConfirmViewModel { Title = "CONFIRM", Message = "Do you really want to run?", }; await IoC.UI.ShowMessage(m); if (m.DialogResult == DialogResult.No) { return; } } List <AdGroupItem> SeletedAdGroupItems = new List <AdGroupItem>(); foreach (var item in AdGroupItems) { if (item.IsChecked) { SeletedAdGroupItems.Add(item); } } if (SeletedAdGroupItems.Count != 1) { throw new Exception("Select One AD Group"); } if (string.IsNullOrEmpty(DomainName)) { throw new Exception("Type DomainName"); } if (!DomainName.Contains(".")) { throw new Exception("Please enter the domain name in FQDN format. '.' This should be included. Ex) ncpdom.local, ncp.local, myad.local"); } //if (string.IsNullOrEmpty(NetBiosName)) // throw new Exception("Type NetBiosName"); //if (NetBiosName.Length > 15) // throw new Exception("NetBiosName should be less than 15 characters"); if (string.IsNullOrEmpty(SafeModePassword)) { throw new Exception("Type SafeMode Password"); } if (SafeModePassword.Length <= 7) { throw new Exception("SafeMode Passord : minimum password length is 8"); } if (!(SpecialChar.IsContainUpperChar(SafeModePassword) && SpecialChar.IsContainLowerChar(SafeModePassword) && SpecialChar.IsContainNumChar(SafeModePassword))) { throw new Exception("SafeMode Passord : A combination of uppercase and lowercase numbers is required"); } if (string.IsNullOrEmpty(MstscPort)) { throw new Exception("Type MSTSC Port(RDP)"); } if (!int.TryParse(MstscPort, out int portNum)) { throw new Exception("MSTSC port number must be numeric."); } if (int.TryParse(MstscPort, out int portNum2)) { if (portNum2 > 20000) { throw new Exception("MSTSC port is recommended to be 10000 ~ 20000."); } } if (MstscPort == "3389") { var m = new MessageBoxDialogConfirmViewModel { Title = "CONFIRM", Message = "The MSTSC port is the default port. Targeted for RDP attacks, would you like to proceed?", }; await IoC.UI.ShowMessage(m); if (m.DialogResult == DialogResult.No) { return; } } // step 1 StepName = "Install Started"; ProgressValue = 0; AppendVerifyLog(StepName); string response = string.Empty; WcfResponse wcfResponse = new WcfResponse(); var step = 0; var debugStep = 0; // dir test step++; if (debugStep <= step) { string psCmd = $@"dir c:\"; StepName = $"STEP {step} : communication test"; AppendVerifyLog($"{StepName} started"); AppendVerifyLog($"{StepName} + {psCmd}"); var task = dataManager.Execute ("ExecuterPs" , "out-string" , psCmd , CsLib.RequestType.POST , $"https://{SeletedAdGroupItems.FirstOrDefault().MasterServerPublicIp}:9090" , @"/LazyServer/LazyCommand/PostCmd" , LogClient.Config.Instance.GetValue(LogClient.Category.Api, LogClient.Key.AccessKey) , LogClient.Config.Instance.GetValue(LogClient.Category.Api, LogClient.Key.SecretKey) , 30 ); response = await task; AppendVerifyLog($"{StepName} {response}"); wcfResponse = JsonConvert.DeserializeObject <WcfResponse>(response); if (!wcfResponse.IsSuccess) { AppendVerifyLog($"{StepName} failed ({wcfResponse.ErrorMessage})"); throw new Exception($"{StepName} failed ({wcfResponse.ErrorMessage})"); } ProgressValue = 10; AppendVerifyLog(StepName + " completed successfully"); } step++; if (debugStep <= step) //added { string psCmd = $"Set-Service RemoteRegistry -StartupType Automatic" + Environment.NewLine + $"Start-Service RemoteRegistry"; StepName = $"STEP {step} : RemoteRegistry Enable"; AppendVerifyLog($"{StepName} started"); AppendVerifyLog($"{StepName} + {psCmd}"); var task = dataManager.Execute ("ExecuterPs" , "out-string" , psCmd , CsLib.RequestType.POST , $"https://{SeletedAdGroupItems.FirstOrDefault().MasterServerPublicIp}:9090" , @"/LazyServer/LazyCommand/PostCmd" , LogClient.Config.Instance.GetValue(LogClient.Category.Api, LogClient.Key.AccessKey) , LogClient.Config.Instance.GetValue(LogClient.Category.Api, LogClient.Key.SecretKey) , 30 ); response = await task; AppendVerifyLog(response); wcfResponse = JsonConvert.DeserializeObject <WcfResponse>(response); if (!wcfResponse.IsSuccess) { AppendVerifyLog($"{StepName} failed ({wcfResponse.ErrorMessage})"); throw new Exception($"{StepName} failed ({wcfResponse.ErrorMessage})"); } ProgressValue = 20; AppendVerifyLog(StepName + " completed successfully"); } // hosts add ip step++; if (debugStep <= step) { string psCmd = $"Clear-Content -Path \"C:\\Windows\\System32\\drivers\\etc\\hosts\"" + Environment.NewLine + $"Add-Content -Path \"C:\\Windows\\System32\\drivers\\etc\\hosts\" -Value \"{SeletedAdGroupItems.FirstOrDefault().MasterServerPublicIp} {SeletedAdGroupItems.FirstOrDefault().MasterServerName}\"" + Environment.NewLine + $"Add-Content -Path \"C:\\Windows\\System32\\drivers\\etc\\hosts\" -Value \"{SeletedAdGroupItems.FirstOrDefault().SlaveServerPublicIp} {SeletedAdGroupItems.FirstOrDefault().SlaveServerName}\""; StepName = $"STEP {step} : hosts add ip"; AppendVerifyLog($"{StepName} started"); AppendVerifyLog($"{StepName} + {psCmd}"); var task = dataManager.Execute ("ExecuterPs" , "out-string" , psCmd , CsLib.RequestType.POST , $"https://{SeletedAdGroupItems.FirstOrDefault().MasterServerPublicIp}:9090" , @"/LazyServer/LazyCommand/PostCmd" , LogClient.Config.Instance.GetValue(LogClient.Category.Api, LogClient.Key.AccessKey) , LogClient.Config.Instance.GetValue(LogClient.Category.Api, LogClient.Key.SecretKey) , 30 ); response = await task; AppendVerifyLog(response); wcfResponse = JsonConvert.DeserializeObject <WcfResponse>(response); if (!wcfResponse.IsSuccess) { AppendVerifyLog($"{StepName} failed ({wcfResponse.ErrorMessage})"); throw new Exception($"{StepName} failed ({wcfResponse.ErrorMessage})"); } ProgressValue = 20; AppendVerifyLog(StepName + " completed successfully"); } // hosts add ip confirm step++; if (debugStep <= step) { string psCmd = $"get-content \"C:\\Windows\\System32\\drivers\\etc\\hosts\""; StepName = $"STEP {step} : hosts add ip confirm"; AppendVerifyLog($"{StepName} started"); AppendVerifyLog($"{StepName} + {psCmd}"); var task = dataManager.Execute ("ExecuterPs" , "out-string" , psCmd , CsLib.RequestType.POST , $"https://{SeletedAdGroupItems.FirstOrDefault().MasterServerPublicIp}:9090" , @"/LazyServer/LazyCommand/PostCmd" , LogClient.Config.Instance.GetValue(LogClient.Category.Api, LogClient.Key.AccessKey) , LogClient.Config.Instance.GetValue(LogClient.Category.Api, LogClient.Key.SecretKey) , 30 ); response = await task; AppendVerifyLog(response); wcfResponse = JsonConvert.DeserializeObject <WcfResponse>(response); if (!wcfResponse.IsSuccess) { AppendVerifyLog($"{StepName} failed ({wcfResponse.ErrorMessage})"); throw new Exception($"{StepName} failed ({wcfResponse.ErrorMessage})"); } ProgressValue = 30; AppendVerifyLog(StepName + " completed successfully"); } step++; if (debugStep <= step) //4 { string psCmd = "" + $"$contents=[System.Text.Encoding]::Unicode.GetString([System.Convert]::FromBase64String(\"JABhAGQAYQBwAHQAZQByACAAPQAgAEcAZQB0AC0ATgBlAHQAQQBkAGEAcAB0AGUAcgAgAHwAIAA/ACAAewAkAF8ALgBTAHQAYQB0AHUAcwAgAC0AZQBxACAAIgB1AHAAIgB9AA0ACgAkAEkAUAAgAD0AIAAoACQAYQBkAGEAcAB0AGUAcgAgAHwAIABHAGUAdAAtAE4AZQB0AEkAUABDAG8AbgBmAGkAZwB1AHIAYQB0AGkAbwBuACkALgBJAFAAdgA0AEEAZABkAHIAZQBzAHMALgBJAFAAQQBkAGQAcgBlAHMAcwANAAoAJABHAEEAVABFAFcAQQBZACAAPQAgACgAJABhAGQAYQBwAHQAZQByACAAfAAgAEcAZQB0AC0ATgBlAHQASQBQAEMAbwBuAGYAaQBnAHUAcgBhAHQAaQBvAG4AKQAuAEkAUAB2ADQARABlAGYAYQB1AGwAdABHAGEAdABlAHcAYQB5AC4ATgBlAHgAdABIAG8AcAANAAoAJABCAEkAVABNAEEAUwBLACAAPQAgACgAJABhAGQAYQBwAHQAZQByACAAfAAgAEcAZQB0AC0ATgBlAHQASQBQAEMAbwBuAGYAaQBnAHUAcgBhAHQAaQBvAG4AKQAuAEkAUAB2ADQAQQBkAGQAcgBlAHMAcwAuAFAAcgBlAGYAaQB4AEwAZQBuAGcAdABoAA0ACgAkAEQATgBTACAAPQAgACIAMQAyADcALgAwAC4AMAAuADEAIgANAAoAJABJAFAAVAB5AHAAZQAgAD0AIAAiAEkAUAB2ADQAIgANAAoAIwAgAFIAZQBtAG8AdgBlACAAYQBuAHkAIABlAHgAaQBzAHQAaQBuAGcAIABJAFAALAAgAGcAYQB0AGUAdwBhAHkAIABmAHIAbwBtACAAbwB1AHIAIABpAHAAdgA0ACAAYQBkAGEAcAB0AGUAcgANAAoASQBmACAAKAAoACQAYQBkAGEAcAB0AGUAcgAgAHwAIABHAGUAdAAtAE4AZQB0AEkAUABDAG8AbgBmAGkAZwB1AHIAYQB0AGkAbwBuACkALgBJAFAAdgA0AEEAZABkAHIAZQBzAHMALgBJAFAAQQBkAGQAcgBlAHMAcwApACAAewANAAoAJABhAGQAYQBwAHQAZQByACAAfAAgAFIAZQBtAG8AdgBlAC0ATgBlAHQASQBQAEEAZABkAHIAZQBzAHMAIAAtAEEAZABkAHIAZQBzAHMARgBhAG0AaQBsAHkAIAAkAEkAUABUAHkAcABlACAALQBDAG8AbgBmAGkAcgBtADoAJABmAGEAbABzAGUADQAKAH0ADQAKAEkAZgAgACgAKAAkAGEAZABhAHAAdABlAHIAIAB8ACAARwBlAHQALQBOAGUAdABJAFAAQwBvAG4AZgBpAGcAdQByAGEAdABpAG8AbgApAC4ASQBwAHYANABEAGUAZgBhAHUAbAB0AEcAYQB0AGUAdwBhAHkAKQAgAHsADQAKACQAYQBkAGEAcAB0AGUAcgAgAHwAIABSAGUAbQBvAHYAZQAtAE4AZQB0AFIAbwB1AHQAZQAgAC0AQQBkAGQAcgBlAHMAcwBGAGEAbQBpAGwAeQAgACQASQBQAFQAeQBwAGUAIAAtAEMAbwBuAGYAaQByAG0AOgAkAGYAYQBsAHMAZQANAAoAfQANAAoAJABhAGQAYQBwAHQAZQByACAAfAAgAE4AZQB3AC0ATgBlAHQASQBQAEEAZABkAHIAZQBzAHMAIAAtAEEAZABkAHIAZQBzAHMARgBhAG0AaQBsAHkAIAAkAEkAUABUAHkAcABlACAALQBJAFAAQQBkAGQAcgBlAHMAcwAgACQASQBQACAALQBQAHIAZQBmAGkAeABMAGUAbgBnAHQAaAAgACQAQgBJAFQATQBBAFMASwAgAC0ARABlAGYAYQB1AGwAdABHAGEAdABlAHcAYQB5ACAAJABHAEEAVABFAFcAQQBZAA0ACgAjACAAQwBvAG4AZgBpAGcAdQByAGUAIAB0AGgAZQAgAEQATgBTACAAYwBsAGkAZQBuAHQAIABzAGUAcgB2AGUAcgAgAEkAUAAgAGEAZABkAHIAZQBzAHMAZQBzAA0ACgAkAGEAZABhAHAAdABlAHIAIAB8ACAAUwBlAHQALQBEAG4AcwBDAGwAaQBlAG4AdABTAGUAcgB2AGUAcgBBAGQAZAByAGUAcwBzACAALQBTAGUAcgB2AGUAcgBBAGQAZAByAGUAcwBzAGUAcwAgACQARABOAFMADQAKAA==\"))" + Environment.NewLine + $"New-Item -Path \"c:\\script\\nicSettingMaster.ps1\" -ItemType \"file\" -Force" + Environment.NewLine + $"Add-Content -Path \"c:\\script\\nicSettingMaster.ps1\" -Value $contents" + Environment.NewLine + $"try" + Environment.NewLine + $"<<" + Environment.NewLine + $" powershell \"c:\\script\\nicSettingMaster.ps1\" -ErrorAction Stop" + Environment.NewLine + $" Write-Output \"completed\" " + Environment.NewLine + $">>" + Environment.NewLine + $"catch " + Environment.NewLine + $"<<" + Environment.NewLine + $" Write-Output \"error\" " + Environment.NewLine + $">>"; psCmd = psCmd.Replace("<<", "{"); psCmd = psCmd.Replace(">>", "}"); StepName = $"STEP {step} : nic setting"; AppendVerifyLog($"{StepName} started"); AppendVerifyLog($"{StepName} + {psCmd}"); try { var task = dataManager.Execute ("ExecuterPs" , "out-string" , psCmd , CsLib.RequestType.POST , $"https://{SeletedAdGroupItems.FirstOrDefault().MasterServerPublicIp}:9090" , @"/LazyServer/LazyCommand/PostCmd" , LogClient.Config.Instance.GetValue(LogClient.Category.Api, LogClient.Key.AccessKey) , LogClient.Config.Instance.GetValue(LogClient.Category.Api, LogClient.Key.SecretKey) , 10 ); response = await task; AppendVerifyLog(response); wcfResponse = JsonConvert.DeserializeObject <WcfResponse>(response); } catch { } AppendVerifyLog($"{StepName} completed"); } // hosts add ip confirm step++; if (debugStep <= step) // 5 { string psCmd = $"ipconfig /all"; StepName = $"STEP {step} : dns ip confirm"; AppendVerifyLog($"{StepName} started"); AppendVerifyLog($"{StepName} + {psCmd}"); var task = dataManager.Execute ("ExecuterPs" , "out-string" , psCmd , CsLib.RequestType.POST , $"https://{SeletedAdGroupItems.FirstOrDefault().MasterServerPublicIp}:9090" , @"/LazyServer/LazyCommand/PostCmd" , LogClient.Config.Instance.GetValue(LogClient.Category.Api, LogClient.Key.AccessKey) , LogClient.Config.Instance.GetValue(LogClient.Category.Api, LogClient.Key.SecretKey) , 30 ); response = await task; AppendVerifyLog(response); wcfResponse = JsonConvert.DeserializeObject <WcfResponse>(response); if (!wcfResponse.IsSuccess) { AppendVerifyLog($"{StepName} failed ({wcfResponse.ErrorMessage})"); throw new Exception($"{StepName} failed ({wcfResponse.ErrorMessage})"); } ProgressValue = 40; AppendVerifyLog(StepName + " completed successfully"); } step++; if (debugStep <= step) // 6 { string psCmd = $"Install-windowsfeature AD-domain-services -IncludeManagementTools"; StepName = $"STEP {step} : Install-windowsfeature AD-domain-services -IncludeManagementTools"; AppendVerifyLog($"{StepName} started"); AppendVerifyLog($"{StepName} + {psCmd}"); var task = dataManager.Execute ("ExecuterPs" , "out-string" , psCmd , CsLib.RequestType.POST , $"https://{SeletedAdGroupItems.FirstOrDefault().MasterServerPublicIp}:9090" , @"/LazyServer/LazyCommand/PostCmd" , LogClient.Config.Instance.GetValue(LogClient.Category.Api, LogClient.Key.AccessKey) , LogClient.Config.Instance.GetValue(LogClient.Category.Api, LogClient.Key.SecretKey) , 600 ); response = await task; AppendVerifyLog(response); wcfResponse = JsonConvert.DeserializeObject <WcfResponse>(response); if (!wcfResponse.IsSuccess) { AppendVerifyLog($"{StepName} failed ({wcfResponse.ErrorMessage})"); throw new Exception($"{StepName} failed ({wcfResponse.ErrorMessage})"); } ProgressValue = 70; AppendVerifyLog(StepName + " completed successfully"); } step++; if (debugStep <= step) // 7 { string psCmd = $"Import-Module ADDSDeployment"; StepName = $"STEP {step} : Import-Module ADDSDeployment"; AppendVerifyLog($"{StepName} started"); AppendVerifyLog($"{StepName} + {psCmd}"); var task = dataManager.Execute ("ExecuterPs" , "out-string" , psCmd , CsLib.RequestType.POST , $"https://{SeletedAdGroupItems.FirstOrDefault().MasterServerPublicIp}:9090" , @"/LazyServer/LazyCommand/PostCmd" , LogClient.Config.Instance.GetValue(LogClient.Category.Api, LogClient.Key.AccessKey) , LogClient.Config.Instance.GetValue(LogClient.Category.Api, LogClient.Key.SecretKey) , 300 ); response = await task; AppendVerifyLog(response); wcfResponse = JsonConvert.DeserializeObject <WcfResponse>(response); if (!wcfResponse.IsSuccess) { AppendVerifyLog($"{StepName} failed ({wcfResponse.ErrorMessage})"); throw new Exception($"{StepName} failed ({wcfResponse.ErrorMessage})"); } ProgressValue = 80; AppendVerifyLog(StepName + " completed successfully"); } step++; if (debugStep <= step) // 8 { string psCmd = $"Install-ADDSForest -CreateDnsDelegation:$false -DatabasePath \"C:\\Windows\\NTDS\" -DomainMode \"{SelectedDomainModeItem.Display}\" -DomainName \"{DomainName}\" -DomainNetbiosName \"{NetBiosName}\" -ForestMode \"{SelectedDomainModeItem.Display}\" -InstallDns:$true -LogPath \"C:\\Windows\\NTDS\" -NoRebootOnCompletion:$false -SysvolPath \"C:\\Windows\\SYSVOL\" -SafeModeAdministratorPassword (Convertto-SecureString -AsPlainText \"{SafeModePassword}\" -Force) -Force:$true"; StepName = $"STEP {step} : Import-Module ADDSDeployment"; AppendVerifyLog($"{StepName} started"); AppendVerifyLog($"{StepName} + {psCmd}"); var task = dataManager.Execute ("ExecuterPs" , "out-string" , psCmd , CsLib.RequestType.POST , $"https://{SeletedAdGroupItems.FirstOrDefault().MasterServerPublicIp}:9090" , @"/LazyServer/LazyCommand/PostCmd" , LogClient.Config.Instance.GetValue(LogClient.Category.Api, LogClient.Key.AccessKey) , LogClient.Config.Instance.GetValue(LogClient.Category.Api, LogClient.Key.SecretKey) , 600 ); response = await task; AppendVerifyLog(response); wcfResponse = JsonConvert.DeserializeObject <WcfResponse>(response); if (!wcfResponse.IsSuccess) { AppendVerifyLog($"{StepName} failed ({wcfResponse.ErrorMessage})"); throw new Exception($"{StepName} failed ({wcfResponse.ErrorMessage})"); } ProgressValue = 90; AppendVerifyLog(StepName + " completed successfully"); } step++; if (debugStep <= step && !MstscPort.Equals("3389")) // 9 { string psCmd = $"Set-ItemProperty -Path \"HKLM:\\System\\CurrentControlSet\\Control\\Terminal Server\\WinStations\\RDP-Tcp\\\" -Name PortNumber -Value {MstscPort}"; StepName = $"STEP {step} : MSTSC Port Chagne"; AppendVerifyLog($"{StepName} started"); AppendVerifyLog($"{StepName} + {psCmd}"); var task = dataManager.Execute ("ExecuterPs" , "out-string" , psCmd , CsLib.RequestType.POST , $"https://{SeletedAdGroupItems.FirstOrDefault().MasterServerPublicIp}:9090" , @"/LazyServer/LazyCommand/PostCmd" , LogClient.Config.Instance.GetValue(LogClient.Category.Api, LogClient.Key.AccessKey) , LogClient.Config.Instance.GetValue(LogClient.Category.Api, LogClient.Key.SecretKey) , 200 ); response = await task; AppendVerifyLog(response); wcfResponse = JsonConvert.DeserializeObject <WcfResponse>(response); if (!wcfResponse.IsSuccess) { AppendVerifyLog($"{StepName} failed ({wcfResponse.ErrorMessage})"); throw new Exception($"{StepName} failed ({wcfResponse.ErrorMessage})"); } ProgressValue = 95; AppendVerifyLog(StepName + " completed successfully"); AppendVerifyLog(StepName + " Restart Started"); } step++; if (debugStep <= step) // 10 { try { StepName = $"STEP {step} : Restart"; AppendVerifyLog($"{StepName} started"); string endpoint = dataManager.GetValue(DataManager.Category.ApiGateway, DataManager.Key.Endpoint); string action = @"/server/v2/rebootServerInstances"; List <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> >(); parameters.Add(new KeyValuePair <string, string>("responseFormatType", "json")); parameters.Add(new KeyValuePair <string, string>("serverInstanceNoList.1", SeletedAdGroupItems.FirstOrDefault().MasterServerInstanceNo)); 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)); response = await task; JsonSerializerSettings options = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore, MissingMemberHandling = MissingMemberHandling.Ignore }; rebootServerInstances rebootServerInstances = JsonConvert.DeserializeObject <rebootServerInstances>(response, options); if (rebootServerInstances.rebootServerInstancesResponse.returnCode.Equals("0")) { AppendVerifyLog(StepName + response); } } catch (Exception ex) { AppendVerifyLog(StepName + $"Restart Request Failed : {ex.Message}"); throw new Exception($"Restart Request Failed : {ex.Message}"); } ProgressValue = 99; AppendVerifyLog(StepName + " completed successfully"); AppendVerifyLog(StepName + " Target Server Restart Started"); AppendVerifyLog(StepName + " After rebooting, you can check whether the domain was successfully created with the following command."); AppendVerifyLog(StepName + " CMD >> systeminfo | findstr /B /C:\"Domain\""); } step++; if (debugStep <= step) // 11 { try { StepName = $"STEP {step} : Restart Check"; AppendVerifyLog($"{StepName} started"); for (int i = 0; i < 30; i++) { await Task.Delay(5000); string endpoint = dataManager.GetValue(DataManager.Category.ApiGateway, DataManager.Key.Endpoint); string action = @"/server/v2/getServerInstanceList"; List <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> >(); parameters.Add(new KeyValuePair <string, string>("responseFormatType", "json")); parameters.Add(new KeyValuePair <string, string>("serverInstanceNoList.1", SeletedAdGroupItems.FirstOrDefault().MasterServerInstanceNo)); 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)); response = await task; JsonSerializerSettings options = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore, MissingMemberHandling = MissingMemberHandling.Ignore }; getServerInstanceList getServerInstanceList = JsonConvert.DeserializeObject <getServerInstanceList>(response, options); if (getServerInstanceList.getServerInstanceListResponse.returnCode.Equals("0")) { var Status = ""; var Operation = ""; foreach (var a in getServerInstanceList.getServerInstanceListResponse.serverInstanceList) { Status = a.serverInstanceStatus.code; Operation = a.serverInstanceOperation.code; } if (Status.Equals("RUN") && (Operation.Equals("NULL"))) { AppendVerifyLog(StepName + $"Restart Completed"); break; } else { AppendVerifyLog(StepName + $"Current Status : {Status}, Operation : {Operation}, Please wait."); } } } } catch (Exception ex) { AppendVerifyLog(StepName + $"Restart Check Failed : {ex.Message}"); throw new Exception($"Restart Check Failed : {ex.Message}"); } ProgressValue = 100; AppendVerifyLog(StepName + " completed successfully"); } ProgressValue = 100; StepName = "completed"; await IoC.UI.ShowMessage(new MessageBoxDialogViewModel { Title = "SUCCESS", Message = "Active Directory installation on the primary server completed successfully.", OkText = "OK" }); } catch (Exception ex) { await IoC.UI.ShowMessage(new MessageBoxDialogViewModel { Title = "ERROR", Message = ex.Message, OkText = "OK" }); } });
private void CheckConfigurationKey() { AppendVerifyLog("*. Encrytpion Key"); string getCryptionKeyType = logClientConfig.GetValue(LogClient.Category.Encryption, LogClient.Key.GetCryptionKey); string keyTag = LogClient.Config.Instance.GetValue(LogClient.Category.Encryption, LogClient.Key.KeyTag); string ciphertext = LogClient.Config.Instance.GetValue(LogClient.Category.Encryption, LogClient.Key.Ciphertext); try { AppendVerifyLog($" Current Encrytpion Type : {getCryptionKeyType}"); if (getCryptionKeyType.Equals("Local", StringComparison.OrdinalIgnoreCase)) { AppendVerifyLog(" Cryption Key : " + logClientConfig.GetValue(Category.Encryption, Key.LocalCryptionKey)); if (logClientConfig.GetValue(Category.Encryption, Key.LocalCryptionKey).Length == 0) { AppendVerifyLog($" [Warning] Cryption Key is too short! (key length is : {logClientConfig.GetValue(Category.Encryption, Key.LocalCryptionKey).Length})"); } } else { if (keyTag.Length <= 1) { throw new Exception(" [ERROR] The KMS keytag is not corrent!"); } if (ciphertext.Length <= 1) { throw new Exception(" [ERROR] The KMS ciphertext is not corrent!"); } var kmsDecrypteParameters = new { ciphertext = ciphertext }; var jt = JToken.Parse(JsonConvert.SerializeObject(kmsDecrypteParameters)); string parameters = jt.ToString(Newtonsoft.Json.Formatting.Indented); SoaCall asyncCall = new SoaCall(); var response = AsyncHelpers.RunSync <string>(() => asyncCall.WebApiCall( @"https://kms.apigw.ntruss.com", RequestType.POST, @"/keys/v2/" + keyTag + @"/decrypt", parameters, LogClient.Config.Instance.GetValue(LogClient.Category.Api, LogClient.Key.AccessKey), LogClient.Config.Instance.GetValue(LogClient.Category.Api, LogClient.Key.SecretKey), 5)); JsonSerializerSettings options = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore, MissingMemberHandling = MissingMemberHandling.Ignore }; if (!response.Contains("SUCCESS")) { throw new Exception(response); } KmsDecryptResponse KmsDecryptResponse = JsonConvert.DeserializeObject <KmsDecryptResponse>(response, options); AppendVerifyLog(" Cryption KMS key : " + TranString.DecodeBase64(KmsDecryptResponse.data.plaintext)); } AppendVerifyLog($" Encryption Key Check Result : Success"); } catch (Exception ex) { AppendVerifyLog(ex.Message); AppendVerifyLog(" Encryption Key(KMS) Help Message..."); AppendVerifyLog(" -----------------------------------------------"); AppendVerifyLog(" 1. Enable subaccount in MC Console."); AppendVerifyLog(" 2. In the Management Console, create a key for encryption / decryption."); AppendVerifyLog(" 3. Paste the generated keytag into the SQL Server DBA Tool."); AppendVerifyLog(" 4. In the SQL Server DBA Tool, type key"); AppendVerifyLog(" 5. Create ciphertext in the SQL Server DBA Tool."); AppendVerifyLog(" 6. Save."); AppendVerifyLog(" -----------------------------------------------"); throw new Exception("Encryption Key Error!"); } }
private async Task ServerNameCheck(bool message = true) { try { if (textBoxServerName.Text.Length < 3) { throw new Exception("check server name first"); } List <serverInstance> serverInstances = new List <serverInstance>(); string endpoint = dataManager.GetValue(DataManager.Category.ApiGateway, DataManager.Key.Endpoint); string action = @"/server/v2/getServerInstanceList"; List <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> >(); parameters.Add(new KeyValuePair <string, string>("responseFormatType", "json")); parameters.Add(new KeyValuePair <string, string>("searchFilterName", "serverName")); parameters.Add(new KeyValuePair <string, string>("searchFilterValue", textBoxServerName.Text.Trim())); 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 }; if (response.Contains("responseError")) { hasError hasError = JsonConvert.DeserializeObject <hasError>(response, options); throw new Exception(hasError.responseError.returnMessage); } else { getServerInstanceList getServerInstanceList = JsonConvert.DeserializeObject <getServerInstanceList>(response, options); if (getServerInstanceList.getServerInstanceListResponse.returnCode.Equals("0")) { serverInstances.Clear(); foreach (var a in getServerInstanceList.getServerInstanceListResponse.serverInstanceList) { var item = new serverInstance { serverInstanceNo = a.serverInstanceNo, serverName = a.serverName, publicIp = a.publicIp, privateIp = a.privateIp, serverInstanceStatus = new codeCodeName { code = a.serverInstanceStatus.code, codeName = a.serverInstanceStatus.codeName }, serverInstanceOperation = new codeCodeName { code = a.serverInstanceOperation.code, codeName = a.serverInstanceOperation.codeName } }; serverInstances.Add(item); } if (getServerInstanceList.getServerInstanceListResponse.totalRows == 0) { CheckedServer = new serverInstance(); if (message) { MessageBox.Show("You can use the name as the server name."); } } else { bool matched = false; foreach (var a in serverInstances) { if (a.serverName.Equals(textBoxServerName.Text.Trim(), StringComparison.OrdinalIgnoreCase)) { matched = true; CheckedServer = a; if (message) { MessageBox.Show($"You have a server with that name. serverInstanceNo : {CheckedServer.serverInstanceNo}"); } } } if (!matched) { if (message) { MessageBox.Show("You can use the name as the server name."); } } } } } } catch (Exception) { throw; } }
private async Task GetBlockStorageInstanceList(string storageInstanceNo) { try { if (storageInstanceNo == null || storageInstanceNo.Length < 1) { throw new Exception("select one server"); } string endpoint = dataManager.GetValue(DataManager.Category.ApiGateway, DataManager.Key.Endpoint); string action = @"/server/v2/getBlockStorageInstanceList"; List <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> >(); parameters.Add(new KeyValuePair <string, string>("responseFormatType", "json")); parameters.Add(new KeyValuePair <string, string>("serverInstanceNo", storageInstanceNo)); 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 }; if (response.Contains("responseError")) { hasError hasError = JsonConvert.DeserializeObject <hasError>(response, options); throw new Exception(hasError.responseError.returnMessage); } else { getBlockStorageInstanceList getBlockStorageInstanceList = JsonConvert.DeserializeObject <getBlockStorageInstanceList>(response, options); if (getBlockStorageInstanceList.getBlockStorageInstanceListResponse.returnCode.Equals("0")) { dgvStorageList.InvokeIfRequired(s => { s.Rows.Clear(); foreach (var a in getBlockStorageInstanceList.getBlockStorageInstanceListResponse.blockStorageInstanceList) { int n = s.Rows.Add(); s.Rows[n].Cells["CheckBox"].Value = false; s.Rows[n].Cells["InstanceNo"].Value = a.blockStorageInstanceNo; s.Rows[n].Cells["ServerName"].Value = a.serverName; s.Rows[n].Cells["Name"].Value = a.blockStorageName; s.Rows[n].Cells["Size"].Value = a.blockStorageSize; s.Rows[n].Cells["Type"].Value = a.diskDetailType.code; s.Rows[n].Cells["Desc"].Value = a.blockStorageInstanceDescription; s.Rows[n].Cells["Status"].Value = a.blockStorageInstanceStatus.code; s.Rows[n].Cells["Operation"].Value = a.blockStorageInstanceOperation.code; } }); if (getBlockStorageInstanceList.getBlockStorageInstanceListResponse.totalRows == 0) { MessageBox.Show("storage not founds"); } } } } catch (Exception) { throw; } }
private async Task GetServerImageProductList(string productCode, string regionNo) { try { string endpoint = dataManager.GetValue(DataManager.Category.ApiGateway, DataManager.Key.Endpoint); string action = @"/server/v2/getServerImageProductList"; List <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> >(); parameters.Add(new KeyValuePair <string, string>("responseFormatType", "json")); parameters.Add(new KeyValuePair <string, string>("blockStorageSize", "100")); parameters.Add(new KeyValuePair <string, string>("productCode", "SPSW0WINNTEN0043A")); parameters.Add(new KeyValuePair <string, string>("regionNo", regionNo)); 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 }; comboBoxServerImage.InvokeIfRequired(s => { if (response.Contains("responseError")) { hasError hasError = JsonConvert.DeserializeObject <hasError>(response, options); throw new Exception(hasError.responseError.returnMessage); } else { getServerImageProductList getServerImageProductList = JsonConvert.DeserializeObject <getServerImageProductList>(response, options); if (getServerImageProductList.getServerImageProductListResponse.returnCode.Equals("0")) { s.Items.Clear(); foreach (var a in getServerImageProductList.getServerImageProductListResponse.productList) { var item = new imgProduct { productCode = a.productCode, productName = a.productName, productType = new codeCodeName { code = a.productType.code, codeName = a.productType.codeName }, productDescription = a.productDescription, infraResourceType = new codeCodeName { code = a.infraResourceType.code, codeName = a.infraResourceType.codeName }, cpuCount = a.cpuCount, memorySize = a.memorySize, baseBlockStorageSize = a.baseBlockStorageSize, platformType = new codeCodeName { code = a.platformType.code, codeName = a.platformType.codeName }, osInformation = a.osInformation, dbKindCode = a.dbKindCode, addBlockStorageSize = a.addBlockStorageSize, }; s.Items.Add(item); } } } s.SelectedIndex = 0; }); } catch (Exception) { throw; } }