From 0d80eb3e6d309c222fea4f6785f3581da8298d01 Mon Sep 17 00:00:00 2001 From: Christopher York Date: Wed, 9 Jan 2013 17:27:45 -0600 Subject: [PATCH 01/11] Fixed: Parse error: syntax error, unexpected T_BOOLEAN_OR error --- WebsitePanel.WHMCSModule/includes/hooks/websitepanel_sync.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WebsitePanel.WHMCSModule/includes/hooks/websitepanel_sync.php b/WebsitePanel.WHMCSModule/includes/hooks/websitepanel_sync.php index 1487b98e..46a7a10e 100644 --- a/WebsitePanel.WHMCSModule/includes/hooks/websitepanel_sync.php +++ b/WebsitePanel.WHMCSModule/includes/hooks/websitepanel_sync.php @@ -53,7 +53,7 @@ function websitepanel_sync_ClientEdit($params) // Retrieve the WebsitePanel Addons module settings $modSettings = websitepanel_sync_GetSettings(); - if (empty($modSettings['username']) || empty($modSettings['password'])) || empty($modSettings['serverhost'])) || empty($modSettings['serverport']))) + if (empty($modSettings['username']) || empty($modSettings['password']) || empty($modSettings['serverhost']) || empty($modSettings['serverport'])) { // The module is disabled or has not yet been configured - stop return; From 3fb60ed6b310a22d424d32b88568b410f8284d8b Mon Sep 17 00:00:00 2001 From: Christopher York Date: Thu, 10 Jan 2013 10:13:37 -0600 Subject: [PATCH 02/11] Fixed: Parse error: syntax error, unexpected T_BOOLEAN_OR --- WebsitePanel.WHMCSModule/includes/hooks/websitepanel_addons.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WebsitePanel.WHMCSModule/includes/hooks/websitepanel_addons.php b/WebsitePanel.WHMCSModule/includes/hooks/websitepanel_addons.php index 4666d0e4..5d628e81 100644 --- a/WebsitePanel.WHMCSModule/includes/hooks/websitepanel_addons.php +++ b/WebsitePanel.WHMCSModule/includes/hooks/websitepanel_addons.php @@ -54,7 +54,7 @@ function websitepanel_addons_AddonActivation($params) // Retrieve the WebsitePanel Addons module settings $modSettings = websitepanel_addons_GetSettings(); - if (empty($modSettings['username']) || empty($modSettings['password'])) || empty($modSettings['serverhost'])) || empty($modSettings['serverport']))) + if (empty($modSettings['username']) || empty($modSettings['password']) || empty($modSettings['serverhost']) || empty($modSettings['serverport'])) { // The module is disabled or has not yet been configured - stop return; From d3ae924c6006b6218746a16a04188799dc4e9788 Mon Sep 17 00:00:00 2001 From: Virtuworks Date: Fri, 11 Jan 2013 19:01:32 -0500 Subject: [PATCH 03/11] Update Build.xml for WebPI Changes --- WebsitePanel/build.xml | 71 ++++++++++++++++++++++++------------------ 1 file changed, 40 insertions(+), 31 deletions(-) diff --git a/WebsitePanel/build.xml b/WebsitePanel/build.xml index a821fa72..e768a727 100644 --- a/WebsitePanel/build.xml +++ b/WebsitePanel/build.xml @@ -3,7 +3,7 @@ 2.0.0 $(BUILD_NUMBER) $(BUILD_NUMBER) - 2012-12-07 + 2012-1-11 .. $(RootFolder)\WebsitePanel @@ -20,10 +20,10 @@ $(TrunkFolder)\Tools\Diff.exe "$(RootFolder)\tools\sqlcmd\sqlcmd.exe" -S (local)\SQLEXPRESS -E - "$(RootFolder)\tools\webdeploy\msdeploy.exe" + "$(RootFolder)\tools\webdeploy\msdeploy.exe" "C:\Program Files\7-Zip\7z.exe" - WebsitePanel_build + WebsitePanel_build server=(local)\SQLEXPRESS;database=$(DataBaseName);Integrated Security=true; $(TrunkFolder)\Sources\WebsitePanel.WebPortal @@ -59,6 +59,11 @@ + + + http://www.websitepanel.net/files/$(Version)/WebsitePanelInstaller-$(Version)-webpi.msi + + @@ -185,7 +190,7 @@ - + @@ -194,7 +199,7 @@ - + @@ -379,7 +384,7 @@ - + @@ -389,7 +394,7 @@ - + @@ -634,9 +639,11 @@ - + + - + + @@ -663,13 +670,14 @@ ]]> + - + $(Version) @@ -687,33 +695,34 @@ $(InstallerFileChecksum) - TODO: Evaluate MSI file URL + $(InstallerRemoteUri) - + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + From 38938c090276912d65f77e419679bd61af1b4ae3 Mon Sep 17 00:00:00 2001 From: Virtuworks Date: Fri, 11 Jan 2013 19:50:46 -0500 Subject: [PATCH 04/11] Create a seperate upload task for webpi xml --- WebsitePanel/build.xml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/WebsitePanel/build.xml b/WebsitePanel/build.xml index e768a727..0c447a53 100644 --- a/WebsitePanel/build.xml +++ b/WebsitePanel/build.xml @@ -639,6 +639,10 @@ + + + + @@ -717,11 +721,10 @@ - + - From a54c5e1eb80612e48a36f10ce9919c4e61a59794 Mon Sep 17 00:00:00 2001 From: Virtuworks Date: Mon, 14 Jan 2013 17:11:20 -0500 Subject: [PATCH 05/11] Fix issue with Web Scheduler crashing Enterprise Server --- .../Code/SchedulerTasks/CheckWebSiteTask.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/SchedulerTasks/CheckWebSiteTask.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/SchedulerTasks/CheckWebSiteTask.cs index fcd83826..c16812d9 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/SchedulerTasks/CheckWebSiteTask.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/SchedulerTasks/CheckWebSiteTask.cs @@ -31,6 +31,7 @@ using System.IO; using System.Net; using System.Collections.Generic; using System.Text; +using System.Threading; namespace WebsitePanel.EnterpriseServer { @@ -166,6 +167,7 @@ namespace WebsitePanel.EnterpriseServer WebSiteResponse result = new WebSiteResponse(); HttpWebResponse resp = null; StringBuilder sb = new StringBuilder(); + Stream respStream = null; try { WebRequest req = WebRequest.Create(url); @@ -177,7 +179,7 @@ namespace WebsitePanel.EnterpriseServer } resp = (HttpWebResponse)req.GetResponse(); - Stream respStream = resp.GetResponseStream(); + respStream = resp.GetResponseStream(); string charSet = !String.IsNullOrEmpty(resp.CharacterSet) ? resp.CharacterSet : "utf-8"; Encoding encode = System.Text.Encoding.GetEncoding(charSet); @@ -196,6 +198,9 @@ namespace WebsitePanel.EnterpriseServer result.Status = (int)resp.StatusCode; result.Text = sb.ToString(); } + catch (ThreadAbortException) + { + } catch (WebException ex) { result.Status = (int)((HttpWebResponse)ex.Response).StatusCode; @@ -210,10 +215,16 @@ namespace WebsitePanel.EnterpriseServer } finally { + if (respStream != null) + { + respStream.Close(); + } + if (resp != null) { resp.Close(); } + } return result; From f1b05c9ea05bee3a0e259640e24a09cb47b9b197 Mon Sep 17 00:00:00 2001 From: Virtuworks Date: Mon, 14 Jan 2013 17:20:41 -0500 Subject: [PATCH 06/11] Add SP manual-update-sp.zip to have ability to upload a current build that does not affect release --- WebsitePanel/build.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/WebsitePanel/build.xml b/WebsitePanel/build.xml index 0c447a53..b2197158 100644 --- a/WebsitePanel/build.xml +++ b/WebsitePanel/build.xml @@ -705,6 +705,9 @@ + + + From 5b3c358a023ef043382db71df22c0e920707c0c3 Mon Sep 17 00:00:00 2001 From: Christopher York Date: Tue, 15 Jan 2013 11:39:18 -0600 Subject: [PATCH 07/11] Fixed: SOAP compression causes exceptions on certain PHP installations Updated: Readme.txt updated --- .../modules/servers/websitepanel/websitepanel.class.php | 1 - WebsitePanel.WHMCSModule/readme.txt | 9 +++------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/WebsitePanel.WHMCSModule/modules/servers/websitepanel/websitepanel.class.php b/WebsitePanel.WHMCSModule/modules/servers/websitepanel/websitepanel.class.php index 7c99db93..8e8d8f7e 100644 --- a/WebsitePanel.WHMCSModule/modules/servers/websitepanel/websitepanel.class.php +++ b/WebsitePanel.WHMCSModule/modules/servers/websitepanel/websitepanel.class.php @@ -415,7 +415,6 @@ class WebsitePanel $soapParams = array('login' => $this->_esUsername, 'password' => $this->_esPassword, 'cache_wsdl' => WSDL_CACHE_NONE, // WSDL caching is an annoying nightmare - we will disable it - 'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP ); try { diff --git a/WebsitePanel.WHMCSModule/readme.txt b/WebsitePanel.WHMCSModule/readme.txt index 9da3efc4..dade497c 100644 --- a/WebsitePanel.WHMCSModule/readme.txt +++ b/WebsitePanel.WHMCSModule/readme.txt @@ -13,10 +13,7 @@ To enable addon automation... What does not work? - Quantities, only a single addon => addon can be allocated - Terminating / Suspending Addons, I've ran out of time on what I can do currently -- When an IP address is allocated WebsitePanel does not return back what IP was allocated, so WHMCS is not updated which what IP has been allocated to -his / her package at this time. +- When an IP address is allocated WebsitePanel does not return back what IP was allocated, so WHMCS is not updated which what IP has been allocated to his / her package at this time. - A single user => single package is the only way the WebsitePanel server module works. I have no plans on making this work any other way. -- Users who use empty pointers when creating websites (domain.com instead of www.domain.com), websites are not created automatically even if the "Create Website" - option is selected. I have provided a patch to the websitepanel developers, should be fixed in a later release. -- The "Enable DNS Zone" option does not currently work - I have provided a patch to the websitepanel developers, should be fixed in a later release. -- Instant aliases / Temp domain are not properly created for websites, I have provided a patch to the websitepanel developers, should be fixed in a later release. \ No newline at end of file + +DO NOT CONTACT WHMCS FOR SUPPORT WITH THIS MODULE - THIS IS NOT DEVELOPED BY WHMCS AND HAS NO AFFILIATION WITH WHMCS OR WHMCS.COM. \ No newline at end of file From c3d784d327a27b59cf8f3ae49d4ec1fe10431794 Mon Sep 17 00:00:00 2001 From: Christopher York Date: Tue, 15 Jan 2013 11:44:31 -0600 Subject: [PATCH 08/11] Fixed: Stupid comma missed :) --- .../modules/servers/websitepanel/websitepanel.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WebsitePanel.WHMCSModule/modules/servers/websitepanel/websitepanel.class.php b/WebsitePanel.WHMCSModule/modules/servers/websitepanel/websitepanel.class.php index 8e8d8f7e..c9689251 100644 --- a/WebsitePanel.WHMCSModule/modules/servers/websitepanel/websitepanel.class.php +++ b/WebsitePanel.WHMCSModule/modules/servers/websitepanel/websitepanel.class.php @@ -414,7 +414,7 @@ class WebsitePanel $esUrl = (($this->_esUseSsl ? "https" : "http") . "://{$this->_esServerUrl}:{$this->_esServerPort}/{$serviceFile}?WSDL"); $soapParams = array('login' => $this->_esUsername, 'password' => $this->_esPassword, - 'cache_wsdl' => WSDL_CACHE_NONE, // WSDL caching is an annoying nightmare - we will disable it + 'cache_wsdl' => WSDL_CACHE_NONE // WSDL caching is an annoying nightmare - we will disable it ); try { From 3a22ea2ef09d044baebfc5885dd190d406bee41a Mon Sep 17 00:00:00 2001 From: Christopher York Date: Tue, 15 Jan 2013 16:44:34 -0600 Subject: [PATCH 09/11] Fixed: (WHMCS Module) - Domain is not created even if the "Create Zone Record" checkbox is checked. --- .../Code/Wizards/UserCreationWizard.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/Wizards/UserCreationWizard.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/Wizards/UserCreationWizard.cs index 4f4fbdee..c30c70aa 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/Wizards/UserCreationWizard.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/Wizards/UserCreationWizard.cs @@ -165,7 +165,7 @@ namespace WebsitePanel.EnterpriseServer // create domain int domainId = 0; - if ((createWebSite || createMailAccount) && !String.IsNullOrEmpty(domainName)) + if ((createWebSite || createMailAccount || createZoneRecord) && !String.IsNullOrEmpty(domainName)) { try { @@ -193,7 +193,7 @@ namespace WebsitePanel.EnterpriseServer } } - if (createWebSite && !String.IsNullOrEmpty(domainName)) + if (createWebSite && (domainId > 0)) { // create web site try @@ -252,7 +252,7 @@ namespace WebsitePanel.EnterpriseServer } } - if (createMailAccount && !String.IsNullOrEmpty(domainName)) + if (createMailAccount && (domainId > 0)) { // create default mailbox try From bdd51f21510567f68b239492cdf711dc2607fe89 Mon Sep 17 00:00:00 2001 From: Christopher York Date: Fri, 18 Jan 2013 13:05:15 -0600 Subject: [PATCH 10/11] Fixed: Enabling DNS / Temporary URL not enabling properly for WHMCS Changed: SmarterMail 5 - 10 now calculates disk space usage using the API not the file system / user path. --- .../Code/Wizards/UserCreationWizard.cs | 28 +++++++-------- .../SmarterMail10.cs | 36 ++++++++----------- .../SmarterMail5.cs | 26 ++++++-------- .../SmarterMail6.cs | 26 ++++++-------- .../SmarterMail7.cs | 36 ++++++++----------- .../SmarterMail9.cs | 26 ++++++-------- 6 files changed, 74 insertions(+), 104 deletions(-) diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/Wizards/UserCreationWizard.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/Wizards/UserCreationWizard.cs index c30c70aa..44556807 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/Wizards/UserCreationWizard.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/Wizards/UserCreationWizard.cs @@ -310,25 +310,25 @@ namespace WebsitePanel.EnterpriseServer // error while creating mail account throw new Exception("Could not create mail account", ex); } + } - // Instant Alias / Temporary URL - if (tempDomain && (domainId > 0)) + // Instant Alias / Temporary URL + if (tempDomain && (domainId > 0)) + { + int instantAliasId = ServerController.CreateDomainInstantAlias("", domainId); + if (instantAliasId < 0) { - int instantAliasId = ServerController.CreateDomainInstantAlias("", domainId); - if (instantAliasId < 0) - { - // rollback wizard - Rollback(); + // rollback wizard + Rollback(); - return instantAliasId; - } + return instantAliasId; } + } - // Domain DNS Zone - if (createZoneRecord && (domainId > 0)) - { - ServerController.EnableDomainDns(domainId); - } + // Domain DNS Zone + if (createZoneRecord && (domainId > 0)) + { + ServerController.EnableDomainDns(domainId); } } diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Mail.SmarterMail10/SmarterMail10.cs b/WebsitePanel/Sources/WebsitePanel.Providers.Mail.SmarterMail10/SmarterMail10.cs index 97ece705..2fd4a4d7 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.Mail.SmarterMail10/SmarterMail10.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.Mail.SmarterMail10/SmarterMail10.cs @@ -200,29 +200,23 @@ namespace WebsitePanel.Providers.Mail { try { + svcUserAdmin users = new svcUserAdmin(); + PrepareProxy(users); - // get mailbox size - string name = item.Name; + StatInfoResult userStats = users.GetUserStats(AdminUsername, AdminPassword, item.Name, DateTime.Now, DateTime.Now); + if (!userStats.Result) + { + throw new Exception(userStats.Message); + } - // try to get SmarterMail postoffices path - string poPath = DomainsPath; - if (poPath == null) - continue; - - string mailboxName = name.Substring(0, name.IndexOf("@")); - string domainName = name.Substring(name.IndexOf("@") + 1); - - string mailboxPath = Path.Combine(DomainsPath, String.Format("{0}\\Users\\{1}", domainName, mailboxName)); - - Log.WriteStart(String.Format("Calculating '{0}' folder size", mailboxPath)); - - // calculate disk space - ServiceProviderItemDiskSpace diskspace = new ServiceProviderItemDiskSpace(); - diskspace.ItemId = item.Id; - //diskspace.DiskSpace = 0; - diskspace.DiskSpace = FileUtils.CalculateFolderSize(mailboxPath); - itemsDiskspace.Add(diskspace); - Log.WriteEnd(String.Format("Calculating '{0}' folder size", mailboxPath)); + Log.WriteStart(String.Format("Calculating mail account '{0}' size", item.Name)); + // calculate disk space + ServiceProviderItemDiskSpace diskspace = new ServiceProviderItemDiskSpace(); + diskspace.ItemId = item.Id; + //diskspace.DiskSpace = 0; + diskspace.DiskSpace = userStats.BytesSize; + itemsDiskspace.Add(diskspace); + Log.WriteEnd(String.Format("Calculating mail account '{0}' size", item.Name)); } catch (Exception ex) { diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Mail.SmarterMail5/SmarterMail5.cs b/WebsitePanel/Sources/WebsitePanel.Providers.Mail.SmarterMail5/SmarterMail5.cs index 56e8cb21..2433bff8 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.Mail.SmarterMail5/SmarterMail5.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.Mail.SmarterMail5/SmarterMail5.cs @@ -1570,29 +1570,23 @@ namespace WebsitePanel.Providers.Mail { try { + svcUserAdmin users = new svcUserAdmin(); + PrepareProxy(users); - // get mailbox size - string name = item.Name; - - // try to get SmarterMail postoffices path - string poPath = DomainsPath; - if (poPath == null) - continue; - - string mailboxName = name.Substring(0, name.IndexOf("@")); - string domainName = name.Substring(name.IndexOf("@") + 1); - - string mailboxPath = Path.Combine(DomainsPath, String.Format("{0}\\Users\\{1}", domainName, mailboxName)); - - Log.WriteStart(String.Format("Calculating '{0}' folder size", mailboxPath)); + StatInfoResult userStats = users.GetUserStats(AdminUsername, AdminPassword, item.Name, DateTime.Now, DateTime.Now); + if (!userStats.Result) + { + throw new Exception(userStats.Message); + } + Log.WriteStart(String.Format("Calculating mail account '{0}' size", item.Name)); // calculate disk space ServiceProviderItemDiskSpace diskspace = new ServiceProviderItemDiskSpace(); diskspace.ItemId = item.Id; //diskspace.DiskSpace = 0; - diskspace.DiskSpace = FileUtils.CalculateFolderSize(mailboxPath); + diskspace.DiskSpace = userStats.BytesSize; itemsDiskspace.Add(diskspace); - Log.WriteEnd(String.Format("Calculating '{0}' folder size", mailboxPath)); + Log.WriteEnd(String.Format("Calculating mail account '{0}' size", item.Name)); } catch (Exception ex) { diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Mail.SmarterMail6/SmarterMail6.cs b/WebsitePanel/Sources/WebsitePanel.Providers.Mail.SmarterMail6/SmarterMail6.cs index cfa88210..64a3369d 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.Mail.SmarterMail6/SmarterMail6.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.Mail.SmarterMail6/SmarterMail6.cs @@ -200,29 +200,23 @@ namespace WebsitePanel.Providers.Mail { try { + svcUserAdmin users = new svcUserAdmin(); + PrepareProxy(users); - // get mailbox size - string name = item.Name; - - // try to get SmarterMail postoffices path - string poPath = DomainsPath; - if (poPath == null) - continue; - - string mailboxName = name.Substring(0, name.IndexOf("@")); - string domainName = name.Substring(name.IndexOf("@") + 1); - - string mailboxPath = Path.Combine(DomainsPath, String.Format("{0}\\Users\\{1}", domainName, mailboxName)); - - Log.WriteStart(String.Format("Calculating '{0}' folder size", mailboxPath)); + StatInfoResult userStats = users.GetUserStats(AdminUsername, AdminPassword, item.Name, DateTime.Now, DateTime.Now); + if (!userStats.Result) + { + throw new Exception(userStats.Message); + } + Log.WriteStart(String.Format("Calculating mail account '{0}' size", item.Name)); // calculate disk space ServiceProviderItemDiskSpace diskspace = new ServiceProviderItemDiskSpace(); diskspace.ItemId = item.Id; //diskspace.DiskSpace = 0; - diskspace.DiskSpace = FileUtils.CalculateFolderSize(mailboxPath); + diskspace.DiskSpace = userStats.BytesSize; itemsDiskspace.Add(diskspace); - Log.WriteEnd(String.Format("Calculating '{0}' folder size", mailboxPath)); + Log.WriteEnd(String.Format("Calculating mail account '{0}' size", item.Name)); } catch (Exception ex) { diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Mail.SmarterMail7/SmarterMail7.cs b/WebsitePanel/Sources/WebsitePanel.Providers.Mail.SmarterMail7/SmarterMail7.cs index 5f6df0b4..7d5d69a0 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.Mail.SmarterMail7/SmarterMail7.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.Mail.SmarterMail7/SmarterMail7.cs @@ -200,29 +200,23 @@ namespace WebsitePanel.Providers.Mail { try { + svcUserAdmin users = new svcUserAdmin(); + PrepareProxy(users); - // get mailbox size - string name = item.Name; + StatInfoResult userStats = users.GetUserStats(AdminUsername, AdminPassword, item.Name, DateTime.Now, DateTime.Now); + if (!userStats.Result) + { + throw new Exception(userStats.Message); + } - // try to get SmarterMail postoffices path - string poPath = DomainsPath; - if (poPath == null) - continue; - - string mailboxName = name.Substring(0, name.IndexOf("@")); - string domainName = name.Substring(name.IndexOf("@") + 1); - - string mailboxPath = Path.Combine(DomainsPath, String.Format("{0}\\Users\\{1}", domainName, mailboxName)); - - Log.WriteStart(String.Format("Calculating '{0}' folder size", mailboxPath)); - - // calculate disk space - ServiceProviderItemDiskSpace diskspace = new ServiceProviderItemDiskSpace(); - diskspace.ItemId = item.Id; - //diskspace.DiskSpace = 0; - diskspace.DiskSpace = FileUtils.CalculateFolderSize(mailboxPath); - itemsDiskspace.Add(diskspace); - Log.WriteEnd(String.Format("Calculating '{0}' folder size", mailboxPath)); + Log.WriteStart(String.Format("Calculating mail account '{0}' size", item.Name)); + // calculate disk space + ServiceProviderItemDiskSpace diskspace = new ServiceProviderItemDiskSpace(); + diskspace.ItemId = item.Id; + //diskspace.DiskSpace = 0; + diskspace.DiskSpace = userStats.BytesSize; + itemsDiskspace.Add(diskspace); + Log.WriteEnd(String.Format("Calculating mail account '{0}' size", item.Name)); } catch (Exception ex) { diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Mail.SmarterMail9/SmarterMail9.cs b/WebsitePanel/Sources/WebsitePanel.Providers.Mail.SmarterMail9/SmarterMail9.cs index 3ce85581..4a1bbde2 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.Mail.SmarterMail9/SmarterMail9.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.Mail.SmarterMail9/SmarterMail9.cs @@ -200,29 +200,23 @@ namespace WebsitePanel.Providers.Mail { try { + svcUserAdmin users = new svcUserAdmin(); + PrepareProxy(users); - // get mailbox size - string name = item.Name; - - // try to get SmarterMail postoffices path - string poPath = DomainsPath; - if (poPath == null) - continue; - - string mailboxName = name.Substring(0, name.IndexOf("@")); - string domainName = name.Substring(name.IndexOf("@") + 1); - - string mailboxPath = Path.Combine(DomainsPath, String.Format("{0}\\Users\\{1}", domainName, mailboxName)); - - Log.WriteStart(String.Format("Calculating '{0}' folder size", mailboxPath)); + StatInfoResult userStats = users.GetUserStats(AdminUsername, AdminPassword, item.Name, DateTime.Now, DateTime.Now); + if (!userStats.Result) + { + throw new Exception(userStats.Message); + } + Log.WriteStart(String.Format("Calculating mail account '{0}' size", item.Name)); // calculate disk space ServiceProviderItemDiskSpace diskspace = new ServiceProviderItemDiskSpace(); diskspace.ItemId = item.Id; //diskspace.DiskSpace = 0; - diskspace.DiskSpace = FileUtils.CalculateFolderSize(mailboxPath); + diskspace.DiskSpace = userStats.BytesSize; itemsDiskspace.Add(diskspace); - Log.WriteEnd(String.Format("Calculating '{0}' folder size", mailboxPath)); + Log.WriteEnd(String.Format("Calculating mail account '{0}' size", item.Name)); } catch (Exception ex) { From 96ca6053b6712768578847aefe9429bec1b6d6eb Mon Sep 17 00:00:00 2001 From: Virtuworks Date: Fri, 18 Jan 2013 18:47:19 -0500 Subject: [PATCH 11/11] Update cvsbulk import to support mailbox plans --- .../ExchangeImport.cs | 55 +++++++++++++++++-- 1 file changed, 50 insertions(+), 5 deletions(-) diff --git a/WebsitePanel/Sources/Tools/WebsitePanel.Import.CsvBulk/ExchangeImport.cs b/WebsitePanel/Sources/Tools/WebsitePanel.Import.CsvBulk/ExchangeImport.cs index ac586b4b..77c16c9c 100644 --- a/WebsitePanel/Sources/Tools/WebsitePanel.Import.CsvBulk/ExchangeImport.cs +++ b/WebsitePanel/Sources/Tools/WebsitePanel.Import.CsvBulk/ExchangeImport.cs @@ -92,7 +92,10 @@ namespace WebsitePanel.Import.CsvBulk private int PagerIndex = -1; private int WebPageIndex = -1; private int NotesIndex = -1; + private int PlanIndex = -1; + private int defaultPlanId = -1; + private Dictionary planName2Id = new Dictionary(); public ExchangeImport() { @@ -184,6 +187,8 @@ namespace WebsitePanel.Import.CsvBulk } index = 0; + GetMailboxPlans(orgId); + using (StreamReader sr = new StreamReader(inputFile)) { string line; @@ -210,6 +215,22 @@ namespace WebsitePanel.Import.CsvBulk } } + private void GetMailboxPlans(int orgId) + { + ExchangeMailboxPlan[] plans = ES.Services.ExchangeServer.GetExchangeMailboxPlans(orgId); + foreach (ExchangeMailboxPlan plan in plans) + { + if (!planName2Id.ContainsKey(plan.MailboxPlan)) + { + planName2Id.Add(plan.MailboxPlan, plan.MailboxPlanId); + } + if (plan.IsDefault) + { + defaultPlanId = plan.MailboxPlanId; + } + } + } + private void ShowSummary() { Log.WriteLine(string.Format("{0} line(s) processed", index)); @@ -286,7 +307,9 @@ namespace WebsitePanel.Import.CsvBulk WebPageIndex = i; else if (StringEquals(cells[i], "Notes")) NotesIndex = i; - } + else if (StringEquals(cells[i], "Mailbox Plan")) + PlanIndex = i; + } return true; } //check csv structure @@ -430,6 +453,29 @@ namespace WebsitePanel.Import.CsvBulk string webPage = cells[WebPageIndex]; string notes = cells[NotesIndex]; + int planId; + // do we have plan-column? + if (PlanIndex > -1) + { + string planName = cells[PlanIndex]; + if (!planName2Id.TryGetValue(planName, out planId)) + { + Log.WriteInfo(String.Format("Warning at line {0}: Plan named {1} does not exist!", index + 1, planName)); + // fall back to default plan + planId = defaultPlanId; + } + } + // or not? + else + { + // fall back to default plan + planId = defaultPlanId; + } + if (planId < 0) + { + Log.WriteError(string.Format("Error at line {0}: No valid plan name and/or no valid default plan", index + 1)); + return false; + } @@ -480,7 +526,7 @@ namespace WebsitePanel.Import.CsvBulk //create mailbox using web service if (!CreateMailbox(index, orgId, displayName, emailAddress, password, firstName, middleName, lastName, address, city, state, zip, country, jobTitle, company, department, office, - businessPhone, fax, homePhone, mobilePhone, pager, webPage, notes)) + businessPhone, fax, homePhone, mobilePhone, pager, webPage, notes, planId)) { return false; } @@ -517,7 +563,7 @@ namespace WebsitePanel.Import.CsvBulk /// private bool CreateMailbox(int index, int orgId, string displayName, string emailAddress, string password, string firstName, string middleName, string lastName, string address, string city, string state, string zip, string country, string jobTitle, string company, string department, string office, - string businessPhone, string fax, string homePhone, string mobilePhone, string pager, string webPage, string notes) + string businessPhone, string fax, string homePhone, string mobilePhone, string pager, string webPage, string notes, int planId) { bool ret = false; try @@ -528,7 +574,7 @@ namespace WebsitePanel.Import.CsvBulk //create mailbox //ES.Services.ExchangeServer. string accountName = string.Empty; - int accountId = ES.Services.ExchangeServer.CreateMailbox(orgId, 0, ExchangeAccountType.Mailbox, accountName, displayName, name, domain, password, false, string.Empty, 0, string.Empty); + int accountId = ES.Services.ExchangeServer.CreateMailbox(orgId, 0, ExchangeAccountType.Mailbox, accountName, displayName, name, domain, password, false, string.Empty, planId, string.Empty); if (accountId < 0) { string errorMessage = GetErrorMessage(accountId); @@ -557,7 +603,6 @@ namespace WebsitePanel.Import.CsvBulk mailbox.WebPage = webPage; mailbox.Notes = notes; - //update mailbox /* ES.Services.ExchangeServer.SetMailboxGeneralSettings(orgId, accountId, mailbox.DisplayName,