static async Task RunAsync() { string pcName = Environment.MachineName.ToLower(); client.BaseAddress = new Uri("http://r54web03.main.russianpost.ru:52473/api/govno"); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); HBDataTable dataTable = new HBDataTable(); ChangeDateTime dateTime = new ChangeDateTime(); //Get dataTable = await GetDatasync("http://r54web03.main.russianpost.ru:52473/api/govno/" + pcName); //Update dataTable.Pcname = pcName; dataTable.ClientTime = DateTime.Now; dataTable.DateServer = DateTime.Now; dataTable.ExportTime = dateTime.ChangeTimeExport(); dataTable.ImportTime = dateTime.ChangeTimeImport(); dataTable.IsChecked = false; dataTable.TimeOut = 15; await UpdateData(dataTable); }
//GET by pcname static async Task <HBDataTable> GetDatasync(string path) { HBDataTable data = null; ChangeDateTime dateTime = new ChangeDateTime(); HttpResponseMessage message = await client.GetAsync(path); if (message.StatusCode == System.Net.HttpStatusCode.OK) { data = await message.Content.ReadAsAsync <HBDataTable>(); if (data.IsChecked == true) { //тут запускаем keeper Export(); Import(); //данные апдейтим на сервере HBDataTable dataTable = new HBDataTable { Pcname = Environment.MachineName.ToLower(), ClientTime = DateTime.Now, DateServer = DateTime.Now, ExportTime = dateTime.ChangeTimeExport(), ImportTime = dateTime.ChangeTimeImport(), IsChecked = false, TimeOut = 15 }; await UpdateData(dataTable); if (data.IsChecked == false) { //данные апдейтим на сервере HBDataTable dataTable1 = new HBDataTable { Pcname = Environment.MachineName.ToLower(), ClientTime = DateTime.Now, DateServer = DateTime.Now, ExportTime = dateTime.ChangeTimeExport(), ImportTime = dateTime.ChangeTimeImport(), IsChecked = false, TimeOut = 15 }; await UpdateData(dataTable1); } else { //Create HBDataTable hBDataTable = new HBDataTable { Pcname = Environment.MachineName.ToLower(), ClientTime = DateTime.Now, DateServer = DateTime.Now, ExportTime = dateTime.ChangeTimeExport(), ImportTime = dateTime.ChangeTimeImport(), IsChecked = false, TimeOut = 15 }; await CreateDataAsync(hBDataTable); } } return(data); } else { //Create HBDataTable hBDataTable = new HBDataTable { Pcname = Environment.MachineName.ToLower(), ClientTime = DateTime.Now, DateServer = DateTime.Now, ExportTime = dateTime.ChangeTimeExport(), ImportTime = dateTime.ChangeTimeImport(), IsChecked = false, TimeOut = 15 }; await CreateDataAsync(hBDataTable); } return(data); }