PageRenderTime 51ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/BlogEngine/DotNetSlave.BusinessLogic/Web/InstallUtil.cs

#
C# | 73 lines | 48 code | 9 blank | 16 comment | 7 complexity | 62016f7c3e67323f156d04d05d85c1d0 MD5 | raw file
Possible License(s): LGPL-2.1, Apache-2.0, BSD-3-Clause
  1. // Written by: Roman D. Clarkson
  2. // http://www.romanclarkson.com mailto:inspirit@romanclarkson.com
  3. using System;
  4. using System.Web.Configuration;
  5. namespace BlogEngine.Core.Web
  6. {
  7. /// <summary>
  8. ///
  9. /// </summary>
  10. public class InstallUtil
  11. {
  12. private const string beversion = "BEVersion";
  13. private const string installdate = "InstallDate";
  14. private const string lastupdated = "LastUpdated";
  15. /// <summary>
  16. ///
  17. /// </summary>
  18. public static void CheckInstallation()
  19. {
  20. CheckIfInstalling();
  21. CheckIfUpgrading();
  22. }
  23. private static void UpdateTheLastUpdatedAppKey()
  24. {
  25. string currentDateTime = DateTime.Now.ToString();
  26. if (WebConfigurationManager.AppSettings[lastupdated] == null)
  27. {
  28. AppConfig.Instance().SetValue(lastupdated, currentDateTime);
  29. }
  30. else
  31. {
  32. AppConfig.Instance().SetValue(lastupdated, currentDateTime);
  33. }
  34. }
  35. /// <summary>
  36. ///
  37. /// </summary>
  38. /// Todo: Need to expand this to check the web.config assembly version and compare it with the current assembly in the bin.
  39. private static void CheckIfUpgrading()
  40. {
  41. string currentAssemblyVersion = WebConfigurationManager.AppSettings[beversion];
  42. string assemblyVersion = BlogSettings.Instance.Version();
  43. if (WebConfigurationManager.AppSettings[beversion] == null)
  44. {
  45. AppConfig.Instance().SetValue(beversion, BlogSettings.Instance.Version());
  46. UpdateTheLastUpdatedAppKey();
  47. }
  48. }
  49. /// <summary>
  50. ///
  51. /// </summary>
  52. /// Todo: This can be expanded using install scripts.
  53. private static void CheckIfInstalling()
  54. {
  55. string currentDateTime = DateTime.Now.ToString();
  56. if (WebConfigurationManager.AppSettings[installdate] == string.Empty ||
  57. WebConfigurationManager.AppSettings[installdate] == null)
  58. {
  59. AppConfig.Instance().SetValue(installdate, currentDateTime);
  60. UpdateTheLastUpdatedAppKey();
  61. }
  62. }
  63. }
  64. }