public static List<SearchClass> Users(string userId, string email, string lastFourdigits) { SearchClass Alex = new SearchClass(); Alex.userId = "1234"; Alex.email = "*****@*****.**"; Alex.lastFourdigits = "1885"; SearchClass Emilio = new SearchClass(); Emilio.userId = "0928"; Emilio.email = "*****@*****.**"; Emilio.lastFourdigits = "0706"; SearchClass Ulysses = new SearchClass(); Ulysses.userId = "0914"; Ulysses.email = "*****@*****.**"; Ulysses.lastFourdigits = "01zx"; var list = new List<SearchClass>(); list.Add(Alex); list.Add(Emilio); list.Add(Ulysses); IEnumerable<SearchClass> result = list; if(!string.IsNullOrEmpty(userId)) result = result.Where(u => u.userId == userId); if(!string.IsNullOrEmpty(email)) result = result.Where(u => u.email == email); if(!string.IsNullOrEmpty(lastFourdigits)) result = result.Where(u => u.lastFourdigits == lastFourdigits); return result.ToList(); }
public void AddMessageTest() { IPagesStorageProviderV30 pagesStorageProvider = mocks.DynamicMock <IPagesStorageProviderV30>(); mocks.ReplayAll(); Host.Instance = new Host(); Collectors.IndexDirectoryProvider = new DummyIndexDirectoryProvider(); ProviderLoader.SetUp <IIndexDirectoryProviderV30>(typeof(DummyIndexDirectoryProvider), ""); string messageSubject = "This is the subject of the message"; string messageBody = "This is the body of the message"; DateTime dt = DateTime.Now; PageContent page = new PageContent(new PageInfo("pagefullname", pagesStorageProvider, dt), "title", "user-test", dt, "", "content", new string[0], ""); Message message = new Message(1, "user-test", messageSubject, dt, messageBody); Assert.IsTrue(SearchClass.IndexMessage(message, page)); List <SearchResult> results = SearchClass.Search(new SearchField[] { SearchField.Content }, "message", SearchOptions.AtLeastOneWord); Assert.AreEqual(1, results.Count, "Wrong result length"); Assert.AreEqual(DocumentType.Message, results[0].DocumentType, "Wrong document type"); MessageDocument documentMessage = results[0].Document as MessageDocument; Assert.AreEqual("This is the subject of the message", documentMessage.Subject, "Wrong title"); Assert.AreEqual("This is the body of the <b class=\"searchkeyword\">message</b>", documentMessage.HighlightedBody, "Wrong content"); }
public void AddMessageTest() { IPagesStorageProviderV60 pagesStorageProvider = mocks.DynamicMock <IPagesStorageProviderV60>(); Expect.Call(pagesStorageProvider.CurrentWiki).Return("wiki1").Repeat.Any(); mocks.ReplayAll(); Collectors.InitCollectors(); Collectors.AddProvider(typeof(FSIndexDirectoryProvider), System.Reflection.Assembly.GetAssembly(typeof(FSIndexDirectoryProvider)), "", typeof(IIndexDirectoryProviderV60)); Host.Instance = new Host(); Host.Instance.OverridePublicDirectory(testDir); ProviderLoader.SetUp <IIndexDirectoryProviderV60>(typeof(FSIndexDirectoryProvider), ""); string messageSubject = "This is the subject of the message"; string messageBody = "This is the body of the message"; DateTime dt = DateTime.Now; PageContent page = new PageContent("pagefullname", pagesStorageProvider, dt, "title", "user-test", dt, "", "content", new string[0], ""); Message message = new Message(1, "user-test", messageSubject, dt, messageBody); Assert.IsTrue(SearchClass.IndexMessage(message, page)); List <SearchResult> results = SearchClass.Search("wiki1", new SearchField[] { SearchField.Content }, "message", SearchOptions.AtLeastOneWord); Assert.AreEqual(1, results.Count, "Wrong result length"); Assert.AreEqual(DocumentType.Message, results[0].DocumentType, "Wrong document type"); MessageDocument documentMessage = results[0].Document as MessageDocument; Assert.AreEqual("This is the subject of the message", documentMessage.Subject, "Wrong title"); Assert.AreEqual("This is the body of the <b class=\"searchkeyword\">message</b>", documentMessage.HighlightedBody, "Wrong content"); }
public void AddPageAttachmentTest() { IPagesStorageProviderV30 pagesStorageProvider = mocks.DynamicMock <IPagesStorageProviderV30>(); mocks.ReplayAll(); Host.Instance = new Host(); Collectors.IndexDirectoryProvider = new DummyIndexDirectoryProvider(); ProviderLoader.SetUp <IIndexDirectoryProviderV30>(typeof(DummyIndexDirectoryProvider), ""); DateTime dt = DateTime.Now; PageContent page = new PageContent(new PageInfo("pagefullname", pagesStorageProvider, dt), "title", "user-test", dt, "", "content", new string[0], ""); string fileName = "file_name_1"; string filePath = Path.Combine(testDir, "test.txt"); using (StreamWriter writer = File.CreateText(filePath)) { writer.Write("This is the content of a file"); } Assert.IsTrue(SearchClass.IndexPageAttachment(fileName, filePath, page)); List <SearchResult> results = SearchClass.Search(new SearchField[] { SearchField.FileName, SearchField.FileContent }, "file", SearchOptions.AtLeastOneWord); Assert.AreEqual(1, results.Count, "Wrong result length"); Assert.AreEqual(DocumentType.Attachment, results[0].DocumentType, "Wrong document type"); PageAttachmentDocument pageAttachmentDocument = results[0].Document as PageAttachmentDocument; Assert.AreEqual(fileName, pageAttachmentDocument.FileName, "Wrong file name"); Assert.AreEqual("This is the content of a <b class=\"searchkeyword\">file</b>", pageAttachmentDocument.HighlightedFileContent, "Wrong file content"); }
public void AddPageTest() { IPagesStorageProviderV30 pagesStorageProvider = mocks.DynamicMock <IPagesStorageProviderV30>(); mocks.ReplayAll(); Host.Instance = new Host(); Collectors.IndexDirectoryProvider = new DummyIndexDirectoryProvider(); ProviderLoader.SetUp <IIndexDirectoryProviderV30>(typeof(DummyIndexDirectoryProvider), ""); string pageTitle = "This page is the title of the page"; string pageContent = "This is the content of the page"; PageContent page = new PageContent(new PageInfo("pagefullname", pagesStorageProvider, DateTime.Now), pageTitle, "user-test", DateTime.Now, "comment to last editing", pageContent, null, "Description of the page"); Assert.IsTrue(SearchClass.IndexPage(page)); List <SearchResult> results = SearchClass.Search(new SearchField[] { SearchField.Title }, "page", SearchOptions.AtLeastOneWord); Assert.AreEqual(1, results.Count, "Wrong result length"); Assert.AreEqual(DocumentType.Page, results[0].DocumentType, "Wrong document type"); PageDocument documentPage = results[0].Document as PageDocument; Assert.AreEqual("This <b class=\"searchkeyword\">page</b> is the title of the <b class=\"searchkeyword\">page</b>", documentPage.HighlightedTitle, "Wrong title"); Assert.AreEqual("This is the content of the <b class=\"searchkeyword\">page</b>", documentPage.HighlightedContent, "Wrong content"); }
//Searches the files for the given word when button is clicked //Displays filename and result in a textbox private void btn_Search_Click(object sender, EventArgs e) { //When the search button is clicked, textbox will be cleared and new serach result displayed resultSearch.Text = string.Empty; SearchClass search = new SearchClass(); if (word.Length > 0) { //Loop file/files to get filename and count of matches for the searched word for (int i = 0; i < SortedWords.Count; i++) { var wordCount = search.MatchOnSearchedWord(SortedWords[i], word); var fileName = Path.GetFileNameWithoutExtension(readFiles[i].FileName); resultSearch.Text += "\nThe searched word '" + word + "' was found " + wordCount + " times in File: " + fileName + " \r"; } } else { if (string.IsNullOrWhiteSpace(searchInputField.Text)) { MessageBox.Show("Please enter a valid input"); resultSearch.Text = string.Empty; } else { MessageBox.Show("Please enter a valid input"); resultSearch.Text = string.Empty; } } //Cleares search textbox after each search searchInputField.Text = string.Empty; btn_Search.Enabled = false; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Creates a new list resultView item for the specified search class. /// </summary> /// ------------------------------------------------------------------------------------ public static ClassListViewItem Create(SearchClass srchClass, bool addMembersAndClassTypeColumns) { ClassListViewItem item = new ClassListViewItem(srchClass.Name); item.Name = kClassNameSubitem; item.ClassType = srchClass.Type; if (addMembersAndClassTypeColumns) { item.SubItems.Add(srchClass.Pattern); item.SubItems.Add(item.ClassTypeText); } item.ANDFeatures = (string.IsNullOrEmpty(srchClass.Pattern) || srchClass.Pattern[0] == '['); if (srchClass.Type == SearchClassType.Articulatory) { item.Mask = App.AFeatureCache.GetEmptyMask(); GetMasksFromPattern(item, srchClass.Pattern); } else if (srchClass.Type == SearchClassType.Binary) { item.Mask = App.BFeatureCache.GetEmptyMask(); GetMasksFromPattern(item, srchClass.Pattern); } return(item); }
private void btTest_Click(object sender, RoutedEventArgs e) { try { int i = 0; while (i++ < 10) { double x = Convert.ToDouble(tbX.Text.Trim()); double y = Convert.ToDouble(tbY.Text.Trim()); ThreadPool.QueueUserWorkItem((o) => { DateTime time1 = DateTime.Now; SearchClass instance = new SearchClass(); instance.InitMemMap(); //String Result = GISLib.SearchClass.Instance.SearchNearRoad(x, y); SearchResult rs = instance.Search(x, y, true, true, true, double.MaxValue); DateTime time2 = DateTime.Now; MessageBox.Show(string.Format("Zone:{0} Road:{1} Point:{2} 耗时:{3}ms", rs.ZoneName, rs.RoadName, rs.PointName, (time2 - time1).TotalMilliseconds)); }); } } catch (Exception ex) { MessageBox.Show("发生错误;" + ex.Message); } }
public void UnindexFileTest() { Host.Instance = new Host(); Collectors.IndexDirectoryProvider = new DummyIndexDirectoryProvider(); ProviderLoader.SetUp <IIndexDirectoryProviderV30>(typeof(DummyIndexDirectoryProvider), ""); string fileName = "file name_1"; string filePath = Path.Combine(testDir, "test.txt"); using (StreamWriter writer = File.CreateText(filePath)) { writer.Write("This is the content of a file"); } Assert.IsTrue(SearchClass.IndexFile(fileName, filePath)); List <SearchResult> results = SearchClass.Search(new SearchField[] { SearchField.FileName, SearchField.FileContent }, "file", SearchOptions.AtLeastOneWord); Assert.AreEqual(1, results.Count, "Wrong result length"); Assert.AreEqual(DocumentType.File, results[0].DocumentType, "Wrong document type"); FileDocument fileDocument = results[0].Document as FileDocument; Assert.AreEqual(fileName, fileDocument.FileName, "Wrong file name"); Assert.AreEqual("This is the content of a <b class=\"searchkeyword\">file</b>", fileDocument.HighlightedFileContent, "Wrong file content"); Assert.IsTrue(SearchClass.UnindexFile(fileName)); results = SearchClass.Search(new SearchField[] { SearchField.FileName, SearchField.FileContent }, "file", SearchOptions.AtLeastOneWord); Assert.AreEqual(0, results.Count, "Wrong result length"); }
public ActionResult filter(string type) { SearchClass search = (SearchClass)Session["SearchClass"]; if (type != null) { int typeid = int.Parse(type); if (typeid == 2) { int Edit = int.Parse(search.EId); int Div1 = int.Parse(search.DId); int Coun = int.Parse(search.CId); var Ind = from plm_vw in db.plm_vwProductsByEdition where plm_vw.DivisionId == Div1 && plm_vw.EditionId == Edit && plm_vw.CountryId == Coun && plm_vw.TypeInEdition == "P" && plm_vw.NewProduct == "N" select plm_vw; return(View("Index", Ind)); } else if (typeid == 3) { return(View()); } else { return(View("Index")); } } else { return(RedirectToAction("Index")); } }
public void AddPageTest() { IPagesStorageProviderV60 pagesStorageProvider = mocks.DynamicMock <IPagesStorageProviderV60>(); Expect.Call(pagesStorageProvider.CurrentWiki).Return("wiki1").Repeat.Any(); mocks.ReplayAll(); Collectors.InitCollectors(); Collectors.AddProvider(typeof(FSIndexDirectoryProvider), System.Reflection.Assembly.GetAssembly(typeof(FSIndexDirectoryProvider)), "", typeof(IIndexDirectoryProviderV60)); Host.Instance = new Host(); Host.Instance.OverridePublicDirectory(testDir); ProviderLoader.SetUp <IIndexDirectoryProviderV60>(typeof(FSIndexDirectoryProvider), ""); string pageTitle = "This is the title of the page"; string pageContent = "This is the content of the page"; PageContent page = new PageContent("pagefullname", pagesStorageProvider, DateTime.Now, pageTitle, "user-test", DateTime.Now, "comment to last editing", pageContent, null, "Description of the page"); Assert.IsTrue(SearchClass.IndexPage(page)); List <SearchResult> results = SearchClass.Search("wiki1", new SearchField[] { SearchField.Title }, "page", SearchOptions.AtLeastOneWord); Assert.AreEqual(1, results.Count, "Wrong result length"); Assert.AreEqual(DocumentType.Page, results[0].DocumentType, "Wrong document type"); PageDocument documentPage = results[0].Document as PageDocument; Assert.AreEqual("This is the title of the <b class=\"searchkeyword\">page</b>", documentPage.HighlightedTitle, "Wrong title"); Assert.AreEqual("This is the content of the <b class=\"searchkeyword\">page</b>", documentPage.HighlightedContent, "Wrong content"); }
public void AddFileTest() { Collectors.InitCollectors(); Collectors.AddProvider(typeof(FSIndexDirectoryProvider), System.Reflection.Assembly.GetAssembly(typeof(FSIndexDirectoryProvider)), "", typeof(IIndexDirectoryProviderV60)); Host.Instance = new Host(); Host.Instance.OverridePublicDirectory(testDir); ProviderLoader.SetUp <IIndexDirectoryProviderV60>(typeof(FSIndexDirectoryProvider), ""); string fileName = "file_name_1"; string filePath = Path.Combine(testDir, "test.txt"); using (StreamWriter writer = File.CreateText(filePath)) { writer.Write("This is the content of a file"); } Assert.IsTrue(SearchClass.IndexFile(fileName, filePath, "wiki1")); List <SearchResult> results = SearchClass.Search("wiki1", new SearchField[] { SearchField.FileName, SearchField.FileContent }, "file", SearchOptions.AtLeastOneWord); Assert.AreEqual(1, results.Count, "Wrong result length"); Assert.AreEqual(DocumentType.File, results[0].DocumentType, "Wrong document type"); FileDocument fileDocument = results[0].Document as FileDocument; Assert.AreEqual(fileName, fileDocument.FileName, "Wrong file name"); Assert.AreEqual("This is the content of a <b class=\"searchkeyword\">file</b>", fileDocument.HighlightedFileContent, "Wrong file content"); }
public void UnindexPageTest() { IPagesStorageProviderV40 pagesStorageProvider = mocks.DynamicMock <IPagesStorageProviderV40>(); Expect.Call(pagesStorageProvider.CurrentWiki).Return("wiki1").Repeat.Any(); mocks.ReplayAll(); Collectors.InitCollectors(); Collectors.AddProvider(typeof(AzureIndexDirectoryProvider), System.Reflection.Assembly.GetAssembly(typeof(AzureIndexDirectoryProvider)), ConfigurationManager.AppSettings["AzureConnString"], typeof(IIndexDirectoryProviderV40)); Host.Instance = new Host(); Host.Instance.OverridePublicDirectory(testDir); ProviderLoader.SetUp <IIndexDirectoryProviderV40>(typeof(AzureIndexDirectoryProvider), ConfigurationManager.AppSettings["AzureConnString"]); string pageTitle1 = "This is the title"; string pageContent1 = "This is the content of the page"; PageContent page1 = new PageContent("pagefullname1", pagesStorageProvider, DateTime.Now, pageTitle1, "user-test", DateTime.Now, "comment to last editing", pageContent1, null, "Description of the page"); string pageTitle2 = "This is the title of the second page"; string pageContent2 = "This is the content of the second page"; PageContent page2 = new PageContent("pagefullname2", pagesStorageProvider, DateTime.Now, pageTitle2, "user-test", DateTime.Now, "comment to last editing", pageContent2, null, "Description of the page"); Lucene.Net.Store.Directory directory = new RAMDirectory(); Assert.IsTrue(SearchClass.IndexPage(page1)); Assert.IsTrue(SearchClass.IndexPage(page2)); List <SearchResult> results = SearchClass.Search("wiki1", new SearchField[] { SearchField.Title, SearchField.Content }, "page", SearchOptions.AtLeastOneWord); Assert.AreEqual(2, results.Count, "Wrong result length"); Assert.AreEqual(DocumentType.Page, results[1].DocumentType, "Wrong document type"); PageDocument doc1 = results[1].Document as PageDocument; Assert.AreEqual(string.Empty, doc1.HighlightedTitle, "Wrong title"); Assert.AreEqual("This is the content of the <b class=\"searchkeyword\">page</b>", doc1.HighlightedContent, "Wrong content"); Assert.AreEqual(DocumentType.Page, results[0].DocumentType, "Wrong document type"); PageDocument doc2 = results[0].Document as PageDocument; Assert.AreEqual("This is the title of the second <b class=\"searchkeyword\">page</b>", doc2.HighlightedTitle, "Wrong title"); Assert.AreEqual("This is the content of the second <b class=\"searchkeyword\">page</b>", doc2.HighlightedContent, "Wrong content"); Assert.IsTrue(SearchClass.UnindexPage(page1)); results = SearchClass.Search("wiki1", new SearchField[] { SearchField.Title, SearchField.Content }, "page", SearchOptions.AtLeastOneWord); Assert.AreEqual(1, results.Count, "Wrong result length"); Assert.AreEqual(DocumentType.Page, results[0].DocumentType, "Wrong document type"); PageDocument doc3 = results[0].Document as PageDocument; Assert.AreEqual("This is the title of the second <b class=\"searchkeyword\">page</b>", doc3.HighlightedTitle, "Wrong title"); Assert.AreEqual("This is the content of the second <b class=\"searchkeyword\">page</b>", doc3.HighlightedContent, "Wrong content"); }
static void Main(string[] args) { char choice; string SearchWordFromUser; string SearchDirectoryFromUser; SearchClass newSearchFile = new SearchClass(); newSearchFile.DisplayResults += new DisplaySearchResultsDelegate(printSearchResult); newSearchFile.DisplayError += new SearchFindErrorDelegate(PrintSearchErrors); SearchClass.SearchResult result = SearchClass.SearchResult.SuccessfulSearch; try { do { Console.Write("1. Enter file name to search.\n" + "2. Enter file name to search + parent directory to search in.\n" + "3. Exit."); Console.WriteLine();; choice = Console.ReadKey().KeyChar; Console.Clear(); switch (choice) { case '1': Console.WriteLine("Insert filename"); SearchWordFromUser = Console.ReadLine(); Console.Clear(); result = newSearchFile.AddNewSearch(SearchWordFromUser); Console.WriteLine("Start searching... \n-------------------------------------"); Console.WriteLine(result.ToString()); break; //IMPORTENT:The results are being saved and the developer can see that in the SQL Server Object explorer case '2': Console.WriteLine("Insert directory to search in"); SearchDirectoryFromUser = Console.ReadLine(); Console.WriteLine("Insert file name"); SearchWordFromUser = Console.ReadLine(); Console.Clear(); result = newSearchFile.AddNewSearch(SearchWordFromUser, SearchDirectoryFromUser); Console.WriteLine("Start searching... \n-------------------------------------"); Console.WriteLine(result.ToString()); break; default: Console.Clear(); break; } } while (choice != '3'); } catch (Exception ex) { Console.WriteLine("An error has occured: " + ex.Message); } }
public void Order_DefaultValue() { //arrange //act var value = new SearchClass(); //assert Assert.Null(value.OrderBy); Assert.True(value.OrderAscending); }
// This controls the players by position view, it lists all of the players of the selected position public ActionResult displayAllPlayersByPosition(SearchClass model) { // Gets the players by position from the service ViewBag.Players = client.retreveAllPlayerByPosition(model.pos).dt; var teamArray = new string[6] { "Boston Bruins", "Toronto Maple Leafs", "Montreal Canadiens", "Chicago Black Hawks", "Detroit Red Wings", "New York Rangers" }; ViewBag.TeamNames = teamArray; return(View("PlayersByPosition")); }
public void UnindexPageTest() { IPagesStorageProviderV30 pagesStorageProvider = mocks.DynamicMock <IPagesStorageProviderV30>(); mocks.ReplayAll(); Host.Instance = new Host(); Collectors.IndexDirectoryProvider = new DummyIndexDirectoryProvider(); ProviderLoader.SetUp <IIndexDirectoryProviderV30>(typeof(DummyIndexDirectoryProvider), ""); string pageTitle1 = "This is the title"; string pageContent1 = "This is the content of the page"; PageContent page1 = new PageContent(new PageInfo("pagefullname1", pagesStorageProvider, DateTime.Now), pageTitle1, "user-test", DateTime.Now, "comment to last editing", pageContent1, null, "Description of the page"); string pageTitle2 = "This is the title of the second page"; string pageContent2 = "This is the content of the second page"; PageContent page2 = new PageContent(new PageInfo("pagefullname2", pagesStorageProvider, DateTime.Now), pageTitle2, "user-test", DateTime.Now, "comment to last editing", pageContent2, null, "Description of the page"); Lucene.Net.Store.Directory directory = new RAMDirectory(); Assert.IsTrue(SearchClass.IndexPage(page1)); Assert.IsTrue(SearchClass.IndexPage(page2)); List <SearchResult> results = SearchClass.Search(new SearchField[] { SearchField.Title, SearchField.Content }, "page", SearchOptions.AtLeastOneWord); Assert.AreEqual(2, results.Count, "Wrong result length"); Assert.AreEqual(DocumentType.Page, results[1].DocumentType, "Wrong document type"); PageDocument doc1 = results[1].Document as PageDocument; Assert.AreEqual(string.Empty, doc1.HighlightedTitle, "Wrong title"); Assert.AreEqual("This is the content of the <b class=\"searchkeyword\">page</b>", doc1.HighlightedContent, "Wrong content"); Assert.AreEqual(DocumentType.Page, results[0].DocumentType, "Wrong document type"); PageDocument doc2 = results[0].Document as PageDocument; Assert.AreEqual("This is the title of the second <b class=\"searchkeyword\">page</b>", doc2.HighlightedTitle, "Wrong title"); Assert.AreEqual("This is the content of the second <b class=\"searchkeyword\">page</b>", doc2.HighlightedContent, "Wrong content"); Assert.IsTrue(SearchClass.UnindexPage(page1)); results = SearchClass.Search(new SearchField[] { SearchField.Title, SearchField.Content }, "page", SearchOptions.AtLeastOneWord); Assert.AreEqual(1, results.Count, "Wrong result length"); Assert.AreEqual(DocumentType.Page, results[0].DocumentType, "Wrong document type"); PageDocument doc3 = results[0].Document as PageDocument; Assert.AreEqual("This is the title of the second <b class=\"searchkeyword\">page</b>", doc3.HighlightedTitle, "Wrong title"); Assert.AreEqual("This is the content of the second <b class=\"searchkeyword\">page</b>", doc3.HighlightedContent, "Wrong content"); }
public void OrderBy_IsSet(string orderBy) { //arrange //act var value = new SearchClass() { OrderBy = orderBy }; //assert Assert.Equal(orderBy, value.OrderBy); Assert.True(value.OrderAscending); }
public LookupForm(string tableName) { InitializeComponent(); dgvMasterList.AutoGenerateColumns = false; if (!jobSearch) { _dtSource = SearchClass.GetSearchData(tableName, Convert.ToInt32(txtRowCount.Text.Trim())); } else { _dtSource = Employee.GetEmployees().Tables[0]; } }
public void RenamePageAttachmentTest() { IPagesStorageProviderV60 pagesStorageProvider = mocks.DynamicMock <IPagesStorageProviderV60>(); Expect.Call(pagesStorageProvider.CurrentWiki).Return("wiki1").Repeat.Any(); mocks.ReplayAll(); Collectors.InitCollectors(); Collectors.AddProvider(typeof(FSIndexDirectoryProvider), System.Reflection.Assembly.GetAssembly(typeof(FSIndexDirectoryProvider)), "", typeof(IIndexDirectoryProviderV60)); Host.Instance = new Host(); Host.Instance.OverridePublicDirectory(testDir); ProviderLoader.SetUp <IIndexDirectoryProviderV60>(typeof(FSIndexDirectoryProvider), ""); DateTime dt = DateTime.Now; PageContent page = new PageContent("pagefullname", pagesStorageProvider, dt, "title", "user-test", dt, "", "content", new string[0], ""); string fileName = "file name_1"; string filePath = Path.Combine(testDir, "test.txt"); using (StreamWriter writer = File.CreateText(filePath)) { writer.Write("This is the content of a file"); } Assert.IsTrue(SearchClass.IndexPageAttachment(fileName, filePath, page)); List <SearchResult> results = SearchClass.Search("wiki1", new SearchField[] { SearchField.FileName, SearchField.FileContent }, "file", SearchOptions.AtLeastOneWord); Assert.AreEqual(1, results.Count, "Wrong result length"); Assert.AreEqual(DocumentType.Attachment, results[0].DocumentType, "Wrong document type"); PageAttachmentDocument pageAttachmentDocument = results[0].Document as PageAttachmentDocument; Assert.AreEqual(fileName, pageAttachmentDocument.FileName, "Wrong file name"); Assert.AreEqual("This is the content of a <b class=\"searchkeyword\">file</b>", pageAttachmentDocument.HighlightedFileContent, "Wrong file content"); Assert.IsTrue(SearchClass.RenamePageAttachment(page, fileName, "file name_2")); results = SearchClass.Search("wiki1", new SearchField[] { SearchField.FileName, SearchField.FileContent }, "file", SearchOptions.AtLeastOneWord); Assert.AreEqual(1, results.Count, "Wrong result length"); Assert.AreEqual(DocumentType.Attachment, results[0].DocumentType, "Wrong document type"); pageAttachmentDocument = results[0].Document as PageAttachmentDocument; Assert.AreEqual("file name_2", pageAttachmentDocument.FileName, "Wrong file name"); Assert.AreEqual("This is the content of a <b class=\"searchkeyword\">file</b>", pageAttachmentDocument.HighlightedFileContent, "Wrong file content"); }
public async Task <AngularSTResult <DetailsSysUserDto> > Get(PageSysUserDto Params) { //EditSysUserDto Params = new EditSysUserDto(); //Params.Email = "377749229@"; //Params.Tel = "321321"; AngularSTResult <DetailsSysUserDto> res = new AngularSTResult <DetailsSysUserDto>(); var seaechLambda = SearchClass <SysUser, EditSysUserDto, SysUser> .GetWhereLambda(Params); var userList = await _userService.UserQueryAsync(seaechLambda, Params.pi, Params.ps, s => s.CreatorTime, SqlSugar.OrderByType.Desc); res.list = _mapper.Map <List <DetailsSysUserDto> >(userList); return(await Task.Run(() => res)); }
// This controls the tabel view, it displays the team and all of its details public ActionResult displayID(SearchClass model) { // Gets the team details from the service (team, players, wins & losses, and sponsers) ViewBag.Team = client.retreveTeamDetails(model.id).dt; ViewBag.Players = client.retreveAllPlayersByTeam(model.id).dt; ViewBag.WinLoss = client.retreveTeamWinLoss().dt; ViewBag.Sponsor = client.retreveSponsor().dt; ViewBag.TeamID = model.id; var teamArray = new string[6] { "Boston Bruins", "Toronto Maple Leafs", "Montreal Canadiens", "Chicago Black Hawks", "Detroit Red Wings", "New York Rangers" }; ViewBag.TeamNames = teamArray; return(View("TableView")); }
//Searches the files for the given word when button is clicked //Displays filename and result in a textbox private void BtnSearch_Click(object sender, EventArgs e) { //When the search button is clicked, textbox will be cleared and new serach result displayed resultSearch.Text = string.Empty; string resultString = string.Empty; SearchClass search = new SearchClass(); Cursor.Current = Cursors.WaitCursor; if (searchInputField.Text.Trim() == string.Empty) { MessageBox.Show("Please enter a valid input"); searchInputField.Text = string.Empty; searchInputField.Focus(); btn_Search.Enabled = false; } else if (word.Length > 0) { // List to sort for results List <SearchResult> resultList = new List <SearchResult>(); //Loop file/files to get filename and count of matches for the searched word for (int i = 0; i < SortedWords.Count; i++) { var wordCount = search.MatchOnSearchedWord(SortedWords[i], word); var fileName = Path.GetFileNameWithoutExtension(readFiles[i].FileName); resultList.Add(new SearchResult(fileName, wordCount)); } // Sort results using the standard CompareTo praxis resultList.Sort(); // Iterate over the sorted results and write out foreach (var result in resultList) { resultString += "\nThe searched word '" + word + "' was found " + result.MatchCount + " times in File: " + result.FileName + " \r"; } } Cursor.Current = Cursors.Default; resultSearch.Text = resultString; //Cleares search textbox after each search searchInputField.Text = string.Empty; btn_Search.Enabled = false; }
static void Main(string s, int strandID) { int lenCutoff = 10000; if (s.Length > lenCutoff) { var searches = new List <SearchClass>(); var tasks = new List <System.Threading.Tasks.Task>(); for (int i = 0; i < s.Length; i += lenCutoff) { SearchClass newSearch = new SearchClass(s.Substring(i, lenCutoff), i); searches.Add(newSearch); tasks.Add(System.Threading.Tasks.Task.Factory.StartNew(() => newSearch.Run(strandID))); } System.Threading.Tasks.Task.WaitAll(tasks.ToArray()); // Combine the result } }
public IActionResult SearchFriend(AdapterId busqueda) { UsuarioActual.GetUsuarioActual().ActualizarAmigos(); var bus = busqueda.id; var op = Convert.ToInt32(busqueda.comentario); SearchClass search = new SearchClass(new SearchName(), bus); if (op == 2) { search = new SearchClass(new SearchLastname(), bus); } else if (op == 3) { search = new SearchClass(new SearchCorreo(), bus); } var result = search.Search(); UsuarioActual.GetUsuarioActual().Buscar(result); return(Json(new { success = true, res = result, redirecturl = Url.Action("Index1", "Home") })); }
protected override string exec(MessageEventArgs Msg, string param) { return(SearchClass.Search(SearchData, param)); }
public ActionResult Index(string CountryId, string DivisionId, string EditionId, string ProductName, string ProductId, string BookId, string TypeInEdition) { SearchClass search = (SearchClass)Session["SearchClass"]; TypeInEditionn ST = (TypeInEditionn)Session["TypeInEdition"]; if (search != null) { if (ProductName != null) { if (ProductName == string.Empty) { return(RedirectToAction("Index")); } else { if (ST == null) { int count = 0; int Coun = int.Parse(search.CId); int Div1 = int.Parse(search.DId); int Edition = int.Parse(search.EId); var Ind = (from plm_vw in db.plm_vwProductsByEdition where plm_vw.DivisionId == Div1 && plm_vw.EditionId == Edition && plm_vw.CountryId == Coun && plm_vw.TypeInEdition == "P" select plm_vw); if (!string.IsNullOrEmpty(ProductName)) { Ind = Ind.Where(s => s.ProductName.StartsWith(ProductName)).OrderBy(x => x.ProductName); foreach (plm_vwProductsByEdition J in Ind) { count = count + 1; } ViewData["Count"] = count; } return(View(Ind)); } else { if (TypeInEdition == null) { int count = 0; string type = ST.TypeInEdition; if (type == "P") { int Edit = int.Parse(search.EId); int Div1 = int.Parse(search.DId); int Coun = int.Parse(search.CId); var Ind = (from plm_vw in db.plm_vwProductsByEdition where plm_vw.DivisionId == Div1 && plm_vw.EditionId == Edit && plm_vw.CountryId == Coun && plm_vw.TypeInEdition == "P" select plm_vw); if (!string.IsNullOrEmpty(ProductName)) { Ind = Ind.Where(s => s.ProductName.StartsWith(ProductName)).OrderBy(x => x.ProductName); foreach (plm_vwProductsByEdition J in Ind) { count = count + 1; } ViewData["Count"] = count; } return(View(Ind)); } else if (type == "N") { int Edit = int.Parse(search.EId); int Div1 = int.Parse(search.DId); int Coun = int.Parse(search.CId); var Ind = (from plm_vw in db.plm_vwProductsByEdition where plm_vw.DivisionId == Div1 && plm_vw.EditionId == Edit && plm_vw.CountryId == Coun && plm_vw.TypeInEdition == "P" && plm_vw.NewProduct == "N" select plm_vw); if (!string.IsNullOrEmpty(ProductName)) { Ind = Ind.Where(s => s.ProductName.StartsWith(ProductName)).OrderBy(x => x.ProductName); foreach (plm_vwProductsByEdition J in Ind) { count = count + 1; } ViewData["Count"] = count; } return(View("Index", Ind)); } else if (type == "C/C") { int Edit = int.Parse(search.EId); int Div1 = int.Parse(search.DId); int Coun = int.Parse(search.CId); var Ind = (from plm_vw in db.plm_vwProductsByEdition where plm_vw.DivisionId == Div1 && plm_vw.EditionId == Edit && plm_vw.CountryId == Coun && plm_vw.TypeInEdition == "P" && plm_vw.ContentType == "C/C" select plm_vw); if (!string.IsNullOrEmpty(ProductName)) { Ind = Ind.Where(s => s.ProductName.StartsWith(ProductName)).OrderBy(x => x.ProductName); foreach (plm_vwProductsByEdition J in Ind) { count = count + 1; } ViewData["Count"] = count; } return(View("Index", Ind)); } } } } } } if (TypeInEdition != null) { int count = 0; if (TypeInEdition == "P") { int Edit = int.Parse(search.EId); int Div1 = int.Parse(search.DId); int Coun = int.Parse(search.CId); var Ind = (from plm_vw in db.plm_vwProductsByEdition where plm_vw.DivisionId == Div1 && plm_vw.EditionId == Edit && plm_vw.CountryId == Coun && plm_vw.TypeInEdition == "P" orderby plm_vw.ProductName ascending select plm_vw).ToList(); foreach (plm_vwProductsByEdition plm in Ind) { count = count + 1; } if (count == 0) { ViewData["CountProds"] = null; } else { ViewData["CountProds"] = count; } TypeInEditionn TInEdition = new TypeInEditionn(TypeInEdition); Session["TypeInEdition"] = TInEdition; return(View("Index", Ind)); } else if (TypeInEdition == "N") { int Edit = int.Parse(search.EId); int Div1 = int.Parse(search.DId); int Coun = int.Parse(search.CId); var Ind = (from plm_vw in db.plm_vwProductsByEdition where plm_vw.DivisionId == Div1 && plm_vw.EditionId == Edit && plm_vw.CountryId == Coun && plm_vw.TypeInEdition == "P" && plm_vw.NewProduct == "N" orderby plm_vw.ProductName ascending select plm_vw).ToList(); foreach (plm_vwProductsByEdition plm in Ind) { count = count + 1; } if (count == 0) { ViewData["CountProds"] = null; } else { ViewData["CountProds"] = count; } TypeInEditionn TInEdition = new TypeInEditionn(TypeInEdition); Session["TypeInEdition"] = TInEdition; return(View("Index", Ind)); } else if (TypeInEdition == "C/C") { int Edit = int.Parse(search.EId); int Div1 = int.Parse(search.DId); int Coun = int.Parse(search.CId); var Ind = (from plm_vw in db.plm_vwProductsByEdition where plm_vw.DivisionId == Div1 && plm_vw.EditionId == Edit && plm_vw.CountryId == Coun && plm_vw.TypeInEdition == "P" && plm_vw.ContentType == "C/C" orderby plm_vw.ProductName ascending select plm_vw).ToList(); foreach (plm_vwProductsByEdition plm in Ind) { count = count + 1; } if (count == 0) { ViewData["CountProds"] = null; } else { ViewData["CountProds"] = count; } TypeInEditionn TInEdition = new TypeInEditionn(TypeInEdition); Session["TypeInEdition"] = TInEdition; return(View("Index", Ind)); } } if (DivisionId != null) { int count = 0; int country = int.Parse(CountryId); int Division = int.Parse(DivisionId); int Edition = int.Parse(EditionId); string CId = CountryId; string DId = DivisionId; string EId = EditionId; string PId = ProductId; string BId = BookId; List <JoinClasification> LCLASS = new List <JoinClasification>(); List <Crops> LCROPS = new List <Crops>(); JoinClasification jclass = new JoinClasification(); Crops Crops = new Models.Crops(); var Ind = (from plm_vw in db.plm_vwProductsByEdition where plm_vw.DivisionId == Division && plm_vw.EditionId == Edition && plm_vw.CountryId == country && plm_vw.TypeInEdition == "P" orderby plm_vw.ProductName ascending select plm_vw).ToList(); foreach (plm_vwProductsByEdition plm in Ind) { count = count + 1; } if (count == 0) { ViewData["CountProds"] = null; } else { ViewData["CountProds"] = count; } SearchClass SearchClass = new SearchClass(CId, DId, EId, PId, BId); Session["SearchClass"] = SearchClass; return(View(Ind)); } else if (search != null) { if (ST != null) { if (TypeInEdition == null) { int count = 0; string type = ST.TypeInEdition; if (type == "P") { int Edit = int.Parse(search.EId); int Div1 = int.Parse(search.DId); int Coun = int.Parse(search.CId); var Ind = (from plm_vw in db.plm_vwProductsByEdition where plm_vw.DivisionId == Div1 && plm_vw.EditionId == Edit && plm_vw.CountryId == Coun && plm_vw.TypeInEdition == "P" orderby plm_vw.ProductName ascending select plm_vw).ToList(); foreach (plm_vwProductsByEdition plm in Ind) { count = count + 1; } if (count == 0) { ViewData["CountProds"] = null; } else { ViewData["CountProds"] = count; } return(View("Index", Ind)); } else if (type == "N") { int Edit = int.Parse(search.EId); int Div1 = int.Parse(search.DId); int Coun = int.Parse(search.CId); var Ind = (from plm_vw in db.plm_vwProductsByEdition where plm_vw.DivisionId == Div1 && plm_vw.EditionId == Edit && plm_vw.CountryId == Coun && plm_vw.TypeInEdition == "P" && plm_vw.NewProduct == "N" orderby plm_vw.ProductName ascending select plm_vw).ToList(); foreach (plm_vwProductsByEdition plm in Ind) { count = count + 1; } if (count == 0) { ViewData["CountProds"] = null; } else { ViewData["CountProds"] = count; } return(View("Index", Ind)); } else if (type == "C/C") { int Edit = int.Parse(search.EId); int Div1 = int.Parse(search.DId); int Coun = int.Parse(search.CId); var Ind = (from plm_vw in db.plm_vwProductsByEdition where plm_vw.DivisionId == Div1 && plm_vw.EditionId == Edit && plm_vw.CountryId == Coun && plm_vw.TypeInEdition == "P" && plm_vw.ContentType == "C/C" orderby plm_vw.ProductName ascending select plm_vw).ToList(); foreach (plm_vwProductsByEdition plm in Ind) { count = count + 1; } if (count == 0) { ViewData["CountProds"] = null; } else { ViewData["CountProds"] = count; } return(View("Index", Ind)); } } } else { int count = 0; int Edit = int.Parse(search.EId); int Div1 = int.Parse(search.DId); int Coun = int.Parse(search.CId); var Ind = (from plm_vw in db.plm_vwProductsByEdition where plm_vw.DivisionId == Div1 && plm_vw.EditionId == Edit && plm_vw.CountryId == Coun && plm_vw.TypeInEdition == "P" orderby plm_vw.ProductName ascending select plm_vw).ToList(); foreach (plm_vwProductsByEdition plm in Ind) { count = count + 1; } if (count == 0) { ViewData["CountProds"] = null; } else { ViewData["CountProds"] = count; } return(View(Ind)); } } if (DivisionId == null) { var Ind = from plm_vw in db.plm_vwProductsByEdition where plm_vw.DivisionId == 0 && plm_vw.EditionId == 0 && plm_vw.CountryId == 0 && plm_vw.TypeInEdition == "P" orderby plm_vw.ProductName ascending select plm_vw; ViewData["CountProds"] = null; return(View(Ind)); } return(View()); }
} // DG_TabMusic_MouseRightButtonDown private void Button_Search_Click(object sender, RoutedEventArgs e) { SearchClass search = new SearchClass(TB_TextSearch.Text); DG_TabMusic.ItemsSource = search.Search(DG_TabMusic.Items); }
public ActionResult getSupplierLocation(string search) { LocationClass supplier = new LocationClass(); SearchClass current = JsonConvert.DeserializeObject <SearchClass>(search); //Insert record OdbcConnection OdbcConn = new OdbcConnection("Dsn=VHHAL202;uid=HACKT03;pwd=gfZhA7dQ"); OdbcCommand myCommand = new OdbcCommand(); myCommand.Connection = OdbcConn; OdbcConn.Open(); string sqlGetUser = "******"HACKT03\".\"USERS\" where NAME = '" + current.name + "'"; myCommand.CommandText = sqlGetUser; string id = ""; var reader = myCommand.ExecuteReader(); if (reader.Read()) { //we hvae an existing record id = reader["userid"].ToString(); reader.Close(); } else { reader.Close(); //Insert user string sqlInsert = $"insert into \"HACKT03\".\"USERS\" values(id_seq.NEXTVAL, '{current.name}', '', NEW ST_Point('Point ({current.location.x} {current.location.y})', 4326))"; myCommand.CommandText = sqlInsert; myCommand.ExecuteNonQuery(); sqlGetUser = "******"HACKT03\".\"USERS\" where NAME = '" + current.name + "'"; myCommand.CommandText = sqlGetUser; reader = myCommand.ExecuteReader(); if (reader.Read()) { //we hvae an existing record id = reader["userid"].ToString(); } reader.Close(); } foreach (var item in current.items) { myCommand.CommandText = $"INSERT INTO \"HACKT03\".\"TRANSACTIONS\" VALUES(id_seq_trans.NEXTVAL, {id}, 'DROP' , '{item.productType}', {item.amount}, 'Finished', '')"; myCommand.ExecuteNonQuery(); } string sql = "SELECT TOP 1 * FROM (select A.NAME AS \"USERNAME\",B.ID AS \"FACILITYID\", B.NAME AS \"FACILITYNAME\" , B.LOCATION.ST_X() AS \"LON\", B.LOCATION.ST_Y() AS \"LAT\", A.LOCATION.ST_Distance(B.LOCATION, 'meter') AS \"DISTANCE\" from \"HACKT03\".\"USERS\" A, \"HACKT03\".\"FACILITIES\" B where A.NAME = '" + current.name + "') TEMP ORDER BY DISTANCE"; myCommand.CommandText = sql; OdbcDataReader myReader = myCommand.ExecuteReader(); try { //Get Neerest Center while (myReader.Read()) { supplier.x = double.Parse(myReader["LON"].ToString()); supplier.y = double.Parse(myReader["LAT"].ToString()); supplier.name = myReader["FACILITYNAME"]?.ToString(); supplier.distance = Math.Round(0.000621371 * double.Parse(myReader["DISTANCE"].ToString()), 2); } } finally { myReader.Close(); OdbcConn.Close(); } //Return it // supplier.x = -95.4805; // supplier.y = 29; var data = Content(JsonConvert.SerializeObject(supplier), "application/json", System.Text.Encoding.UTF8); return(data); }