private async Task VPDbServerExistsCheck() { StatusUpdate(Status.Working); string returnMessage = string.Empty; bool serverExists = false; Dictionary <string, string> dicCloudDBInstance = new Dictionary <string, string>(); try { ConfigSaveAllItem(); string json = string.Empty; var settings = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore, MissingMemberHandling = MissingMemberHandling.Ignore }; json = await GetZoneListAsync(); getZoneList getZoneList = JsonConvert.DeserializeObject <getZoneList>(json, settings); List <zone> zones = getZoneList.getZoneListResponse.zoneList; foreach (var a in zones) { string InstancesOfZoneJson = string.Empty; nlog.Warn(string.Format("{0},{1},{2},{3},{4}", a.zoneNo, a.zoneName, a.zoneCode, a.zoneDescription, a.regionNo)); InstancesOfZoneJson = await GetVPCloudDBInstanceListAsync(a.zoneNo.ToString()); dicCloudDBInstance.Add(a.zoneNo.ToString(), InstancesOfZoneJson); // stirng dic nlog.Warn(InstancesOfZoneJson); } foreach (var a in dicCloudDBInstance) { getCloudMssqlInstanceList getCloudMssqlInstanceList = JsonConvert.DeserializeObject <getCloudMssqlInstanceList>(a.Value, settings); List <CloudMssqlInstance> CloudMssqlInstanceList = getCloudMssqlInstanceList.getCloudMssqlInstanceListResponse.cloudMssqlInstanceList; foreach (var b in CloudMssqlInstanceList) { nlog.Warn(b.cloudMssqlInstanceNo); if (b.cloudMssqlInstanceNo.Equals(textCloudDbInstanceNo.Text.Trim())) { serverExists = true; break; } } } if (serverExists) { MessageBox.Show("DatabaseInfo Connection test was successful"); DatabaseInfoTested = true; } if (!serverExists) { MessageBox.Show(string.Format("{0} : Server dose not exists", CallResult.Fail.ToString())); DatabaseInfoTested = false; } } catch (Exception ex) { nlog.Error(string.Format("{0}, {1}", ex.Message, ex.StackTrace)); MessageBox.Show(string.Format("{0} : {1}", CallResult.Fail.ToString(), ex.Message)); } StatusUpdate(Status.Completed); }
private async void buttonDbServerExistsCheck_Click(object sender, EventArgs e) { nlog.Warn("BackupStorageFileList Started"); StatusUpdate(Status.Working); string returnMessage = string.Empty; bool serverExists = false; Dictionary <string, string> cloudDBInstanceLists = new Dictionary <string, string>(); try { ConfigSaveAllItem(); string json = string.Empty; var settings = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore, MissingMemberHandling = MissingMemberHandling.Ignore }; json = await GetZoneListAsync(); getZoneList getZoneList = JsonConvert.DeserializeObject <getZoneList>(json, settings); List <zone> zones = getZoneList.getZoneListResponse.zoneList; foreach (var a in zones) { string InstancesOfZoneJson = string.Empty; nlog.Warn(string.Format("{0},{1},{2},{3},{4}", a.zoneNo, a.zoneName, a.zoneCode, a.zoneDescription, a.regionNo)); InstancesOfZoneJson = await GetCloudDBInstanceListAsync(a.zoneNo.ToString()); cloudDBInstanceLists.Add(a.zoneNo.ToString(), InstancesOfZoneJson); nlog.Warn(InstancesOfZoneJson); } foreach (var a in cloudDBInstanceLists) { getCloudDBInstanceList getCloudDBInstanceList = JsonConvert.DeserializeObject <getCloudDBInstanceList>(a.Value, settings); List <cloudDBInstanceList> cloudDBInstanceList = getCloudDBInstanceList.getCloudDBInstanceListResponse.cloudDBInstanceList; foreach (var b in cloudDBInstanceList) { nlog.Warn(b.cloudDBInstanceNo); //if (b.cloudDBInstanceNo == textCloudDbInstanceNo.Text) if (b.cloudDBInstanceNo.Equals(textCloudDbInstanceNo.Text.Trim())) { serverExists = true; MessageBox.Show(CallResult.Success.ToString()); break; } } } if (!serverExists) { MessageBox.Show(string.Format("{0} : Server dose not exists", CallResult.Fail.ToString())); } } catch (Exception ex) { nlog.Error(string.Format("{0}, {1}", ex.Message, ex.StackTrace)); MessageBox.Show(string.Format("{0} : {1}", CallResult.Fail.ToString(), ex.Message)); } StatusUpdate(Status.Completed); nlog.Warn("BackupStorageFileList Completed"); }