コード例 #1
0
        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));
        }
コード例 #2
0
 /// <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);
 }
コード例 #3
0
        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;
                }
            }
        }
コード例 #4
0
        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;
        }
コード例 #5
0
        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;
        }
コード例 #6
0
        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);
            }
        }
コード例 #7
0
        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));
        }
コード例 #8
0
        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);
            }
        }
コード例 #9
0
        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);
        }
コード例 #10
0
        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);
        }
コード例 #11
0
        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);
        }
コード例 #12
0
 public void CreateNewProfile(string name)
 {
     SearchProfile     = CreateDefaultProfile(name);
     EmptyProfile      = true;
     NewProfileCreated = true;
 }
コード例 #13
0
 public bool DeleteSearchProfile(SearchProfileModel searchProfile)
 {
     throw new NotImplementedException();
 }
コード例 #14
0
 public Guid InsertSearchProfile(SearchProfileModel searchProfile)
 {
     return(new SearchProfileRepository().InsertSearchProfile(searchProfile));
 }
コード例 #15
0
 public void UpdateSearchProfile(SearchProfileModel searchProfile)
 {
     throw new NotImplementedException();
 }
コード例 #16
0
        public void SaveSearchProfile(SearchProfileModel searchProfile, string filename)
        {
            SearchProfileDataModel searchProfileDataModel = _mapper.Map <SearchProfileDataModel>(searchProfile);

            _storageManager.SerializeObjectToFile(searchProfileDataModel, filename, null);
        }