Skip to content

Commit

Permalink
Merge pull request #189 from MarkSummerville/master
Browse files Browse the repository at this point in the history
Fixed #182
  • Loading branch information
SirSparkles authored Dec 22, 2017
2 parents 9f11d10 + b81ceb9 commit 2b591e7
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 24 deletions.
1 change: 1 addition & 0 deletions TVRename#/App/AutoFolderMonitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ void mScanDelayTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
//We only wish to do a scan now if we are not already undertaking one
if (!mDoc.CurrentlyBusy)
{
logger.Info("*******************************");
logger.Info("Auto scan fired");
if (mUI != null)
{
Expand Down
8 changes: 8 additions & 0 deletions TVRename#/App/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,13 @@

public static class GlobalMembersTVRename
{

private static NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();

[STAThread]
private static int Main(string[] args)
{
logger.Info("TV Rename Started with args: {0}",args);
// Enabling Windows XP visual effects before any controls are created
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Expand All @@ -39,6 +43,7 @@ private static int Main(string[] args)
if (!createdNew)
{
// we're already running
logger.Warn("TV Rename is alrady running");

// tell the already running copy to come to the foreground
IpcClientChannel clientChannel = new IpcClientChannel();
Expand Down Expand Up @@ -120,6 +125,9 @@ private static int Main(string[] args)
catch (System.Exception ex)
{
MessageBox.Show("Error while setting the User-Defined File Path:" + Environment.NewLine + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
logger.Error("Error while setting the User-Defined File Path - EXITING: {0}",clargs.UserFilePath);
logger.Error(ex);

Environment.Exit(1);
}

Expand Down
5 changes: 4 additions & 1 deletion TVRename#/Forms/UI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2404,6 +2404,8 @@ public void SelectShow(ShowItem si)

private void bnMyShowsAdd_Click(object sender, System.EventArgs e)
{
logger.Info("****************");
logger.Info("Adding New Show");
this.MoreBusy();
ShowItem si = new ShowItem();
TheTVDB.Instance.GetLock( "AddShow");
Expand All @@ -2419,8 +2421,9 @@ private void bnMyShowsAdd_Click(object sender, System.EventArgs e)
ser.ShowTimeZone = aes.ShowTimeZone;
this.ShowAddedOrEdited(true);
this.SelectShow(si);
logger.Info("Added new show called {0}",ser.Name );
} else logger.Info("Cancelled adding new show");

}
this.LessBusy();
}

Expand Down
4 changes: 2 additions & 2 deletions TVRename#/Settings/Statistics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ private static TVRenameStats LoadFrom(String filename)
}
catch (Exception e)
{
logger.Fatal(e.Message + " " + e.StackTrace);
return null;
logger.Fatal(e);
return new TVRenameStats();
}

return sc;
Expand Down
5 changes: 4 additions & 1 deletion TVRename#/TVRename/TVDoc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -301,10 +301,13 @@ public bool MonitorFolderHasSeasonFolders(DirectoryInfo di, out string folderNam
return true;
}
}
catch (UnauthorizedAccessException)
catch (UnauthorizedAccessException uae)
{
// e.g. recycle bin, system volume information
logger.Warn(uae, "Could not access {0} (or a subdir), may not be an issue as could be expected e.g. recycle bin, system volume information",di.FullName);
}


folderName = null;
return false;
}
Expand Down
46 changes: 26 additions & 20 deletions TVRename#/Utility/Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,9 @@ public static class RegistryHelper {

private const string InternetExplorerRootKey = @"Software\Microsoft\Internet Explorer";
private const string BrowserEmulationKey = InternetExplorerRootKey + @"\Main\FeatureControl\FEATURE_BROWSER_EMULATION";

private static NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();

private enum BrowserEmulationVersion
{
Default = 0,
Expand Down Expand Up @@ -397,13 +400,15 @@ private static int GetInternetExplorerMajorVersion()
}
}
}
catch (SecurityException)
catch (SecurityException se)
{
// The user does not have the permissions required to read from the registry key.
logger.Error(se);
}
catch (UnauthorizedAccessException)
catch (UnauthorizedAccessException uae)
{
// The user does not have the necessary registry rights.
logger.Error(uae);
}

return result;
Expand Down Expand Up @@ -434,13 +439,15 @@ private static BrowserEmulationVersion GetBrowserEmulationVersion()
}
}
}
catch (SecurityException)
catch (SecurityException se)
{
// The user does not have the permissions required to read from the registry key.
logger.Error(se);
}
catch (UnauthorizedAccessException)
catch (UnauthorizedAccessException uae)
{
// The user does not have the necessary registry rights.
logger.Error(uae);
}

return result;
Expand Down Expand Up @@ -473,23 +480,27 @@ private static bool SetBrowserEmulationVersion(BrowserEmulationVersion browserEm
{
// if it's a valid value, update or create the value
key.SetValue(programName, (int)browserEmulationVersion, RegistryValueKind.DWord);
logger.Warn("SETTING REGISTRY:{0}-{1}-{2}-{3}",key.Name,programName, (int)browserEmulationVersion, RegistryValueKind.DWord.ToString());
}
else
{
// otherwise, remove the existing value
key.DeleteValue(programName, false);
logger.Warn("DELETING REGISTRY KEY:{0}-{1}", key.Name, programName);
}

result = true;
}
}
catch (SecurityException)
catch (SecurityException se)
{
// The user does not have the permissions required to read from the registry key.
logger.Error(se);
}
catch (UnauthorizedAccessException)
catch (UnauthorizedAccessException uae)
{
// The user does not have the necessary registry rights.
logger.Error(uae);
}

return result;
Expand All @@ -501,6 +512,7 @@ private static bool SetBrowserEmulationVersion()
BrowserEmulationVersion emulationCode;

ieVersion = GetInternetExplorerMajorVersion();
logger.Warn("IE Version {0} is identified",ieVersion );

if (ieVersion >= 11)
{
Expand Down Expand Up @@ -532,6 +544,7 @@ public static void UpdateBrowserEmulationVersion()
{
if (!IsBrowserEmulationSet())
{
logger.Warn("Updating the registry to ensure that the latest browser version is used");
SetBrowserEmulationVersion();
}
}
Expand All @@ -542,6 +555,7 @@ public static void UpdateBrowserEmulationVersion()
public static class Helpers
{

private static NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();

public static string pad(int i)
{
Expand Down Expand Up @@ -574,26 +588,18 @@ public static bool SysOpen(string what, string arguments = null)
System.Diagnostics.Process.Start(what, arguments);
return true;
}
catch
catch (Exception e)
{
logger.Error(e);
return false;
}
}

public static Color WarningColor()
{
return Color.FromArgb(255, 210, 210);
}
public static Color WarningColor() => Color.FromArgb(255, 210, 210);

public static bool Contains(string source, string toCheck, StringComparison comp)
{
return source.IndexOf(toCheck, comp) >= 0;
}

public static string TranslateColorToHtml(Color c)
{
return String.Format("#{0:X2}{1:X2}{2:X2}", c.R, c.G, c.B);
}
public static bool Contains(string source, string toCheck, StringComparison comp) => source.IndexOf(toCheck, comp) >= 0;

public static string TranslateColorToHtml(Color c) =>String.Format("#{0:X2}{1:X2}{2:X2}", c.R, c.G, c.B);

public static string SimplifyName(string n)
{
Expand Down

0 comments on commit 2b591e7

Please sign in to comment.