private void btnSurveys_Click(object sender, EventArgs e) { var dialog = new OpenFileDialog() { CheckFileExists = true, CheckPathExists = true, DefaultExt = "csv", AddExtension = true, InitialDirectory = Environment.GetFolderPath( Environment.SpecialFolder.UserProfile ) + @"\Downloads", Title = "Choose a Source File - PestPac Utility", RestoreDirectory = true, Multiselect = false }; string lastPath = null; string temp = null; if (config.TryGetValue("LastPath", out temp)) { if (!(MessageBox.Show( "The current target is set to \"" + lastPath + "\", would you like to change it?", "PestPac Utility", MessageBoxButtons.YesNo ) == DialogResult.Yes && dialog.TryGetPath(out lastPath)) ) { lastPath = temp; } } else if (!dialog.TryGetPath(out lastPath)) { return; } dialog.Dispose(); dialog = null; string type = grpType.Controls.Cast <RadioButton>().Single(r => r.Checked).Text; grpType.Enabled = false; ThreadPool.QueueUserWorkItem( new WaitCallback( (o) => { SogoClient sogo = new SogoClient(Logger); sogo.LoadSurvey(lastPath, o.ToString()); sogo.UploadNotes(); UIThread.Invoke(() => grpType.Enabled = true); } ), type ); }
private void Form1_Load(object sender, EventArgs e) { SogoClient sogo = new SogoClient(Logger); SogoClient.Surveys["QTPC"].SaveAs(@"E:\Temp\QTPCFormat.txt"); sogo.CreateFormat(@"C:\DocUploads\Program Files\Surveys\QTPC.csv").Value.SaveAs(@"E:\Temp\CreateFormatTest1.txt"); sogo.CreateFormat(@"C:\DocUploads\Program Files\Surveys\SoGoSurvey_QTPC Survey 2.2_14.csv").Value.SaveAs(@"E:\Temp\CreateFormatTest2.txt"); AppDomain.CurrentDomain.ProcessExit += CurrentDomain_ProcessExit; UIThread = Dispatcher.CurrentDispatcher; prgThread.DoWork += prgThread_DoWork; ThreadPool.QueueUserWorkItem(new WaitCallback((obj) => UIUpdater(prgThread, ref prgCounter, 250))); Logger.OnEntry += Logger_OnEntry; }