public ActionResult Create() { IList <ThemeModel> temas = new ThemeService().GetActiveThemes(); IList <TopicsViewModel> _topics = new List <TopicsViewModel>(); IList <TopicModel> topics = new TopicService().GetActiveTopics() .OrderBy(x => x.Theme.Name) .ToList(); topics.ToList().ForEach(x => _topics.Add(new TopicsViewModel { Name = x.Name, Check = false, Id = x.Id, ThemeId = x.Theme.Id, ThemeName = x.Theme.Name })); SearchProfileModel model = new SearchProfileModel { SearchProfileCheckBoxs = _topics }; return(View(model)); }
/// <summary> /// Initializes a new instance of the <see cref="AutoMapperProfile"/> class. /// </summary> public AutoMapperProfile() { SearchProfileModel.CreateMappings(this); ApplicationSettingsModel.CreateMappings(this); //ComputedFileHashModel.CreateMappings(this); //FileHashCollection.CreateMappings(this); }
public Guid InsertSearchProfile(SearchProfileModel searchProfile) { using (AppTourEntities data = new AppTourEntities()) { try { SEARCH_PROFILE novo = new SEARCH_PROFILE { ID = searchProfile.Id == null || searchProfile.Id == Guid.Empty ? Guid.NewGuid() : searchProfile.Id, NAME = searchProfile.Name, POINTS_RANGE_DISTANCE = searchProfile.PointsRangeDistance, SEARCH_CRITERIA = searchProfile.SearchCriteria, EVENTS_SEARCH_DAYS = searchProfile.EventsSearchDays, CREATION_DATE = DateTime.Now, UPDATE_DATE = DateTime.Now, IS_ACTIVE = searchProfile.IsActive, USER = data.USER.Single(x => x.ID == searchProfile.Utilizador.Id) }; if (searchProfile.SearchProfileTopics != null && searchProfile.SearchProfileTopics.Count() > 0) { // Adicionar Atributos searchProfile.SearchProfileTopics.ToList().ForEach(x => novo.SEARCH_PROFILE_TOPIC.Add(new SEARCH_PROFILE_TOPIC { ID = Guid.NewGuid(), TOPIC = data.TOPIC.SingleOrDefault(y => y.ID == x.Id), SEARCH_PROFILE = novo })); } // Guardar tudo data.SEARCH_PROFILE.AddObject(novo); data.SaveChanges(); return(novo.ID); } catch (UpdateException upd) { throw new UpdateException(upd.InnerException.Message); } catch (Exception e) { if (e.InnerException != null) { throw new ApplicationException(e.InnerException.Message); } throw; } } }
public void LoadeScanFolderList(List <ScanFolderModel> scanFolderList) { if (scanFolderList == null) { throw new ArgumentNullException(nameof(scanFolderList)); } //This seems very unlikely if (SearchProfile == null) { SearchProfile = CreateDefaultProfile("New Profile"); } SearchProfile.ScanFolderList = scanFolderList; }
public void LoadPreferredDirecoryList(List <PreferredDirectoryDataModel> preferredDirectories) { if (preferredDirectories == null) { throw new ArgumentNullException(nameof(preferredDirectories)); } //This seems very unlikely if (SearchProfile == null) { SearchProfile = CreateDefaultProfile("New Profile"); } SearchProfile.PreferredDirecoryList = preferredDirectories; }
public SearchProfileModel GetSearchProfile(Guid SearchProfileID) { using (AppTourEntities data = new AppTourEntities()) { SearchProfileModel profile = this.GetSearchProfiles(data).SingleOrDefault(x => x.Id == SearchProfileID); if (profile == null) { return(null); } profile.SearchProfileTopics = new TopicRepository().GetTopicsForSearchProfile(SearchProfileID); return(profile); } }
public ActionResult Create(SearchProfileModel model) { if (model.IsValid) { try { string userName = this.Session["USERNAME"].ToString(); if (model.SearchProfileCheckBoxs.Where(x => x.Check).Count() == 0) { ModelState.AddModelError("", "Must choose a topic, at least!"); return(View(model)); } model.SearchProfileTopics = new List <TopicModel>(); model.Utilizador = new UserService().GetUser(userName); model.IsActive = true; foreach (TopicsViewModel item in model.SearchProfileCheckBoxs.Where(x => x.Check)) { model.SearchProfileTopics.Add(new TopicService().GetTopic(item.Id)); } service.InsertSearchProfile(model); return(RedirectToAction("Profile", "Account", new { id = userName })); } catch (Exception e) { ModelState.AddModelError("", e.Message); } } IList <ThemeModel> temas = new ThemeService().GetActiveThemes(); IList <TopicsViewModel> _topics = new List <TopicsViewModel>(); IList <TopicModel> topics = new TopicService().GetActiveTopics().OrderBy(x => x.Theme.Name).ToList(); topics.ToList().ForEach(x => _topics.Add(new TopicsViewModel { Name = x.Name, Check = false, Id = x.Id, ThemeId = x.Theme.Id, ThemeName = x.Theme.Name })); model = new SearchProfileModel { SearchProfileCheckBoxs = _topics }; ModelState.AddModelError("", model.Error); return(View(model)); }
private async void SearchForDuplicateFiles() { if (!_duplicateFileFinder.IsReady) { MessageBox.Show(Display.frmMain_SearchForDuplicateFiles_ComputeHashServUnavailable, Display.frmMain_SearchForDuplicateFiles_DatabaseIsLoading, MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (_scanFolders.Count == 0) { MessageBox.Show(Generics.PleaseSelectAValidDirectory); return; } string filenameFilter = txtFilenameFilter.Text; if (filenameFilter == "") { filenameFilter = null; } try { lbResults.DataSource = null; _hashComputeCount = 0; // ReSharper disable once LocalizableElement standard value lblSearchResults.Text = "0"; txtMasterFilename.Text = ""; lbDuplicateFiles.DataSource = null; UpdateMenuItemState(); var searchProfile = new SearchProfileModel(filenameFilter, _scanFolders.ToList(), new List <PreferredDirectoryDataModel> ()) { IncludeSubfolders = chkIncludeSubfolders.Checked }; await _duplicateFileFinder.StartDuplicateSearchAsync(searchProfile); Invoke(new EventHandler(duplicateFileFinder_OnSearchCompleteNativeThread), this, new EventArgs()); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public bool LoadSearchProfile(string filepath) { try { var profile = _profileRepository.LoadSearchProfileFromFile(filepath); if (profile != null) { SearchProfile = profile; return(true); } } catch (Exception e) { Log.Error(e, "LoadSearchProfile failed for file: {filepath}", filepath); } return(false); }
public Guid InsertUser(UserModel user) { Guid userId = new UserRepository().InsertUser(user); SearchProfileModel myDefaultSearchProfile = new SearchProfileModel { Id = Guid.NewGuid(), Name = "Default", EventsSearchDays = 10, IsActive = true, PointsRangeDistance = 5, SearchCriteria = string.Empty, Utilizador = GetUser(userId), SearchProfileTopics = new TopicService().GetActiveTopics() }; Guid id = new SearchProfileService().InsertSearchProfile(myDefaultSearchProfile); return(userId); }
public async Task <bool> StartDuplicateSearchAsync(SearchProfileModel searchProfile) { if (IsRunning) { return(false); } IsRunning = true; _searchingRequested = true; // Find all relevant files in scanfolderList //List<DuplicateFileModel> duplicateFileCandidateList= new List<DuplicateFileModel>(); ParallelOptions parallelOptions = new ParallelOptions(); var cancelationToken = parallelOptions.CancellationToken; parallelOptions.MaxDegreeOfParallelism = Environment.ProcessorCount; ISearchSettings searchSettings = new SearchSettings { DirectoryList = searchProfile.ScanFolderList, FileExtentionFilter = searchProfile.FileNameFilter, IncludeSubdirs = searchProfile.IncludeSubfolders }; DistributedFileScanner fileScanner = new DistributedFileScanner(); BlockingCollection <List <DuplicateFileModel> > duplicateFileCandidateList = new BlockingCollection <List <DuplicateFileModel> >(); int index = 0; OnSearchBegin?.Invoke(this, EventArgs.Empty); Parallel.ForEach(searchSettings.DirectoryList, parallelOptions, folder => { Console.WriteLine(Interlocked.Increment(ref index)); Console.WriteLine(Thread.CurrentThread.ManagedThreadId); var result = fileScanner.GetFilesFromBaseDirectory(folder.FullPath, searchSettings, OnProgressUpdate); duplicateFileCandidateList.Add(result, cancelationToken); }); return(true); }
public void CreateNewProfile(string name) { SearchProfile = CreateDefaultProfile(name); EmptyProfile = true; NewProfileCreated = true; }
public bool DeleteSearchProfile(SearchProfileModel searchProfile) { throw new NotImplementedException(); }
public Guid InsertSearchProfile(SearchProfileModel searchProfile) { return(new SearchProfileRepository().InsertSearchProfile(searchProfile)); }
public void UpdateSearchProfile(SearchProfileModel searchProfile) { throw new NotImplementedException(); }
public void SaveSearchProfile(SearchProfileModel searchProfile, string filename) { SearchProfileDataModel searchProfileDataModel = _mapper.Map <SearchProfileDataModel>(searchProfile); _storageManager.SerializeObjectToFile(searchProfileDataModel, filename, null); }