Ejemplo n.º 1
0
 static void Main()
 {
     string[] args = Environment.GetCommandLineArgs();
     if (args.Count() > 1) {
         if (UACHelperFunctions.UACHelper.IsAdmin()) {
             Load.FilesCache = Load.FilesCache.LoadFromDisk<Dictionary<UInt32, Item>>(
                 Path.Combine(Application.UserAppDataPath, "FilesCache"));
             Settings settings = new Settings();
             settings =
                 settings.LoadFromDisk<Settings>(Path.Combine(Application.UserAppDataPath,
                                                              "Settings"));
             Dictionary<string, List<string>> aprioriData = new Dictionary<string, List<string>>();
             var allEnabledItems = (from directory in settings.EnabledDirectories select directory.Items).SelectMany(item => item).ToList();
             foreach (Item item in allEnabledItems) {
                 aprioriData[item.Path] = (from tag in item.Tags select tag.Name).ToList();
             }
             Apriori.Apriori apriori = new Apriori.Apriori(aprioriData, 5);
             var frequentSets = apriori.getFrequentSets();
             var filesToSort = from file in allEnabledItems where file.Invalidated select file;
             foreach (Item file in filesToSort) {
                 TreeHelper.createSortedTree(file, frequentSets, settings);
             }
             Load.FilesCache.SaveToDisk(Path.Combine(Application.UserAppDataPath, "FilesCache"));
             Application.Exit();
             return;
         }
     }
     Application.EnableVisualStyles();
     Application.SetCompatibleTextRenderingDefault(false);
     Application.Run(new TwilightSortle());
 }
Ejemplo n.º 2
0
 private void updateSortedTree()
 {
     if (!UACHelper.IsAdmin()) {
         runLongOperation(save, null, "Saving data...");
         Action runOperationAction = (() => UACHelper.RunApplicationAsAdmin(Application.ExecutablePath, "CreateTree", true));
         runLongOperation(runOperationAction, (() => beginLoad()), "Updating Sorted Tree");
         return;
     }
     List<List<string>> frequentSets = null;
     IEnumerable<Item> filesToSort = null;
     Action action = (() => {
         Dictionary<string, List<string>> aprioriData = new Dictionary<string, List<string>>();
         foreach (Item item in allEnabledItems()) {
             aprioriData[item.Path] = (from tag in item.Tags select tag.Name).ToList();
         }
         Apriori.Apriori apriori = new Apriori.Apriori(aprioriData, 5);
         frequentSets = apriori.getFrequentSets();
         filesToSort = from file in allEnabledItems() where file.Invalidated select file;
     });
     runLongOperation(action, null, "Processing tag data");
     Action makeTree = (() => {
         foreach (Item file in filesToSort) {
             TreeHelper.createSortedTree(file, frequentSets, settings);
         }
     });
     Action after = refreshListingWithSearch;
     runLongOperation(makeTree, after, "Updating sorted tree");
 }