예제 #1
0
 public Confirm(string optionKey, string LabelText)
 {
     InitializeComponent();
     _optionKey             = optionKey;
     lblConfirmText.Text    = LabelText;
     chkShowConfirm.Checked = RepositoryUtils.GetOptionValue(_optionKey) == "1" ? true : false;
 }
예제 #2
0
        private void GetRoot()
        {
            ManageControls(true);

            cboOperator.SelectedIndex = 0;
            txtSourceFile.Text        = String.Empty;
            txtGrep.Text  = String.Empty;
            lblHitAt.Text = String.Empty;

            var defaultRoot = RepositoryUtils.GetDefaultRootId();

            if (defaultRoot != null)
            {
                var progressHandler = new Progress <ProgressResult>(value =>
                {
                    var percent = (int)(((double)progressRefresh.Value / (double)progressRefresh.Maximum) * 100);
                    progressRefresh.ProgressBar.Refresh();
                    progressRefresh.ProgressBar.CreateGraphics().DrawString(percent.ToString() + "%", new Font("Arial", (float)8.25, FontStyle.Regular), Brushes.Black, new PointF(progressRefresh.Width / 2 - 10, progressRefresh.Height / 2 - 7));
                    progressRefresh.Value  = value.ProgressValue;
                    tsCurrentSolution.Text = value.WorkingOn;
                });
                var progress = progressHandler as IProgress <ProgressResult>;

                var t = Task.Run(() => _repo = new RepositoryFile(defaultRoot[0], progress));
                t.ContinueWith(r =>
                {
                    MessageBox.Show($"Error retrieving root {defaultRoot[1]}. Please remove and re-add it.");
                    ManageControls(false);
                }, CancellationToken.None, TaskContinuationOptions.OnlyOnFaulted, TaskScheduler.FromCurrentSynchronizationContext());

                t.ContinueWith(r =>
                {
                    lblRoot.Text = _repo.Root.RootPath;
                    ManageControls(false);
                    RefreshCount();
                    lblResultCount.Text = "0";
                    _timerGrep          = new Timer {
                        Interval = MILLISECOND_SEARCH_DELAY
                    };
                    _timerGrep.Tick += _timerGrep_Tick;
                }, CancellationToken.None, TaskContinuationOptions.OnlyOnRanToCompletion, TaskScheduler.FromCurrentSynchronizationContext())
                .ContinueWith(r1 => Task.Run(() => System.Threading.Thread.Sleep(3000))
                              .ContinueWith(r2 =>
                {
                    progressRefresh.Value = 0;
                }, CancellationToken.None, TaskContinuationOptions.OnlyOnRanToCompletion, TaskScheduler.FromCurrentSynchronizationContext()),
                              CancellationToken.None, TaskContinuationOptions.OnlyOnRanToCompletion, TaskScheduler.FromCurrentSynchronizationContext());
            }
            else
            {
                btnRefresh.Enabled             = false;
                picWaiting.Visible             = false;
                toolStripButtonRoots.Enabled   = true;
                toolStripButtonOptions.Enabled = true;
                lblRoot.Text = "No default source root found. Please add at least one.";
            }
        }
예제 #3
0
 private void btnOk_Click(object sender, EventArgs e)
 {
     _OkToClose = File.Exists(txtVSLocation.Text);
     if (_OkToClose)
     {
         RepositoryUtils.UpdateOptionValue(Constants.CONFIRM_RECRAWL, chkRecrawlConfirm.Checked ? "1" : "0");
         RepositoryUtils.UpdateOptionValue(Constants.VS_LOCATION, txtVSLocation.Text);
     }
 }
예제 #4
0
        public Options()
        {
            InitializeComponent();

            chkRecrawlConfirm.Checked = RepositoryUtils.GetOptionValue(Constants.CONFIRM_RECRAWL) == "1" ? true : false;
            var vsLoc = RepositoryUtils.GetOptionValue(Constants.VS_LOCATION);

            txtVSLocation.Text = String.IsNullOrWhiteSpace(vsLoc) ? Constants.DEFAULT_VS_LOCATION : vsLoc;
        }
예제 #5
0
        public void Refresh(string rootId)
        {
            var SQL = "select * from roots where root_id={0}";
            var ds  = RepositoryUtils.ExecuteQuery(String.Format(SQL, rootId.SafeStringToSQL()));

            if (ds.Tables[0].Rows.Count == 1)
            {
                var row = ds.Tables[0].Rows[0];

                RootId     = rootId;
                RootPath   = row["root_path"].ToString();
                IsDefault  = Convert.ToInt32(row["is_default"]) == 1 ? true : false;
                LastUpdate = Convert.ToDateTime(row["last_update"]);
            }
        }
