/// <summary> /// Initializes the specified should refresh. /// </summary> /// <param name="shouldRefresh"> /// if set to <c>true</c>, scan the addin probe directories for new and updated addins every time the application starts up. /// otherwise, initialize the addin framework directly. /// </param> public void Initialize(bool shouldRefresh) { if (_initialized) { return; } var storage = CreateStorage(_adnConfig.FileConfiguration); _indexManager = new IndexManager { Storage = storage }; _bodyRepo = new BodyRepository { Storage = storage }; var hasExistingAddins = _indexManager.Read(); // remove addins waiting for delete. ProcessPendingAddins(); if (shouldRefresh || !hasExistingAddins) { // get addin file packs. // excluding: those files that have been scanned last time, if they are unchanged var filePackResult = GetFilePackResult(); if (filePackResult != null) { //storage.Close(); // close the persistence file first if (BuildDatabase(filePackResult)) { storage = StorageHelper.CreateStorage (_adnConfig.FileConfiguration.PersistentFile, _adnConfig.FileConfiguration.TransactionFile); _indexManager.Storage = storage; _bodyRepo.Storage = storage; hasExistingAddins = _indexManager.Read(); if (hasExistingAddins) { _indexManager.Build(); } _bodyRepo.ResetCache(); } } else if (hasExistingAddins) { _indexManager.Build(); } } else { _indexManager.Build(); } _initialized = true; }
static void Main(string[] args) { OPT.LoadSettings(); DesCipher = new XDes(OPT.GetString("des.key")); clientList = new Dictionary <int, Client>(); Console.WriteLine("Indexing legacy file names..."); OPT.LoadLegacyFiles(); Console.WriteLine("\t- {0} legacy files indexed!", OPT.LegacyCount); Console.WriteLine("Indexing delete file names..."); OPT.LoadDeleteFiles(); Console.WriteLine("\t- {0} delete files indexed!", OPT.DeleteCount); IndexManager.Build(false); Console.Write("Checking for tmp directory..."); if (!Directory.Exists(tmpPath)) { Directory.CreateDirectory(tmpPath); } Console.Write("[OK]\n\t- Cleaning up temp files..."); int cleanedCount = 0; foreach (string filePath in Directory.GetFiles(tmpPath)) { File.Delete(filePath); cleanedCount++; } Console.WriteLine("[OK] ({0} files cleared!)", cleanedCount); Console.Write("Initializing client listener... "); if (ClientManager.Instance.Start()) { Console.WriteLine("[OK]"); } Console.Write("Initializing Index Rebuild Service..."); int rebuildInterval = OPT.GetInt("rebuild.interval") * 1000; indexTimer = new Timer(indexTick, null, rebuildInterval, rebuildInterval); Console.WriteLine("[OK]"); Console.Write("Initializing OTP Reset Service..."); otpTimer = new Timer(otpTick, null, 0, 300000); Console.WriteLine("[OK]"); Console.ReadLine(); }
// @return value: whether the persistence file (AddinIndexManager/AddinBodyRepository) has been updated. public bool Resolve(IMessageDialog dialog, FilePackResult filePackResult, string persistentFile, string transactionFile) { var storage = StorageHelper.CreateStorage(persistentFile, transactionFile); var indexManager = new IndexManager { Storage = storage }; if (indexManager.Read()) { indexManager.Build(); } var bodyRepo = new BodyRepository { Storage = storage }; var convertionManager = new ConvertionManager(); InitializeConvertion(convertionManager); var resolver = new DefaultAddinResolver(indexManager, bodyRepo, convertionManager); var hasNewAddin = resolver.Resolve(dialog, filePackResult); //storage.Close(); return(hasNewAddin); }
private async void GUI_Shown(object sender, EventArgs e) { OPT.LoadSettings(); DesCipher = new XDes(OPT.GetString("des.key")); Statistics.SetIO(); Statistics.StartUptime(); clientList = new Dictionary <int, Client>(); Output.Write(new Structures.Message() { Text = "Indexing legacy file names..." }); OPT.LoadLegacyIndex(); Output.Write(new Structures.Message() { Text = string.Format("[OK]\n\t- {0} legacy files indexed!", OPT.LegacyCount), AddBreak = true }); Output.Write(new Structures.Message() { Text = "Indexing delete file names..." }); OPT.LoadDeleteFiles(); Output.Write(new Structures.Message() { Text = string.Format("[OK]\n\t- {0} delete files indexed!", OPT.DeleteCount), AddBreak = true }); await Task.Run(() => { IndexManager.Build(false); }); Output.Write(new Structures.Message() { Text = "Checking for tmp directory..." }); if (!Directory.Exists(tmpPath)) { Directory.CreateDirectory(tmpPath); } Output.Write(new Structures.Message() { Text = "[OK]", AddBreak = true }); clearTmp(); Output.Write(new Structures.Message() { Text = string.Format("Initializing client listener...{0}", (ClientManager.Instance.Start()) ? "[OK]" : "[FAIL]"), AddBreak = true }); Output.Write(new Structures.Message() { Text = "Initializing Index Rebuild Service..." }); int rebuildInterval = OPT.GetInt("rebuild.interval") * 1000; indexTimer = new Timer() { Enabled = true, Interval = rebuildInterval }; indexTimer.Tick += indexTick; indexTimer.Start(); Output.Write(new Structures.Message() { Text = "[OK]", AddBreak = true }); Output.Write(new Structures.Message() { Text = "Initializing OTP Reset Service..." }); otpTimer = new Timer() { Enabled = true, Interval = 300000 }; otpTimer.Tick += otpTick; Output.Write(new Structures.Message() { Text = "[OK]", AddBreak = true }); Output.Write(new Structures.Message() { Text = "Initializing Statistics Update Service..." }); Statistics.StartUpdating(); Output.Write(new Structures.Message() { Text = "[OK]", AddBreak = true }); toolTip.SetToolTip(setWTBtn, "Sets the Updates folder last write time to the current time"); }
private void indexTick(object sender, EventArgs e) { IndexManager.Build(true); }
private static async void indexTick(object state) { await Task.Run(() => { IndexManager.Build(true); }); }