Ejemplo n.º 1
0
        private void getTheFiles()
        {
            string        OutputDir = "";
            List <string> Files     = new List <string>();

            // shows wait cursor while getting the files info
            System.Windows.Forms.Cursor currentCurser = this.Cursor;
            this.Cursor = System.Windows.Forms.Cursors.WaitCursor;

            // prepare parameters for the query
            if (rbNoCriteria.Checked)
            {
                // set query criteria to include everything
                de.UserSelection     = DocExtractor.FilterUser.AllUsers; // Users
                de.DocSize           = 0;                                // Size
                de.DocDateSelection  = DocExtractor.FilterDate.AllDates; // Date
                de.NameTextSelection = DocExtractor.FilterText.AnyText;
                de.TextinName        = "";

                // Run the query
                Files = de._getAllDocsInSiteCollection();
            }
            else if (rbSetCriteria.Checked)
            {
                // set query criteria based on user selection
                CheckUserSelection();      // Users
                if (!CheckTypeSelection()) // Type
                {
                    return;
                }
                if (!CheckSizeSelection())// Size
                {
                    return;
                }
                if (!CheckDateSelection())// Date
                {
                    return;
                }
                CheckTextSelection();// Text

                // Run the query and get file urls
                if ((string)cbSites.SelectedItem == "All Sites")
                {
                    Files = de._getSpecificDocsInSiteCollection();
                }
                else if ((string)cbSites.SelectedItem != "All Sites")
                {
                    Files = de._getSpecificDocsInSingleSite((string)cbSites.SelectedItem);// put site name here
                }
            }

            this.Cursor = currentCurser;

            // Prepare the files downloading
            int FileCount = Files.Count;

            OutputDir = tbOutDir.Text;

            if (FileCount == 0)
            {
                MessageBox.Show("No files were found. Try changing the criteria.", "No Results Found");
            }

            // Proceed only when there are files, the user wants to proceed, and when dir is created/overwrited
            else if ((FileCount > 0) &&
                     MessageBox.Show(FileCount.ToString() + " files found. Do you want to proceed with downloading?", "Results Found", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                FileDownloadForm = new DownloaderForm(de.SiteUrl, Files, OutputDir, DownloadType);
                FileDownloadForm.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
                FileDownloadForm.Show();// show the downloader form and begin downloading files
            }
            Files = null;
        }