static void insert() { using (SqlConnection connec = new SqlConnection(connect())) { connec.Open(); try { for (int i = 0; i < Words.Count; i++) { string query = $"INSERT INTO {_Title} (ID, word, wordQuanity) values ({i}, N'{Words[i]._word}', {Words[i]._quanity})"; SqlCommand command = new SqlCommand(query, connec); command.ExecuteNonQuery(); command.Dispose(); } connec.Close(); Console.WriteLine("Данные сохранены в БД в таблицу с названием " + _Title); } catch (Exception insertExeptions) { Console.WriteLine("Ошибка!"); FileWorker fileWorker = new FileWorker(); fileWorker.WriteExeptions("дата: " + Convert.ToString(DateTime.Now) + "метод insert" + insertExeptions.Message, ConfigurationManager.AppSettings.Get("DBworkerExeption")); fileWorker.Dispose(); } } }
static void Download() { string path = ConfigurationManager.AppSettings.Get("DownloadHtmlPath") + FileName() + ".html"; try { using (WebClient client = new WebClient()) client.DownloadFile(_url, path); FileWorker.Read(path); } catch (Exception downloadExepions) { FileWorker fileWorker = new FileWorker(); fileWorker.WriteExeptions("дата:" + Convert.ToString(DateTime.Now) + "|| метод Download: " + downloadExepions.Message, ConfigurationManager.AppSettings.Get("DownloadHtmlExeptions")); fileWorker.Dispose(); Console.WriteLine("Не корректная ссылка, введите повторно"); _url = Console.ReadLine(); Download(); } }