From 8533ec2fe0a0abf6a158ffa53086a7b1fd2f0c11 Mon Sep 17 00:00:00 2001 From: Gary Sharp Date: Fri, 3 May 2013 20:48:15 +1000 Subject: [PATCH] Update: Configuration Framework +CallerMemberName Simplified creation of configuration modules; Scope is obtained from abstract, Property names become keys (via CallerMemberName); Simple generic Get/Set methods are used; Helpers for Obsfucation and Json are available. --- Disco.BI/BI/DataStore.cs | 2 +- .../BI/Expressions/Extensions/ImageExt.cs | 4 +- .../BI/Extensions/DeviceModelExtensions.cs | 2 +- Disco.BI/Properties/AssemblyInfo.cs | 4 +- Disco.Client/Properties/AssemblyInfo.cs | 4 +- .../Properties/AssemblyInfo.cs | 4 +- Disco.Data/Configuration/ConfigurationBase.cs | 76 ++- .../Configuration/ConfigurationCache.cs | 150 ++++++ .../Configuration/ConfigurationContext.cs | 483 ------------------ .../Modules/BootstrapperConfiguration.cs | 13 +- .../Modules/DeviceProfilesConfiguration.cs | 38 +- .../OrganisationAddressesConfiguration.cs | 29 +- .../Modules/WirelessConfiguration.cs | 109 ---- .../Configuration/SystemConfiguration.cs | 275 ++++++++++ Disco.Data/Disco.Data.csproj | 4 +- Disco.Data/Properties/AssemblyInfo.cs | 4 +- Disco.Data/Repository/DiscoDataContext.cs | 6 +- Disco.Models/Properties/AssemblyInfo.cs | 4 +- Disco.Services/Properties/AssemblyInfo.cs | 4 +- .../Properties/AssemblyInfo.cs | 4 +- .../Config/Models/SystemConfig/IndexModel.cs | 4 +- Disco.Web/Extensions/HtmlExtensions.cs | 2 +- Disco.Web/Properties/AssemblyInfo.cs | 4 +- 23 files changed, 545 insertions(+), 684 deletions(-) create mode 100644 Disco.Data/Configuration/ConfigurationCache.cs delete mode 100644 Disco.Data/Configuration/ConfigurationContext.cs delete mode 100644 Disco.Data/Configuration/Modules/WirelessConfiguration.cs create mode 100644 Disco.Data/Configuration/SystemConfiguration.cs diff --git a/Disco.BI/BI/DataStore.cs b/Disco.BI/BI/DataStore.cs index e93bb1ca..3d907da5 100644 --- a/Disco.BI/BI/DataStore.cs +++ b/Disco.BI/BI/DataStore.cs @@ -14,7 +14,7 @@ namespace Disco.BI { return CreateLocation(dbContext.DiscoConfiguration, SubLocation, SubSubLocationTimestamp); } - public static string CreateLocation(ConfigurationContext DiscoConfiguration, string SubLocation, DateTime? SubSubLocationTimestamp = null) + public static string CreateLocation(SystemConfiguration DiscoConfiguration, string SubLocation, DateTime? SubSubLocationTimestamp = null) { string SubSubLocation = string.Empty; if (SubSubLocationTimestamp.HasValue) diff --git a/Disco.BI/BI/Expressions/Extensions/ImageExt.cs b/Disco.BI/BI/Expressions/Extensions/ImageExt.cs index 910a4df7..47c2ece9 100644 --- a/Disco.BI/BI/Expressions/Extensions/ImageExt.cs +++ b/Disco.BI/BI/Expressions/Extensions/ImageExt.cs @@ -21,7 +21,7 @@ namespace Disco.BI.Expressions.Extensions } public static FileImageExpressionResult ImageFromDataStoreFile(string RelativeFilePath) { - var configCache = new Disco.Data.Configuration.ConfigurationContext(null); + var configCache = new Disco.Data.Configuration.SystemConfiguration(null); string DataStoreLocation = configCache.DataStoreLocation; string AbsoluteFilePath = System.IO.Path.Combine(DataStoreLocation, RelativeFilePath); return new FileImageExpressionResult(AbsoluteFilePath); @@ -126,7 +126,7 @@ namespace Disco.BI.Expressions.Extensions } public static BitmapImageExpressionResult OrganisationLogo() { - var configCache = new Disco.Data.Configuration.ConfigurationContext(null); + var configCache = new Disco.Data.Configuration.SystemConfiguration(null); BitmapImageExpressionResult result; using (var orgLogo = configCache.OrganisationLogo) { diff --git a/Disco.BI/BI/Extensions/DeviceModelExtensions.cs b/Disco.BI/BI/Extensions/DeviceModelExtensions.cs index 03a5a34a..a885c70d 100644 --- a/Disco.BI/BI/Extensions/DeviceModelExtensions.cs +++ b/Disco.BI/BI/Extensions/DeviceModelExtensions.cs @@ -55,7 +55,7 @@ namespace Disco.BI.Extensions public static string ImageFilePath(this DeviceModel deviceModel) { - var configCache = new Disco.Data.Configuration.ConfigurationContext(null); + var configCache = new Disco.Data.Configuration.SystemConfiguration(null); var deviceModelImagesDataStore = DataStore.CreateLocation(configCache, "DeviceModelImages"); diff --git a/Disco.BI/Properties/AssemblyInfo.cs b/Disco.BI/Properties/AssemblyInfo.cs index 98594c03..d1ea26bf 100644 --- a/Disco.BI/Properties/AssemblyInfo.cs +++ b/Disco.BI/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("1.2.0430.1219")] -[assembly: AssemblyFileVersion("1.2.0430.1219")] \ No newline at end of file +[assembly: AssemblyVersion("1.2.0503.2044")] +[assembly: AssemblyFileVersion("1.2.0503.2044")] \ No newline at end of file diff --git a/Disco.Client/Properties/AssemblyInfo.cs b/Disco.Client/Properties/AssemblyInfo.cs index 312128e4..6fd92637 100644 --- a/Disco.Client/Properties/AssemblyInfo.cs +++ b/Disco.Client/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("1.2.0429.1616")] -[assembly: AssemblyFileVersion("1.2.0429.1616")] \ No newline at end of file +[assembly: AssemblyVersion("1.2.0503.2044")] +[assembly: AssemblyFileVersion("1.2.0503.2044")] \ No newline at end of file diff --git a/Disco.ClientBootstrapper/Properties/AssemblyInfo.cs b/Disco.ClientBootstrapper/Properties/AssemblyInfo.cs index e9afa829..3ac0a5f9 100644 --- a/Disco.ClientBootstrapper/Properties/AssemblyInfo.cs +++ b/Disco.ClientBootstrapper/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("1.2.0426.1841")] -[assembly: AssemblyFileVersion("1.2.0426.1841")] \ No newline at end of file +[assembly: AssemblyVersion("1.2.0503.2044")] +[assembly: AssemblyFileVersion("1.2.0503.2044")] \ No newline at end of file diff --git a/Disco.Data/Configuration/ConfigurationBase.cs b/Disco.Data/Configuration/ConfigurationBase.cs index 68e18196..03aed9af 100644 --- a/Disco.Data/Configuration/ConfigurationBase.cs +++ b/Disco.Data/Configuration/ConfigurationBase.cs @@ -1,35 +1,89 @@ -using System; +using Disco.Data.Repository; +using Disco.Models.Repository; +using Newtonsoft.Json; +using System; using System.Collections.Generic; using System.Linq; +using System.Runtime.CompilerServices; using System.Text; namespace Disco.Data.Configuration { public abstract class ConfigurationBase { - private ConfigurationContext _context; + private DiscoDataContext dbContext; - public ConfigurationContext Context + public abstract string Scope { get; } + + public ConfigurationBase(DiscoDataContext dbContext) + { + this.dbContext = dbContext; + } + + protected List Items { get { - return _context; + return ConfigurationCache.GetConfigurationItems(dbContext, this.Scope); } } - public abstract string Scope { get; } - public ConfigurationBase(ConfigurationContext Context) + private void SetValue(string Key, ValueType Value) { - this._context = Context; + ConfigurationCache.SetConfigurationValue(dbContext, this.Scope, Key, Value); + } + private ValueType GetValue(string Key, ValueType Default) + { + return ConfigurationCache.GetConfigurationValue(dbContext, this.Scope, Key, Default); } - protected void SetValue(string Key, ValueType Value) + protected void Set(ValueType Value, [CallerMemberName] string Key = null) { - this.Context.SetConfigurationValue(this.Scope, Key, Value); + if (Key == null) + throw new ArgumentNullException("Key"); + + this.SetValue(Key, Value); } - protected ValueType GetValue(string Key, ValueType Default) + + protected ValueType Get(ValueType Default, [CallerMemberName] string Key = null) { - return this.Context.GetConfigurationValue(this.Scope, Key, Default); + if (Key == null) + throw new ArgumentNullException("Key"); + + return this.GetValue(Key, Default); + } + + protected void SetObsfucated(string Value, [CallerMemberName] string Key = null) + { + this.Set(ConfigurationCache.ObsfucateValue(Value), Key); + } + + protected string GetDeobsfucated(string Default, [CallerMemberName] string Key = null) + { + var obsfucatedValue = this.Get(null, Key); + + if (obsfucatedValue == null) + return Default; + else + return ConfigurationCache.DeobsfucateValue(obsfucatedValue); + } + + protected void SetAsJson(ValueType Value, [CallerMemberName] string Key = null) + { + if (Value == null) + this.Set(null, Key); + else + this.Set(JsonConvert.SerializeObject(Value), Key); + } + + protected ValueType GetFromJson(ValueType Default, [CallerMemberName] string Key = null) + { + var jsonValue = this.Get(null, Key); + + if (jsonValue == null) + return Default; + else + return JsonConvert.DeserializeObject(jsonValue); } } diff --git a/Disco.Data/Configuration/ConfigurationCache.cs b/Disco.Data/Configuration/ConfigurationCache.cs new file mode 100644 index 00000000..29dcf782 --- /dev/null +++ b/Disco.Data/Configuration/ConfigurationCache.cs @@ -0,0 +1,150 @@ +using Disco.Data.Repository; +using Disco.Models.Repository; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Disco.Data.Configuration +{ + internal static class ConfigurationCache + { + #region Cache + + private static Dictionary> configDictionary = new Dictionary>(); + private static List configurationItems = new List(); + private static object configurationItemsLock = new object(); + + private static void LoadConfigurationItems(DiscoDataContext dbContext, string Scope, bool Reload) + { + if (Reload || !configDictionary.ContainsKey(Scope)) + { + lock (configurationItemsLock) + { + if (Reload || !configDictionary.ContainsKey(Scope)) + { + if (dbContext == null) + throw new InvalidOperationException("Cache-miss where Configuration Item requested from Cache-Only Configuration Context"); + + var newItems = dbContext.ConfigurationItems.Where(ci => ci.Scope == Scope).ToArray(); + + if (configDictionary.ContainsKey(Scope)) + { + var existingItems = configDictionary[Scope]; + foreach (var existingItem in existingItems.Values) + { + configurationItems.Remove(existingItem); + } + } + configurationItems.AddRange(newItems); + configDictionary[Scope] = newItems.ToDictionary(ci => ci.Key); + } + } + } + } + private static Dictionary> ConfigurationDictionary(DiscoDataContext dbContext, string IncludingScope) + { + LoadConfigurationItems(dbContext, IncludingScope, false); + return configDictionary; + } + private static ConfigurationItem ConfigurationItem(DiscoDataContext dbContext, string Scope, string Key) + { + Dictionary scopeDict = default(Dictionary); + if (ConfigurationDictionary(dbContext, Scope).TryGetValue(Scope, out scopeDict)) + { + ConfigurationItem item = default(ConfigurationItem); + if (scopeDict.TryGetValue(Key, out item)) + return item; + } + return null; + } + private static List ConfigurationItems(DiscoDataContext dbContext, string IncludingScope) + { + LoadConfigurationItems(dbContext, IncludingScope, false); + return configurationItems; + } + + #endregion + + #region Public Helpers + internal static ValueType GetConfigurationValue(DiscoDataContext dbContext, string Scope, string Key, ValueType Default) + { + var ci = ConfigurationItem(dbContext, Scope, Key); + if (ci == null) + return Default; + else + return (ValueType)Convert.ChangeType(ci.Value, typeof(ValueType)); + } + internal static void SetConfigurationValue(DiscoDataContext dbContext, string Scope, string Key, ValueType Value) + { + if (dbContext == null) + throw new InvalidOperationException("Cannot save changes with a CacheOnly Context"); + + var ci = ConfigurationItem(dbContext, Scope, Key); + if (ci == null && Value != null) + { + lock (configurationItemsLock) + { + ci = ConfigurationItem(dbContext, Scope, Key); + if (ci == null) + { + // Create Configuration Item + ci = new ConfigurationItem() { Scope = Scope, Key = Key, Value = Value.ToString() }; + // Add Item to DB & Internal Collections + dbContext.ConfigurationItems.Add(ci); + ConfigurationItems(dbContext, Scope).Add(ci); + ConfigurationDictionary(dbContext, Scope)[Scope].Add(Key, ci); + ci = null; + } + } + } + if (ci != null) + { + lock (configurationItemsLock) + { + var entityInfo = dbContext.Entry(ci); + if (entityInfo.State == System.Data.EntityState.Detached) + { + // Reload Scope from DB + LoadConfigurationItems(dbContext, Scope, true); + ci = ConfigurationItem(dbContext, Scope, Key); + } + + if (Value == null) + { + dbContext.ConfigurationItems.Remove(ci); + configurationItems.Remove(ci); + configDictionary[Scope].Remove(Key); + } + else + { + ci.Value = Value.ToString(); + } + } + } + } + + internal static List GetConfigurationItems(DiscoDataContext dbContext, string Scope) + { + return ConfigurationDictionary(dbContext, Scope)[Scope].Values.ToList(); + } + + internal static string ObsfucateValue(string Value) + { + if (string.IsNullOrEmpty(Value)) + return Value; + else + return Convert.ToBase64String(Encoding.Unicode.GetBytes(Value)); + } + internal static string DeobsfucateValue(string ObsfucatedValue) + { + if (string.IsNullOrEmpty(ObsfucatedValue)) + return ObsfucatedValue; + else + return Encoding.Unicode.GetString(Convert.FromBase64String(ObsfucatedValue)); + } + #endregion + + } +} diff --git a/Disco.Data/Configuration/ConfigurationContext.cs b/Disco.Data/Configuration/ConfigurationContext.cs deleted file mode 100644 index da075f5c..00000000 --- a/Disco.Data/Configuration/ConfigurationContext.cs +++ /dev/null @@ -1,483 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Disco.Data.Repository; -using Disco.Models.Repository; -using System.IO; -using System.Security.Cryptography; -using Disco.Models.BI.Interop.Community; -using Newtonsoft.Json; - -namespace Disco.Data.Configuration -{ - public class ConfigurationContext - { - private DiscoDataContext _dbContext; - private DiscoDataContext dbContext - { - get - { - if (_dbContext != null) - return _dbContext; - else - throw new InvalidOperationException("Cache-miss where Configuration Item requested from Cache-Only Configuration Context"); - } - } - - public bool CacheOnly - { - get - { - return _dbContext == null; - } - } - - public ConfigurationContext(DiscoDataContext dbContext) - { - this._dbContext = dbContext; - - // Init Modules - this.moduleBootstrapperConfiguration = new Lazy(() => new Modules.BootstrapperConfiguration(this)); - this.moduleDeviceProfilesConfiguration = new Lazy(() => new Modules.DeviceProfilesConfiguration(this)); - this.moduleOrganisationAddressesConfiguration = new Lazy(() => new Modules.OrganisationAddressesConfiguration(this)); - this.moduleWirelessConfiguration = new Lazy(() => new Modules.WirelessConfiguration(this)); - } - - #region Item Cache - - private static Dictionary> configDictionary = new Dictionary>(); - private static List configurationItems = new List(); - private static object configurationItemsLock = new object(); - - private void loadConfigurationItems(string Scope, bool Reload) - { - if (Reload || !configDictionary.ContainsKey(Scope)) - { - lock (configurationItemsLock) - { - if (Reload || !configDictionary.ContainsKey(Scope)) - { - var newItems = this.dbContext.ConfigurationItems.Where(ci => ci.Scope == Scope).ToArray(); - - if (configDictionary.ContainsKey(Scope)) - { - var existingItems = configDictionary[Scope]; - foreach (var existingItem in existingItems.Values) - { - configurationItems.Remove(existingItem); - } - } - configurationItems.AddRange(newItems); - configDictionary[Scope] = newItems.ToDictionary(ci => ci.Key); - } - } - } - } - public Dictionary> ConfigurationDictionary(string IncludingScope) - { - this.loadConfigurationItems(IncludingScope, false); - return configDictionary; - } - public ConfigurationItem ConfigurationItem(string Scope, string Key) - { - Dictionary scopeDict = default(Dictionary); - if (this.ConfigurationDictionary(Scope).TryGetValue(Scope, out scopeDict)) - { - ConfigurationItem item = default(ConfigurationItem); - if (scopeDict.TryGetValue(Key, out item)) - return item; - } - return null; - } - private List ConfigurationItems(string IncludingScope) - { - this.loadConfigurationItems(IncludingScope, false); - return configurationItems; - } - - #endregion - - #region Helpers - public ValueType GetConfigurationValue(string Scope, string Key, ValueType Default) - { - var ci = this.ConfigurationItem(Scope, Key); - if (ci == null) - return Default; - else - return (ValueType)Convert.ChangeType(ci.Value, typeof(ValueType)); - } - public void SetConfigurationValue(string Scope, string Key, ValueType Value) - { - if (CacheOnly) - throw new InvalidOperationException("Cannot save changes with a CacheOnly Context"); - - var ci = this.ConfigurationItem(Scope, Key); - if (ci == null && Value != null) - { - lock (configurationItemsLock) - { - ci = this.ConfigurationItem(Scope, Key); - if (ci == null) - { - // Create Configuration Item - ci = new ConfigurationItem() { Scope = Scope, Key = Key, Value = Value.ToString() }; - // Add Item to DB & Internal Collections - this.dbContext.ConfigurationItems.Add(ci); - this.ConfigurationItems(Scope).Add(ci); - this.ConfigurationDictionary(Scope)[Scope].Add(Key, ci); - ci = null; - } - } - } - if (ci != null) - { - lock (configurationItemsLock) - { - var entityInfo = dbContext.Entry(ci); - if (entityInfo.State == System.Data.EntityState.Detached) - { - // Reload Scope from DB - this.loadConfigurationItems(Scope, true); - ci = this.ConfigurationItem(Scope, Key); - } - - if (Value == null) - { - dbContext.ConfigurationItems.Remove(ci); - configurationItems.Remove(ci); - configDictionary[Scope].Remove(Key); - } - else - { - ci.Value = Value.ToString(); - } - } - } - } - - public static string ObsfucateValue(string Value) - { - if (string.IsNullOrEmpty(Value)) - return Value; - else - return Convert.ToBase64String(Encoding.Unicode.GetBytes(Value)); - } - public static string DeobsfucateValue(string ObsfucatedValue) - { - if (string.IsNullOrEmpty(ObsfucatedValue)) - return ObsfucatedValue; - else - return Encoding.Unicode.GetString(Convert.FromBase64String(ObsfucatedValue)); - } - #endregion - - #region Configuration Modules - - private Lazy moduleBootstrapperConfiguration; - private Lazy moduleDeviceProfilesConfiguration; - private Lazy moduleOrganisationAddressesConfiguration; - private Lazy moduleWirelessConfiguration; - - public Modules.BootstrapperConfiguration Bootstrapper - { - get - { - return moduleBootstrapperConfiguration.Value; - } - } - public Modules.DeviceProfilesConfiguration DeviceProfiles - { - get - { - return moduleDeviceProfilesConfiguration.Value; - } - } - public Modules.OrganisationAddressesConfiguration OrganisationAddresses - { - get - { - return moduleOrganisationAddressesConfiguration.Value; - } - } - public Modules.WirelessConfiguration Wireless - { - get - { - return moduleWirelessConfiguration.Value; - } - } - - #endregion - - #region System Configuration Items - - public string Scope { get { return "System"; } } - - public string DataStoreLocation - { - get - { - var result = this.GetConfigurationValue(this.Scope, "DataStoreLocation", null); - if (result == null) - { - var appDataPath = System.Web.HttpContext.Current.Server.MapPath("~/App_Data"); - if (appDataPath.EndsWith("\\")) - return appDataPath; - else - return string.Concat(appDataPath, '\\'); - } - else - return result; - } - set - { - if (value == null) - throw new ArgumentNullException("value"); - if (!System.IO.Directory.Exists(value)) - throw new System.IO.DirectoryNotFoundException(string.Format("DataStoreLocation: '{0}' could not be found", value)); - string storePath; - if (value.EndsWith("\\")) - storePath = value; - else - storePath = string.Concat(value, '\\'); - this.SetConfigurationValue(this.Scope, "DataStoreLocation", storePath); - } - } - public string PluginsLocation - { - get - { - return System.IO.Path.Combine(this.DataStoreLocation, @"Plugins\"); - } - } - public string PluginStorageLocation - { - get - { - return System.IO.Path.Combine(this.DataStoreLocation, @"PluginStorage\"); - } - } - public string PluginPackagesLocation - { - get - { - return System.IO.Path.Combine(this.DataStoreLocation, @"PluginPackages\"); - } - } - #region Organisation Logo - private string OrganisationLogoPath - { - get - { - return System.IO.Path.Combine(DataStoreLocation, "OrganisationLogo.png"); - } - } - //private static string _OrganisationLogoHash; - //private static byte[] _OrganisationLogo; - //private static object _OrganisationLogoLock = new object(); - //private static void LoadOrganisationLogo(ConfigurationContext context, bool reload = false) - //{ - // if (_OrganisationLogoHash == null || reload) - // { - // lock (_OrganisationLogoLock) - // { - // if (_OrganisationLogoHash == null || reload) - // { - // _OrganisationLogo = null; - // _OrganisationLogoHash = null; - - // string organisationLogoPath = context.OrganisationLogoPath; - // if (System.IO.File.Exists(organisationLogoPath)) - // _OrganisationLogo = System.IO.File.ReadAllBytes(organisationLogoPath); - // } - // if (_OrganisationLogo == null || _OrganisationLogo.Length == 0) - // { - // _OrganisationLogo = Disco.Data.Properties.Resources.EmptyLogo; - // } - // if (_OrganisationLogoHash == null) - // { - // using (SHA256 h = SHA256.Create()) - // { - // _OrganisationLogoHash = Convert.ToBase64String(h.ComputeHash(_OrganisationLogo)); - // } - // } - // } - // } - //} - public string OrganisationLogoHash - { - get - { - var path = this.OrganisationLogoPath; - if (File.Exists(path)) - return File.GetLastWriteTimeUtc(path).ToBinary().ToString(); - else - return "-1"; - } - } - public Stream OrganisationLogo - { - get - { - //LoadOrganisationLogo(this); - //if (_OrganisationLogo == null || _OrganisationLogo.Length != 0) - // return new MemoryStream(_OrganisationLogo); - //else - // return null; - var path = this.OrganisationLogoPath; - if (File.Exists(path)) - return new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read); - else - return new MemoryStream(Disco.Data.Properties.Resources.EmptyLogo); - } - set - { - string organisationLogoPath = this.OrganisationLogoPath; - if (value == null) - { - if (System.IO.File.Exists(organisationLogoPath)) - System.IO.File.Delete(organisationLogoPath); - } - else - { - using (FileStream fs = new FileStream(organisationLogoPath, FileMode.Create, FileAccess.Write, FileShare.None)) - { - value.CopyTo(fs); - } - } - //LoadOrganisationLogo(this, true); - } - } - #endregion - public string OrganisationName - { - get - { - return this.GetConfigurationValue(this.Scope, "OrganisationName", null); - } - set - { - this.SetConfigurationValue(this.Scope, "OrganisationName", value); - } - } - public bool MultiSiteMode - { - get - { - return this.GetConfigurationValue(this.Scope, "MultiSiteMode", false); - } - set - { - this.SetConfigurationValue(this.Scope, "MultiSiteMode", value); - } - } - - #region Proxy Configuration - public string ProxyAddress - { - get - { - return this.GetConfigurationValue(this.Scope, "ProxyAddress", null); - } - set - { - this.SetConfigurationValue(this.Scope, "ProxyAddress", value); - } - } - public int ProxyPort - { - get - { - return this.GetConfigurationValue(this.Scope, "ProxyPort", 8080); - } - set - { - this.SetConfigurationValue(this.Scope, "ProxyPort", value); - } - } - public string ProxyUsername - { - get - { - return this.GetConfigurationValue(this.Scope, "ProxyUsername", null); - } - set - { - this.SetConfigurationValue(this.Scope, "ProxyUsername", value); - } - } - public string ProxyPassword - { - get - { - return DeobsfucateValue(this.GetConfigurationValue(this.Scope, "ProxyPassword", null)); - } - set - { - this.SetConfigurationValue(this.Scope, "ProxyPassword", ObsfucateValue(value)); - } - } - #endregion - - #region UpdateCheck - public string DeploymentId - { - get - { - return this.GetConfigurationValue(this.Scope, "DeploymentId", null); - } - } - public UpdateResponse UpdateLastCheck - { - get - { - var json = this.GetConfigurationValue(this.Scope, "UpdateLastCheck", null); - if (json != null) - { - try - { - return JsonConvert.DeserializeObject(json); - } - catch (Exception) - { }// Ignore Serialization Issues - } - return null; - } - set - { - if (value == null) - this.SetConfigurationValue(this.Scope, "UpdateLastCheck", null); - - var json = JsonConvert.SerializeObject(value); - this.SetConfigurationValue(this.Scope, "UpdateLastCheck", json); - } - } - public bool UpdateBetaDeployment - { - get - { - return this.GetConfigurationValue(this.Scope, "UpdateBetaDeployment", false); - } - } - public Version InstalledDatabaseVersion - { - get - { - var versionString = this.GetConfigurationValue(this.Scope, "InstalledDatabaseVersion", null); - if (string.IsNullOrEmpty(versionString)) - return null; - else - return Version.Parse(versionString); - } - set - { - this.SetConfigurationValue(this.Scope, "InstalledDatabaseVersion", value.ToString(4)); - } - } - #endregion - - #endregion - - } -} diff --git a/Disco.Data/Configuration/Modules/BootstrapperConfiguration.cs b/Disco.Data/Configuration/Modules/BootstrapperConfiguration.cs index 636fc1fa..1eba4020 100644 --- a/Disco.Data/Configuration/Modules/BootstrapperConfiguration.cs +++ b/Disco.Data/Configuration/Modules/BootstrapperConfiguration.cs @@ -1,4 +1,5 @@ -using System; +using Disco.Data.Repository; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -7,7 +8,7 @@ namespace Disco.Data.Configuration.Modules { public class BootstrapperConfiguration : ConfigurationBase { - public BootstrapperConfiguration(ConfigurationContext Context) : base(Context) { } + public BootstrapperConfiguration(DiscoDataContext dbContext) : base(dbContext) { } public override string Scope { @@ -18,11 +19,11 @@ namespace Disco.Data.Configuration.Modules { get { - return this.GetValue("MacSshUsername", "root"); + return this.Get("root"); } set { - this.SetValue("MacSshUsername", value); + this.Set(value); } } @@ -30,11 +31,11 @@ namespace Disco.Data.Configuration.Modules { get { - return ConfigurationContext.DeobsfucateValue(this.GetValue("MacSshPassword", string.Empty)); + return this.GetDeobsfucated(string.Empty); } set { - this.SetValue("MacSshPassword", ConfigurationContext.ObsfucateValue(value)); + this.SetObsfucated(value); } } } diff --git a/Disco.Data/Configuration/Modules/DeviceProfilesConfiguration.cs b/Disco.Data/Configuration/Modules/DeviceProfilesConfiguration.cs index 1a778dc3..942ac218 100644 --- a/Disco.Data/Configuration/Modules/DeviceProfilesConfiguration.cs +++ b/Disco.Data/Configuration/Modules/DeviceProfilesConfiguration.cs @@ -3,43 +3,21 @@ using System.Collections.Generic; using System.Linq; using System.Text; using Disco.Models.Repository; +using Disco.Data.Repository; namespace Disco.Data.Configuration.Modules { public class DeviceProfilesConfiguration : ConfigurationBase { - // Removed 2012-06-14 G# - Properties moved to DeviceProfile model & DB Migrated in DBv3. - //private Dictionary deviceProfileConfigurations; + public DeviceProfilesConfiguration(DiscoDataContext dbContext) : base(dbContext) { } - public DeviceProfilesConfiguration(ConfigurationContext Context) - : base(Context) - { - // Removed 2012-06-14 G# - Properties moved to DeviceProfile model & DB Migrated in DBv3. - //this.deviceProfileConfigurations = new Dictionary(); - } - - public override string Scope - { - get { return "DeviceProfiles"; } - } - - // Removed 2012-06-14 G# - Properties moved to DeviceProfile model & DB Migrated in DBv3. - //public DeviceProfileConfiguration DeviceProfile(DeviceProfile Profile) - //{ - // DeviceProfileConfiguration dpc = default(DeviceProfileConfiguration); - // if (!this.deviceProfileConfigurations.TryGetValue(Profile.Id, out dpc)) - // { - // dpc = new DeviceProfileConfiguration(this.Context, Profile); - // this.deviceProfileConfigurations[Profile.Id] = dpc; - // } - // return dpc; - //} + public override string Scope { get { return "DeviceProfiles"; } } public int DefaultDeviceProfileId { get { - var v = this.GetValue("DefaultDeviceProfileId", 1); + var v = this.Get(1); if (v > 0) return v; else @@ -49,20 +27,22 @@ namespace Disco.Data.Configuration.Modules { if (value < 1) throw new ArgumentOutOfRangeException("value", "Expected >= 1"); - this.SetValue("DefaultDeviceProfileId", value); + + this.Set(value); } } public int DefaultAddDeviceOfflineDeviceProfileId { get { - return this.GetValue("DefaultAddDeviceOfflineDeviceProfileId", 0); + return this.Get(0); } set { if (value < 0) throw new ArgumentOutOfRangeException("value", "Expected >= 0"); - this.SetValue("DefaultAddDeviceOfflineDeviceProfileId", value); + + this.Set(value); } } diff --git a/Disco.Data/Configuration/Modules/OrganisationAddressesConfiguration.cs b/Disco.Data/Configuration/Modules/OrganisationAddressesConfiguration.cs index 1c38ccf9..f35d94db 100644 --- a/Disco.Data/Configuration/Modules/OrganisationAddressesConfiguration.cs +++ b/Disco.Data/Configuration/Modules/OrganisationAddressesConfiguration.cs @@ -5,22 +5,20 @@ using System.Text; using Disco.Models.BI.Config; using Disco.Models.Repository; using Newtonsoft.Json; +using Disco.Data.Repository; namespace Disco.Data.Configuration.Modules { public class OrganisationAddressesConfiguration : ConfigurationBase { - public OrganisationAddressesConfiguration(ConfigurationContext Context) : base(Context) { } + public OrganisationAddressesConfiguration(DiscoDataContext dbContext) : base(dbContext) { } - public override string Scope - { - get { return "OrganisationAddresses"; } - } + public override string Scope { get { return "OrganisationAddresses"; } } public OrganisationAddress GetAddress(int Id) { var address = default(OrganisationAddress); - var addressString = this.GetValue(Id.ToString(), null); + var addressString = this.Get(null, Id.ToString()); if (addressString != null) { if (addressString.StartsWith("{")) @@ -45,28 +43,23 @@ namespace Disco.Data.Configuration.Modules string addressString = JsonConvert.SerializeObject(Address); - this.SetValue(Address.Id.ToString(), addressString); //Address.ToConfigurationEntry()); + this.Set(addressString, Address.Id.ToString()); //Address.ToConfigurationEntry()); return Address; } public void RemoveAddress(int Id) { // Set Config Item to null = Remove Configuration Item - this.SetValue(Id.ToString(), null); + this.Set(null, Id.ToString()); } public List Addresses { get { - Dictionary configAddress = default(Dictionary); - if (this.Context.ConfigurationDictionary(this.Scope).TryGetValue(this.Scope, out configAddress)) - return configAddress.Select( - ca => ca.Value.Value.StartsWith("{") ? - JsonConvert.DeserializeObject(ca.Value.Value) : - OrganisationAddress.FromConfigurationEntry(int.Parse(ca.Key), ca.Value.Value) - ).ToList(); - else - return new List(); // Empty List - No Addresses + return this.Items.Select(ca => ca.Value.StartsWith("{") ? + JsonConvert.DeserializeObject(ca.Value) : + OrganisationAddress.FromConfigurationEntry(int.Parse(ca.Key), ca.Value) + ).ToList(); } } @@ -77,7 +70,7 @@ namespace Disco.Data.Configuration.Modules int nextId = 0; while (true) { - if (this.Context.ConfigurationItem(this.Scope, nextId.ToString()) == null) + if (this.Get(null, nextId.ToString()) == null) break; nextId++; } diff --git a/Disco.Data/Configuration/Modules/WirelessConfiguration.cs b/Disco.Data/Configuration/Modules/WirelessConfiguration.cs deleted file mode 100644 index ba011755..00000000 --- a/Disco.Data/Configuration/Modules/WirelessConfiguration.cs +++ /dev/null @@ -1,109 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace Disco.Data.Configuration.Modules -{ - public class WirelessConfiguration : ConfigurationBase - { - public const string Provider_eduSTAR = "eduSTAR"; - public const string Provider_eduPaSS = "eduPaSS"; - - public WirelessConfiguration(ConfigurationContext Context) : base(Context) { } - - public override string Scope - { - get { return "Wireless"; } - } - - public int CertificateAutoBufferMax - { - get - { - return this.GetValue("CertificateAutoBufferMax", 50); - } - set - { - this.SetValue("CertificateAutoBufferMax", value); - } - } - public int CertificateAutoBufferLow - { - get - { - return this.GetValue("CertificateAutoBufferLow", 10); - } - set - { - this.SetValue("CertificateAutoBufferLow", value); - } - } - public string Provider - { - get - { - return this.GetValue("Provider", Provider_eduSTAR); - } - set - { - if (string.IsNullOrEmpty(value)) - throw new ArgumentNullException("value"); - if (value.Equals(Provider_eduSTAR, StringComparison.InvariantCultureIgnoreCase)) - this.SetValue("Provider", Provider_eduSTAR); - else - throw new NotSupportedException(string.Format("Unsupported Wireless Provider: ", value)); - } - } - - #region eduSTAR Configuration - - public string eduSTAR_Scope - { - get { return "Wireless_eduSTAR"; } - } - - public string eduSTAR_ServiceAccountSchoolId - { - get - { - return this.Context.GetConfigurationValue(this.eduSTAR_Scope, "ServiceAccountSchoolId", null); - } - set - { - if (string.IsNullOrEmpty(value)) - throw new ArgumentNullException("value"); - this.Context.SetConfigurationValue(this.eduSTAR_Scope, "ServiceAccountSchoolId", value); - } - } - public string eduSTAR_ServiceAccountUsername - { - get - { - return this.Context.GetConfigurationValue(this.eduSTAR_Scope, "ServiceAccountUsername", null); - } - set - { - if (string.IsNullOrEmpty(value)) - throw new ArgumentNullException("value"); - this.Context.SetConfigurationValue(this.eduSTAR_Scope, "ServiceAccountUsername", value); - } - } - public string eduSTAR_ServiceAccountPassword - { - get - { - return ConfigurationContext.DeobsfucateValue(this.Context.GetConfigurationValue(this.eduSTAR_Scope, "ServiceAccountPassword", null)); - } - set - { - if (string.IsNullOrEmpty(value)) - throw new ArgumentNullException("value"); - this.Context.SetConfigurationValue(this.eduSTAR_Scope, "ServiceAccountPassword", ConfigurationContext.ObsfucateValue(value)); - } - } - - #endregion - - } -} diff --git a/Disco.Data/Configuration/SystemConfiguration.cs b/Disco.Data/Configuration/SystemConfiguration.cs new file mode 100644 index 00000000..3ec1fe24 --- /dev/null +++ b/Disco.Data/Configuration/SystemConfiguration.cs @@ -0,0 +1,275 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Disco.Data.Repository; +using Disco.Models.Repository; +using System.IO; +using System.Security.Cryptography; +using Disco.Models.BI.Interop.Community; +using Newtonsoft.Json; + +namespace Disco.Data.Configuration +{ + public class SystemConfiguration : ConfigurationBase + { + public SystemConfiguration(DiscoDataContext dbContext) + : base(dbContext) + { + // Init Modules + this.moduleBootstrapperConfiguration = new Lazy(() => new Modules.BootstrapperConfiguration(dbContext)); + this.moduleDeviceProfilesConfiguration = new Lazy(() => new Modules.DeviceProfilesConfiguration(dbContext)); + this.moduleOrganisationAddressesConfiguration = new Lazy(() => new Modules.OrganisationAddressesConfiguration(dbContext)); + } + + #region Configuration Modules + + private Lazy moduleBootstrapperConfiguration; + private Lazy moduleDeviceProfilesConfiguration; + private Lazy moduleOrganisationAddressesConfiguration; + + public Modules.BootstrapperConfiguration Bootstrapper + { + get + { + return moduleBootstrapperConfiguration.Value; + } + } + public Modules.DeviceProfilesConfiguration DeviceProfiles + { + get + { + return moduleDeviceProfilesConfiguration.Value; + } + } + public Modules.OrganisationAddressesConfiguration OrganisationAddresses + { + get + { + return moduleOrganisationAddressesConfiguration.Value; + } + } + + #endregion + + public override string Scope { get { return "System"; } } + + public string DataStoreLocation + { + get + { + var result = this.Get(null); + if (result == null) + { + var appDataPath = System.Web.HttpContext.Current.Server.MapPath("~/App_Data"); + if (appDataPath.EndsWith("\\")) + return appDataPath; + else + return string.Concat(appDataPath, '\\'); + } + else + return result; + } + set + { + if (value == null) + throw new ArgumentNullException("value"); + if (!System.IO.Directory.Exists(value)) + throw new System.IO.DirectoryNotFoundException(string.Format("DataStoreLocation: '{0}' could not be found", value)); + string storePath; + if (value.EndsWith("\\")) + storePath = value; + else + storePath = string.Concat(value, '\\'); + this.Set(storePath); + } + } + + #region Plugin Locations + public string PluginsLocation + { + get + { + return System.IO.Path.Combine(this.DataStoreLocation, @"Plugins\"); + } + } + public string PluginStorageLocation + { + get + { + return System.IO.Path.Combine(this.DataStoreLocation, @"PluginStorage\"); + } + } + public string PluginPackagesLocation + { + get + { + return System.IO.Path.Combine(this.DataStoreLocation, @"PluginPackages\"); + } + } + #endregion + + #region Organisation Details + #region Organisation Logo + private string OrganisationLogoPath + { + get + { + return System.IO.Path.Combine(DataStoreLocation, "OrganisationLogo.png"); + } + } + public string OrganisationLogoHash + { + get + { + var path = this.OrganisationLogoPath; + if (File.Exists(path)) + return File.GetLastWriteTimeUtc(path).ToBinary().ToString(); + else + return "-1"; + } + } + public Stream OrganisationLogo + { + get + { + var path = this.OrganisationLogoPath; + if (File.Exists(path)) + return new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read); + else + return new MemoryStream(Disco.Data.Properties.Resources.EmptyLogo); + } + set + { + string organisationLogoPath = this.OrganisationLogoPath; + if (value == null) + { + if (System.IO.File.Exists(organisationLogoPath)) + System.IO.File.Delete(organisationLogoPath); + } + else + { + using (FileStream fs = new FileStream(organisationLogoPath, FileMode.Create, FileAccess.Write, FileShare.None)) + { + value.CopyTo(fs); + } + } + } + } + #endregion + public string OrganisationName + { + get + { + return this.Get(null); + } + set + { + this.Set(value); + } + } + public bool MultiSiteMode + { + get + { + return this.Get(false); + } + set + { + this.Set(value); + } + } + #endregion + + #region Proxy Configuration + public string ProxyAddress + { + get + { + return this.Get(null); + } + set + { + this.Set(value); + } + } + public int ProxyPort + { + get + { + return this.Get(8080); + } + set + { + this.Set(value); + } + } + public string ProxyUsername + { + get + { + return this.Get(null); + } + set + { + this.Set(value); + } + } + public string ProxyPassword + { + get + { + return this.GetDeobsfucated(null); + } + set + { + this.SetObsfucated(value); + } + } + #endregion + + #region UpdateCheck + public string DeploymentId + { + get + { + return this.Get(null); + } + } + public UpdateResponse UpdateLastCheck + { + get + { + return this.GetFromJson(null); + } + set + { + this.SetAsJson(value); + } + } + public bool UpdateBetaDeployment + { + get + { + return this.Get(false); + } + } + public Version InstalledDatabaseVersion + { + get + { + var versionString = this.Get(null); + if (string.IsNullOrEmpty(versionString)) + return null; + else + return Version.Parse(versionString); + } + set + { + this.Set(value.ToString(4)); + } + } + #endregion + + } +} diff --git a/Disco.Data/Disco.Data.csproj b/Disco.Data/Disco.Data.csproj index a59d31e8..a4e3d33a 100644 --- a/Disco.Data/Disco.Data.csproj +++ b/Disco.Data/Disco.Data.csproj @@ -71,12 +71,12 @@ - + + - 201204250418485_DBv0.cs diff --git a/Disco.Data/Properties/AssemblyInfo.cs b/Disco.Data/Properties/AssemblyInfo.cs index 8ed97915..745e5946 100644 --- a/Disco.Data/Properties/AssemblyInfo.cs +++ b/Disco.Data/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("1.2.0430.1219")] -[assembly: AssemblyFileVersion("1.2.0430.1219")] \ No newline at end of file +[assembly: AssemblyVersion("1.2.0503.2044")] +[assembly: AssemblyFileVersion("1.2.0503.2044")] \ No newline at end of file diff --git a/Disco.Data/Repository/DiscoDataContext.cs b/Disco.Data/Repository/DiscoDataContext.cs index 3fcdd193..0b407358 100644 --- a/Disco.Data/Repository/DiscoDataContext.cs +++ b/Disco.Data/Repository/DiscoDataContext.cs @@ -10,11 +10,11 @@ namespace Disco.Data.Repository { public class DiscoDataContext : DbContext { - private Lazy _Configuration; + private Lazy _Configuration; public DiscoDataContext() { - this._Configuration = new Lazy(() => new Configuration.ConfigurationContext(this)); + this._Configuration = new Lazy(() => new Configuration.SystemConfiguration(this)); } public virtual DbSet ConfigurationItems { get; set; } @@ -47,7 +47,7 @@ namespace Disco.Data.Repository public virtual DbSet JobMetaNonWarranties { get; set; } public virtual DbSet JobMetaInsurances { get; set; } - public Configuration.ConfigurationContext DiscoConfiguration + public Configuration.SystemConfiguration DiscoConfiguration { get { diff --git a/Disco.Models/Properties/AssemblyInfo.cs b/Disco.Models/Properties/AssemblyInfo.cs index 39b89013..27f56e4d 100644 --- a/Disco.Models/Properties/AssemblyInfo.cs +++ b/Disco.Models/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("1.2.0430.1219")] -[assembly: AssemblyFileVersion("1.2.0430.1219")] \ No newline at end of file +[assembly: AssemblyVersion("1.2.0503.2044")] +[assembly: AssemblyFileVersion("1.2.0503.2044")] \ No newline at end of file diff --git a/Disco.Services/Properties/AssemblyInfo.cs b/Disco.Services/Properties/AssemblyInfo.cs index dfa4bac3..44bd8ad4 100644 --- a/Disco.Services/Properties/AssemblyInfo.cs +++ b/Disco.Services/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("1.2.0430.1219")] -[assembly: AssemblyFileVersion("1.2.0430.1219")] \ No newline at end of file +[assembly: AssemblyVersion("1.2.0503.2044")] +[assembly: AssemblyFileVersion("1.2.0503.2044")] \ No newline at end of file diff --git a/Disco.Web.Extensions/Properties/AssemblyInfo.cs b/Disco.Web.Extensions/Properties/AssemblyInfo.cs index af707973..4f4eaf65 100644 --- a/Disco.Web.Extensions/Properties/AssemblyInfo.cs +++ b/Disco.Web.Extensions/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("1.2.0430.1219")] -[assembly: AssemblyFileVersion("1.2.0430.1219")] \ No newline at end of file +[assembly: AssemblyVersion("1.2.0503.2044")] +[assembly: AssemblyFileVersion("1.2.0503.2044")] \ No newline at end of file diff --git a/Disco.Web/Areas/Config/Models/SystemConfig/IndexModel.cs b/Disco.Web/Areas/Config/Models/SystemConfig/IndexModel.cs index d4ff8f3e..a7def612 100644 --- a/Disco.Web/Areas/Config/Models/SystemConfig/IndexModel.cs +++ b/Disco.Web/Areas/Config/Models/SystemConfig/IndexModel.cs @@ -85,7 +85,7 @@ namespace Disco.Web.Areas.Config.Models.SystemConfig public UpdateResponse UpdateLatestResponse { get; set; } public bool UpdateBetaDeployment { get; set; } - public static IndexModel FromConfiguration(ConfigurationContext config) + public static IndexModel FromConfiguration(SystemConfiguration config) { return new IndexModel() { @@ -104,7 +104,7 @@ namespace Disco.Web.Areas.Config.Models.SystemConfig public void ToConfiguration(DiscoDataContext db) { - ConfigurationContext config = db.DiscoConfiguration; + SystemConfiguration config = db.DiscoConfiguration; //config.DataStoreLocation = DataStoreLocation; config.ProxyAddress = ProxyAddress; config.ProxyPort = ProxyPort; diff --git a/Disco.Web/Extensions/HtmlExtensions.cs b/Disco.Web/Extensions/HtmlExtensions.cs index 3e2a1ca3..775f0353 100644 --- a/Disco.Web/Extensions/HtmlExtensions.cs +++ b/Disco.Web/Extensions/HtmlExtensions.cs @@ -70,7 +70,7 @@ namespace Disco.Web } public static MvcHtmlString OrganisationLogoUrl(this UrlHelper urlHelper, int Width = 256, int Height = 256) { - var config = new Disco.Data.Configuration.ConfigurationContext(null); + var config = new Disco.Data.Configuration.SystemConfiguration(null); return new MvcHtmlString(urlHelper.Action(MVC.API.System.OrganisationLogo(Width, Height, config.OrganisationLogoHash))); } #endregion diff --git a/Disco.Web/Properties/AssemblyInfo.cs b/Disco.Web/Properties/AssemblyInfo.cs index e9dd8032..286d3dfe 100644 --- a/Disco.Web/Properties/AssemblyInfo.cs +++ b/Disco.Web/Properties/AssemblyInfo.cs @@ -31,5 +31,5 @@ using System.Runtime.InteropServices; // // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("1.2.0430.1219")] -[assembly: AssemblyFileVersion("1.2.0430.1219")] \ No newline at end of file +[assembly: AssemblyVersion("1.2.0503.2044")] +[assembly: AssemblyFileVersion("1.2.0503.2044")] \ No newline at end of file