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; }
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 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) { throw; } }
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 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 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)); } }
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 ResponseFileDbSave(string response) { try { List <serverInstance> serverInstances = new List <serverInstance>(); 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 { createServerInstances createServerInstances = JsonConvert.DeserializeObject <createServerInstances>(response, options); if (createServerInstances.createServerInstancesResponse.returnCode.Equals("0")) { serverInstances.Clear(); foreach (var a in createServerInstances.createServerInstancesResponse.serverInstanceList) { var item = new serverInstance { serverName = a.serverName, serverInstanceNo = a.serverInstanceNo, publicIp = a.publicIp, privateIp = a.privateIp, region = new region { regionNo = a.region.regionNo, regionCode = a.region.regionCode, regionName = a.region.regionName }, zone = new zone { zoneNo = a.zone.zoneNo, zoneName = a.zone.zoneName, zoneCode = a.zone.zoneCode, zoneDescription = a.zone.zoneDescription, regionNo = a.zone.regionNo }, serverImageProductCode = a.serverImageProductCode, serverProductCode = a.serverProductCode, feeSystemTypeCode = "FXSUM", loginKeyName = a.loginKeyName, // where is acg list ? }; serverInstances.Add(item); } if (createServerInstances.createServerInstancesResponse.totalRows == 0) { CheckedServer = new serverInstance(); new Exception("createServerInstances response error."); } else { foreach (var a in serverInstances) { var p = new List <KeyValuePair <string, string> >(); p.Add(new KeyValuePair <string, string>("serverName", a.serverName)); p.Add(new KeyValuePair <string, string>("serverInstanceNo", a.serverInstanceNo)); p.Add(new KeyValuePair <string, string>("serverPublicIp", a.publicIp)); p.Add(new KeyValuePair <string, string>("serverPrivateIp", a.privateIp)); p.Add(new KeyValuePair <string, string>("regionNo", a.region.regionNo)); p.Add(new KeyValuePair <string, string>("zoneNo", a.zone.zoneNo)); p.Add(new KeyValuePair <string, string>("serverImageProductCode", a.serverImageProductCode)); p.Add(new KeyValuePair <string, string>("serverProductCode", a.serverProductCode)); p.Add(new KeyValuePair <string, string>("feeSystemTypeCode", a.feeSystemTypeCode)); p.Add(new KeyValuePair <string, string>("loginKeyName", a.loginKeyName)); if (comboBoxACG1.Text.Equals("")) { p.Add(new KeyValuePair <string, string>("accessControlGroupConfigurationNoList_1", "NULL")); } else { p.Add(new KeyValuePair <string, string>("accessControlGroupConfigurationNoList_1", (comboBoxACG1.SelectedItem as accessControlGroup).accessControlGroupConfigurationNo)); } if (comboBoxACG2.Text.Equals("")) { p.Add(new KeyValuePair <string, string>("accessControlGroupConfigurationNoList_2", "NULL")); } else { p.Add(new KeyValuePair <string, string>("accessControlGroupConfigurationNoList_2", (comboBoxACG2.SelectedItem as accessControlGroup).accessControlGroupConfigurationNo)); } if (comboBoxACG3.Text.Equals("")) { p.Add(new KeyValuePair <string, string>("accessControlGroupConfigurationNoList_3", "NULL")); } else { p.Add(new KeyValuePair <string, string>("accessControlGroupConfigurationNoList_3", (comboBoxACG3.SelectedItem as accessControlGroup).accessControlGroupConfigurationNo)); } if (comboBoxACG4.Text.Equals("")) { p.Add(new KeyValuePair <string, string>("accessControlGroupConfigurationNoList_4", "NULL")); } else { p.Add(new KeyValuePair <string, string>("accessControlGroupConfigurationNoList_4", (comboBoxACG4.SelectedItem as accessControlGroup).accessControlGroupConfigurationNo)); } if (comboBoxACG5.Text.Equals("")) { p.Add(new KeyValuePair <string, string>("accessControlGroupConfigurationNoList_5", "NULL")); } else { p.Add(new KeyValuePair <string, string>("accessControlGroupConfigurationNoList_5", (comboBoxACG5.SelectedItem as accessControlGroup).accessControlGroupConfigurationNo)); } await fileDb.UpSertTable(FileDb.TableName.TBL_SERVER, p); } } } } } 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; } }
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"); } }
private async Task GetServerInstanceList(List <string> instanceNoList) { try { 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) { var item = new serverInstance { serverInstanceNo = a.serverInstanceNo, serverName = a.serverName, publicIp = a.publicIp, privateIp = a.privateIp, serverInstanceStatus = a.serverInstanceStatus, serverInstanceOperation = a.serverInstanceOperation }; serverInstances.Add(item); } if (getServerInstanceList.getServerInstanceListResponse.totalRows == 0) { MessageBox.Show("server not founds"); } } } } 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 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; } }