예제 #6
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            //Check if a default exists
            if (lbxRoots.SelectedItem != null)
            {
                foreach (var item in _allRoots)
                {
                    item.IsDefault = lbxRoots.SelectedItem.Equals(item);

                    RepositoryUtils.Upsert(item);
                }
            }

            DialogResult = DialogResult.OK;
        }
예제 #7
0
        private void btnVSLocation_Click(object sender, EventArgs e)
        {
            var vsLoc = RepositoryUtils.GetOptionValue(Constants.VS_LOCATION);
            var exec  = String.IsNullOrWhiteSpace(vsLoc) ? Constants.DEFAULT_VS_LOCATION : vsLoc;

            var initDir = File.Exists(exec) ? Path.GetDirectoryName(exec) : String.Empty;
            var f       = new OpenFileDialog {
                FileName = Path.GetFileName(exec), InitialDirectory = initDir
            };

            if (f.ShowDialog() == DialogResult.OK)
            {
                txtVSLocation.Text = f.FileName;
            }
        }
예제 #8
0
        public ManageRoots(RepositoryFile currentRepo)
        {
            InitializeComponent();

            _allRoots              = new BindingList <RootObject>(RepositoryUtils.GetAllRoots());
            lbxRoots.DataSource    = _allRoots;
            lbxRoots.DisplayMember = "RootPath";

            if (_allRoots.Count > 0)
            {
                lbxRoots.SelectedItem = _allRoots.FirstOrDefault(r => r.IsDefault);
            }
            else
            {
                btnRemove.Enabled = false;
            }
            _currentRepo = currentRepo;
            lbxRoots.Focus();
        }
