Good day! There is a program (client / server) that allows you to take data from the mssql database.
static void Main(string[] args) { OnCallAlgorithm(); } //метод static void OnCallAlgorithm() { ConsoleApplication1.CallAlgorithm.ForSendingSoapClient client = new CallAlgorithm.ForSendingSoapClient(); SqlConnection connect = new SqlConnection(); connect.ConnectionString = @ "Data Source=Пример-ПК;Initial Catalog=ihd_aktobe;Integrated Security=True"; connect.Open(); string data = string.Format(@ "select metaAlg,datetime from Alg_stack"); SqlDataAdapter algorithm_adapter = new SqlDataAdapter(data, connect); DataTable algorithm_table = new DataTable(); algorithm_adapter.Fill(algorithm_table); foreach(DataRow algorithm_row in algorithm_table.Rows) { try { string algorithm_name = algorithm_row["metaAlg"].ToString(); string algorithm_date = algorithm_row["datetime"].ToString(); client.CallAlgorithmByDate(algorithm_name, algorithm_date); } catch (Exception e) { } } connect.Close(); string sql_data = "select * from Alg_stack"; SqlDataAdapter data_adapter = new SqlDataAdapter(sql_data, connect); DataTable data_table = new DataTable(); data_adapter.Fill(data_table); foreach(DataRow data_row in data_table.Rows) { string sql = "UPDATE Alg_stack SET st=1 WHERE st = 0 "; connect.Open(); SqlCommand cmd = new SqlCommand(sql, connect); cmd.ExecuteNonQuery(); connect.Close(); string data_status = data_row["st"].ToString(); switch (data_status) { case "1": { //Если успешно отправлены данные то записать в //comment "успешно" string succesful = "update Alg_stack set comment ='Успешно' where comment is null"; connect.Open(); SqlCommand cmd_2 = new SqlCommand(succesful, connect); cmd_2.ExecuteNonQuery(); connect.Close(); } break; case "2": { string sql_error = "Ошибка"; string error = string.Format(@ "update Alg_stack set comment = {} where comment is null", sql_error); connect.Open(); SqlCommand cmd_3 = new SqlCommand(error, connect); cmd_3.ExecuteNonQuery(); connect.Close(); } break; case "3": { string sql_not_available = "Сервис не доступен"; string not_available = string.Format(@ "update Alg_stack set comment = {} where comment is null", sql_not_available); connect.Open(); SqlCommand cmd_4 = new SqlCommand(not_available, connect); cmd_4.ExecuteNonQuery(); connect.Close(); } break; } } } The server takes data from the client, if successful, then in the "comment" column it writes "successfully" (this is done). Now, you need to create an exception (using try / catch) to add to "comment". Exceptions:
The request channel timeout while waiting has expired. Increase the time-out value transmitted by the call during the Request or increase the SendTimeout value.
and more if you incorrectly set the server address
Listening to http://192.168.1.5/services/forsending.asmx did not perform any endpoint that could receive the message. Among other reasons, this could have been caused by an incorrect address or a SOAP action.
I will be very grateful!
Found something to write in if condition
if () { throw new Exception(@ "Тайм-аут канала запроса во время ожидания истёк.Увеличьте значение времени тайм-аута, передаваемое вызову при Request или увеличьте значение SendTimeout "); }