//[Fact] public void DownloadNonExistentComponentFromExchange() { string metaDirectory = META.VersionInfo.MetaPath; var componentToDownload = new ISIS.VehicleForge.VFComponent(); // Might make sense to randomly generate a component id and try it - 24 hex characters componentToDownload.zip_url = "/rest/exchange/components/aaaabbbbccccddddeeeeffff/zip"; using (VFWebClient vfWebClient = new VFWebClient(this.fixture.credentials.Url, this.fixture.credentials)) { VFExchange exchange = new VFExchange(vfWebClient); string newZipPath = exchange.DownloadComponent(componentToDownload, metaDirectory); Assert.Null(newZipPath); } }
//[Fact] public void DownloadComponentFromExchange() { string metaDirectory = META.VersionInfo.MetaPath; var componentToDownload = new ISIS.VehicleForge.VFComponent(); // https://testbench.vf.isis.vanderbilt.edu/rest/exchange/components/5282583bc51df0577fa0fd23 // Engine_Caterpillar_C9_280kW componentToDownload.zip_url = "/rest/exchange/components/5282583bc51df0577fa0fd23/zip"; using (VFWebClient vfWebClient = new VFWebClient(this.fixture.credentials.Url, this.fixture.credentials)) { VFExchange exchange = new VFExchange(vfWebClient); string newZipPath = exchange.DownloadComponent(componentToDownload, metaDirectory); Assert.NotNull(newZipPath); if (File.Exists(newZipPath)) { File.Delete(newZipPath); } } }
private void btnImport_Click(object sender, EventArgs e) { if (this.dgvSelectorVFComponents.SelectedRows.Count == 0) { var msgBoxResponse = MessageBox.Show( "No Components have been selected for Import. VehicleForge Component Exchange Dialog will close.", "Nothing Happened", MessageBoxButtons.OKCancel, MessageBoxIcon.Information); if (msgBoxResponse == System.Windows.Forms.DialogResult.OK) { this.DialogResult = System.Windows.Forms.DialogResult.Cancel; this.Close(); } else { return; } } List <string> componentZipPaths = new List <string>(); using (VFDownloadProgressDialog downloadProgressDialog = new VFDownloadProgressDialog()) { // set the size of the download progess bar, and print how many components will be downloaded downloadProgressDialog.pbDownloadProgress.Maximum = this.dgvSelectorVFComponents.SelectedRows.Count; downloadProgressDialog.lblNumberComponents.Text = string.Format("{0} Components", this.dgvSelectorVFComponents.SelectedRows.Count); downloadProgressDialog.Show(); foreach (var row in this.dgvSelectorVFComponents.SelectedRows) { var dgvr = row as System.Windows.Forms.DataGridViewRow; var vfcli = dgvr.DataBoundItem as VFComponentListItem; try { string newZipPath = exchange.DownloadComponent(vfcli.Component, this.zipDownloadDir); if (newZipPath != null) { componentZipPaths.Add(newZipPath); } downloadProgressDialog.pbDownloadProgress.PerformStep(); downloadProgressDialog.pbDownloadProgress.Refresh(); } catch (ISIS.VehicleForge.VFDownloadFailedException ex) { var msgBoxResponse = MessageBox.Show( "Unable to download component.", "Component download failed.", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } this.DownloadedComponentZips.AddRange(componentZipPaths); this.DialogResult = System.Windows.Forms.DialogResult.OK; this.Close(); }