예제 #9
0
        internal static string[] GetDefaultRootId()
        {
            try
            {
                CheckRepositoryFile();
                var ds = RepositoryUtils.ExecuteQuery("select root_id,root_path from roots where is_default=1"); // should be only 1 record

                if (ds.Tables[0].Rows.Count == 1)
                {
                    return(new[] { ds.Tables[0].Rows[0]["root_id"].ToString(), ds.Tables[0].Rows[0]["root_path"].ToString() });
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #10
0
        private void deleteRootToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (lbxRoots.Items.Count == 0 || lbxRoots.SelectedItem == null)
            {
                MessageBox.Show("Nothing to delete.");
                return;
            }

            var IdToDelete  = (lbxRoots.SelectedItem as RootObject).RootId;
            var objToDelete = _allRoots.First(r => r.RootId == IdToDelete);

            if (_currentRepo != null && IdToDelete == _currentRepo.Root.RootId)
            {
                _currentRepo.ClearCache();
            }

            RepositoryUtils.DeleteRoot(IdToDelete);
            _allRoots.Remove(objToDelete);

            AdjustAddRemoveButtons();
        }
예제 #11
0
        private void addNewRootToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog folder = new FolderBrowserDialog();

            if (folder.ShowDialog() == DialogResult.OK)
            {
                var newRoot = new RootObject
                {
                    RootId     = Guid.NewGuid().ToString(),
                    RootPath   = folder.SelectedPath,
                    IsDefault  = _allRoots.Count == 0 ? true : false,
                    LastUpdate = DateTime.Now
                };

                RepositoryUtils.Upsert(newRoot);
                _allRoots.Add(newRoot);
                lbxRoots.SelectedItem = newRoot;
            }

            AdjustAddRemoveButtons();
        }
예제 #12
0
        private void OpenSolution()
        {
            if (gridResults.Rows.Count == 0)
            {
                return;
            }

            var file   = String.Empty;
            var errors = new Collection <string>();
            var vsLoc  = RepositoryUtils.GetOptionValue(Constants.VS_LOCATION);
            var exec   = String.IsNullOrWhiteSpace(vsLoc) ? Constants.DEFAULT_VS_LOCATION : vsLoc;

            try
            {
                var sol = _repo.GetSourceData(gridResults.SelectedRows[0].Cells[0].Value.ToString());
                file = sol.SolutionPathAndFileName;
                if (!File.Exists(sol.SolutionPathAndFileName))
                {
                    errors.Add("File doesn't exist: " + sol.SolutionPathAndFileName);
                }
                else if (!File.Exists(exec))
                {
                    errors.Add($"Visual Studio executable file doesn't exist: {exec}. Please change it in the Options.");
                }
                else
                {
                    System.Diagnostics.Process.Start(exec, file);
                }
            }
            catch (Exception ex)
            {
                errors.Add("File = " + file + "\r\n" + ex.Message);
            }

            if (errors.Any())
            {
                var er = String.Join("\r\n", errors);
                MessageBox.Show("Exception!\r\n" + er);
            }
        }
예제 #13
0
        private void btnRefresh_Click(object sender, EventArgs e)
        {
            try
            {
                var conf = new Confirm(Constants.CONFIRM_RECRAWL, "Are you sure?");
                var dr   = DialogResult.OK;

                if (RepositoryUtils.GetOptionValue(Constants.CONFIRM_RECRAWL) == "1" && _repo.GetSourceCount() > 0)
                {
                    dr = conf.ShowDialog();
                }

                if (dr == DialogResult.OK)
                {
                    RemoveAllButMainTab();
                    txtSourceFile.Text = String.Empty;
                    txtGrep.Text       = String.Empty;
                    txtDLL.Text        = String.Empty;

                    if (_timerGrep != null)
                    {
                        _timerGrep_Tick(null, null);
                    }

                    ManageControls(true);
                    lblCount.Text       = "0";
                    lblResultCount.Text = "0";
                    lblHitAt.Text       = String.Empty;

                    var progressHandler = new Progress <ProgressResult>(value =>
                    {
                        var percent = (int)(((double)progressRefresh.Value / (double)progressRefresh.Maximum) * 100);
                        progressRefresh.ProgressBar.Refresh();
                        progressRefresh.ProgressBar.CreateGraphics().DrawString(percent.ToString() + "%", new Font("Arial", (float)8.25, FontStyle.Regular), Brushes.Black, new PointF(progressRefresh.Width / 2 - 10, progressRefresh.Height / 2 - 7));
                        progressRefresh.Value  = value.ProgressValue;
                        tsCurrentSolution.Text = value.WorkingOn;
                    });
                    var progress = progressHandler as IProgress <ProgressResult>;

                    var sw = Stopwatch.StartNew();
                    var t  = Task.Run(() => { _repo.CrawlSource(progress); });

                    t.ContinueWith(r =>
                    {
                        lblCount.Text = _repo.GetSourceCount().ToString();
                        ManageControls(false);
                        progressRefresh.Value = 0;

                        sw.Stop();
                        _timerGrep = new Timer {
                            Interval = MILLISECOND_SEARCH_DELAY
                        };
                        _timerGrep.Tick += _timerGrep_Tick;
                    }, CancellationToken.None, TaskContinuationOptions.OnlyOnRanToCompletion, TaskScheduler.FromCurrentSynchronizationContext());

                    t.ContinueWith(r =>
                    {
                        sw.Stop();
                        ManageControls(false);
                    }, CancellationToken.None, TaskContinuationOptions.OnlyOnFaulted, TaskScheduler.FromCurrentSynchronizationContext());
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #14
0
 private void btnOk_Click(object sender, EventArgs e)
 {
     RepositoryUtils.UpdateOptionValue(_optionKey, chkShowConfirm.Checked ? "1" : "0");
     DialogResult = DialogResult.OK;
 }
예제 #15
0
        static void Main(string[] args)
        {
            if (args.Length > 0 && args[0].Equals("-crawldefault"))
            {
                var progressWindow = new RecrawlProgressCommandLine();
                progressWindow.SetProgress(0, "");

                var progressHandler = new Progress <ProgressResult>(value =>
                {
                    var percent   = (int)(((double)progressWindow.GetCurrentProgressValue() / (double)progressWindow.GetMaxProgressValue()) * 100);
                    var workingOn = String.Empty;

                    if (value.WorkingOn != null && value.WorkingOn.Contains(".sln"))
                    {
                        workingOn = Path.GetFileName(value.WorkingOn);
                    }
                    else
                    {
                        workingOn = value.WorkingOn;
                    }

                    progressWindow.SetProgress(value.ProgressValue, workingOn);

                    if (value.CloseForm.HasValue && value.CloseForm.Value)
                    {
                        progressWindow.KillSelf();
                    }
                });

                var progress = progressHandler as IProgress <ProgressResult>;
                var t        = Task.Run(() =>
                {
                    var defaultRootId = RepositoryUtils.GetDefaultRootId()[0];
                    if (defaultRootId != null)
                    {
                        progress.Report(new ProgressResult {
                            ProgressValue = 0, WorkingOn = "Caching..."
                        });

                        var repo = new RepositoryFile(defaultRootId, progress);

                        progress.Report(new ProgressResult {
                            ProgressValue = 0, WorkingOn = $"Refreshing default repository: {repo.Root.RootPath}..."
                        });
                        repo.CrawlSource(progress);

                        progress.Report(new ProgressResult {
                            ProgressValue = 0, CloseForm = true
                        });
                    }
                    else
                    {
                        //Console.WriteLine("No default source repository exists.");
                    }
                });

                progressWindow.ShowDialog();
            }
            else
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new Main());
            }
        }