From ffed3b135013e9d6b061e76125052d097c5bf6d9 Mon Sep 17 00:00:00 2001 From: vfedosevich Date: Fri, 22 May 2015 01:17:16 -0700 Subject: [PATCH] OWA settings added to control panel --- .../System/SystemSettings.cs | 2 + .../Config/Entities/OfficeOnlineCollection.cs | 24 +++++++-- .../OfficeOnlineElementCollection.cs | 16 ------ .../FileOperations/FileOpenerManager.cs | 26 +++++---- .../WebsitePanel.WebDavPortal/Web.config | 2 +- .../SystemSettings.ascx.resx | 12 +++++ .../WebsitePanel/SystemSettings.ascx | 16 ++++++ .../WebsitePanel/SystemSettings.ascx.cs | 7 +++ .../SystemSettings.ascx.designer.cs | 54 +++++++++++++++++++ 9 files changed, 128 insertions(+), 31 deletions(-) diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/System/SystemSettings.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/System/SystemSettings.cs index ba6a885f..d935462d 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/System/SystemSettings.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/System/SystemSettings.cs @@ -57,6 +57,8 @@ namespace WebsitePanel.EnterpriseServer public const string WEBDAV_PASSWORD_RESET_ENABLED_KEY = "WebdavPswResetEnabled"; public const string WEBDAV_PASSWORD_RESET_LINK_LIFE_SPAN = "WebdavPswdResetLinkLifeSpan"; + public const string WEBDAV_OWA_ENABLED_KEY = "WebdavOwaEnabled"; + public const string WEBDAV_OWA_URL = "WebdavOwaUrl"; // key to access to wpi main & custom feed in wpi settings public const string WPI_MAIN_FEED_KEY = "WpiMainFeedUrl"; diff --git a/WebsitePanel/Sources/WebsitePanel.WebDav.Core/Config/Entities/OfficeOnlineCollection.cs b/WebsitePanel/Sources/WebsitePanel.WebDav.Core/Config/Entities/OfficeOnlineCollection.cs index c7f2d45d..7664bf67 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebDav.Core/Config/Entities/OfficeOnlineCollection.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebDav.Core/Config/Entities/OfficeOnlineCollection.cs @@ -1,6 +1,7 @@ using System.Collections; using System.Collections.Generic; using System.Linq; +using WebsitePanel.EnterpriseServer; using WebsitePanel.WebDavPortal.WebConfigSections; namespace WebsitePanel.WebDav.Core.Config.Entities @@ -11,15 +12,30 @@ namespace WebsitePanel.WebDav.Core.Config.Entities public OfficeOnlineCollection() { - IsEnabled = ConfigSection.OfficeOnline.IsEnabled; - Url = ConfigSection.OfficeOnline.Url; NewFilePath = ConfigSection.OfficeOnline.CobaltNewFilePath; CobaltFileTtl = ConfigSection.OfficeOnline.CobaltFileTtl; _officeExtensions = ConfigSection.OfficeOnline.Cast().ToList(); } - public bool IsEnabled { get; private set; } - public string Url { get; private set; } + public bool IsEnabled { + get + { + return GetWebdavSystemSettigns().GetValueOrDefault(EnterpriseServer.SystemSettings.WEBDAV_OWA_ENABLED_KEY, false); + } + } + public string Url + { + get + { + return GetWebdavSystemSettigns().GetValueOrDefault(EnterpriseServer.SystemSettings.WEBDAV_OWA_URL, string.Empty); + } + } + + private SystemSettings GetWebdavSystemSettigns() + { + return WspContext.Services.Organizations.GetWebDavSystemSettings() ?? new SystemSettings(); + } + public string NewFilePath { get; private set; } public int CobaltFileTtl { get; private set; } diff --git a/WebsitePanel/Sources/WebsitePanel.WebDav.Core/Config/WebConfigSections/OfficeOnlineElementCollection.cs b/WebsitePanel/Sources/WebsitePanel.WebDav.Core/Config/WebConfigSections/OfficeOnlineElementCollection.cs index 51603c99..482fb7b3 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebDav.Core/Config/WebConfigSections/OfficeOnlineElementCollection.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebDav.Core/Config/WebConfigSections/OfficeOnlineElementCollection.cs @@ -6,25 +6,9 @@ namespace WebsitePanel.WebDavPortal.WebConfigSections [ConfigurationCollection(typeof(OfficeOnlineElement))] public class OfficeOnlineElementCollection : ConfigurationElementCollection { - private const string UrlKey = "url"; - private const string IsEnabledKey = "isEnabled"; private const string CobaltFileTtlKey = "cobaltFileTtl"; private const string CobaltNewFilePathKey = "cobaltNewFilePath"; - [ConfigurationProperty(UrlKey, IsKey = true, IsRequired = true)] - public string Url - { - get { return this[UrlKey].ToString(); } - set { this[UrlKey] = value; } - } - - [ConfigurationProperty(IsEnabledKey, IsKey = true, IsRequired = true, DefaultValue = false)] - public bool IsEnabled - { - get { return Boolean.Parse(this[IsEnabledKey].ToString()); } - set { this[IsEnabledKey] = value; } - } - [ConfigurationProperty(CobaltNewFilePathKey, IsKey = true, IsRequired = true)] public string CobaltNewFilePath { diff --git a/WebsitePanel/Sources/WebsitePanel.WebDavPortal/FileOperations/FileOpenerManager.cs b/WebsitePanel/Sources/WebsitePanel.WebDavPortal/FileOperations/FileOpenerManager.cs index a362692d..32e6993d 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebDavPortal/FileOperations/FileOpenerManager.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebDavPortal/FileOperations/FileOpenerManager.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.IO; using System.Linq; using System.Net; @@ -15,18 +16,23 @@ namespace WebsitePanel.WebDavPortal.FileOperations { public class FileOpenerManager { - private readonly IDictionary _officeOperationTypes = new Dictionary(); private readonly IDictionary _operationTypes = new Dictionary(); + private readonly Lazy> _officeOperationTypes = new Lazy>( + () => + { + if (WebDavAppConfigManager.Instance.OfficeOnline.IsEnabled) + { + return + WebDavAppConfigManager.Instance.OfficeOnline.ToDictionary(x => x.Extension, + y => FileOpenerType.OfficeOnline); + } + + return new Dictionary(); + }); + public FileOpenerManager() { - if (WebDavAppConfigManager.Instance.OfficeOnline.IsEnabled) - { - _officeOperationTypes.AddRange( - WebDavAppConfigManager.Instance.OfficeOnline.ToDictionary(x => x.Extension, - y => FileOpenerType.OfficeOnline)); - } - _operationTypes.AddRange( WebDavAppConfigManager.Instance.FileOpener.ToDictionary(x => x.Extension, y => FileOpenerType.Open)); @@ -94,7 +100,7 @@ namespace WebsitePanel.WebDavPortal.FileOperations get { FileOpenerType result; - if (_officeOperationTypes.TryGetValue(fileExtension, out result) && CheckBrowserSupport()) + if (_officeOperationTypes.Value.TryGetValue(fileExtension, out result) && CheckBrowserSupport()) { return result; } diff --git a/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Web.config b/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Web.config index 20161ca7..c61c6b1a 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Web.config +++ b/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Web.config @@ -87,7 +87,7 @@ - + diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/App_LocalResources/SystemSettings.ascx.resx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/App_LocalResources/SystemSettings.ascx.resx index 776683cc..19018369 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/App_LocalResources/SystemSettings.ascx.resx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/App_LocalResources/SystemSettings.ascx.resx @@ -195,4 +195,16 @@ Password Reset Link Life Span (hours): + + Office Web Apps + + + Enable OWA: + + + Yes + + + OWA URL: + \ No newline at end of file diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SystemSettings.ascx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SystemSettings.ascx index d39e917c..745a23bc 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SystemSettings.ascx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SystemSettings.ascx @@ -104,6 +104,22 @@ + + + + + + + + + + +
+ +
+
+
+ diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SystemSettings.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SystemSettings.ascx.cs index 90aeee79..f0b85ff7 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SystemSettings.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SystemSettings.ascx.cs @@ -167,6 +167,9 @@ namespace WebsitePanel.Portal chkEnablePasswordReset.Checked = Utils.ParseBool(settings[WSP.SystemSettings.WEBDAV_PASSWORD_RESET_ENABLED_KEY], false); txtWebdavPortalUrl.Text = settings[WEBDAV_PORTAL_URL]; txtPasswordResetLinkLifeSpan.Text = settings[WSP.SystemSettings.WEBDAV_PASSWORD_RESET_LINK_LIFE_SPAN]; + + chkEnableOwa.Checked = Utils.ParseBool(settings[WSP.SystemSettings.WEBDAV_OWA_ENABLED_KEY], false); + txtOwaUrl.Text = settings[WSP.SystemSettings.WEBDAV_OWA_URL]; } // Twilio portal @@ -264,6 +267,10 @@ namespace WebsitePanel.Portal settings[WEBDAV_PORTAL_URL] = txtWebdavPortalUrl.Text; settings[WSP.SystemSettings.WEBDAV_PASSWORD_RESET_ENABLED_KEY] = chkEnablePasswordReset.Checked.ToString(); settings[WSP.SystemSettings.WEBDAV_PASSWORD_RESET_LINK_LIFE_SPAN] = txtPasswordResetLinkLifeSpan.Text; + + settings[WSP.SystemSettings.WEBDAV_OWA_ENABLED_KEY] = chkEnableOwa.Checked.ToString(); + settings[WSP.SystemSettings.WEBDAV_OWA_URL] = txtOwaUrl.Text; + result = ES.Services.System.SetSystemSettings(WSP.SystemSettings.WEBDAV_PORTAL_SETTINGS, settings); if (result < 0) diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SystemSettings.ascx.designer.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SystemSettings.ascx.designer.cs index a027a548..a85205ca 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SystemSettings.ascx.designer.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/SystemSettings.ascx.designer.cs @@ -300,6 +300,60 @@ namespace WebsitePanel.Portal { /// protected global::System.Web.UI.WebControls.TextBox txtWebdavPortalUrl; + /// + /// OwaSettings control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::WebsitePanel.Portal.CollapsiblePanel OwaSettings; + + /// + /// PanelOwaSettings control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Panel PanelOwaSettings; + + /// + /// locEnableOwa control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Localize locEnableOwa; + + /// + /// chkEnableOwa control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.CheckBox chkEnableOwa; + + /// + /// locOwaUrl control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Localize locOwaUrl; + + /// + /// txtOwaUrl control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.TextBox txtOwaUrl; + /// /// TwilioSettings control. ///