Created
June 9, 2016 07:02
-
-
Save alexanderbluhm/b8b0c07200d82f81478297e2685e7b2f to your computer and use it in GitHub Desktop.
AppSettings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Configuration; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace AmazonReportTool.Core.Helper | |
{ | |
/// <summary> | |
/// Read and write to the app config file | |
/// </summary> | |
public class ApplicationConfig | |
{ | |
public ApplicationConfig() | |
{ | |
} | |
/// <summary> | |
/// Gets or sets the item connecting to the config file. | |
/// </summary> | |
public static string Path | |
{ | |
get { return System.IO.Path.Combine(Environment.CurrentDirectory, "reports"); } | |
} | |
/// <summary> | |
/// Ruft den Pfad zu den Bestellberichten ab | |
/// </summary> | |
public static string BookingPath | |
{ | |
get { return System.IO.Path.Combine(Environment.CurrentDirectory, "bookings"); } | |
} | |
/// <summary> | |
/// Ruft den Pfad zur Kategoriendatei ab (mit Dateinamen) | |
/// </summary> | |
public static string CategoryPath | |
{ | |
get { return System.IO.Path.Combine(Environment.CurrentDirectory, "categories.xml"); } | |
} | |
public static int AlertDays | |
{ | |
get | |
{ | |
return int.Parse(ConfigurationManager.AppSettings["AlertDays"]); | |
} | |
set | |
{ | |
string appPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); | |
string configFile = System.IO.Path.Combine(appPath, "AmazonReportTool.exe.config"); | |
ExeConfigurationFileMap configFileMap = new ExeConfigurationFileMap(); | |
configFileMap.ExeConfigFilename = configFile; | |
System.Configuration.Configuration config = ConfigurationManager.OpenMappedExeConfiguration(configFileMap, ConfigurationUserLevel.None); | |
config.AppSettings.Settings["AlertDays"].Value = value.ToString(); | |
config.Save(); | |
} | |
} | |
public static int AlertQty | |
{ | |
get | |
{ | |
return int.Parse(ConfigurationManager.AppSettings["AlertQty"]); | |
} | |
set | |
{ | |
string appPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); | |
string configFile = System.IO.Path.Combine(appPath, "AmazonReportTool.exe.config"); | |
ExeConfigurationFileMap configFileMap = new ExeConfigurationFileMap(); | |
configFileMap.ExeConfigFilename = configFile; | |
System.Configuration.Configuration config = ConfigurationManager.OpenMappedExeConfiguration(configFileMap, ConfigurationUserLevel.None); | |
config.AppSettings.Settings["AlertQty"].Value = value.ToString(); | |
config.Save(); | |
} | |
} | |
public static int AlertQtyInReport | |
{ | |
get | |
{ | |
return int.Parse(ConfigurationManager.AppSettings["AlertQtyInReport"]); | |
} | |
set | |
{ | |
string appPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); | |
string configFile = System.IO.Path.Combine(appPath, "AmazonReportTool.exe.config"); | |
ExeConfigurationFileMap configFileMap = new ExeConfigurationFileMap(); | |
configFileMap.ExeConfigFilename = configFile; | |
System.Configuration.Configuration config = ConfigurationManager.OpenMappedExeConfiguration(configFileMap, ConfigurationUserLevel.None); | |
config.AppSettings.Settings["AlertQtyInReport"].Value = value.ToString(); | |
config.Save(); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment