/// <summary> /// Action log loading work /// </summary> private static void LoadActionLog(object sender, DoWorkEventArgs e) { try { string path = Path.Combine(GetBasePath(false), ACTION_LOG_XML + ".xml"); if (File.Exists(path)) lock (ActionLogFileLock) { // Load XML XmlTextReader reader = new XmlTextReader(path); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(reader); // Load movies data List<OrgItem> loadActionLog = new List<OrgItem>(); XmlNodeList logNodes = xmlDoc.DocumentElement.ChildNodes; for (int i = 0; i < logNodes.Count; i++) { OnActionLogLoadProgressChange((int)(((double)i / logNodes.Count) * 100)); OrgItem item = new OrgItem(); if (item.Load(logNodes[i])) loadActionLog.Add(item); } reader.Close(); OnActionLogLoadProgressChange(100); lock (ActionLogLock) { ActionLog.Clear(); foreach (OrgItem item in loadActionLog) ActionLog.Add(item); } } } catch { } OnActionLogLoadComplete(); }
/// <summary> /// Action log loading work /// </summary> public static void LoadScanDirLog(object sender, DoWorkEventArgs e) { try { string path = Path.Combine(GetBasePath(false), DIR_SCAN_LOG_XML + ".xml"); List<OrgItem> loadScanDirLog = new List<OrgItem>(); if (File.Exists(path)) { lock (DirScanLogFileLock) { // Load XML XmlTextReader reader = new XmlTextReader(path); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(reader); // Load movies data XmlNodeList logNodes = xmlDoc.DocumentElement.ChildNodes; for (int i = 0; i < logNodes.Count; i++) { OrgItem item = new OrgItem(); if (item.Load(logNodes[i])) { if (File.Exists(item.SourcePath)) { for (int j = 0; j < Settings.ScanDirectories.Count; j++) if (item.sourcePath.ToLower().Contains(Settings.ScanDirectories[j].FolderPath.ToLower())) { loadScanDirLog.Add(item); break; } } } } reader.Close(); } lock (DirScanLogLock) { DirScanLog.Clear(); foreach (OrgItem item in loadScanDirLog) DirScanLog.Add(item); } } } catch { } }