public void AddAllToMyMovies() { foreach (PossibleNewMovie ai in AddItems.Where(ai => ai.CodeKnown)) { AddToLibrary(ai); } mDoc.SetDirty(); AddItems.Clear(); mDoc.ExportMovieInfo(); }
public void AddAllToMyShows() { foreach (FoundFolder ai in AddItems.Where(ai => !ai.CodeUnknown)) { AddToLibrary(ai); } mDoc.Library.GenDict(); mDoc.SetDirty(); AddItems.Clear(); mDoc.ExportShowInfo(); }
public void AddAllToMyShows() { foreach (PossibleNewTvShow ai in AddItems.Where(ai => !ai.CodeUnknown)) { AddToLibrary(ai); } mDoc.TvLibrary.GenDict(); mDoc.SetDirty(); AddItems.Clear(); mDoc.ExportShowInfo(); }
private void bnRemoveMonFolder_Click(object sender, System.EventArgs e) { for (int i = lstFMMonitorFolders.SelectedIndices.Count - 1; i >= 0; i--) { int n = lstFMMonitorFolders.SelectedIndices[i]; TVSettings.Instance.LibraryFolders.RemoveAt(n); } mDoc.SetDirty(); FillFolderStringLists(); }
public override bool Go(TVRenameStats stats) { // read NTFS permissions (if any) FileSecurity security = null; try { security = From.GetAccessControl(); } catch { // ignored } DoCopyRename(stats); if (To.IsMovieFile()) { //File is correct name LOGGER.Debug($"Just copied {To.FullName} to the right place. Marking it as 'seen'."); //Record this episode as seen TVSettings.Instance.PreviouslySeenEpisodes.EnsureAdded(Episode); if (TVSettings.Instance.IgnorePreviouslySeen) { doc.SetDirty(); } } // set NTFS permissions try { if (security != null) { To.SetAccessControl(security); } } catch { // ignored } TidyUpIfNeeded(); return(!Error); }
public void Fix() { try { IsError = false; ErrorText = string.Empty; FixInternal(); Doc.SetDirty(); } catch (FixCheckException e) { IsError = true; ErrorText = e.Message; LOGGER.Warn($"Error occurred fixing {Explain()}, error was {e.Message} for {MediaName}"); } catch (Exception exception) { IsError = true; ErrorText = exception.Message; LOGGER.Error($"Error occurred fixing {Explain()}, for {MediaName}, error was {exception.Message}"); } }
public override ActionOutcome Go(TVRenameStats stats) { // read NTFS permissions (if any) FileSecurity security = null; try { security = From.GetAccessControl(); } catch { // ignored } try { //we use a temp name just in case we are interrupted or some other problem occurs string tempName = TempFor(To); if (!Directory.Exists(To.Directory.FullName)) { Directory.CreateDirectory(To.Directory.FullName); } // If both full filenames are the same then we want to move it away and back //This deals with an issue on some systems (XP?) that case insensitive moves did not occur if (IsMoveRename() || FileHelper.Same(From, To)) { // This step could be slow, so report progress CopyMoveResult moveResult = File.Move(From.FullName, tempName, MoveOptions.CopyAllowed | MoveOptions.ReplaceExisting, CopyProgressCallback, null); if (moveResult.ErrorCode != 0) { throw new ActionFailedException(moveResult.ErrorMessage); } } else { //we are copying Debug.Assert(Operation == Op.copy); // This step could be slow, so report progress CopyMoveResult copyResult = File.Copy(From.FullName, tempName, CopyOptions.None, true, CopyProgressCallback, null); if (copyResult.ErrorCode != 0) { throw new ActionFailedException(copyResult.ErrorMessage); } } // Copying the temp file into the correct name is very quick, so no progress reporting File.Move(tempName, To.FullName, MoveOptions.ReplaceExisting); LOGGER.Info($"{Name} completed: {From.FullName} to {To.FullName } "); UpdateStats(stats); if (To.IsMovieFile()) { //File is correct name LOGGER.Debug($"Just copied {To.FullName} to the right place. Marking it as 'seen'."); if (Episode != null) { //Record this episode as seen TVSettings.Instance.PreviouslySeenEpisodes.EnsureAdded(SourceEpisode); if (TVSettings.Instance.IgnorePreviouslySeen) { doc.SetDirty(); } } if (Movie != null) { //Record this movie as seen TVSettings.Instance.PreviouslySeenMovies.EnsureAdded(Movie); if (TVSettings.Instance.IgnorePreviouslySeenMovies) { doc.SetDirty(); } } } } catch (Exception e) { LOGGER.Warn(e, $"Error occurred while {Name}: {From.FullName} to {To.FullName } "); return(new ActionOutcome(e)); } // set NTFS permissions try { if (security != null) { To.SetAccessControl(security); } } catch { // ignored } try { if (Operation == Op.move && Tidyup != null && Tidyup.DeleteEmpty) { LOGGER.Info($"Testing {From.Directory.FullName} to see whether it should be tidied up"); DoTidyUp(From.Directory); } } catch (Exception e) { return(new ActionOutcome(e)); } return(ActionOutcome.Success()); }
private static TVDoc LoadSettings([NotNull] CommandLineArgs clargs) { bool recover = false; string recoverText = string.Empty; // Check arguments for forced recover if (clargs.ForceRecover) { recover = true; recoverText = "Recover manually requested."; } SetupCustomSettings(clargs); FileInfo tvdbFile = PathManager.TVDBFile; FileInfo settingsFile = PathManager.TVDocSettingsFile; TVDoc doc; do // Loop until files correctly load { if (recover) // Recovery required, prompt user { /* RecoverXml recoveryForm = new RecoverXml(recoverText); * * if (recoveryForm.ShowDialog() == DialogResult.OK) * { * tvdbFile = recoveryForm.DbFile; * settingsFile = recoveryForm.SettingsFile; * } * else * { * Logger.Error("User requested no recovery"); * throw new TVRenameOperationInterruptedException(); * }*/ } // Try loading settings file doc = new TVDoc(settingsFile, clargs); // Try loading TheTVDB cache file TheTVDB.Instance.Setup(doc.Library, tvdbFile, PathManager.TVDBFile, clargs); if (recover) { doc.SetDirty(); } recover = !doc.LoadOk; // Continue if correctly loaded if (!recover) { continue; } // Set recover message recoverText = string.Empty; if (!doc.LoadOk && !string.IsNullOrEmpty(doc.LoadErr)) { recoverText = doc.LoadErr; } if (!TheTVDB.Instance.LoadOk && !string.IsNullOrEmpty(TheTVDB.Instance.LoadErr)) { recoverText += $"{Environment.NewLine}{TheTVDB.Instance.LoadErr}"; } } while (recover); return(doc); }
private void bnOK_Click(object sender, EventArgs e) { TVSettings.Instance.Ignore = ignore; mDoc.SetDirty(); Close(); }
private static int Main(string[] args) { // Enabling Windows XP visual effects before any controls are created Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); // Sort out the command line arguments CommandLineArgs clargs = new CommandLineArgs(args); // see if we're already running bool createdNew = false; System.Threading.Mutex mutex = new System.Threading.Mutex(true, "TVRenameMutex", out createdNew); if (!createdNew) { // we're already running // tell the already running copy to come to the foreground IpcClientChannel clientChannel = new IpcClientChannel(); ChannelServices.RegisterChannel(clientChannel, true); RemotingConfiguration.RegisterWellKnownClientType(typeof (IPCMethods), "ipc://TVRenameChannel/IPCMethods"); IPCMethods ipc = new IPCMethods(); // if we were already running, and no command line arguments, then bring application to the foreground // and we're done. if (args.Length == 0) { ipc.BringToForeground(); return 0; } // Send command-line arguments to already running TVRename via IPC CommandLineArgs.MissingFolderBehaviour before = ipc.MissingBehaviour; bool renameBefore = ipc.RenameBehaviour; if (clargs.RenameCheck == false) { // Temporarily override behaviour for missing folders ipc.RenameBehaviour = false; } if (clargs.MissingFolder != CommandLineArgs.MissingFolderBehaviour.Ask) { // Temporarily override behaviour for missing folders ipc.MissingBehaviour = clargs.MissingFolder; } // TODO: Unify command line handling between here and in UI.cs (ProcessArgs). Just send in clargs via IPC? if (clargs.Scan || clargs.DoAll) // doall implies scan ipc.Scan(); if (clargs.DoAll) ipc.DoAll(); if (clargs.Quit) { ipc.Quit(); return 0; } ipc.RenameBehaviour = renameBefore; ipc.MissingBehaviour = before; return 0; } #if !DEBUG try { #endif // Starting TVRename... // Check arguments for forced recover bool ok = true; string recoverText = ""; if (clargs.ForceRecover) { ok = false; // force recover dialog recoverText = "Recover manually requested."; } // Load settings files TVDoc doc = null; try { if (!string.IsNullOrEmpty(clargs.UserFilePath)) PathManager.SetUserDefinedBasePath(clargs.UserFilePath); } catch (System.Exception ex) { MessageBox.Show("Error while setting the User-Defined File Path:" + Environment.NewLine + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); Environment.Exit(1); } FileInfo tvdbFile = PathManager.TVDBFile; FileInfo settingsFile = PathManager.TVDocSettingsFile; do // loop until no problems loading settings & tvdb cache files { if (!ok) // something went wrong last time around, ask the user what to do { RecoverXML rec = new RecoverXML(recoverText); if (rec.ShowDialog() == DialogResult.OK) { tvdbFile = rec.DBFile; settingsFile = rec.SettingsFile; } else return 1; } // try loading using current settings files, and set up the main // classes TheTVDB.Instance.setup(tvdbFile, PathManager.TVDBFile, clargs); doc = new TVDoc(settingsFile, clargs); if (!ok) doc.SetDirty(); ok = doc.LoadOK; if (!ok) { recoverText = ""; if (!doc.LoadOK && !String.IsNullOrEmpty(doc.LoadErr)) recoverText += doc.LoadErr; if (!TheTVDB.Instance.LoadOK && !String.IsNullOrEmpty(TheTVDB.Instance.LoadErr)) recoverText += "\r\n" + TheTVDB.Instance.LoadErr; } } while (!ok); // Show user interface UI theUI = new UI(doc); Application.Run(theUI); GC.KeepAlive(mutex); #if !DEBUG } catch (Exception e) { ShowException se = new ShowException(e); se.ShowDialog(); } #endif return 0; }