diff --git a/Office365APIEditor/App.config b/Office365APIEditor/App.config
index 17bdd95..f99a451 100644
--- a/Office365APIEditor/App.config
+++ b/Office365APIEditor/App.config
@@ -133,6 +133,9 @@
+
+ False
+
diff --git a/Office365APIEditor/Program.cs b/Office365APIEditor/Program.cs
index 4ff11e6..882a634 100644
--- a/Office365APIEditor/Program.cs
+++ b/Office365APIEditor/Program.cs
@@ -23,7 +23,7 @@ namespace Office365APIEditor
private void OnFormClosed(object sender, FormClosedEventArgs e)
{
- Util.WriteCustomLog("Office365APIEditor Closing Log", "Exit. Code 20");
+ Util.WriteSystemLog("Office365APIEditor Closing Log", "Exit. Code 20");
if (!string.IsNullOrEmpty(Properties.Settings.Default.NewerInstallerPath) && File.Exists(Properties.Settings.Default.NewerInstallerPath))
{
@@ -76,6 +76,11 @@ namespace Office365APIEditor
}
}
+ // Turn off SystemLogging flag.
+ startupLog.AppendLine("Disable SystemLogging as default.");
+ Properties.Settings.Default.SystemLogging = false;
+ Properties.Settings.Default.Save();
+
// Check the command line switches.
startupLog.AppendLine("CommandLine : " + Environment.CommandLine);
string[] switches = Environment.GetCommandLineArgs();
@@ -94,11 +99,11 @@ namespace Office365APIEditor
{
// Remove Run History file.
startupLog.AppendLine("The history file will be delete.");
- if (File.Exists(Path.Combine(Util.DefaultApplicationPath, "RunHistory.xml")))
+ if (File.Exists(Util.RunHistoryPath))
{
try
{
- File.Delete(Path.Combine(Util.DefaultApplicationPath, "RunHistory.xml"));
+ File.Delete(Util.RunHistoryPath);
startupLog.AppendLine("The history file was deleted.");
}
catch(Exception ex)
@@ -120,6 +125,13 @@ namespace Office365APIEditor
Properties.Settings.Default.Save();
startupLog.AppendLine("CustomDefinedScopes setting was saved.");
}
+ else if (command.ToLower() == ("/SystemLogging").ToLower())
+ {
+ // Turn on SystemLogging flag.
+ startupLog.AppendLine("Enable SystemLogging.");
+ Properties.Settings.Default.SystemLogging = true;
+ Properties.Settings.Default.Save();
+ }
}
// Set default log folder path.
@@ -134,7 +146,7 @@ namespace Office365APIEditor
}
// Write startup log.
- Util.WriteCustomLog("Office365APIEditor startup log", startupLog.ToString());
+ Util.WriteSystemLog("Office365APIEditor startup log", startupLog.ToString());
// Create the MyApplicationContext, that derives from ApplicationContext,
// that manages when the application should exit.
@@ -182,7 +194,7 @@ namespace Office365APIEditor
}
finally
{
- Util.WriteCustomLog("Office365APIEditor Closing Log", "Exit. Code 10");
+ Util.WriteSystemLog("Office365APIEditor Closing Log", "Exit. Code 10");
}
}
diff --git a/Office365APIEditor/Properties/AssemblyInfo.cs b/Office365APIEditor/Properties/AssemblyInfo.cs
index e8883a3..8ba9260 100644
--- a/Office365APIEditor/Properties/AssemblyInfo.cs
+++ b/Office365APIEditor/Properties/AssemblyInfo.cs
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("0.10.6.0")]
-[assembly: AssemblyFileVersion("0.10.6.0")]
+[assembly: AssemblyVersion("0.10.6.1")]
+[assembly: AssemblyFileVersion("0.10.6.1")]
diff --git a/Office365APIEditor/Properties/Settings.Designer.cs b/Office365APIEditor/Properties/Settings.Designer.cs
index 0f8f23f..1ca82ce 100644
--- a/Office365APIEditor/Properties/Settings.Designer.cs
+++ b/Office365APIEditor/Properties/Settings.Designer.cs
@@ -542,5 +542,17 @@ namespace Office365APIEditor.Properties {
this["NewerInstallerPath"] = value;
}
}
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("False")]
+ public bool SystemLogging {
+ get {
+ return ((bool)(this["SystemLogging"]));
+ }
+ set {
+ this["SystemLogging"] = value;
+ }
+ }
}
}
diff --git a/Office365APIEditor/Properties/Settings.settings b/Office365APIEditor/Properties/Settings.settings
index 5e33377..167fedb 100644
--- a/Office365APIEditor/Properties/Settings.settings
+++ b/Office365APIEditor/Properties/Settings.settings
@@ -205,5 +205,8 @@
+
+ False
+
\ No newline at end of file
diff --git a/Office365APIEditor/UI/AcquireViewerTokenForm.cs b/Office365APIEditor/UI/AcquireViewerTokenForm.cs
index e4d96eb..c1a9c7a 100644
--- a/Office365APIEditor/UI/AcquireViewerTokenForm.cs
+++ b/Office365APIEditor/UI/AcquireViewerTokenForm.cs
@@ -105,7 +105,7 @@ namespace Office365APIEditor
Enabled = true;
}
- Util.WriteCustomLog("AcquireViewerTokenForm", stringBuilder.ToString());
+ Util.WriteSystemLog("AcquireViewerTokenForm", stringBuilder.ToString());
}
}
}
diff --git a/Office365APIEditor/UI/RequestForm.cs b/Office365APIEditor/UI/RequestForm.cs
index b7b1cf4..9248259 100644
--- a/Office365APIEditor/UI/RequestForm.cs
+++ b/Office365APIEditor/UI/RequestForm.cs
@@ -58,7 +58,7 @@ namespace Office365APIEditor
// Load Run History
try
{
- string runHistoryFilePath = Path.Combine(Util.DefaultApplicationPath, "RunHistory.xml");
+ string runHistoryFilePath = Util.RunHistoryPath;
if (File.Exists(runHistoryFilePath))
{
using (FileStream stream = new FileStream(runHistoryFilePath, FileMode.Open))
@@ -610,10 +610,7 @@ namespace Office365APIEditor
if (ex.Response == null)
{
// Logging
- if (checkBox_Logging.Checked)
- {
- Util.WriteCustomLog("Response", ex.Message);
- }
+ WriteResponseErrorLog(ex.Message);
DisplayResponse("Error", null, ex.Message);
@@ -646,10 +643,7 @@ namespace Office365APIEditor
catch (Exception ex)
{
// Logging
- if (checkBox_Logging.Checked)
- {
- Util.WriteCustomLog("Response", ex.Message);
- }
+ WriteResponseErrorLog(ex.Message);
DisplayResponse("Error", null, ex.Message);
@@ -807,10 +801,7 @@ namespace Office365APIEditor
if (ex.Response == null)
{
// Logging
- if (checkBox_Logging.Checked)
- {
- Util.WriteCustomLog("Response", ex.Message);
- }
+ WriteResponseErrorLog(ex.Message);
DisplayResponse("Error", null, ex.Message);
}
@@ -837,10 +828,7 @@ namespace Office365APIEditor
catch (Exception ex)
{
// Logging
- if (checkBox_Logging.Checked)
- {
- Util.WriteCustomLog("Response", ex.Message);
- }
+ WriteResponseErrorLog(ex.Message);
DisplayResponse("Error", null, ex.Message);
}
@@ -1063,6 +1051,18 @@ namespace Office365APIEditor
Util.WriteLog(sb);
}
+
+ private void WriteResponseErrorLog(string ErrorMessage)
+ {
+ StringBuilder sb = new StringBuilder();
+ sb.AppendLine("Response");
+ sb.AppendLine(ErrorMessage);
+
+ if (checkBox_Logging.Checked)
+ {
+ Util.WriteLog(sb);
+ }
+ }
private void AddRunHistory(WebRequest Request, string RequestHeader, string RequestBody, HttpWebResponse Response, string JsonResponse)
{
@@ -1117,7 +1117,7 @@ namespace Office365APIEditor
try
{
- FileStream stream = new FileStream(Path.Combine(Util.DefaultApplicationPath, "RunHistory.xml"), FileMode.Create);
+ FileStream stream = new FileStream(Util.RunHistoryPath, FileMode.Create);
using (StreamWriter writer = new StreamWriter(stream, Encoding.UTF8))
{
diff --git a/Office365APIEditor/Util.cs b/Office365APIEditor/Util.cs
index 9d9a2be..0cdfaf3 100644
--- a/Office365APIEditor/Util.cs
+++ b/Office365APIEditor/Util.cs
@@ -23,23 +23,29 @@ namespace Office365APIEditor
{
get
{
- if (System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed)
- {
- // ClickOnce scenario
+ string result = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "Office365APIEditor");
- string result = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "Office365APIEditor");
-
- if (!Directory.Exists(result))
- {
- Directory.CreateDirectory(result);
- }
-
- return result;
- }
- else
+ if (!Directory.Exists(result))
{
- return System.Windows.Forms.Application.StartupPath;
+ Directory.CreateDirectory(result);
}
+
+ return result;
+ }
+ }
+
+ public static string RunHistoryPath
+ {
+ get
+ {
+ string workingFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Office365APIEditor");
+
+ if (!Directory.Exists(workingFolder))
+ {
+ Directory.CreateDirectory(workingFolder);
+ }
+
+ return Path.Combine(workingFolder, "RunHistory.xml");
}
}
@@ -149,18 +155,29 @@ namespace Office365APIEditor
};
}
- public static bool WriteCustomLog(string Title, string Message)
+ public static bool WriteSystemLog(string Title, string Message)
{
+ // Write log if SystemLogging flag is true.
+
StringBuilder sb = new StringBuilder();
sb.AppendLine(Title);
sb.AppendLine("DateTime : " + DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ss.fffZ"));
sb.AppendLine(Message);
- return WriteLog(sb);
+ if (Properties.Settings.Default.SystemLogging)
+ {
+ return WriteLog(sb);
+ }
+ else
+ {
+ return true;
+ }
}
public static bool WriteLog(StringBuilder Message)
{
+ // Write log.
+
Message.AppendLine("");
string logFilePath = "";