public Form1() { // Checking and adding to boot AddToBoot(); // Reading cfg cfg = ConfigIO.ReadFromFile(cfgPath); if (cfg == null) { ShowErrorMessage("config file can not be read"); cfg = new Config(); } InitializeComponent(); // Sync config values with UI tbDataPath.Text = cfg.saveFilePath; tbLink.Text = cfg.link; // Checking arguments if (IsSilenceLaunch()) { LaunchOnSilentMode(); } }
private void BtnChooseDataPath_Click(object sender, EventArgs e) { // Adding file saving path if (folderBrowserDialog1.ShowDialog() == DialogResult.OK) { tbDataPath.Text = folderBrowserDialog1.SelectedPath + "\\PriceData.csv"; cfg.saveFilePath = tbDataPath.Text; ConfigIO.SaveToFile(cfg, cfgPath); } }
private async Task <bool> Pull() { // Get config values from UI if (cfg.link != tbLink.Text) { cfg.link = tbLink.Text; } if (cfg.saveFilePath != tbDataPath.Text) { cfg.saveFilePath = tbDataPath.Text; } // Save configuration to file if (!ConfigIO.SaveToFile(cfg, cfgPath)) { ShowErrorMessage("Can`t save config"); return(false); } // Parse products Parser parser = new Parser(); List <ParsedProduct> products = await parser.ParseLink(cfg.link); // If parse error if (products == null) { ShowErrorMessage("Data doesn`t parsed!"); return(false); } // Write data to csv file if (!DataWriter.WriteToFIle(products, cfg.saveFilePath) && cfg.saveFilePath == "") { ShowErrorMessage("Folder doesn't chosen"); return(false); } MessageBox.Show("Success", "OK!", MessageBoxButtons.OK, MessageBoxIcon.Information); return(true); }