merge commit

This commit is contained in:
robvde 2013-01-19 09:56:31 +04:00
commit 5309b1d973
13 changed files with 191 additions and 154 deletions

View file

@ -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;

View file

@ -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;

View file

@ -414,8 +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
'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP
'cache_wsdl' => WSDL_CACHE_NONE // WSDL caching is an annoying nightmare - we will disable it
);
try
{

View file

@ -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.
DO NOT CONTACT WHMCS FOR SUPPORT WITH THIS MODULE - THIS IS NOT DEVELOPED BY WHMCS AND HAS NO AFFILIATION WITH WHMCS OR WHMCS.COM.

View file

@ -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<string, int> planName2Id = new Dictionary<string,int>();
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,6 +307,8 @@ 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;
}
@ -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
/// </summary>
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,

View file

@ -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;

View file

@ -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
@ -310,6 +310,7 @@ 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))
@ -330,7 +331,6 @@ namespace WebsitePanel.EnterpriseServer
ServerController.EnableDomainDns(domainId);
}
}
}
// send welcome letters
if (sendAccountLetter)

View file

@ -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)
{

View file

@ -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)
{

View file

@ -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)
{

View file

@ -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)
{

View file

@ -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)
{

View file

@ -3,7 +3,7 @@
<Version>2.0.0</Version>
<FileVersion>$(BUILD_NUMBER)</FileVersion>
<VersionLabel>$(BUILD_NUMBER)</VersionLabel>
<ReleaseDate>2012-12-07</ReleaseDate>
<ReleaseDate>2012-1-11</ReleaseDate>
<BuildConfiguration></BuildConfiguration>
<RootFolder>..</RootFolder>
<TrunkFolder>$(RootFolder)\WebsitePanel</TrunkFolder>
@ -59,6 +59,11 @@
</PropertyGroup>
<PropertyGroup Label="WebPlatformFeed">
<!-- URI where to locate the installer's distributive online -->
<InstallerRemoteUri>http://www.websitepanel.net/files/$(Version)/WebsitePanelInstaller-$(Version)-webpi.msi</InstallerRemoteUri>
</PropertyGroup>
<Target Name="GenerateBuildVersionFilesInstaller">
<AssemblyInfo CodeLanguage="CS" OutputFile="$(RootFolder)\WebsitePanel.Installer\Sources\VersionInfo.cs" AssemblyCompany="Outercurve Foundation" AssemblyCopyright="Copyright © 2012 Outercurve Foundation." AssemblyVersion="$(VersionLabel)" AssemblyFileVersion="$(FileVersion)" AssemblyInformationalVersion="$(Version)" />
</Target>
@ -634,9 +639,15 @@
</Target>
<Target Name="BuildWebPlatformInstallerFeed" DependsOnTargets="Deploy">
<Target Name="uploadwebpi" DependsOnTargets="BuildWebPlatformInstallerFeed">
<FtpUpload Username="$(ftpUsername)" password="$(ftpPassword)" RemoteUri="ftp://$(ftphost)/WebsitePanelFeed-$(Version).xml" LocalFile="$(DeployFolder)\WebsitePanelFeed.xml" />
</Target>
<!-- This task depends on FTP upload task and will be run afterwards -->
<Target Name="BuildWebPlatformInstallerFeed" DependsOnTargets="uploadtoftp">
<ItemGroup>
<InstallerFilePath Include="$(DeployFolder)\WebsitePanelInstaller.msi" />
<!-- This will generate path to a temporary file that will be used by WebDownload task below to download the installer's distributive locally -->
<InstallerFilePath Include="$([System.IO.Path]::GetTempFileName())" />
</ItemGroup>
<PropertyGroup>
<GetFileSizeScript>
@ -663,13 +674,14 @@
]]>
</ComputeChecksumScript>
</PropertyGroup>
<WebDownload FileUri="$(InstallerRemoteUri)" FileName="%(InstallerFilePath.FullPath)" />
<Script Language="C#" Code="$(ComputeChecksumScript)">
<Output TaskParameter="ReturnValue" PropertyName="InstallerFileChecksum" />
</Script>
<Script Language="C#" Code="$(GetFileSizeScript)">
<Output TaskParameter="ReturnValue" PropertyName="InstallerFileSize" />
</Script>
<Delete Files="%(InstallerFilePath.FullPath)" />
<ItemGroup>
<Tokens Include="ProductVersion">
<ReplacementValue>$(Version)</ReplacementValue>
@ -687,12 +699,15 @@
<ReplacementValue>$(InstallerFileChecksum)</ReplacementValue>
</Tokens>
<Tokens Include="InstallerFileUrl">
<ReplacementValue>TODO: Evaluate MSI file URL</ReplacementValue>
<ReplacementValue>$(InstallerRemoteUri)</ReplacementValue>
</Tokens>
</ItemGroup>
<TemplateFile Template="$(TrunkFolder)\WebsitePanelFeedTemplate.xml" OutputFilename="$(DeployFolder)\WebsitePanelFeed.xml" Tokens="@(Tokens)" />
</Target>
<Target Name="upload-sp-update">
<FtpUpload Username="$(ftpUsername)" password="$(ftpPassword)" RemoteUri="ftp://$(ftphost)/Manual-Update-sp-$(Version).zip" LocalFile="$(DeployFolder)\Manual-Update.zip" />
</Target>
<Target Name="uploadtoftp">
<FtpUpload Username="$(ftpUsername)" password="$(ftpPassword)" RemoteUri="ftp://$(ftphost)/WebsitePanel-Portal-$(Version).zip" LocalFile="$(DeployFolder)\WebsitePanel-Portal-$(Version).zip" />
@ -709,10 +724,10 @@
<FtpUpload Username="$(ftpUsername)" password="$(ftpPassword)" RemoteUri="ftp://$(ftphost)/WebsitePanel-WSPTransportAgent-$(Version).zip" LocalFile="$(ToolsFolder)\WebsitePanel-WSPTransportAgent-$(Version).zip" />
<FtpUpload Username="$(ftpUsername)" password="$(ftpPassword)" RemoteUri="ftp://$(ftphost)/WebsitePanel.LocalizationToolkit-$(Version).msi" LocalFile="$(ToolsFolder)\WebsitePanel.LocalizationToolkit.msi" />
<FtpUpload Username="$(ftpUsername)" password="$(ftpPassword)" RemoteUri="ftp://$(ftphost)/WebsitePanelInstaller-$(Version).msi" LocalFile="$(DeployFolder)\WebsitePanelInstaller.msi" />
<FtpUpload Username="$(ftpUsername)" password="$(ftpPassword)" RemoteUri="ftp://$(ftphost)/WebsitePanelInstaller-$(Version)-webpi.msi" LocalFile="$(DeployFolder)\WebsitePanelInstaller.msi" />
<FtpUpload Username="$(ftpUsername)" password="$(ftpPassword)" RemoteUri="ftp://$(ftphost)/WebsitePanel-HyperVUtils-$(Version).zip" LocalFile="$(ToolsFolder)\WebsitePanel-HyperVUtils-$(Version).zip" />
<FtpUpload Username="$(ftpUsername)" password="$(ftpPassword)" RemoteUri="ftp://$(ftphost)/WebsitePanel-VMConfig-$(Version).zip" LocalFile="$(ToolsFolder)\WebsitePanel-VMConfig-$(Version).zip" />
<FtpUpload Username="$(ftpUsername)" password="$(ftpPassword)" RemoteUri="ftp://$(ftphost)/Manual-Update-$(Version).zip" LocalFile="$(DeployFolder)\Manual-Update.zip" />
<FtpUpload Username="$(ftpUsername)" password="$(ftpPassword)" RemoteUri="ftp://$(ftphost)/WebsitePanelFeed-$(Version).xml" LocalFile="$(DeployFolder)\WebsitePanelFeed.xml" />
</Target>
<Import Project="$(RootFolder)\tools\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets"/>