Exemple #1
0
        private void searchBtnRegularClick(object sender, EventArgs e) // When clicking on search button for user free-typing
        {
            limit = 0;                                                 // Set starting result index

            if (MainSearchText.Text == "")                             // Check if the textbox is empty
            {
                MessageBox.Show("Enter something!!", "Error!!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                List <Dictionary <string, string> > tempListDict = new List <Dictionary <string, string> >();                                                       // Create temporary list of dictionaries
                DateTime start = System.DateTime.Now;                                                                                                               // Searching time starts
                tempListDict = IndexBuildNew.Search_Click(MainSearchText.Text, asIsCheckBox.Checked, QECheckbox.Checked, advancedCheck.Checked, out finalQueryTxt); // Search user input texts
                DateTime end = System.DateTime.Now;                                                                                                                 // Searching time starts

                if (tempListDict.Count != 0)
                {
                    AddLog("The time for searching text was " + (end - start).Milliseconds / 1000.0 + " seconds");

                    double searchingTextTime = (end - start).Milliseconds / 1000.0;
                    //  AddLog($"The time for searching text was ({searchingTextTime}) seconds");

                    finalResultList = tempListDict;   // Assign temporary list to global variable as current 10 results
                    queryCount++;                     // Count number of query search
                    ViewData(limit, finalResultList); // View data on listview



                    if (limit + 20 - finalResultList.Count >= 10) // If no next 10 results
                    {
                        NextBtn.Enabled = false;                  // Disable next button
                    }
                    else
                    {
                        NextBtn.Enabled = true;                 // Enable next button
                    }

                    PreviousBtn.Enabled  = false;                                                                                            // Disable previous button
                    SaveResult.Enabled   = true;                                                                                             // Enable save result button
                    saveLogbtn.Enabled   = true;                                                                                             // Save Log Button on
                    FinalQueryBox.Text   = finalQueryTxt;                                                                                    // Display final query text
                    resultLab.Text       = "Result numbers:";                                                                                // Display result number label
                    resultNumLab.Text    = finalResultList.Count.ToString() + ", Time: " + (end - start).Milliseconds / 1000.0 + " seconds"; // Display result number & time
                    initailPagination    = 1;
                    totalpage            = Convert.ToInt32(Math.Ceiling((double)finalResultList.Count / 10));
                    PaginationLabel.Text = String.Format("{0}/{1}", initailPagination, totalpage);
                }
                else
                {
                    MessageBox.Show("No results were found, please try again!", "Error!!", MessageBoxButtons.OK, MessageBoxIcon.Error);  // Display error
                    AddLog($"No results were found, please try again!");
                }
            }
        }
Exemple #2
0
        // Whe clicking on search button for Cran Needs

        private void SearchBtnCranclick(object sender, EventArgs e)
        {
            limit = 0;                                                                                                                                                       // Set starting result index

            DateTime start = System.DateTime.Now;                                                                                                                            // Searching time starts

            finalResultList = IndexBuildNew.Search_Click(cranNeeds[comboBox1.SelectedItem.ToString()], false, QECheckbox.Checked, advancedCheck.Checked, out finalQueryTxt); // Search Cran needs texts
            DateTime end = System.DateTime.Now;                                                                                                                              // Searching time starts

            AddLog("The time for searching text was " + (end - start).Milliseconds / 1000.0 + " seconds");

            ViewData(limit, finalResultList);    // View data on listview
            IndexBuildNew.Create_BaseLine_Results(cranNeeds);



            if (limit + 20 - finalResultList.Count >= 10) // If no next 10 results
            {
                NextBtn.Enabled = false;                  // Disable next button
            }
            else
            {
                NextBtn.Enabled = true;                                                                                             // Enable next button
            }
            PreviousBtn.Enabled = false;                                                                                            // Disable previous button
            SaveResult.Enabled  = true;                                                                                             // Enable save result button
            resultLab.Text      = "Result numbers:";                                                                                // Display result number label
            FinalQueryBox.Text  = cranNeeds[comboBox1.SelectedItem.ToString()];                                                     //Print Query
            resultNumLab.Text   = finalResultList.Count.ToString() + ", Time: " + (end - start).Milliseconds / 1000.0 + " seconds"; // Display result number


            //Pagination code
            initailPagination    = 1;                                                                 //For
            totalpage            = Convert.ToInt32(Math.Ceiling((double)finalResultList.Count / 10)); //For each Page Count
            PaginationLabel.Text = String.Format("{0}/{1}", initailPagination, totalpage);
        }