コード例 #1
0
ファイル: PanHGViewModel.cs プロジェクト: panonit/PanHG
        private void ScanLocalRepoCommandExecute(object param)
        {
            try
            {
                LoaderVisibility = Visibility.Visible;
                IsEnable         = false;

                string[] dirs = Directory.GetDirectories(@UpdateRepoPath, ".hg", SearchOption.AllDirectories);
                UpdateRepoList = new ObservableCollection <CheckBoxRepos>();

                foreach (string dir in dirs)
                {
                    CheckBoxRepos cbr = new CheckBoxRepos();
                    cbr.Name      = Directory.GetParent(dir).FullName;
                    cbr.IsChecked = false;
                    UpdateRepoList.Add(cbr);
                    updateRepoListAll.Add(cbr);
                }

                IsEnable         = true;
                LoaderVisibility = Visibility.Hidden;
            }
            catch
            {
                LoaderVisibility = Visibility.Hidden;
                IsEnable         = true;
                System.Windows.Forms.MessageBox.Show("ERROR - Please chose correct folder.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #2
0
ファイル: PanHGViewModel.cs プロジェクト: panonit/PanHG
        private List <CheckBoxRepos> getRepoList(string password)
        {
            LoaderVisibility = Visibility.Visible;
            List <CheckBoxRepos> repos = new List <CheckBoxRepos>();

            try
            {
                HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create("http://example.com");  // Returns a response from an Internet resource. You can use it to send HTTP requests to any server. You need to change it to send requests to your server.
                webRequest.Method      = "GET";
                webRequest.ContentType = "application/x-www-form-urlencoded";
                webRequest.Credentials = new NetworkCredential(username, password);

                string webpageContent = string.Empty;

                using (HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse())
                {
                    using (StreamReader reader = new StreamReader(webResponse.GetResponseStream()))
                    {
                        while (!reader.EndOfStream)
                        {
                            string repoName = string.Empty;
                            webpageContent = reader.ReadLine();
                            int index1 = webpageContent.IndexOf("<a href=\"/");
                            if (index1 > 0)
                            {
                                int index2 = webpageContent.IndexOf("/\">");
                                repoName = webpageContent.Substring(index1 + 9, index2 - index1 - 8);

                                reader.ReadLine();
                                reader.ReadLine();
                                webpageContent = reader.ReadLine();

                                CheckBoxRepos repo = new CheckBoxRepos();
                                repo.Name            = repoName;
                                repo.IsChecked       = false;
                                repo.DateModified    = webpageContent.Substring(21, 17);
                                repo.BackgroundColor = Colors.Transparent.ToString();
                                repo.Tooltip         = "Remote repo";

                                repos.Add(repo);
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                System.Windows.Forms.MessageBox.Show(e.Message.ToString(), "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            LoaderVisibility = Visibility.Hidden;

            return(repos);
        }
コード例 #3
0
ファイル: PanHGViewModel.cs プロジェクト: panonit/PanHG
        private void ScanLocalRepoCommandExecute(object param)
        {
            try
            {
                LoaderVisibility = Visibility.Visible;
                IsEnable = false;

                string[] dirs = Directory.GetDirectories(@UpdateRepoPath, ".hg", SearchOption.AllDirectories);
                UpdateRepoList = new ObservableCollection<CheckBoxRepos>();

                foreach (string dir in dirs)
                {
                    CheckBoxRepos cbr = new CheckBoxRepos();
                    cbr.Name = Directory.GetParent(dir).FullName;
                    cbr.IsChecked = false;
                    UpdateRepoList.Add(cbr);
                    updateRepoListAll.Add(cbr);

                }

                IsEnable = true;
                LoaderVisibility = Visibility.Hidden;
            }
            catch
            {
                LoaderVisibility = Visibility.Hidden;
                IsEnable = true;
                System.Windows.Forms.MessageBox.Show("ERROR - Please chose correct folder.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #4
0
ファイル: PanHGViewModel.cs プロジェクト: panonit/PanHG
        private List<CheckBoxRepos> getRepoList(string password)
        {
            LoaderVisibility = Visibility.Visible;
            List<CheckBoxRepos> repos = new List<CheckBoxRepos>();
            try
            {
                HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create("http://example.com");  // Returns a response from an Internet resource. You can use it to send HTTP requests to any server. You need to change it to send requests to your server.
                webRequest.Method = "GET";
                webRequest.ContentType = "application/x-www-form-urlencoded";
                webRequest.Credentials = new NetworkCredential(username, password);

                string webpageContent = string.Empty;

                using (HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse())
                {
                    using (StreamReader reader = new StreamReader(webResponse.GetResponseStream()))
                    {
                        while (!reader.EndOfStream)
                        {
                            string repoName = string.Empty;
                            webpageContent = reader.ReadLine();
                            int index1 = webpageContent.IndexOf("<a href=\"/");
                            if (index1 > 0)
                            {
                                int index2 = webpageContent.IndexOf("/\">");
                                repoName = webpageContent.Substring(index1 + 9, index2 - index1 - 8);

                                reader.ReadLine();
                                reader.ReadLine();
                                webpageContent = reader.ReadLine();

                                CheckBoxRepos repo = new CheckBoxRepos();
                                repo.Name = repoName;
                                repo.IsChecked = false;
                                repo.DateModified = webpageContent.Substring(21, 17);
                                repo.BackgroundColor = Colors.Transparent.ToString();
                                repo.Tooltip = "Remote repo";

                                repos.Add(repo);
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                System.Windows.Forms.MessageBox.Show(e.Message.ToString(), "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            LoaderVisibility = Visibility.Hidden;

            return repos;
        }