Beispiel #1
0
        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;
        }
Beispiel #2
0
        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);
        }