RunAsync(user, pass, guid).Wait();
static async Task RunAsync(string user , string pw , string guid)
using (var client = new HttpClient())
client.BaseAddress = new Uri("https://***/api/");
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
HttpResponseMessage response = await client.GetAsync(string.Format("gs/{0}/{1}/{2}", user, pw, guid)).ConfigureAwait(false);
if (response.IsSuccessStatusCode)
string jsonInput = await response.Content.ReadAsStringAsync();
JavaScriptSerializer jsonSerializer = new JavaScriptSerializer();
RootObject objCustomer = jsonSerializer.Deserialize<RootObject>(jsonInput);
_conn = objCustomer.Client[0].constring;
var config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
var connectionStringsSection = (ConnectionStringsSection)config.GetSection("connectionStrings");
connectionStringsSection.ConnectionStrings["AMS.Properties.Settings.ams_roumpasConnectionString"].ConnectionString = objCustomer.Client[0].constring;
config.Save(ConfigurationSaveMode.Full, true);
ConfigurationManager.RefreshSection("connectionStrings");
ConfigurationManager.RefreshSection("configSections");
ams_DataSetTableAdapters.AppointmentsTableAdapter aa = new ams_DataSetTableAdapters.AppointmentsTableAdapter();
aa.Connection.ConnectionString = objCustomer.Client[0].constring;
if (aa.Connection.State != System.Data.ConnectionState.Closed)
setupdated = Convert.ToDateTime(objCustomer.Client[0].setupdate);
expireddated = Convert.ToDateTime(objCustomer.Client[0].expired);
private void InitConnection() {
this._connection = new global::MySql.Data.MySqlClient.MySqlConnection();
this._connection.ConnectionString = global::AMS.Properties.Settings.Default.ams_roumpasConnectionString;