/// <summary> /// This button launches a control window allowing user to upload file from /// computer or URL. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button3_Click(object sender, EventArgs e) { DialogResult dialogResult = MessageBox.Show("Is the file on your computer?", "Where's the file?", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { string file = ""; DialogResult result = openFileDialog1.ShowDialog(); //If a file is selected, parse it to a dynamic object to be stored in the DB. if (result == DialogResult.OK) { file = openFileDialog1.FileName; //Parsed data DCS_STORE myStore = new DCS_STORE(GlobalConnectionString.ConnectionString); if (myStore.parseFile(file) != null) { if (myStore.storeData()) { columns = new List<string>(); setTableSelector(); getColumns(); MessageBox.Show("Data successfully uploaded!"); } else { MessageBox.Show("Data was not uploaded successfully."); } } else { MessageBox.Show("Data was not parsed successfully."); } } openFileDialog1.FileName = ""; this.Close(); } else { DialogResult dialogResult2 = MessageBox.Show("Do you have the URL of the file?", "Where's the file?", MessageBoxButtons.YesNo); if (dialogResult2 == DialogResult.Yes) { Upload myUP = new Upload(this); myUP.ShowDialog(); } else { MessageBox.Show("If the file is not saved locally, and you do not have the link to the file, then you will not be able to upload the file."); } } }
private void button1_Click(object sender, EventArgs e) { //Creates webclient to get the download. using (var client = new WebClient()) { string fileLoc = textBox1.Text; string fileName = fileLoc.Split('/').Last(); try { client.DownloadFile(fileLoc, fileName); //Parsed data DCS_STORE myStore = new DCS_STORE(GlobalConnectionString.ConnectionString); if (myStore.parseFile(fileName) != null) { //Delete file File.Delete(fileName); if (myStore.storeData()) { columns = new List <string>(); myForm.setTableSelector(); myForm.getColumns(); MessageBox.Show("Data successfully uploaded!"); } else { MessageBox.Show("Data was not uploaded successfully."); } } else { MessageBox.Show("Data was not parsed successfully."); } } catch (Exception k) { MessageBox.Show("Unable to download file at given URL. More Info: " + k); } } this.Close(); }
static void Main(string[] args) { AttachConsole(ATTACH_PARENT_PROCESS); //If no arguments are specified, launch windows form. if (args.Length == 0) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); //Launch login page and wait for it to close before //launching the main form with the connection string. LoginForm myLogin = new LoginForm(); myLogin.ShowDialog(); if (GlobalConnectionString.ConnectionString != null) { Application.Run(new Form1(myLogin.username)); myLogin.Close(); } } else { //Username, password, action, param if (args.Length == 4) { LoginForm.login(args[0], args[1]); if (!LoginForm.testConnection()) { Console.WriteLine("Error: Invalid login information. Please try again."); } else { Console.WriteLine("Successfully connected to the database."); int action = 0; if (Int32.TryParse(args[2], out action)) { if (action == 1) { //Parsed data DCS_STORE myStore = new DCS_STORE(GlobalConnectionString.ConnectionString); if (myStore.parseFile(args[3]) != null) { if (myStore.storeData()) { /* * columns = new List<string>(); * setTableSelector(); * getColumns(); */ Console.WriteLine("Data successfully uploaded!"); } else { Console.WriteLine("Data was not uploaded successfully."); } } else { Console.WriteLine("Data was not parsed successfully."); } } } else { Console.WriteLine("Argument 3 must be an integer."); } } } else { Console.WriteLine("Invalid argument count."); } Application.Exit(); } }