string queryStatistics = null; // string to hold " of about " + hits.Count + " for " + lStatisticsInDocuments.Text + " in " + (dt.Second != 0 ? dt.Second + "s " : "") + (dt.Millisecond != 0 ? dt.Millisecond + "ms" : ""); private void bSearchInPicture_Click(object sender, EventArgs e) { bSearchInPicture.Enabled = false; GlobalData.MainStatusStrip.Items["tsslSearchingStatus"].Visible = true; StringDictionary queryTerms = new StringDictionary(); //Validate the parameters //Validate file name if (this.tbFileNameInPictures.Text.Trim() != "") { queryTerms.Add("name", this.tbFileNameInPictures.Text.ToLower()); queryStatistics = "File name: " + this.tbFileNameInPictures.Text; } //Validate file size if (this.tbSizeFromInPictures.Text.Trim() != "" && this.tbSizeToInPictures.Text.Trim() != "") { int minSize, maxSize; int.TryParse(this.tbSizeFromInPictures.Text, out minSize); int.TryParse(this.tbSizeToInPictures.Text, out maxSize); if (this.cobSizeMetricsInPictures.SelectedIndex == 1) // if KB is selected { minSize *= 1024; maxSize *= 1024; } else if (this.cobSizeMetricsInPictures.SelectedIndex == 2)// if MB is selected { minSize *= 1024 * 1024; maxSize *= 1024 * 1024; } else if (this.cobSizeMetricsInPictures.SelectedIndex == 3)// if GB is selected { minSize *= 1024 * 1024 * 1024; maxSize *= 1024 * 1024 * 1024; } queryTerms.Add("size", minSize + " " + maxSize); queryStatistics = "Size: " + minSize + " - " + maxSize; } //Validate file date if (cbDateInPictures.Checked) { string from; DateTime minDate = dtpFromInPictures.Value; from = minDate.Year + ""; if (minDate.Month < 10) { from += "0" + minDate.Month; } else { from += minDate.Month; } if (minDate.Day < 10) { from += "0" + minDate.Day; } else { from += minDate.Day; } string to; DateTime maxDate = dtpToInPictures.Value; to = maxDate.Year + ""; if (maxDate.Month < 10) { to += "0" + maxDate.Month; } else { to += maxDate.Month; } if (maxDate.Day < 10) { to += "0" + maxDate.Day; } else { to += maxDate.Day; } if (cobDate.SelectedIndex == 0) { queryTerms.Add("cdate", from + " " + to); queryStatistics = "Created Date: " + minDate.ToShortDateString() + " - " + maxDate.ToShortDateString(); } else if (cobDate.SelectedIndex == 1) { queryTerms.Add("mdate", from + " " + to); queryStatistics = "Modified Date: " + minDate.ToShortDateString() + " - " + maxDate.ToShortDateString(); } else if (cobDate.SelectedIndex == 2) { queryTerms.Add("adate", from + " " + to); queryStatistics = "Accessed Date: " + minDate.ToShortDateString() + " - " + maxDate.ToShortDateString(); } } //Validate width and height properties if (tbWidthInPictures.Text.Trim() != "" && tbHeightInPictures.Text.Trim() != "") { queryTerms.Add("all", "+width:" + tbWidthInPictures.Text + " +height:" + tbHeightInPictures.Text); queryStatistics = "Dimension: " + tbWidthInPictures.Text + " x " + tbHeightInPictures.Text; } //Validate horizontal properties if (tbHresInPictures.Text.Trim() != "") { queryTerms.Add("hres", tbHresInPictures.Text); queryStatistics = "HRes: " + tbHresInPictures.Text; } //Validate vertical properties if (tbVResInPictures.Text.Trim() != "") { queryTerms.Add("vres", tbVResInPictures.Text); queryStatistics = "VRes: " + tbVResInPictures.Text; } if (queryTerms.Count != 0) //if a query is given(prevent from searching for not entering anything in the fields) { //Start searching.......... long start = DateTime.Now.Ticks; EDSQueryEngine queryEngine = new EDSQueryEngine(); hits = queryEngine.GetDocResults(queryTerms); //filter image files from the results string ext; List <Hit> temp = new List <Hit>(); foreach (Hit hit in hits) { ext = hit.Get("type"); if (GlobalData.ImageFileTypes.Contains(ext + " ") && ext != "") { temp.Add(hit); } } hits = temp; long end = DateTime.Now.Ticks; DateTime dt = new DateTime(end - start); if (dt.Second == 0 && dt.Millisecond == 0) { queryStatistics = " of about " + hits.Count + " for " + GlobalData.AutoEllipsis(queryStatistics) + " in 0ms"; } else { queryStatistics = " of about " + hits.Count + " for " + GlobalData.AutoEllipsis(queryStatistics) + " in " + (dt.Second != 0 ? dt.Second + "s " : "") + (dt.Millisecond != 0 ? dt.Millisecond + "ms" : ""); } pageNum = 0; DisplayPage(); // displays the first page of the results } bSearchInPicture.Enabled = true; GlobalData.MainStatusStrip.Items["tsslSearchingStatus"].Visible = false; }
string queryStatistics = null; // string to hold " of about " + hits.Count + " for " + queryStatistics + " in " + (dt.Second != 0 ? dt.Second + "s " : "") + (dt.Millisecond != 0 ? dt.Millisecond + "ms" : ""); private void bSearchInAllFiles_Click(object sender, EventArgs e) { bSearchInAllFiles.Enabled = false; GlobalData.MainStatusStrip.Items["tsslSearchingStatus"].Visible = true; StringDictionary queryTerms = new StringDictionary(); //Validate the parameters if (tbQuery.Text.Trim() != "") { try { new QueryParser("name", new KeywordAnalyzer()).Parse(this.tbQuery.Text.Trim().ToLower()); queryTerms.Add("all", this.tbQuery.Text.Trim().ToLower()); queryStatistics = this.tbQuery.Text; } catch { MessageBox.Show("Given query " + tbQuery.Text + " cannot be processed. Check examples on EDS query syntax below \n\n1. 'attr:hidden' searches for file with hidden attribute\n2. 'name:abc.txt' searches for file name with abc.txt\n3. '+attr:hidden +name:abc.txt' searches for hidden files with file name abc.txt ", "Extendable Desktop Search"); } } else { //Validate file name if (this.tbFileNameInAllFiles.Text.Trim() != "") { queryTerms.Add("name", this.tbFileNameInAllFiles.Text.ToLower()); queryStatistics = "File name: " + this.tbFileNameInAllFiles.Text; } //Validate file size if (this.tbSizeFromInFiles.Text.Trim() != "" && this.tbSizeToInFiles.Text.Trim() != "") { int minSize, maxSize; int.TryParse(this.tbSizeFromInFiles.Text, out minSize); int.TryParse(this.tbSizeToInFiles.Text, out maxSize); if (this.cobSizeMetricsInFiles.SelectedIndex == 1) // if KB is selected { minSize *= 1024; maxSize *= 1024; } else if (this.cobSizeMetricsInFiles.SelectedIndex == 2)// if MB is selected { minSize *= 1024 * 1024; maxSize *= 1024 * 1024; } else if (this.cobSizeMetricsInFiles.SelectedIndex == 3)// if GB is selected { minSize *= 1024 * 1024 * 1024; maxSize *= 1024 * 1024 * 1024; } queryTerms.Add("size", minSize + " " + maxSize); queryStatistics = "Size: " + minSize + " - " + maxSize; } //Validate file date if (cbDateInAllFiles.Checked) { string from; DateTime minDate = dtpFromInFiles.Value; from = minDate.Year + ""; if (minDate.Month < 10) { from += "0" + minDate.Month; } else { from += minDate.Month; } if (minDate.Day < 10) { from += "0" + minDate.Day; } else { from += minDate.Day; } string to; DateTime maxDate = dtpToInAllFiles.Value; to = maxDate.Year + ""; if (maxDate.Month < 10) { to += "0" + maxDate.Month; } else { to += maxDate.Month; } if (maxDate.Day < 10) { to += "0" + maxDate.Day; } else { to += maxDate.Day; } if (cobDate.SelectedIndex == 0) { queryTerms.Add("cdate", from + " " + to); queryStatistics = "Created Date: " + minDate.ToShortDateString() + " - " + maxDate.ToShortDateString(); } else if (cobDate.SelectedIndex == 1) { queryTerms.Add("mdate", from + " " + to); queryStatistics = "Modified Date: " + minDate.ToShortDateString() + " - " + maxDate.ToShortDateString(); } else if (cobDate.SelectedIndex == 2) { queryTerms.Add("adate", from + " " + to); queryStatistics = "Accessed Date: " + minDate.ToShortDateString() + " - " + maxDate.ToShortDateString(); } } //validate attributes if (cbAttributes.Checked) { queryTerms.Add("attr", "*" + ((string)cobAttributes.SelectedItem).ToLower() + "*"); queryStatistics = "Attribute: " + ((string)cobAttributes.SelectedItem); } } if (queryTerms.Count != 0) //if a query is given(prevent from searching for not entering anything in the fields) { long start = DateTime.Now.Ticks; EDSQueryEngine queryEngine = new EDSQueryEngine(); hits = queryEngine.GetDocResults(queryTerms); long end = DateTime.Now.Ticks; DateTime dt = new DateTime(end - start); if (dt.Second == 0 && dt.Millisecond == 0) { queryStatistics = " of about " + hits.Count + " for " + GlobalData.AutoEllipsis(queryStatistics) + " in 0ms"; } else { queryStatistics = " of about " + hits.Count + " for " + GlobalData.AutoEllipsis(queryStatistics) + " in " + (dt.Second != 0 ? dt.Second + "s " : "") + (dt.Millisecond != 0 ? dt.Millisecond + "ms" : ""); } pageNum = 0; DisplayPage(); // displays the first page of the results } bSearchInAllFiles.Enabled = true; GlobalData.MainStatusStrip.Items["tsslSearchingStatus"].Visible = false; }
string queryStatistics = null; // string to hold " of about " + hits.Count + " for " + queryStatistics + " in " + (dt.Second != 0 ? dt.Second + "s " : "") + (dt.Millisecond != 0 ? dt.Millisecond + "ms" : ""); private void bSearchInDocuments_Click(object sender, EventArgs e) { bSearchInDocuments.Enabled = false; GlobalData.MainStatusStrip.Items["tsslSearchingStatus"].Visible = true; StringDictionary queryTerms = new StringDictionary(); //Validate the parameters //Validate file name if (this.tbFileNameInDocuments.Text.Trim() != "") { queryTerms.Add("name", this.tbFileNameInDocuments.Text.ToLower()); queryStatistics = "File name: " + this.tbFileNameInDocuments.Text; } //Validate file content if (this.tbFileContentInDocuments.Text.Trim() != "") { queryTerms.Add("content", this.tbFileContentInDocuments.Text.ToLower()); queryStatistics = "Content: " + this.tbFileContentInDocuments.Text; } //Validate file size if (this.tbSizeFromInDocuments.Text.Trim() != "" && this.tbSizeToInDocuments.Text.Trim() != "") { int minSize, maxSize; int.TryParse(this.tbSizeFromInDocuments.Text, out minSize); int.TryParse(this.tbSizeToInDocuments.Text, out maxSize); if (this.cobSizeMetricsInDocuments.SelectedIndex == 1) // if KB is selected { minSize *= 1024; maxSize *= 1024; } else if (this.cobSizeMetricsInDocuments.SelectedIndex == 2)// if MB is selected { minSize *= 1024 * 1024; maxSize *= 1024 * 1024; } else if (this.cobSizeMetricsInDocuments.SelectedIndex == 3)// if GB is selected { minSize *= 1024 * 1024 * 1024; maxSize *= 1024 * 1024 * 1024; } queryTerms.Add("size", minSize + " " + maxSize); queryStatistics = "Size: " + minSize + " - " + maxSize; } //Validate file date if (cbDateInDocuments.Checked) { string from; DateTime minDate = dtpFromInDocuments.Value; from = minDate.Year + ""; if (minDate.Month < 10) { from += "0" + minDate.Month; } else { from += minDate.Month; } if (minDate.Day < 10) { from += "0" + minDate.Day; } else { from += minDate.Day; } string to; DateTime maxDate = dtpToInDocuments.Value; to = maxDate.Year + ""; if (maxDate.Month < 10) { to += "0" + maxDate.Month; } else { to += maxDate.Month; } if (maxDate.Day < 10) { to += "0" + maxDate.Day; } else { to += maxDate.Day; } if (cobDate.SelectedIndex == 0) { queryTerms.Add("cdate", from + " " + to); queryStatistics = "Created Date: " + minDate.ToShortDateString() + " - " + maxDate.ToShortDateString(); } else if (cobDate.SelectedIndex == 1) { queryTerms.Add("mdate", from + " " + to); queryStatistics = "Modified Date: " + minDate.ToShortDateString() + " - " + maxDate.ToShortDateString(); } else if (cobDate.SelectedIndex == 2) { queryTerms.Add("adate", from + " " + to); queryStatistics = "Accessed Date: " + minDate.ToShortDateString() + " - " + maxDate.ToShortDateString(); } } //Validate file company name if (this.tbFileCompanyNameInDocuments.Text.Trim() != "") { queryTerms.Add("companyname", this.tbFileCompanyNameInDocuments.Text.ToLower()); queryStatistics = "Company name: " + tbFileCompanyNameInDocuments.Text; } //Validate file description if (this.tbDescriptionInDocuments.Text.Trim() != "") { queryTerms.Add("filedesc", this.tbDescriptionInDocuments.Text.ToLower()); queryStatistics = "Description: " + tbDescriptionInDocuments.Text; } //Validate file company name if (this.tbVersionInDocuments.Text.Trim() != "") { queryTerms.Add("filever", this.tbVersionInDocuments.Text.ToLower()); queryStatistics = "Version: " + tbVersionInDocuments.Text; } //sd.Add("comment", "*gu"); //sd.Add("companyname", "microsoft corporation"); //sd.Add("cdate", "20080325 20080330"); //sd.Add("size", "10000 20000"); //sd.Add("name", "kernel32.dll"); if (queryTerms.Count != 0) //if a query is given(prevent from searching for not entering anything in the fields) { long start = DateTime.Now.Ticks; EDSQueryEngine queryEngine = new EDSQueryEngine(); hits = queryEngine.GetDocResults(queryTerms); //filter music files from the results string ext; List <Hit> temp = new List <Hit>(); foreach (Hit hit in hits) { ext = hit.Get("type"); if (GlobalData.DocFileTypes.Contains(ext + " ") && ext != "") { temp.Add(hit); } } hits = temp; long end = DateTime.Now.Ticks; DateTime dt = new DateTime(end - start); if (dt.Second == 0 && dt.Millisecond == 0) { queryStatistics = " of about " + hits.Count + " for " + GlobalData.AutoEllipsis(queryStatistics) + " in 0ms"; } else { queryStatistics = " of about " + hits.Count + " for " + GlobalData.AutoEllipsis(queryStatistics) + " in " + (dt.Second != 0 ? dt.Second + "s " : "") + (dt.Millisecond != 0 ? dt.Millisecond + "ms" : ""); } pageNum = 0; DisplayPage(); // displays the first page of the results } bSearchInDocuments.Enabled = true; GlobalData.MainStatusStrip.Items["tsslSearchingStatus"].Visible = false; }
string queryStatistics = null; // string to hold " of about " + hits.Count + " for " + lStatisticsInDocuments.Text + " in " + (dt.Second != 0 ? dt.Second + "s " : "") + (dt.Millisecond != 0 ? dt.Millisecond + "ms" : ""); private void bSearchInEmails_Click(object sender, EventArgs e) { bSearchInEmails.Enabled = false; GlobalData.MainStatusStrip.Items["tsslSearchingStatus"].Visible = true; StringDictionary queryTerms = new StringDictionary(); //Validate the parameters //Validate subject if (this.tbSubjectInEmails.Text.Trim() != "") { queryTerms.Add("subject", this.tbSubjectInEmails.Text.ToLower()); queryStatistics = "Subject: " + this.tbSubjectInEmails.Text; } //Validate from field if (this.tbFromAddressInEmails.Text.Trim() != "") { queryTerms.Add("from", this.tbFromAddressInEmails.Text.ToLower()); queryStatistics = "From: " + this.tbFromAddressInEmails.Text; } //Validate to field if (this.tbToAddressInEmails.Text.Trim() != "") { queryTerms.Add("to", this.tbToAddressInEmails.Text.ToLower()); queryStatistics = "To: " + this.tbToAddressInEmails.Text; } //Validate body field if (this.tbBodyInEmails.Text.Trim() != "") { queryTerms.Add("body", this.tbBodyInEmails.Text.ToLower()); queryStatistics = "Body: " + this.tbBodyInEmails.Text; } //Validate file date if (cbDateInEmails.Checked) { string from; DateTime minDate = dtpFromInEmails.Value; from = minDate.Year + ""; if (minDate.Month < 10) { from += "0" + minDate.Month; } else { from += minDate.Month; } if (minDate.Day < 10) { from += "0" + minDate.Day; } else { from += minDate.Day; } string to; DateTime maxDate = dtpToInEmails.Value; to = maxDate.Year + ""; if (maxDate.Month < 10) { to += "0" + maxDate.Month; } else { to += maxDate.Month; } if (maxDate.Day < 10) { to += "0" + maxDate.Day; } else { to += maxDate.Day; } queryTerms.Add("date", from + " " + to); queryStatistics = "Date: " + minDate.ToShortDateString() + " - " + maxDate.ToShortDateString(); } if (queryTerms.Count != 0) //if a query is given(prevent from searching for not entering anything in the fields) { long start = DateTime.Now.Ticks; EDSQueryEngine queryEngine = new EDSQueryEngine(); hits = queryEngine.GetEmailResults(queryTerms); long end = DateTime.Now.Ticks; DateTime dt = new DateTime(end - start); if (dt.Second == 0 && dt.Millisecond == 0) { queryStatistics = " of about " + hits.Count + " for " + GlobalData.AutoEllipsis(queryStatistics) + " in 0ms"; } else { queryStatistics = " of about " + hits.Count + " for " + GlobalData.AutoEllipsis(queryStatistics) + " in " + (dt.Second != 0 ? dt.Second + "s " : "") + (dt.Millisecond != 0 ? dt.Millisecond + "ms" : ""); } pageNum = 0; DisplayPage(); // displays the first page of the results } bSearchInEmails.Enabled = true; GlobalData.MainStatusStrip.Items["tsslSearchingStatus"].Visible = false; }
private void bSearchInPicture_Click(object sender, EventArgs e) { bSearchInPicture.Enabled = false; GlobalData.MainStatusStrip.Items["tsslSearchingStatus"].Visible = true; StringDictionary queryTerms = new StringDictionary(); //Validate the parameters //Validate file name if (this.tbFileNameInPictures.Text.Trim() != "") { queryTerms.Add("name", this.tbFileNameInPictures.Text.ToLower()); queryStatistics = "File name: " + this.tbFileNameInPictures.Text; } //Validate file size if (this.tbSizeFromInPictures.Text.Trim() != "" && this.tbSizeToInPictures.Text.Trim() != "") { int minSize, maxSize; int.TryParse(this.tbSizeFromInPictures.Text, out minSize); int.TryParse(this.tbSizeToInPictures.Text, out maxSize); if (this.cobSizeMetricsInPictures.SelectedIndex == 1) // if KB is selected { minSize *= 1024; maxSize *= 1024; } else if (this.cobSizeMetricsInPictures.SelectedIndex == 2)// if MB is selected { minSize *= 1024 * 1024; maxSize *= 1024 * 1024; } else if (this.cobSizeMetricsInPictures.SelectedIndex == 3)// if GB is selected { minSize *= 1024 * 1024 * 1024; maxSize *= 1024 * 1024 * 1024; } queryTerms.Add("size", minSize + " " + maxSize); queryStatistics = "Size: " + minSize + " - " + maxSize; } //Validate file date if (cbDateInPictures.Checked) { string from; DateTime minDate = dtpFromInPictures.Value; from = minDate.Year + ""; if (minDate.Month < 10) from += "0" + minDate.Month; else from += minDate.Month; if (minDate.Day < 10) from += "0" + minDate.Day; else from += minDate.Day; string to; DateTime maxDate = dtpToInPictures.Value; to = maxDate.Year + ""; if (maxDate.Month < 10) to += "0" + maxDate.Month; else to += maxDate.Month; if (maxDate.Day < 10) to += "0" + maxDate.Day; else to += maxDate.Day; if (cobDate.SelectedIndex == 0) { queryTerms.Add("cdate", from + " " + to); queryStatistics = "Created Date: " + minDate.ToShortDateString() + " - " + maxDate.ToShortDateString(); } else if (cobDate.SelectedIndex == 1) { queryTerms.Add("mdate", from + " " + to); queryStatistics = "Modified Date: " + minDate.ToShortDateString() + " - " + maxDate.ToShortDateString(); } else if (cobDate.SelectedIndex == 2) { queryTerms.Add("adate", from + " " + to); queryStatistics = "Accessed Date: " + minDate.ToShortDateString() + " - " + maxDate.ToShortDateString(); } } //Validate width and height properties if (tbWidthInPictures.Text.Trim() != "" && tbHeightInPictures.Text.Trim() != "") { queryTerms.Add("all", "+width:" + tbWidthInPictures.Text + " +height:" + tbHeightInPictures.Text); queryStatistics = "Dimension: " + tbWidthInPictures.Text + " x " + tbHeightInPictures.Text; } //Validate horizontal properties if (tbHresInPictures.Text.Trim() != "") { queryTerms.Add("hres", tbHresInPictures.Text); queryStatistics = "HRes: " + tbHresInPictures.Text; } //Validate vertical properties if (tbVResInPictures.Text.Trim() != "") { queryTerms.Add("vres", tbVResInPictures.Text); queryStatistics = "VRes: " + tbVResInPictures.Text; } if (queryTerms.Count != 0) //if a query is given(prevent from searching for not entering anything in the fields) { //Start searching.......... long start = DateTime.Now.Ticks; EDSQueryEngine queryEngine = new EDSQueryEngine(); hits = queryEngine.GetDocResults(queryTerms); //filter image files from the results string ext; List<Hit> temp = new List<Hit>(); foreach (Hit hit in hits) { ext = hit.Get("type"); if (GlobalData.ImageFileTypes.Contains(ext + " ") && ext != "") temp.Add(hit); } hits = temp; long end = DateTime.Now.Ticks; DateTime dt = new DateTime(end - start); if (dt.Second == 0 && dt.Millisecond == 0) queryStatistics = " of about " + hits.Count + " for " + GlobalData.AutoEllipsis(queryStatistics) + " in 0ms"; else queryStatistics = " of about " + hits.Count + " for " + GlobalData.AutoEllipsis(queryStatistics) + " in " + (dt.Second != 0 ? dt.Second + "s " : "") + (dt.Millisecond != 0 ? dt.Millisecond + "ms" : ""); pageNum = 0; DisplayPage(); // displays the first page of the results } bSearchInPicture.Enabled = true; GlobalData.MainStatusStrip.Items["tsslSearchingStatus"].Visible = false; }
private void bSearchInAudio_Click(object sender, EventArgs e) { bSearchInAudio.Enabled = false; GlobalData.MainStatusStrip.Items["tsslSearchingStatus"].Visible = true; StringDictionary queryTerms = new StringDictionary(); //Validate the parameters //Validate file name if (this.tbFileNameInAudio.Text.Trim() != "") { queryTerms.Add("name", this.tbFileNameInAudio.Text.ToLower()); queryStatistics = "File name: " + this.tbFileNameInAudio.Text; } //Validate file size if (this.tbSizeFromInAudio.Text.Trim() != "" && this.tbSizeToInAudio.Text.Trim() != "") { int minSize, maxSize; int.TryParse(this.tbSizeFromInAudio.Text, out minSize); int.TryParse(this.tbSizeToInAudio.Text, out maxSize); if (this.cobSizeMetricsInAudio.SelectedIndex == 1) // if KB is selected { minSize *= 1024; maxSize *= 1024; } else if (this.cobSizeMetricsInAudio.SelectedIndex == 2)// if MB is selected { minSize *= 1024 * 1024; maxSize *= 1024 * 1024; } else if (this.cobSizeMetricsInAudio.SelectedIndex == 3)// if GB is selected { minSize *= 1024 * 1024 * 1024; maxSize *= 1024 * 1024 * 1024; } queryTerms.Add("size", minSize + " " + maxSize); queryStatistics = "Size: " + minSize + " - " + maxSize; } //Validate file date if (cbDateInAudio.Checked) { string from; DateTime minDate = dtpFromInAudio.Value; from = minDate.Year + ""; if (minDate.Month < 10) from += "0" + minDate.Month; else from += minDate.Month; if (minDate.Day < 10) from += "0" + minDate.Day; else from += minDate.Day; string to; DateTime maxDate = dtpToInAudio.Value; to = maxDate.Year + ""; if (maxDate.Month < 10) to += "0" + maxDate.Month; else to += maxDate.Month; if (maxDate.Day < 10) to += "0" + maxDate.Day; else to += maxDate.Day; if (cobDate.SelectedIndex == 0) { queryTerms.Add("cdate", from + " " + to); queryStatistics = "Created Date: " + minDate.ToShortDateString() + " - " + maxDate.ToShortDateString(); } else if (cobDate.SelectedIndex == 1) { queryTerms.Add("mdate", from + " " + to); queryStatistics = "Modified Date: " + minDate.ToShortDateString() + " - " + maxDate.ToShortDateString(); } else if (cobDate.SelectedIndex == 2) { queryTerms.Add("adate", from + " " + to); queryStatistics = "Accessed Date: " + minDate.ToShortDateString() + " - " + maxDate.ToShortDateString(); } } //Validate duration if (this.tbLengthFromInAudio.Text.Trim() != "" && this.tbLengthToInAudio.Text.Trim() != "") { string from = "", to = ""; if (this.cobLengthMetricsInAudio.SelectedIndex == 0) // if Sec is selected { from = tbLengthFromInAudio.Text; if (from.Length < 2) from = "0" + from; //from = from.PadLeft(2, '0'); from = "00:00:" + from; to = tbLengthToInAudio.Text; if (to.Length < 2) to = "0" + to; to = "00:00:" + to; } else if (this.cobLengthMetricsInAudio.SelectedIndex == 1)// if Min is selected { from = tbLengthFromInAudio.Text; if (from.Length < 2) from = "0" + from; from = "00:" + from + ":00"; to = tbLengthToInAudio.Text; if (to.Length < 2) to = "0" + to; to = "00:" + to + ":00"; } else if (this.cobLengthMetricsInAudio.SelectedIndex == 2)// if Hour is selected { from = tbLengthFromInAudio.Text; if (from.Length < 2) from = "0" + from; from = from + ":00:00"; to = tbLengthToInAudio.Text; if (to.Length < 2) to = "0" + to; to = to + ":00:00"; } queryTerms.Add("length", from + " " + to); queryStatistics = "Duration: " + from + " - " + to; } //Validate title if (this.tbTitleInAudio.Text.Trim() != "") { queryTerms.Add("title", this.tbTitleInAudio.Text.ToLower()); queryStatistics = "Title: " + this.tbTitleInAudio.Text; } //Validate album if (this.tbAlbumInAudio.Text.Trim() != "") { queryTerms.Add("album", this.tbAlbumInAudio.Text.ToLower()); queryStatistics = "Album: " + this.tbAlbumInAudio.Text; } //Validate artist if (this.tbArtistInAudio.Text.Trim() != "") { queryTerms.Add("artist", this.tbArtistInAudio.Text.ToLower()); queryStatistics = "artist: " + this.tbArtistInAudio.Text; } //Validate comment if (this.tbCommentInAudio.Text.Trim() != "") { queryTerms.Add("comment", this.tbCommentInAudio.Text.ToLower()); queryStatistics = "Comment: " + this.tbCommentInAudio.Text; } //Validate genre if (this.tbGenreInAudio.Text.Trim() != "") { queryTerms.Add("genre", this.tbGenreInAudio.Text.ToLower()); queryStatistics = "Genre: " + this.tbGenreInAudio.Text; } //Validate track if (this.tbTrackInAudio.Text.Trim() != "") { queryTerms.Add("track", this.tbTrackInAudio.Text); queryStatistics = "Track: " + this.tbGenreInAudio.Text; } //Validate year if (this.tbYearInAudio.Text.Trim() != "") { queryTerms.Add("year", this.tbYearInAudio.Text); queryStatistics = "Year: " + this.tbYearInAudio.Text; } if (queryTerms.Count != 0) //if a query is given(prevent from searching for not entering anything in the fields) { //Start searching.......... long start = DateTime.Now.Ticks; EDSQueryEngine queryEngine = new EDSQueryEngine(); hits = queryEngine.GetDocResults(queryTerms); //filter music files from the results string ext; List<Hit> temp = new List<Hit>(); foreach (Hit hit in hits) { ext = hit.Get("type"); if (GlobalData.AudioFileTypes.Contains(ext + " ") && ext != "") temp.Add(hit); } hits = temp; long end = DateTime.Now.Ticks; DateTime dt = new DateTime(end - start); if (dt.Second == 0 && dt.Millisecond == 0) queryStatistics = " of about " + hits.Count + " for " + GlobalData.AutoEllipsis(queryStatistics) + " in 0ms"; else queryStatistics = " of about " + hits.Count + " for " + GlobalData.AutoEllipsis(queryStatistics) + " in " + (dt.Second != 0 ? dt.Second + "s " : "") + (dt.Millisecond != 0 ? dt.Millisecond + "ms" : ""); pageNum = 0; DisplayPage(); // displays the first page of the results } bSearchInAudio.Enabled = true; GlobalData.MainStatusStrip.Items["tsslSearchingStatus"].Visible = false; }
private void bSearchInEmails_Click(object sender, EventArgs e) { bSearchInEmails.Enabled = false; GlobalData.MainStatusStrip.Items["tsslSearchingStatus"].Visible = true; StringDictionary queryTerms = new StringDictionary(); //Validate the parameters //Validate subject if (this.tbSubjectInEmails.Text.Trim() != "") { queryTerms.Add("subject", this.tbSubjectInEmails.Text.ToLower()); queryStatistics = "Subject: " + this.tbSubjectInEmails.Text; } //Validate from field if (this.tbFromAddressInEmails.Text.Trim() != "") { queryTerms.Add("from", this.tbFromAddressInEmails.Text.ToLower()); queryStatistics = "From: " + this.tbFromAddressInEmails.Text; } //Validate to field if (this.tbToAddressInEmails.Text.Trim() != "") { queryTerms.Add("to", this.tbToAddressInEmails.Text.ToLower()); queryStatistics = "To: " + this.tbToAddressInEmails.Text; } //Validate body field if (this.tbBodyInEmails.Text.Trim() != "") { queryTerms.Add("body", this.tbBodyInEmails.Text.ToLower()); queryStatistics = "Body: " + this.tbBodyInEmails.Text; } //Validate file date if (cbDateInEmails.Checked) { string from; DateTime minDate = dtpFromInEmails.Value; from = minDate.Year + ""; if (minDate.Month < 10) from += "0" + minDate.Month; else from += minDate.Month; if (minDate.Day < 10) from += "0" + minDate.Day; else from += minDate.Day; string to; DateTime maxDate = dtpToInEmails.Value; to = maxDate.Year + ""; if (maxDate.Month < 10) to += "0" + maxDate.Month; else to += maxDate.Month; if (maxDate.Day < 10) to += "0" + maxDate.Day; else to += maxDate.Day; queryTerms.Add("date", from + " " + to); queryStatistics = "Date: " + minDate.ToShortDateString() + " - " + maxDate.ToShortDateString(); } if (queryTerms.Count != 0) //if a query is given(prevent from searching for not entering anything in the fields) { long start = DateTime.Now.Ticks; EDSQueryEngine queryEngine = new EDSQueryEngine(); hits = queryEngine.GetEmailResults(queryTerms); long end = DateTime.Now.Ticks; DateTime dt = new DateTime(end - start); if (dt.Second == 0 && dt.Millisecond == 0) queryStatistics = " of about " + hits.Count + " for " + GlobalData.AutoEllipsis(queryStatistics) + " in 0ms"; else queryStatistics = " of about " + hits.Count + " for " + GlobalData.AutoEllipsis(queryStatistics) + " in " + (dt.Second != 0 ? dt.Second + "s " : "") + (dt.Millisecond != 0 ? dt.Millisecond + "ms" : ""); pageNum = 0; DisplayPage(); // displays the first page of the results } bSearchInEmails.Enabled = true; GlobalData.MainStatusStrip.Items["tsslSearchingStatus"].Visible = false; }
private void bSearchInDocuments_Click(object sender, EventArgs e) { bSearchInDocuments.Enabled = false; GlobalData.MainStatusStrip.Items["tsslSearchingStatus"].Visible = true; StringDictionary queryTerms = new StringDictionary(); //Validate the parameters //Validate file name if (this.tbFileNameInDocuments.Text.Trim() != "") { queryTerms.Add("name", this.tbFileNameInDocuments.Text.ToLower()); queryStatistics = "File name: " + this.tbFileNameInDocuments.Text; } //Validate file content if (this.tbFileContentInDocuments.Text.Trim() != "") { queryTerms.Add("content", this.tbFileContentInDocuments.Text.ToLower()); queryStatistics = "Content: " + this.tbFileContentInDocuments.Text; } //Validate file size if (this.tbSizeFromInDocuments.Text.Trim() != "" && this.tbSizeToInDocuments.Text.Trim() != "") { int minSize, maxSize; int.TryParse(this.tbSizeFromInDocuments.Text, out minSize); int.TryParse(this.tbSizeToInDocuments.Text, out maxSize); if (this.cobSizeMetricsInDocuments.SelectedIndex == 1) // if KB is selected { minSize *= 1024; maxSize *= 1024; } else if (this.cobSizeMetricsInDocuments.SelectedIndex == 2)// if MB is selected { minSize *= 1024 * 1024; maxSize *= 1024 * 1024; } else if (this.cobSizeMetricsInDocuments.SelectedIndex == 3)// if GB is selected { minSize *= 1024 * 1024 * 1024; maxSize *= 1024 * 1024 * 1024; } queryTerms.Add("size", minSize + " " + maxSize); queryStatistics = "Size: " + minSize + " - " + maxSize; } //Validate file date if (cbDateInDocuments.Checked) { string from; DateTime minDate = dtpFromInDocuments.Value; from = minDate.Year + ""; if (minDate.Month < 10) from += "0" + minDate.Month; else from += minDate.Month; if (minDate.Day < 10) from += "0" + minDate.Day; else from += minDate.Day; string to; DateTime maxDate = dtpToInDocuments.Value; to = maxDate.Year + ""; if (maxDate.Month < 10) to += "0" + maxDate.Month; else to += maxDate.Month; if (maxDate.Day < 10) to += "0" + maxDate.Day; else to += maxDate.Day; if (cobDate.SelectedIndex == 0) { queryTerms.Add("cdate", from + " " + to); queryStatistics = "Created Date: " + minDate.ToShortDateString() + " - " + maxDate.ToShortDateString(); } else if (cobDate.SelectedIndex == 1) { queryTerms.Add("mdate", from + " " + to); queryStatistics = "Modified Date: " + minDate.ToShortDateString() + " - " + maxDate.ToShortDateString(); } else if (cobDate.SelectedIndex == 2) { queryTerms.Add("adate", from + " " + to); queryStatistics = "Accessed Date: " + minDate.ToShortDateString() + " - " + maxDate.ToShortDateString(); } } //Validate file company name if (this.tbFileCompanyNameInDocuments.Text.Trim() != "") { queryTerms.Add("companyname", this.tbFileCompanyNameInDocuments.Text.ToLower()); queryStatistics = "Company name: " + tbFileCompanyNameInDocuments.Text; } //Validate file description if (this.tbDescriptionInDocuments.Text.Trim() != "") { queryTerms.Add("filedesc", this.tbDescriptionInDocuments.Text.ToLower()); queryStatistics = "Description: " + tbDescriptionInDocuments.Text; } //Validate file company name if (this.tbVersionInDocuments.Text.Trim() != "") { queryTerms.Add("filever", this.tbVersionInDocuments.Text.ToLower()); queryStatistics = "Version: " + tbVersionInDocuments.Text; } //sd.Add("comment", "*gu"); //sd.Add("companyname", "microsoft corporation"); //sd.Add("cdate", "20080325 20080330"); //sd.Add("size", "10000 20000"); //sd.Add("name", "kernel32.dll"); if (queryTerms.Count != 0) //if a query is given(prevent from searching for not entering anything in the fields) { long start = DateTime.Now.Ticks; EDSQueryEngine queryEngine = new EDSQueryEngine(); hits = queryEngine.GetDocResults(queryTerms); //filter music files from the results string ext; List<Hit> temp = new List<Hit>(); foreach (Hit hit in hits) { ext = hit.Get("type"); if (GlobalData.DocFileTypes.Contains(ext + " ") && ext != "") temp.Add(hit); } hits = temp; long end = DateTime.Now.Ticks; DateTime dt = new DateTime(end - start); if (dt.Second == 0 && dt.Millisecond == 0) queryStatistics = " of about " + hits.Count + " for " + GlobalData.AutoEllipsis(queryStatistics) + " in 0ms"; else queryStatistics = " of about " + hits.Count + " for " + GlobalData.AutoEllipsis(queryStatistics) + " in " + (dt.Second != 0 ? dt.Second + "s " : "") + (dt.Millisecond != 0 ? dt.Millisecond + "ms" : ""); pageNum = 0; DisplayPage(); // displays the first page of the results } bSearchInDocuments.Enabled = true; GlobalData.MainStatusStrip.Items["tsslSearchingStatus"].Visible = false; }
string queryStatistics = null; // string to hold " of about " + hits.Count + " for " + lStatisticsInDocuments.Text + " in " + (dt.Second != 0 ? dt.Second + "s " : "") + (dt.Millisecond != 0 ? dt.Millisecond + "ms" : ""); private void bSearchInAudio_Click(object sender, EventArgs e) { bSearchInAudio.Enabled = false; GlobalData.MainStatusStrip.Items["tsslSearchingStatus"].Visible = true; StringDictionary queryTerms = new StringDictionary(); //Validate the parameters //Validate file name if (this.tbFileNameInAudio.Text.Trim() != "") { queryTerms.Add("name", this.tbFileNameInAudio.Text.ToLower()); queryStatistics = "File name: " + this.tbFileNameInAudio.Text; } //Validate file size if (this.tbSizeFromInAudio.Text.Trim() != "" && this.tbSizeToInAudio.Text.Trim() != "") { int minSize, maxSize; int.TryParse(this.tbSizeFromInAudio.Text, out minSize); int.TryParse(this.tbSizeToInAudio.Text, out maxSize); if (this.cobSizeMetricsInAudio.SelectedIndex == 1) // if KB is selected { minSize *= 1024; maxSize *= 1024; } else if (this.cobSizeMetricsInAudio.SelectedIndex == 2)// if MB is selected { minSize *= 1024 * 1024; maxSize *= 1024 * 1024; } else if (this.cobSizeMetricsInAudio.SelectedIndex == 3)// if GB is selected { minSize *= 1024 * 1024 * 1024; maxSize *= 1024 * 1024 * 1024; } queryTerms.Add("size", minSize + " " + maxSize); queryStatistics = "Size: " + minSize + " - " + maxSize; } //Validate file date if (cbDateInAudio.Checked) { string from; DateTime minDate = dtpFromInAudio.Value; from = minDate.Year + ""; if (minDate.Month < 10) { from += "0" + minDate.Month; } else { from += minDate.Month; } if (minDate.Day < 10) { from += "0" + minDate.Day; } else { from += minDate.Day; } string to; DateTime maxDate = dtpToInAudio.Value; to = maxDate.Year + ""; if (maxDate.Month < 10) { to += "0" + maxDate.Month; } else { to += maxDate.Month; } if (maxDate.Day < 10) { to += "0" + maxDate.Day; } else { to += maxDate.Day; } if (cobDate.SelectedIndex == 0) { queryTerms.Add("cdate", from + " " + to); queryStatistics = "Created Date: " + minDate.ToShortDateString() + " - " + maxDate.ToShortDateString(); } else if (cobDate.SelectedIndex == 1) { queryTerms.Add("mdate", from + " " + to); queryStatistics = "Modified Date: " + minDate.ToShortDateString() + " - " + maxDate.ToShortDateString(); } else if (cobDate.SelectedIndex == 2) { queryTerms.Add("adate", from + " " + to); queryStatistics = "Accessed Date: " + minDate.ToShortDateString() + " - " + maxDate.ToShortDateString(); } } //Validate duration if (this.tbLengthFromInAudio.Text.Trim() != "" && this.tbLengthToInAudio.Text.Trim() != "") { string from = "", to = ""; if (this.cobLengthMetricsInAudio.SelectedIndex == 0) // if Sec is selected { from = tbLengthFromInAudio.Text; if (from.Length < 2) { from = "0" + from; //from = from.PadLeft(2, '0'); } from = "00:00:" + from; to = tbLengthToInAudio.Text; if (to.Length < 2) { to = "0" + to; } to = "00:00:" + to; } else if (this.cobLengthMetricsInAudio.SelectedIndex == 1)// if Min is selected { from = tbLengthFromInAudio.Text; if (from.Length < 2) { from = "0" + from; } from = "00:" + from + ":00"; to = tbLengthToInAudio.Text; if (to.Length < 2) { to = "0" + to; } to = "00:" + to + ":00"; } else if (this.cobLengthMetricsInAudio.SelectedIndex == 2)// if Hour is selected { from = tbLengthFromInAudio.Text; if (from.Length < 2) { from = "0" + from; } from = from + ":00:00"; to = tbLengthToInAudio.Text; if (to.Length < 2) { to = "0" + to; } to = to + ":00:00"; } queryTerms.Add("length", from + " " + to); queryStatistics = "Duration: " + from + " - " + to; } //Validate title if (this.tbTitleInAudio.Text.Trim() != "") { queryTerms.Add("title", this.tbTitleInAudio.Text.ToLower()); queryStatistics = "Title: " + this.tbTitleInAudio.Text; } //Validate album if (this.tbAlbumInAudio.Text.Trim() != "") { queryTerms.Add("album", this.tbAlbumInAudio.Text.ToLower()); queryStatistics = "Album: " + this.tbAlbumInAudio.Text; } //Validate artist if (this.tbArtistInAudio.Text.Trim() != "") { queryTerms.Add("artist", this.tbArtistInAudio.Text.ToLower()); queryStatistics = "artist: " + this.tbArtistInAudio.Text; } //Validate comment if (this.tbCommentInAudio.Text.Trim() != "") { queryTerms.Add("comment", this.tbCommentInAudio.Text.ToLower()); queryStatistics = "Comment: " + this.tbCommentInAudio.Text; } //Validate genre if (this.tbGenreInAudio.Text.Trim() != "") { queryTerms.Add("genre", this.tbGenreInAudio.Text.ToLower()); queryStatistics = "Genre: " + this.tbGenreInAudio.Text; } //Validate track if (this.tbTrackInAudio.Text.Trim() != "") { queryTerms.Add("track", this.tbTrackInAudio.Text); queryStatistics = "Track: " + this.tbGenreInAudio.Text; } //Validate year if (this.tbYearInAudio.Text.Trim() != "") { queryTerms.Add("year", this.tbYearInAudio.Text); queryStatistics = "Year: " + this.tbYearInAudio.Text; } if (queryTerms.Count != 0) //if a query is given(prevent from searching for not entering anything in the fields) { //Start searching.......... long start = DateTime.Now.Ticks; EDSQueryEngine queryEngine = new EDSQueryEngine(); hits = queryEngine.GetDocResults(queryTerms); //filter music files from the results string ext; List <Hit> temp = new List <Hit>(); foreach (Hit hit in hits) { ext = hit.Get("type"); if (GlobalData.AudioFileTypes.Contains(ext + " ") && ext != "") { temp.Add(hit); } } hits = temp; long end = DateTime.Now.Ticks; DateTime dt = new DateTime(end - start); if (dt.Second == 0 && dt.Millisecond == 0) { queryStatistics = " of about " + hits.Count + " for " + GlobalData.AutoEllipsis(queryStatistics) + " in 0ms"; } else { queryStatistics = " of about " + hits.Count + " for " + GlobalData.AutoEllipsis(queryStatistics) + " in " + (dt.Second != 0 ? dt.Second + "s " : "") + (dt.Millisecond != 0 ? dt.Millisecond + "ms" : ""); } pageNum = 0; DisplayPage(); // displays the first page of the results } bSearchInAudio.Enabled = true; GlobalData.MainStatusStrip.Items["tsslSearchingStatus"].Visible = false; }
private void bSearchInAllFiles_Click(object sender, EventArgs e) { bSearchInAllFiles.Enabled = false; GlobalData.MainStatusStrip.Items["tsslSearchingStatus"].Visible = true; StringDictionary queryTerms = new StringDictionary(); //Validate the parameters if (tbQuery.Text.Trim() != "") { try { new QueryParser("name", new KeywordAnalyzer()).Parse(this.tbQuery.Text.Trim().ToLower()); queryTerms.Add("all", this.tbQuery.Text.Trim().ToLower()); queryStatistics = this.tbQuery.Text; } catch { MessageBox.Show("Given query " + tbQuery.Text + " cannot be processed. Check examples on EDS query syntax below \n\n1. 'attr:hidden' searches for file with hidden attribute\n2. 'name:abc.txt' searches for file name with abc.txt\n3. '+attr:hidden +name:abc.txt' searches for hidden files with file name abc.txt ", "Extendable Desktop Search"); } } else { //Validate file name if (this.tbFileNameInAllFiles.Text.Trim() != "") { queryTerms.Add("name", this.tbFileNameInAllFiles.Text.ToLower()); queryStatistics = "File name: " + this.tbFileNameInAllFiles.Text; } //Validate file size if (this.tbSizeFromInFiles.Text.Trim() != "" && this.tbSizeToInFiles.Text.Trim() != "") { int minSize, maxSize; int.TryParse(this.tbSizeFromInFiles.Text, out minSize); int.TryParse(this.tbSizeToInFiles.Text, out maxSize); if (this.cobSizeMetricsInFiles.SelectedIndex == 1) // if KB is selected { minSize *= 1024; maxSize *= 1024; } else if (this.cobSizeMetricsInFiles.SelectedIndex == 2)// if MB is selected { minSize *= 1024 * 1024; maxSize *= 1024 * 1024; } else if (this.cobSizeMetricsInFiles.SelectedIndex == 3)// if GB is selected { minSize *= 1024 * 1024 * 1024; maxSize *= 1024 * 1024 * 1024; } queryTerms.Add("size", minSize + " " + maxSize); queryStatistics = "Size: " + minSize + " - " + maxSize; } //Validate file date if (cbDateInAllFiles.Checked) { string from; DateTime minDate = dtpFromInFiles.Value; from = minDate.Year + ""; if (minDate.Month < 10) from += "0" + minDate.Month; else from += minDate.Month; if (minDate.Day < 10) from += "0" + minDate.Day; else from += minDate.Day; string to; DateTime maxDate = dtpToInAllFiles.Value; to = maxDate.Year + ""; if (maxDate.Month < 10) to += "0" + maxDate.Month; else to += maxDate.Month; if (maxDate.Day < 10) to += "0" + maxDate.Day; else to += maxDate.Day; if (cobDate.SelectedIndex == 0) { queryTerms.Add("cdate", from + " " + to); queryStatistics = "Created Date: " + minDate.ToShortDateString() + " - " + maxDate.ToShortDateString(); } else if (cobDate.SelectedIndex == 1) { queryTerms.Add("mdate", from + " " + to); queryStatistics = "Modified Date: " + minDate.ToShortDateString() + " - " + maxDate.ToShortDateString(); } else if (cobDate.SelectedIndex == 2) { queryTerms.Add("adate", from + " " + to); queryStatistics = "Accessed Date: " + minDate.ToShortDateString() + " - " + maxDate.ToShortDateString(); } } //validate attributes if (cbAttributes.Checked) { queryTerms.Add("attr", "*" + ((string)cobAttributes.SelectedItem).ToLower() + "*"); queryStatistics = "Attribute: " + ((string)cobAttributes.SelectedItem); } } if (queryTerms.Count != 0) //if a query is given(prevent from searching for not entering anything in the fields) { long start = DateTime.Now.Ticks; EDSQueryEngine queryEngine = new EDSQueryEngine(); hits = queryEngine.GetDocResults(queryTerms); long end = DateTime.Now.Ticks; DateTime dt = new DateTime(end - start); if (dt.Second == 0 && dt.Millisecond == 0) queryStatistics = " of about " + hits.Count + " for " + GlobalData.AutoEllipsis(queryStatistics) + " in 0ms"; else queryStatistics = " of about " + hits.Count + " for " + GlobalData.AutoEllipsis(queryStatistics) + " in " + (dt.Second != 0 ? dt.Second + "s " : "") + (dt.Millisecond != 0 ? dt.Millisecond + "ms" : ""); pageNum = 0; DisplayPage(); // displays the first page of the results } bSearchInAllFiles.Enabled = true; GlobalData.MainStatusStrip.Items["tsslSearchingStatus"].Visible = false; }