public ThumnailProcessDlg(int ProcessPercent, bool isProcess, string CurrentProcess) { InitializeComponent(); this.thumnailProcess = new ThumnailProcess(); this.SearchFiles = new SearchFiles(); this.startProcess.Enabled = false; }
private static void GenerateLogPdb() { //搜索指定目录,得到所有匹配文件路径 string[] subPaths = SearchFiles.SearchAllFilesWithSpecifiedSuffixs(baseDir, searchPath, ".cs,.lua"); //新建LogPdb映射 LogTrackPdbFile pdb = new LogTrackPdbFile(); //处理所有子文件 foreach (var subPath in subPaths) { //剔除所有屏蔽文件 bool ignoreSign = false; foreach (var ignorePath in ignorePaths) { if (subPath == ignorePath) { ignoreSign = true; break; } } if (ignoreSign == false) { //编码手动插入的代码 HashLogTrackCode(baseDir, subPath, pdb); } } //生成新LogPdb pdb.CreateLogPdb(newLogPdbFolderPath + "/newLogPdb.json"); }
private void ProgressButton_Click(object sender, EventArgs e) { EnterBaseDrive ebd = new EnterBaseDrive(); ebd.ShowDialog(); // RedemptionAntiRansomwareEntities db = new RedemptionAntiRansomwareEntities(); Anti_Ransomware.Database db = new Anti_Ransomware.Database(); listBox5.DataSource = db.Extension.Select(x => new { x.Ext }.Ext).ToList(); List <string> lst = new List <string>(); foreach (var item in listBox5.Items) { lst.Add(item.ToString()); } FlatAlertBox.Text = "Scan for special Directory Started ."; this.FlatAlertBox.Visible = false; FlatAlertBox._Kind kind = FlatUI.FlatAlertBox._Kind.Success; this.FlatAlertBox.kind = kind; this.FlatAlertBox.Visible = true; SearchFiles sf = new SearchFiles(); Thread t3 = new Thread(delegate() { sf.ApplyAllFiles(ebd.Folder, sf.ProcessFile, lst.ToArray(), false); }); t3.Start(); }
public void TestSearchFiles() { var id = CreateTestBlob(filePath); var files = SearchFiles.DriveSearchFiles(); Assert.AreNotEqual(0, files.Count); DeleteFileOnCleanup(id); }
public async Task IncorrectDirectoryInput() { await Assert.ThrowsExceptionAsync <DirectoryNotFoundException>(async() => await SearchFiles.SearchByRegex("1", "12348-32104283-05-14857918-1")); await Assert.ThrowsExceptionAsync <ArgumentException>(async() => await SearchFiles.SearchByRegex("1", "")); await Assert.ThrowsExceptionAsync <ArgumentNullException>(async() => await SearchFiles.SearchByRegex("1", null)); Assert.AreEqual(true, SearchFiles.SearchCancelledOrDone); }
public void Handle(SearchFiles searchfiles, Action <IEnumerable <SearchResult> > reply) { //int x = 1; reply(searchResults.Where(searchDto => searchDto.Name.ToLower().Contains(searchfiles.SearchText.ToLower())) .Select(found => new SearchResult() { Directory = found.Path, Name = found.Name })); // reply(from file in searchResults // where file.Name.ToLower().Contains(searchfiles.SearchText.ToLower()) // select new SearchResult() // { // Directory = "foo", // Name = "bar" // } // // ); }
public IEnumerable <IResult> ExecuteSearch() { var search = new SearchFiles { SearchText = Name }.AsResult(); yield return(search); if (search.Response != null) { foreach (var result in search.Response) { Response += result.Name; } } //Activate a popup. // SearchViewModel model = new SearchViewModel(); // Screen screen = new Screen(); // WindowManager windowManager = new WindowManager(); // windowManager.ShowDialog(model); }
public Configuration(CommandLineOptions options) { this.Main = (args) => SearchFiles.Main(args); this.Name = "search-files"; this.Description = FromResource("Description"); this.ExtendedHelpText = FromResource("ExtendedHelpText"); this.IndexDirectoryArgument = new IndexDirectoryArgument(required: true); this.Arguments.Add(IndexDirectoryArgument); this.FieldOption = this.Option( "-f|--field <FIELD>", FromResource("FieldDescription"), CommandOptionType.SingleValue); this.RepeatOption = this.Option( "-r|--repeat <NUMBER>", FromResource("RepeatDescription"), CommandOptionType.SingleValue); this.QueriesFileOption = this.Option( "-qf|--queries-file <PATH>", FromResource("QueriesFileDescription"), CommandOptionType.SingleValue); this.QueryOption = this.Option( "-q|--query <QUERY>", FromResource("QueryDescription"), CommandOptionType.SingleValue); this.RawOption = this.Option( "--raw", FromResource("RawDescription"), CommandOptionType.NoValue); this.PageSizeOption = this.Option( "-p|--page-size <NUMBER>", FromResource("PageSizeDescription"), CommandOptionType.SingleValue); this.OnExecute(() => new DemoSearchFilesCommand().Run(this)); }
private void flatButton2_Click(object sender, EventArgs e) { if (FlatNumeric.Value == 0) { MessageBox.Show("Please specify how much honeypot you need ! It cannot be zero ..."); return; } EnterBaseDrive ebd = new EnterBaseDrive(); ebd.ShowDialog(); // RedemptionAntiRansomwareEntities db = new RedemptionAntiRansomwareEntities(); Anti_Ransomware.Database db = new Anti_Ransomware.Database(); listBox5.DataSource = db.Extension.Select(x => new { x.Ext }.Ext).ToList(); List <string> lst = new List <string>(); foreach (var item in listBox5.Items) { lst.Add(item.ToString()); } FlatAlertBox.Text = "Put for Honeypot Directory Started ."; this.FlatAlertBox.Visible = false; FlatAlertBox._Kind kind = FlatUI.FlatAlertBox._Kind.Success; this.FlatAlertBox.kind = kind; this.FlatAlertBox.Visible = true; SearchFiles sf = new SearchFiles(); SearchFiles.HoneyCount = Convert.ToInt32(FlatNumeric.Value) - 1; Thread t3 = new Thread(delegate() { sf.ApplyAllFiles(ebd.Folder, sf.ProcessFile, lst.ToArray(), true); }); t3.Start(); }
public ActionResult SearchFilePartial(string userId, string keyWord, int currentPage) { AppUser currentUser = userManager.Users.FirstOrDefault(u => u.Id == userId); List <SearchFiles> files = new List <SearchFiles>(); foreach (Course course in repository.Courses.Where(c => c.Status == "Public" && (c.CreatedBy.CompanyName == currentUser.CompanyName || c.CreatedBy.CompanyName == null))) { foreach (Presentation presentation in course.Presentations) { //presentation files foreach (PresentationFiles file1 in repository.PresentationFiles .Where(f => f.PresentationId == presentation.PresentationId)) { if (SearchWordExists(file1.Title, keyWord)) { string info = $"<span class='text-muted'>For: <strong>{presentation.Title}</strong> <i class='{course.AwardIcon}'></i>" + $"<strong>{course.Title}</strong></span>"; SearchFiles searchFile1 = new SearchFiles { File = file1, CreatedBy = userManager.Users.FirstOrDefault(u => u.Id == presentation.CreatedBy.Id), FileForInfo = info }; files.Add(searchFile1); } } } } //courses where currentUser == course.CreatedBy && status == "Private" //& presentations foreach (Course course in repository.Courses.Where(c => c.Status == "Private" && (c.CreatedBy.CompanyName == currentUser.CompanyName || c.CreatedBy.CompanyName == null))) { if (course.CreatedBy != null) { if (course.CreatedBy.Id == currentUser.Id) { foreach (Presentation presentation in course.Presentations) { //presentation files foreach (PresentationFiles file2 in repository.PresentationFiles .Where(f => f.PresentationId == presentation.PresentationId)) { if (SearchWordExists(file2.Title, keyWord)) { string info = $"<span class='text-muted'>For: <strong>{presentation.Title}</strong> <i class='{course.AwardIcon}'></i>" + $"<strong>{course.Title}</strong></span>"; SearchFiles searchFile2 = new SearchFiles { File = file2, CreatedBy = userManager.Users.FirstOrDefault(u => u.Id == presentation.CreatedBy.Id), FileForInfo = info }; files.Add(searchFile2); } } } } } } SearchAllFiles allFiles = new SearchAllFiles { AllFiles = files.AsQueryable() .OrderBy(f => f.File.Title) .Take(MaxSearchPageFile), FilePageInfo = new SearchFilesPageInfo { CurrentPage = currentPage, TotalFiles = files.Count(), FilesPerPage = MaxSearchPageFile } }; return(PartialView("SearchFilePartial", allFiles)); }
public async Task <ViewResult> Search(string id, string KeyWord) { ViewData["Id"] = id; AppUser currentUser = userManager.Users.FirstOrDefault(u => u.Id == id); //users List <AppUser> users = new List <AppUser>(); foreach (AppUser user in userManager.Users.Where(u => u.CompanyName == currentUser.CompanyName)) { if (SearchWordExists(user.FirstName, KeyWord)) { users.Add(user); } else if (SearchWordExists(user.LastName, KeyWord)) { users.Add(user); } else if (SearchWordExists(user.UserName, KeyWord)) { users.Add(user); } } SearchAllUsers allUsers = new SearchAllUsers { AllUsers = users.AsQueryable().OrderBy(u => u.LastName) .Take(MaxSearchPageUsers), UserPageInfo = new SearchUserPageInfo { CurrentPage = 1, TotalUsers = users.AsQueryable().Count(), UsersPerPage = MaxSearchPageUsers } }; //courses for ALL USERS //& presentations List <SearchCourse> courses = new List <SearchCourse>(); List <SearchPresentation> presentations = new List <SearchPresentation>(); List <SearchRepresentation> representations = new List <SearchRepresentation>(); List <SearchVideo> videos = new List <SearchVideo>(); List <SearchFiles> files = new List <SearchFiles>(); foreach (Course course in repository.Courses.Where(c => c.Status == "Public" && (c.CreatedBy.CompanyName == currentUser.CompanyName || c.CreatedBy.CompanyName == null))) { if (SearchWordExists(course.Title, KeyWord)) { SearchCourse searchCourse = new SearchCourse { Course = course, CreatedBy = userManager.Users.FirstOrDefault(u => u.Id == course.CreatedBy.Id) }; courses.Add(searchCourse); } //course video if (repository.Videos.Any(v => v.Id == course.VideoId)) { Video courseVideo = repository.Videos.FirstOrDefault(v => v.Id == course.VideoId); if (SearchWordExists(courseVideo.Title, KeyWord)) { string info = $"<span class='text-muted'>For: <i class='{course.AwardIcon}'></i>" + $"<strong>{course.Title}</strong></span>"; SearchVideo searchVideoC = new SearchVideo { Video = courseVideo, CreatedBy = userManager.Users.FirstOrDefault(u => u.Id == courseVideo.CreatedBy), VideoForInfo = info }; videos.Add(searchVideoC); } } foreach (Presentation presentation in course.Presentations) { if (SearchWordExists(presentation.Title, KeyWord)) { SearchPresentation searchPresentation = new SearchPresentation { Presentation = presentation, Course = course, CreatedBy = userManager.Users.FirstOrDefault(u => u.Id == course.CreatedBy.Id) }; presentations.Add(searchPresentation); } //presentation video if (repository.Videos.Any(v => v.Id == presentation.VideoId)) { Video presentationVideo = repository.Videos.FirstOrDefault(v => v.Id == presentation.VideoId); if (SearchWordExists(presentationVideo.Title, KeyWord)) { string info = $"<span class='text-muted'>For: <strong>{presentation.Title}</strong> <i class='{course.AwardIcon}'></i>" + $"<strong>{course.Title}</strong></span>"; SearchVideo searchVideoP = new SearchVideo { Video = presentationVideo, CreatedBy = userManager.Users.FirstOrDefault(u => u.Id == presentationVideo.CreatedBy), VideoForInfo = info }; videos.Add(searchVideoP); } } //presentation files foreach (PresentationFiles file1 in repository.PresentationFiles .Where(f => f.PresentationId == presentation.PresentationId)) { if (SearchWordExists(file1.Title, KeyWord)) { string info = $"<span class='text-muted'>For: <strong>{presentation.Title}</strong> <i class='{course.AwardIcon}'></i>" + $"<strong>{course.Title}</strong></span>"; SearchFiles searchFile1 = new SearchFiles { File = file1, CreatedBy = userManager.Users.FirstOrDefault(u => u.Id == presentation.CreatedBy.Id), FileForInfo = info }; files.Add(searchFile1); } } foreach (Representation representation in presentation.Representations) { if (SearchWordExists(representation.Title, KeyWord)) { SearchRepresentation searchRepresentation = new SearchRepresentation { Representation = representation, PresentationTitle = presentation.Title, Course = course, Video = repository.Videos.FirstOrDefault(v => v.Id == representation.VideoId), CreatedBy = userManager.Users.FirstOrDefault(u => u.Id == representation.CreatedBy.Id) }; representations.Add(searchRepresentation); } //representation video if (repository.Videos.Any(v => v.Id == representation.VideoId)) { Video representationVideo = repository.Videos.FirstOrDefault(v => v.Id == representation.VideoId); if (SearchWordExists(representationVideo.Title, KeyWord)) { if (repository.VideoShareds.Any(v => v.UserId == currentUser.Id && v.VideoId == representationVideo.Id) || await userManager.IsInRoleAsync(currentUser, "Admin") == true || await userManager.IsInRoleAsync(currentUser, "Manager") == true || representationVideo.CreatedBy == currentUser.Id) { string info = $"<span class='text-muted'>For: <strong>{representation.Title}</strong> <strong>{presentation.Title}</strong> <i class='{course.AwardIcon}'></i>" + $"<strong>{course.Title}</strong></span>"; SearchVideo searchVideoR = new SearchVideo { Video = representationVideo, CreatedBy = userManager.Users.FirstOrDefault(u => u.Id == representationVideo.CreatedBy), VideoForInfo = info }; videos.Add(searchVideoR); } } } } } } //courses where currentUser == course.CreatedBy && status == "Private" //& presentations foreach (Course course in repository.Courses.Where(c => c.Status == "Private" && (c.CreatedBy.CompanyName == currentUser.CompanyName || c.CreatedBy.CompanyName == null))) { if (course.CreatedBy != null) { if (course.CreatedBy.Id == currentUser.Id) { if (SearchWordExists(course.Title, KeyWord)) { SearchCourse searchCourse = new SearchCourse { Course = course, CreatedBy = userManager.Users.FirstOrDefault(u => u.Id == course.CreatedBy.Id) }; courses.Add(searchCourse); } //course video if (repository.Videos.Any(v => v.Id == course.VideoId)) { Video courseVideo = repository.Videos.FirstOrDefault(v => v.Id == course.VideoId); if (SearchWordExists(courseVideo.Title, KeyWord)) { string info = $"<span class='text-muted'>For: <i class='{course.AwardIcon}'></i>" + $"<strong>{course.Title}</strong></span>"; SearchVideo searchVideoC = new SearchVideo { Video = courseVideo, CreatedBy = userManager.Users.FirstOrDefault(u => u.Id == courseVideo.CreatedBy), VideoForInfo = info }; videos.Add(searchVideoC); } } foreach (Presentation presentation in course.Presentations) { if (SearchWordExists(presentation.Title, KeyWord)) { SearchPresentation searchPresentation = new SearchPresentation { Presentation = presentation, Course = course, CreatedBy = userManager.Users.FirstOrDefault(u => u.Id == course.CreatedBy.Id) }; presentations.Add(searchPresentation); } //presentation video if (repository.Videos.Any(v => v.Id == presentation.VideoId)) { Video presentationVideo = repository.Videos.FirstOrDefault(v => v.Id == presentation.VideoId); if (SearchWordExists(presentationVideo.Title, KeyWord)) { string info = $"<span class='text-muted'>For: <strong>{presentation.Title}</strong> <i class='{course.AwardIcon}'></i>" + $"<strong>{course.Title}</strong></span>"; SearchVideo searchVideoP = new SearchVideo { Video = presentationVideo, CreatedBy = userManager.Users.FirstOrDefault(u => u.Id == presentationVideo.CreatedBy), VideoForInfo = info }; videos.Add(searchVideoP); } } //presentation files foreach (PresentationFiles file2 in repository.PresentationFiles .Where(f => f.PresentationId == presentation.PresentationId)) { if (SearchWordExists(file2.Title, KeyWord)) { string info = $"<span class='text-muted'>For: <strong>{presentation.Title}</strong> <i class='{course.AwardIcon}'></i>" + $"<strong>{course.Title}</strong></span>"; SearchFiles searchFile2 = new SearchFiles { File = file2, CreatedBy = userManager.Users.FirstOrDefault(u => u.Id == presentation.CreatedBy.Id), FileForInfo = info }; files.Add(searchFile2); } } } } } } SearchAllCourses allCourses = new SearchAllCourses { AllCourses = courses.AsQueryable().OrderBy(c => c.Course.Title) .Take(MaxSearchPageCourse), CoursePageInfo = new SearchCoursePageInfo { CurrentPage = 1, TotalCourses = courses.AsQueryable().Count(), CoursesPerPage = MaxSearchPageCourse } }; SearchAllPresentation allPresentation = new SearchAllPresentation { AllPresentations = presentations.AsQueryable() .OrderBy(p => p.Presentation.Title) .Take(MaxSearchPagePresentation), PresentationPageInfo = new SearchPresentationPageInfo { CurrentPage = 1, TotalPresentations = presentations.AsQueryable().Count(), PresentationsPerPage = MaxSearchPagePresentation } }; SearchAllRepresentation allRepresentation = new SearchAllRepresentation { AllRepresentation = representations.AsQueryable() .OrderBy(r => r.Representation.Title) .Take(MaxSearchPageRepresentation), RepresentationPageInfo = new SearchRepresentationPageInfo { CurrentPage = 1, TotalRepresentation = representations.AsQueryable().Count(), RepresentationPerPage = MaxSearchPageRepresentation } }; SearchAllVideos allVideos = new SearchAllVideos { AllVideos = videos.AsQueryable() .OrderBy(v => v.Video.Title) .Take(MaxSearchPageVideo), VideoPageInfo = new SearchVideoPageInfo { CurrentPage = 1, TotalVideos = videos.Count(), VideosPerPage = MaxSearchPageVideo } }; SearchAllFiles allFiles = new SearchAllFiles { AllFiles = files.AsQueryable() .OrderBy(f => f.File.Title) .Take(MaxSearchPageFile), FilePageInfo = new SearchFilesPageInfo { CurrentPage = 1, TotalFiles = files.Count(), FilesPerPage = MaxSearchPageFile } }; return(View("Search", new SearchViewModel { KeyWord = KeyWord, Users = allUsers, Courses = allCourses, Presentations = allPresentation, Representations = allRepresentation, Videos = allVideos, Files = allFiles })); }
public void TestSearchFiles() { var files = SearchFiles.DriveSearchFiles(); Assert.AreNotEqual(0, files.Count); }
public async Task IncorrectRegexInput() { await Assert.ThrowsExceptionAsync <TaskCanceledException>(async() => await SearchFiles.SearchByRegex("}{!}@#{!}$!{}!{%%!)%(!_)()$(*!$)(!@#_)!@#", @"C:\\")); await Assert.ThrowsExceptionAsync <TaskCanceledException>(async() => await SearchFiles.SearchByRegex(null, @"C:\\")); var cancelledSearch = SearchFiles.SearchCancelledOrDone; Assert.AreEqual(true, cancelledSearch); Assert.AreEqual(true, ActionForm.CancellationToken.IsCancellationRequested); ActionForm.CancellationToken.Cancel(); }