//[Fact] public void SearchComponentOnExchangeWithFilter() { ISIS.Web.IComponentLibrarySearchResult <VFComponent> searchResult; using (VFWebClient vfWebClient = new VFWebClient(this.fixture.credentials.Url, this.fixture.credentials)) { VFExchange exchange = new VFExchange(vfWebClient); Dictionary <string, ISIS.Web.ComponentLibraryFilterParameter> filterParams = new Dictionary <string, ISIS.Web.ComponentLibraryFilterParameter>(); string categoryToSearch = "Engine"; string filterName = "Power"; string minimumValue = "400"; // Create a new filter object var newParam = new ISIS.Web.ContinuousFilterParameter(filterName) { MinValue = minimumValue, }; filterParams[filterName] = newParam; var filter = new VFExchangeFilter() { Category = categoryToSearch, ParameterList = filterParams }; searchResult = exchange.Search(filter); Assert.Equal(1, searchResult.hits); } }
public VFComponentExchangeForm(VFExchange exchange, VFExchangeFilter filter, string zipDownloadDir) { this.InitializeComponent(); this.exchange = exchange; this.filter = filter; this.zipDownloadDir = zipDownloadDir; this.dataSource = new List <ClmLib.VFComponentListItem>(); this.DownloadedComponentZips = new List <string>(); // Show which Component Category we are searching for this.lblComponentCategory.Text = this.filter.Category; //try //{ this.searchResult = this.exchange.Search(this.filter); if (this.searchResult == null) { throw new VFCategoryNotFoundException(); } int highestDisplayedIndex = (this.filter.NumberOfResults > this.searchResult.hits) ? this.searchResult.hits : this.filter.NumberOfResults; this.lblSearchResultsInfo.Text = string.Format( "Showing {0}-{1} of {2} search hits", this.filter.StartPosition + 1, highestDisplayedIndex, //this.filter.StartPosition + this.filter.NumberOfResults, this.searchResult.hits ); foreach (var comp in searchResult.components) { this.dataSource.Add(new ClmLib.VFComponentListItem(comp)); } this.dgvSelectorVFComponents.DataSource = this.dataSource; this.dgvSelectorVFComponents.ClearSelection(); //} //catch (VFInvalidURLException) //{ // MessageBox.Show("Invalid VehicleForge URL"); //} }
public VFComponentExchangeForm(VFExchange exchange, VFExchangeFilter filter, string zipDownloadDir) { this.InitializeComponent(); this.exchange = exchange; this.filter = filter; this.zipDownloadDir = zipDownloadDir; this.dataSource = new List<ClmLib.VFComponentListItem>(); this.DownloadedComponentZips = new List<string>(); // Show which Component Category we are searching for this.lblComponentCategory.Text = this.filter.Category; //try //{ this.searchResult = this.exchange.Search(this.filter); if (this.searchResult == null) { throw new VFCategoryNotFoundException(); } int highestDisplayedIndex = (this.filter.NumberOfResults > this.searchResult.hits) ? this.searchResult.hits : this.filter.NumberOfResults; this.lblSearchResultsInfo.Text = string.Format( "Showing {0}-{1} of {2} search hits", this.filter.StartPosition + 1, highestDisplayedIndex, //this.filter.StartPosition + this.filter.NumberOfResults, this.searchResult.hits ); foreach (var comp in searchResult.components) { this.dataSource.Add(new ClmLib.VFComponentListItem(comp)); } this.dgvSelectorVFComponents.DataSource = this.dataSource; this.dgvSelectorVFComponents.ClearSelection(); //} //catch (VFInvalidURLException) //{ // MessageBox.Show("Invalid VehicleForge URL"); //} }
public void SearchEmptyCategoryOnExchange() { ISIS.Web.IComponentLibrarySearchResult <VFComponent> searchResult; string categoryToSearch = ""; using (VFWebClient vfWebClient = new VFWebClient(this.fixture.credentials.Url, this.fixture.credentials)) { VFExchange exchange = new VFExchange(vfWebClient); var filter = new VFExchangeFilter() { Category = categoryToSearch, }; searchResult = exchange.Search(filter); Assert.Null(searchResult); } }
//[Fact] public void SearchComponentOnExchange() { ISIS.Web.IComponentLibrarySearchResult <VFComponent> searchResult; string categoryToSearch = "Engine"; using (VFWebClient vfWebClient = new VFWebClient(this.fixture.credentials.Url, this.fixture.credentials)) { VFExchange exchange = new VFExchange(vfWebClient); var filter = new VFExchangeFilter() { Category = categoryToSearch, StartPosition = 0, NumberOfResults = 10 }; searchResult = exchange.Search(filter); Assert.Equal(5, searchResult.hits); } }
public List<MgaFCO> ShowAndSelectVFComponents(Dictionary<string, ComponentLibraryFilterParameter> filterParameters) { // VF List<MgaFCO> importedComponents = new List<MgaFCO>(); using (VFExchangeConfig config = new VFExchangeConfig()) { var dialogResult = config.ShowDialog(); if (dialogResult == DialogResult.OK) { Credentials credentials = config.Credentials; // FOR DEBUGGING. Should remove these two lines... // For testing only //if (System.IO.File.Exists("pass.txt")) //{ // string loginInfo = System.IO.File.ReadAllText("pass.txt"); // credentials.Url = loginInfo.Split(',').ElementAt(0); // credentials.Username = loginInfo.Split(',').ElementAt(1); // credentials.Password = loginInfo.Split(',').ElementAt(2); //} try { using (VFWebClient vfWebClient = new VFWebClient(credentials.Url, credentials)) { VFExchange exchange = new VFExchange(vfWebClient); // in the future, may also allow the user to define parameter ranges in a form? var filter = new VFExchangeFilter() { Category = Clm.GetComponentCategory(this.CyPhyComponent), NumberOfResults = 10, StartPosition = 0, ParameterList = filterParameters }; using (VFComponentExchangeForm vfComponentSelection = new VFComponentExchangeForm(exchange, filter, this.ZipDownloadDir)) { var dr = vfComponentSelection.ShowDialog(); if (dr == DialogResult.OK) { // import the component zip files from VFComponentDownloads importedComponents.AddRange(Clm.ImportComponentZips(this.CyPhyComponent.Project, vfComponentSelection.DownloadedComponentZips)); } } } } catch (VFException ex) { string message = string.Format("{0}{1}{2}", ex.Message, Environment.NewLine, ex.GetType()); MessageBox.Show(message); } } } return importedComponents; }
public List <MgaFCO> ShowAndSelectVFComponents(Dictionary <string, ComponentLibraryFilterParameter> filterParameters) { // VF List <MgaFCO> importedComponents = new List <MgaFCO>(); using (VFExchangeConfig config = new VFExchangeConfig()) { var dialogResult = config.ShowDialog(); if (dialogResult == DialogResult.OK) { Credentials credentials = config.Credentials; // FOR DEBUGGING. Should remove these two lines... // For testing only //if (System.IO.File.Exists("pass.txt")) //{ // string loginInfo = System.IO.File.ReadAllText("pass.txt"); // credentials.Url = loginInfo.Split(',').ElementAt(0); // credentials.Username = loginInfo.Split(',').ElementAt(1); // credentials.Password = loginInfo.Split(',').ElementAt(2); //} try { using (VFWebClient vfWebClient = new VFWebClient(credentials.Url, credentials)) { VFExchange exchange = new VFExchange(vfWebClient); // in the future, may also allow the user to define parameter ranges in a form? var filter = new VFExchangeFilter() { Category = Clm.GetComponentCategory(this.CyPhyComponent), NumberOfResults = 10, StartPosition = 0, ParameterList = filterParameters }; using (VFComponentExchangeForm vfComponentSelection = new VFComponentExchangeForm(exchange, filter, this.ZipDownloadDir)) { var dr = vfComponentSelection.ShowDialog(); if (dr == DialogResult.OK) { // import the component zip files from VFComponentDownloads importedComponents.AddRange(Clm.ImportComponentZips(this.CyPhyComponent.Project, vfComponentSelection.DownloadedComponentZips)); } } } } catch (VFException ex) { string message = string.Format("{0}{1}{2}", ex.Message, Environment.NewLine, ex.GetType()); MessageBox.Show(message); } } } return(importedComponents); }