Interaction logic for SearchComponenetDialog.xaml
예제 #1
0
        /// <summary>
        /// Searches the components.
        /// </summary>
        /// <param name="conf">The conf.</param>
        /// <param name="rest">The rest.</param>
        /// <param name="availableProjects">The available projects.</param>
        /// <param name="listofSaveComp">The listof save comp.</param>
        /// <returns>returns saved component list</returns>
        public static List <Resource> SearchComponents(
            ISonarConfiguration conf,
            ISonarRestService rest,
            List <Resource> availableProjects,
            List <Resource> listofSaveComp,
            IVsEnvironmentHelper helper)
        {
            var savedList = new List <Resource>();

            foreach (var item in listofSaveComp)
            {
                savedList.Add(item);
            }


            try
            {
                var searchComponenetDialog = new SearchComponenetDialog(conf, rest, availableProjects, listofSaveComp, helper);
                searchComponenetDialog.ShowDialog();

                if (searchComponenetDialog.DialogResult == true)
                {
                    return(searchComponenetDialog.SelectedDataGrid.Items.OfType <Resource>().ToList());
                }
                else
                {
                    return(savedList);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Ups Something wrong has happened. Please Report : " + ex.Message + " -> " + ex.StackTrace);
            }

            return(new List <Resource>());
        }
        /// <summary>
        /// Searches the components.
        /// </summary>
        /// <param name="conf">The conf.</param>
        /// <param name="rest">The rest.</param>
        /// <param name="availableProjects">The available projects.</param>
        /// <param name="listofSaveComp">The listof save comp.</param>
        /// <returns>returns saved component list</returns>
        public static List<Resource> SearchComponents(ISonarConfiguration conf, ISonarRestService rest, List<Resource> availableProjects, List<Resource> listofSaveComp)
        {
            var savedList = new List<Resource>();
            foreach (var item in listofSaveComp)
            {
                savedList.Add(item);
            }

            try
            {
                var searchComponenetDialog = new SearchComponenetDialog(conf, rest, availableProjects, listofSaveComp);
                searchComponenetDialog.ShowDialog();

                if (searchComponenetDialog.DialogResult == true)
                {
                    return searchComponenetDialog.SelectedDataGrid.Items.OfType<Resource>().ToList();
                }
                else
                {
                    return savedList;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Ups Something wrong has happened. Please Report : " + ex.Message + " -> " + ex.StackTrace);
            }

            return new List<Resource>();
        }