diff --git a/WebsitePanel.Installer/Sources/Setup.SchedulerService/Setup.SchedulerService.wixproj b/WebsitePanel.Installer/Sources/Setup.SchedulerService/Setup.SchedulerService.wixproj index e067c9b7..4f0a70f4 100644 --- a/WebsitePanel.Installer/Sources/Setup.SchedulerService/Setup.SchedulerService.wixproj +++ b/WebsitePanel.Installer/Sources/Setup.SchedulerService/Setup.SchedulerService.wixproj @@ -3,7 +3,7 @@ Debug x86 - 3.7 + 3.9 {ead7c528-ea3d-40e8-9688-9f1d8dc8d758} 2.0 Websitepanel-SchedulerService @@ -49,4 +49,4 @@ --> - \ No newline at end of file + diff --git a/WebsitePanel.Installer/Sources/Setup.WIX/Setup.WIX.wixproj b/WebsitePanel.Installer/Sources/Setup.WIX/Setup.WIX.wixproj index d3178260..fa43aa7a 100644 --- a/WebsitePanel.Installer/Sources/Setup.WIX/Setup.WIX.wixproj +++ b/WebsitePanel.Installer/Sources/Setup.WIX/Setup.WIX.wixproj @@ -3,7 +3,7 @@ Debug x86 - 3.7 + 3.9 f963a4af-cc72-4512-b636-829345c35318 2.0 WebsitePanelInstaller @@ -91,4 +91,4 @@ --> - \ No newline at end of file + diff --git a/WebsitePanel.Installer/Sources/Setup.WIXInstaller.CreateFileList.bat b/WebsitePanel.Installer/Sources/Setup.WIXInstaller.CreateFileList.bat index 1dfc0e52..441907d7 100644 --- a/WebsitePanel.Installer/Sources/Setup.WIXInstaller.CreateFileList.bat +++ b/WebsitePanel.Installer/Sources/Setup.WIXInstaller.CreateFileList.bat @@ -1,6 +1,8 @@ -"%WIX%\bin\heat.exe" dir ..\..\WebsitePanel\Build\Release\EnterpriseServer -o Setup.WIXInstaller\EnterpriseServerFiles.wxs -gg -sreg -srd -var wix.BUILDESPATH -cg EnterpriseServerFiles -dr INSTALLENTERPRISESERVERFOLDER +"%WIX%\bin\heat.exe" dir ..\..\WebsitePanel\Build\debug\EnterpriseServer -o Setup.WIXInstaller\EnterpriseServerFiles.wxs -gg -sreg -srd -var wix.BUILDESPATH -cg EnterpriseServerFiles -dr INSTALLENTERPRISESERVERFOLDER -"%WIX%\bin\heat.exe" dir ..\..\WebsitePanel\Build\Release\Server -o Setup.WIXInstaller\ServerFiles.wxs -gg -sreg -srd -var wix.BUILDSPATH -cg ServerFiles -dr INSTALLSERVERFOLDER +"%WIX%\bin\heat.exe" dir ..\..\WebsitePanel\Build\debug\Server -o Setup.WIXInstaller\ServerFiles.wxs -gg -sreg -srd -var wix.BUILDSPATH -cg ServerFiles -dr INSTALLSERVERFOLDER -"%WIX%\bin\heat.exe" dir ..\..\WebsitePanel\Build\Release\Portal -o Setup.WIXInstaller\PortalFiles.wxs -gg -sreg -srd -var wix.BUILDPPATH -cg PortalFiles -dr INSTALLPORTALFOLDER +"%WIX%\bin\heat.exe" dir ..\..\WebsitePanel\Build\debug\Portal -o Setup.WIXInstaller\PortalFiles.wxs -gg -sreg -srd -var wix.BUILDPPATH -cg PortalFiles -dr INSTALLPORTALFOLDER + +"%WIX%\bin\heat.exe" dir ..\..\WebsitePanel\Build\debug\WebDavPortal -o Setup.WIXInstaller\WebDavPortalFiles.wxs -gg -sreg -srd -var wix.BUILDWDPPATH -cg WebDavPortalFiles -dr INSTALLWEBDAVPORTALFOLDER diff --git a/WebsitePanel.Installer/Sources/Setup.WIXInstaller/Config.wxi b/WebsitePanel.Installer/Sources/Setup.WIXInstaller/Config.wxi index dad6088c..3e009012 100644 --- a/WebsitePanel.Installer/Sources/Setup.WIXInstaller/Config.wxi +++ b/WebsitePanel.Installer/Sources/Setup.WIXInstaller/Config.wxi @@ -1,5 +1,14 @@ - - + + + + + + + + + + + diff --git a/WebsitePanel.Installer/Sources/Setup.WIXInstaller/CustomVerifyReadyDlg.wxs b/WebsitePanel.Installer/Sources/Setup.WIXInstaller/CustomVerifyReadyDlg.wxs new file mode 100644 index 00000000..656e3316 --- /dev/null +++ b/WebsitePanel.Installer/Sources/Setup.WIXInstaller/CustomVerifyReadyDlg.wxs @@ -0,0 +1,148 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + + + WixUI_InstallMode = "Remove" + + + + + + + + diff --git a/WebsitePanel.Installer/Sources/Setup.WIXInstaller/Product.wxs b/WebsitePanel.Installer/Sources/Setup.WIXInstaller/Product.wxs index 0b827603..26442c52 100644 --- a/WebsitePanel.Installer/Sources/Setup.WIXInstaller/Product.wxs +++ b/WebsitePanel.Installer/Sources/Setup.WIXInstaller/Product.wxs @@ -1,421 +1,691 @@ - - - - - - - - - - - - - - - - - - - - - - - - bannrbmp - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1 - - - 1 - - - 1 - - - - - - - - - - - - - - - - - - - - 1 - - - 1 - - - 1 - - - - - - - - - - - AUTHENTICATIONTYPE = "Windows Authentication" - NOT(AUTHENTICATIONTYPE = "Windows Authentication") - - - - - - - - - - - 1 - - - &EnterpriseServerFeature=3 - &SchedulerServiceFeature=3 - &PortalFeature=3 - - - 1 - - - - - - - - - - - - - - 1 - - - 1 - - - 1 - - - - - - - - - - - - - - - 1 - - - 1 - - - 1 - - - - - - - - - - - AUTHENTICATIONTYPE = "Windows Authentication" - NOT(AUTHENTICATIONTYPE = "Windows Authentication") - - - - - - - - - - - 1 - - - &EnterpriseServerFeature=3 - &SchedulerServiceFeature=3 - &PortalFeature=3 - - - 1 - - - - - - - - - - - - - - - - 1 - - - &PortalFeature=3 - 1 - - - 1 - - - - - - - - - - - - - - - - - - AUTHENTICATIONTYPE = "Windows Authentication" - NOT(AUTHENTICATIONTYPE = "Windows Authentication") - - - - - - - - - 1 - - - Connection not valid. - - - - - - 1 - - - 1 - - - 1 - - - - - - - - - - - - - - - 1 - - - 1 - - - 1 - - - - - - - - - - - AUTHENTICATIONTYPE = "Windows Authentication" - NOT(AUTHENTICATIONTYPE = "Windows Authentication") - - - - - - - - - - - 1 - - - 1 - - - 1 - - - - - - - - - - - - - - 1 - - - - - - - - - - - LicenseAccepted = "1" - - - &ServerFeature=3 - &EnterpriseServerFeature=3 - &SchedulerServiceFeature=3 - &PortalFeature=3 - - 1 - - - - - - - (NOT UPGRADINGPRODUCTCODE) AND (REMOVE="ALL") - - NOT Installed or REINSTALL - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + NOT(PI_SERVER_CREATE_AD = "1") + PI_SERVER_CREATE_AD = "1" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + NOT(PI_ESERVER_CREATE_AD = "1") + PI_ESERVER_CREATE_AD = "1" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + DB_CONN_CORRECT="0" + DB_CONN_CORRECT="1" + + + + + + + + + + + + + + + + + + + + + + + DB_AUTH = "Windows Authentication" + NOT(DB_AUTH = "Windows Authentication") + + + + + + DB_CONN_CORRECT="0" + DB_CONN_CORRECT="1" + + + DB_CONN_CORRECT="0" + DB_CONN_CORRECT="1" + + + + + + + Connection not valid. [DB_CONN_MSG] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + NOT(PI_PORTAL_CREATE_AD = "1") + PI_PORTAL_CREATE_AD = "1" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + PI_PREREQ_OS="1" AND PI_PREREQ_IIS="1" AND PI_PREREQ_ASPNET="1" + + + + + + + + + + + + + + + + + + + [VALIDATE_MSG] + + + + + LicenseAccepted = "1" + + 1 + 1 + 1 + + 1 + &ServerFeature=3 + &EnterpriseServerFeature=3 + &PortalFeature=3 + &SchedulerServiceFeature=3 + &WDPortalFeature=3 + 1 + 1 + + 1 + 1 + 1 + + 1 + VALIDATE_OK="1" + VALIDATE_OK="0" + 1 + 1 + + 1 + 1 + 1 + 1 + 1 + ""]]> + "" AND DSOP_UPN = ""]]> + + 1 + &EnterpriseServerFeature=3 AND VALIDATE_OK = "1" + &PortalFeature=3 AND VALIDATE_OK = "1" + &SchedulerServiceFeature=3 AND VALIDATE_OK = "1" + &WDPortalFeature=3 AND VALIDATE_OK = "1" + + + + VALIDATE_OK = "0" + 1 + 1 + + + 1 + 1 + 1 + 1 + + 1 + VALIDATE_OK="1" + VALIDATE_OK="0" + 1 + 1 + + 1 + 1 + 1 + 1 + 1 + ""]]> + "" AND DSOP_UPN = ""]]> + + 1 + + VALIDATE_OK="0" + 1 + 1 + + + + + 1 + &PortalFeature=3 AND DB_CONN_CORRECT="1" AND VALIDATE_OK = "1" + DB_CONN_CORRECT = "1" AND VALIDATE_OK = "1" + VALIDATE_OK = "0" + 1 + 1 + DB_CONN_CORRECT = "0" + 1 + 1 + 1 + 1 + + 1 + + 1 + 1 + 1 + + + + 1 + 1 + 1 + + 1 + + + VALIDATE_OK="0" + 1 + 1 + + 1 + 1 + 1 + 1 + 1 + ""]]> + "" AND DSOP_UPN = ""]]> + + 1 + + 1 + 1 + + + + + 3]]> + 3 AND &PortalFeature<>3]]> + 1 + + 1 + + 1 + + + + + + + + + + + + + + + + + + + + + bannrbmp + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + WSP_ROOT + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + (NOT Installed OR NOT WIX_UPGRADE_DETECTED) AND NOT(DB_AUTH = "Windows Authentication") + + + + + + + NOT (Remove="ALL") AND NOT(DB_AUTH = "Windows Authentication") + + + + + + + (NOT Installed OR NOT WIX_UPGRADE_DETECTED) AND (DB_AUTH = "Windows Authentication") + + + + + + NOT (Remove="ALL") AND (DB_AUTH = "Windows Authentication") + + + + + - - \ No newline at end of file + + + + + + + + + + + diff --git a/WebsitePanel.Installer/Sources/Setup.WIXInstaller/Setup.WIXInstaller.wixproj b/WebsitePanel.Installer/Sources/Setup.WIXInstaller/Setup.WIXInstaller.wixproj index ab5acac6..7278ed94 100644 --- a/WebsitePanel.Installer/Sources/Setup.WIXInstaller/Setup.WIXInstaller.wixproj +++ b/WebsitePanel.Installer/Sources/Setup.WIXInstaller/Setup.WIXInstaller.wixproj @@ -3,7 +3,7 @@ Debug x86 - 3.7 + 3.9 {978f0a18-7c81-4561-8f6d-5a165484ad0a} 2.0 Websitepanel @@ -14,35 +14,50 @@ bin\ obj\$(Configuration)\ - Debug;BUILD=debug + Debug;BUILD=debug;Version=$(Version);BuildDate=$(ReleaseDate) False - + bin\$(Configuration)\ obj\$(Configuration)\ - BUILD=release + BUILD=release;Version=$(Version);BuildDate=$(ReleaseDate) - - + - + + + + + ..\..\..\tools\WIX\WixUIExtension.dll WixUIExtension + + ..\..\..\tools\WIX\WixIIsExtension.dll + WixIIsExtension + + + ..\..\..\tools\WIX\WixSqlExtension.dll + WixSqlExtension + + + ..\..\..\tools\WIX\WixUtilExtension.dll + WixUtilExtension + - \ No newline at end of file + diff --git a/WebsitePanel.Installer/Sources/Setup.WIXInstaller/WebsitePanel.config b/WebsitePanel.Installer/Sources/Setup.WIXInstaller/WebsitePanel.config new file mode 100644 index 00000000..60bc4b39 --- /dev/null +++ b/WebsitePanel.Installer/Sources/Setup.WIXInstaller/WebsitePanel.config @@ -0,0 +1,20 @@ + + + +
+ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/WebsitePanel.Installer/Sources/Setup.WIXInstaller/failmark.ico b/WebsitePanel.Installer/Sources/Setup.WIXInstaller/failmark.ico new file mode 100644 index 00000000..7d0aa3e2 Binary files /dev/null and b/WebsitePanel.Installer/Sources/Setup.WIXInstaller/failmark.ico differ diff --git a/WebsitePanel.Installer/Sources/Setup.WIXInstaller/passmark.ico b/WebsitePanel.Installer/Sources/Setup.WIXInstaller/passmark.ico new file mode 100644 index 00000000..62a48019 Binary files /dev/null and b/WebsitePanel.Installer/Sources/Setup.WIXInstaller/passmark.ico differ diff --git a/WebsitePanel.Installer/Sources/VersionInfo.cs b/WebsitePanel.Installer/Sources/VersionInfo.cs index 4f3d2fdf..9df3788e 100644 --- a/WebsitePanel.Installer/Sources/VersionInfo.cs +++ b/WebsitePanel.Installer/Sources/VersionInfo.cs @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.18051 +// Runtime Version:4.0.30319.34209 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/WebsitePanel.Installer/Sources/WebsitePanel.Installer.sln b/WebsitePanel.Installer/Sources/WebsitePanel.Installer.sln index 6185b28b..95ec3f32 100644 --- a/WebsitePanel.Installer/Sources/WebsitePanel.Installer.sln +++ b/WebsitePanel.Installer/Sources/WebsitePanel.Installer.sln @@ -1,6 +1,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 2013 -VisualStudioVersion = 12.0.30723.0 +VisualStudioVersion = 12.0.31101.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{129305D5-A9E6-4DCE-BFF6-41809E13EEEE}" ProjectSection(SolutionItems) = preProject @@ -33,6 +33,13 @@ Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "Setup.SchedulerService", "S EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebsitePanel.SchedulerServiceInstaller", "WebsitePanel.SchedulerServiceInstaller\WebsitePanel.SchedulerServiceInstaller.csproj", "{24A4C231-73A9-4F03-ABAD-9A8FE5324495}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebsitePanel.WIXInstaller", "WebsitePanel.WIXInstaller\WebsitePanel.WIXInstaller.csproj", "{3343FFD8-7CCE-451B-95AE-3D97244313A2}" +EndProject +Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "Setup.WIXInstaller", "Setup.WIXInstaller\Setup.WIXInstaller.wixproj", "{978F0A18-7C81-4561-8F6D-5A165484AD0A}" + ProjectSection(ProjectDependencies) = postProject + {3343FFD8-7CCE-451B-95AE-3D97244313A2} = {3343FFD8-7CCE-451B-95AE-3D97244313A2} + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -125,6 +132,26 @@ Global {24A4C231-73A9-4F03-ABAD-9A8FE5324495}.Release|Mixed Platforms.Build.0 = Release|x86 {24A4C231-73A9-4F03-ABAD-9A8FE5324495}.Release|x86.ActiveCfg = Release|x86 {24A4C231-73A9-4F03-ABAD-9A8FE5324495}.Release|x86.Build.0 = Release|x86 + {3343FFD8-7CCE-451B-95AE-3D97244313A2}.Debug|Any CPU.ActiveCfg = Debug|x86 + {3343FFD8-7CCE-451B-95AE-3D97244313A2}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 + {3343FFD8-7CCE-451B-95AE-3D97244313A2}.Debug|Mixed Platforms.Build.0 = Debug|x86 + {3343FFD8-7CCE-451B-95AE-3D97244313A2}.Debug|x86.ActiveCfg = Debug|x86 + {3343FFD8-7CCE-451B-95AE-3D97244313A2}.Debug|x86.Build.0 = Debug|x86 + {3343FFD8-7CCE-451B-95AE-3D97244313A2}.Release|Any CPU.ActiveCfg = Release|x86 + {3343FFD8-7CCE-451B-95AE-3D97244313A2}.Release|Mixed Platforms.ActiveCfg = Release|x86 + {3343FFD8-7CCE-451B-95AE-3D97244313A2}.Release|Mixed Platforms.Build.0 = Release|x86 + {3343FFD8-7CCE-451B-95AE-3D97244313A2}.Release|x86.ActiveCfg = Release|x86 + {3343FFD8-7CCE-451B-95AE-3D97244313A2}.Release|x86.Build.0 = Release|x86 + {978F0A18-7C81-4561-8F6D-5A165484AD0A}.Debug|Any CPU.ActiveCfg = Debug|x86 + {978F0A18-7C81-4561-8F6D-5A165484AD0A}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 + {978F0A18-7C81-4561-8F6D-5A165484AD0A}.Debug|Mixed Platforms.Build.0 = Debug|x86 + {978F0A18-7C81-4561-8F6D-5A165484AD0A}.Debug|x86.ActiveCfg = Debug|x86 + {978F0A18-7C81-4561-8F6D-5A165484AD0A}.Debug|x86.Build.0 = Debug|x86 + {978F0A18-7C81-4561-8F6D-5A165484AD0A}.Release|Any CPU.ActiveCfg = Release|x86 + {978F0A18-7C81-4561-8F6D-5A165484AD0A}.Release|Mixed Platforms.ActiveCfg = Release|x86 + {978F0A18-7C81-4561-8F6D-5A165484AD0A}.Release|Mixed Platforms.Build.0 = Release|x86 + {978F0A18-7C81-4561-8F6D-5A165484AD0A}.Release|x86.ActiveCfg = Release|x86 + {978F0A18-7C81-4561-8F6D-5A165484AD0A}.Release|x86.Build.0 = Release|x86 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/WebsitePanel.Installer/Sources/WebsitePanel.Installer/Updater.exe b/WebsitePanel.Installer/Sources/WebsitePanel.Installer/Updater.exe index 113e18c1..b2a7fa47 100644 Binary files a/WebsitePanel.Installer/Sources/WebsitePanel.Installer/Updater.exe and b/WebsitePanel.Installer/Sources/WebsitePanel.Installer/Updater.exe differ diff --git a/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Actions/EntServerActionManager.cs b/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Actions/EntServerActionManager.cs index c6279ca0..3680e837 100644 --- a/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Actions/EntServerActionManager.cs +++ b/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Actions/EntServerActionManager.cs @@ -67,37 +67,21 @@ namespace WebsitePanel.Setup.Actions { OnInstallProgressChanged(LogStartInstallMessage, 0); Log.WriteStart(LogStartInstallMessage); - - var file = Path.Combine(vars.InstallationFolder, vars.ConfigurationFile); - vars.CryptoKey = Utils.GetRandomString(20); - - // load file - string content = string.Empty; - using (StreamReader reader = new StreamReader(file)) - { - content = reader.ReadToEnd(); - } - - // expand variables - content = Utils.ReplaceScriptVariable(content, "installer.cryptokey", vars.CryptoKey); - // - Log.WriteInfo(String.Format("The following cryptographic key has been generated: '{0}'", vars.CryptoKey)); - - // save file - using (StreamWriter writer = new StreamWriter(file)) - { - writer.Write(content); - } - //update log + var file = Path.Combine(vars.InstallationFolder, vars.ConfigurationFile); + vars.CryptoKey = Utils.GetRandomString(20); + var Xml = new XmlDocument(); + Xml.Load(file); + var CryptoNode = Xml.SelectSingleNode("configuration/appSettings/add[@key='WebsitePanel.CryptoKey']") as XmlElement; + if (CryptoNode != null) + CryptoNode.SetAttribute("value", vars.CryptoKey); + Xml.Save(file); Log.WriteEnd(LogEndInstallMessage); } catch (Exception ex) { if (Utils.IsThreadAbortException(ex)) return; - // Log.WriteError("Update web.config error", ex); - // throw; } } @@ -116,6 +100,10 @@ namespace WebsitePanel.Setup.Actions Begin(LogStartInstallMessage); Log.WriteStart(LogStartInstallMessage); + + var ServiceName = Global.Parameters.SchedulerServiceName; + var ServiceFile = Path.Combine(vars.InstallationFolder, "bin", Global.Parameters.SchedulerServiceFileName); + Log.WriteInfo(String.Format("Scheduler Service Name: \"{0}\"", Global.Parameters.SchedulerServiceName)); if (ServiceController.GetServices().Any(s => s.DisplayName.Equals(Global.Parameters.SchedulerServiceName, StringComparison.CurrentCultureIgnoreCase))) @@ -125,8 +113,13 @@ namespace WebsitePanel.Setup.Actions return; } - ManagedInstallerClass.InstallHelper(new[] { "/i", Path.Combine(vars.InstallationFolder, "bin", Global.Parameters.SchedulerServiceFileName) }); + ManagedInstallerClass.InstallHelper(new[] { "/i /LogFile=\"\" ", ServiceFile }); Utils.StartService(Global.Parameters.SchedulerServiceName); + + AppConfig.EnsureComponentConfig(vars.ComponentId); + AppConfig.SetComponentSettingStringValue(vars.ComponentId, "ServiceName", ServiceName); + AppConfig.SetComponentSettingStringValue(vars.ComponentId, "ServiceFile", ServiceFile); + AppConfig.SaveConfiguration(); } catch (Exception ex) { @@ -166,7 +159,7 @@ namespace WebsitePanel.Setup.Actions { if (ServiceController.GetServices().Any(s => s.ServiceName.Equals(Global.Parameters.SchedulerServiceName, StringComparison.CurrentCultureIgnoreCase))) { - ManagedInstallerClass.InstallHelper(new[] { "/u", Path.Combine(vars.InstallationFolder, "bin", Global.Parameters.SchedulerServiceFileName) }); + ManagedInstallerClass.InstallHelper(new[] { "/u /LogFile=\"\" ", Path.Combine(vars.InstallationFolder, "bin", Global.Parameters.SchedulerServiceFileName) }); } } } @@ -397,25 +390,14 @@ namespace WebsitePanel.Setup.Actions void IInstallAction.Run(SetupVariables vars) { Log.WriteStart("Updating web.config file (connection string)"); - // var file = Path.Combine(vars.InstallationFolder, vars.ConfigurationFile); - // - var content = String.Empty; - // load file - using (StreamReader reader = new StreamReader(file)) - { - content = reader.ReadToEnd(); - } - // Build connection string vars.ConnectionString = String.Format(vars.ConnectionString, vars.DatabaseServer, vars.Database, vars.Database, vars.DatabaseUserPassword); - // Expand variables - content = Utils.ReplaceScriptVariable(content, "installer.connectionstring", vars.ConnectionString); - // Save file - using (StreamWriter writer = new StreamWriter(file)) - { - writer.Write(content); - } - // + var Xml = new XmlDocument(); + Xml.Load(file); + var ConnNode = Xml.SelectSingleNode("configuration/connectionStrings/add[@name='EnterpriseServer']") as XmlElement; + if(ConnNode != null) + ConnNode.SetAttribute("connectionString", vars.ConnectionString); + Xml.Save(file); Log.WriteEnd(String.Format("Updated {0} file", vars.ConfigurationFile)); } } @@ -509,10 +491,11 @@ namespace WebsitePanel.Setup.Actions { void IInstallAction.Run(SetupVariables vars) { + Log.WriteStart("SaveEntServerConfigSettingsAction"); AppConfig.EnsureComponentConfig(vars.ComponentId); // AppConfig.SetComponentSettingStringValue(vars.ComponentId, "Database", vars.Database); - AppConfig.SetComponentSettingBooleanValue(vars.ComponentId, "NewDatabase", true); + AppConfig.SetComponentSettingBooleanValue(vars.ComponentId, "NewDatabase", vars.CreateDatabase); // AppConfig.SetComponentSettingStringValue(vars.ComponentId, "DatabaseUser", vars.Database); AppConfig.SetComponentSettingBooleanValue(vars.ComponentId, "NewDatabaseUser", vars.NewDatabaseUser); @@ -523,6 +506,7 @@ namespace WebsitePanel.Setup.Actions AppConfig.SetComponentSettingStringValue(vars.ComponentId, Global.Parameters.CryptoKey, vars.CryptoKey); // AppConfig.SaveConfiguration(); + Log.WriteEnd("SaveEntServerConfigSettingsAction"); } } diff --git a/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/AppConfig.cs b/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/AppConfig.cs index 00fb1421..a964a0c2 100644 --- a/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/AppConfig.cs +++ b/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/AppConfig.cs @@ -38,25 +38,27 @@ namespace WebsitePanel.Setup public sealed class AppConfig { public const string AppConfigFileNameWithoutExtension = "WebsitePanel.Installer.exe"; - + static AppConfig() + { + ConfigurationPath = DefaultConfigurationPath; + } private AppConfig() { + } - private static Configuration appConfig = null; private static XmlDocument xmlConfig = null; - - public static void LoadConfiguration() + public static string ConfigurationPath { get; set; } + public static string DefaultConfigurationPath { get { return Path.Combine(AppDomain.CurrentDomain.BaseDirectory, AppConfigFileNameWithoutExtension); } } + public static void LoadConfiguration(ExeConfigurationFileMap FnMap = null, ConfigurationUserLevel CuLevel = ConfigurationUserLevel.None) { - // - var exePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, AppConfigFileNameWithoutExtension); - // - appConfig = ConfigurationManager.OpenExeConfiguration(exePath); - // + if (FnMap == null) + appConfig = ConfigurationManager.OpenExeConfiguration(ConfigurationPath); + else + appConfig = ConfigurationManager.OpenMappedExeConfiguration(FnMap, CuLevel); ConfigurationSection section = appConfig.Sections["installer"]; if (section == null) - throw new ConfigurationErrorsException("instalelr section not found"); - + throw new ConfigurationErrorsException("installer section not found in " + appConfig.FilePath); string strXml = section.SectionInformation.GetRawXml(); xmlConfig = new XmlDocument(); xmlConfig.LoadXml(strXml); diff --git a/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/CopyProcess.cs b/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/CopyProcess.cs index 4d7c8ba6..6c58ff69 100644 --- a/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/CopyProcess.cs +++ b/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/CopyProcess.cs @@ -48,9 +48,9 @@ namespace WebsitePanel.Setup /// Progress bar. /// Source folder. /// Destination folder. - public CopyProcess(ProgressBar bar, string source, string destination) + public CopyProcess(object bar, string source, string destination) { - this.progressBar = bar; + this.progressBar = bar as ProgressBar; this.sourceFolder = new DirectoryInfo(source); this.destFolder = new DirectoryInfo(destination); } @@ -63,9 +63,13 @@ namespace WebsitePanel.Setup // unzip long totalSize = FileUtils.CalculateFolderSize(sourceFolder.FullName); long copied = 0; - progressBar.Minimum = 0; - progressBar.Maximum = 100; - progressBar.Value = 0; + + if (progressBar != null) + { + progressBar.Minimum = 0; + progressBar.Maximum = 100; + progressBar.Value = 0; + } int i = 0; List folders = new List(); @@ -122,7 +126,10 @@ namespace WebsitePanel.Setup copied += files[i].Length; if (totalSize != 0) { - progressBar.Value = Convert.ToInt32(copied * 100 / totalSize); + if (progressBar != null) + { + progressBar.Value = Convert.ToInt32(copied * 100 / totalSize); + } } } } diff --git a/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/Log.cs b/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/Log.cs index d2cd6d04..3c74bfda 100644 --- a/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/Log.cs +++ b/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/Log.cs @@ -170,5 +170,7 @@ namespace WebsitePanel.Setup } catch { } } + + public static TraceListenerCollection Listeners { get { return Trace.Listeners; } } } } diff --git a/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/OS.cs b/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/OS.cs index 23ef37c1..c41de825 100644 --- a/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/OS.cs +++ b/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/OS.cs @@ -286,7 +286,8 @@ namespace WebsitePanel.Setup Windows7, WindowsServer2008R2, Windows8, - WindowsServer2012 + WindowsServer2012, + WindowsServer2012R2 } public static string GetName(WindowsVersion version) @@ -428,6 +429,9 @@ namespace WebsitePanel.Setup else ret = WindowsVersion.WindowsServer2012; break; + case 3: + ret = WindowsVersion.WindowsServer2012R2; + break; } break; } diff --git a/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/SecurityUtils.cs b/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/SecurityUtils.cs index 70767919..072723fb 100644 --- a/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/SecurityUtils.cs +++ b/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/SecurityUtils.cs @@ -338,8 +338,8 @@ namespace WebsitePanel.Setup /// /// internal static string GetSid(string userAccount, string domain) - { - if(domain == null) + { + if(string.IsNullOrWhiteSpace(domain)) domain = Environment.MachineName; // try to get user account diff --git a/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/Utils.cs b/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/Utils.cs index b7509c87..ecf6ed15 100644 --- a/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/Utils.cs +++ b/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/Utils.cs @@ -481,11 +481,11 @@ namespace WebsitePanel.Setup public static void StopService(string serviceName) { ServiceController sc = new ServiceController(serviceName); - // Start the service if the current status is stopped. + // Stop the service if the current status is not stopped. if (sc.Status != ServiceControllerStatus.Stopped && sc.Status != ServiceControllerStatus.StopPending) { - // Start the service, and wait until its status is "Running". + // Stop the service, and wait until its status is "Running". sc.Stop(); sc.WaitForStatus(ServiceControllerStatus.Stopped); } diff --git a/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/WebUtils.cs b/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/WebUtils.cs index 4f57fd97..6b3781b8 100644 --- a/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/WebUtils.cs +++ b/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/WebUtils.cs @@ -150,7 +150,7 @@ namespace WebsitePanel.Setup FileUtils.CreateDirectory(path); SecurityUtils.GrantNtfsPermissions(path, userDomain, userAccount, NtfsPermission.Modify, true, true); - SecurityUtils.GrantNtfsPermissionsBySid(path, SystemSID.NETWORK_SERVICE, NtfsPermission.Modify, true, true); + SecurityUtils.GrantNtfsPermissionsBySid(path, SystemSID.NETWORK_SERVICE, NtfsPermission.Modify, true, true); } /// diff --git a/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/ZipIndicator.cs b/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/ZipIndicator.cs index 68be9581..017cc820 100644 --- a/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/ZipIndicator.cs +++ b/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Common/ZipIndicator.cs @@ -46,9 +46,9 @@ namespace WebsitePanel.Setup.Common int totalFiles = 0; int files = 0; - public ZipIndicator(ProgressBar progressBar, string sourcePath, string zipFile) + public ZipIndicator(object progressBar, string sourcePath, string zipFile) { - this.progressBar = progressBar; + this.progressBar = progressBar as ProgressBar; this.sourcePath = sourcePath; this.zipFile = zipFile; } @@ -71,8 +71,11 @@ namespace WebsitePanel.Setup.Common { string fileName = e.CurrentEntry.FileName; files++; - this.progressBar.Value = Convert.ToInt32(files * 100 / totalFiles); - this.progressBar.Update(); + if (this.progressBar != null) + { + this.progressBar.Value = Convert.ToInt32(files * 100 / totalFiles); + this.progressBar.Update(); + } } } } diff --git a/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Internal/Adapter.cs b/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Internal/Adapter.cs new file mode 100644 index 00000000..60ab6e24 --- /dev/null +++ b/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Internal/Adapter.cs @@ -0,0 +1,4485 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.Specialized; +using System.Configuration; +using System.Configuration.Install; +using System.Data; +using System.Diagnostics; +using System.IO; +using System.Reflection; +using System.Runtime.Serialization; +using System.Text; +using System.Text.RegularExpressions; +using System.Xml; +using WebsitePanel.EnterpriseServer; +using WebsitePanel.Providers.Common; +using WebsitePanel.Providers.ResultObjects; +using WebsitePanel.Setup.Actions; +using WebsitePanel.Setup.Common; +using WebsitePanel.Setup.Web; +using WebsitePanel.Setup.Windows; + +namespace WebsitePanel.Setup.Internal +{ + public enum ModeExtension: byte { Normal, Backup, Restore } + public class WiXSetupException : ApplicationException + { + public WiXSetupException():base() + { + + } + public WiXSetupException(string Msg):base(Msg) + { + + } + public WiXSetupException(string Msg, Exception Inner):base(Msg, Inner) + { + + } + public WiXSetupException(SerializationInfo Info, StreamingContext Context):base(Info, Context) + { + + } + } + public static class DictionaryExtension + { + public static IDictionary ToNonGenericDictionary(this IDictionary Src) + { + var Result = new Hashtable(); + foreach (var Pair in Src) + Result.Add(Pair.Key, Pair.Value); + return Result; + } + } + public sealed class Adapter + { + public static string DefaultConfigFile { get { return "WebsitePanel.config"; } } + private Adapter() { } + public static CheckStatuses CheckASPNET(SetupVariables setupVariables, out string Msg) + { + return ConfigurationCheckPage.CheckASPNET(setupVariables, out Msg); + } + public static CheckStatuses CheckIIS(SetupVariables setupVariables, out string Msg) + { + return ConfigurationCheckPage.CheckIISVersion(setupVariables, out Msg); + } + public static CheckStatuses CheckOS(SetupVariables setupVariables, out string Msg) + { + return ConfigurationCheckPage.CheckOS(setupVariables, out Msg); + } + } + + public interface IWiXSetup + { + void Run(); + } + public abstract class WiXSetup : IWiXSetup + { + private SetupVariables m_Ctx; + public WiXSetup(SetupVariables SessionVariables, ModeExtension Ext = ModeExtension.Normal) + { + m_Ctx = SessionVariables; + ModeExtension = Ext; + } + public SetupVariables Context { get { return m_Ctx; } } + public ModeExtension ModeExtension { get; private set; } + public virtual void Run() + { + switch (Context.SetupAction) + { + case SetupActions.Install: + Install(); + break; + case SetupActions.Uninstall: + Uninstall(); + break; + default: + throw new NotImplementedException(); + } + } + + protected abstract void Install(); + protected abstract void Uninstall(); + + /// + /// LoadSetupVariablesFromParameters. + /// + /// + /// + public static void FillFromSession(IDictionary Src, SetupVariables Dst) + { + if (Src == null) + throw new NullReferenceException("Src"); + var Hash = Src.ToNonGenericDictionary() as Hashtable; + if (Hash == null) + throw new NullReferenceException("Hash"); + Dst.ApplicationName = Utils.GetStringSetupParameter(Hash, "ApplicationName"); + Dst.ComponentName = Utils.GetStringSetupParameter(Hash, "ComponentName"); + Dst.ComponentCode = Utils.GetStringSetupParameter(Hash, "ComponentCode"); + Dst.ComponentDescription = Utils.GetStringSetupParameter(Hash, "ComponentDescription"); + Dst.Version = Utils.GetStringSetupParameter(Hash, "Version"); + + Dst.InstallationFolder = Utils.GetStringSetupParameter(Hash, "InstallationFolder"); + + Dst.InstallerFolder = Utils.GetStringSetupParameter(Hash, "InstallerFolder"); + Dst.Installer = Utils.GetStringSetupParameter(Hash, "Installer"); + Dst.InstallerType = Utils.GetStringSetupParameter(Hash, "InstallerType"); + Dst.InstallerPath = Utils.GetStringSetupParameter(Hash, "InstallerPath"); + //Dst.IISVersion = Utils.GetVersionSetupParameter(Hash, "IISVersion"); + Dst.SetupXml = Utils.GetStringSetupParameter(Hash, "SetupXml"); + Dst.ServerPassword = Utils.GetStringSetupParameter(Hash, Global.Parameters.ServerPassword); + + Dst.WebSiteIP = Utils.GetStringSetupParameter(Hash, Global.Parameters.WebSiteIP); + Dst.WebSitePort = Utils.GetStringSetupParameter(Hash, Global.Parameters.WebSitePort); + Dst.WebSiteDomain = Utils.GetStringSetupParameter(Hash, Global.Parameters.WebSiteDomain); + Dst.UserDomain = Utils.GetStringSetupParameter(Hash, Global.Parameters.UserDomain); + Dst.UserAccount = Utils.GetStringSetupParameter(Hash, Global.Parameters.UserAccount); + Dst.UserPassword = Utils.GetStringSetupParameter(Hash, Global.Parameters.UserPassword); + + // From portal base install. + Dst.ConfigurationFile = "Web.config"; + Dst.NewWebSite = true; + Dst.NewVirtualDirectory = false; + Dst.EnterpriseServerURL = Utils.GetStringSetupParameter(Hash, Global.Parameters.EnterpriseServerUrl); + + // From ent server base install. + Dst.ConnectionString = Global.EntServer.AspNetConnectionStringFormat; + Dst.DatabaseServer = Utils.GetStringSetupParameter(Hash, Global.Parameters.DatabaseServer); + Dst.Database = Utils.GetStringSetupParameter(Hash, Global.Parameters.DatabaseName); + Dst.CreateDatabase = false; // Done by WiX itself. + Dst.NewDatabaseUser = true; + Dst.ServerAdminPassword = Utils.GetStringSetupParameter(Hash, Global.Parameters.ServerAdminPassword); + Dst.UpdateServerAdminPassword = true; + + // DB_LOGIN, DB_PASSWORD. + Dst.DbInstallConnectionString = SqlUtils.BuildDbServerMasterConnectionString( + Dst.DatabaseServer, + Utils.GetStringSetupParameter(Hash, Global.Parameters.DbServerAdmin), + Utils.GetStringSetupParameter(Hash, Global.Parameters.DbServerAdminPassword)); + + Dst.BaseDirectory = Utils.GetStringSetupParameter(Hash, Global.Parameters.BaseDirectory); + } + public static string GetFullConfigPath(SetupVariables Ctx) + { + return Path.Combine(Ctx.InstallerFolder, Adapter.DefaultConfigFile); + } + public static string GetComponentID(SetupVariables Ctx) + { + var XmlPath = string.Format("//component[.//add/@key='ComponentCode' and .//add/@value='{0}']", Ctx.ComponentCode); + var Xml = new XmlDocument(); + Xml.Load(GetFullConfigPath(Ctx)); + var Node = Xml.SelectSingleNode(XmlPath) as XmlElement; + return Node == null ? null : Node.GetAttribute("id"); + } + public static void InstallLogListener(object o) + { + if (o == null) + throw new NullReferenceException("log listener"); + if (o is TraceListener) + Log.Listeners.Add(o as TraceListener); + } + public static void InstallFailed() + { + throw new WiXSetupException("Installation failed."); + } + public static ModeExtension GetModeExtension(IDictionary Src) + { + var mup = "MODE_UP"; + var mrup = "MODE_RUP"; + var Result = ModeExtension.Normal; + if (Src.Keys.Contains(mup) && !string.IsNullOrWhiteSpace(Src[mup])) + Result = ModeExtension.Restore; + else if (Src.Keys.Contains(mrup) && !string.IsNullOrWhiteSpace(Src[mrup])) + Result = ModeExtension.Backup; + return Result; + } + } + public abstract class SetupScript // ExpressInstallPage, UninstallPage etc + { + private int m_Progress; + private List m_Actions; + private SetupVariables m_Ctx; + public SetupScript(SetupVariables SessionVariables) + { + m_Progress = 0; + m_Actions = new List(); + m_Ctx = SessionVariables; + } + public SetupVariables Context { get { return m_Ctx; } } + public List Actions { get { return m_Actions; } } + public void Run() + { + string ComponentName = m_Ctx.ComponentFullName; + string ComponentID = m_Ctx.ComponentId; + Version IisVersion = m_Ctx.IISVersion; + bool iis7 = (IisVersion.Major >= 7); + var ExecuteActions = GetActions(ComponentID); + ExecuteActions.AddRange(Actions); + foreach (var Execute in ExecuteActions) + { + try + { + switch (Execute.ActionType) + { + case ActionTypes.DeleteRegistryKey: + DeleteRegistryKey(Execute.Key, Execute.Empty); + break; + case ActionTypes.DeleteDirectory: + DeleteDirectory(Execute.Path); + break; + case ActionTypes.DeleteDatabase: + DeleteDatabase( + Execute.ConnectionString, + Execute.Name); + break; + case ActionTypes.DeleteDatabaseUser: + DeleteDatabaseUser( + Execute.ConnectionString, + Execute.UserName); + break; + case ActionTypes.DeleteDatabaseLogin: + DeleteDatabaseLogin( + Execute.ConnectionString, + Execute.UserName); + break; + case ActionTypes.DeleteWebSite: + if (iis7) + DeleteIIS7WebSite(Execute.SiteId); + else + DeleteWebSite(Execute.SiteId); + break; + case ActionTypes.DeleteVirtualDirectory: + DeleteVirtualDirectory( + Execute.SiteId, + Execute.Name); + break; + case ActionTypes.DeleteUserMembership: + DeleteUserMembership(Execute.Domain, Execute.Name, Execute.Membership); + break; + case ActionTypes.DeleteUserAccount: + DeleteUserAccount(Execute.Domain, Execute.Name); + break; + case ActionTypes.DeleteApplicationPool: + if (iis7) + DeleteIIS7ApplicationPool(Execute.Name); + else + DeleteApplicationPool(Execute.Name); + break; + case ActionTypes.UpdateConfig: + if (string.IsNullOrWhiteSpace(Execute.Key)) + UpdateSystemConfiguration(); + else + UpdateSystemConfiguration(Execute.Key); + break; + case ActionTypes.DeleteShortcuts: + DeleteShortcuts(Execute.Name); + break; + case ActionTypes.UnregisterWindowsService: + UnregisterWindowsService(Execute.Path, Execute.Name); + break; + // + case ActionTypes.SwitchWebPortal2AspNet40: + SwitchWebPortal2AspNet40(Execute, Context); + break; + case ActionTypes.SwitchEntServer2AspNet40: + SwitchEntServer2AspNet40(Execute, Context); + break; + case ActionTypes.SwitchServer2AspNet40: + SwitchServer2AspNet40(Execute, Context); + break; + case ActionTypes.CopyFiles: + CopyFiles( + Context.InstallerFolder, + Context.InstallationFolder); + break; + case ActionTypes.CreateWebSite: + CreateWebSite(); + break; + case ActionTypes.CryptoKey: + SetCryptoKey(); + break; + case ActionTypes.ServerPassword: + SetServerPassword(); + break; + case ActionTypes.UpdateServerPassword: + UpdateServerPassword(); + break; + //case ActionTypes.UpdateConfig: + // UpdateSystemConfiguration(); + // break; + case ActionTypes.CreateDatabase: + CreateDatabase(); + break; + case ActionTypes.CreateDatabaseUser: + CreateDatabaseUser(); + break; + case ActionTypes.ExecuteSql: + ExecuteSqlScript(Execute.Path); + break; + case ActionTypes.UpdateWebSite: + UpdateWebSiteBindings(); + break; + case ActionTypes.Backup: + Backup(); + break; + case ActionTypes.DeleteFiles: + DeleteFiles(Execute.Path); + break; + case ActionTypes.UpdateEnterpriseServerUrl: + UpdateEnterpriseServerUrl(); + break; + case ActionTypes.CreateShortcuts: + CreateShortcuts(); + break; + case ActionTypes.UpdateServers: + UpdateServers(); + break; + case ActionTypes.CopyWebConfig: + CopyWebConfig(); + break; + case ActionTypes.UpdateWebConfigNamespaces: + UpdateWebConfigNamespaces(); + break; + case ActionTypes.StopApplicationPool: + StopApplicationPool(); + break; + case ActionTypes.StartApplicationPool: + StartApplicationPool(); + break; + case ActionTypes.UpdatePortal2811: + UpdatePortal2811(); + break; + case ActionTypes.UpdateEnterpriseServer2810: + case ActionTypes.UpdateServer2810: + UpdateWseSecuritySettings(); + break; + case ActionTypes.CreateUserAccount: + CreateAccount(Execute.Name); + break; + case ActionTypes.ServiceSettings: + SetServiceSettings(); + break; + case ActionTypes.RegisterWindowsService: + RegisterWindowsService(); + break; + case ActionTypes.StartWindowsService: + StartWindowsService(); + break; + case ActionTypes.StopWindowsService: + StopWindowsService(); + break; + //case ActionTypes.InitSetupVariables: + // InitSetupVaribles(Execute.SetupVariables); + // break; + case ActionTypes.UpdateServerAdminPassword: + UpdateServerAdminPassword(); + break; + case ActionTypes.UpdateLicenseInformation: + UpdateLicenseInformation(); + break; + case ActionTypes.ConfigureStandaloneServerData: + ConfigureStandaloneServer(Execute.Url); + break; + case ActionTypes.CreateWPServerLogin: + CreateWPServerLogin(); + break; + case ActionTypes.FolderPermissions: + ConfigureFolderPermissions(); + break; + case ActionTypes.AddCustomErrorsPage: + AddCustomErrorsPage(); + break; + case ActionTypes.ConfigureSecureSessionModuleInWebConfig: + ConfigureSecureSessionModuleInWebConfig(); + break; + } + } + catch (Exception ex) + { + ProcessError(ex); + // TODO: Add Rollback + } + } + } + + protected virtual List GetActions(string ComponentID) + { + return new List(); + } + protected virtual void ProcessError(Exception ex) + { + + } + protected virtual object GetProgressObject() + { + return null; + } + #region Action Implementations + #region Uninstall + private void UnregisterWindowsService(string path, string serviceName) + { + try + { + Log.WriteStart(string.Format("Removing \"{0}\" Windows service", serviceName)); + Log.WriteStart(string.Format("Stopping \"{0}\" Windows service", serviceName)); + try + { + Utils.StopService(serviceName); + Log.WriteEnd("Stopped Windows service"); + } + catch (Exception ex) + { + if (!Utils.IsThreadAbortException(ex)) + Log.WriteError("Windows service stop error", ex); + } + + try + { + ManagedInstallerClass.InstallHelper(new[] { "/u /LogFile=\"\" ", path }); + } + catch (Exception ex) + { + Log.WriteError(string.Format("Unable to remove \"{0}\" Windows service.", serviceName), null); + InstallLog.AppendLine(string.Format("- Failed to remove \"{0}\" Windows service", serviceName)); + throw; + } + + Log.WriteEnd("Removed Windows service"); + InstallLog.AppendLine(string.Format("- Removed \"{0}\" Windows service", serviceName)); + } + catch (Exception ex) + { + if (Utils.IsThreadAbortException(ex)) + return; + + Log.WriteError("Windows service error", ex); + InstallLog.AppendLine(string.Format("- Failed to remove \"{0}\" Windows service", serviceName)); + throw; + } + } + + private void DeleteShortcuts(string fileName) + { + try + { + Log.WriteStart("Deleting menu shortcut"); + string programs = Environment.GetFolderPath(Environment.SpecialFolder.Programs); + string path = Path.Combine(programs, "WebsitePanel Software"); + path = Path.Combine(path, fileName); + if (File.Exists(path)) + { + File.Delete(path); + } + Log.WriteEnd("Deleted menu shortcut"); + + Log.WriteStart("Deleting desktop shortcut"); + string desktop = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory); + path = Path.Combine(desktop, fileName); + if (File.Exists(path)) + { + File.Delete(path); + } + Log.WriteEnd("Deleted desktop shortcut"); + InstallLog.AppendLine("- Deleted application shortcuts"); + } + catch (Exception ex) + { + if (Utils.IsThreadAbortException(ex)) + return; + + Log.WriteError("Delete shortcut error", ex); + InstallLog.AppendLine("- Failed to delete application shortcuts"); + throw; + } + } + + private void DeleteDirectory(string path) + { + try + { + Log.WriteStart("Deleting folder"); + Log.WriteInfo(string.Format("Deleting \"{0}\" folder", path)); + if (FileUtils.DirectoryExists(path)) + { + FileUtils.DeleteDirectory(path); + Log.WriteEnd("Deleted folder"); + } + InstallLog.AppendLine(string.Format("- Deleted \"{0}\" folder", path)); + } + catch (Exception ex) + { + if (Utils.IsThreadAbortException(ex)) + return; + + Log.WriteError("I/O error", ex); + InstallLog.AppendLine(string.Format("- Failed to delete \"{0}\" folder", path)); + } + } + + private void DeleteRegistryKey(string subkey, bool deleteEmptyOnly) + { + try + { + Log.WriteStart("Deleting registry key"); + if (RegistryUtils.RegistryKeyExist(subkey)) + { + if (deleteEmptyOnly && RegistryUtils.GetSubKeyCount(subkey) != 0) + { + Log.WriteEnd(string.Format("Registry key \"{0}\" is not empty", subkey)); + return; + } + Log.WriteInfo(string.Format("Deleting registry key \"{0}\"", subkey)); + RegistryUtils.DeleteRegistryKey(subkey); + Log.WriteEnd("Deleted registry key"); + InstallLog.AppendLine(string.Format("- Deleted registry key \"{0}\"", subkey)); + } + else + { + Log.WriteEnd(string.Format("Registry key \"{0}\" not found", subkey)); + } + } + catch (Exception ex) + { + if (Utils.IsThreadAbortException(ex)) + return; + + Log.WriteError("Registry key delete error", ex); + InstallLog.AppendLine(string.Format("- Failed to delete registry key \"{0}\"", subkey)); + throw; + } + } + + private void UpdateSystemConfiguration(string componentId) + { + try + { + Log.WriteStart("Updating system configuration"); + string componentName = AppConfig.GetComponentSettingStringValue(componentId, "ComponentName"); + Log.WriteInfo(string.Format("Deleting \"{0}\" component settings ", componentName)); + XmlUtils.RemoveXmlNode(AppConfig.GetComponentConfig(componentId)); + Log.WriteInfo("Saving system configuration"); + AppConfig.SaveConfiguration(); + Log.WriteEnd("Updated system configuration"); + InstallLog.AppendLine("- Updated system configuration"); + } + catch (Exception ex) + { + if (Utils.IsThreadAbortException(ex)) + return; + + Log.WriteError("Config error", ex); + InstallLog.AppendLine("- Failed to update system configuration"); + throw; + } + } + + private void DeleteDatabase(string connectionString, string database) + { + try + { + Log.WriteStart("Deleting SQL server database"); + Log.WriteInfo(string.Format("Deleting \"{0}\" SQL server database", database)); + if (SqlUtils.DatabaseExists(connectionString, database)) + { + SqlUtils.DeleteDatabase(connectionString, database); + Log.WriteEnd("Deleted database"); + InstallLog.AppendLine(string.Format("- Deleted \"{0}\" SQL server database ", database)); + } + } + catch (Exception ex) + { + if (Utils.IsThreadAbortException(ex)) + return; + + Log.WriteError("Database delete error", ex); + InstallLog.AppendLine(string.Format("- Failed to delete \"{0}\" SQL server database ", database)); + throw; + } + } + + private void DeleteDatabaseUser(string connectionString, string username) + { + try + { + Log.WriteStart("Deleting SQL server user"); + Log.WriteInfo(string.Format("Deleting \"{0}\" SQL server user", username)); + if (SqlUtils.UserExists(connectionString, username)) + { + SqlUtils.DeleteUser(connectionString, username); + Log.WriteEnd("Deleted SQL server user"); + InstallLog.AppendLine(string.Format("- Deleted \"{0}\" SQL server user ", username)); + } + } + catch (Exception ex) + { + if (Utils.IsThreadAbortException(ex)) + return; + + Log.WriteError("Database user delete error", ex); + InstallLog.AppendLine(string.Format("- Failed to delete \"{0}\" SQL server user ", username)); + throw; + } + } + + private void DeleteDatabaseLogin(string connectionString, string loginName) + { + try + { + Log.WriteStart("Deleting SQL server login"); + Log.WriteInfo(string.Format("Deleting \"{0}\" SQL server login", loginName)); + if (SqlUtils.LoginExists(connectionString, loginName)) + { + SqlUtils.DeleteLogin(connectionString, loginName); + Log.WriteEnd("Deleted SQL server login"); + InstallLog.AppendLine(string.Format("- Deleted \"{0}\" SQL server login ", loginName)); + } + } + catch (Exception ex) + { + if (Utils.IsThreadAbortException(ex)) + return; + + Log.WriteError("Database login delete error", ex); + InstallLog.AppendLine(string.Format("- Failed to delete \"{0}\" SQL server login ", loginName)); + throw; + } + } + private void DeleteUserMembership(string domain, string username, string[] membership) + { + try + { + Log.WriteStart("Removing user membership"); + if (SecurityUtils.UserExists(domain, username)) + { + Log.WriteInfo(string.Format("Removing user \"{0}\" membership", username)); + SecurityUtils.RemoveUserFromGroups(domain, username, membership); + Log.WriteEnd("Removed user membership"); + } + } + catch (Exception ex) + { + if (Utils.IsThreadAbortException(ex)) + return; + + Log.WriteError("User membership delete error", ex); + throw; + } + } + + private void DeleteUserAccount(string domain, string username) + { + try + { + Log.WriteStart("Deleting user account"); + Log.WriteInfo(string.Format("Deleting \"{0}\" user account", username)); + if (SecurityUtils.UserExists(domain, username)) + { + SecurityUtils.DeleteUser(domain, username); + Log.WriteEnd("Deleted user account"); + InstallLog.AppendLine(string.Format("- Deleted \"{0}\" user account ", username)); + } + } + catch (Exception ex) + { + if (Utils.IsThreadAbortException(ex)) + return; + + Log.WriteError("User account delete error", ex); + InstallLog.AppendLine(string.Format("- Failed to delete \"{0}\" user account ", username)); + throw; + } + } + + private void DeleteApplicationPool(string name) + { + try + { + Log.WriteStart("Deleting application pool"); + Log.WriteInfo(string.Format("Deleting \"{0}\" application pool", name)); + if (WebUtils.ApplicationPoolExists(name)) + { + int count = WebUtils.GetApplicationPoolSitesCount(name); + if (count > 0) + { + Log.WriteEnd("Application pool is not empty"); + } + else + { + WebUtils.DeleteApplicationPool(name); + Log.WriteEnd("Deleted application pool"); + InstallLog.AppendLine(string.Format("- Deleted \"{0}\" application pool ", name)); + } + } + } + catch (Exception ex) + { + if (Utils.IsThreadAbortException(ex)) + return; + + Log.WriteError("Application pool delete error", ex); + InstallLog.AppendLine(string.Format("- Failed to delete \"{0}\" application pool ", name)); + throw; + } + } + + private void DeleteIIS7ApplicationPool(string name) + { + try + { + Log.WriteStart("Deleting application pool"); + Log.WriteInfo(string.Format("Deleting \"{0}\" application pool", name)); + if (WebUtils.IIS7ApplicationPoolExists(name)) + { + int count = WebUtils.GetIIS7ApplicationPoolSitesCount(name); + if (count > 0) + { + Log.WriteEnd("Application pool is not empty"); + } + else + { + WebUtils.DeleteIIS7ApplicationPool(name); + Log.WriteEnd("Deleted application pool"); + InstallLog.AppendLine(string.Format("- Deleted \"{0}\" application pool ", name)); + } + } + } + catch (Exception ex) + { + if (Utils.IsThreadAbortException(ex)) + return; + + Log.WriteError("Application pool delete error", ex); + InstallLog.AppendLine(string.Format("- Failed to delete \"{0}\" application pool ", name)); + throw; + } + } + + private void DeleteWebSite(string siteId) + { + try + { + Log.WriteStart("Deleting web site"); + Log.WriteInfo(string.Format("Deleting \"{0}\" web site", siteId)); + if (WebUtils.SiteIdExists(siteId)) + { + WebUtils.DeleteSite(siteId); + Log.WriteEnd("Deleted web site"); + InstallLog.AppendLine(string.Format("- Deleted \"{0}\" web site ", siteId)); + } + } + catch (Exception ex) + { + if (Utils.IsThreadAbortException(ex)) + return; + + Log.WriteError("Web site delete error", ex); + InstallLog.AppendLine(string.Format("- Failed to delete \"{0}\" web site ", siteId)); + throw; + } + } + + private void DeleteIIS7WebSite(string siteId) + { + try + { + Log.WriteStart("Deleting web site"); + Log.WriteInfo(string.Format("Deleting \"{0}\" web site", siteId)); + if (WebUtils.IIS7SiteExists(siteId)) + { + WebUtils.DeleteIIS7Site(siteId); + Log.WriteEnd("Deleted web site"); + InstallLog.AppendLine(string.Format("- Deleted \"{0}\" web site ", siteId)); + } + } + catch (Exception ex) + { + if (Utils.IsThreadAbortException(ex)) + return; + + Log.WriteError("Web site delete error", ex); + InstallLog.AppendLine(string.Format("- Failed to delete \"{0}\" web site ", siteId)); + + throw; + } + } + + private void DeleteVirtualDirectory(string siteId, string name) + { + try + { + Log.WriteStart("Deleting virtual directory"); + Log.WriteInfo(string.Format("Deleting virtual directory \"{0}\" for the site \"{1}\"", name, siteId)); + if (WebUtils.VirtualDirectoryExists(siteId, name)) + { + WebUtils.DeleteVirtualDirectory(siteId, name); + Log.WriteEnd("Deleted virtual directory"); + InstallLog.AppendLine(string.Format("- Deleted \"{0}\" virtual directory ", name)); + } + } + catch (Exception ex) + { + if (Utils.IsThreadAbortException(ex)) + return; + + Log.WriteError("Virtual directory delete error", ex); + InstallLog.AppendLine(string.Format("- Failed to delete \"{0}\" virtual directory ", name)); + throw; + } + } + #endregion + #region Express + + private void ConfigureSecureSessionModuleInWebConfig() + { + try + { + string webConfigPath = Path.Combine(Context.InstallationFolder, "web.config"); + Log.WriteStart("Web.config file is being updated"); + // Ensure the web.config exists + if (!File.Exists(webConfigPath)) + { + Log.WriteInfo(string.Format("File {0} not found", webConfigPath)); + return; + } + // Load web.config + XmlDocument doc = new XmlDocument(); + doc.Load(webConfigPath); + + // add node: + // + // + // + // + // + // + // ... or for IIS 6: + // + // + // + // + // + // + bool iis6 = false; + XmlElement webServer = doc.SelectSingleNode("configuration/system.webServer") as XmlElement; + if (webServer == null) + { + // this is IIS 6 + webServer = doc.SelectSingleNode("configuration/system.web") as XmlElement; + iis6 = true; + } + + if (webServer != null) + { + string modulesNodeName = iis6 ? "httpModules" : "modules"; + if (webServer.SelectSingleNode(modulesNodeName + "/add[@name='SecureSession']") == null) + { + var modules = doc.CreateElement(modulesNodeName); + webServer.AppendChild(modules); + var sessionModule = doc.CreateElement("add"); + sessionModule.SetAttribute("name", "SecureSession"); + sessionModule.SetAttribute("type", "WebsitePanel.WebPortal.SecureSessionModule"); + modules.AppendChild(sessionModule); + } + } + + // update /system.web/httpRuntime element + var httpRuntime = doc.SelectSingleNode("configuration/system.web/httpRuntime") as XmlElement; + if (httpRuntime != null) + httpRuntime.SetAttribute("enableVersionHeader", "false"); + + // add: + // + // + // + var appSettings = doc.SelectSingleNode("configuration/appSettings"); + if (appSettings != null && appSettings.SelectSingleNode("add[@key='SessionValidationKey']") == null) + { + var sessionKey = doc.CreateElement("add"); + sessionKey.SetAttribute("key", "SessionValidationKey"); + sessionKey.SetAttribute("value", StringUtils.GenerateRandomString(16)); + appSettings.AppendChild(sessionKey); + } + + // save changes have been made + doc.Save(webConfigPath); + // + Log.WriteEnd("Web.config has been updated"); + } + catch (Exception ex) + { + if (Utils.IsThreadAbortException(ex)) + return; + Log.WriteError("Could not update web.config file", ex); + throw; + } + } + + private void SwitchWebPortal2AspNet40(InstallAction action, Setup.SetupVariables setupVariables) + { + var sam = new WebPortalActionManager(setupVariables); + sam.AddAction(new RegisterAspNet40Action()); + sam.AddAction(new EnableAspNetWebExtensionAction()); + sam.AddAction(new MigrateWebPortalWebConfigAction()); + sam.AddAction(new SwitchAppPoolAspNetVersion()); + sam.AddAction(new CleanupWebsitePanelModulesListAction()); + // + sam.ActionError += new EventHandler((object sender, ActionErrorEventArgs e) => + { + throw e.OriginalException; + }); + // + sam.Start(); + } + + private void SwitchEntServer2AspNet40(InstallAction action, Setup.SetupVariables setupVariables) + { + var sam = new EntServerActionManager(setupVariables); + sam.AddAction(new RegisterAspNet40Action()); + sam.AddAction(new EnableAspNetWebExtensionAction()); + sam.AddAction(new MigrateEntServerWebConfigAction()); + sam.AddAction(new AdjustHttpRuntimeRequestLengthAction()); + sam.AddAction(new SwitchAppPoolAspNetVersion()); + // + sam.ActionError += new EventHandler((object sender, ActionErrorEventArgs e) => + { + throw e.OriginalException; + }); + // + sam.Start(); + } + + private void SwitchServer2AspNet40(InstallAction action, Setup.SetupVariables setupVariables) + { + var sam = new ServerActionManager(setupVariables); + sam.AddAction(new RegisterAspNet40Action()); + sam.AddAction(new EnableAspNetWebExtensionAction()); + sam.AddAction(new MigrateServerWebConfigAction()); + sam.AddAction(new AdjustHttpRuntimeRequestLengthAction()); + sam.AddAction(new SwitchAppPoolAspNetVersion()); + // + sam.ActionError += new EventHandler((object sender, ActionErrorEventArgs e) => + { + throw e.OriginalException; + }); + // + sam.Start(); + } + + private void MigrateServerWebConfigFile(Setup.SetupVariables setupVariables) + { + // Migrate web.config + // IIS 6 + if (setupVariables.IISVersion.Major == 6) + { + } + // IIS 7 + else + { + + } + } + + private void UpdatePortal2811() + { + try + { + string webConfigPath = Path.Combine(Context.InstallationFolder, "web.config"); + Log.WriteStart("Web.config file is being updated"); + // Ensure the web.config exists + if (!File.Exists(webConfigPath)) + { + Log.WriteInfo(string.Format("File {0} not found", webConfigPath)); + return; + } + // Load web.config + XmlDocument doc = new XmlDocument(); + doc.Load(webConfigPath); + // do Windows 2008 platform-specific changes + bool iis7 = (Context.IISVersion.Major >= 7); + // + #region Do IIS 7 and IIS 6 specific web.config file changes + if (iis7) + { + // remove existing node: + // + // + // + // + // + XmlElement webChartWebServerHandler = doc.SelectSingleNode("configuration/system.webServer/handlers/add[@path='WebChart.axd']") as XmlElement; + // ensure node is found + if (webChartWebServerHandler != null) + { + var parentNode = webChartWebServerHandler.ParentNode; + parentNode.RemoveChild(webChartWebServerHandler); + } + } + else + { + // remove existing node: + // + // + // + // + // + XmlElement webChartWebServerHandler = doc.SelectSingleNode("configuration/system.web/httpHandlers/add[@path='WebChart.axd']") as XmlElement; + // ensure node is found + if (webChartWebServerHandler != null) + { + var parentNode = webChartWebServerHandler.ParentNode; + parentNode.RemoveChild(webChartWebServerHandler); + } + } + #endregion + + #region CompareValidator + // remove existing node: + // + // + // + // + // + // + // + XmlElement compareValidatorMapping = doc.SelectSingleNode("configuration/system.web/pages/tagMapping/add[@tagType='System.Web.UI.WebControls.CompareValidator']") as XmlElement; + // ensure node is found + if (compareValidatorMapping != null) + { + var parentNode = compareValidatorMapping.ParentNode; + parentNode.RemoveChild(compareValidatorMapping); + } + #endregion + + #region CustomValidator + // remove existing node: + // + // + // + // + // + // + // + XmlElement customValidatorMapping = doc.SelectSingleNode("configuration/system.web/pages/tagMapping/add[@tagType='System.Web.UI.WebControls.CustomValidator']") as XmlElement; + // ensure node is found + if (customValidatorMapping != null) + { + var parentNode = customValidatorMapping.ParentNode; + parentNode.RemoveChild(customValidatorMapping); + } + #endregion + + #region RangeValidator + // remove existing node: + // + // + // + // + // + // + // + XmlElement rangeValidatorMapping = doc.SelectSingleNode("configuration/system.web/pages/tagMapping/add[@tagType='System.Web.UI.WebControls.RangeValidator']") as XmlElement; + // ensure node is found + if (rangeValidatorMapping != null) + { + var parentNode = rangeValidatorMapping.ParentNode; + parentNode.RemoveChild(rangeValidatorMapping); + } + #endregion + + #region RegularExpressionValidator + // remove existing node: + // + // + // + // + // + // + // + XmlElement regExpValidatorMapping = doc.SelectSingleNode("configuration/system.web/pages/tagMapping/add[@tagType='System.Web.UI.WebControls.RegularExpressionValidator']") as XmlElement; + // ensure node is found + if (regExpValidatorMapping != null) + { + var parentNode = regExpValidatorMapping.ParentNode; + parentNode.RemoveChild(regExpValidatorMapping); + } + #endregion + + #region RequiredFieldValidator + // remove existing node: + // + // + // + // + // + // + // + XmlElement requiredFieldValidatorMapping = doc.SelectSingleNode("configuration/system.web/pages/tagMapping/add[@tagType='System.Web.UI.WebControls.RequiredFieldValidator']") as XmlElement; + // ensure node is found + if (requiredFieldValidatorMapping != null) + { + var parentNode = requiredFieldValidatorMapping.ParentNode; + parentNode.RemoveChild(requiredFieldValidatorMapping); + } + #endregion + + #region ValidationSummary + // remove existing node: + // + // + // + // + // + // + // + XmlElement validationSummaryMapping = doc.SelectSingleNode("configuration/system.web/pages/tagMapping/add[@tagType='System.Web.UI.WebControls.ValidationSummary']") as XmlElement; + // ensure node is found + if (validationSummaryMapping != null) + { + var parentNode = validationSummaryMapping.ParentNode; + parentNode.RemoveChild(validationSummaryMapping); + } + #endregion + + #region tagMapping + // remove existing node only if it does not have any siblings: + // + // + // + // + // + XmlElement tagMapping = doc.SelectSingleNode("configuration/system.web/pages/tagMapping") as XmlElement; + // ensure node is found + if (tagMapping != null && !tagMapping.HasChildNodes) + { + var parentNode = tagMapping.ParentNode; + parentNode.RemoveChild(tagMapping); + } + #endregion + + // save changes have been made + doc.Save(webConfigPath); + // + Log.WriteEnd("Web.config has been updated"); + } + catch (Exception ex) + { + if (Utils.IsThreadAbortException(ex)) + return; + Log.WriteError("Could not update web.config file", ex); + throw; + } + } + + private void UpdateLicenseInformation() + { + try + { + if (string.IsNullOrEmpty(Context.LicenseKey)) + return; + + Log.WriteStart("Updating license information"); + + string path = Path.Combine(Context.InstallationFolder, Context.ConfigurationFile); + string licenseKey = Context.LicenseKey; + + if (!File.Exists(path)) + { + Log.WriteInfo(string.Format("File {0} not found", path)); + return; + } + + string connectionString = GetConnectionString(path); + if (string.IsNullOrEmpty(connectionString)) + { + Log.WriteError("Connection string setting not found"); + return; + } + + string cryptoKey = GetCryptoKey(path); + if (string.IsNullOrEmpty(cryptoKey)) + { + Log.WriteError("CryptoKey setting not found"); + return; + } + + bool encryptionEnabled = IsEncryptionEnabled(path); + //encrypt password + if (encryptionEnabled) + { + licenseKey = Utils.Encrypt(cryptoKey, licenseKey); + } + + string query = string.Format("INSERT INTO Licenses ( SerialNumber ) VALUES ('{0}')", licenseKey); + SqlUtils.ExecuteQuery(connectionString, query); + + Log.WriteEnd("Updated license information"); + InstallLog.AppendLine("- Updated license information"); + + } + catch (Exception ex) + { + if (Utils.IsThreadAbortException(ex)) + return; + Log.WriteError("Update error", ex); + throw; + } + } + + private string GetConnectionString(string webConfigPath) + { + string ret = null; + XmlDocument doc = new XmlDocument(); + doc.Load(webConfigPath); + //connection string + string xPath = "configuration/connectionStrings/add[@name=\"EnterpriseServer\"]"; + XmlElement connectionStringNode = doc.SelectSingleNode(xPath) as XmlElement; + if (connectionStringNode != null) + { + ret = connectionStringNode.GetAttribute("connectionString"); + } + return ret; + } + + private string GetCryptoKey(string webConfigPath) + { + string ret = null; + XmlDocument doc = new XmlDocument(); + doc.Load(webConfigPath); + //crypto key + string xPath = "configuration/appSettings/add[@key=\"WebsitePanel.CryptoKey\"]"; + XmlElement keyNode = doc.SelectSingleNode(xPath) as XmlElement; + if (keyNode != null) + { + ret = keyNode.GetAttribute("value"); ; + } + return ret; + } + + private bool IsEncryptionEnabled(string webConfigPath) + { + XmlDocument doc = new XmlDocument(); + doc.Load(webConfigPath); + //encryption enabled + string xPath = "configuration/appSettings/add[@key=\"WebsitePanel.EncryptionEnabled\"]"; + XmlElement encryptionNode = doc.SelectSingleNode(xPath) as XmlElement; + bool encryptionEnabled = false; + if (encryptionNode != null) + { + bool.TryParse(encryptionNode.GetAttribute("value"), out encryptionEnabled); + } + return encryptionEnabled; + } + #region WebsitePanel providioning + private void ConfigureStandaloneServer(string enterpriseServerUrl) + { + try + { + Log.WriteStart("Configuring WebsitePanel"); + AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(ResolvePortalAssembly); + + SetProgressText("Configuring WebsitePanel..."); + if (!ConnectToEnterpriseServer(enterpriseServerUrl, "serveradmin", Context.ServerAdminPassword)) + { + Log.WriteError("Enterprise Server connection error"); + return; + } + SetProgressValue(10); + + //Add server + int serverId = AddServer(Context.RemoteServerUrl, "My Server", Context.RemoteServerPassword); + if (serverId < 0) + { + Log.WriteError(string.Format("Enterprise Server error: {0}", serverId)); + return; + } + //Add IP address + string portalIP = AppConfig.GetComponentSettingStringValue(Context.PortalComponentId, "WebSiteIP"); + int ipAddressId = AddIpAddress(portalIP, serverId); + SetProgressValue(20); + //Add OS service + int osServiceId = AddOSService(serverId); + SetProgressValue(30); + //Add Web service + int webServiceId = AddWebService(serverId, ipAddressId); + SetProgressValue(40); + //Add Sql service + int sqlServiceId = AddSqlService(serverId); + SetProgressValue(50); + //Add Dns service + int dnsServiceId = AddDnsService(serverId, ipAddressId); + SetProgressValue(60); + //Add virtual server + int virtualServerId = AddVirtualServer("My Server Resources", serverId, new int[] { osServiceId, webServiceId, sqlServiceId, dnsServiceId }); + SetProgressValue(70); + //Add user + int userId = AddUser("admin", Context.ServerAdminPassword, "Server", "Administrator", "admin@myhosting.com"); + SetProgressValue(80); + //Add plan + int planId = -1; + if (virtualServerId > 0) + { + planId = AddHostingPlan("My Server", virtualServerId); + } + SetProgressValue(90); + //Add package + if (userId > 0 && planId > 0) + { + int packageId = AddPackage("My Server", userId, planId); + } + SetProgressValue(95); + ConfigureWebPolicy(1); + SetProgressValue(100); + Log.WriteEnd("Server configured"); + } + catch (Exception ex) + { + if (Utils.IsThreadAbortException(ex)) + return; + Log.WriteError("Server configuration error", ex); + } + } + + private void SetProgressText(string p) // Do nothing. + { + //throw new NotImplementedException(); + } + + protected void SetProgressValue(int p) + { + m_Progress = p; + Log.WriteInfo(string.Format("Current progress is {0}%.", m_Progress)); + } + + private void ConfigureWebPolicy(int userId) + { + try + { + Log.WriteStart("Configuring Web Policy"); + UserSettings settings = ES.Services.Users.GetUserSettings(userId, "WebPolicy"); + settings["AspNetInstalled"] = "2I"; + if (Context.IISVersion.Major == 6) + settings["AspNetInstalled"] = "2"; + ES.Services.Users.UpdateUserSettings(settings); + Log.WriteEnd("Configured Web Policy"); + } + catch (Exception ex) + { + if (!Utils.IsThreadAbortException(ex)) + Log.WriteError("Web policy configuration error", ex); + } + } + + private int AddOSService(int serverId) + { + try + { + Log.WriteStart("Adding OS service"); + ServiceInfo serviceInfo = new ServiceInfo(); + serviceInfo.ServerId = serverId; + serviceInfo.ServiceName = "OS"; + serviceInfo.Comments = string.Empty; + + //check OS version + OS.WindowsVersion version = OS.GetVersion(); + if (version == OS.WindowsVersion.WindowsServer2003) + { + serviceInfo.ProviderId = 1; + } + else if (version == OS.WindowsVersion.WindowsServer2008) + { + serviceInfo.ProviderId = 100; + } + int serviceId = ES.Services.Servers.AddService(serviceInfo); + if (serviceId > 0) + { + InstallService(serviceId); + Log.WriteEnd("Added OS service"); + } + else + { + Log.WriteError(string.Format("Enterprise Server error: {0}", serviceId)); + } + return serviceId; + } + catch (Exception ex) + { + if (!Utils.IsThreadAbortException(ex)) + Log.WriteError("OS service configuration error", ex); + return -1; + } + } + + private int AddWebService(int serverId, int ipAddressId) + { + try + { + Log.WriteStart("Adding Web service"); + ServiceInfo serviceInfo = new ServiceInfo(); + serviceInfo.ServerId = serverId; + serviceInfo.ServiceName = "Web"; + serviceInfo.Comments = string.Empty; + + //check IIS version + if (Context.IISVersion.Major >= 7) + { + serviceInfo.ProviderId = 101; + } + else if (Context.IISVersion.Major == 6) + { + serviceInfo.ProviderId = 2; + } + int serviceId = ES.Services.Servers.AddService(serviceInfo); + if (serviceId > 0) + { + StringDictionary settings = GetServiceSettings(serviceId); + if (settings != null) + { + // set ip address + if (ipAddressId > 0) + settings["sharedip"] = ipAddressId.ToString(); + + // settings for win2003 x64 + if (Context.IISVersion.Major == 6 && + Utils.IsWin64() && !Utils.IIS32Enabled()) + { + settings["AspNet20Path"] = @"%SYSTEMROOT%\Microsoft.NET\Framework64\v2.0.50727\aspnet_isapi.dll"; + settings["Php4Path"] = @"%SYSTEMDRIVE%\Program Files (x86)\PHP\php.exe"; + settings["Php5Path"] = @"%SYSTEMDRIVE%\Program Files (x86)\PHP\php-cgi.exe"; + } + // settings for win2008 x64 + if (Context.IISVersion.Major > 6 && + Utils.IsWin64()) + { + settings["Php4Path"] = @"%SYSTEMDRIVE%\Program Files (x86)\PHP\php.exe"; + settings["Php5Path"] = @"%SYSTEMDRIVE%\Program Files (x86)\PHP\php-cgi.exe"; + settings["phppath"] = @"%SYSTEMDRIVE%\Program Files (x86)\PHP\php-cgi.exe"; + } + + UpdateServiceSettings(serviceId, settings); + } + InstallService(serviceId); + Log.WriteEnd("Added Web service"); + } + else + { + Log.WriteError(string.Format("Enterprise Server error: {0}", serviceId)); + } + return serviceId; + } + catch (Exception ex) + { + if (!Utils.IsThreadAbortException(ex)) + Log.WriteError("Web service configuration error", ex); + return -1; + } + } + + private int AddSqlService(int serverId) + { + int serviceId = -1; + try + { + Log.WriteStart("Adding Sql service"); + + SqlServerItem item = ParseConnectionString(Context.DbInstallConnectionString); + string serverName = item.Server.ToLower(); + if (serverName.StartsWith("(local)") || + serverName.StartsWith("localhost") || + serverName.StartsWith(System.Environment.MachineName.ToLower())) + { + ServiceInfo serviceInfo = new ServiceInfo(); + serviceInfo.ServerId = serverId; + serviceInfo.ServiceName = "SQL Server"; + serviceInfo.Comments = string.Empty; + + string connectionString = Context.DbInstallConnectionString; + //check SQL version + if (SqlUtils.CheckSqlConnection(connectionString)) + { + // check SQL server version + string sqlVersion = SqlUtils.GetSqlServerVersion(connectionString); + if (sqlVersion.StartsWith("9.")) + { + serviceInfo.ProviderId = 16; + } + else if (sqlVersion.StartsWith("10.")) + { + serviceInfo.ProviderId = 202; + } + else if (sqlVersion.StartsWith("11.")) + { + serviceInfo.ProviderId = 209; + } + else if (sqlVersion.StartsWith("12.")) + { + serviceInfo.ProviderId = 1203; + } + serviceId = ES.Services.Servers.AddService(serviceInfo); + } + else + Log.WriteInfo("SQL Server connection error"); + //configure service + if (serviceId > 0) + { + StringDictionary settings = GetServiceSettings(serviceId); + if (settings != null) + { + settings["InternalAddress"] = item.Server; + settings["ExternalAddress"] = string.Empty; + settings["UseTrustedConnection"] = item.WindowsAuthentication.ToString(); + settings["SaLogin"] = item.User; + settings["SaPassword"] = item.Password; + UpdateServiceSettings(serviceId, settings); + } + InstallService(serviceId); + Log.WriteEnd("Added Sql service"); + } + else + { + Log.WriteError(string.Format("Enterprise Server error: {0}", serviceId)); + } + } + else + { + Log.WriteError("Microsoft SQL Server was not found"); + } + return serviceId; + } + catch (Exception ex) + { + if (!Utils.IsThreadAbortException(ex)) + Log.WriteError("Sql service configuration error", ex); + return -1; + } + } + + private int AddDnsService(int serverId, int ipAddressId) + { + try + { + Log.WriteStart("Adding DNS service"); + int providerId = 7; + int serviceId = -1; + BoolResult result = ES.Services.Servers.IsInstalled(serverId, providerId); + if (result.IsSuccess && result.Value) + { + ServiceInfo serviceInfo = new ServiceInfo(); + serviceInfo.ServerId = serverId; + serviceInfo.ServiceName = "DNS"; + serviceInfo.Comments = string.Empty; + serviceInfo.ProviderId = providerId; + serviceId = ES.Services.Servers.AddService(serviceInfo); + } + else + { + Log.WriteInfo("Microsoft DNS was not found"); + return -1; + } + + if (serviceId > 0) + { + StringDictionary settings = GetServiceSettings(serviceId); + if (settings != null) + { + if (ipAddressId > 0) + settings["listeningipaddresses"] = ipAddressId.ToString(); + UpdateServiceSettings(serviceId, settings); + } + InstallService(serviceId); + Log.WriteEnd("Added DNS service"); + } + else + { + Log.WriteError(string.Format("Enterprise Server error: {0}", serviceId)); + } + return serviceId; + } + catch (Exception ex) + { + if (!Utils.IsThreadAbortException(ex)) + Log.WriteError("DNS service configuration error", ex); + return -1; + } + } + + private int AddServer(string url, string name, string password) + { + try + { + Log.WriteStart("Adding server"); + ServerInfo serverInfo = new ServerInfo() + { + ADAuthenticationType = null, + ADPassword = null, + ADEnabled = false, + ADRootDomain = null, + ADUsername = null, + Comments = string.Empty, + Password = password, + ServerName = name, + ServerUrl = url, + VirtualServer = false + }; + + int serverId = ES.Services.Servers.AddServer(serverInfo, false); + if (serverId > 0) + { + Log.WriteEnd("Added server"); + } + else + { + Log.WriteError(string.Format("Enterprise Server error: {0}", serverId)); + } + return serverId; + } + catch (Exception ex) + { + if (!Utils.IsThreadAbortException(ex)) + Log.WriteError("Server configuration error", ex); + return -1; + } + } + + private int AddIpAddress(string ip, int serverId) + { + try + { + Log.WriteStart("Adding IP address"); + IntResult res = ES.Services.Servers.AddIPAddress(IPAddressPool.General, serverId, ip, string.Empty, string.Empty, string.Empty, string.Empty); + if (res.IsSuccess && res.Value > 0) + { + Log.WriteEnd("Added IP address"); + } + else + { + Log.WriteError(string.Format("Enterprise Server error: {0}", res.Value)); + } + return res.Value; + } + catch (Exception ex) + { + if (!Utils.IsThreadAbortException(ex)) + Log.WriteError("IP address configuration error", ex); + return -1; + } + } + + private int AddVirtualServer(string name, int serverId, int[] services) + { + Log.WriteStart("Adding virtual server"); + ServerInfo serverInfo = new ServerInfo() + { + Comments = string.Empty, + ServerName = name, + VirtualServer = true + }; + + int virtualServerId = ES.Services.Servers.AddServer(serverInfo, false); + if (virtualServerId > 0) + { + List allServices = new List(services); + List validServices = new List(); + foreach (int serviceId in allServices) + { + if (serviceId > 0) + validServices.Add(serviceId); + } + ES.Services.Servers.AddVirtualServices(virtualServerId, validServices.ToArray()); + Log.WriteEnd("Added virtual server"); + } + else + { + Log.WriteError(string.Format("Enterprise Server error: {0}", virtualServerId)); + } + + return virtualServerId; + } + + private int AddUser(string loginName, string password, string firstName, string lastName, string email) + { + try + { + Log.WriteStart("Adding user account"); + UserInfo user = new UserInfo(); + user.UserId = 0; + user.Role = UserRole.User; + user.StatusId = 1; + user.OwnerId = 1; + user.IsDemo = false; + user.IsPeer = false; + user.HtmlMail = true; + user.Username = loginName; + user.Password = password; + user.FirstName = firstName; + user.LastName = lastName; + user.Email = email; + + int userId = ES.Services.Users.AddUser(user, false); + if (userId > 0) + { + Log.WriteEnd("Added user account"); + } + else + { + Log.WriteError(string.Format("Enterprise Server error: {0}", userId)); + } + return userId; + } + catch (Exception ex) + { + if (!Utils.IsThreadAbortException(ex)) + Log.WriteError("User configuration error", ex); + return -1; + } + } + + private int AddHostingPlan(string name, int serverId) + { + try + { + Log.WriteStart("Adding hosting plan"); + // gather form info + HostingPlanInfo plan = new HostingPlanInfo(); + plan.UserId = 1; + plan.PlanId = 0; + plan.IsAddon = false; + plan.PlanName = name; + plan.PlanDescription = ""; + plan.Available = true; // always available + + plan.SetupPrice = 0; + plan.RecurringPrice = 0; + plan.RecurrenceLength = 1; + plan.RecurrenceUnit = 2; // month + + plan.PackageId = 0; + plan.ServerId = serverId; + List groups = new List(); + List quotas = new List(); + + DataSet ds = ES.Services.Packages.GetHostingPlanQuotas(-1, 0, serverId); + + foreach (DataRow groupRow in ds.Tables[0].Rows) + { + bool enabled = (bool)groupRow["ParentEnabled"]; + if (!enabled) + continue; // disabled group + + int groupId = (int)groupRow["GroupId"]; ; + + HostingPlanGroupInfo group = new HostingPlanGroupInfo(); + group.GroupId = groupId; + group.Enabled = true; + group.CalculateDiskSpace = (bool)groupRow["CalculateDiskSpace"]; + group.CalculateBandwidth = (bool)groupRow["CalculateBandwidth"]; + groups.Add(group); + + DataView dvQuotas = new DataView(ds.Tables[1], "GroupID=" + group.GroupId.ToString(), "", DataViewRowState.CurrentRows); + List groupQuotas = GetGroupQuotas(groupId, dvQuotas); + quotas.AddRange(groupQuotas); + + } + + plan.Groups = groups.ToArray(); + plan.Quotas = quotas.ToArray(); + + int planId = ES.Services.Packages.AddHostingPlan(plan); + if (planId > 0) + { + Log.WriteEnd("Added hosting plan"); + } + else + { + Log.WriteError(string.Format("Enterprise Server error: {0}", planId)); + } + return planId; + } + catch (Exception ex) + { + if (!Utils.IsThreadAbortException(ex)) + Log.WriteError("Hosting plan configuration error", ex); + return -1; + } + } + + private List GetGroupQuotas(int groupId, DataView dvQuotas) + { + List quotas = new List(); + //OS quotas + if (groupId == 1) + quotas = GetOSQuotas(dvQuotas); + //Web quotas + else if (groupId == 2) + quotas = GetWebQuotas(dvQuotas); + else + { + foreach (DataRowView quotaRow in dvQuotas) + { + int quotaTypeId = (int)quotaRow["QuotaTypeID"]; + HostingPlanQuotaInfo quota = new HostingPlanQuotaInfo(); + quota.QuotaId = (int)quotaRow["QuotaID"]; + quota.QuotaValue = (quotaTypeId == 1) ? 1 : -1; + quotas.Add(quota); + } + } + return quotas; + } + + private List GetOSQuotas(DataView dvQuotas) + { + List quotas = new List(); + foreach (DataRowView quotaRow in dvQuotas) + { + int quotaTypeId = (int)quotaRow["QuotaTypeID"]; + string quotaName = (string)quotaRow["QuotaName"]; + HostingPlanQuotaInfo quota = new HostingPlanQuotaInfo(); + quota.QuotaId = (int)quotaRow["QuotaID"]; + quota.QuotaValue = (quotaTypeId == 1) ? 1 : -1; + if (quotaName == "OS.AppInstaller" || + quotaName == "OS.ExtraApplications") + quota.QuotaValue = 0; + + quotas.Add(quota); + } + return quotas; + } + + private List GetWebQuotas(DataView dvQuotas) + { + List quotas = new List(); + foreach (DataRowView quotaRow in dvQuotas) + { + int quotaTypeId = (int)quotaRow["QuotaTypeID"]; + string quotaName = (string)quotaRow["QuotaName"]; + HostingPlanQuotaInfo quota = new HostingPlanQuotaInfo(); + quota.QuotaId = (int)quotaRow["QuotaID"]; + quota.QuotaValue = (quotaTypeId == 1) ? 1 : -1; + if (quotaName == "Web.Asp" || + quotaName == "Web.AspNet11" || + quotaName == "Web.Php4" || + quotaName == "Web.Perl" || + quotaName == "Web.CgiBin" || + quotaName == "Web.SecuredFolders" || + quotaName == "Web.SharedSSL" || + quotaName == "Web.Python" || + quotaName == "Web.AppPools" || + quotaName == "Web.IPAddresses" || + quotaName == "Web.ColdFusion" || + quotaName == "Web.CFVirtualDirectories" || + quotaName == "Web.RemoteManagement") + quota.QuotaValue = 0; + + quotas.Add(quota); + } + return quotas; + } + + private int AddPackage(string name, int userId, int planId) + { + try + { + Log.WriteStart("Adding hosting space"); + // gather form info + PackageResult res = ES.Services.Packages.AddPackageWithResources(userId, planId, + name, 1, false, false, string.Empty, false, false, false, null, false, string.Empty); + if (res.Result > 0) + Log.WriteEnd("Added hosting space"); + else + Log.WriteError(string.Format("Enterprise Server error: {0}", planId)); + return res.Result; + } + catch (Exception ex) + { + if (!Utils.IsThreadAbortException(ex)) + Log.WriteError("Hosting space configuration error", ex); + return -1; + } + } + + private bool ConnectToEnterpriseServer(string url, string username, string password) + { + return ES.Connect(url, username, password); + } + + private void UpdateServiceSettings(int serviceId, StringDictionary settings) + { + if (serviceId < 0 || settings == null) + return; + + try + { + // save settings + int result = ES.Services.Servers.UpdateServiceSettings(serviceId, + ConvertDictionaryToArray(settings)); + + if (result < 0) + { + Log.WriteError(string.Format("Enterprise Server error: {0}", result)); + } + } + catch (Exception ex) + { + if (!Utils.IsThreadAbortException(ex)) + Log.WriteError("Update service settings error", ex); + } + } + + private void InstallService(int serviceId) + { + if (serviceId < 0) + return; + + string[] installResults = null; + + try + { + installResults = ES.Services.Servers.InstallService(serviceId); + foreach (string result in installResults) + { + Log.WriteInfo(result); + } + } + catch (Exception ex) + { + if (!Utils.IsThreadAbortException(ex)) + Log.WriteError("Install service error", ex); + } + } + + private StringDictionary GetServiceSettings(int serviceId) + { + StringDictionary ret = null; + try + { + if (serviceId > 0) + { + // load service properties and bind them + string[] settings = ES.Services.Servers.GetServiceSettings(serviceId); + ret = ConvertArrayToDictionary(settings); + } + } + catch (Exception ex) + { + if (!Utils.IsThreadAbortException(ex)) + Log.WriteError("Get service settings error", ex); + } + return ret; + } + + private string[] ConvertDictionaryToArray(StringDictionary settings) + { + List r = new List(); + foreach (string key in settings.Keys) + r.Add(key + "=" + settings[key]); + return r.ToArray(); + } + + private StringDictionary ConvertArrayToDictionary(string[] settings) + { + StringDictionary r = new StringDictionary(); + foreach (string setting in settings) + { + int idx = setting.IndexOf('='); + r.Add(setting.Substring(0, idx), setting.Substring(idx + 1)); + } + return r; + } + + private SqlServerItem ParseConnectionString(string connectionString) + { + SqlServerItem ret = new SqlServerItem(); + + ret.WindowsAuthentication = false; + string[] pairs = connectionString.Split(';'); + foreach (string pair in pairs) + { + string[] keyValue = pair.Split('='); + if (keyValue.Length == 2) + { + string key = keyValue[0].Trim().ToLower(); + string value = keyValue[1]; + switch (key) + { + case "server": + ret.Server = value; + break; + case "database": + ret.Database = value; + break; + case "integrated security": + if (value.Trim().ToLower() == "sspi") + ret.WindowsAuthentication = true; + break; + case "user": + case "user id": + ret.User = value; + break; + case "password": + ret.Password = value; + break; + } + } + } + return ret; + } + + private Assembly ResolvePortalAssembly(object sender, ResolveEventArgs args) + { + Assembly ret = null; + + string portalPath = AppConfig.GetComponentSettingStringValue(Context.PortalComponentId, "InstallFolder"); + string binPath = Path.Combine(portalPath, "bin"); + string path = Path.Combine(binPath, args.Name.Split(',')[0] + ".dll"); + Log.WriteInfo("Assembly to resolve: " + path); + if (File.Exists(path)) + { + ret = Assembly.LoadFrom(path); + Log.WriteInfo("Assembly resolved: " + path); + } + return ret; + } + #endregion + + private void CreateWPServerLogin() + { + try + { + Log.WriteStart("Creating WebsitePanel login"); + string query = string.Empty; + + string connectionString = AppConfig.GetComponentSettingStringValue( + Context.EnterpriseServerComponentId, + "InstallConnectionString"); + + SqlServerItem item = ParseConnectionString(connectionString); + string serverName = item.Server.ToLower(); + if (serverName.StartsWith("(local)") || + serverName.StartsWith("localhost") || + serverName.StartsWith(System.Environment.MachineName.ToLower())) + { + + string domain = AppConfig.GetComponentSettingStringValue( + Context.ServerComponentId, + "Domain"); + if (string.IsNullOrEmpty(domain)) + domain = System.Environment.MachineName; + + string userAccount = AppConfig.GetComponentSettingStringValue( + Context.ServerComponentId, + "UserAccount"); + + string loginName = string.Format("{0}\\{1}", domain, userAccount); + + if (!SqlUtils.LoginExists(connectionString, loginName)) + { + query = string.Format("CREATE LOGIN [{0}] FROM WINDOWS WITH DEFAULT_DATABASE=[master]", loginName); + SqlUtils.ExecuteQuery(connectionString, query); + } + query = string.Format("EXEC master..sp_addsrvrolemember @loginame = N'{0}', @rolename = N'sysadmin'", loginName); + SqlUtils.ExecuteQuery(connectionString, query); + + AppConfig.SetComponentSettingStringValue(Context.EnterpriseServerComponentId, "DatabaseLogin", loginName); + + Log.WriteEnd("Created WebsitePanel login"); + } + else + { + Log.WriteInfo("Microsoft SQL Server is not located on the local server."); + } + } + catch (Exception ex) + { + if (Utils.IsThreadAbortException(ex)) + return; + Log.WriteError("SQL error", ex); + } + } + + private void UpdateServerAdminPassword() + { + try + { + if (!Context.UpdateServerAdminPassword) + return; + + Log.WriteStart("Updating serveradmin password"); + + string path = Path.Combine(Context.InstallationFolder, Context.ConfigurationFile); + string password = Context.ServerAdminPassword; + + if (!File.Exists(path)) + { + Log.WriteInfo(string.Format("File {0} not found", path)); + return; + } + + string connectionString = GetConnectionString(path); + if (string.IsNullOrEmpty(connectionString)) + { + Log.WriteError("Connection string setting not found"); + return; + } + + string cryptoKey = GetCryptoKey(path); + if (string.IsNullOrEmpty(cryptoKey)) + { + Log.WriteError("CryptoKey setting not found"); + return; + } + + bool encryptionEnabled = IsEncryptionEnabled(path); + //encrypt password + if (encryptionEnabled) + { + password = Utils.Encrypt(cryptoKey, password); + } + + string query = string.Format("UPDATE Users SET Password = '{0}' WHERE UserID = 1", password); + SqlUtils.ExecuteQuery(connectionString, query); + + Log.WriteEnd("Updated serveradmin password"); + InstallLog.AppendLine("- Updated password for the serveradmin account"); + + } + catch (Exception ex) + { + if (Utils.IsThreadAbortException(ex)) + return; + Log.WriteError("Update error", ex); + throw; + } + } + + private void RegisterWindowsService() + { + try + { + string componentId = Context.ComponentId; + string path = Path.Combine(Context.InstallationFolder, Context.ServiceFile); + string service = Context.ServiceName; + if (!File.Exists(path)) + { + Log.WriteError(string.Format("File {0} not found", path), null); + return; + } + + Log.WriteStart(string.Format("Registering \"{0}\" windows service", service)); + string domain = Context.UserDomain; + if (string.IsNullOrEmpty(domain)) + domain = "."; + string arguments = string.Format("/i /LogFile=\"\" /user={0}\\{1} /password={2}", + domain, Context.UserAccount, Context.UserPassword); + int exitCode = Utils.RunProcess(path, arguments); + if (exitCode == 0) + { + //add rollback action + RollBack.RegisterWindowsService(path, service); + + //update log + Log.WriteEnd("Registered windows service"); + //update install log + InstallLog.AppendLine(string.Format("- Registered \"{0}\" Windows service ", service)); + } + else + { + Log.WriteError(string.Format("Unable to register \"{0}\" Windows service. Error code: {1}", service, exitCode), null); + InstallLog.AppendLine(string.Format("- Failed to register \"{0}\" windows service ", service)); + } + // update config setings + AppConfig.SetComponentSettingStringValue(componentId, "ServiceName", Context.ServiceName); + AppConfig.SetComponentSettingStringValue(componentId, "ServiceFile", Context.ServiceFile); + } + catch (Exception ex) + { + if (Utils.IsThreadAbortException(ex)) + return; + Log.WriteError("Windows service error", ex); + } + } + + private void StartWindowsService() + { + try + { + string service = Context.ServiceName; + Log.WriteStart(string.Format("Starting \"{0}\" Windows service", service)); + Utils.StartService(service); + //update log + Log.WriteEnd("Started Windows service"); + InstallLog.AppendLine(string.Format("- Started \"{0}\" Windows service ", service)); + } + catch (Exception ex) + { + if (Utils.IsThreadAbortException(ex)) + return; + Log.WriteError("Windows service start error", ex); + } + } + + private void StopWindowsService() + { + try + { + string service = Context.ServiceName; + Log.WriteStart(string.Format("Stopping \"{0}\" Windows service", service)); + Utils.StopService(service); + //update log + Log.WriteEnd("Stopped Windows service"); + InstallLog.AppendLine(string.Format("- Stopped \"{0}\" Windows service ", service)); + } + catch (Exception ex) + { + if (Utils.IsThreadAbortException(ex)) + return; + Log.WriteError("Windows service stop error", ex); + } + } + + private void StopApplicationPool() + { + try + { + string componentId = Context.ComponentId; + string appPool = AppConfig.GetComponentSettingStringValue(componentId, "ApplicationPool"); + if (string.IsNullOrEmpty(appPool)) + return; + + Version iisVersion = Context.IISVersion; + bool iis7 = (iisVersion.Major >= 7); + + Log.WriteStart("Stopping IIS Application Pool"); + Log.WriteInfo(string.Format("Stopping \"{0}\"", appPool)); + if (iis7) + WebUtils.StopIIS7ApplicationPool(appPool); + else + WebUtils.StopApplicationPool(appPool); + + Log.WriteEnd("Stopped IIS Application Pool"); + // rollback + if (iis7) + RollBack.RegisterStopIIS7ApplicationPool(appPool); + else + RollBack.RegisterStopApplicationPool(appPool); + + } + catch (Exception ex) + { + if (Utils.IsThreadAbortException(ex)) + return; + Log.WriteError("Application Pool stop error", ex); + } + } + + private void StartApplicationPool() + { + try + { + string componentId = Context.ComponentId; + string appPool = AppConfig.GetComponentSettingStringValue(componentId, "ApplicationPool"); + if (string.IsNullOrEmpty(appPool)) + return; + + Version iisVersion = Context.IISVersion; + bool iis7 = (iisVersion.Major >= 7); + + Log.WriteStart("Starting IIS Application Pool"); + Log.WriteInfo(string.Format("Starting \"{0}\"", appPool)); + if (iis7) + WebUtils.StartIIS7ApplicationPool(appPool); + else + WebUtils.StartApplicationPool(appPool); + + Log.WriteEnd("Started IIS Application Pool"); + } + catch (Exception ex) + { + if (Utils.IsThreadAbortException(ex)) + return; + Log.WriteError("Application Pool start error", ex); + } + } + + private void UpdateServers() + { + try + { + if (Context.SQLServers == null) + return; + + string path = Path.Combine(Context.InstallationFolder, "config.xml"); + + if (!File.Exists(path)) + { + Log.WriteInfo(string.Format("File {0} not found", path)); + return; + } + + Log.WriteStart("Updating config.xml file"); + XmlDocument doc = new XmlDocument(); + doc.Load(path); + + XmlNode serversNode = doc.SelectSingleNode("//myLittleAdmin/sqlservers"); + if (serversNode == null) + { + Log.WriteInfo("sql server setting not found"); + return; + } + + if (serversNode.HasChildNodes) + serversNode.RemoveAll(); + + foreach (ServerItem item in Context.SQLServers) + { + XmlElement serverNode = doc.CreateElement("sqlserver"); + serverNode.SetAttribute("address", item.Server); + serverNode.SetAttribute("name", item.Name); + serversNode.AppendChild(serverNode); + } + doc.Save(path); + Log.WriteEnd("Updated config.xml file"); + InstallLog.AppendLine("- Updated config.xml file"); + } + catch (Exception ex) + { + if (Utils.IsThreadAbortException(ex)) + return; + Log.WriteError("Update config.xml error", ex); + throw; + } + } + + private void CreateShortcuts() + { + try + { + string ip = Context.WebSiteIP; + string domain = Context.WebSiteDomain; + string port = Context.WebSitePort; + + string[] urls = GetApplicationUrls(ip, domain, port, null); + string url = null; + if (urls.Length > 0) + url = "http://" + urls[0]; + else + { + Log.WriteInfo("Application url not found"); + return; + } + + Log.WriteStart("Creating menu shortcut"); + string programs = Environment.GetFolderPath(Environment.SpecialFolder.Programs); + string fileName = "Login to WebsitePanel.url"; + string path = Path.Combine(programs, "WebsitePanel Software"); + if (!Directory.Exists(path)) + { + Directory.CreateDirectory(path); + } + path = Path.Combine(path, fileName); + using (StreamWriter sw = File.CreateText(path)) + { + WriteShortcutData(url, sw); + } + Log.WriteEnd("Created menu shortcut"); + + Log.WriteStart("Creating desktop shortcut"); + string desktop = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory); + path = Path.Combine(desktop, fileName); + using (StreamWriter sw = File.CreateText(path)) + { + WriteShortcutData(url, sw); + } + Log.WriteEnd("Created desktop shortcut"); + + InstallLog.AppendLine("- Created application shortcuts"); + } + catch (Exception ex) + { + if (Utils.IsThreadAbortException(ex)) + return; + Log.WriteError("Create shortcut error", ex); + //throw; + } + } + + private static void WriteShortcutData(string url, StreamWriter sw) + { + sw.WriteLine("[InternetShortcut]"); + sw.WriteLine("URL=" + url); + string iconFile = Path.Combine(Environment.SystemDirectory, "url.dll"); + sw.WriteLine("IconFile=" + iconFile); + sw.WriteLine("IconIndex=0"); + sw.WriteLine("HotKey=0"); + Log.WriteInfo(string.Format("Shortcut url: {0}", url)); + } + + /// + /// Tighten WSE security for Server + /// + private void UpdateWseSecuritySettings() + { + try + { + string webConfigPath = Path.Combine(Context.InstallationFolder, "web.config"); + Log.WriteStart("Web.config file is being updated"); + // Ensure the web.config exists + if (!File.Exists(webConfigPath)) + { + Log.WriteInfo(string.Format("File {0} not found", webConfigPath)); + return; + } + // Load web.config + XmlDocument doc = new XmlDocument(); + doc.Load(webConfigPath); + + // Tighten WSE security on local machine + XmlElement httpPostLocalhost = doc.SelectSingleNode("configuration/system.web/webServices/protocols/remove[@name='HttpPostLocalhost']") as XmlElement; + // ensure node is found + if (httpPostLocalhost == null) + { + var protocolsNode = doc.SelectSingleNode("configuration/system.web/webServices/protocols"); + // + if (protocolsNode != null) + { + protocolsNode.InnerXml += ""; + } + } + + // save changes have been made + doc.Save(webConfigPath); + // + Log.WriteEnd("Web.config has been updated"); + } + catch (Exception ex) + { + if (Utils.IsThreadAbortException(ex)) + return; + Log.WriteError("Could not update web.config file", ex); + throw; + } + } + + private void CopyWebConfig() + { + try + { + Log.WriteStart("Copying web.config"); + string configPath = Path.Combine(Context.InstallationFolder, "web.config"); + string config6Path = Path.Combine(Context.InstallationFolder, "web6.config"); + + bool iis7 = (Context.IISVersion.Major == 6); + if (!File.Exists(config6Path)) + { + Log.WriteInfo(string.Format("File {0} not found", config6Path)); + return; + } + + if (iis7) + { + if (!File.Exists(configPath)) + { + Log.WriteInfo(string.Format("File {0} not found", configPath)); + return; + } + + FileUtils.DeleteFile(configPath); + File.Move(config6Path, configPath); + } + else + { + FileUtils.DeleteFile(config6Path); + } + Log.WriteEnd("Copied web.config"); + } + catch (Exception ex) + { + if (Utils.IsThreadAbortException(ex)) + return; + Log.WriteError("Copy web.config error", ex); + throw; + } + } + + private void LoadPortal153Settings() + { + try + { + string path = Path.Combine(Context.InstallationFolder, "web.config"); + + if (!File.Exists(path)) + { + Log.WriteInfo(string.Format("File {0} not found", path)); + return; + } + + Log.WriteStart("Loading portal settings"); + XmlDocument doc = new XmlDocument(); + doc.Load(path); + + string xPath = "configuration/connectionStrings/add[@name=\"SiteSqlServer\"]"; + XmlElement connectionNode = doc.SelectSingleNode(xPath) as XmlElement; + if (connectionNode != null) + { + string connectionString = connectionNode.GetAttribute("connectionString"); + Context.ConnectionString = connectionString; + Log.WriteInfo(string.Format("Connection string loaded: {0}", connectionString)); + } + else + { + Context.ConnectionString = null; + Log.WriteError("Connection string not found!", null); + } + + Log.WriteEnd("Loaded portal settings"); + } + catch (Exception ex) + { + if (Utils.IsThreadAbortException(ex)) + return; + Log.WriteError("Loading portal settings error", ex); + throw; + } + } + + private void UpdateWebConfigNamespaces() + { + try + { + // find all .config files in the installation directory + string[] configFiles = Directory.GetFiles(Context.InstallationFolder, + "*.config", SearchOption.TopDirectoryOnly); + + if (configFiles != null && configFiles.Length > 0) + { + foreach (string path in configFiles) + { + try + { + Log.WriteStart(String.Format("Updating '{0}' file", path)); + + // load configuration file in memory + string content = File.ReadAllText(path); + + // replace DotNetPark. to empty strings + content = Regex.Replace(content, "dotnetpark\\.", "", RegexOptions.IgnoreCase); + + // save updated config + File.WriteAllText(path, content); + + Log.WriteEnd(String.Format("Updated '{0}' file", path)); + InstallLog.AppendLine(String.Format("- Updated {0} file", path)); + } + catch (Exception ex) + { + if (Utils.IsThreadAbortException(ex)) + return; + Log.WriteError(String.Format("Error updating '{0}' file", path), ex); + throw; + } + } + } + } + catch (Exception ex) + { + if (Utils.IsThreadAbortException(ex)) + return; + Log.WriteError("Error listing *.config files", ex); + throw; + } + } + + private void UpdateEnterpriseServerUrl() + { + try + { + string url = Context.EnterpriseServerURL; + string installFolder = Context.InstallationFolder; + string file = @"App_Data\SiteSettings.config"; + + string path = Path.Combine(installFolder, file); + + if (!File.Exists(path)) + { + Log.WriteInfo(string.Format("File {0} not found", path)); + return; + } + + Log.WriteStart("Updating site settings"); + XmlDocument doc = new XmlDocument(); + doc.Load(path); + + XmlElement urlNode = doc.SelectSingleNode("SiteSettings/EnterpriseServer") as XmlElement; + if (urlNode == null) + { + Log.WriteInfo("EnterpriseServer setting not found"); + return; + } + + urlNode.InnerText = url; + doc.Save(path); + Log.WriteEnd("Updated site settings"); + InstallLog.AppendLine("- Updated site settings"); + } + catch (Exception ex) + { + if (Utils.IsThreadAbortException(ex)) + return; + + Log.WriteError("Site settigs error", ex); + throw; + } + } + + private void DeleteFiles(string file) + { + try + { + string component = Context.ComponentFullName; + string installerFolder = Context.InstallerFolder; + string installFolder = Context.InstallationFolder; + + //file with list of files to delete + string path = Path.Combine(installerFolder, file); + + if (!File.Exists(path)) + return; + + Log.WriteStart("Deleting files"); + long count = 0; + + using (StreamReader reader = new StreamReader(path)) + { + string fileName; + string filePath; + // Read and display lines from the file until the end of the file is reached. + while ((fileName = reader.ReadLine()) != null) + { + if (!string.IsNullOrEmpty(fileName)) + { + filePath = Path.Combine(installFolder, fileName); + if (Directory.Exists(filePath)) + { + FileUtils.DeleteDirectory(filePath); + count++; + } + else if (File.Exists(filePath)) + { + FileUtils.DeleteFile(filePath); + count++; + } + } + } + } + Log.WriteEnd(string.Format("Deleted {0} files", count)); + InstallLog.AppendLine(string.Format("- Deleted {0} files", count)); + } + catch (Exception ex) + { + if (Utils.IsThreadAbortException(ex)) + return; + + Log.WriteError("File delete error", ex); + throw; + } + } + + private void Backup() + { + try + { + string componentId = Context.ComponentId; + string componentName = Context.ComponentFullName; + string version = Context.Version; + List actions = GenerateBackupActions(componentId); + + Log.WriteStart("Creating backup directory"); + string backupDirectory = Path.Combine(Context.BaseDirectory, "Backup"); + if (!Directory.Exists(backupDirectory)) + { + Directory.CreateDirectory(backupDirectory); + } + + string destinationDirectory = Path.Combine(backupDirectory, + string.Format("{0}{1}{2} {3}", + DateTime.Now.ToString("yyyy-MM-dd"), + Path.DirectorySeparatorChar, + componentName, + version)); + + if (Directory.Exists(destinationDirectory)) + { + //clear existing dir + FileUtils.DeleteDirectory(destinationDirectory); + } + + Directory.CreateDirectory(destinationDirectory); + Log.WriteEnd("Created backup directory"); + + for (int i = 0; i < actions.Count; i++) + { + InstallAction action = actions[i]; + SetProgressText(action.Description); + SetProgressValue(i * 100 / actions.Count); + + switch (action.ActionType) + { + case ActionTypes.BackupDirectory: + BackupDirectory(action.Path, destinationDirectory); + break; + case ActionTypes.BackupDatabase: + BackupDatabase(action.ConnectionString, action.Name); + break; + case ActionTypes.BackupConfig: + BackupConfig(action.Path, destinationDirectory); + break; + } + } + //this.progressBar.Value = 100; + this.SetProgressValue(100); + } + catch (Exception ex) + { + if (Utils.IsThreadAbortException(ex)) + return; + Log.WriteError("Backup error", ex); + throw; + } + } + + private void BackupConfig(string path, string backupDirectory) + { + try + { + Log.WriteStart("Backing up system configuration"); + + string destination = Path.Combine(backupDirectory, "Config"); + if (!Directory.Exists(destination)) + { + Log.WriteStart(string.Format("Creating directory {0}", destination)); + Directory.CreateDirectory(destination); + Log.WriteEnd("Created directory"); + } + + string[] files = Directory.GetFiles(path, "*.config", SearchOption.TopDirectoryOnly); + foreach (string file in files) + { + FileUtils.CopyFileToFolder(file, destination); + } + Log.WriteEnd("Backed up system configuration"); + InstallLog.AppendLine("- Backed up system configuration"); + } + catch (Exception ex) + { + if (Utils.IsThreadAbortException(ex)) + return; + Log.WriteError("Backup error", ex); + throw; + } + } + + private void BackupDatabase(string connectionString, string database) + { + try + { + Log.WriteStart(string.Format("Backing up database \"{0}\"", database)); + string bakFile; + string position; + SqlUtils.BackupDatabase(connectionString, database, out bakFile, out position); + Log.WriteEnd("Backed up database"); + InstallLog.AppendLine(string.Format("- Backed up {0} database", database)); + RollBack.RegisterDatabaseBackupAction(connectionString, database, bakFile, position); + } + catch (Exception ex) + { + if (Utils.IsThreadAbortException(ex)) + return; + Log.WriteError("Backup error", ex); + throw; + } + } + + private void BackupDirectory(string source, string backupDirectory) + { + try + { + string componentName = Context.ComponentFullName; + string destination = Path.Combine(backupDirectory, "App"); + + if (Directory.Exists(destination)) + { + try + { + Log.WriteStart(string.Format("Deleting directory {0}", destination)); + FileUtils.DeleteDirectory(destination); + Log.WriteEnd("Deleted directory"); + } + catch (Exception ex) + { + Log.WriteError("Backup error", ex); + } + } + + if (!Directory.Exists(destination)) + { + Log.WriteStart(string.Format("Creating directory {0}", destination)); + Directory.CreateDirectory(destination); + Log.WriteEnd("Created directory"); + } + string zipFile = Path.Combine(destination, "app.zip"); + + Log.WriteStart("Backing up files"); + Log.WriteInfo(string.Format("Zipping files from \"{0}\" to \"{1}\"", source, zipFile)); + //showing process + ZipIndicator process = new ZipIndicator(GetProgressObject(), source, zipFile); + //CopyProcess process = new CopyProcess(progressBar, source, destination); + process.Start(); + Log.WriteEnd("Backed up files"); + InstallLog.AppendLine(string.Format("- Backed up {0} files", componentName)); + RollBack.RegisterDirectoryBackupAction(source, zipFile); + } + catch (Exception ex) + { + if (Utils.IsThreadAbortException(ex)) + return; + Log.WriteError("Backup error", ex); + throw; + } + } + + private List GenerateBackupActions(string componentId) + { + List list = new List(); + InstallAction action = null; + + //database + string connectionString = AppConfig.GetComponentSettingStringValue(componentId, "InstallConnectionString"); + if (!String.IsNullOrEmpty(connectionString)) + { + string database = AppConfig.GetComponentSettingStringValue(componentId, "Database"); + action = new InstallAction(ActionTypes.BackupDatabase); + action.ConnectionString = connectionString; + action.Name = database; + action.Description = string.Format("Backing up database {0}...", database); + list.Add(action); + } + + //directory + string path = AppConfig.GetComponentSettingStringValue(componentId, "InstallFolder"); + if (!string.IsNullOrEmpty(path)) + { + action = new InstallAction(ActionTypes.BackupDirectory); + action.Path = path; + action.Description = string.Format("Backing up directory {0}...", path); + list.Add(action); + } + + //config + action = new InstallAction(ActionTypes.BackupConfig); + action.Description = "Backing up configuration settings..."; + action.Path = Context.BaseDirectory; + list.Add(action); + + return list; + + } + + private void UpdateWebSiteBindings() + { + string component = Context.ComponentFullName; + string siteId = Context.WebSiteId; + string ip = Context.WebSiteIP; + string port = Context.WebSitePort; + string domain = Context.WebSiteDomain; + bool update = Context.UpdateWebSite; + Version iisVersion = Context.IISVersion; + bool iis7 = (iisVersion.Major >= 7); + + if (!update) + return; + + //updating web site + try + { + Log.WriteStart("Updating web site"); + Log.WriteInfo(string.Format("Updating web site \"{0}\" ( IP: {1}, Port: {2}, Domain: {3} )", siteId, ip, port, domain)); + + //check for existing site + var oldSiteId = iis7 ? WebUtils.GetIIS7SiteIdByBinding(ip, port, domain) : WebUtils.GetSiteIdByBinding(ip, port, domain); + // We found out that other web site has this combination of {IP:Port:Host Header} already assigned + if (oldSiteId != null && !oldSiteId.Equals(Context.WebSiteId)) + { + // get site name + string oldSiteName = iis7 ? oldSiteId : WebUtils.GetSite(oldSiteId).Name; + throw new Exception( + String.Format("'{0}' web site already has server binding ( IP: {1}, Port: {2}, Domain: {3} )", + oldSiteName, ip, port, domain)); + } + + // Assign the binding only if is not defined + if (String.IsNullOrEmpty(oldSiteId)) + { + ServerBinding newBinding = new ServerBinding(ip, port, domain); + if (iis7) + WebUtils.UpdateIIS7SiteBindings(siteId, new ServerBinding[] { newBinding }); + else + WebUtils.UpdateSiteBindings(siteId, new ServerBinding[] { newBinding }); + } + + // update config setings + string componentId = Context.ComponentId; + AppConfig.SetComponentSettingStringValue(componentId, "WebSiteIP", ip); + AppConfig.SetComponentSettingStringValue(componentId, "WebSitePort", port); + AppConfig.SetComponentSettingStringValue(componentId, "WebSiteDomain", domain); + + //update log + Log.WriteEnd("Updated web site"); + + //update install log + InstallLog.AppendLine("- Updated web site"); + InstallLog.AppendLine(" You can access the application by the following URLs:"); + string[] urls = GetApplicationUrls(ip, domain, port, null); + // + foreach (string url in urls) + { + InstallLog.AppendLine(" http://" + url); + } + } + catch (Exception ex) + { + if (Utils.IsThreadAbortException(ex)) + return; + + Log.WriteError("Update web site error", ex); + throw; + } + + //opening windows firewall ports + try + { + Utils.OpenFirewallPort(component, port, Context.IISVersion); + } + catch (Exception ex) + { + if (Utils.IsThreadAbortException(ex)) + return; + + Log.WriteError("Open windows firewall port error", ex); + } + } + + private void CreateDatabaseUser() + { + try + { + string connectionString = Context.DbInstallConnectionString; + string database = Context.Database; + string component = Context.ComponentFullName; + //user name should be the same as database + string userName = Context.Database; + string password = Utils.GetRandomString(20); + + CreateDbUser(connectionString, database, userName, password); + UpdateWebConfigConnection(userName, password); + + InstallLog.AppendLine(string.Format("- Created database user \"{0}\"", userName)); + } + catch (Exception ex) + { + if (Utils.IsThreadAbortException(ex)) + return; + + Log.WriteError("Create db user error", ex); + throw; + } + } + + private void CreateDbUser(string connectionString, string database, string userName, string password) + { + Log.WriteStart(string.Format("Creating database user {0}", userName)); + + if (SqlUtils.UserExists(connectionString, userName)) + throw new Exception(string.Format("Database user {0} already exists", userName)); + + bool userCreated = SqlUtils.CreateUser(connectionString, userName, password, database); + + // save user details + string componentId = Context.ComponentId; + AppConfig.SetComponentSettingStringValue(componentId, "DatabaseUser", userName); + AppConfig.SetComponentSettingBooleanValue(componentId, "NewDatabaseUser", userCreated); + + // roll-back support + if (userCreated) + RollBack.RegisterDatabaseUserAction(connectionString, userName); + + Log.WriteEnd("Created database user"); + } + + private void UpdateWebConfigConnection(string userName, string password) + { + Log.WriteStart("Updating web.config file (connection string)"); + + string file = Path.Combine(Context.InstallationFolder, "web.config"); + + string content = string.Empty; + // load file + using (StreamReader reader = new StreamReader(file)) + { + content = reader.ReadToEnd(); + } + + string connectionString = string.Format("server={0};database={1};uid={2};pwd={3};", + Context.DatabaseServer, Context.Database, userName, password); + + // expand variables + content = Utils.ReplaceScriptVariable(content, "installer.connectionstring", connectionString); + + // save file + using (StreamWriter writer = new StreamWriter(file)) + { + writer.Write(content); + } + Log.WriteEnd("Updated web.config file"); + + //update settings + string componentId = Context.ComponentId; + AppConfig.SetComponentSettingStringValue(componentId, "ConnectionString", connectionString); + } + + private void ExecuteSqlScript(string file) + { + try + { + string component = Context.ComponentFullName; + string componentId = Context.ComponentId; + + string path = Path.Combine(Context.InstallationFolder, file); + if (Context.SetupAction == SetupActions.Update) + { + path = Path.Combine(Context.InstallerFolder, file); + Context.DbInstallConnectionString = AppConfig.GetComponentSettingStringValue(componentId, "InstallConnectionString"); + Context.Database = AppConfig.GetComponentSettingStringValue(componentId, "Database"); + } + + if (!FileUtils.FileExists(path)) + { + Log.WriteInfo(string.Format("File {0} not found", path)); + return; + } + + string connectionString = Context.DbInstallConnectionString; + string database = Context.Database; + + //if (Context.SetupAction == SetupActions.Install) + //{ + // UpdateSqlScript(path); + //} + RunSqlScript(connectionString, database, path); + + InstallLog.AppendLine(string.Format("- Installed {0} database objects", component)); + } + catch (Exception ex) + { + if (Utils.IsThreadAbortException(ex)) + return; + + Log.WriteError("Run sql error", ex); + throw; + } + } + + private void CreateDatabase() + { + try + { + string connectionString = Context.DbInstallConnectionString; + string database = Context.Database; + + Log.WriteStart("Creating SQL Server database"); + Log.WriteInfo(string.Format("Creating SQL Server database \"{0}\"", database)); + if (SqlUtils.DatabaseExists(connectionString, database)) + { + throw new Exception(string.Format("SQL Server database \"{0}\" already exists", database)); + } + SqlUtils.CreateDatabase(connectionString, database); + Log.WriteEnd("Created SQL Server database"); + + // rollback + RollBack.RegisterDatabaseAction(connectionString, database); + + string componentId = Context.ComponentId; + AppConfig.SetComponentSettingStringValue(componentId, "Database", database); + AppConfig.SetComponentSettingBooleanValue(componentId, "NewDatabase", true); + + InstallLog.AppendLine(string.Format("- Created a new SQL Server database \"{0}\"", database)); + } + catch (Exception ex) + { + if (Utils.IsThreadAbortException(ex)) + return; + Log.WriteError("Create database error", ex); + throw; + } + } + + private void SetServerPassword() + { + try + { + Log.WriteStart("Updating configuration file (server password)"); + + string file = Path.Combine(Context.InstallationFolder, Context.ConfigurationFile); + string hash = Context.ServerPassword; + + // load file + string content = string.Empty; + using (StreamReader reader = new StreamReader(file)) + { + content = reader.ReadToEnd(); + } + + // expand variables + content = Utils.ReplaceScriptVariable(content, "installer.server.password", hash); + + // save file + using (StreamWriter writer = new StreamWriter(file)) + { + writer.Write(content); + } + //update log + Log.WriteEnd("Updated configuration file"); + + //string component = Context.ComponentFullName; + //InstallLog.AppendLine(string.Format("- Updated {0} web.config file", component)); + + } + catch (Exception ex) + { + if (Utils.IsThreadAbortException(ex)) + return; + Log.WriteError("Configuration file update error", ex); + throw; + } + } + + private void UpdateServerPassword() + { + try + { + if (!Context.UpdateServerPassword) + return; + + string path = Path.Combine(Context.InstallationFolder, Context.ConfigurationFile); + string hash = Context.ServerPassword; + + if (!File.Exists(path)) + { + Log.WriteInfo(string.Format("File {0} not found", path)); + return; + } + + Log.WriteStart("Updating configuration file (server password)"); + XmlDocument doc = new XmlDocument(); + doc.Load(path); + + XmlElement passwordNode = doc.SelectSingleNode("//websitepanel.server/security/password") as XmlElement; + if (passwordNode == null) + { + Log.WriteInfo("server password setting not found"); + return; + } + + passwordNode.SetAttribute("value", hash); + doc.Save(path); + Log.WriteEnd("Updated configuration file"); + InstallLog.AppendLine("- Updated password in the configuration file"); + + //string component = Context.ComponentFullName; + //InstallLog.AppendLine(string.Format("- Updated {0} web.config file", component)); + + } + catch (Exception ex) + { + if (Utils.IsThreadAbortException(ex)) + return; + Log.WriteError("Configuration file update error", ex); + throw; + } + } + + private void SetServiceSettings() + { + try + { + string path = Path.Combine(Context.InstallationFolder, Context.ConfigurationFile); + string ip = Context.ServiceIP; + string port = Context.ServicePort; + + if (!File.Exists(path)) + { + Log.WriteInfo(string.Format("File {0} not found", path)); + return; + } + + Log.WriteStart("Updating configuration file (service settings)"); + XmlDocument doc = new XmlDocument(); + doc.Load(path); + + XmlElement ipNode = doc.SelectSingleNode("//configuration/appSettings/add[@key='WebsitePanel.HostIP']") as XmlElement; + if (ipNode == null) + { + Log.WriteInfo("Service host IP setting not found"); + return; + } + ipNode.SetAttribute("value", ip); + XmlElement portNode = doc.SelectSingleNode("//configuration/appSettings/add[@key='WebsitePanel.HostPort']") as XmlElement; + if (portNode == null) + { + Log.WriteInfo("Service host port setting not found"); + return; + } + portNode.SetAttribute("value", port); + doc.Save(path); + Log.WriteEnd("Updated configuration file"); + InstallLog.AppendLine("- Updated service settings in the configuration file"); + } + catch (Exception ex) + { + if (Utils.IsThreadAbortException(ex)) + return; + Log.WriteError("Configuration file update error", ex); + throw; + } + } + + private void SetCryptoKey() + { + try + { + Log.WriteStart("Updating web.config file (crypto key)"); + + string file = Path.Combine(Context.InstallationFolder, "web.config"); + string cryptoKey = Utils.GetRandomString(20); + + // load file + string content = string.Empty; + using (StreamReader reader = new StreamReader(file)) + { + content = reader.ReadToEnd(); + } + + // expand variables + content = Utils.ReplaceScriptVariable(content, "installer.cryptokey", cryptoKey); + + // save file + using (StreamWriter writer = new StreamWriter(file)) + { + writer.Write(content); + } + //update log + Log.WriteEnd("Updated web.config file"); + + string componentId = Context.ComponentId; + Context.CryptoKey = cryptoKey; + AppConfig.SetComponentSettingStringValue(componentId, "CryptoKey", cryptoKey); + } + catch (Exception ex) + { + if (Utils.IsThreadAbortException(ex)) + return; + Log.WriteError("Update web.config error", ex); + throw; + } + } + + private void CopyFiles(string source, string destination) + { + try + { + string component = Context.ComponentFullName; + Log.WriteStart("Copying files"); + Log.WriteInfo(string.Format("Copying files from \"{0}\" to \"{1}\"", source, destination)); + //showing copy process + CopyProcess process = new CopyProcess(GetProgressObject(), source, destination); + process.Run(); + Log.WriteEnd("Copied files"); + InstallLog.AppendLine(string.Format("- Copied {0} files", component)); + // rollback + RollBack.RegisterDirectoryAction(destination); + } + catch (Exception ex) + { + if (Utils.IsThreadAbortException(ex)) + return; + Log.WriteError("Copy error", ex); + throw; + } + } + + private void CreateWebSite() + { + string component = Context.ComponentFullName; + string ip = Context.WebSiteIP; + string port = Context.WebSitePort; + string domain = Context.WebSiteDomain; + string contentPath = Context.InstallationFolder; + + //creating user account + string userName = Context.UserAccount; + string password = Context.UserPassword; + string userDomain = Context.UserDomain; + string userDescription = component + " account for anonymous access to Internet Information Services"; + string[] memberOf = Context.UserMembership; + string identity = userName; + string netbiosDomain = userDomain; + Version iisVersion = Context.IISVersion; + bool iis7 = (iisVersion.Major >= 7); + + try + { + CreateUserAccount(userDomain, userName, password, userDescription, memberOf); + if (!string.IsNullOrEmpty(userDomain)) + { + netbiosDomain = SecurityUtils.GetNETBIOSDomainName(userDomain); + if (iis7) + { + //for iis7 we use fqdn\user + identity = string.Format("{0}\\{1}", userDomain, userName); + } + else + { + //for iis6 we use netbiosdomain\user + identity = string.Format("{0}\\{1}", netbiosDomain, userName); + } + } + WebUtils.SetWebFolderPermissions(contentPath, netbiosDomain, userName); + } + catch (Exception ex) + { + if (Utils.IsThreadAbortException(ex)) + return; + + Log.WriteError("Create user account error", ex); + throw; + } + //progressBar.Value = 30; + this.SetProgressValue(30); + + //creating app pool + string appPool = component + " Pool"; + try + { + CreateAppPool(appPool, identity, password); + } + catch (Exception ex) + { + if (Utils.IsThreadAbortException(ex)) + return; + + Log.WriteError(string.Format("Create application pool \"{0}\" error", appPool), ex); + throw; + } + //progressBar.Value = 60; + this.SetProgressValue(60); + + //creating web site + string siteName = component; + try + { + CreateSite(siteName, ip, port, domain, contentPath, identity, password, appPool); + } + catch (Exception ex) + { + if (Utils.IsThreadAbortException(ex)) + return; + + Log.WriteError("Create web site error", ex); + throw; + } + + //progressBar.Value = 90; + this.SetProgressValue(90); + + //opening windows firewall ports + try + { + Utils.OpenFirewallPort(component, port, Context.IISVersion); + } + catch (Exception ex) + { + if (Utils.IsThreadAbortException(ex)) + return; + + Log.WriteError("Open windows firewall port error", ex); + } + + } + + private void ConfigureFolderPermissions() + { + try + { + string path; + if (Context.IISVersion.Major == 6) + { + // IIS_WPG -> C:\WINDOWS\Temp + path = Environment.GetEnvironmentVariable("TMP", EnvironmentVariableTarget.Machine); + SetFolderPermission(path, "IIS_WPG", NtfsPermission.Modify); + + // IIS_WPG - > C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files + path = Path.Combine(System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory(), + "Temporary ASP.NET Files"); + if (Utils.IsWin64() && Utils.IIS32Enabled()) + path = path.Replace("Framework64", "Framework"); + SetFolderPermission(path, "IIS_WPG", NtfsPermission.Modify); + } + // NETWORK_SERVICE -> C:\WINDOWS\Temp + path = Environment.GetEnvironmentVariable("TMP", EnvironmentVariableTarget.Machine); + SetFolderPermissionBySid(path, SystemSID.NETWORK_SERVICE, NtfsPermission.Modify); + + } + catch (Exception ex) + { + if (Utils.IsThreadAbortException(ex)) + return; + + Log.WriteError("Security error", ex); + } + } + + private void SetFolderPermission(string path, string account, NtfsPermission permission) + { + try + { + if (!FileUtils.DirectoryExists(path)) + { + FileUtils.CreateDirectory(path); + Log.WriteInfo(string.Format("Created {0} folder", path)); + } + + Log.WriteStart(string.Format("Setting '{0}' permission for '{1}' folder for '{2}' account", permission, path, account)); + SecurityUtils.GrantNtfsPermissions(path, null, account, permission, true, true); + Log.WriteEnd("Set security permissions"); + } + catch (Exception ex) + { + if (Utils.IsThreadAbortException(ex)) + return; + + Log.WriteError("Security error", ex); + } + } + + private void SetFolderPermissionBySid(string path, string account, NtfsPermission permission) + { + try + { + if (!FileUtils.DirectoryExists(path)) + { + FileUtils.CreateDirectory(path); + Log.WriteInfo(string.Format("Created {0} folder", path)); + } + + Log.WriteStart(string.Format("Setting '{0}' permission for '{1}' folder for '{2}' account", permission, path, account)); + SecurityUtils.GrantNtfsPermissionsBySid(path, account, permission, true, true); + Log.WriteEnd("Set security permissions"); + } + catch (Exception ex) + { + if (Utils.IsThreadAbortException(ex)) + return; + + Log.WriteError("Security error", ex); + } + } + + private void CreateSite(string siteName, string ip, string port, string domain, string contentPath, string userName, string userPassword, string appPool) + { + SetProgressText("Creating web site..."); + + Log.WriteStart("Creating web site"); + Log.WriteInfo(string.Format("Creating web site \"{0}\" ( IP: {1}, Port: {2}, Domain: {3} )", siteName, ip, port, domain)); + Version iisVersion = Context.IISVersion; + bool iis7 = (iisVersion.Major >= 7); + + //check for existing site + string oldSiteId = iis7 ? WebUtils.GetIIS7SiteIdByBinding(ip, port, domain) : WebUtils.GetSiteIdByBinding(ip, port, domain); + if (oldSiteId != null) + { + // get site name + string oldSiteName = iis7 ? oldSiteId : WebUtils.GetSite(oldSiteId).Name; + throw new Exception( + String.Format("'{0}' web site already has server binding ( IP: {1}, Port: {2}, Domain: {3} )", + oldSiteName, ip, port, domain)); + } + + // create site + WebSiteItem site = new WebSiteItem(); + site.Name = siteName; + site.SiteIPAddress = ip; + + site.ContentPath = contentPath; + //site.LogFileDirectory = logsPath; + + //set bindings + ServerBinding binding = new ServerBinding(ip, port, domain); + site.Bindings = new ServerBinding[] { binding }; + + // set other properties + site.AllowExecuteAccess = false; + site.AllowScriptAccess = true; + site.AllowSourceAccess = false; + site.AllowReadAccess = true; + site.AllowWriteAccess = false; + site.AnonymousUsername = userName; + site.AnonymousUserPassword = userPassword; + site.AllowDirectoryBrowsingAccess = false; + + site.AuthAnonymous = true; + site.AuthWindows = true; + + site.DefaultDocs = null; // inherit from service + site.HttpRedirect = ""; + + site.InstalledDotNetFramework = AspNetVersion.AspNet20; + site.ApplicationPool = appPool; + + // create site + string newSiteId = iis7 ? WebUtils.CreateIIS7Site(site) : WebUtils.CreateSite(site); + + //add rollback action + if (iis7) + RollBack.RegisterIIS7WebSiteAction(newSiteId); + else + RollBack.RegisterWebSiteAction(newSiteId); + + + // update config setings + string componentId = Context.ComponentId; + AppConfig.SetComponentSettingStringValue(componentId, "WebSiteId", newSiteId); + AppConfig.SetComponentSettingStringValue(componentId, "WebSiteIP", ip); + AppConfig.SetComponentSettingStringValue(componentId, "WebSitePort", port); + AppConfig.SetComponentSettingStringValue(componentId, "WebSiteDomain", domain); + AppConfig.SetComponentSettingStringValue(componentId, "VirtualDirectory", string.Empty); + AppConfig.SetComponentSettingBooleanValue(componentId, "NewWebSite", true); + AppConfig.SetComponentSettingBooleanValue(componentId, "NewVirtualDirectory", false); + + // update setup variables + Context.WebSiteId = newSiteId; + + //update log + Log.WriteEnd("Created web site"); + + //update install log + InstallLog.AppendLine(string.Format("- Created a new web site named \"{0}\" ({1})", siteName, newSiteId)); + InstallLog.AppendLine(" You can access the application by the following URLs:"); + string[] urls = GetApplicationUrls(ip, domain, port, null); + foreach (string url in urls) + { + InstallLog.AppendLine(" http://" + url); + } + } + + private void CreateAccount(string description) + { + string component = Context.ComponentFullName; + + //creating user account + string userName = Context.UserAccount; + string password = Context.UserPassword; + string userDomain = Context.UserDomain; + string userDescription = description; + string[] memberOf = Context.UserMembership; + + try + { + CreateUserAccount(userDomain, userName, password, userDescription, memberOf); + } + catch (Exception ex) + { + if (Utils.IsThreadAbortException(ex)) + return; + + Log.WriteError("Create user account error", ex); + throw; + } + } + + private void CreateUserAccount(string domain, string userName, string password, string description, string[] memberOf) + { + SetProgressText("Creating windows user account..."); + this.Update(); + string componentId = Context.ComponentId; + + if (!SecurityUtils.UserExists(domain, userName)) + { + Log.WriteStart("Creating Windows user account"); + Log.WriteInfo(string.Format("Creating Windows user account \"{0}\"", userName)); + + // create account + SystemUserItem user = new SystemUserItem(); + user.Domain = domain; + user.Name = userName; + user.FullName = userName; + user.Description = description; + user.MemberOf = memberOf; + user.Password = password; + user.PasswordCantChange = true; + user.PasswordNeverExpires = true; + user.AccountDisabled = false; + user.System = true; + SecurityUtils.CreateUser(user); + + //add rollback action + RollBack.RegisterUserAccountAction(domain, userName); + + // update config setings + AppConfig.SetComponentSettingBooleanValue(componentId, "NewUserAccount", true); + AppConfig.SetComponentSettingStringValue(componentId, "UserAccount", userName); + AppConfig.SetComponentSettingStringValue(componentId, "Domain", domain); + + //update log + Log.WriteEnd("Created windows user account"); + + //update install log + if (string.IsNullOrEmpty(domain)) + InstallLog.AppendLine(string.Format("- Created a new windows user account \"{0}\"", userName)); + else + InstallLog.AppendLine(string.Format("- Created a new windows user account \"{0}\" in \"{1}\" domain", userName, domain)); + } + else + { + throw new Exception("Account already exists"); + } + } + + protected void Update() // Do nothing. + { + //throw new NotImplementedException(); + } + + private void CreateAppPool(string name, string userName, string userPassword) + { + SetProgressText("Creating local account..."); + string componentId = Context.ComponentId; + Version iisVersion = Context.IISVersion; + bool poolExists = (iisVersion.Major >= 7) ? + WebUtils.IIS7ApplicationPoolExists(name) : + WebUtils.ApplicationPoolExists(name); + + if (poolExists) + { + //update app pool + Log.WriteStart("Updating application pool"); + Log.WriteInfo(string.Format("Updating application pool \"{0}\"", name)); + if (iisVersion.Major >= 7) + WebUtils.UpdateIIS7ApplicationPool(name, userName, userPassword); + else + WebUtils.UpdateApplicationPool(name, userName, userPassword); + + // update config setings + AppConfig.SetComponentSettingBooleanValue(componentId, "NewApplicationPool", false); + AppConfig.SetComponentSettingStringValue(componentId, "ApplicationPool", name); + + //update log + Log.WriteEnd("Updated application pool"); + + //update install log + InstallLog.AppendLine(string.Format("- Updated application pool named \"{0}\"", name)); + } + else + { + // create app pool + Log.WriteStart("Creating application pool"); + Log.WriteInfo(string.Format("Creating application pool \"{0}\"", name)); + if (iisVersion.Major >= 7) + WebUtils.CreateIIS7ApplicationPool(name, userName, userPassword); + else + WebUtils.CreateApplicationPool(name, userName, userPassword); + + //register rollback action + if (iisVersion.Major >= 7) + RollBack.RegisterIIS7ApplicationPool(name); + else + RollBack.RegisterApplicationPool(name); + + + // update config setings + AppConfig.SetComponentSettingBooleanValue(componentId, "NewApplicationPool", true); + AppConfig.SetComponentSettingStringValue(componentId, "ApplicationPool", name); + + //update log + Log.WriteEnd("Created application pool"); + + //update install log + InstallLog.AppendLine(string.Format("- Created a new application pool named \"{0}\"", name)); + } + } + + /// + /// Returns the list of all possible application URLs + /// + /// + /// + /// + /// + /// + protected string[] GetApplicationUrls(string ip, string domain, string port, string virtualDir) + { + List urls = new List(); + + // IP address, [port] and [virtualDir] + string url = ip; + if (String.IsNullOrEmpty(domain)) + { + if (!String.IsNullOrEmpty(port) && port != "80") + url += ":" + port; + if (!String.IsNullOrEmpty(virtualDir)) + url += "/" + virtualDir; + urls.Add(url); + } + + // domain, [port] and [virtualDir] + if (!String.IsNullOrEmpty(domain)) + { + url = domain; + if (!String.IsNullOrEmpty(port) && port != "80") + url += ":" + port; + if (!String.IsNullOrEmpty(virtualDir)) + url += "/" + virtualDir; + urls.Add(url); + } + + // add "localhost" by default + /* + url = "localhost"; + if(port != "" && port != "80" && port != null) + url += ":" + port; + if(virtualDir != "" && virtualDir != null) + url += "/" + virtualDir; + urls.Add(url); + * */ + + return urls.ToArray(); + } + + private void UpdateSystemConfiguration() + { + try + { + Log.WriteStart("Updating system configuration"); + string componentId = Context.ComponentId; + if (Context.SetupAction == SetupActions.Update) + { + //update settings + AppConfig.SetComponentSettingStringValue(componentId, "Release", Context.UpdateVersion); + AppConfig.SetComponentSettingStringValue(componentId, "Installer", Context.Installer); + AppConfig.SetComponentSettingStringValue(componentId, "InstallerType", Context.InstallerType); + AppConfig.SetComponentSettingStringValue(componentId, "InstallerPath", Context.InstallerPath); + } + + Log.WriteInfo("Saving system configuration"); + //save + AppConfig.SaveConfiguration(); + Log.WriteEnd("Updated system configuration"); + InstallLog.AppendLine("- Updated system configuration"); + + if (Context.SetupAction == SetupActions.Install) + { + RollBack.RegisterConfigAction(Context.ComponentId, Context.ComponentName); + } + } + catch (Exception ex) + { + if (Utils.IsThreadAbortException(ex)) + return; + + Log.WriteError("Config error", ex); + throw; + } + } + private void UpdateSqlScript(string file) + { + // get ES crypto key from the registry + string cryptoKey = Context.CryptoKey; + if (String.IsNullOrEmpty(cryptoKey)) + return; + + Log.WriteStart("Updating SQL script file"); + Log.WriteInfo(string.Format("Updating SQL script file \"{0}\"", file)); + + //update 'Users' table + string text = GetServerAdminPasswordScript(cryptoKey); + + using (StreamWriter sw = File.AppendText(file)) + { + sw.Write(text); + } + Log.WriteEnd("Updated SQL script file"); + } + + private string GetServerAdminPasswordScript(string cryptoKey) + { + // encrypt default password + string password = Utils.Encrypt(cryptoKey, "serveradmin"); + + // build script + StringBuilder sb = new StringBuilder(); + + sb.Append("\n\nIF EXISTS (SELECT * FROM sysobjects WHERE id = OBJECT_ID(N'[dbo].[ResourceGroupDnsRecords]') AND type in (N'U'))\n"); + sb.Append("BEGIN\n\n"); + + sb.Append("\nUPDATE Users SET Password = '"); + sb.Append(password).Append("' WHERE Username = 'serveradmin'\n"); + + sb.Append("END\nGO\n\n"); + + return sb.ToString(); + } + + /// + /// Runs sql script. + /// + /// Sql server connection string. + /// Sql server database name. + /// Sql script file + private void RunSqlScript(string connectionString, string database, string fileName) + { + if (!File.Exists(fileName)) + { + Log.WriteInfo(string.Format("File {0} not found", fileName)); + return; + } + + Log.WriteStart("Installing database objects"); + + //showing process + SqlProcess process = new SqlProcess(fileName, connectionString, database); + // Update progress change + process.ProgressChange += new EventHandler>((object sender, ActionProgressEventArgs e) => + { + //this.progressBar.Value = e.EventData; + this.SetProgressValue(e.EventData); + }); + // + process.Run(); + + Log.WriteEnd("Installed database objects"); + } + /// + /// Add custom error page to the web.config (Microsoft Security Advisory (2416728)) + /// + private void AddCustomErrorsPage() + { + try + { + string webConfigPath = Path.Combine(Context.InstallationFolder, "web.config"); + Log.WriteStart("Web.config file is being updated"); + // Ensure the web.config exists + if (!File.Exists(webConfigPath)) + { + Log.WriteInfo(string.Format("File {0} not found", webConfigPath)); + return; + } + // Load web.config + XmlDocument doc = new XmlDocument(); + doc.Load(webConfigPath); + + // replace existing node: + // + // + // + // with: + // + // + // + // + XmlElement customErrors = doc.SelectSingleNode("configuration/system.web/customErrors[@mode='Off']") as XmlElement; + // ensure node is found + if (customErrors != null) + { + XmlUtils.SetXmlAttribute(customErrors, "mode", "RemoteOnly"); + XmlUtils.SetXmlAttribute(customErrors, "defaultRedirect", "~/error.htm"); + } + // save changes have been made + doc.Save(webConfigPath); + // + Log.WriteEnd("Web.config has been updated"); + } + catch (Exception ex) + { + if (Utils.IsThreadAbortException(ex)) + return; + Log.WriteError("Could not update web.config file", ex); + throw; + } + } + #endregion + #endregion + } + + public class UninstallScript : SetupScript // UninstallPage + { + public UninstallScript(SetupVariables SessionVariables):base(SessionVariables) + { + + } + protected override List GetActions(string componentId) + { + var list = base.GetActions(componentId); + InstallAction action = null; + + //windows service + string serviceName = AppConfig.GetComponentSettingStringValue(componentId, "ServiceName"); + string serviceFile = AppConfig.GetComponentSettingStringValue(componentId, "ServiceFile"); + string installFolder = AppConfig.GetComponentSettingStringValue(componentId, "InstallFolder"); + if (!string.IsNullOrEmpty(serviceName) && !string.IsNullOrEmpty(serviceFile)) + { + action = new InstallAction(ActionTypes.UnregisterWindowsService); + action.Path = Path.Combine(installFolder, serviceFile); + action.Name = serviceName; + action.Description = "Removing Windows service..."; + action.Log = string.Format("- Remove {0} Windows service", serviceName); + list.Add(action); + } + + //database + bool deleteDatabase = AppConfig.GetComponentSettingBooleanValue(componentId, "NewDatabase"); + if (deleteDatabase) + { + string connectionString = AppConfig.GetComponentSettingStringValue(componentId, "InstallConnectionString"); + string database = AppConfig.GetComponentSettingStringValue(componentId, "Database"); + action = new InstallAction(ActionTypes.DeleteDatabase); + action.ConnectionString = connectionString; + action.Name = database; + action.Description = "Deleting database..."; + action.Log = string.Format("- Delete {0} database", database); + list.Add(action); + } + //database user + bool deleteDatabaseUser = AppConfig.GetComponentSettingBooleanValue(componentId, "NewDatabaseUser"); + if (deleteDatabaseUser) + { + string connectionString = AppConfig.GetComponentSettingStringValue(componentId, "InstallConnectionString"); + string username = AppConfig.GetComponentSettingStringValue(componentId, "DatabaseUser"); + action = new InstallAction(ActionTypes.DeleteDatabaseUser); + action.ConnectionString = connectionString; + action.UserName = username; + action.Description = "Deleting database user..."; + action.Log = string.Format("- Delete {0} database user", username); + list.Add(action); + } + //database login (from standalone setup) + string loginName = AppConfig.GetComponentSettingStringValue(componentId, "DatabaseLogin"); + if (!string.IsNullOrEmpty(loginName)) + { + string connectionString = AppConfig.GetComponentSettingStringValue(componentId, "InstallConnectionString"); + action = new InstallAction(ActionTypes.DeleteDatabaseLogin); + action.ConnectionString = connectionString; + action.UserName = loginName; + action.Description = "Deleting database login..."; + action.Log = string.Format("- Delete {0} database login", loginName); + list.Add(action); + } + + //virtual directory + bool deleteVirtualDirectory = AppConfig.GetComponentSettingBooleanValue(componentId, "NewVirtualDirectory"); + if (deleteVirtualDirectory) + { + string virtualDirectory = AppConfig.GetComponentSettingStringValue(componentId, "VirtualDirectory"); + string virtualDirectorySiteId = AppConfig.GetComponentSettingStringValue(componentId, "WebSiteId"); + action = new InstallAction(ActionTypes.DeleteVirtualDirectory); + action.SiteId = virtualDirectorySiteId; + action.Name = virtualDirectory; + action.Description = "Deleting virtual directory..."; + action.Log = string.Format("- Delete {0} virtual directory...", virtualDirectory); + list.Add(action); + } + + //web site + bool deleteWebSite = AppConfig.GetComponentSettingBooleanValue(componentId, "NewWebSite"); + if (deleteWebSite) + { + string siteId = AppConfig.GetComponentSettingStringValue(componentId, "WebSiteId"); + action = new InstallAction(ActionTypes.DeleteWebSite); + action.SiteId = siteId; + action.Description = "Deleting web site..."; + action.Log = string.Format("- Delete {0} web site", siteId); + list.Add(action); + } + + //application pool + bool deleteAppPool = AppConfig.GetComponentSettingBooleanValue(componentId, "NewApplicationPool"); + if (deleteAppPool) + { + string appPoolName = AppConfig.GetComponentSettingStringValue(componentId, "ApplicationPool"); + if (string.IsNullOrEmpty(appPoolName)) + appPoolName = WebUtils.WEBSITEPANEL_ADMIN_POOL; + action = new InstallAction(ActionTypes.DeleteApplicationPool); + action.Name = appPoolName; + action.Description = "Deleting application pool..."; + action.Log = string.Format("- Delete {0} application pool", appPoolName); + list.Add(action); + } + + //user account + bool deleteUserAccount = AppConfig.GetComponentSettingBooleanValue(componentId, "NewUserAccount"); + if (deleteUserAccount) + { + string username = AppConfig.GetComponentSettingStringValue(componentId, "UserAccount"); + string domain = AppConfig.GetComponentSettingStringValue(componentId, "Domain"); + //membership + if (Context.UserMembership != null && Context.UserMembership.Length > 0) + { + action = new InstallAction(ActionTypes.DeleteUserMembership); + action.Name = username; + action.Domain = domain; + action.Membership = Context.UserMembership; + action.Description = "Removing user account membership..."; + action.Log = string.Format("- Remove {0} user account membership", username); + list.Add(action); + } + + action = new InstallAction(ActionTypes.DeleteUserAccount); + action.Name = username; + action.Domain = domain; + action.Description = "Deleting user account..."; + action.Log = string.Format("- Delete {0} user account", username); + list.Add(action); + } + + // TODO: WiX does not need it by default. + //directory + //string path = AppConfig.GetComponentSettingStringValue(componentId, "InstallFolder"); + //if (!string.IsNullOrEmpty(path)) + //{ + // action = new InstallAction(ActionTypes.DeleteDirectory); + // action.Path = path; + // action.Description = "Deleting application folder..."; + // action.Log = string.Format("- Delete {0} folder", path); + // list.Add(action); + //} + + //config + action = new InstallAction(ActionTypes.UpdateConfig); + action.Key = componentId; + action.Description = "Updating configuration settings..."; + action.Log = "- Update configuration settings"; + list.Add(action); + return list; + } + protected override void ProcessError(Exception ex) + { + Log.WriteError("Uninstall error", ex); + } + } + public class ExpressScript : SetupScript // ExpressInstallPage + { + public ExpressScript(SetupVariables SessionVariables) + : base(SessionVariables) + { + + } + protected override void ProcessError(Exception ex) + { + var Msg = "An unexpected error has occurred. We apologize for this inconvenience.\n" + + "Please contact Technical Support at info@websitepanel.net.\n\n" + + "Make sure you include a copy of the Installer.log file from the\n" + + "WebsitePanel Installer home directory."; + Log.WriteError(Msg, ex); + } + } + public class BackupScript : ExpressScript + { + public BackupScript(SetupVariables SessionVariables) + : base(SessionVariables) + { + Context.SetupAction = SetupActions.Update; + } + protected override List GetActions(string ComponentID) + { + var Scenario = base.GetActions(ComponentID); + var Act = new InstallAction(ActionTypes.StopApplicationPool); + Act.Description = "Stopping IIS Application Pool..."; + Scenario.Add(Act); + Act = new InstallAction(ActionTypes.Backup); + Act.Description = "Backing up..."; + Scenario.Add(Act); + return Scenario; + } + } + public class RestoreScript : ExpressScript + { + public RestoreScript(SetupVariables SessionVariables) + : base(SessionVariables) + { + Context.SetupAction = SetupActions.Update; + } + protected override List GetActions(string ComponentID) + { + var Scenario = base.GetActions(ComponentID); + var Act = new InstallAction(ActionTypes.UpdateConfig); + Act.Description = "Updating system configuration..."; + Scenario.Add(Act); + Act = new InstallAction(ActionTypes.StartApplicationPool); + Act.Description = "Starting IIS Application Pool..."; + Scenario.Add(Act); + return Scenario; + } + } + public class ServerSetup : WiXSetup + { + public ServerSetup(SetupVariables Ctx, ModeExtension Ext) + : base(Ctx, Ext) + { + + } + public static IWiXSetup Create(IDictionary Ctx, SetupActions Action) + { + var SetupVars = new SetupVariables(); + FillFromSession(Ctx, SetupVars); + SetupVars.SetupAction = Action; + SetupVars.IISVersion = Global.IISVersion; + AppConfig.LoadConfiguration(new ExeConfigurationFileMap { ExeConfigFilename = GetFullConfigPath(SetupVars) }); + return new ServerSetup(SetupVars, GetModeExtension(Ctx)); + } + protected override void Install() + { + bool WiXThrow = default(bool); + if (ModeExtension == ModeExtension.Normal) + { + Context.ComponentId = Guid.NewGuid().ToString(); + Context.Instance = String.Empty; + var sam = new WiXServerActionManager(Context); + sam.PrepareDistributiveDefaults(); + try + { + sam.ActionError += new EventHandler((object sender, ActionErrorEventArgs e) => + { + Log.WriteError(e.ErrorMessage); + WiXThrow = true; + }); + sam.Start(); + } + catch (Exception ex) + { + Log.WriteError("Failed to install the component", ex); + } + if (WiXThrow) + InstallFailed(); + } + else if (ModeExtension == ModeExtension.Restore) + { + Context.ComponentId = GetComponentID(Context); + AppConfig.LoadComponentSettings(Context); + new RestoreScript(Context).Run(); + } + else + throw new NotImplementedException("Install " + ModeExtension.ToString()); + } + protected override void Uninstall() + { + Context.ComponentId = GetComponentID(Context); + AppConfig.LoadComponentSettings(Context); + SetupScript Script = null; + switch (ModeExtension) + { + case ModeExtension.Normal: + Script = new UninstallScript(Context); + break; + case ModeExtension.Backup: + Script = new BackupScript(Context); + break; + default: + throw new NotImplementedException("Uninstall " + ModeExtension.ToString()); + } + Script.Run(); + } + } + + public class EServerSetup : WiXSetup + { + public EServerSetup(SetupVariables Ctx) + : base(Ctx) + { + + } + public static IWiXSetup Create(IDictionary Ctx, SetupActions Action) + { + var SetupVars = new SetupVariables(); + FillFromSession(Ctx, SetupVars); + SetupVars.SetupAction = Action; + SetupVars.IISVersion = Global.IISVersion; + AppConfig.LoadConfiguration(new ExeConfigurationFileMap { ExeConfigFilename = GetFullConfigPath(SetupVars) }); + return new EServerSetup(SetupVars); + } + protected override void Install() + { + if (ModeExtension == ModeExtension.Normal) + { + bool WiXThrow = default(bool); + Context.ComponentId = Guid.NewGuid().ToString(); + Context.Instance = String.Empty; + var sam = new WiXEnterpriseServerActionManager(Context); + sam.PrepareDistributiveDefaults(); + try + { + sam.ActionError += new EventHandler((object sender, ActionErrorEventArgs e) => + { + Log.WriteError(e.ErrorMessage); + WiXThrow = true; + }); + sam.Start(); + } + catch (Exception ex) + { + Log.WriteError("Failed to install the component", ex); + } + if (WiXThrow) + InstallFailed(); + } + else if (ModeExtension == ModeExtension.Restore) + { + Context.ComponentId = GetComponentID(Context); + AppConfig.LoadComponentSettings(Context); + new RestoreScript(Context).Run(); + } + else + throw new NotImplementedException("Install " + ModeExtension.ToString()); + } + protected override void Uninstall() + { + Context.ComponentId = GetComponentID(Context); + AppConfig.LoadComponentSettings(Context); + SetupScript Script = null; + switch (ModeExtension) + { + case ModeExtension.Normal: + Script = new UninstallScript(Context); + break; + case ModeExtension.Backup: + Script = new BackupScript(Context); + break; + default: + throw new NotImplementedException("Uninstall " + ModeExtension.ToString()); + } + Script.Run(); + } + } + + public class PortalSetup : WiXSetup + { + public PortalSetup(SetupVariables Ctx) + : base(Ctx) + { + + } + public static IWiXSetup Create(IDictionary Ctx, SetupActions Action) + { + var SetupVars = new SetupVariables(); + FillFromSession(Ctx, SetupVars); + SetupVars.SetupAction = Action; + SetupVars.IISVersion = Global.IISVersion; + AppConfig.LoadConfiguration(new ExeConfigurationFileMap { ExeConfigFilename = GetFullConfigPath(SetupVars) }); + return new PortalSetup(SetupVars); + } + protected override void Install() + { + if (ModeExtension == ModeExtension.Normal) + { + bool WiXThrow = default(bool); + Context.ComponentId = Guid.NewGuid().ToString(); + Context.Instance = String.Empty; + var sam = new WiXPortalActionManager(Context); + sam.PrepareDistributiveDefaults(); + try + { + sam.ActionError += new EventHandler((object sender, ActionErrorEventArgs e) => + { + Log.WriteError(e.ErrorMessage); + WiXThrow = true; + }); + sam.Start(); + } + catch (Exception ex) + { + Log.WriteError("Failed to install the component", ex); + } + if (WiXThrow) + InstallFailed(); + + else if (ModeExtension == ModeExtension.Restore) + { + Context.ComponentId = GetComponentID(Context); + AppConfig.LoadComponentSettings(Context); + new RestoreScript(Context).Run(); + } + } + else if (ModeExtension == ModeExtension.Restore) + { + Context.ComponentId = GetComponentID(Context); + AppConfig.LoadComponentSettings(Context); + new RestoreScript(Context).Run(); + } + else + throw new NotImplementedException("Install " + ModeExtension.ToString()); + } + protected override void Uninstall() + { + Context.ComponentId = GetComponentID(Context); + AppConfig.LoadComponentSettings(Context); + SetupScript Script = null; + switch (ModeExtension) + { + case ModeExtension.Normal: + { + Script = new UninstallScript(Context); + var Act = new InstallAction(ActionTypes.DeleteShortcuts); + Act.Description = "Deleting shortcuts..."; + Act.Log = "- Delete shortcuts"; + Act.Name = "Login to WebsitePanel.url"; + Script.Actions.Add(Act); + } + break; + case ModeExtension.Backup: + Script = new BackupScript(Context); + break; + default: + throw new NotImplementedException("Uninstall " + ModeExtension.ToString()); + } + Script.Run(); + } + } + +#region WiXActionManagers + public class WiXServerActionManager : BaseActionManager + { + public static readonly List InstallScenario = new List + { + new SetCommonDistributiveParamsAction(), + new SetServerDefaultInstallationSettingsAction(), + new EnsureServiceAccntSecured(), + //new CopyFilesAction(), + new SetServerPasswordAction(), + new CreateWindowsAccountAction(), + new ConfigureAspNetTempFolderPermissionsAction(), + new SetNtfsPermissionsAction(), + new CreateWebApplicationPoolAction(), + new CreateWebSiteAction(), + new SwitchAppPoolAspNetVersion(), + new SaveComponentConfigSettingsAction() + }; + + public WiXServerActionManager(SetupVariables sessionVars) + : base(sessionVars) + { + Initialize += new EventHandler(WiXServerActionManager_Initialize); + } + + void WiXServerActionManager_Initialize(object sender, EventArgs e) + { + switch (SessionVariables.SetupAction) + { + case SetupActions.Install: + LoadInstallationScenario(); + break; + default: + break; + } + } + + protected virtual void LoadInstallationScenario() + { + CurrentScenario.AddRange(InstallScenario); + } + } + + public class WiXPortalActionManager : BaseActionManager + { + public static readonly List InstallScenario = new List + { + new SetCommonDistributiveParamsAction(), + new SetWebPortalWebSettingsAction(), + new EnsureServiceAccntSecured(), + //new CopyFilesAction(), + new CopyWebConfigAction(), + new CreateWindowsAccountAction(), + new ConfigureAspNetTempFolderPermissionsAction(), + new SetNtfsPermissionsAction(), + new CreateWebApplicationPoolAction(), + new CreateWebSiteAction(), + new SwitchAppPoolAspNetVersion(), + new UpdateEnterpriseServerUrlAction(), + new GenerateSessionValidationKeyAction(), + new SaveComponentConfigSettingsAction(), + new CreateDesktopShortcutsAction() + }; + public WiXPortalActionManager(SetupVariables sessionVars) + : base(sessionVars) + { + Initialize += new EventHandler(WiXPortalActionManager_Initialize); + } + void WiXPortalActionManager_Initialize(object sender, EventArgs e) + { + switch (SessionVariables.SetupAction) + { + case SetupActions.Install: + LoadInstallationScenario(); + break; + default: + break; + } + } + protected virtual void LoadInstallationScenario() + { + CurrentScenario.AddRange(InstallScenario); + } + } + public class WiXEnterpriseServerActionManager : BaseActionManager + { + public static readonly List InstallScenario = new List + { + new SetCommonDistributiveParamsAction(), + new SetEntServerWebSettingsAction(), + new EnsureServiceAccntSecured(), + //new CopyFilesAction(), + new SetEntServerCryptoKeyAction(), + new CreateWindowsAccountAction(), + new ConfigureAspNetTempFolderPermissionsAction(), + new SetNtfsPermissionsAction(), + new CreateWebApplicationPoolAction(), + new CreateWebSiteAction(), + new SwitchAppPoolAspNetVersion(), + //new CreateDatabaseAction(), + new CreateDatabaseUserAction(), + //new ExecuteInstallSqlAction(), + new UpdateServeradminPasswAction(), + new SaveAspNetDbConnectionStringAction(), + new SaveComponentConfigSettingsAction(), + new SaveEntServerConfigSettingsAction(), + new SaveSchedulerServiceConnectionStringAction(), + new SaveSchedulerServiceCryptoKeyAction(), + new InstallSchedulerServiceAction() + }; + public WiXEnterpriseServerActionManager(SetupVariables sessionVars) + : base(sessionVars) + { + Initialize += new EventHandler(WiXEnterpriseServerActionManager_Initialize); + } + void WiXEnterpriseServerActionManager_Initialize(object sender, EventArgs e) + { + switch (SessionVariables.SetupAction) + { + case SetupActions.Install: + LoadInstallationScenario(); + break; + default: + break; + } + } + protected virtual void LoadInstallationScenario() + { + CurrentScenario.AddRange(InstallScenario); + } + } +#endregion +} diff --git a/WebsitePanel.Installer/Sources/WebsitePanel.Setup/WebsitePanel.Setup.csproj b/WebsitePanel.Installer/Sources/WebsitePanel.Setup/WebsitePanel.Setup.csproj index f8a058bc..246d4850 100644 --- a/WebsitePanel.Installer/Sources/WebsitePanel.Setup/WebsitePanel.Setup.csproj +++ b/WebsitePanel.Installer/Sources/WebsitePanel.Setup/WebsitePanel.Setup.csproj @@ -143,6 +143,7 @@ + diff --git a/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Wizard/ConfigurationCheckPage.cs b/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Wizard/ConfigurationCheckPage.cs index db4610e2..20344e42 100644 --- a/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Wizard/ConfigurationCheckPage.cs +++ b/WebsitePanel.Installer/Sources/WebsitePanel.Setup/Wizard/ConfigurationCheckPage.cs @@ -127,13 +127,13 @@ namespace WebsitePanel.Setup switch (check.CheckType) { case CheckTypes.OperationSystem: - status = CheckOS(out details); + status = CheckOS(check.SetupVariables, out details); break; case CheckTypes.IISVersion: - status = CheckIISVersion(out details); + status = CheckIISVersion(check.SetupVariables, out details); break; case CheckTypes.ASPNET: - status = CheckASPNET(out details); + status = CheckASPNET(check.SetupVariables, out details); break; case CheckTypes.WPServer: status = CheckWPServer(check.SetupVariables, out details); @@ -221,7 +221,7 @@ namespace WebsitePanel.Setup } - private CheckStatuses CheckOS(out string details) + internal static CheckStatuses CheckOS(SetupVariables setupVariables, out string details) { details = string.Empty; try @@ -237,6 +237,7 @@ namespace WebsitePanel.Setup version == OS.WindowsVersion.WindowsServer2008 || version == OS.WindowsVersion.WindowsServer2008R2 || version == OS.WindowsVersion.WindowsServer2012 || + version == OS.WindowsVersion.WindowsServer2012R2 || version == OS.WindowsVersion.WindowsVista || version == OS.WindowsVersion.Windows7 || version == OS.WindowsVersion.Windows8 )) @@ -260,20 +261,20 @@ namespace WebsitePanel.Setup return CheckStatuses.Error; } } - private CheckStatuses CheckIISVersion(out string details) + internal static CheckStatuses CheckIISVersion(SetupVariables setupVariables, out string details) { details = string.Empty; try { - details = string.Format("IIS {0}", SetupVariables.IISVersion.ToString(2)); - if (SetupVariables.IISVersion.Major == 6 && + details = string.Format("IIS {0}", setupVariables.IISVersion.ToString(2)); + if (setupVariables.IISVersion.Major == 6 && Utils.IsWin64() && Utils.IIS32Enabled()) { details += " (32-bit mode)"; } Log.WriteInfo(string.Format("IIS check: {0}", details)); - if (SetupVariables.IISVersion.Major < 6) + if (setupVariables.IISVersion.Major < 6) { details = "IIS 6.0 or greater required."; Log.WriteError(string.Format("IIS check: {0}", details), null); @@ -291,26 +292,26 @@ namespace WebsitePanel.Setup } } - private CheckStatuses CheckASPNET(out string details) + internal static CheckStatuses CheckASPNET(SetupVariables setupVariables, out string details) { details = "ASP.NET 4.0 is installed."; CheckStatuses ret = CheckStatuses.Success; try { // IIS 6 - if (SetupVariables.IISVersion.Major == 6) + if (setupVariables.IISVersion.Major == 6) { // - if (Utils.CheckAspNet40Registered(SetupVariables) == false) + if (Utils.CheckAspNet40Registered(setupVariables) == false) { // Register ASP.NET 4.0 - Utils.RegisterAspNet40(SetupVariables); + Utils.RegisterAspNet40(setupVariables); // ret = CheckStatuses.Warning; details = AspNet40HasBeenInstalledMessage; } // Enable ASP.NET 4.0 Web Server Extension if it is prohibited - if (Utils.GetAspNetWebExtensionStatus_Iis6(SetupVariables) == WebExtensionStatus.Prohibited) + if (Utils.GetAspNetWebExtensionStatus_Iis6(setupVariables) == WebExtensionStatus.Prohibited) { Utils.EnableAspNetWebExtension_Iis6(); } @@ -331,10 +332,10 @@ namespace WebsitePanel.Setup return CheckStatuses.Error; } // Register ASP.NET 4.0 - if (Utils.CheckAspNet40Registered(SetupVariables) == false) + if (Utils.CheckAspNet40Registered(setupVariables) == false) { // Register ASP.NET 4.0 - Utils.RegisterAspNet40(SetupVariables); + Utils.RegisterAspNet40(setupVariables); // ret = CheckStatuses.Warning; details = AspNet40HasBeenInstalledMessage; @@ -359,17 +360,17 @@ namespace WebsitePanel.Setup } } - private CheckStatuses CheckIIS32Mode(out string details) + internal static CheckStatuses CheckIIS32Mode(SetupVariables setupVariables, out string details) { details = string.Empty; - CheckStatuses ret = CheckIISVersion(out details); + CheckStatuses ret = CheckIISVersion(setupVariables, out details); if (ret == CheckStatuses.Error) return ret; try { //IIS 6 - if (SetupVariables.IISVersion.Major == 6) + if (setupVariables.IISVersion.Major == 6) { //x64 if (Utils.IsWin64()) diff --git a/WebsitePanel.Installer/Sources/WebsitePanel.WIXInstaller/Common/InMemoryStringLogListener.cs b/WebsitePanel.Installer/Sources/WebsitePanel.WIXInstaller/Common/InMemoryStringLogListener.cs new file mode 100644 index 00000000..fa9904df --- /dev/null +++ b/WebsitePanel.Installer/Sources/WebsitePanel.WIXInstaller/Common/InMemoryStringLogListener.cs @@ -0,0 +1,35 @@ +using System; +using System.Diagnostics; +using System.Text; + +namespace WebsitePanel.WIXInstaller.Common +{ + class InMemoryStringLogListener : TraceListener + { + private const string Format = "[{0}] Message: {1}"; + static private StringBuilder m_Ctx; + string m_id; + static InMemoryStringLogListener() + { + m_Ctx = new StringBuilder(); + } + public InMemoryStringLogListener(string InstanceID) + : base(InstanceID) + { + m_id = InstanceID; + } + public override void Write(string Value) + { + WriteLog(Value); + } + public override void WriteLine(string Value) + { + WriteLog(Value + Environment.NewLine); + } + [Conditional("DEBUG")] + private void WriteLog(string Value) + { + m_Ctx.Append(string.Format(Format, m_id, Value)); + } + } +} diff --git a/WebsitePanel.Installer/Sources/WebsitePanel.WIXInstaller/Common/Prop.cs b/WebsitePanel.Installer/Sources/WebsitePanel.WIXInstaller/Common/Prop.cs new file mode 100644 index 00000000..a82c5b40 --- /dev/null +++ b/WebsitePanel.Installer/Sources/WebsitePanel.WIXInstaller/Common/Prop.cs @@ -0,0 +1,19 @@ +using System; + +namespace WebsitePanel.WIXInstaller.Common +{ + internal struct Prop + { + public const int REQ_IIS_MINIMUM = 6; + public const string REQ_LOG = "PI_PREREQ_LOG"; + public const string REQ_OS = "PI_PREREQ_OS"; + public const string REQ_IIS = "PI_PREREQ_IIS"; + public const string REQ_IIS_MAJOR = "PI_PREREQ_IIS_MAJOR"; + public const string REQ_IIS_MINOR = "PI_PREREQ_IIS_MINOR"; + public const string REQ_ASPNET = "PI_PREREQ_ASPNET"; + public const string REQ_SERVER = "PI_PREREQ_WP_SERVER"; + public const string REQ_ESERVER = "PI_PREREQ_WP_ESERVER"; + public const string REQ_PORTAL = "PI_PREREQ_WP_PORTAL"; + public const string REQ_WDPORTAL = "PI_PREREQ_WP_WDPORTAL"; + } +} diff --git a/WebsitePanel.Installer/Sources/WebsitePanel.WIXInstaller/Common/Tool.cs b/WebsitePanel.Installer/Sources/WebsitePanel.WIXInstaller/Common/Tool.cs new file mode 100644 index 00000000..0c8159b1 --- /dev/null +++ b/WebsitePanel.Installer/Sources/WebsitePanel.WIXInstaller/Common/Tool.cs @@ -0,0 +1,36 @@ +using Microsoft.Deployment.WindowsInstaller; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using WebsitePanel.Setup; + +namespace WebsitePanel.WIXInstaller.Common +{ + internal static class Tool + { + public static SetupVariables GetSetupVars(Session Ctx) + { + return new SetupVariables + { + SetupAction = SetupActions.Install, + IISVersion = Global.IISVersion + }; + } + + public static void FillServerVariables(SetupVariables Vars) + { + + } + + public static void FillEServerVariables(SetupVariables Vars) + { + + } + + public static void FillPortalVariables(SetupVariables Vars) + { + + } + } +} diff --git a/WebsitePanel.Installer/Sources/WebsitePanel.WIXInstaller/Common/Util/IListCtrl.cs b/WebsitePanel.Installer/Sources/WebsitePanel.WIXInstaller/Common/Util/IListCtrl.cs new file mode 100644 index 00000000..965d5ab8 --- /dev/null +++ b/WebsitePanel.Installer/Sources/WebsitePanel.WIXInstaller/Common/Util/IListCtrl.cs @@ -0,0 +1,79 @@ +using System; +using Microsoft.Deployment.WindowsInstaller; + +namespace WebsitePanel.WIXInstaller.Common.Util +{ + internal interface IListCtrl + { + ulong Count { get; } + string Id { get; } + void AddItem(Record Item); + } + + internal abstract class ListCtrlBase : IListCtrl + { + private Session m_Ctx; + private string m_CtrlType; + private string m_CtrlId; + private View m_View; + private ulong m_Count; + + public ListCtrlBase(Session session, string CtrlType, string CtrlId) + { + m_Ctx = session; + m_CtrlType = CtrlType; + m_CtrlId = CtrlId; + m_View = null; + m_Count = 0; + Initialize(); + } + + ~ListCtrlBase() + { + if (m_View != null) + m_View.Close(); + } + + public virtual ulong Count { get { return m_Count; } } + + public virtual string Id { get { return m_CtrlId; } } + + public virtual void AddItem(Record Item) + { + m_View.Execute(Item); + ++m_Count; + } + + private void Initialize() + { + m_Ctx.Database.Execute(string.Format("DELETE FROM `{0}` WHERE `Property`='{1}'", m_CtrlType, m_CtrlId)); + m_View = m_Ctx.Database.OpenView(m_Ctx.Database.Tables[m_CtrlType].SqlInsertString + " TEMPORARY"); + } + } + + class ListViewCtrl : ListCtrlBase + { + public ListViewCtrl(Session session, string WiXListID) : base(session, "ListView", WiXListID) + { + + } + + public void AddItem(bool Checked, string Value) + { + AddItem(new Record(new object[] { Id, Count, Value, Value, Checked ? "passmark" : "failmark" })); + } + } + + class ComboBoxCtrl : ListCtrlBase + { + public ComboBoxCtrl(Session session, string WiXComboID): base(session, "ComboBox", WiXComboID) + { + + } + + public void AddItem(string Value) + { + AddItem(new Record(new object[] { Id, Count, Value, Value })); + } + } +} diff --git a/WebsitePanel.Installer/Sources/WebsitePanel.WIXInstaller/Common/WiXLogListener.cs b/WebsitePanel.Installer/Sources/WebsitePanel.WIXInstaller/Common/WiXLogListener.cs new file mode 100644 index 00000000..6c90a0c2 --- /dev/null +++ b/WebsitePanel.Installer/Sources/WebsitePanel.WIXInstaller/Common/WiXLogListener.cs @@ -0,0 +1,26 @@ +using System; +using System.Diagnostics; +using Microsoft.Deployment.WindowsInstaller; + +namespace WebsitePanel.WIXInstaller.Common +{ + public class WiXLogListener : TraceListener + { + private Session m_Ctx; + public WiXLogListener(Session Ctx) + : base("WiXLogListener") + { + m_Ctx = Ctx; + } + + public override void Write(string Value) + { + m_Ctx.Log(Value); + } + + public override void WriteLine(string Value) + { + m_Ctx.Log(Value + Environment.NewLine); + } + } +} diff --git a/WebsitePanel.Installer/Sources/WebsitePanel.WIXInstaller/Common/YesNo.cs b/WebsitePanel.Installer/Sources/WebsitePanel.WIXInstaller/Common/YesNo.cs new file mode 100644 index 00000000..f97e9eea --- /dev/null +++ b/WebsitePanel.Installer/Sources/WebsitePanel.WIXInstaller/Common/YesNo.cs @@ -0,0 +1,11 @@ +using System; + +namespace WebsitePanel.WIXInstaller.Common +{ + internal struct YesNo + { + public static string Yes { get { return "1"; } } + + public static string No { get { return "0"; } } + } +} diff --git a/WebsitePanel.Installer/Sources/WebsitePanel.WIXInstaller/CustomAction.cs b/WebsitePanel.Installer/Sources/WebsitePanel.WIXInstaller/CustomAction.cs index 1ce53461..d9c553dc 100644 --- a/WebsitePanel.Installer/Sources/WebsitePanel.WIXInstaller/CustomAction.cs +++ b/WebsitePanel.Installer/Sources/WebsitePanel.WIXInstaller/CustomAction.cs @@ -25,51 +25,244 @@ // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - using System; using System.Collections.Generic; using System.Configuration.Install; using System.Data; +using System.Data.Sql; using System.Data.SqlClient; +using System.Diagnostics; using System.IO; using System.Linq; +using System.Net.NetworkInformation; +using System.Net.Sockets; using System.ServiceProcess; using System.Text.RegularExpressions; -using System.Threading; -using System.Windows.Forms; -using System.Windows.Forms.VisualStyles; using System.Xml; using Microsoft.Deployment.WindowsInstaller; using WebsitePanel.Setup; +using WebsitePanel.Setup.Internal; +using WebsitePanel.WIXInstaller.Common; +using WebsitePanel.WIXInstaller.Common.Util; namespace WebsitePanel.WIXInstaller { public class CustomActions { + public static List SysDb = new List { "tempdb", "master", "model", "msdb" }; public const string CustomDataDelimiter = "-=del=-"; + #region CustomActions + // Install. [CustomAction] - public static ActionResult CheckConnection(Session session) + public static ActionResult OnServerInstall(Session session) { - string testConnectionString = session["AUTHENTICATIONTYPE"].Equals("Windows Authentication") ? GetConnectionString(session["SERVERNAME"], "master") : GetConnectionString(session["SERVERNAME"], "master", session["LOGIN"], session["PASSWORD"]); - - if (CheckConnection(testConnectionString)) + PopUpDebugger(); + return ProcessInstall(session, WiXInstallType.InstallServer); + } + [CustomAction] + public static ActionResult OnEServerInstall(Session session) + { + PopUpDebugger(); + return ProcessInstall(session, WiXInstallType.InstallEnterpriseServer); + } + [CustomAction] + public static ActionResult OnPortalInstall(Session session) + { + PopUpDebugger(); + return ProcessInstall(session, WiXInstallType.InstallPortal); + } + // Remove. + [CustomAction] + public static ActionResult OnServerRemove(Session session) + { + PopUpDebugger(); + return ProcessInstall(session, WiXInstallType.RemoveServer); + } + [CustomAction] + public static ActionResult OnEServerRemove(Session session) + { + PopUpDebugger(); + return ProcessInstall(session, WiXInstallType.RemoveEnterpriseServer); + } + [CustomAction] + public static ActionResult OnPortalRemove(Session session) + { + PopUpDebugger(); + return ProcessInstall(session, WiXInstallType.RemovePortal); + } + // Other. + [CustomAction] + public static ActionResult SetEServerUrlUI(Session session) + { + var Ctx = session; + Ctx["PI_ESERVER_URL"] = string.Format("http://{0}:{1}/", Ctx["PI_ESERVER_IP"], Ctx["PI_ESERVER_PORT"]); + return ActionResult.Success; + } + [CustomAction] + public static ActionResult RecapListUI(Session session) + { + const string F_WSP = "WebsitePanel"; + const string F_Server = "ServerFeature"; + const string F_EServer = "EnterpriseServerFeature"; + const string F_Portal = "PortalFeature"; + const string F_Scheduler = "SchedulerServiceFeature"; + const string F_WDPosrtal = "WDPortalFeature"; + var S_Install = new List { "Copy WebsitePanel Server files", "Add WebsitePanel Server website" }; + var ES_Install = new List { "Copy WebsitePanel Enterprise Server files", "Install WebsitePanel database and updates", "Add WebsitePanel Enterprise Server website" }; + var P_Install = new List { "Copy WebsitePanel Portal files", "Add WebsitePanel Enterprise Portal website" }; + var SCH_Install = new List { "Copy WebsitePanel Scheduler Service files", "Install Scheduler Service Windows Service" }; + var WDP_Install = new List { "Copy WebsitePanel WebDav Portal files" }; + var S_Uninstall = new List { "Delete WebsitePanel Server files", "Remove WebsitePanel Server website" }; + var ES_Uninstall = new List { "Delete WebsitePanel Enterprise Server files", "Keep WebsitePanel database and updates", "Remove WebsitePanel Enterprise Server website" }; + var P_Uninstall = new List { "Delete WebsitePanel Portal files", "Remove WebsitePanel Enterprise Portal website" }; + var SCH_Uninstall = new List { "Delete WebsitePanel Scheduler Service files", "Remove Scheduler Service Windows Service" }; + var WDP_Uninstall = new List { "Delete WebsitePanel WebDav Portal files" }; + var RecapList = new List(); + var EmptyList = new List(); + var Ctx = session; + RecapListReset(Ctx); + foreach (var Feature in Ctx.Features) { - session["CORRECTCONNECTION"] = "1"; - session["CONNECTIONSTRING"] = session["AUTHENTICATIONTYPE"].Equals("Windows Authentication") ? GetConnectionString(session["SERVERNAME"], session["DATABASENAME"]) : GetConnectionString(session["SERVERNAME"], session["DATABASENAME"], session["LOGIN"], session["PASSWORD"]); + switch (Feature.Name) + { + case F_WSP: + break; + case F_Server: + RecapList.AddRange(Feature.RequestState == InstallState.Local ? S_Install : /*S_Uninstall*/ EmptyList); + break; + case F_EServer: + RecapList.AddRange(Feature.RequestState == InstallState.Local ? ES_Install : /*ES_Uninstall*/ EmptyList); + break; + case F_Portal: + RecapList.AddRange(Feature.RequestState == InstallState.Local ? P_Install : /*P_Uninstall*/ EmptyList); + break; + case F_Scheduler: + RecapList.AddRange(Feature.RequestState == InstallState.Local ? SCH_Install : /*SCH_Uninstall*/ EmptyList); + break; + case F_WDPosrtal: + RecapList.AddRange(Feature.RequestState == InstallState.Local ? WDP_Install : /*WDP_Uninstall*/ EmptyList); + break; + default: + break; + } } + RecapListAdd(Ctx, RecapList.ToArray()); + return ActionResult.Success; + } + [CustomAction] + public static ActionResult DatabaseConnectionValidateUI(Session session) + { + var Ctx = session; + bool Valid = true; + string Msg; + ValidationReset(Ctx); + Valid = ValidateDbNameUI(Ctx, out Msg); + ValidationMsg(Ctx, Msg); + ValidationStatus(Ctx, Valid); + return ActionResult.Success; + } + [CustomAction] + public static ActionResult ServerAdminValidateUI(Session session) + { + var Ctx = session; + bool Valid = true; + string Msg; + ValidationReset(Ctx); + Valid = ValidatePasswordUI(Ctx, "SERVERADMIN", out Msg); + ValidationMsg(Ctx, Msg); + ValidationStatus(Ctx, Valid); + return ActionResult.Success; + } + [CustomAction] + public static ActionResult ServerValidateADUI(Session session) + { + var Ctx = session; + bool Valid = true; + string Msg; + ValidationReset(Ctx); + Valid = ValidateADUI(Ctx, "PI_SERVER", out Msg); + ValidationMsg(Ctx, Msg); + ValidationStatus(Ctx, Valid); + return ActionResult.Success; + } + [CustomAction] + public static ActionResult EServerValidateADUI(Session session) + { + var Ctx = session; + bool Valid = true; + string Msg; + ValidationReset(Ctx); + Valid = ValidateADUI(Ctx, "PI_ESERVER", out Msg); + ValidationMsg(Ctx, Msg); + ValidationStatus(Ctx, Valid); + return ActionResult.Success; + } + [CustomAction] + public static ActionResult PortalValidateADUI(Session session) + { + var Ctx = session; + bool Valid = true; + string Msg; + ValidationReset(Ctx); + Valid = ValidateADUI(Ctx, "PI_PORTAL", out Msg); + ValidationMsg(Ctx, Msg); + ValidationStatus(Ctx, Valid); + return ActionResult.Success; + } + [CustomAction] + public static ActionResult ServerAccessValidateUI(Session session) + { + var Ctx = session; + bool Valid = true; + string Msg; + ValidationReset(Ctx); + Valid = ValidatePasswordUI(Ctx, "SERVER_ACCESS", out Msg); + ValidationMsg(Ctx, Msg); + ValidationStatus(Ctx, Valid); + return ActionResult.Success; + } + [CustomAction] + public static ActionResult SqlServerListUI(Session session) + { + var Ctx = session; + var SrvList = new ComboBoxCtrl(Ctx, "DB_SERVER"); + foreach (var Srv in GetSqlInstances()) + SrvList.AddItem(Srv); + return ActionResult.Success; + } + [CustomAction] + public static ActionResult DbListUI(Session session) + { + string tmp; + var Ctrl = new ComboBoxCtrl(session, "DB_SELECT"); + if (CheckConnection(session["DB_CONN"], out tmp)) + foreach (var Db in GetDbList(ConnStr: session["DB_CONN"], ForbiddenNames: SysDb)) + { + Ctrl.AddItem(Db); + session["DB_SELECT"] = Db; // Adds available DBs to installer log. + } else - { - session["CORRECTCONNECTION"] = "0"; - } - + session["DB_SELECT"] = ""; + return ActionResult.Success; + } + [CustomAction] + public static ActionResult CheckConnectionUI(Session session) + { + string ConnStr = session["DB_AUTH"].Equals("Windows Authentication") ? GetConnectionString(session["DB_SERVER"], "master") : + GetConnectionString(session["DB_SERVER"], "master", session["DB_LOGIN"], session["DB_PASSWORD"]); + string msg; + bool Result = CheckConnection(ConnStr, out msg); + session["DB_CONN_CORRECT"] = Result ? "1" : "0"; + session["DB_CONN"] = Result ? ConnStr : ""; + session["DB_CONN_MSG"] = msg; return ActionResult.Success; } [CustomAction] public static ActionResult FinalizeInstall(Session session) { - var connectionString = GetCustomActionProperty(session, "ConnectionString").Replace(CustomDataDelimiter, ";"); + /*var connectionString = GetCustomActionProperty(session, "ConnectionString").Replace(CustomDataDelimiter, ";"); var serviceFolder = GetCustomActionProperty(session, "ServiceFolder"); var previousConnectionString = GetCustomActionProperty(session, "PreviousConnectionString").Replace(CustomDataDelimiter, ";"); var previousCryptoKey = GetCustomActionProperty(session, "PreviousCryptoKey"); @@ -85,7 +278,7 @@ namespace WebsitePanel.WIXInstaller ChangeConfigString("/configuration/connectionStrings/add[@name='EnterpriseServer']", "connectionString", connectionString, serviceFolder); ChangeConfigString("/configuration/appSettings/add[@key='WebsitePanel.CryptoKey']", "value", previousCryptoKey, serviceFolder); - InstallService(serviceFolder); + InstallService(serviceFolder);*/ return ActionResult.Success; } @@ -93,7 +286,7 @@ namespace WebsitePanel.WIXInstaller [CustomAction] public static ActionResult FinalizeUnInstall(Session session) { - UnInstallService(); + // UnInstallService(); return ActionResult.Success; } @@ -105,7 +298,7 @@ namespace WebsitePanel.WIXInstaller session["SERVICEFOLDER"] = session["INSTALLFOLDER"]; - var servicePath = SecurityUtils.GetServicePath("WebsitePanel Scheduler"); + var servicePath = /*SecurityUtils.GetServicePath("WebsitePanel Scheduler")*/""; if (!string.IsNullOrEmpty(servicePath)) { @@ -131,13 +324,59 @@ namespace WebsitePanel.WIXInstaller { session["SERVICEFOLDER"] = servicePath; } - } + } } return ActionResult.Success; } + [CustomAction] + public static ActionResult PrereqCheck(Session session) + { + string Msg; + var Ctx = Tool.GetSetupVars(session); + var ros = Adapter.CheckOS(Ctx, out Msg); + AddLog(session, Msg); + var riis = Adapter.CheckIIS(Ctx, out Msg); + AddLog(session, Msg); + var raspnet = Adapter.CheckASPNET(Ctx, out Msg); + AddLog(session, Msg); + session[Prop.REQ_OS] = ros == CheckStatuses.Success ? YesNo.Yes : YesNo.No; + session[Prop.REQ_IIS] = riis == CheckStatuses.Success ? YesNo.Yes : YesNo.No; ; + session[Prop.REQ_ASPNET] = raspnet == CheckStatuses.Success ? YesNo.Yes : YesNo.No; ; + session[Prop.REQ_SERVER] = YesNo.Yes; + session[Prop.REQ_ESERVER] = YesNo.Yes; + session[Prop.REQ_PORTAL] = YesNo.Yes; + session[Prop.REQ_WDPORTAL] = YesNo.Yes; + return ActionResult.Success; + } + [CustomAction] + public static ActionResult PrereqCheckUI(Session session) + { + var ListView = new ListViewCtrl(session, "REQCHECKLIST"); + AddCheck(ListView, session, Prop.REQ_OS); + AddCheck(ListView, session, Prop.REQ_IIS); + AddCheck(ListView, session, Prop.REQ_ASPNET); + AddCheck(ListView, session, Prop.REQ_SERVER); + AddCheck(ListView, session, Prop.REQ_ESERVER); + AddCheck(ListView, session, Prop.REQ_PORTAL); + AddCheck(ListView, session, Prop.REQ_WDPORTAL); + return ActionResult.Success; + } + [CustomAction] + public static ActionResult FillIpListUI(Session session) + { + var Ctrls = new[]{ new ComboBoxCtrl(session, "PI_SERVER_IP"), + new ComboBoxCtrl(session, "PI_ESERVER_IP"), + new ComboBoxCtrl(session, "PI_PORTAL_IP") }; + foreach (var Ip in GetIpList()) + foreach (var Ctrl in Ctrls) + Ctrl.AddItem(Ip); + return ActionResult.Success; + } + + #endregion private static void InstallService(string installFolder) { try @@ -204,7 +443,6 @@ namespace WebsitePanel.WIXInstaller } } - private static void StopService(string serviceName) { var sc = new ServiceController(serviceName); @@ -229,36 +467,30 @@ namespace WebsitePanel.WIXInstaller private static string GetConnectionString(string serverName, string databaseName) { - return string.Format("Server={0};database={1};Trusted_Connection=true;", serverName, databaseName).Replace(";", CustomDataDelimiter); + return string.Format("Server={0};database={1};Trusted_Connection=true;", serverName, databaseName)/*.Replace(";", CustomDataDelimiter)*/; } private static string GetConnectionString(string serverName, string databaseName, string login, string password) { - return string.Format("Server={0};database={1};uid={2};password={3};", serverName, databaseName, login, password).Replace(";", CustomDataDelimiter); + return string.Format("Server={0};database={1};uid={2};password={3};", serverName, databaseName, login, password)/*.Replace(";", CustomDataDelimiter)*/; } - - private static bool CheckConnection(string connectionString) + static bool CheckConnection(string ConnStr, out string Info) { - var connection = new SqlConnection(connectionString); - bool result = true; - - try + Info = string.Empty; + bool Result = false; + using (var Conn = new SqlConnection(ConnStr)) { - connection.Open(); - } - catch (Exception) - { - result = false; - } - finally - { - if (connection != null && connection.State == ConnectionState.Open) + try { - connection.Close(); + Conn.Open(); + Result = true; + } + catch (Exception ex) + { + Info = ex.Message; } } - - return result; + return Result; } private static string GetCustomActionProperty(Session session, string key) @@ -270,5 +502,235 @@ namespace WebsitePanel.WIXInstaller return string.Empty; } + private static void AddCheck(ListViewCtrl view, Session session, string PropertyID) + { + view.AddItem(session[PropertyID] == YesNo.Yes, session[PropertyID + "_TITLE"]); + } + static IList GetSqlInstances() + { + var Result = new List(); + using (var Src = SqlDataSourceEnumerator.Instance.GetDataSources()) + { + foreach (DataRow Row in Src.Rows) + { + var Instance = Row["InstanceName"].ToString(); + Result.Add((string.IsNullOrWhiteSpace(Instance) ? "" : (Instance + "\\")) + Row["ServerName"].ToString()); + } + } + return Result; + } + static IEnumerable GetDbList(string ConnStr, IList ForbiddenNames = null) + { + using (var Conn = new SqlConnection(ConnStr)) + { + Conn.Open(); + var Cmd = Conn.CreateCommand(); + Cmd.CommandText = "SELECT name FROM master..sysdatabases"; + if (ForbiddenNames != null && ForbiddenNames.Count > 0) + Cmd.CommandText += string.Format(" WHERE name NOT IN ({0})", string.Join(", ", ForbiddenNames.Select(x => string.Format("'{0}'", x)))); + var Result = Cmd.ExecuteReader(); + while (Result.Read()) + yield return Result["name"].ToString(); + } + } + static IEnumerable GetIpList() + { + foreach (var Ni in NetworkInterface.GetAllNetworkInterfaces()) + if (Ni.OperationalStatus == OperationalStatus.Up && (Ni.NetworkInterfaceType == NetworkInterfaceType.Ethernet || + Ni.NetworkInterfaceType == NetworkInterfaceType.Wireless80211 || + Ni.NetworkInterfaceType == NetworkInterfaceType.Loopback)) + foreach (var IpInfo in Ni.GetIPProperties().UnicastAddresses) + if (IpInfo.Address.AddressFamily == AddressFamily.InterNetwork) + yield return IpInfo.Address.ToString(); + } + internal static void AddLog(Session Ctx, string Msg) + { + AddTo(Ctx, "PI_PREREQ_LOG", Msg); + } + internal static void AddTo(Session Ctx, string TextProp, string Msg) + { + if (!string.IsNullOrWhiteSpace(Msg)) + { + string tmp = Ctx[TextProp]; + if (string.IsNullOrWhiteSpace(tmp)) + Ctx[TextProp] = Msg; + else + Ctx[TextProp] = tmp + Environment.NewLine + Msg; + } + } + internal static void ValidationReset(Session Ctx) + { + Ctx["VALIDATE_OK"] = "0"; + Ctx["VALIDATE_MSG"] = "Error occurred."; + } + internal static void ValidationStatus(Session Ctx, bool Value) + { + Ctx["VALIDATE_OK"] = Value ? YesNo.Yes : YesNo.No; + } + internal static void ValidationMsg(Session Ctx, string Msg) + { + AddTo(Ctx, "VALIDATE_MSG", Msg); + } + internal static bool PasswordValidate(string Password, string Confirm, out string Msg) + { + Msg = string.Empty; + bool Result = false; + if (string.IsNullOrWhiteSpace(Password)) + Msg = "Empty password."; + else if (Password != Confirm) + Msg = "Password does not match the confirm password. Type both passwords again."; + else + Result = true; + return Result; + } + internal static bool ValidatePasswordUI(Session Ctx, string Ns, out string Msg) + { + string p1 = Ctx[Ns + "_PASSWORD"]; + string p2 = Ctx[Ns + "_PASSWORD_CONFIRM"]; + return PasswordValidate(p1, p2, out Msg); + } + internal static bool ValidateADDomainUI(Session Ctx, string Ns, out string Msg) + { + bool Result = default(bool); + bool check = Ctx[Ns + "_CREATE_AD"] == YesNo.Yes; + string name = Ctx[Ns + "_DOMAIN"]; + if (check && string.IsNullOrWhiteSpace(name)) + { + Result = false; + Msg = "The domain can't be empty."; + } + else + { + Result = true; + Msg = string.Empty; + } + return Result; + } + internal static bool ValidateADLoginUI(Session Ctx, string Ns, out string Msg) + { + bool Result = default(bool); + string name = Ctx[Ns + "_LOGIN"]; + if (string.IsNullOrWhiteSpace(name)) + { + Result = false; + Msg = "The login can't be empty."; + } + else + { + Result = true; + Msg = string.Empty; + } + return Result; + } + internal static bool ValidateADUI(Session Ctx, string Ns, out string Msg) + { + bool Result = true; + if (!ValidateADDomainUI(Ctx, Ns, out Msg)) + Result = false; + else if (!ValidateADLoginUI(Ctx, Ns, out Msg)) + Result = false; + else if (!ValidatePasswordUI(Ctx, Ns, out Msg)) + Result = false; + return Result; + } + internal static bool ValidateDbNameUI(Session Ctx, out string Msg) + { + Msg = string.Empty; + var Result = true; + string DbName = Ctx["DB_DATABASE"]; + if (string.IsNullOrWhiteSpace(DbName)) + { + Result = false; + Msg = "The database name can't be empty."; + + } + return Result; + } + internal static void RecapListReset(Session Ctx) + { + Ctx["CUSTOM_INSTALL_TEXT"] = string.Empty; + } + internal static void RecapListAdd(Session Ctx, params string[] Msgs) + { + foreach (var Msg in Msgs) + AddTo(Ctx, "CUSTOM_INSTALL_TEXT", Msg); ; + } + + internal static string GetProperty(Session Ctx, string Property) + { + if (Ctx.CustomActionData.ContainsKey(Property)) + return Ctx[Property]; + else + return string.Empty; + } + + private static ActionResult ProcessInstall(Session Ctx, WiXInstallType InstallType) + { + IWiXSetup Install = null; + try + { + Ctx.AttachToSetupLog(); + switch (InstallType) + { + case WiXInstallType.InstallServer: + Install = ServerSetup.Create(Ctx.CustomActionData, SetupActions.Install); + break; + case WiXInstallType.RemoveServer: + Install = ServerSetup.Create(Ctx.CustomActionData, SetupActions.Uninstall); + break; + case WiXInstallType.InstallEnterpriseServer: + Install = EServerSetup.Create(Ctx.CustomActionData, SetupActions.Install); + break; + case WiXInstallType.RemoveEnterpriseServer: + Install = EServerSetup.Create(Ctx.CustomActionData, SetupActions.Uninstall); + break; + case WiXInstallType.InstallPortal: + Install = PortalSetup.Create(Ctx.CustomActionData, SetupActions.Install); + break; + case WiXInstallType.RemovePortal: + Install = PortalSetup.Create(Ctx.CustomActionData, SetupActions.Uninstall); + break; + default: + throw new NotImplementedException(); + } + Install.Run(); + } + catch (WiXSetupException we) + { + Ctx.Log("Expected exception: " + we.ToString()); + return ActionResult.Failure; + } + catch (Exception ex) + { + Ctx.Log(ex.ToString()); + return ActionResult.Failure; + } + return ActionResult.Success; + } + [Conditional("DEBUG")] + private static void PopUpDebugger() + { + Debugger.Launch(); + } } + public static class SessionExtension + { + public static void AttachToSetupLog(this Session Ctx) + { + WiXSetup.InstallLogListener(new WiXLogListener(Ctx)); + WiXSetup.InstallLogListener(new InMemoryStringLogListener("WIX CA IN MEMORY")); + } + } + + internal enum WiXInstallType: byte + { + InstallServer, + InstallEnterpriseServer, + InstallPortal, + RemoveServer, + RemoveEnterpriseServer, + RemovePortal, + RemoveUpdate, + RestoreUpdate + } } diff --git a/WebsitePanel.Installer/Sources/WebsitePanel.WIXInstaller/WebsitePanel.WIXInstaller.csproj b/WebsitePanel.Installer/Sources/WebsitePanel.WIXInstaller/WebsitePanel.WIXInstaller.csproj index b2211e38..59ae4596 100644 --- a/WebsitePanel.Installer/Sources/WebsitePanel.WIXInstaller/WebsitePanel.WIXInstaller.csproj +++ b/WebsitePanel.Installer/Sources/WebsitePanel.WIXInstaller/WebsitePanel.WIXInstaller.csproj @@ -32,10 +32,25 @@ 4 + + + + $(BaseIntermediateOutputPath)$(Configuration)\ + $(BaseIntermediateOutputPath)$(PlatformName)\$(Configuration)\ + + + $(IntermediateOutputPath)$(AssemblyName).pdb;@(AddPdb) + + + + False + ..\..\Lib\Microsoft.Web.Administration.dll + + @@ -44,6 +59,12 @@ + + + + + + @@ -53,6 +74,10 @@ {3951C0EC-BD98-450E-B228-CDBE5BD4AD49} WebsitePanel.Setup + + {0E4A3F5B-0BB1-4F63-863D-7B0182B378CF} + WebsitePanel.Installer.Core + diff --git a/WebsitePanel/Database/install_db.sql b/WebsitePanel/Database/install_db.sql index a0f5162d..a9774f04 100644 --- a/WebsitePanel/Database/install_db.sql +++ b/WebsitePanel/Database/install_db.sql @@ -111,25 +111,25 @@ GO -CREATE PROCEDURE [dbo].[AddBlackBerryUser] +CREATE PROCEDURE [dbo].[AddBlackBerryUser] @AccountID int AS -BEGIN +BEGIN SET NOCOUNT ON; INSERT INTO dbo.BlackBerryUsers - ( - + ( + AccountID, CreatedDate, ModifiedDate) VALUES -( +( @AccountID, getdate(), getdate() -) +) END @@ -355,7 +355,7 @@ CREATE PROCEDURE [dbo].[AddDnsRecord] @RecordData nvarchar(500), @MXPriority int, @SrvPriority int, - @SrvWeight int, + @SrvWeight int, @SrvPort int, @IPAddressID int ) @@ -378,7 +378,7 @@ IF EXISTS ServiceID = @ServiceID AND ServerID = @ServerID AND PackageID = @PackageID AND RecordName = @RecordName AND RecordType = @RecordType ) - + UPDATE GlobalDnsRecords SET RecordData = RecordData, @@ -386,7 +386,7 @@ IF EXISTS SrvPriority = SrvPriority, SrvWeight = SrvWeight, SrvPort = SrvPort, - + IPAddressID = @IPAddressID WHERE ServiceID = @ServiceID AND ServerID = @ServerID AND PackageID = @PackageID @@ -439,7 +439,7 @@ GO -CREATE PROCEDURE AddDomain +CREATE PROCEDURE AddDomain ( @DomainID int OUTPUT, @ActorID int, @@ -516,7 +516,7 @@ GO /****** Object: Table [dbo].[AddExchangeAccount] ******/ -CREATE PROCEDURE [dbo].[AddExchangeAccount] +CREATE PROCEDURE [dbo].[AddExchangeAccount] ( @AccountID int OUTPUT, @ItemID int, @@ -664,7 +664,7 @@ GO -CREATE PROCEDURE [dbo].[AddExchangeMailboxPlan] +CREATE PROCEDURE [dbo].[AddExchangeMailboxPlan] ( @MailboxPlanId int OUTPUT, @ItemID int, @@ -818,7 +818,7 @@ GO -CREATE PROCEDURE AddExchangeOrganizationDomain +CREATE PROCEDURE AddExchangeOrganizationDomain ( @ItemID int, @DomainID int, @@ -884,7 +884,7 @@ GO -CREATE PROCEDURE [dbo].[AddIPAddress] +CREATE PROCEDURE [dbo].[AddIPAddress] ( @AddressID int OUTPUT, @ServerID int, @@ -1049,7 +1049,7 @@ GO -CREATE PROCEDURE [dbo].[AddLyncUser] +CREATE PROCEDURE [dbo].[AddLyncUser] @AccountID int, @LyncUserPlanID int, @SipAddress nvarchar(300) @@ -1062,7 +1062,7 @@ INSERT INTO ModifiedDate, SipAddress) VALUES -( +( @AccountID, @LyncUserPlanID, getdate(), @@ -1084,7 +1084,7 @@ GO -CREATE PROCEDURE [dbo].[AddLyncUserPlan] +CREATE PROCEDURE [dbo].[AddLyncUserPlan] ( @LyncUserPlanId int OUTPUT, @ItemID int, @@ -1154,28 +1154,28 @@ SET QUOTED_IDENTIFIER ON GO -CREATE PROCEDURE [dbo].[AddOCSUser] +CREATE PROCEDURE [dbo].[AddOCSUser] @AccountID int, @InstanceID nvarchar(50) AS -BEGIN +BEGIN SET NOCOUNT ON; INSERT INTO dbo.OCSUsers - ( - + ( + AccountID, InstanceID, CreatedDate, ModifiedDate) VALUES -( +( @AccountID, @InstanceID, getdate(), getdate() -) +) END @@ -1490,20 +1490,20 @@ GO -CREATE PROCEDURE [dbo].[AddPFX] +CREATE PROCEDURE [dbo].[AddPFX] ( @ActorID int, @PackageID int, @UserID int, @WebSiteID int, @FriendlyName nvarchar(255), - @HostName nvarchar(255), + @HostName nvarchar(255), @CSRLength int, @DistinguishedName nvarchar(500), @SerialNumber nvarchar(250), @ValidFrom datetime, @ExpiryDate datetime - + ) AS @@ -1642,7 +1642,7 @@ SELECT @ScheduleID, ParameterID, ParameterValue -FROM OPENXML(@idoc, '/parameters/parameter',1) WITH +FROM OPENXML(@idoc, '/parameters/parameter',1) WITH ( ParameterID nvarchar(50) '@id', ParameterValue nvarchar(3000) '@value' @@ -1776,7 +1776,7 @@ VALUES SET @ServerID = SCOPE_IDENTITY() -RETURN +RETURN @@ -1937,7 +1937,7 @@ ORDER BY RecordOrder COMMIT TRAN END -RETURN +RETURN @@ -2023,9 +2023,9 @@ BEGIN BEGIN INSERT INTO ServiceItems (PackageID, ItemTypeID,ServiceID,ItemName,CreatedDate) VALUES(1, @ItemTypeID, @ServiceID, 'System', @CreatedDate) - + DECLARE @TempItemID int - + SET @TempItemID = SCOPE_IDENTITY() INSERT INTO ExchangeOrganizations (ItemID, OrganizationID) VALUES(@TempItemID, 'System') @@ -2071,7 +2071,7 @@ SELECT @ItemID, PropertyName, PropertyValue -FROM OPENXML(@idoc, '/properties/property',1) WITH +FROM OPENXML(@idoc, '/properties/property',1) WITH ( PropertyName nvarchar(50) '@name', PropertyValue nvarchar(3000) '@value' @@ -2081,7 +2081,7 @@ FROM OPENXML(@idoc, '/properties/property',1) WITH exec sp_xml_removedocument @idoc COMMIT TRAN -RETURN +RETURN GO @@ -2091,7 +2091,7 @@ SET QUOTED_IDENTIFIER OFF GO -CREATE PROCEDURE [dbo].[AddSSLRequest] +CREATE PROCEDURE [dbo].[AddSSLRequest] ( @SSLID int OUTPUT, @ActorID int, @@ -2105,7 +2105,7 @@ CREATE PROCEDURE [dbo].[AddSSLRequest] @DistinguishedName nvarchar(500), @IsRenewal bit = 0, @PreviousId int = NULL - + ) AS @@ -2254,7 +2254,7 @@ VALUES SET @UserID = SCOPE_IDENTITY() -RETURN +RETURN GO SET ANSI_NULLS ON @@ -2321,7 +2321,7 @@ INSERT INTO VirtualServices SELECT @ServerID, ServiceID -FROM OPENXML(@idoc, '/services/service',1) WITH +FROM OPENXML(@idoc, '/services/service',1) WITH ( ServiceID int '@id' ) as XS @@ -2404,7 +2404,7 @@ BEGIN -- delete DELETE FROM PackageIPAddresses FROM PackageIPAddresses AS PIP - INNER JOIN OPENXML(@idoc, '/items/item', 1) WITH + INNER JOIN OPENXML(@idoc, '/items/item', 1) WITH ( AddressID int '@id' ) as PV ON PIP.AddressID = PV.AddressID @@ -2412,15 +2412,15 @@ BEGIN -- insert INSERT INTO dbo.PackageIPAddresses - ( + ( PackageID, - AddressID + AddressID ) - SELECT + SELECT @PackageID, AddressID - FROM OPENXML(@idoc, '/items/item', 1) WITH + FROM OPENXML(@idoc, '/items/item', 1) WITH ( AddressID int '@id' ) as PV @@ -2466,7 +2466,7 @@ GO -CREATE PROCEDURE [dbo].ChangeExchangeAcceptedDomainType +CREATE PROCEDURE [dbo].ChangeExchangeAcceptedDomainType ( @ItemID int, @DomainID int, @@ -2530,7 +2530,7 @@ UPDATE Users SET Password = @Password WHERE UserID = @UserID -RETURN +RETURN @@ -2588,13 +2588,13 @@ GO -CREATE PROCEDURE [dbo].[CheckBlackBerryUserExists] +CREATE PROCEDURE [dbo].[CheckBlackBerryUserExists] @AccountID int AS -BEGIN - SELECT +BEGIN + SELECT COUNT(AccountID) - FROM + FROM dbo.BlackBerryUsers WHERE AccountID = @AccountID END @@ -2691,7 +2691,7 @@ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER OFF GO -CREATE PROCEDURE [dbo].[CheckDomainUsedByHostedOrganization] +CREATE PROCEDURE [dbo].[CheckDomainUsedByHostedOrganization] @DomainName nvarchar(100), @Result int OUTPUT AS @@ -2710,7 +2710,7 @@ AS BEGIN SET @Result = 1 END - + RETURN @Result GO SET ANSI_NULLS ON @@ -2725,13 +2725,13 @@ GO -CREATE PROCEDURE [dbo].[CheckLyncUserExists] +CREATE PROCEDURE [dbo].[CheckLyncUserExists] @AccountID int AS -BEGIN - SELECT +BEGIN + SELECT COUNT(AccountID) - FROM + FROM dbo.LyncUsers WHERE AccountID = @AccountID END @@ -2750,13 +2750,13 @@ GO -CREATE PROCEDURE [dbo].[CheckOCSUserExists] +CREATE PROCEDURE [dbo].[CheckOCSUserExists] @AccountID int AS -BEGIN - SELECT +BEGIN + SELECT COUNT(AccountID) - FROM + FROM dbo.OCSUsers WHERE AccountID = @AccountID END @@ -2971,7 +2971,7 @@ GO CREATE PROCEDURE [dbo].[CheckSSL] ( @siteID int, - @Renewal bit = 0, + @Renewal bit = 0, @Result int OUTPUT ) AS @@ -3009,7 +3009,7 @@ GO CREATE PROCEDURE [dbo].[CheckSSLExistsForWebsite] ( - @siteID int, + @siteID int, @SerialNumber nvarchar(250), @Result bit OUTPUT ) @@ -3024,7 +3024,7 @@ AS SET @Result = 0 -- OK -- check if a SSL Certificate is installed for domain -IF EXISTS(SELECT [ID] FROM [dbo].[SSLCertificates] WHERE [SiteID] = @siteID +IF EXISTS(SELECT [ID] FROM [dbo].[SSLCertificates] WHERE [SiteID] = @siteID --AND SerialNumber=@SerialNumber ) BEGIN @@ -3131,18 +3131,18 @@ GO -CREATE PROCEDURE [dbo].[CompleteSSLRequest] +CREATE PROCEDURE [dbo].[CompleteSSLRequest] ( @ActorID int, @PackageID int, - @ID int, + @ID int, @Certificate ntext, @SerialNumber nvarchar(250), @Hash ntext, @DistinguishedName nvarchar(500), @ValidFrom datetime, @ExpiryDate datetime - + ) AS @@ -3156,16 +3156,16 @@ END -- insert record UPDATE [dbo].[SSLCertificates] -SET +SET [Certificate] = @Certificate, [Installed] = 1, [SerialNumber] = @SerialNumber, [DistinguishedName] = @DistinguishedName, [Hash] = @Hash, [ValidFrom] = @ValidFrom, - [ExpiryDate] = @ExpiryDate + [ExpiryDate] = @ExpiryDate WHERE - [ID] = @ID; + [ID] = @ID; @@ -3204,18 +3204,18 @@ GO CREATE PROCEDURE [dbo].[ConvertToExchangeOrganization] ( - @ItemID int + @ItemID int ) AS -UPDATE +UPDATE [dbo].[ServiceItems] -SET +SET [ItemTypeID] = 26 -WHERE +WHERE [ItemID] = @ItemID -RETURN +RETURN @@ -3357,7 +3357,7 @@ AS DELETE FROM Log -RETURN +RETURN @@ -3461,7 +3461,7 @@ AND ((@TaskName = '') OR (@TaskName <> '' AND TaskName = @TaskName)) AND ((@ItemID = 0) OR (@ItemID > 0 AND ItemID = @ItemID)) AND ((@ItemName = '') OR (@ItemName <> '' AND ItemName LIKE @ItemName)) -RETURN +RETURN @@ -3539,7 +3539,7 @@ AS TRUNCATE TABLE AuditLog -RETURN +RETURN @@ -3598,17 +3598,17 @@ GO CREATE PROCEDURE [dbo].[DeleteBlackBerryUser] -( +( @AccountID int ) AS -DELETE FROM +DELETE FROM BlackBerryUsers -WHERE +WHERE AccountID = @AccountID -RETURN +RETURN @@ -3637,12 +3637,12 @@ GO -CREATE PROCEDURE [dbo].[DeleteCertificate] +CREATE PROCEDURE [dbo].[DeleteCertificate] ( @ActorID int, @PackageID int, @id int - + ) AS @@ -3658,7 +3658,7 @@ DELETE FROM [dbo].[SSLCertificates] WHERE [ID] = @id - + RETURN @@ -4272,7 +4272,7 @@ GO -CREATE PROCEDURE [dbo].[DeleteExchangeOrganization] +CREATE PROCEDURE [dbo].[DeleteExchangeOrganization] ( @ItemID int ) @@ -4316,7 +4316,7 @@ GO -CREATE PROCEDURE DeleteExchangeOrganizationDomain +CREATE PROCEDURE DeleteExchangeOrganizationDomain ( @ItemID int, @DomainID int @@ -4769,17 +4769,17 @@ GO CREATE PROCEDURE [dbo].[DeleteLyncUser] -( +( @AccountId int ) AS -DELETE FROM +DELETE FROM LyncUsers -WHERE +WHERE AccountId = @AccountId -RETURN +RETURN GO SET ANSI_NULLS ON @@ -4816,17 +4816,17 @@ GO CREATE PROCEDURE [dbo].[DeleteOCSUser] -( +( @InstanceId nvarchar(50) ) AS -DELETE FROM +DELETE FROM OCSUsers -WHERE +WHERE InstanceId = @InstanceId -RETURN +RETURN @@ -4858,7 +4858,7 @@ GO CREATE PROCEDURE [dbo].[DeleteOrganizationUsers] - @ItemID int + @ItemID int AS BEGIN SET NOCOUNT ON; @@ -4976,7 +4976,7 @@ BEGIN WHERE PackageID = @PackageID COMMIT TRAN -END +END @@ -5269,7 +5269,7 @@ DELETE FROM VirtualServices WHERE ServerID = @ServerID COMMIT TRAN -RETURN +RETURN @@ -5381,7 +5381,7 @@ WHERE ServiceID = @ServiceID COMMIT TRAN -RETURN +RETURN @@ -5482,7 +5482,7 @@ WHERE ItemID = @ItemID COMMIT TRAN -RETURN +RETURN GO @@ -5526,7 +5526,7 @@ IF (@@ERROR <> 0 ) RETURN -1 END ---delete reseller addon +--delete reseller addon DELETE FROM HostingPlans WHERE UserID = @UserID AND IsAddon = 'True' IF (@@ERROR <> 0 ) @@ -5608,14 +5608,14 @@ GO -- ============================================= -- Description: Delete user email addresses except primary email -- ============================================= -CREATE PROCEDURE [dbo].[DeleteUserEmailAddresses] +CREATE PROCEDURE [dbo].[DeleteUserEmailAddresses] @AccountId int, @PrimaryEmailAddress nvarchar(300) AS BEGIN - -DELETE FROM - ExchangeAccountEmailAddresses + +DELETE FROM + ExchangeAccountEmailAddresses WHERE AccountID = @AccountID AND LOWER(EmailAddress) <> LOWER(@PrimaryEmailAddress) END @@ -5710,7 +5710,7 @@ DELETE FROM VirtualServices WHERE ServiceID IN ( SELECT ServiceID -FROM OPENXML(@idoc, '/services/service',1) WITH +FROM OPENXML(@idoc, '/services/service',1) WITH ( ServiceID int '@id' ) as XS) @@ -5795,7 +5795,7 @@ SELECT END FROM ResourceGroups AS RG WHERE dbo.GetPackageAllocatedResource(@PackageID, RG.GroupID, NULL) = 1 -AND RG.GroupID NOT IN +AND RG.GroupID NOT IN ( SELECT P.GroupID FROM PackageServices AS PS @@ -5821,7 +5821,7 @@ END ELSE BEGIN -- VIRTUAL SERVER - + DECLARE @GroupID int, @PrimaryGroup int DECLARE GroupsCursor CURSOR FOR SELECT GroupID, PrimaryGroup FROM @Groups @@ -5839,7 +5839,7 @@ BEGIN DEALLOCATE GroupsCursor BREAK END - + -- read group information DECLARE @DistributionType int, @BindDistributionToPrimary int SELECT @@ -5847,11 +5847,11 @@ BEGIN @BindDistributionToPrimary = BindDistributionToPrimary FROM VirtualGroups AS VG WHERE ServerID = @ServerID AND GroupID = @GroupID - + -- bind distribution to primary IF @BindDistributionToPrimary = 1 AND @PrimaryGroup = 0 AND @PrimaryGroupID <> 0 BEGIN - -- if only one service found just use it and do not distribute + -- if only one service found just use it and do not distribute IF (SELECT COUNT(*) FROM VirtualServices AS VS INNER JOIN Services AS S ON VS.ServiceID = S.ServiceID INNER JOIN Providers AS P ON S.ProviderID = P.ProviderID @@ -5876,7 +5876,7 @@ BEGIN INNER JOIN Services AS S ON PS.ServiceID = S.ServiceID INNER JOIN Providers AS P ON S.ProviderID = P.ProviderID WHERE PS.PackageID = @PackageID AND P.GroupID = @PrimaryGroupID - + INSERT INTO PackageServices (PackageID, ServiceID) SELECT @PackageID, @@ -5889,7 +5889,7 @@ BEGIN END ELSE BEGIN - + -- DISTRIBUTION DECLARE @Services TABLE ( @@ -5897,9 +5897,9 @@ BEGIN ItemsNumber int, RandomNumber int ) - + DELETE FROM @Services - + INSERT INTO @Services (ServiceID, ItemsNumber, RandomNumber) SELECT VS.ServiceID, @@ -5909,7 +5909,7 @@ BEGIN INNER JOIN Services AS S ON VS.ServiceID = S.ServiceID INNER JOIN Providers AS P ON S.ProviderID = P.ProviderID WHERE VS.ServerID = @ServerID AND P.GroupID = @GroupID - + -- BALANCED DISTRIBUTION IF @DistributionType = 1 BEGIN @@ -5933,12 +5933,12 @@ BEGIN ORDER BY RandomNumber END END - + IF @PrimaryGroup = 1 SET @PrimaryGroupID = @GroupID END -- while groups - + END -- end virtual server RETURN @@ -6010,7 +6010,7 @@ GO -CREATE PROCEDURE [dbo].[ecAddBillingCycle] +CREATE PROCEDURE [dbo].[ecAddBillingCycle] @ActorID int, @UserID int, @CycleName nvarchar(255), @@ -6126,7 +6126,7 @@ GO -CREATE PROCEDURE [dbo].[ecAddCategory] +CREATE PROCEDURE [dbo].[ecAddCategory] @ActorID int, @UserID int, @CategoryName nvarchar(255), @@ -6150,7 +6150,7 @@ BEGIN IF @ParentID = -1 SET @ParentID = NULL; - + -- identify category level SELECT @Level = [Level] FROM [dbo].[ecCategory] WHERE [CategoryID] = @ParentID AND [ResellerID] = @UserID; IF @Level >= 0 @@ -6169,7 +6169,7 @@ BEGIN [CreatorID], [ResellerID] ) - VALUES + VALUES ( @CategoryName, @CategorySku, @@ -6341,7 +6341,7 @@ GO CREATE PROCEDURE [dbo].[ecAddCustomerPayment] - @ActorID int, + @ActorID int, @ContractID nvarchar(50), @InvoiceID int, @TransactionID nvarchar(255), @@ -6364,7 +6364,7 @@ BEGIN RAISERROR('You are not allowed to perform this action', 16, 1); RETURN; END - + SET NOCOUNT ON; INSERT INTO [dbo].[ecCustomersPayments] @@ -6449,7 +6449,7 @@ GO -CREATE PROCEDURE [dbo].[ecAddDomainNameSvc] +CREATE PROCEDURE [dbo].[ecAddDomainNameSvc] @ContractID nvarchar(50), @ParentID int, @ProductID int, @@ -6466,7 +6466,7 @@ BEGIN @ResellerID = [ResellerID] FROM [dbo].[ecContracts] WHERE [ContractID] = @ContractID; - + BEGIN TRAN ADD_TLD_SVC -- add service INSERT INTO [dbo].[ecService] @@ -6707,7 +6707,7 @@ XML Format: [dbo].[ecHostingAddons] SET [SetupFee] = [SXML].[Data].value('@SetupFee','money'), - [OneTimeFee] = [SXML].[Data].value('@RecurringFee','money') + [OneTimeFee] = [SXML].[Data].value('@RecurringFee','money') FROM @AddonCyclesXml.nodes('/PlanCycles/Cycle') [SXML]([Data]) WHERE @@ -6738,15 +6738,15 @@ XML Format: END -- COMMIT TRAN ADD_ADDON; - -- + -- RETURN; - + ERROR_HANDLE: BEGIN SET @Result = -1; ROLLBACK TRAN ADD_ADDON; - RETURN; + RETURN; END END @@ -7222,7 +7222,7 @@ BEGIN TRAN ADD_HPLAN_SVC GOTO ERROR_HANDLE; -- obtain result SET @SvcCycleID = SCOPE_IDENTITY(); - + -- add plan details INSERT INTO [dbo].[ecHostingPackageSvcs] ( @@ -7249,7 +7249,7 @@ BEGIN TRAN ADD_HPLAN_SVC -- check error IF @@ROWCOUNT = 0 GOTO ERROR_HANDLE; - + -- commit tran COMMIT TRAN ADD_HPLAN_SVC; @@ -7315,7 +7315,7 @@ GO -CREATE PROCEDURE [dbo].[ecAddInvoice] +CREATE PROCEDURE [dbo].[ecAddInvoice] @ContractID nvarchar(50), @Created datetime, @DueDate datetime, @@ -7351,7 +7351,7 @@ BEGIN TRAN ADD_INVOICE --Create an internal representation of the XML document. EXEC sp_xml_preparedocument @XmlDocID OUTPUT, @Xml;; - -- + -- INSERT INTO [dbo].[ecInvoiceItems] ( [InvoiceID], @@ -7365,7 +7365,7 @@ BEGIN TRAN ADD_INVOICE ) SELECT @Result, - CASE [XML].[ServiceID] + CASE [XML].[ServiceID] WHEN 0 THEN NULL ELSE [XML].[ServiceID] END, @@ -7375,7 +7375,7 @@ BEGIN TRAN ADD_INVOICE [XML].[Total], [XML].[SubTotal], [XML].[UnitPrice] - FROM OPENXML(@XmlDocID, '/items/item',1) WITH + FROM OPENXML(@XmlDocID, '/items/item',1) WITH ( [ServiceID] int '@serviceid', [ItemName] nvarchar(255) '@itemname', @@ -7545,7 +7545,7 @@ CREATE PROCEDURE [dbo].[ecAddServiceUsageRecord] @Result int OUTPUT AS BEGIN - + -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; @@ -7566,7 +7566,7 @@ BEGIN @StartDate, @EndDate ); - + END @@ -7632,7 +7632,7 @@ BEGIN -- interfering with SELECT statements. SET NOCOUNT ON; - IF NOT EXISTS(SELECT * FROM [dbo].[ecSystemTriggers] WHERE [OwnerID] = @OwnerID AND + IF NOT EXISTS(SELECT * FROM [dbo].[ecSystemTriggers] WHERE [OwnerID] = @OwnerID AND [TriggerHandler] = @TriggerHandler AND [ReferenceID] = @ReferenceID AND [Namespace] = @Namespace AND [Status] = @Status) BEGIN @@ -7711,7 +7711,7 @@ BEGIN -- interfering with SELECT statements. SET NOCOUNT ON; -- check before insert - IF EXISTS (SELECT [TaxationID] FROM [dbo].[ecTaxations] + IF EXISTS (SELECT [TaxationID] FROM [dbo].[ecTaxations] WHERE [ResellerID] = @UserID AND [Country] = @Country AND [State] = @State) BEGIN SET @Result = -202; @@ -7741,7 +7741,7 @@ BEGIN ); -- SET @Result = SCOPE_IDENTITY(); - + END @@ -7906,7 +7906,7 @@ XML Format: GOTO ERROR_HANDLE; -- COMMIT TRAN ADD_DOMAIN; - -- + -- RETURN; ERROR_HANDLE: @@ -8112,7 +8112,7 @@ BEGIN TRAN CHNG_SVC_CYCLE GOTO ERROR_HANDLE; -- obtain result SET @Result = SCOPE_IDENTITY(); - + -- update service UPDATE [dbo].[ecHostingPackageSvcs] @@ -8128,7 +8128,7 @@ BEGIN TRAN CHNG_SVC_CYCLE COMMIT TRAN CHNG_SVC_CYCLE; -- exit RETURN; - + -- error handler ERROR_HANDLE: BEGIN @@ -8363,7 +8363,7 @@ GO -CREATE PROCEDURE [dbo].[ecDeleteCategory] +CREATE PROCEDURE [dbo].[ecDeleteCategory] @ActorID int, @UserID int, @CategoryID int, @@ -8381,7 +8381,7 @@ BEGIN SET @Result = 0; - -- check whether the category doesn't empty + -- check whether the category doesn't empty IF EXISTS( SELECT [ProductID] @@ -8417,8 +8417,8 @@ BEGIN DELETE FROM [dbo].[ecCategory] WHERE - [CategoryID] = @CategoryID - AND + [CategoryID] = @CategoryID + AND [ResellerID] = @UserID; END @@ -8505,7 +8505,7 @@ BEGIN SET @Result = -1; RETURN; END - + SET @Result = 0; DELETE FROM [dbo].[ecContracts] WHERE [ContractID] = @ContractID; @@ -8590,7 +8590,7 @@ BEGIN SET @Result = 0; DELETE - FROM [dbo].[ecCustomersPayments] + FROM [dbo].[ecCustomersPayments] WHERE [PaymentID] = @PaymentID; @@ -8754,10 +8754,10 @@ BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; - -- + -- SET @Result = 0; -- remove - DELETE FROM [dbo].[ecPaymentMethods] + DELETE FROM [dbo].[ecPaymentMethods] WHERE [ResellerID] = @UserID AND [MethodName] = @MethodName; END @@ -8911,7 +8911,7 @@ GO -CREATE PROCEDURE [dbo].[ecDeleteProduct] +CREATE PROCEDURE [dbo].[ecDeleteProduct] @ActorID int, @UserID int, @ProductID int, @@ -8926,7 +8926,7 @@ BEGIN RETURN; END -BEGIN TRAN RMV_PRODUCT +BEGIN TRAN RMV_PRODUCT -- remove product DELETE FROM [dbo].[ecProduct] WHERE [ProductID] = @ProductID AND [ResellerID] = @UserID; -- check errors @@ -9197,13 +9197,13 @@ GO -CREATE PROCEDURE [dbo].[ecGetAddonProducts] +CREATE PROCEDURE [dbo].[ecGetAddonProducts] @UserID int, @ProductID int AS BEGIN - SELECT + SELECT [P].* FROM [dbo].[ecProduct] AS [P] @@ -9292,8 +9292,8 @@ CREATE PROCEDURE [dbo].[ecGetAddonProductsIds] @ProductID int AS BEGIN - - SELECT + + SELECT [P].[ProductID] FROM [dbo].[ecProduct] AS [P] @@ -9302,7 +9302,7 @@ BEGIN WHERE [ATP].[AddonID] = @ProductID AND - [P].[ResellerID] = @UserID; + [P].[ResellerID] = @UserID; END @@ -9644,7 +9644,7 @@ CREATE PROCEDURE [dbo].[ecGetBillingCyclesPaged] @StartRowIndex int AS BEGIN - + -- check actor user rights IF [dbo].[CheckUserParent](@ActorID, @UserID) = 0 BEGIN @@ -9864,7 +9864,7 @@ AS SELECT ROW_NUMBER() OVER(ORDER BY [Created] DESC) AS [RowIndex], * - FROM + FROM [dbo].[ecCategory] WHERE [ParentID] = @ParentID @@ -9880,7 +9880,7 @@ AS SELECT ROW_NUMBER() OVER(ORDER BY [Created] DESC) AS [RowIndex], * - FROM + FROM [dbo].[ecCategory] WHERE [ParentID] IS NULL @@ -9890,7 +9890,7 @@ AS SELECT * FROM [CategoryCTE] WHERE [RowIndex] BETWEEN @StartRowIndex AND @EndIndex ORDER BY [CategoryID], [CategoryName]; END - + RETURN @@ -9965,7 +9965,7 @@ GO -CREATE PROCEDURE [dbo].[ecGetCategory] +CREATE PROCEDURE [dbo].[ecGetCategory] @ActorID int, @UserID int, @CategoryID int @@ -9974,13 +9974,13 @@ BEGIN SET NOCOUNT ON; - SELECT + SELECT * - FROM - [dbo].[ecCategory] - WHERE - [CategoryID] = @CategoryID - AND + FROM + [dbo].[ecCategory] + WHERE + [CategoryID] = @CategoryID + AND [ResellerID] = @UserID; END @@ -10250,7 +10250,7 @@ GO -CREATE PROCEDURE [dbo].[ecGetCustomerInvoiceItems] +CREATE PROCEDURE [dbo].[ecGetCustomerInvoiceItems] @ActorID int, @InvoiceID int AS @@ -10337,7 +10337,7 @@ BEGIN @ContractID = [ContractID] FROM [dbo].[ecCustomersPayments] WHERE [PaymentID] = @PaymentID; - + SET NOCOUNT ON; SELECT @@ -10501,7 +10501,7 @@ BEGIN [ResellerID] = @UserID; RETURN; END - + SELECT @Result = COUNT([InvoiceID]) FROM [dbo].[ContractsInvoicesDetailed] WHERE @@ -10598,7 +10598,7 @@ BEGIN RETURN; END; - + -- get customer invoices WITH [INVOICES] AS ( SELECT @@ -10607,7 +10607,7 @@ BEGIN [CustomerID] = @UserID ) - SELECT * FROM [INVOICES] + SELECT * FROM [INVOICES] WHERE [RowIndex] BETWEEN @StartRowIndex AND @EndIndex ORDER BY [Created] DESC; @@ -10787,7 +10787,7 @@ BEGIN WHERE [C].[ResellerID] = @UserID ) - + SELECT [P].*, [INV].[InvoiceNumber], [SP].[DisplayName] AS [ProviderName] FROM [PAYMENTS] AS [P] LEFT OUTER JOIN @@ -10795,13 +10795,13 @@ BEGIN LEFT OUTER JOIN [dbo].[ecInvoice] AS [INV] ON [INV].[InvoiceID] = [P].[InvoiceID] WHERE - [RowIndex] BETWEEN @StartRowIndex AND @EndIndex + [RowIndex] BETWEEN @StartRowIndex AND @EndIndex ORDER BY [Created] DESC; - + RETURN; END; - + WITH [PAYMENTS] AS ( SELECT ROW_NUMBER() OVER(ORDER BY [CP].[Created] DESC) AS [RowIndex], [CP].* FROM [dbo].[ecCustomersPayments] AS [CP] @@ -10810,15 +10810,15 @@ BEGIN WHERE [C].[CustomerID] = @UserID ) - + SELECT [P].*, [INV].[InvoiceNumber], [SP].[DisplayName] AS [ProviderName] FROM [PAYMENTS] AS [P] LEFT OUTER JOIN [dbo].[ecSupportedPlugins] AS [SP] ON [SP].[PluginID] = [P].[PluginID] LEFT OUTER JOIN - [dbo].[ecInvoice] AS [INV] ON [INV].[InvoiceID] = [P].[InvoiceID] + [dbo].[ecInvoice] AS [INV] ON [INV].[InvoiceID] = [P].[InvoiceID] WHERE - [RowIndex] BETWEEN @StartRowIndex AND @EndIndex + [RowIndex] BETWEEN @StartRowIndex AND @EndIndex ORDER BY [Created] DESC; @@ -10899,7 +10899,7 @@ BEGIN [ResellerID] = @UserID; RETURN; END - + SELECT @Result = COUNT([ServiceID]) FROM [dbo].[ContractsServicesDetailed] WHERE @@ -10996,7 +10996,7 @@ BEGIN -- exit RETURN; END; - + WITH [SERVICES] AS ( SELECT ROW_NUMBER() OVER(ORDER BY [Created] DESC) AS [RowIndex], * FROM [dbo].[ContractsServicesDetailed] @@ -11081,7 +11081,7 @@ BEGIN * FROM [dbo].[ecTaxations] - WHERE + WHERE [ResellerID] = @ResellerID AND ([Country] = @Country OR [Country] = '*') @@ -11252,7 +11252,7 @@ GO -CREATE PROCEDURE [dbo].[ecGetDomainNameSvcHistory] +CREATE PROCEDURE [dbo].[ecGetDomainNameSvcHistory] @ActorID int, @ServiceID int AS @@ -11787,7 +11787,7 @@ GO -CREATE PROCEDURE [dbo].[ecGetHostingPackageSvc] +CREATE PROCEDURE [dbo].[ecGetHostingPackageSvc] @ActorID int, @ServiceID int AS @@ -11808,7 +11808,7 @@ BEGIN RETURN; END - -- + -- SET NOCOUNT ON; SELECT @@ -12275,7 +12275,7 @@ BEGIN AND [CP].[StatusID] = 1 -- Approved payments only ) - SELECT * FROM [dbo].[ecInvoiceItems] + SELECT * FROM [dbo].[ecInvoiceItems] WHERE [ServiceID] IS NOT NULL AND [InvoiceID] IN ( SELECT [InvoiceID] FROM [OVERDUE_INVOICES] @@ -12362,7 +12362,7 @@ BEGIN * FROM [dbo].[ecInvoiceItems] WHERE [ServiceID] IS NOT NULL AND [Processed] = 0 AND [InvoiceID] IN (SELECT [InvoiceID] FROM [PAID_INVOICES]); - + END @@ -12442,7 +12442,7 @@ BEGIN -- interfering with SELECT statements. SET NOCOUNT ON; - SELECT * FROM [dbo].[ecPaymentMethods] + SELECT * FROM [dbo].[ecPaymentMethods] WHERE [MethodName] = @MethodName AND [ResellerID] = @UserID; END @@ -12798,7 +12798,7 @@ CREATE PROCEDURE [dbo].[ecGetProductCategoriesIds] AS BEGIN - SELECT [CategoryID] FROM [dbo].[ecProductCategories] WHERE [ResellerID] = @UserID AND [ProductID] = @ProductID; + SELECT [CategoryID] FROM [dbo].[ecProductCategories] WHERE [ResellerID] = @UserID AND [ProductID] = @ProductID; END @@ -12874,7 +12874,7 @@ CREATE PROCEDURE [dbo].[ecGetProductHighlights] @ProductID int AS BEGIN - + SELECT [PH].[HighlightText] FROM @@ -12960,7 +12960,7 @@ GO -CREATE PROCEDURE [dbo].[ecGetProductsByType] +CREATE PROCEDURE [dbo].[ecGetProductsByType] @UserID int, @TypeID int AS @@ -13145,7 +13145,7 @@ BEGIN SELECT ROW_NUMBER() OVER(ORDER BY [Created] DESC) AS [RowIndex], * - FROM + FROM [dbo].[ecProduct] WHERE [ResellerID] = @UserID @@ -13740,7 +13740,7 @@ BEGIN -- interfering with SELECT statements. SET NOCOUNT ON; - SELECT + SELECT * FROM [ServiceHandlersResponsesDetailed] WHERE [ResellerID] = @ResellerID AND [ErrorMessage] IS NULL @@ -13800,7 +13800,7 @@ CREATE PROCEDURE [dbo].[ecGetServiceItemType] @ServiceID int AS BEGIN - + SELECT [PT].* FROM [dbo].[ecProductType] AS [PT] INNER JOIN @@ -13861,7 +13861,7 @@ GO -CREATE PROCEDURE [dbo].[ecGetServicesToInvoice] +CREATE PROCEDURE [dbo].[ecGetServicesToInvoice] @ActorID int, @ResellerID int, @TodayDate datetime, @@ -13904,7 +13904,7 @@ BEGIN INNER JOIN @Svcs AS [SVCS] ON [S].[ServiceID] = [SVCS].[ServiceID] WHERE - [S].[Status] = 1 AND @DaysOffset >= DATEDIFF(d, @TodayDate, [SVCS].[MaxEndDate]) + [S].[Status] = 1 AND @DaysOffset >= DATEDIFF(d, @TodayDate, [SVCS].[MaxEndDate]) ORDER BY [ContractID]; @@ -14519,13 +14519,13 @@ BEGIN SET NOCOUNT ON; - SELECT + SELECT * - FROM + FROM [dbo].[ecProduct] - WHERE - [ProductID] = @ProductID - AND + WHERE + [ProductID] = @ProductID + AND [ResellerID] = @ResellerID AND [Enabled] = 1; @@ -14607,9 +14607,9 @@ CREATE PROCEDURE [dbo].[ecGetStorefrontProductsByType] AS BEGIN - SELECT + SELECT * - FROM + FROM [dbo].[ecProduct] WHERE [ResellerID] = @UserID @@ -14872,7 +14872,7 @@ GO -CREATE PROCEDURE [dbo].[ecGetSupportedPlugin] +CREATE PROCEDURE [dbo].[ecGetSupportedPlugin] @PluginName nvarchar(50), @GroupName nvarchar(50) AS @@ -15032,7 +15032,7 @@ CREATE PROCEDURE [dbo].[ecGetSupportedPluginsByGroup] AS BEGIN - SELECT * FROM [dbo].[ecSupportedPlugins] + SELECT * FROM [dbo].[ecSupportedPlugins] WHERE [PluginGroup] = @GroupName ORDER BY [DisplayName]; @@ -15117,8 +15117,8 @@ BEGIN [C].[ResellerID] = @ResellerID AND [S].[ServiceID] IN (SELECT [SXML].[Data].value('@id','int') FROM @SvcsXml.nodes('/Svcs/Svc') [SXML]([Data])); - - -- result is empty + + -- result is empty SET @Result = ISNULL(@Result, @DefaultValue); END @@ -15641,7 +15641,7 @@ BEGIN AND [TLDC].[ProductID] = @ProductID ORDER BY - [TLDC].[SortOrder]; + [TLDC].[SortOrder]; END @@ -15722,7 +15722,7 @@ BEGIN SELECT ROW_NUMBER() OVER(ORDER BY [Created] DESC) AS [RowIndex], * - FROM + FROM [dbo].[ecProduct] WHERE [ResellerID] = @UserID @@ -15730,7 +15730,7 @@ BEGIN [TypeID] = 3 -- Top Level Domain ) - SELECT + SELECT [TldsCTE].*, [Tlds].[PluginId], [PLG].[DisplayName] @@ -15746,7 +15746,7 @@ BEGIN [PLG].[PluginID] = [Tlds].[PluginID] WHERE [TldsCTE].[RowIndex] BETWEEN @StartRowIndex AND @EndIndex; - + END @@ -16009,7 +16009,7 @@ BEGIN -- interfering with SELECT statements. SET NOCOUNT ON; - IF EXISTS(SELECT * FROM [dbo].[ecPluginsProperties] + IF EXISTS(SELECT * FROM [dbo].[ecPluginsProperties] WHERE [ResellerID] = @ResellerID AND [PluginID] = @PluginID) BEGIN SET @Active = 1; @@ -16576,7 +16576,7 @@ XML Format: --Create an internal representation of the XML document. EXEC sp_xml_preparedocument @XmlDocID OUTPUT, @xml; -- cleanup - DELETE FROM [dbo].[ecPluginsProperties] + DELETE FROM [dbo].[ecPluginsProperties] WHERE [ResellerID] = @UserID AND [PluginID] = @PluginID; -- insert INSERT INTO [dbo].[ecPluginsProperties] @@ -16591,7 +16591,7 @@ XML Format: @UserID, [XML].[PropertyName], [XML].[PropertyValue] - FROM OPENXML(@XmlDocID, '/properties/property',1) WITH + FROM OPENXML(@XmlDocID, '/properties/property',1) WITH ( [PropertyName] nvarchar(50) '@name', [PropertyValue] ntext '@value' @@ -16668,7 +16668,7 @@ GO -CREATE PROCEDURE [dbo].[ecSetStoreSettings] +CREATE PROCEDURE [dbo].[ecSetStoreSettings] @ActorID int, @UserID int, @SettingsName nvarchar(50), @@ -16698,7 +16698,7 @@ XML Format: EXEC sp_xml_preparedocument @docid OUTPUT, @Xml; -- cleanup - DELETE FROM [dbo].[ecStoreSettings] + DELETE FROM [dbo].[ecStoreSettings] WHERE [SettingsName] = @SettingsName AND [ResellerID] = @UserID; INSERT INTO [dbo].[ecStoreSettings] @@ -16713,7 +16713,7 @@ XML Format: @SettingsName, [XML].[PropertyName], [XML].[PropertyValue] - FROM OPENXML(@docid, '/settings/setting', 1) WITH + FROM OPENXML(@docid, '/settings/setting', 1) WITH ( [PropertyName] nvarchar(50) '@name', [PropertyValue] ntext '@value' @@ -16721,7 +16721,7 @@ XML Format: -- remove document EXEC sp_xml_removedocument @docid; - + END @@ -16972,7 +16972,7 @@ GO -CREATE PROCEDURE [dbo].[ecUpdateCategory] +CREATE PROCEDURE [dbo].[ecUpdateCategory] @ActorID int, @UserID int, @CategoryID int, @@ -17066,9 +17066,9 @@ BEGIN END -- update a category - UPDATE + UPDATE [dbo].[ecCategory] - SET + SET [CategoryName] = @CategoryName, [CategorySku] = @CategorySku, [ParentID] = @ParentID, @@ -17077,9 +17077,9 @@ BEGIN [FullDescription] = @FullDescription, [Modified] = GETUTCDATE(), [ModifierID] = @ActorID - WHERE - [CategoryID] = @CategoryID - AND + WHERE + [CategoryID] = @CategoryID + AND [ResellerID] = @UserID; END @@ -17172,7 +17172,7 @@ BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; - + SET @Result = 0; IF @CustomerID < 1 @@ -17541,7 +17541,7 @@ XML Format: */ -- cleanup hosting addon cycles first DELETE FROM [dbo].[ecHostingAddonsCycles] WHERE [ProductID] = @ProductID; - + IF @Recurring = 1 -- insert cycles INSERT INTO [dbo].[ecHostingAddonsCycles] @@ -17586,22 +17586,22 @@ XML Format: FROM @AssignedProductsXml.nodes('/AssignedProducts/Product') [SXML]([Data]); -- check errors IF @@ERROR <> 0 - GOTO ERROR_HANDLE; + GOTO ERROR_HANDLE; -- set result ok SET @Result = 0; -- COMMIT TRAN UPDATE_ADDON; - -- + -- RETURN; - + ERROR_HANDLE: BEGIN SET @Result = -1; ROLLBACK TRAN UPDATE_ADDON; RETURN; - + END END @@ -17730,7 +17730,7 @@ BEGIN SET @Result = -1; ROLLBACK TRAN UPD_HADDON_SVC; RETURN; -END +END END @@ -18088,7 +18088,7 @@ GO -CREATE PROCEDURE [dbo].[ecUpdateInvoice] +CREATE PROCEDURE [dbo].[ecUpdateInvoice] @ActorID int, @InvoiceID int, @InvoiceNumber nvarchar(50), @@ -18190,7 +18190,7 @@ GO -CREATE PROCEDURE [dbo].[ecUpdateServiceHandlersResponses] +CREATE PROCEDURE [dbo].[ecUpdateServiceHandlersResponses] @ResellerID int, @XmlData xml AS @@ -18212,7 +18212,7 @@ BEGIN WHERE [ResponseID] IN (SELECT [SXML].[Data].value('@ID','int') FROM @XmlData.nodes('/Succeed/Response') [SXML]([Data])) - UPDATE + UPDATE [ecServiceHandlersResponses] SET [ErrorMessage] = [SXML].[Data].value('@Error','nvarchar(255)') @@ -18389,7 +18389,7 @@ BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; - + -- DECLARE @T_TaxationID int; -- @@ -18421,7 +18421,7 @@ BEGIN -- taxation update error SET @Result = -202; - + END @@ -18574,7 +18574,7 @@ XML Format: SET @Result = 0; -- COMMIT TRAN UPDATE_DOMAIN; - -- + -- RETURN; ERROR_HANDLE: @@ -18658,7 +18658,7 @@ BEGIN RAISERROR('You are not allowed to access the contract', 16, 1); RETURN; END - -- + -- SET NOCOUNT ON; -- void invoice DELETE FROM [dbo].[ecInvoice] WHERE [InvoiceID] = @InvoiceID; @@ -18812,7 +18812,7 @@ GO -CREATE PROCEDURE [dbo].[ExchangeAccountExists] +CREATE PROCEDURE [dbo].[ExchangeAccountExists] ( @AccountName nvarchar(20), @Exists bit OUTPUT @@ -18860,7 +18860,7 @@ GO -CREATE PROCEDURE ExchangeOrganizationDomainExists +CREATE PROCEDURE ExchangeOrganizationDomainExists ( @DomainID int, @Exists bit OUTPUT @@ -19131,7 +19131,7 @@ SELECT L.TaskName, L.ItemName, L.ExecutionLog, - + ISNULL(L.UserID, 0) AS UserID, L.Username, U.FirstName, @@ -19142,7 +19142,7 @@ SELECT FROM AuditLog AS L LEFT OUTER JOIN UsersDetailed AS U ON L.UserID = U.UserID WHERE RecordID = @RecordID -RETURN +RETURN @@ -19229,7 +19229,7 @@ IF @TaskName IS NULL SET @TaskName = '' IF @ItemName IS NULL SET @ItemName = '' IF @SortColumn IS NULL OR @SortColumn = '' -SET @SortColumn = 'L.StartDate DESC' +SET @SortColumn = 'L.StartDate DESC' -- build query and run it to the temporary table DECLARE @sql nvarchar(2000) @@ -19542,7 +19542,7 @@ WHERE ServiceID NOT IN (SELECT ServiceID FROM VirtualServices WHERE ServerID = @ServerID) AND @IsAdmin = 1 -RETURN +RETURN @@ -19606,7 +19606,7 @@ CREATE PROCEDURE [dbo].[GetBlackBerryUsers] @Name nvarchar(400), @Email nvarchar(400), @StartRow int, - @Count int + @Count int ) AS @@ -19620,84 +19620,84 @@ BEGIN SET @Email = '%' END -CREATE TABLE #TempBlackBerryUsers -( +CREATE TABLE #TempBlackBerryUsers +( [ID] [int] IDENTITY(1,1) NOT NULL, - [AccountID] [int], + [AccountID] [int], [ItemID] [int] NOT NULL, [AccountName] [nvarchar](300) NOT NULL, [DisplayName] [nvarchar](300) NOT NULL, [PrimaryEmailAddress] [nvarchar](300) NULL, - [SamAccountName] [nvarchar](100) NULL + [SamAccountName] [nvarchar](100) NULL ) IF (@SortColumn = 'DisplayName') BEGIN - INSERT INTO - #TempBlackBerryUsers - SELECT + INSERT INTO + #TempBlackBerryUsers + SELECT ea.AccountID, ea.ItemID, ea.AccountName, ea.DisplayName, ea.PrimaryEmailAddress, - ea.SamAccountName - FROM - ExchangeAccounts ea - INNER JOIN - BlackBerryUsers bu - ON + ea.SamAccountName + FROM + ExchangeAccounts ea + INNER JOIN + BlackBerryUsers bu + ON ea.AccountID = bu.AccountID - WHERE - ea.ItemID = @ItemID AND ea.DisplayName LIKE @Name AND ea.PrimaryEmailAddress LIKE @Email - ORDER BY + WHERE + ea.ItemID = @ItemID AND ea.DisplayName LIKE @Name AND ea.PrimaryEmailAddress LIKE @Email + ORDER BY ea.DisplayName END ELSE BEGIN - INSERT INTO + INSERT INTO #TempBlackBerryUsers - SELECT + SELECT ea.AccountID, ea.ItemID, ea.AccountName, ea.DisplayName, ea.PrimaryEmailAddress, - ea.SamAccountName - FROM - ExchangeAccounts ea - INNER JOIN - BlackBerryUsers bu - ON + ea.SamAccountName + FROM + ExchangeAccounts ea + INNER JOIN + BlackBerryUsers bu + ON ea.AccountID = bu.AccountID - WHERE - ea.ItemID = @ItemID AND ea.DisplayName LIKE @Name AND ea.PrimaryEmailAddress LIKE @Email - ORDER BY - ea.PrimaryEmailAddress + WHERE + ea.ItemID = @ItemID AND ea.DisplayName LIKE @Name AND ea.PrimaryEmailAddress LIKE @Email + ORDER BY + ea.PrimaryEmailAddress END DECLARE @RetCount int -SELECT @RetCount = COUNT(ID) FROM #TempBlackBerryUsers +SELECT @RetCount = COUNT(ID) FROM #TempBlackBerryUsers IF (@SortDirection = 'ASC') BEGIN - SELECT * FROM #TempBlackBerryUsers - WHERE ID > @StartRow AND ID <= (@StartRow + @Count) + SELECT * FROM #TempBlackBerryUsers + WHERE ID > @StartRow AND ID <= (@StartRow + @Count) END ELSE BEGIN IF (@SortColumn = 'DisplayName') BEGIN - SELECT * FROM #TempBlackBerryUsers + SELECT * FROM #TempBlackBerryUsers WHERE ID >@RetCount - @Count - @StartRow AND ID <= @RetCount- @StartRow ORDER BY DisplayName DESC END ELSE BEGIN - SELECT * FROM #TempBlackBerryUsers + SELECT * FROM #TempBlackBerryUsers WHERE ID >@RetCount - @Count - @StartRow AND ID <= @RetCount- @StartRow ORDER BY PrimaryEmailAddress DESC END - + END @@ -19722,12 +19722,12 @@ GO -CREATE PROCEDURE [dbo].[GetBlackBerryUsersCount] +CREATE PROCEDURE [dbo].[GetBlackBerryUsersCount] ( @ItemID int, @Name nvarchar(400), @Email nvarchar(400) - + ) AS @@ -19741,16 +19741,16 @@ BEGIN SET @Email = '%' END -SELECT - COUNT(ea.AccountID) -FROM - ExchangeAccounts ea -INNER JOIN - BlackBerryUsers bu -ON +SELECT + COUNT(ea.AccountID) +FROM + ExchangeAccounts ea +INNER JOIN + BlackBerryUsers bu +ON ea.AccountID = bu.AccountID -WHERE - ea.ItemID = @ItemID AND ea.DisplayName LIKE @Name AND ea.PrimaryEmailAddress LIKE @Email +WHERE + ea.ItemID = @ItemID AND ea.DisplayName LIKE @Name AND ea.PrimaryEmailAddress LIKE @Email @@ -19793,8 +19793,8 @@ BEGIN END SELECT - [ID], [UserID], [SiteID], [FriendlyName], [Hostname], [DistinguishedName], - [CSR], [CSRLength], [ValidFrom], [ExpiryDate], [Installed], [IsRenewal], + [ID], [UserID], [SiteID], [FriendlyName], [Hostname], [DistinguishedName], + [CSR], [CSRLength], [ValidFrom], [ExpiryDate], [Installed], [IsRenewal], [PreviousId], [SerialNumber] FROM [dbo].[SSLCertificates] @@ -19950,7 +19950,7 @@ SELECT C.CreatedDate, C.CommentText, C.SeverityID, - + -- user U.Username, U.FirstName, @@ -20027,20 +20027,20 @@ CREATE PROCEDURE [dbo].[GetCRMOrganizationUsers] @ItemID int AS BEGIN - SELECT + SELECT ea.AccountID, ea.ItemID, ea.AccountName, ea.DisplayName, ea.PrimaryEmailAddress, - ea.SamAccountName - FROM - ExchangeAccounts ea - INNER JOIN - CRMUsers cu - ON + ea.SamAccountName + FROM + ExchangeAccounts ea + INNER JOIN + CRMUsers cu + ON ea.AccountID = cu.AccountID - WHERE + WHERE ea.ItemID = @ItemID END @@ -20100,7 +20100,7 @@ SELECT FROM CRMUsers WHERE - AccountID = @AccountID + AccountID = @AccountID END @@ -20146,7 +20146,7 @@ CREATE PROCEDURE [dbo].[GetCRMUsers] @Name nvarchar(400), @Email nvarchar(400), @StartRow int, - @Count int + @Count int ) AS @@ -20160,61 +20160,61 @@ BEGIN SET @Email = '%' END -CREATE TABLE #TempCRMUsers -( +CREATE TABLE #TempCRMUsers +( [ID] [int] IDENTITY(1,1) NOT NULL, - [AccountID] [int], + [AccountID] [int], [ItemID] [int] NOT NULL, [AccountName] [nvarchar](300) NOT NULL, [DisplayName] [nvarchar](300) NOT NULL, [PrimaryEmailAddress] [nvarchar](300) NULL, - [SamAccountName] [nvarchar](100) NULL + [SamAccountName] [nvarchar](100) NULL ) IF (@SortColumn = 'DisplayName') BEGIN - INSERT INTO + INSERT INTO #TempCRMUsers - SELECT + SELECT ea.AccountID, ea.ItemID, ea.AccountName, ea.DisplayName, ea.PrimaryEmailAddress, - ea.SamAccountName - FROM - ExchangeAccounts ea - INNER JOIN - CRMUsers cu - ON + ea.SamAccountName + FROM + ExchangeAccounts ea + INNER JOIN + CRMUsers cu + ON ea.AccountID = cu.AccountID - WHERE - ea.ItemID = @ItemID AND ea.DisplayName LIKE @Name AND ea.PrimaryEmailAddress LIKE @Email - ORDER BY + WHERE + ea.ItemID = @ItemID AND ea.DisplayName LIKE @Name AND ea.PrimaryEmailAddress LIKE @Email + ORDER BY ea.DisplayName END ELSE BEGIN - INSERT INTO + INSERT INTO #TempCRMUsers - SELECT + SELECT ea.AccountID, ea.ItemID, ea.AccountName, ea.DisplayName, ea.PrimaryEmailAddress, - ea.SamAccountName - FROM - ExchangeAccounts ea - INNER JOIN - CRMUsers cu - ON + ea.SamAccountName + FROM + ExchangeAccounts ea + INNER JOIN + CRMUsers cu + ON ea.AccountID = cu.AccountID - WHERE - ea.ItemID = @ItemID AND ea.DisplayName LIKE @Name AND ea.PrimaryEmailAddress LIKE @Email - ORDER BY - ea.PrimaryEmailAddress + WHERE + ea.ItemID = @ItemID AND ea.DisplayName LIKE @Name AND ea.PrimaryEmailAddress LIKE @Email + ORDER BY + ea.PrimaryEmailAddress END DECLARE @RetCount int @@ -20223,7 +20223,7 @@ SELECT @RetCount = COUNT(ID) FROM #TempCRMUsers IF (@SortDirection = 'ASC') BEGIN SELECT * FROM #TempCRMUsers - WHERE ID > @StartRow AND ID <= (@StartRow + @Count) + WHERE ID > @StartRow AND ID <= (@StartRow + @Count) END ELSE BEGIN @@ -20237,7 +20237,7 @@ BEGIN SELECT * FROM #TempCRMUsers WHERE ID >@RetCount - @Count - @StartRow AND ID <= @RetCount- @StartRow ORDER BY PrimaryEmailAddress DESC END - + END @@ -20267,12 +20267,12 @@ GO -CREATE PROCEDURE [dbo].[GetCRMUsersCount] +CREATE PROCEDURE [dbo].[GetCRMUsersCount] ( @ItemID int, @Name nvarchar(400), @Email nvarchar(400) - + ) AS @@ -20286,16 +20286,16 @@ BEGIN SET @Email = '%' END -SELECT - COUNT(ea.AccountID) -FROM - ExchangeAccounts ea -INNER JOIN - CRMUsers cu -ON +SELECT + COUNT(ea.AccountID) +FROM + ExchangeAccounts ea +INNER JOIN + CRMUsers cu +ON ea.AccountID = cu.AccountID -WHERE - ea.ItemID = @ItemID AND ea.DisplayName LIKE @Name AND ea.PrimaryEmailAddress LIKE @Email +WHERE + ea.ItemID = @ItemID AND ea.DisplayName LIKE @Name AND ea.PrimaryEmailAddress LIKE @Email @@ -20369,7 +20369,7 @@ SELECT NR.MXPriority, NR.SrvPriority, NR.SrvWeight, - NR.SrvPort, + NR.SrvPort, NR.IPAddressID FROM GlobalDnsRecords AS NR @@ -20502,7 +20502,7 @@ SELECT NR.MXPriority, NR.SrvPriority, NR.SrvWeight, - NR.SrvPort, + NR.SrvPort, NR.IPAddressID, CASE WHEN NR.RecordType = 'A' AND NR.RecordData = '' THEN dbo.GetFullIPAddress(IP.ExternalIP, IP.InternalIP) @@ -20559,7 +20559,7 @@ SELECT NR.MXPriority, NR.SrvPriority, NR.SrvWeight, - NR.SrvPort, + NR.SrvPort, NR.IPAddressID, dbo.GetFullIPAddress(IP.ExternalIP, IP.InternalIP) AS IPAddress, IP.ExternalIP, @@ -20610,7 +20610,7 @@ SELECT NR.MXPriority, NR.SrvPriority, NR.SrvWeight, - NR.SrvPort, + NR.SrvPort, NR.IPAddressID, dbo.GetFullIPAddress(IP.ExternalIP, IP.InternalIP) AS IPAddress, IP.ExternalIP, @@ -20676,10 +20676,10 @@ BEGIN @ParentPackageID = ParentPackageID FROM Packages WHERE PackageID = @TmpPackageID - + IF @ParentPackageID IS NULL -- the last parent BREAK - + SET @TmpPackageID = @ParentPackageID END @@ -20741,7 +20741,7 @@ SELECT NR.MXPriority, NR.SrvPriority, NR.SrvWeight, - NR.SrvPort, + NR.SrvPort, NR.IPAddressID, ISNULL(IP.ExternalIP, '') AS ExternalIP, ISNULL(IP.InternalIP, '') AS InternalIP, @@ -21068,16 +21068,16 @@ SET @sql = @sql + ' SELECT COUNT(DomainID) FROM @Domains;SELECT D.IsSubDomain, D.IsInstantAlias, D.IsDomainPointer, - + -- packages P.PackageName, - + -- server ISNULL(SRV.ServerID, 0) AS ServerID, ISNULL(SRV.ServerName, '''') AS ServerName, ISNULL(SRV.Comments, '''') AS ServerComments, ISNULL(SRV.VirtualServer, 0) AS VirtualServer, - + -- user P.UserID, U.Username, @@ -21118,7 +21118,7 @@ GO -CREATE PROCEDURE [dbo].[GetExchangeAccount] +CREATE PROCEDURE [dbo].[GetExchangeAccount] ( @ItemID int, @AccountID int @@ -21138,10 +21138,10 @@ SELECT E.MailboxPlanId, P.MailboxPlan, E.SubscriberNumber, - E.UserPrincipalName + E.UserPrincipalName FROM ExchangeAccounts AS E -LEFT OUTER JOIN ExchangeMailboxPlans AS P ON E.MailboxPlanId = P.MailboxPlanId +LEFT OUTER JOIN ExchangeMailboxPlans AS P ON E.MailboxPlanId = P.MailboxPlanId WHERE E.ItemID = @ItemID AND E.AccountID = @AccountID @@ -21155,7 +21155,7 @@ GO -CREATE PROCEDURE [dbo].[GetExchangeAccountByAccountName] +CREATE PROCEDURE [dbo].[GetExchangeAccountByAccountName] ( @ItemID int, @AccountName nvarchar(300) @@ -21175,10 +21175,10 @@ SELECT E.MailboxPlanId, P.MailboxPlan, E.SubscriberNumber, - E.UserPrincipalName + E.UserPrincipalName FROM ExchangeAccounts AS E -LEFT OUTER JOIN ExchangeMailboxPlans AS P ON E.MailboxPlanId = P.MailboxPlanId +LEFT OUTER JOIN ExchangeMailboxPlans AS P ON E.MailboxPlanId = P.MailboxPlanId WHERE E.ItemID = @ItemID AND E.AccountName = @AccountName @@ -21195,7 +21195,7 @@ GO -CREATE PROCEDURE [dbo].[GetExchangeAccountByMailboxPlanId] +CREATE PROCEDURE [dbo].[GetExchangeAccountByMailboxPlanId] ( @ItemID int, @MailboxPlanId int @@ -21218,14 +21218,14 @@ SELECT E.MailboxPlanId, P.MailboxPlan, E.SubscriberNumber, - E.UserPrincipalName + E.UserPrincipalName FROM ExchangeAccounts AS E -LEFT OUTER JOIN ExchangeMailboxPlans AS P ON E.MailboxPlanId = P.MailboxPlanId +LEFT OUTER JOIN ExchangeMailboxPlans AS P ON E.MailboxPlanId = P.MailboxPlanId WHERE E.ItemID = @ItemID AND E.MailboxPlanId IS NULL AND - E.AccountType IN (1,5) + E.AccountType IN (1,5) RETURN END @@ -21246,13 +21246,13 @@ SELECT E.MailboxPlanId, P.MailboxPlan, E.SubscriberNumber, - E.UserPrincipalName + E.UserPrincipalName FROM ExchangeAccounts AS E -LEFT OUTER JOIN ExchangeMailboxPlans AS P ON E.MailboxPlanId = P.MailboxPlanId +LEFT OUTER JOIN ExchangeMailboxPlans AS P ON E.MailboxPlanId = P.MailboxPlanId WHERE E.MailboxPlanId = @MailboxPlanId AND - E.AccountType IN (1,5) + E.AccountType IN (1,5) END ELSE BEGIN @@ -21270,14 +21270,14 @@ SELECT E.MailboxPlanId, P.MailboxPlan, E.SubscriberNumber, - E.UserPrincipalName + E.UserPrincipalName FROM ExchangeAccounts AS E -LEFT OUTER JOIN ExchangeMailboxPlans AS P ON E.MailboxPlanId = P.MailboxPlanId +LEFT OUTER JOIN ExchangeMailboxPlans AS P ON E.MailboxPlanId = P.MailboxPlanId WHERE E.ItemID = @ItemID AND E.MailboxPlanId = @MailboxPlanId AND - E.AccountType IN (1,5) + E.AccountType IN (1,5) RETURN END @@ -21395,15 +21395,15 @@ SELECT E.PrimaryEmailAddress, E.MailEnabledPublicFolder, E.MailboxPlanId, - P.MailboxPlan, + P.MailboxPlan, E.SubscriberNumber, E.UserPrincipalName FROM ExchangeAccounts AS E -LEFT OUTER JOIN ExchangeMailboxPlans AS P ON E.MailboxPlanId = P.MailboxPlanId +LEFT OUTER JOIN ExchangeMailboxPlans AS P ON E.MailboxPlanId = P.MailboxPlanId WHERE E.ItemID = @ItemID AND - (E.AccountType = @AccountType OR @AccountType IS NULL) + (E.AccountType = @AccountType OR @AccountType IS NULL) ORDER BY DisplayName RETURN @@ -21455,11 +21455,11 @@ IF @FilterColumn <> '' AND @FilterColumn IS NOT NULL AND @FilterValue <> '' AND @FilterValue IS NOT NULL BEGIN IF @FilterColumn = 'PrimaryEmailAddress' AND @AccountTypes <> '2' - BEGIN + BEGIN SET @condition = @condition + ' AND EA.AccountID IN (SELECT EAEA.AccountID FROM ExchangeAccountEmailAddresses EAEA WHERE EAEA.EmailAddress LIKE ''' + @FilterValue + ''')' END ELSE - BEGIN + BEGIN SET @condition = @condition + ' AND ' + @FilterColumn + ' LIKE ''' + @FilterValue + '''' END END @@ -21501,7 +21501,7 @@ print @sql exec sp_executesql @sql, N'@ItemID int, @StartRow int, @MaximumRows int', @ItemID, @StartRow, @MaximumRows -RETURN +RETURN @@ -21539,7 +21539,7 @@ FROM ExchangeAccounts WHERE ItemID = @ItemID AND - (AccountType =1 OR AccountType=5 OR AccountType=6) + (AccountType =1 OR AccountType=5 OR AccountType=6) ORDER BY 1 END @@ -21556,7 +21556,7 @@ GO -CREATE PROCEDURE [dbo].[GetExchangeMailboxPlan] +CREATE PROCEDURE [dbo].[GetExchangeMailboxPlan] ( @MailboxPlanId int ) @@ -21628,7 +21628,7 @@ SELECT FROM ExchangeMailboxPlans WHERE - ItemID = @ItemID + ItemID = @ItemID ORDER BY MailboxPlan RETURN @@ -21649,7 +21649,7 @@ SELECT FROM ExchangeOrganizations WHERE - ItemID = @ItemID + ItemID = @ItemID RETURN GO SET ANSI_NULLS ON @@ -21660,7 +21660,7 @@ GO -CREATE PROCEDURE [dbo].[GetExchangeOrganizationDomains] +CREATE PROCEDURE [dbo].[GetExchangeOrganizationDomains] ( @ItemID int ) @@ -21699,7 +21699,7 @@ GO -CREATE PROCEDURE [dbo].[GetExchangeOrganizationStatistics] +CREATE PROCEDURE [dbo].[GetExchangeOrganizationStatistics] ( @ItemID int ) @@ -21993,7 +21993,7 @@ SELECT FROM HostingPlans AS HP WHERE HP.PlanID = @PlanID -RETURN +RETURN @@ -22084,7 +22084,7 @@ SELECT dbo.GetPackageAllocatedResource(@PackageID, RG.GroupID, @ServerID) AS ParentEnabled, ISNULL(HPR.CalculateDiskSpace, 1) AS CalculateDiskSpace, ISNULL(HPR.CalculateBandwidth, 1) AS CalculateBandwidth -FROM ResourceGroups AS RG +FROM ResourceGroups AS RG LEFT OUTER JOIN HostingPlanResources AS HPR ON RG.GroupID = HPR.GroupID AND HPR.PlanID = @PlanID WHERE (RG.ShowGroup = 1) ORDER BY RG.GroupOrder @@ -22160,19 +22160,19 @@ SELECT HP.RecurrenceLength, HP.RecurrenceUnit, HP.IsAddon, - + (SELECT COUNT(P.PackageID) FROM Packages AS P WHERE P.PlanID = HP.PlanID) AS PackagesNumber, - + -- server ISNULL(HP.ServerID, 0) AS ServerID, ISNULL(S.ServerName, 'None') AS ServerName, ISNULL(S.Comments, '') AS ServerComments, ISNULL(S.VirtualServer, 1) AS VirtualServer, - + -- package ISNULL(HP.PackageID, 0) AS PackageID, ISNULL(P.PackageName, 'None') AS PackageName - + FROM HostingPlans AS HP LEFT OUTER JOIN Servers AS S ON HP.ServerID = S.ServerID LEFT OUTER JOIN Packages AS P ON HP.PackageID = P.PackageID @@ -22240,9 +22240,9 @@ GO CREATE PROCEDURE [dbo].[GetInstanceID] @AccountID int AS -BEGIN +BEGIN SET NOCOUNT ON; - + SELECT InstanceID FROM OCSUsers WHERE AccountID = @AccountID END @@ -22278,7 +22278,7 @@ GO -CREATE PROCEDURE [dbo].[GetIPAddress] +CREATE PROCEDURE [dbo].[GetIPAddress] ( @AddressID int ) @@ -22299,7 +22299,7 @@ BEGIN WHERE AddressID = @AddressID - RETURN + RETURN END @@ -22340,7 +22340,7 @@ GO -CREATE PROCEDURE [dbo].[GetIPAddresses] +CREATE PROCEDURE [dbo].[GetIPAddresses] ( @ActorID int, @PoolID int, @@ -22424,7 +22424,7 @@ GO -CREATE PROCEDURE [dbo].[GetIPAddressesPaged] +CREATE PROCEDURE [dbo].[GetIPAddressesPaged] ( @ActorID int, @PoolID int, @@ -22551,17 +22551,17 @@ GO -CREATE PROCEDURE [dbo].[GetItemIdByOrganizationId] +CREATE PROCEDURE [dbo].[GetItemIdByOrganizationId] @OrganizationId nvarchar(128) AS BEGIN SET NOCOUNT ON; - - SELECT + + SELECT ItemID - FROM + FROM dbo.ExchangeOrganizations - WHERE + WHERE OrganizationId = @OrganizationId END @@ -22678,7 +22678,7 @@ GO -CREATE PROCEDURE [dbo].[GetLyncUserPlan] +CREATE PROCEDURE [dbo].[GetLyncUserPlan] ( @LyncUserPlanId int ) @@ -22714,7 +22714,7 @@ GO -CREATE PROCEDURE [dbo].[GetLyncUserPlanByAccountId] +CREATE PROCEDURE [dbo].[GetLyncUserPlanByAccountId] ( @AccountID int ) @@ -22770,7 +22770,7 @@ SELECT FROM LyncUserPlans WHERE - ItemID = @ItemID + ItemID = @ItemID ORDER BY LyncUserPlanName RETURN @@ -22789,22 +22789,22 @@ CREATE PROCEDURE [dbo].[GetLyncUsers] @SortColumn nvarchar(40), @SortDirection nvarchar(20), @StartRow int, - @Count int + @Count int ) AS -CREATE TABLE #TempLyncUsers -( +CREATE TABLE #TempLyncUsers +( [ID] [int] IDENTITY(1,1) NOT NULL, - [AccountID] [int], + [AccountID] [int], [ItemID] [int] NOT NULL, [AccountName] [nvarchar](300) NOT NULL, [DisplayName] [nvarchar](300) NOT NULL, [UserPrincipalName] [nvarchar](300) NULL, [SipAddress] [nvarchar](300) NULL, [SamAccountName] [nvarchar](100) NULL, - [LyncUserPlanId] [int] NOT NULL, - [LyncUserPlanName] [nvarchar] (300) NOT NULL, + [LyncUserPlanId] [int] NOT NULL, + [LyncUserPlanName] [nvarchar] (300) NOT NULL, ) @@ -22835,9 +22835,9 @@ END DECLARE @sql nvarchar(3500) set @sql = '' - INSERT INTO - #TempLyncUsers - SELECT + INSERT INTO + #TempLyncUsers + SELECT ea.AccountID, ea.ItemID, ea.AccountName, @@ -22846,29 +22846,29 @@ set @sql = '' ou.SipAddress, ea.SamAccountName, ou.LyncUserPlanId, - lp.LyncUserPlanName - FROM - ExchangeAccounts ea - INNER JOIN + lp.LyncUserPlanName + FROM + ExchangeAccounts ea + INNER JOIN LyncUsers ou INNER JOIN - LyncUserPlans lp + LyncUserPlans lp + ON + ou.LyncUserPlanId = lp.LyncUserPlanId ON - ou.LyncUserPlanId = lp.LyncUserPlanId - ON ea.AccountID = ou.AccountID - WHERE + WHERE ea.ItemID = @ItemID + @condition exec sp_executesql @sql, N'@ItemID int',@ItemID DECLARE @RetCount int -SELECT @RetCount = COUNT(ID) FROM #TempLyncUsers +SELECT @RetCount = COUNT(ID) FROM #TempLyncUsers IF (@SortDirection = 'ASC') BEGIN - SELECT * FROM #TempLyncUsers - WHERE ID > @StartRow AND ID <= (@StartRow + @Count) + SELECT * FROM #TempLyncUsers + WHERE ID > @StartRow AND ID <= (@StartRow + @Count) END ELSE BEGIN @@ -22876,34 +22876,34 @@ BEGIN BEGIN IF (@SortColumn = 'DisplayName') BEGIN - SELECT * FROM #TempLyncUsers + SELECT * FROM #TempLyncUsers WHERE ID >@RetCount - @Count - @StartRow AND ID <= @RetCount- @StartRow ORDER BY DisplayName DESC END IF (@SortColumn = 'UserPrincipalName') BEGIN - SELECT * FROM #TempLyncUsers + SELECT * FROM #TempLyncUsers WHERE ID >@RetCount - @Count - @StartRow AND ID <= @RetCount- @StartRow ORDER BY UserPrincipalName DESC END IF (@SortColumn = 'SipAddress') BEGIN - SELECT * FROM #TempLyncUsers + SELECT * FROM #TempLyncUsers WHERE ID >@RetCount - @Count - @StartRow AND ID <= @RetCount- @StartRow ORDER BY SipAddress DESC END IF (@SortColumn = 'LyncUserPlanName') BEGIN - SELECT * FROM #TempLyncUsers + SELECT * FROM #TempLyncUsers WHERE ID >@RetCount - @Count - @StartRow AND ID <= @RetCount- @StartRow ORDER BY LyncUserPlanName DESC END END ELSE BEGIN - SELECT * FROM #TempLyncUsers + SELECT * FROM #TempLyncUsers WHERE ID >@RetCount - @Count - @StartRow AND ID <= @RetCount- @StartRow ORDER BY UserPrincipalName DESC END - + END DROP TABLE #TempLyncUsers @@ -22927,7 +22927,7 @@ CREATE PROCEDURE [dbo].[GetLyncUsersByPlanId] ) AS - SELECT + SELECT ea.AccountID, ea.ItemID, ea.AccountName, @@ -22936,17 +22936,17 @@ AS ea.SamAccountName, ou.LyncUserPlanId, lp.LyncUserPlanName - FROM - ExchangeAccounts ea - INNER JOIN + FROM + ExchangeAccounts ea + INNER JOIN LyncUsers ou INNER JOIN - LyncUserPlans lp + LyncUserPlans lp + ON + ou.LyncUserPlanId = lp.LyncUserPlanId ON - ou.LyncUserPlanId = lp.LyncUserPlanId - ON ea.AccountID = ou.AccountID - WHERE + WHERE ea.ItemID = @ItemID AND ou.LyncUserPlanId = @PlanId @@ -22965,21 +22965,21 @@ GO -CREATE PROCEDURE [dbo].[GetLyncUsersCount] +CREATE PROCEDURE [dbo].[GetLyncUsersCount] ( @ItemID int ) AS -SELECT - COUNT(ea.AccountID) -FROM - ExchangeAccounts ea -INNER JOIN - LyncUsers ou -ON +SELECT + COUNT(ea.AccountID) +FROM + ExchangeAccounts ea +INNER JOIN + LyncUsers ou +ON ea.AccountID = ou.AccountID -WHERE +WHERE ea.ItemID = @ItemID GO @@ -23007,18 +23007,18 @@ SELECT P.StatusID, P.PlanID, P.PurchaseDate, - + dbo.GetItemComments(P.PackageID, 'PACKAGE', @ActorID) AS Comments, - + -- server ISNULL(P.ServerID, 0) AS ServerID, ISNULL(S.ServerName, 'None') AS ServerName, ISNULL(S.Comments, '') AS ServerComments, ISNULL(S.VirtualServer, 1) AS VirtualServer, - + -- hosting plan HP.PlanName, - + -- user P.UserID, U.Username, @@ -23159,19 +23159,19 @@ SELECT P.PackageName, P.StatusID, P.PurchaseDate, - + dbo.GetItemComments(P.PackageID, ''PACKAGE'', @ActorID) AS Comments, - + -- server P.ServerID, ISNULL(S.ServerName, ''None'') AS ServerName, ISNULL(S.Comments, '''') AS ServerComments, ISNULL(S.VirtualServer, 1) AS VirtualServer, - + -- hosting plan P.PlanID, HP.PlanName, - + -- user P.UserID, U.Username, @@ -23465,7 +23465,7 @@ CREATE PROCEDURE [dbo].[GetOCSUsers] @Name nvarchar(400), @Email nvarchar(400), @StartRow int, - @Count int + @Count int ) AS @@ -23479,87 +23479,87 @@ BEGIN SET @Email = '%' END -CREATE TABLE #TempOCSUsers -( +CREATE TABLE #TempOCSUsers +( [ID] [int] IDENTITY(1,1) NOT NULL, - [AccountID] [int], + [AccountID] [int], [ItemID] [int] NOT NULL, [AccountName] [nvarchar](300) NOT NULL, [DisplayName] [nvarchar](300) NOT NULL, [InstanceID] [nvarchar](50) NOT NULL, [PrimaryEmailAddress] [nvarchar](300) NULL, - [SamAccountName] [nvarchar](100) NULL + [SamAccountName] [nvarchar](100) NULL ) IF (@SortColumn = 'DisplayName') BEGIN - INSERT INTO - #TempOCSUsers - SELECT + INSERT INTO + #TempOCSUsers + SELECT ea.AccountID, ea.ItemID, ea.AccountName, ea.DisplayName, ou.InstanceID, ea.PrimaryEmailAddress, - ea.SamAccountName - FROM - ExchangeAccounts ea - INNER JOIN - OCSUsers ou - ON + ea.SamAccountName + FROM + ExchangeAccounts ea + INNER JOIN + OCSUsers ou + ON ea.AccountID = ou.AccountID - WHERE - ea.ItemID = @ItemID AND ea.DisplayName LIKE @Name AND ea.PrimaryEmailAddress LIKE @Email - ORDER BY + WHERE + ea.ItemID = @ItemID AND ea.DisplayName LIKE @Name AND ea.PrimaryEmailAddress LIKE @Email + ORDER BY ea.DisplayName END ELSE BEGIN - INSERT INTO + INSERT INTO #TempOCSUsers - SELECT + SELECT ea.AccountID, ea.ItemID, ea.AccountName, ea.DisplayName, ou.InstanceID, ea.PrimaryEmailAddress, - ea.SamAccountName - FROM - ExchangeAccounts ea - INNER JOIN - OCSUsers ou - ON + ea.SamAccountName + FROM + ExchangeAccounts ea + INNER JOIN + OCSUsers ou + ON ea.AccountID = ou.AccountID - WHERE - ea.ItemID = @ItemID AND ea.DisplayName LIKE @Name AND ea.PrimaryEmailAddress LIKE @Email - ORDER BY - ea.PrimaryEmailAddress + WHERE + ea.ItemID = @ItemID AND ea.DisplayName LIKE @Name AND ea.PrimaryEmailAddress LIKE @Email + ORDER BY + ea.PrimaryEmailAddress END DECLARE @RetCount int -SELECT @RetCount = COUNT(ID) FROM #TempOCSUsers +SELECT @RetCount = COUNT(ID) FROM #TempOCSUsers IF (@SortDirection = 'ASC') BEGIN - SELECT * FROM #TempOCSUsers - WHERE ID > @StartRow AND ID <= (@StartRow + @Count) + SELECT * FROM #TempOCSUsers + WHERE ID > @StartRow AND ID <= (@StartRow + @Count) END ELSE BEGIN IF (@SortColumn = 'DisplayName') BEGIN - SELECT * FROM #TempOCSUsers + SELECT * FROM #TempOCSUsers WHERE ID >@RetCount - @Count - @StartRow AND ID <= @RetCount- @StartRow ORDER BY DisplayName DESC END ELSE BEGIN - SELECT * FROM #TempOCSUsers + SELECT * FROM #TempOCSUsers WHERE ID >@RetCount - @Count - @StartRow AND ID <= @RetCount- @StartRow ORDER BY PrimaryEmailAddress DESC END - + END @@ -23580,12 +23580,12 @@ GO -CREATE PROCEDURE [dbo].[GetOCSUsersCount] +CREATE PROCEDURE [dbo].[GetOCSUsersCount] ( @ItemID int, @Name nvarchar(400), @Email nvarchar(400) - + ) AS @@ -23599,16 +23599,16 @@ BEGIN SET @Email = '%' END -SELECT - COUNT(ea.AccountID) -FROM - ExchangeAccounts ea -INNER JOIN - OCSUsers ou -ON +SELECT + COUNT(ea.AccountID) +FROM + ExchangeAccounts ea +INNER JOIN + OCSUsers ou +ON ea.AccountID = ou.AccountID -WHERE - ea.ItemID = @ItemID AND ea.DisplayName LIKE @Name AND ea.PrimaryEmailAddress LIKE @Email +WHERE + ea.ItemID = @ItemID AND ea.DisplayName LIKE @Name AND ea.PrimaryEmailAddress LIKE @Email @@ -23651,13 +23651,13 @@ CREATE PROCEDURE [dbo].[GetOrganizationCRMUserCount] @ItemID int AS BEGIN -SELECT - COUNT(CRMUserID) -FROM +SELECT + COUNT(CRMUserID) +FROM CrmUsers CU -INNER JOIN +INNER JOIN ExchangeAccounts EA -ON +ON CU.AccountID = EA.AccountID WHERE EA.ItemID = @ItemID END @@ -23717,7 +23717,7 @@ GO -CREATE PROCEDURE [dbo].[GetOrganizationStatistics] +CREATE PROCEDURE [dbo].[GetOrganizationStatistics] ( @ItemID int ) @@ -24139,7 +24139,7 @@ LEFT OUTER JOIN WHERE GB.BytesTotal > 0 ORDER BY RG.GroupOrder -RETURN +RETURN @@ -24220,7 +24220,7 @@ CREATE PROCEDURE GetPackageBandwidthUpdate AS SELECT @UpdateDate = BandwidthUpdated FROM Packages WHERE PackageID = @PackageID -RETURN +RETURN @@ -24326,7 +24326,7 @@ LEFT OUTER JOIN WHERE GD.Diskspace <> 0 ORDER BY RG.GroupOrder -RETURN +RETURN @@ -24616,17 +24616,17 @@ SELECT P.PackageName, P.StatusID, P.PurchaseDate, - + -- server P.ServerID, ISNULL(S.ServerName, 'None') AS ServerName, ISNULL(S.Comments, '') AS ServerComments, ISNULL(S.VirtualServer, 1) AS VirtualServer, - + -- hosting plan P.PlanID, HP.PlanName, - + -- user P.UserID, U.Username, @@ -25210,17 +25210,17 @@ SELECT P.PackageName, P.StatusID, P.PurchaseDate, - + -- server ISNULL(P.ServerID, 0) AS ServerID, ISNULL(S.ServerName, 'None') AS ServerName, ISNULL(S.Comments, '') AS ServerComments, ISNULL(S.VirtualServer, 1) AS VirtualServer, - + -- hosting plan P.PlanID, HP.PlanName, - + -- user P.UserID, U.Username, @@ -25233,7 +25233,7 @@ INNER JOIN Users AS U ON P.UserID = U.UserID INNER JOIN Servers AS S ON P.ServerID = S.ServerID INNER JOIN HostingPlans AS HP ON P.PlanID = HP.PlanID WHERE - P.UserID = @UserID + P.UserID = @UserID RETURN GO @@ -25346,12 +25346,12 @@ SELECT ISNULL(R.QuotaValue, 0) AS QuotaValue, ISNULL(R.Bandwidth, 0) AS Bandwidth, ISNULL(R.UsagePercentage, 0) AS UsagePercentage, - + -- package P.PackageName, ISNULL(R.PackagesNumber, 0) AS PackagesNumber, P.StatusID, - + -- user P.UserID, U.Username, @@ -25370,7 +25370,7 @@ WHERE R.ItemPosition BETWEEN @StartRow AND @EndRow exec sp_executesql @sql, N'@ActorID int, @UserID int, @PackageID int, @StartDate datetime, @EndDate datetime, @StartRow int, @MaximumRows int', @ActorID, @UserID, @PackageID, @StartDate, @EndDate, @StartRow, @MaximumRows -RETURN +RETURN @@ -25512,12 +25512,12 @@ SELECT ISNULL(R.QuotaValue, 0) AS QuotaValue, ISNULL(R.Diskspace, 0) AS Diskspace, ISNULL(R.UsagePercentage, 0) AS UsagePercentage, - + -- package P.PackageName, ISNULL(R.PackagesNumber, 0) AS PackagesNumber, P.StatusID, - + -- user P.UserID, U.Username, @@ -25536,7 +25536,7 @@ WHERE R.ItemPosition BETWEEN @StartRow AND @EndRow exec sp_executesql @sql, N'@ActorID int, @UserID int, @PackageID int, @StartRow int, @MaximumRows int', @ActorID, @UserID, @PackageID, @StartRow, @MaximumRows -RETURN +RETURN @@ -25661,7 +25661,7 @@ INNER JOIN Services AS S ON PS.ServiceID = S.ServiceID INNER JOIN Providers AS P ON S.ProviderID = P.ProviderID WHERE PS.PackageID = @PackageID AND P.GroupID = @GroupID -RETURN +RETURN @@ -25776,27 +25776,27 @@ BEGIN WHERE PackageID = @TmpPackageID AND SettingsName = @SettingsName - + BREAK END END SET @ParentPackageID = NULL --reset var - + -- get owner SELECT @ParentPackageID = ParentPackageID FROM Packages WHERE PackageID = @TmpPackageID - + IF @ParentPackageID IS NULL -- the last parent BREAK - + SET @TmpPackageID = @ParentPackageID END -RETURN +RETURN @@ -25920,19 +25920,19 @@ SELECT P.PackageName, P.StatusID, P.PurchaseDate, - + dbo.GetItemComments(P.PackageID, ''PACKAGE'', @ActorID) AS Comments, - + -- server P.ServerID, ISNULL(S.ServerName, ''None'') AS ServerName, ISNULL(S.Comments, '''') AS ServerComments, ISNULL(S.VirtualServer, 1) AS VirtualServer, - + -- hosting plan P.PlanID, HP.PlanName, - + -- user P.UserID, U.Username, @@ -26147,7 +26147,7 @@ FROM Providers WHERE ProviderID = @ProviderID -RETURN +RETURN @@ -26242,7 +26242,7 @@ INNER JOIN Providers AS P ON S.ProviderID = P.ProviderID WHERE S.ServiceID = @ServiceID -RETURN +RETURN @@ -26480,7 +26480,7 @@ SELECT FROM Quotas AS Q INNER JOIN ResourceGroups AS RG ON Q.GroupID = RG.GroupID ORDER BY RG.GroupOrder, Q.QuotaOrder -RETURN +RETURN @@ -26574,7 +26574,7 @@ WHERE AND @IsAdmin = 1 ORDER BY RG.GroupOrder -RETURN +RETURN GO SET ANSI_NULLS ON @@ -26726,7 +26726,7 @@ SELECT FROM ResourceGroups AS RG WHERE RG.GroupID = @GroupID -RETURN +RETURN @@ -26808,7 +26808,7 @@ SELECT GroupController FROM ResourceGroups ORDER BY GroupOrder -RETURN +RETURN @@ -27225,7 +27225,7 @@ SELECT FROM Schedule AS S INNER JOIN PackagesTree(@PackageID, @Recursive) AS PT ON S.PackageID = PT.PackageID ORDER BY S.Enabled DESC, S.NextRun - + -- select schedules SELECT @@ -27419,7 +27419,7 @@ SELECT -- packages P.PackageID, P.PackageName, - + -- user P.UserID, U.Username, @@ -27596,7 +27596,7 @@ GO -CREATE PROCEDURE GetScheduleTasks +CREATE PROCEDURE GetScheduleTasks ( @ActorID int ) @@ -27869,7 +27869,7 @@ WHERE ServerID = @ServerID AND @IsAdmin = 1 -RETURN +RETURN @@ -27973,7 +27973,7 @@ WHERE ServerName = @ServerName AND @IsAdmin = 1 -RETURN +RETURN @@ -28070,7 +28070,7 @@ FROM Servers WHERE ServerID = @ServerID -RETURN +RETURN @@ -28174,7 +28174,7 @@ INNER JOIN ResourceGroups AS RG ON P.GroupID = RG.GroupID WHERE @IsAdmin = 1 ORDER BY RG.GroupOrder -RETURN +RETURN @@ -28264,7 +28264,7 @@ FROM Servers WHERE ServerID = @ServerID -RETURN +RETURN @@ -28336,7 +28336,7 @@ FROM Services INNER JOIN Servers ON Services.ServerID = Servers.ServerID WHERE ServiceID = @ServiceID -RETURN +RETURN @@ -28431,7 +28431,7 @@ FROM ServiceItemProperties AS IP INNER JOIN @Items AS FI ON IP.ItemID = FI.ItemID -RETURN +RETURN @@ -28549,7 +28549,7 @@ FROM ServiceItemProperties AS IP INNER JOIN @Items AS FI ON IP.ItemID = FI.ItemID -RETURN +RETURN @@ -28665,7 +28665,7 @@ SELECT FROM ServiceItemProperties AS IP INNER JOIN @Items AS FI ON IP.ItemID = FI.ItemID -RETURN +RETURN @@ -28777,7 +28777,7 @@ FROM ServiceItemProperties AS IP INNER JOIN @Items AS FI ON IP.ItemID = FI.ItemID -RETURN +RETURN @@ -29336,7 +29336,7 @@ INNER JOIN @Items AS TSI ON IP.ItemID = TSI.ItemID' exec sp_executesql @sql, N'@ItemTypeID int, @PackageID int, @GroupID int, @StartRow int, @MaximumRows int, @Recursive bit, @ServerID int', @ItemTypeID, @PackageID, @GroupID, @StartRow, @MaximumRows, @Recursive, @ServerID -RETURN +RETURN @@ -29579,7 +29579,7 @@ FROM ServiceProperties WHERE ServiceID = @ServiceID -RETURN +RETURN @@ -29681,7 +29681,7 @@ INNER JOIN Servers AS SRV ON S.ServerID = SRV.ServerID WHERE PROV.GroupID = @GroupID AND @IsAdmin = 1 -RETURN +RETURN @@ -29760,7 +29760,7 @@ INNER JOIN ResourceGroups AS RG ON PROV.GroupID = RG.GroupID WHERE RG.GroupName = @GroupName AND @IsAdmin = 1 -RETURN +RETURN @@ -29844,7 +29844,7 @@ WHERE AND @IsAdmin = 1 ORDER BY RG.GroupOrder -RETURN +RETURN @@ -29951,7 +29951,7 @@ WHERE AND @IsAdmin = 1 ORDER BY RG.GroupOrder -RETURN +RETURN @@ -30142,7 +30142,7 @@ GO SET QUOTED_IDENTIFIER OFF GO -CREATE PROCEDURE [dbo].[GetUnallottedIPAddresses] +CREATE PROCEDURE [dbo].[GetUnallottedIPAddresses] @PackageID int, @ServiceID int, @PoolID int = 0 @@ -30151,7 +30151,7 @@ BEGIN DECLARE @ParentPackageID int DECLARE @ServerID int - + SELECT @ParentPackageID = ParentPackageID, @ServerID = ServerID @@ -30159,7 +30159,7 @@ BEGIN WHERE PackageID = @PackageId IF (@ParentPackageID = 1 OR @PoolID = 4 /* management network */) -- "System" space - BEGIN + BEGIN -- check if server is physical IF EXISTS(SELECT * FROM Servers WHERE ServerID = @ServerID AND VirtualServer = 0) BEGIN @@ -30187,7 +30187,7 @@ BEGIN SELECT @GroupID = P.GroupID FROM Services AS S INNER JOIN Providers AS P ON S.ProviderID = P.ProviderID WHERE S.ServiceID = @ServiceID - + SELECT IP.AddressID, IP.ExternalIP, @@ -30213,7 +30213,7 @@ BEGIN -- get service location SELECT @ServerID = S.ServerID FROM Services AS S WHERE S.ServiceID = @ServiceID - + SELECT IP.AddressID, IP.ExternalIP, @@ -30511,7 +30511,7 @@ AS FROM Users AS U WHERE U.UserID IN (SELECT UserID FROM Packages WHERE PackageID IN ( SELECT PackageID FROM ServiceItems WHERE ItemID = @ItemID)) - + RETURN GO @@ -30892,7 +30892,7 @@ SELECT FROM UserParents(@ActorID, @UserID) AS UP INNER JOIN Users AS U ON UP.UserID = U.UserID ORDER BY UP.UserOrder DESC -RETURN +RETURN GO SET ANSI_NULLS ON @@ -30946,7 +30946,7 @@ FROM UsersDetailed AS U WHERE U.OwnerID = @UserID AND IsPeer = 1 AND @CanGetDetails = 1 -- actor rights -RETURN +RETURN GO SET ANSI_NULLS ON @@ -31006,12 +31006,12 @@ SELECT U.EcommerceEnabled FROM UsersDetailed AS U WHERE U.UserID <> @OwnerID AND -((@Recursive = 1 AND dbo.CheckUserParent(@OwnerID, U.UserID) = 1) OR +((@Recursive = 1 AND dbo.CheckUserParent(@OwnerID, U.UserID) = 1) OR (@Recursive = 0 AND U.OwnerID = @OwnerID)) AND U.IsPeer = 0 AND @CanGetDetails = 1 -- actor user rights -RETURN +RETURN GO SET ANSI_NULLS ON @@ -31063,28 +31063,28 @@ Algorythm: 3. If the requested resource has one service remember the ID of this single service 4. If the requested resource has several services DO distribution: - + 4.1. If the resource is NOT BOUNDED or is PRIMARY DISTRIBUTION RESOURCE if PRIMARY DISTRIBUTION RESOURCE and exists in UserServices return serviceId from UserServices table - + remember any service from that resource according to distribution type ("BALANCED" or "RANDOM") - get the number of ServiceItems for each service - + 4.2. If the resource is BOUNDED to primary distribution resource - If the primary distribution resource is NULL EXCEPTION "Requested resource marked as bound to primary distribution resource, but there is no any resources in hosting plan marked as primary" - + - Get the service id of the primary distribution resource GetServiceId(userId, primaryResourceId) - - - Get from user assigned hosting plan - + + + Get from user assigned hosting plan + 5. If it is PRIMARY DISTRIBUTION RESOURCE Save it's ID to UserServices table - + 6. return serviceId - + ERROR CODES: -1 - there are several hosting plans with PDR assigned to that user -2 - The requested service is not available for the user. The resource of the @@ -31103,7 +31103,7 @@ CREATE PROCEDURE GetUserServiceID ) AS DECLARE @PrimaryResourceID int -- primary distribution resource assigned through hosting plan - + ---------------------------------------- -- Get the primary distribution resource ---------------------------------------- @@ -31114,14 +31114,14 @@ AS SET @ServiceID = -1 RETURN END - + SELECT @PrimaryResourceID = HP.PrimaryResourceID FROM PurchasedHostingPlans AS PHP INNER JOIN HostingPlans AS HP ON PHP.PlanID = HP.PlanID WHERE PHP.UserID = @UserID AND HP.PrimaryResourceID IS NOT NULL AND HP.PrimaryResourceID <> 0 - + ---------------------------------------------- - -- Check whether user has a resource + -- Check whether user has a resource -- of this type in his hosting plans or addons ---------------------------------------------- DECLARE @UserResourcesTable TABLE @@ -31151,13 +31151,13 @@ AS SET @ServiceID = -3 -- several resources of the same type was assigned RETURN END - + ---------------------------------------- -- Check services number ---------------------------------------- DECLARE @ResourceID int SET @ResourceID = (SELECT TOP 1 ResourceID FROM @UserResourcesTable) - + DECLARE @UserServicesTable TABLE ( ServiceID int, @@ -31174,7 +31174,7 @@ AS FROM ResourceServices AS RS INNER JOIN Services AS S ON RS.ServiceID = S.ServiceID WHERE RS.ResourceID = @ResourceID - + DECLARE @ServicesCount int SET @ServicesCount = @@ROWCOUNT IF @ServicesCount = 0 @@ -31182,7 +31182,7 @@ AS SET @ServiceID = -4 -- The resource {name} of type {type} should contain atleast one service RETURN END - + -- try to return from UserServices -- if it is a PDR IF @ResourceID = @PrimaryResourceID @@ -31191,7 +31191,7 @@ AS SELECT @ServiceID = US.ServiceID FROM ResourceServices AS RS INNER JOIN UserServices AS US ON RS.ServiceID = US.ServiceID WHERE RS.ResourceID = @ResourceID AND US.UserID = @UserID - + -- check validness of the current primary service id IF @ServiceID IS NOT NULL BEGIN @@ -31202,7 +31202,7 @@ AS DELETE FROM UserServices WHERE UserID = @UserID END END - + IF @ServicesCount = 1 BEGIN -- nothing to distribute @@ -31216,7 +31216,7 @@ AS DECLARE @BoundToPrimaryResource bit SELECT @DistributionTypeID = R.DistributionTypeID, @BoundToPrimaryResource = R.BoundToPrimaryResource FROM Resources AS R WHERE R.ResourceID = @ResourceID - + IF @BoundToPrimaryResource = 0 OR @ResourceID = @PrimaryResourceID BEGIN IF @ResourceID = @PrimaryResourceID -- it's PDR itself @@ -31225,7 +31225,7 @@ AS SELECT @ServiceID = US.ServiceID FROM ResourceServices AS RS INNER JOIN UserServices AS US ON RS.ServiceID = US.ServiceID WHERE RS.ResourceID = @ResourceID AND US.UserID = @UserID - + -- check validness of the current primary service id IF @ServiceID IS NOT NULL BEGIN @@ -31236,7 +31236,7 @@ AS DELETE FROM UserServices WHERE UserID = @UserID END END - + -- distribute IF @DistributionTypeID = 1 -- BALANCED distribution SELECT @ServiceID = ServiceID FROM @UserServicesTable @@ -31253,14 +31253,14 @@ AS -- but there is no any resources in hosting plan marked as primary RETURN END - + -- get the type of primary resource DECLARE @PrimaryTypeName nvarchar(200) SELECT @PrimaryTypeName = ST.TypeName FROM Resources AS R INNER JOIN ServiceTypes AS ST ON R.ServiceTypeID = ST.ServiceTypeID WHERE R.ResourceID = @PrimaryResourceID - - + + DECLARE @PrimaryServiceID int EXEC GetUserServiceID @UserID, @PrimaryTypeName, @PrimaryServiceID OUTPUT @@ -31269,29 +31269,29 @@ AS SET @ServiceID = @PrimaryServiceID RETURN END - + DECLARE @ServerID int SET @ServerID = (SELECT ServerID FROM Services WHERE ServiceID = @PrimaryServiceID) - + -- try to get the service of the requested type on PDR server SET @ServiceID = (SELECT ServiceID FROM @UserServicesTable WHERE ServerID = @ServerID) - + IF @ServiceID IS NULL BEGIN SET @ServiceID = -6 -- the server where PDR is located doesn't contain the service of requested resource type END END END - + IF @ResourceID = @PrimaryResourceID -- it's PDR BEGIN DELETE FROM UserServices WHERE UserID = @UserID - + INSERT INTO UserServices (UserID, ServiceID) VALUES (@UserID, @ServiceID) END - -RETURN + +RETURN @@ -31403,25 +31403,25 @@ BEGIN WHERE UserID = @TmpUserID AND SettingsName = @SettingsName - + BREAK END SET @ParentUserID = NULL --reset var - + -- get owner SELECT @ParentUserID = OwnerID FROM Users WHERE UserID = @TmpUserID - + IF @ParentUserID IS NULL -- the last parent BREAK - + SET @TmpUserID = @ParentUserID END -RETURN +RETURN @@ -31510,7 +31510,7 @@ INSERT INTO @Users (UserID) SELECT U.UserID FROM UsersDetailed AS U -WHERE +WHERE U.UserID <> @UserID AND U.IsPeer = 0 AND ( (@Recursive = 0 AND OwnerID = @UserID) OR @@ -31776,7 +31776,7 @@ LEFT OUTER JOIN PrivateIPAddresses AS PIP ON PIP.ItemID = SI.ItemID AND PIP.IsPr exec sp_executesql @sql, N'@PackageID int, @StartRow int, @MaximumRows int, @Recursive bit', @PackageID, @StartRow, @MaximumRows, @Recursive -RETURN +RETURN @@ -31965,7 +31965,7 @@ WHERE AND @IsAdmin = 1 ORDER BY S.ServerName -RETURN +RETURN @@ -32065,7 +32065,7 @@ WHERE VS.ServerID = @ServerID AND @IsAdmin = 1 -RETURN +RETURN GO SET ANSI_NULLS ON @@ -32106,15 +32106,15 @@ INSERT INTO CRMUserGuid, BusinessUnitID ) -VALUES +VALUES ( - @ItemID, + @ItemID, @CrmUserID, @BusinessUnitID ) - - + + END @@ -32181,7 +32181,7 @@ AS BEGIN SET @Exists = 1 END - + RETURN @@ -32221,7 +32221,7 @@ WHERE ItemID = @ItemID COMMIT TRAN -RETURN +RETURN @@ -32346,7 +32346,7 @@ GO -CREATE PROCEDURE [dbo].[OrganizationUserExists] +CREATE PROCEDURE [dbo].[OrganizationUserExists] ( @LoginName nvarchar(20), @Exists bit OUTPUT @@ -32447,13 +32447,13 @@ SELECT MailEnabledPublicFolder, MailboxManagerActions, SamAccountName, - AccountPassword, + AccountPassword, SubscriberNumber, UserPrincipalName FROM ExchangeAccounts WHERE AccountID = @AccountID -RETURN +RETURN GO @@ -32534,7 +32534,7 @@ exec sp_executesql @sql, N'@ItemID int, @IncludeMailboxes int, @IncludeContacts @IncludeDistributionLists int, @IncludeRooms bit, @IncludeEquipment bit', @ItemID, @IncludeMailboxes, @IncludeContacts, @IncludeDistributionLists, @IncludeRooms, @IncludeEquipment -RETURN +RETURN GO @@ -32609,10 +32609,10 @@ WHERE ' + @condition print @sql -exec sp_executesql @sql, N'@ItemID int, @IncludeMailboxes bit', +exec sp_executesql @sql, N'@ItemID int, @IncludeMailboxes bit', @ItemID, @IncludeMailboxes -RETURN +RETURN GO @@ -32677,7 +32677,7 @@ BEGIN SET @sql = @sql + ' SELECT COUNT(ItemID) FROM @Items; SELECT - + SI.ItemID, SI.ItemName, @@ -32685,7 +32685,7 @@ BEGIN P.PackageName, P.StatusID, P.PurchaseDate, - + -- user P.UserID, U.Username, @@ -32704,7 +32704,7 @@ ELSE BEGIN SET @SortColumn = REPLACE(@SortColumn, 'ItemName', 'DomainName') - + SET @sql = ' DECLARE @EndRow int SET @EndRow = @StartRow + @MaximumRows @@ -32733,7 +32733,7 @@ BEGIN SET @sql = @sql + ' SELECT COUNT(ItemID) FROM @Items; SELECT - + D.DomainID AS ItemID, D.DomainName AS ItemName, @@ -32741,7 +32741,7 @@ BEGIN P.PackageName, P.StatusID, P.PurchaseDate, - + -- user P.UserID, U.Username, @@ -32781,7 +32781,7 @@ GO -CREATE PROCEDURE [dbo].[SetExchangeAccountMailboxplan] +CREATE PROCEDURE [dbo].[SetExchangeAccountMailboxplan] ( @AccountID int, @MailboxPlanId int @@ -32928,7 +32928,7 @@ GO -CREATE PROCEDURE [dbo].[SetLyncUserLyncUserPlan] +CREATE PROCEDURE [dbo].[SetLyncUserLyncUserPlan] ( @AccountID int, @LyncUserPlanId int @@ -32950,7 +32950,7 @@ GO -CREATE PROCEDURE [dbo].[SetOrganizationDefaultExchangeMailboxPlan] +CREATE PROCEDURE [dbo].[SetOrganizationDefaultExchangeMailboxPlan] ( @ItemID int, @MailboxPlanId int @@ -32977,7 +32977,7 @@ GO -CREATE PROCEDURE [dbo].[SetOrganizationDefaultLyncUserPlan] +CREATE PROCEDURE [dbo].[SetOrganizationDefaultLyncUserPlan] ( @ItemID int, @LyncUserPlanId int @@ -33043,7 +33043,7 @@ XML Format: DECLARE @idoc int; --Create an internal representation of the XML document. EXEC sp_xml_preparedocument @idoc OUTPUT, @xml; - + DELETE FROM [dbo].[SystemSettings] WHERE [SettingsName] = @SettingsName; INSERT INTO [dbo].[SystemSettings] @@ -33056,7 +33056,7 @@ XML Format: @SettingsName, [XML].[PropertyName], [XML].[PropertyValue] - FROM OPENXML(@idoc, '/properties/property',1) WITH + FROM OPENXML(@idoc, '/properties/property',1) WITH ( [PropertyName] nvarchar(50) '@name', [PropertyValue] ntext '@value' @@ -33128,8 +33128,8 @@ CREATE PROCEDURE [dbo].[UpdateDnsRecord] @RecordData nvarchar(500), @MXPriority int, @SrvPriority int, - @SrvWeight int, - @SrvPort int, + @SrvWeight int, + @SrvPort int, @IPAddressID int ) AS @@ -33238,7 +33238,7 @@ GO -CREATE PROCEDURE [dbo].[UpdateExchangeAccount] +CREATE PROCEDURE [dbo].[UpdateExchangeAccount] ( @AccountID int, @AccountName nvarchar(300), @@ -33254,9 +33254,9 @@ CREATE PROCEDURE [dbo].[UpdateExchangeAccount] ) AS -BEGIN TRAN +BEGIN TRAN -IF (@MailboxPlanId = -1) +IF (@MailboxPlanId = -1) BEGIN SET @MailboxPlanId = NULL END @@ -33266,7 +33266,7 @@ UPDATE ExchangeAccounts SET DisplayName = @DisplayName, PrimaryEmailAddress = @PrimaryEmailAddress, MailEnabledPublicFolder = @MailEnabledPublicFolder, - MailboxManagerActions = @MailboxManagerActions, + MailboxManagerActions = @MailboxManagerActions, AccountType =@AccountType, SamAccountName = @SamAccountName, MailboxPlanId = @MailboxPlanId, @@ -33281,7 +33281,7 @@ IF (@@ERROR <> 0 ) RETURN -1 END -UPDATE ExchangeAccounts SET +UPDATE ExchangeAccounts SET AccountPassword = @Password WHERE AccountID = @AccountID AND @Password IS NOT NULL IF (@@ERROR <> 0 ) @@ -33297,7 +33297,7 @@ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER OFF GO - CREATE PROCEDURE [dbo].[UpdateExchangeAccountUserPrincipalName] + CREATE PROCEDURE [dbo].[UpdateExchangeAccountUserPrincipalName] ( @AccountID int, @UserPrincipalName nvarchar(300) @@ -33322,7 +33322,7 @@ GO -CREATE PROCEDURE [dbo].[UpdateExchangeMailboxPlan] +CREATE PROCEDURE [dbo].[UpdateExchangeMailboxPlan] ( @MailboxPlanId int, @MailboxPlan nvarchar(300), @@ -33498,7 +33498,7 @@ SELECT GroupID, CalculateDiskSpace, CalculateBandwidth -FROM OPENXML(@idoc, '/plan/groups/group',1) WITH +FROM OPENXML(@idoc, '/plan/groups/group',1) WITH ( GroupID int '@id', CalculateDiskSpace bit '@calculateDiskSpace', @@ -33516,7 +33516,7 @@ SELECT @PlanID, QuotaID, QuotaValue -FROM OPENXML(@idoc, '/plan/quotas/quota',1) WITH +FROM OPENXML(@idoc, '/plan/quotas/quota',1) WITH ( QuotaID int '@id', QuotaValue int '@value' @@ -33525,7 +33525,7 @@ FROM OPENXML(@idoc, '/plan/quotas/quota',1) WITH -- remove document exec sp_xml_removedocument @idoc -RETURN +RETURN @@ -33613,7 +33613,7 @@ END COMMIT TRAN -RETURN +RETURN @@ -33710,7 +33710,7 @@ SET @PlanID = SCOPE_IDENTITY() EXEC UpdateHostingPlanQuotas @ActorID, @PlanID, @QuotasXml COMMIT TRAN -RETURN +RETURN @@ -33770,7 +33770,7 @@ GO -CREATE PROCEDURE [dbo].[UpdateIPAddress] +CREATE PROCEDURE [dbo].[UpdateIPAddress] ( @AddressID int, @ServerID int, @@ -33865,7 +33865,7 @@ BEGIN DefaultGateway = @DefaultGateway, Comments = @Comments FROM IPAddresses AS IP - INNER JOIN OPENXML(@idoc, '/items/item', 1) WITH + INNER JOIN OPENXML(@idoc, '/items/item', 1) WITH ( AddressID int '@id' ) as PV ON IP.AddressID = PV.AddressID @@ -33898,7 +33898,7 @@ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER OFF GO -CREATE PROCEDURE [dbo].[UpdateLyncUser] +CREATE PROCEDURE [dbo].[UpdateLyncUser] ( @AccountID int, @SipAddress nvarchar(300) @@ -33924,7 +33924,7 @@ GO -CREATE PROCEDURE [dbo].[UpdateLyncUserPlan] +CREATE PROCEDURE [dbo].[UpdateLyncUserPlan] ( @LyncUserPlanId int, @LyncUserPlanName nvarchar(300), @@ -34147,14 +34147,14 @@ INSERT INTO @Items ItemID, LogDate, BytesSent, - BytesReceived + BytesReceived ) SELECT ItemID, CONVERT(datetime, LogDate, 101), BytesSent, BytesReceived -FROM OPENXML(@idoc, '/items/item',1) WITH +FROM OPENXML(@idoc, '/items/item',1) WITH ( ItemID int '@id', LogDate nvarchar(10) '@date', @@ -34192,7 +34192,7 @@ GROUP BY I.LogDate, SIT.GroupID -- remove document exec sp_xml_removedocument @idoc -RETURN +RETURN @@ -34275,7 +34275,7 @@ AS UPDATE Packages SET BandwidthUpdated = @UpdateDate WHERE PackageID = @PackageID -RETURN +RETURN @@ -34365,7 +34365,7 @@ DECLARE @Items TABLE ) INSERT INTO @Items (ItemID, Bytes) -SELECT ItemID, DiskSpace FROM OPENXML (@idoc, '/items/item',1) +SELECT ItemID, DiskSpace FROM OPENXML (@idoc, '/items/item',1) WITH ( ItemID int '@id', @@ -34613,7 +34613,7 @@ BEGIN -- delete old Package quotas DELETE FROM PackageQuotas WHERE PackageID = @PackageID - + DECLARE @idoc int --Create an internal representation of the XML document. EXEC sp_xml_preparedocument @idoc OUTPUT, @xml @@ -34631,7 +34631,7 @@ BEGIN GroupID, CalculateDiskSpace, CalculateBandwidth - FROM OPENXML(@idoc, '/plan/groups/group',1) WITH + FROM OPENXML(@idoc, '/plan/groups/group',1) WITH ( GroupID int '@id', CalculateDiskSpace bit '@calculateDiskSpace', @@ -34649,16 +34649,16 @@ BEGIN @PackageID, QuotaID, QuotaValue - FROM OPENXML(@idoc, '/plan/quotas/quota',1) WITH + FROM OPENXML(@idoc, '/plan/quotas/quota',1) WITH ( QuotaID int '@id', QuotaValue int '@value' ) as PV - + -- remove document exec sp_xml_removedocument @idoc END -RETURN +RETURN @@ -34763,7 +34763,7 @@ SELECT @SettingsName, PropertyName, PropertyValue -FROM OPENXML(@idoc, '/properties/property',1) WITH +FROM OPENXML(@idoc, '/properties/property',1) WITH ( PropertyName nvarchar(50) '@name', PropertyValue ntext '@value' @@ -34774,7 +34774,7 @@ exec sp_xml_removedocument @idoc COMMIT TRAN -RETURN +RETURN @@ -34898,7 +34898,7 @@ SET WeekMonthDay = @WeekMonthDay WHERE ScheduleID = @ScheduleID - + DECLARE @idoc int --Create an internal representation of the XML document. EXEC sp_xml_preparedocument @idoc OUTPUT, @XmlParameters @@ -34917,7 +34917,7 @@ SELECT @ScheduleID, ParameterID, ParameterValue -FROM OPENXML(@idoc, '/parameters/parameter',1) WITH +FROM OPENXML(@idoc, '/parameters/parameter',1) WITH ( ParameterID nvarchar(50) '@id', ParameterValue nvarchar(3000) '@value' @@ -35127,7 +35127,7 @@ SET ClusterID = @ClusterID WHERE ServiceID = @ServiceID -RETURN +RETURN @@ -35249,7 +35249,7 @@ SELECT @ItemID, PropertyName, PropertyValue -FROM OPENXML(@idoc, '/properties/property',1) WITH +FROM OPENXML(@idoc, '/properties/property',1) WITH ( PropertyName nvarchar(50) '@name', PropertyValue nvarchar(3000) '@value' @@ -35262,9 +35262,9 @@ INSERT INTO ServiceItemProperties PropertyName, PropertyValue ) -SELECT - ItemID, - PropertyName, +SELECT + ItemID, + PropertyName, PropertyValue FROM #TempTable @@ -35275,7 +35275,7 @@ exec sp_xml_removedocument @idoc COMMIT TRAN -RETURN +RETURN @@ -35366,7 +35366,7 @@ EXEC sp_xml_preparedocument @idoc OUTPUT, @xml -- Execute a SELECT statement that uses the OPENXML rowset provider. DELETE FROM ServiceProperties -WHERE ServiceID = @ServiceID +WHERE ServiceID = @ServiceID AND PropertyName COLLATE Latin1_General_CI_AS IN ( SELECT PropertyName @@ -35384,7 +35384,7 @@ SELECT @ServiceID, PropertyName, PropertyValue -FROM OPENXML(@idoc, '/properties/property',1) WITH +FROM OPENXML(@idoc, '/properties/property',1) WITH ( PropertyName nvarchar(50) '@name', PropertyValue nvarchar(1000) '@value' @@ -35394,7 +35394,7 @@ FROM OPENXML(@idoc, '/properties/property',1) WITH exec sp_xml_removedocument @idoc COMMIT TRAN -RETURN +RETURN @@ -35479,12 +35479,12 @@ AS IF @LoginStatusId = 0 BEGIN - UPDATE Users SET + UPDATE Users SET FailedLogins = 0 WHERE UserID = @UserID END - UPDATE Users SET + UPDATE Users SET RoleID = @RoleID, StatusID = @StatusID, SubscriberNumber = @SubscriberNumber, @@ -35641,7 +35641,7 @@ SELECT @SettingsName, PropertyName, PropertyValue -FROM OPENXML(@idoc, '/properties/property',1) WITH +FROM OPENXML(@idoc, '/properties/property',1) WITH ( PropertyName nvarchar(50) '@name', PropertyValue ntext '@value' @@ -35652,7 +35652,7 @@ exec sp_xml_removedocument @idoc COMMIT TRAN -RETURN +RETURN @@ -35767,7 +35767,7 @@ SELECT GroupID, DistributionType, BindDistributionToPrimary -FROM OPENXML(@idoc, '/groups/group',1) WITH +FROM OPENXML(@idoc, '/groups/group',1) WITH ( GroupID int '@id', DistributionType int '@distributionType', @@ -35778,7 +35778,7 @@ FROM OPENXML(@idoc, '/groups/group',1) WITH exec sp_xml_removedocument @idoc COMMIT TRAN -RETURN +RETURN @@ -36098,13 +36098,13 @@ AS INNER JOIN PackagesTreeCache AS PT ON PIP.PackageID = PT.PackageID WHERE PT.ParentPackageID = @PackageID AND IP.PoolID = 3) ELSE IF @QuotaID = 319 -- BB Users - SET @Result = (SELECT COUNT(ea.AccountID) FROM ExchangeAccounts ea + SET @Result = (SELECT COUNT(ea.AccountID) FROM ExchangeAccounts ea INNER JOIN BlackBerryUsers bu ON ea.AccountID = bu.AccountID INNER JOIN ServiceItems si ON ea.ItemID = si.ItemID INNER JOIN PackagesTreeCache pt ON si.PackageID = pt.PackageID WHERE pt.ParentPackageID = @PackageID) ELSE IF @QuotaID = 320 -- OCS Users - SET @Result = (SELECT COUNT(ea.AccountID) FROM ExchangeAccounts ea + SET @Result = (SELECT COUNT(ea.AccountID) FROM ExchangeAccounts ea INNER JOIN OCSUsers ocs ON ea.AccountID = ocs.AccountID INNER JOIN ServiceItems si ON ea.ItemID = si.ItemID INNER JOIN PackagesTreeCache pt ON si.PackageID = pt.PackageID @@ -36118,12 +36118,12 @@ AS SET @Result = (SELECT COUNT(ea.AccountID) FROM ExchangeAccounts AS ea INNER JOIN ServiceItems si ON ea.ItemID = si.ItemID INNER JOIN PackagesTreeCache pt ON si.PackageID = pt.PackageID - WHERE pt.ParentPackageID = @PackageID + WHERE pt.ParentPackageID = @PackageID AND ea.AccountType IN (1) AND ea.MailboxPlanId IS NOT NULL) ELSE IF @QuotaID = 77 -- Exchange2007.DiskSpace - SET @Result = (SELECT SUM(B.MailboxSizeMB) FROM ExchangeAccounts AS ea - INNER JOIN ExchangeMailboxPlans AS B ON ea.MailboxPlanId = B.MailboxPlanId + SET @Result = (SELECT SUM(B.MailboxSizeMB) FROM ExchangeAccounts AS ea + INNER JOIN ExchangeMailboxPlans AS B ON ea.MailboxPlanId = B.MailboxPlanId INNER JOIN ServiceItems si ON ea.ItemID = si.ItemID INNER JOIN PackagesTreeCache pt ON si.PackageID = pt.PackageID WHERE pt.ParentPackageID = @PackageID) @@ -36231,10 +36231,10 @@ BEGIN IF @ParentUserID IS NULL -- the last parent BREAK - + IF @ParentUserID = @ActorID RETURN 1 - + SET @TmpUserID = @ParentUserID END @@ -36369,10 +36369,10 @@ BEGIN IF @ParentUserID IS NULL -- the last parent BREAK - + IF @ParentUserID = @ActorID RETURN 1 - + SET @TmpUserID = @ParentUserID END @@ -36481,12 +36481,12 @@ BEGIN -- and his owner IF @UserID = @OwnerID RETURN 0 - + IF EXISTS ( SELECT UserID FROM Users WHERE IsPeer = 1 AND OwnerID = @OwnerID AND UserID = @UserID ) RETURN 0 - + -- set actor to his owner SET @ActorID = @OwnerID END @@ -36514,10 +36514,10 @@ BEGIN IF @ParentUserID IS NULL -- the last parent BREAK - + IF @ParentUserID = @ActorID RETURN 1 - + SET @TmpUserID = @ParentUserID END @@ -36739,10 +36739,10 @@ BEGIN IF @ParentUserID IS NULL -- the last parent BREAK - + IF @ParentUserID = @ActorID RETURN 1 - + SET @TmpUserID = @ParentUserID END @@ -36850,12 +36850,12 @@ BEGIN -- check if the peer is trying to update his owner IF @UserID = @OwnerID RETURN 0 - + -- check if the peer is trying to update his peers IF EXISTS (SELECT UserID FROM Users WHERE IsPeer = 1 AND OwnerID = @OwnerID AND UserID = @UserID) RETURN 0 - + SET @ActorID = @OwnerID END @@ -36875,10 +36875,10 @@ BEGIN IF @ParentUserID IS NULL -- the last parent BREAK - + IF @ParentUserID = @ActorID RETURN 1 - + SET @TmpUserID = @ParentUserID END @@ -37213,10 +37213,10 @@ BEGIN IF @ParentUserID IS NULL -- the last parent BREAK - + IF @ParentUserID = @ActorID RETURN 1 - + SET @TmpUserID = @ParentUserID END @@ -37310,7 +37310,7 @@ DECLARE @UsedAddons int INNER JOIN PackageQuotas AS PQ ON P.PackageID = PQ.PackageID AND PQ.QuotaID = @QuotaID WHERE P.ParentPackageID = @PackageID AND P.OverrideQuotas = 1 - + -- addons SELECT @UsedAddons = SUM(HPQ.QuotaValue * PA.Quantity) FROM Packages AS P @@ -37319,9 +37319,9 @@ DECLARE @UsedAddons int WHERE P.ParentPackageID = @PackageID AND HPQ.QuotaID = @QuotaID AND PA.StatusID = 1 -- active --SET @UsedQuantity = (SELECT SUM(dbo.GetPackageAllocatedQuota(PackageID, @QuotaID)) FROM Packages WHERE ParentPackageID = @PackageID) - + SET @UsedQuantity = @UsedPlans + @UsedOverrides + @UsedAddons - + IF @UsedQuantity IS NULL RETURN 0 -- can exceed @@ -37492,10 +37492,10 @@ BEGIN IF @TmpParentPackageID IS NULL -- the last parent package BREAK - + IF @TmpParentPackageID = @ParentPackageID RETURN 1 - + SET @TmpPackageID = @TmpParentPackageID END @@ -37620,10 +37620,10 @@ BEGIN IF @ParentUserID IS NULL -- the last parent BREAK - + IF @ParentUserID = @OwnerID RETURN 1 - + SET @TmpUserID = @ParentUserID END @@ -37883,7 +37883,7 @@ GO -CREATE FUNCTION dbo.GetPackageAllocatedQuota +CREATE FUNCTION dbo.GetPackageAllocatedQuota ( @PackageID int, @QuotaID int @@ -37912,7 +37912,7 @@ WHILE 1 = 1 BEGIN DECLARE @QuotaValue int - + -- get package info SELECT @ParentPackageID = ParentPackageID, @@ -37938,10 +37938,10 @@ BEGIN SELECT @QuotaValue = HPQ.QuotaValue FROM Packages AS P INNER JOIN HostingPlanQuotas AS HPQ ON P.PlanID = HPQ.PlanID WHERE HPQ.QuotaID = @QuotaID AND P.PackageID = @PID - + IF @QuotaValue IS NULL SET @QuotaValue = 0 - + -- check package addons DECLARE @QuotaAddonValue int SELECT @@ -37949,7 +37949,7 @@ BEGIN FROM PackageAddons AS PA INNER JOIN HostingPlanQuotas AS HPQ ON PA.PlanID = HPQ.PlanID WHERE PA.PackageID = @PID AND HPQ.QuotaID = @QuotaID AND PA.StatusID = 1 -- active - + -- process bool quota IF @QuotaAddonValue IS NOT NULL BEGIN @@ -37967,7 +37967,7 @@ BEGIN END END END - + -- process bool quota IF @QuotaTypeID = 1 BEGIN @@ -37978,14 +37978,14 @@ BEGIN BEGIN -- numeric quota IF @QuotaValue = 0 OR @QuotaValue IS NULL -- zero quantity RETURN 0 - + IF (@QuotaValue <> -1 AND @Result = -1) OR (@QuotaValue < @Result AND @QuotaValue <> -1) SET @Result = @QuotaValue END - + IF @ParentPackageID IS NULL RETURN @Result -- exit from the loop - + SET @PID = @ParentPackageID END -- end while @@ -38088,7 +38088,7 @@ WHILE 1 = 1 BEGIN DECLARE @GroupEnabled int - + -- get package info SELECT @ParentPackageID = ParentPackageID, @@ -38099,14 +38099,14 @@ BEGIN SET @GroupEnabled = 1 -- enabled IF @ParentPackageID IS NULL BEGIN - + IF @ServerID = -1 OR @ServerID IS NULL RETURN 1 - + IF EXISTS (SELECT VirtualServer FROM Servers WHERE ServerID = @ServerID AND VirtualServer = 1) BEGIN IF NOT EXISTS( - SELECT + SELECT DISTINCT(PROV.GroupID) FROM VirtualServices AS VS INNER JOIN Services AS S ON VS.ServiceID = S.ServiceID @@ -38118,7 +38118,7 @@ BEGIN ELSE BEGIN IF NOT EXISTS( - SELECT + SELECT DISTINCT(PROV.GroupID) FROM Services AS S INNER JOIN Providers AS PROV ON S.ProviderID = PROV.ProviderID @@ -38126,7 +38126,7 @@ BEGIN ) SET @GroupEnabled = 0 END - + RETURN @GroupEnabled -- exit from the loop END ELSE -- parentpackage is not null @@ -38148,7 +38148,7 @@ BEGIN ) SET @GroupEnabled = 0 END - + -- check addons IF EXISTS( SELECT HPR.GroupID FROM PackageAddons AS PA @@ -38158,10 +38158,10 @@ BEGIN ) SET @GroupEnabled = 1 END - + IF @GroupEnabled = 0 RETURN 0 - + SET @PID = @ParentPackageID END -- end while @@ -38316,19 +38316,19 @@ BEGIN -- owner DECLARE @ParentPackageID int, @TmpPackageID int SET @TmpPackageID = @PackageID - + WHILE 10 = 10 BEGIN - + SET @ParentPackageID = NULL --reset var SELECT @ParentPackageID = ParentPackageID FROM Packages WHERE PackageID = @TmpPackageID - + IF @ParentPackageID IS NULL -- parent not found BREAK - + INSERT @T VALUES (@ParentPackageID) - + SET @TmpPackageID = @ParentPackageID END @@ -38423,7 +38423,7 @@ INSERT INTO @T VALUES (@PackageID) IF @Recursive = 1 BEGIN - WITH RecursivePackages(ParentPackageID, PackageID, PackageLevel) AS + WITH RecursivePackages(ParentPackageID, PackageID, PackageLevel) AS ( SELECT ParentPackageID, PackageID, 0 AS PackageLevel FROM Packages @@ -38439,7 +38439,7 @@ BEGIN SELECT PackageID FROM RecursivePackages END - + RETURN END @@ -38527,7 +38527,7 @@ AS BEGIN -- insert current user INSERT @T VALUES (@UserID) - + DECLARE @TopUserID int IF @ActorID = -1 BEGIN @@ -38536,14 +38536,14 @@ BEGIN ELSE BEGIN SET @TopUserID = @ActorID - + IF EXISTS (SELECT UserID FROM Users WHERE UserID = @ActorID AND IsPeer = 1) SELECT @TopUserID = OwnerID FROM Users WHERE UserID = @ActorID AND IsPeer = 1 END -- owner DECLARE @OwnerID int, @TmpUserID int - + SET @TmpUserID = @UserID WHILE (@TmpUserID <> @TopUserID) @@ -38551,7 +38551,7 @@ BEGIN SET @OwnerID = NULL SELECT @OwnerID = OwnerID FROM Users WHERE UserID = @TmpUserID - + IF @OwnerID IS NOT NULL BEGIN INSERT @T VALUES (@OwnerID) @@ -38650,7 +38650,7 @@ BEGIN BEGIN -- insert "root" user INSERT @T VALUES(@OwnerID) - + -- get all children recursively WHILE @@ROWCOUNT > 0 BEGIN @@ -38663,7 +38663,7 @@ BEGIN BEGIN INSERT @T VALUES(@OwnerID) END - + RETURN END @@ -38722,7 +38722,7 @@ CREATE TABLE [dbo].[AuditLog]( [ItemName] [nvarchar](100) COLLATE Latin1_General_CI_AS NULL, [ExecutionLog] [ntext] COLLATE Latin1_General_CI_AS NULL, [PackageID] [int] NULL, - CONSTRAINT [PK_Log] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_Log] PRIMARY KEY CLUSTERED ( [RecordID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) @@ -38735,7 +38735,7 @@ SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[AuditLogSources]( [SourceName] [varchar](100) COLLATE Latin1_General_CI_AS NOT NULL, - CONSTRAINT [PK_AuditLogSources] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_AuditLogSources] PRIMARY KEY CLUSTERED ( [SourceName] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) @@ -38750,7 +38750,7 @@ CREATE TABLE [dbo].[AuditLogTasks]( [SourceName] [varchar](100) COLLATE Latin1_General_CI_AS NOT NULL, [TaskName] [varchar](100) COLLATE Latin1_General_CI_AS NOT NULL, [TaskDescription] [nvarchar](100) COLLATE Latin1_General_CI_AS NULL, - CONSTRAINT [PK_LogActions] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_LogActions] PRIMARY KEY CLUSTERED ( [SourceName] ASC, [TaskName] ASC @@ -38767,7 +38767,7 @@ CREATE TABLE [dbo].[BlackBerryUsers]( [AccountId] [int] NOT NULL, [CreatedDate] [datetime] NOT NULL, [ModifiedDate] [datetime] NOT NULL, - CONSTRAINT [PK_BlackBerryUsers] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_BlackBerryUsers] PRIMARY KEY CLUSTERED ( [BlackBerryUserId] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) @@ -38781,7 +38781,7 @@ GO CREATE TABLE [dbo].[Clusters]( [ClusterID] [int] IDENTITY(1,1) NOT NULL, [ClusterName] [nvarchar](100) COLLATE Latin1_General_CI_AS NOT NULL, - CONSTRAINT [PK_Clusters] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_Clusters] PRIMARY KEY CLUSTERED ( [ClusterID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) @@ -38800,7 +38800,7 @@ CREATE TABLE [dbo].[Comments]( [CreatedDate] [datetime] NOT NULL, [CommentText] [nvarchar](1000) COLLATE Latin1_General_CI_AS NULL, [SeverityID] [int] NULL, - CONSTRAINT [PK_Comments] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_Comments] PRIMARY KEY CLUSTERED ( [CommentID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) @@ -38818,7 +38818,7 @@ CREATE TABLE [dbo].[CRMUsers]( [ChangedDate] [datetime] NOT NULL, [CRMUserGuid] [uniqueidentifier] NULL, [BusinessUnitID] [uniqueidentifier] NULL, - CONSTRAINT [PK_CRMUsers] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_CRMUsers] PRIMARY KEY CLUSTERED ( [CRMUserID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) @@ -38841,7 +38841,7 @@ CREATE TABLE [dbo].[Domains]( [IsInstantAlias] [bit] NOT NULL, [IsDomainPointer] [bit] NOT NULL, [DomainItemId] [int] NULL, - CONSTRAINT [PK_Domains] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_Domains] PRIMARY KEY CLUSTERED ( [DomainID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) @@ -38856,7 +38856,7 @@ CREATE TABLE [dbo].[ecAddonProducts]( [AddonID] [int] NOT NULL, [ProductID] [int] NOT NULL, [ResellerID] [int] NOT NULL, - CONSTRAINT [PK_ecAddonProducts] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_ecAddonProducts] PRIMARY KEY CLUSTERED ( [AddonID] ASC, [ProductID] ASC, @@ -38876,7 +38876,7 @@ CREATE TABLE [dbo].[ecBillingCycles]( [BillingPeriod] [nvarchar](50) COLLATE Latin1_General_CI_AS NOT NULL, [PeriodLength] [int] NOT NULL, [Created] [datetime] NOT NULL, - CONSTRAINT [PK_ecBillingCycles] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_ecBillingCycles] PRIMARY KEY CLUSTERED ( [CycleID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) @@ -38901,7 +38901,7 @@ CREATE TABLE [dbo].[ecCategory]( [ModifierID] [int] NULL, [ItemOrder] [int] NULL, [ResellerID] [int] NOT NULL, - CONSTRAINT [PK_EC_Categories] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_EC_Categories] PRIMARY KEY CLUSTERED ( [CategoryID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) @@ -38927,7 +38927,7 @@ CREATE TABLE [dbo].[ecContracts]( [CompanyName] [nvarchar](50) COLLATE Latin1_General_CI_AS NULL, [PropertyNames] [ntext] COLLATE Latin1_General_CI_AS NULL, [PropertyValues] [ntext] COLLATE Latin1_General_CI_AS NULL, - CONSTRAINT [PK_ecContracts] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_ecContracts] PRIMARY KEY CLUSTERED ( [ContractID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) @@ -38949,7 +38949,7 @@ CREATE TABLE [dbo].[ecCustomersPayments]( [PluginID] [int] NOT NULL, [StatusID] [int] NOT NULL, [ContractID] [nvarchar](50) COLLATE Latin1_General_CI_AS NOT NULL, - CONSTRAINT [PK_EC_Payments] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_EC_Payments] PRIMARY KEY CLUSTERED ( [PaymentID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) @@ -38969,7 +38969,7 @@ CREATE TABLE [dbo].[ecDomainSvcs]( [SvcCycleID] [int] NULL, [PropertyNames] [ntext] COLLATE Latin1_General_CI_AS NULL, [PropertyValues] [ntext] COLLATE Latin1_General_CI_AS NULL, - CONSTRAINT [PK_ecDomainsSvcs] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_ecDomainsSvcs] PRIMARY KEY CLUSTERED ( [ServiceID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) @@ -38989,7 +38989,7 @@ CREATE TABLE [dbo].[ecDomainSvcsCycles]( [SetupFee] [money] NOT NULL, [RecurringFee] [money] NOT NULL, [Currency] [nvarchar](3) COLLATE Latin1_General_CI_AS NOT NULL, - CONSTRAINT [PK_ecDomainsSvcsCycles] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_ecDomainsSvcsCycles] PRIMARY KEY CLUSTERED ( [SvcCycleID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) @@ -39023,7 +39023,7 @@ CREATE TABLE [dbo].[ecHostingAddonsCycles]( [SetupFee] [money] NOT NULL, [RecurringFee] [money] NOT NULL, [SortOrder] [int] NOT NULL, - CONSTRAINT [PK_ecHostingAddonsCycles] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_ecHostingAddonsCycles] PRIMARY KEY CLUSTERED ( [ProductID] ASC, [CycleID] ASC @@ -39044,7 +39044,7 @@ CREATE TABLE [dbo].[ecHostingAddonSvcs]( [Recurring] [bit] NOT NULL, [DummyAddon] [bit] NOT NULL, [SvcCycleID] [int] NOT NULL, - CONSTRAINT [PK_ecAddonPackagesSvcs] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_ecAddonPackagesSvcs] PRIMARY KEY CLUSTERED ( [ServiceID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) @@ -39064,7 +39064,7 @@ CREATE TABLE [dbo].[ecHostingAddonSvcsCycles]( [SetupFee] [money] NULL, [CyclePrice] [money] NOT NULL, [Currency] [nvarchar](3) COLLATE Latin1_General_CI_AS NOT NULL, - CONSTRAINT [PK_ecAddonPackagesSvcsCycles] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_ecAddonPackagesSvcsCycles] PRIMARY KEY CLUSTERED ( [SvcCycleID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) @@ -39083,7 +39083,7 @@ CREATE TABLE [dbo].[ecHostingPackageSvcs]( [UserRole] [int] NOT NULL, [InitialStatus] [int] NOT NULL, [SvcCycleID] [int] NOT NULL, - CONSTRAINT [PK_ecPackagesSvcs] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_ecPackagesSvcs] PRIMARY KEY CLUSTERED ( [ServiceID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) @@ -39103,7 +39103,7 @@ CREATE TABLE [dbo].[ecHostingPackageSvcsCycles]( [SetupFee] [money] NULL, [RecurringFee] [money] NOT NULL, [Currency] [nvarchar](3) COLLATE Latin1_General_CI_AS NOT NULL, - CONSTRAINT [PK_ecPackagesSvcsCycles] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_ecPackagesSvcsCycles] PRIMARY KEY CLUSTERED ( [SvcCycleID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) @@ -39121,7 +39121,7 @@ CREATE TABLE [dbo].[ecHostingPlans]( [UserRole] [int] NOT NULL, [InitialStatus] [int] NOT NULL, [DomainOption] [int] NOT NULL, - CONSTRAINT [PK_ecHostingPlans] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_ecHostingPlans] PRIMARY KEY CLUSTERED ( [ProductID] ASC, [ResellerID] ASC, @@ -39140,7 +39140,7 @@ CREATE TABLE [dbo].[ecHostingPlansBillingCycles]( [SetupFee] [money] NOT NULL, [RecurringFee] [money] NOT NULL, [SortOrder] [int] NOT NULL, - CONSTRAINT [PK_ecHostingPlansBillingCycles] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_ecHostingPlansBillingCycles] PRIMARY KEY CLUSTERED ( [ProductID] ASC, [CycleID] ASC @@ -39163,7 +39163,7 @@ CREATE TABLE [dbo].[ecInvoice]( [InvoiceNumber] [nvarchar](50) COLLATE Latin1_General_CI_AS NULL, [TaxationID] [int] NULL, [ContractID] [nvarchar](50) COLLATE Latin1_General_CI_AS NOT NULL, - CONSTRAINT [PK_EC_Invoices] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_EC_Invoices] PRIMARY KEY CLUSTERED ( [InvoiceID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) @@ -39185,7 +39185,7 @@ CREATE TABLE [dbo].[ecInvoiceItems]( [SubTotal] [money] NOT NULL, [UnitPrice] [money] NOT NULL, [Processed] [bit] NOT NULL, - CONSTRAINT [PK_EC_InvoiceItems] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_EC_InvoiceItems] PRIMARY KEY CLUSTERED ( [ItemID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) @@ -39202,7 +39202,7 @@ CREATE TABLE [dbo].[ecPaymentMethods]( [PluginID] [int] NOT NULL, [DisplayName] [nvarchar](50) COLLATE Latin1_General_CI_AS NOT NULL, [SupportedItems] [nvarchar](255) COLLATE Latin1_General_CI_AS NULL, - CONSTRAINT [PK_ecPaymentMethods] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_ecPaymentMethods] PRIMARY KEY CLUSTERED ( [ResellerID] ASC, [MethodName] ASC @@ -39219,7 +39219,7 @@ CREATE TABLE [dbo].[ecPaymentProfiles]( [PropertyValues] [ntext] COLLATE Latin1_General_CI_AS NOT NULL, [Created] [datetime] NOT NULL, [ContractID] [nvarchar](50) COLLATE Latin1_General_CI_AS NOT NULL, - CONSTRAINT [PK_ecPaymentProfiles] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_ecPaymentProfiles] PRIMARY KEY CLUSTERED ( [ContractID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) @@ -39235,7 +39235,7 @@ CREATE TABLE [dbo].[ecPluginsProperties]( [PropertyName] [nvarchar](50) COLLATE Latin1_General_CI_AS NOT NULL, [PropertyValue] [nvarchar](512) COLLATE Latin1_General_CI_AS NULL, [ResellerID] [int] NOT NULL, - CONSTRAINT [PK_ecPluginsSettings] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_ecPluginsSettings] PRIMARY KEY CLUSTERED ( [PluginID] ASC, [ResellerID] ASC, @@ -39258,7 +39258,7 @@ CREATE TABLE [dbo].[ecProduct]( [Enabled] [bit] NOT NULL, [ResellerID] [int] NOT NULL, [TaxInclusive] [bit] NULL, - CONSTRAINT [PK_EC_Products] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_EC_Products] PRIMARY KEY CLUSTERED ( [ProductID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) @@ -39273,7 +39273,7 @@ CREATE TABLE [dbo].[ecProductCategories]( [ProductID] [int] NOT NULL, [CategoryID] [int] NOT NULL, [ResellerID] [int] NOT NULL, - CONSTRAINT [PK_ecProductCategories] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_ecProductCategories] PRIMARY KEY CLUSTERED ( [ProductID] ASC, [CategoryID] ASC, @@ -39304,7 +39304,7 @@ CREATE TABLE [dbo].[ecProductType]( [Created] [datetime] NOT NULL, [NativeItemType] [nvarchar](512) COLLATE Latin1_General_CI_AS NOT NULL, [ServiceItemType] [nvarchar](512) COLLATE Latin1_General_CI_AS NOT NULL, - CONSTRAINT [PK_EC_ProductTypes] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_EC_ProductTypes] PRIMARY KEY CLUSTERED ( [TypeID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) @@ -39319,7 +39319,7 @@ CREATE TABLE [dbo].[ecProductTypeControls]( [TypeID] [int] NOT NULL, [ControlKey] [nvarchar](50) COLLATE Latin1_General_CI_AS NOT NULL, [ControlSrc] [nvarchar](512) COLLATE Latin1_General_CI_AS NOT NULL, - CONSTRAINT [PK_ecProductTypeControls] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_ecProductTypeControls] PRIMARY KEY CLUSTERED ( [TypeID] ASC, [ControlKey] ASC @@ -39340,7 +39340,7 @@ CREATE TABLE [dbo].[ecService]( [Modified] [datetime] NULL, [ParentID] [int] NULL, [ContractID] [nvarchar](50) COLLATE Latin1_General_CI_AS NOT NULL, - CONSTRAINT [PK_SpaceInstances] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_SpaceInstances] PRIMARY KEY CLUSTERED ( [ServiceID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) @@ -39359,7 +39359,7 @@ CREATE TABLE [dbo].[ecServiceHandlersResponses]( [TextResponse] [ntext] COLLATE Latin1_General_CI_AS NULL, [Received] [datetime] NOT NULL, [ErrorMessage] [nvarchar](255) COLLATE Latin1_General_CI_AS NULL, - CONSTRAINT [PK_ecServiceHandlersResponses] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_ecServiceHandlersResponses] PRIMARY KEY CLUSTERED ( [ResponseID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) @@ -39374,7 +39374,7 @@ CREATE TABLE [dbo].[ecStoreDefaultSettings]( [SettingsName] [nvarchar](50) COLLATE Latin1_General_CI_AS NOT NULL, [PropertyName] [nvarchar](50) COLLATE Latin1_General_CI_AS NOT NULL, [PropertyValue] [ntext] COLLATE Latin1_General_CI_AS NULL, - CONSTRAINT [PK_ecSpaceDefaultSettings] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_ecSpaceDefaultSettings] PRIMARY KEY CLUSTERED ( [SettingsName] ASC, [PropertyName] ASC @@ -39391,7 +39391,7 @@ CREATE TABLE [dbo].[ecStoreSettings]( [PropertyName] [nvarchar](50) COLLATE Latin1_General_CI_AS NOT NULL, [PropertyValue] [ntext] COLLATE Latin1_General_CI_AS NULL, [ResellerID] [int] NOT NULL, - CONSTRAINT [PK_ecSystemSettings] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_ecSystemSettings] PRIMARY KEY CLUSTERED ( [ResellerID] ASC, [SettingsName] ASC, @@ -39411,7 +39411,7 @@ CREATE TABLE [dbo].[ecSupportedPluginLog]( [RawData] [ntext] COLLATE Latin1_General_CI_AS NOT NULL, [Created] [datetime] NOT NULL, [ContractID] [nvarchar](50) COLLATE Latin1_General_CI_AS NOT NULL, - CONSTRAINT [PK_ecSpacePluginLog] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_ecSpacePluginLog] PRIMARY KEY CLUSTERED ( [RecordID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) @@ -39431,7 +39431,7 @@ CREATE TABLE [dbo].[ecSupportedPlugins]( [Interactive] [bit] NOT NULL, [SupportedItems] [nvarchar](255) COLLATE Latin1_General_CI_AS NULL, [UniqueID] [nvarchar](50) COLLATE Latin1_General_CI_AS NULL, - CONSTRAINT [PK_ecSupportedPlugins] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_ecSupportedPlugins] PRIMARY KEY CLUSTERED ( [PluginID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) @@ -39448,7 +39448,7 @@ CREATE TABLE [dbo].[ecSvcsUsageLog]( [EndDate] [datetime] NOT NULL, [SvcCycleID] [int] NOT NULL, [PeriodClosed] [bit] NULL, - CONSTRAINT [PK_ecServicesLifeCyclesLog] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_ecServicesLifeCyclesLog] PRIMARY KEY CLUSTERED ( [ServiceID] ASC, [SvcCycleID] ASC, @@ -39469,7 +39469,7 @@ CREATE TABLE [dbo].[ecSystemTriggers]( [ReferenceID] [nvarchar](50) COLLATE Latin1_General_CI_AS NOT NULL, [Namespace] [nvarchar](255) COLLATE Latin1_General_CI_AS NOT NULL, [Status] [nvarchar](50) COLLATE Latin1_General_CI_AS NULL, - CONSTRAINT [PK_ecSystemTriggers] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_ecSystemTriggers] PRIMARY KEY CLUSTERED ( [TriggerID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) @@ -39489,7 +39489,7 @@ CREATE TABLE [dbo].[ecTaxations]( [TypeID] [int] NOT NULL, [Amount] [decimal](5, 2) NOT NULL, [Active] [bit] NOT NULL, - CONSTRAINT [PK_ecTaxations_1] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_ecTaxations_1] PRIMARY KEY CLUSTERED ( [TaxationID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) @@ -39506,7 +39506,7 @@ CREATE TABLE [dbo].[ecTopLevelDomains]( [PluginID] [int] NOT NULL, [ResellerID] [int] NOT NULL, [WhoisEnabled] [bit] NULL, - CONSTRAINT [PK_ecTopLevelDomains] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_ecTopLevelDomains] PRIMARY KEY CLUSTERED ( [TopLevelDomain] ASC, [ResellerID] ASC @@ -39536,7 +39536,7 @@ CREATE TABLE [dbo].[ExchangeAccountEmailAddresses]( [AddressID] [int] IDENTITY(1,1) NOT NULL, [AccountID] [int] NOT NULL, [EmailAddress] [nvarchar](300) COLLATE Latin1_General_CI_AS NOT NULL, - CONSTRAINT [PK_ExchangeAccountEmailAddresses] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_ExchangeAccountEmailAddresses] PRIMARY KEY CLUSTERED ( [AddressID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) @@ -39562,7 +39562,7 @@ CREATE TABLE [dbo].[ExchangeAccounts]( [MailboxPlanId] [int] NULL, [SubscriberNumber] [nvarchar](32) COLLATE Latin1_General_CI_AS NULL, [UserPrincipalName] [nvarchar](300) COLLATE Latin1_General_CI_AS NULL, - CONSTRAINT [PK_ExchangeAccounts] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_ExchangeAccounts] PRIMARY KEY CLUSTERED ( [AccountID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) @@ -39593,7 +39593,7 @@ CREATE TABLE [dbo].[ExchangeMailboxPlans]( [ProhibitSendPct] [int] NOT NULL, [ProhibitSendReceivePct] [int] NOT NULL, [HideFromAddressBook] [bit] NOT NULL, - CONSTRAINT [PK_ExchangeMailboxPlans] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_ExchangeMailboxPlans] PRIMARY KEY CLUSTERED ( [MailboxPlanId] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) @@ -39610,7 +39610,7 @@ CREATE TABLE [dbo].[ExchangeOrganizationDomains]( [DomainID] [int] NULL, [IsHost] [bit] NULL, [DomainTypeID] [int] NOT NULL, - CONSTRAINT [PK_ExchangeOrganizationDomains] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_ExchangeOrganizationDomains] PRIMARY KEY CLUSTERED ( [OrganizationDomainID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) @@ -39626,7 +39626,7 @@ CREATE TABLE [dbo].[ExchangeOrganizations]( [OrganizationID] [nvarchar](128) COLLATE Latin1_General_CI_AS NOT NULL, [ExchangeMailboxPlanID] [int] NULL, [LyncUserPlanID] [int] NULL, - CONSTRAINT [PK_ExchangeOrganizations] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_ExchangeOrganizations] PRIMARY KEY CLUSTERED ( [ItemID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) @@ -39650,7 +39650,7 @@ CREATE TABLE [dbo].[GlobalDnsRecords]( [SrvPriority] [int] NULL, [SrvWeight] [int] NULL, [SrvPort] [int] NULL, - CONSTRAINT [PK_GlobalDnsRecords] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_GlobalDnsRecords] PRIMARY KEY CLUSTERED ( [RecordID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) @@ -39665,7 +39665,7 @@ CREATE TABLE [dbo].[HostingPlanQuotas]( [PlanID] [int] NOT NULL, [QuotaID] [int] NOT NULL, [QuotaValue] [int] NOT NULL, - CONSTRAINT [PK_HostingPlanQuotas_1] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_HostingPlanQuotas_1] PRIMARY KEY CLUSTERED ( [PlanID] ASC, [QuotaID] ASC @@ -39682,7 +39682,7 @@ CREATE TABLE [dbo].[HostingPlanResources]( [GroupID] [int] NOT NULL, [CalculateDiskSpace] [bit] NULL, [CalculateBandwidth] [bit] NULL, - CONSTRAINT [PK_HostingPlanResources] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_HostingPlanResources] PRIMARY KEY CLUSTERED ( [PlanID] ASC, [GroupID] ASC @@ -39707,7 +39707,7 @@ CREATE TABLE [dbo].[HostingPlans]( [RecurrenceUnit] [int] NULL, [RecurrenceLength] [int] NULL, [IsAddon] [bit] NULL, - CONSTRAINT [PK_HostingPlans] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_HostingPlans] PRIMARY KEY CLUSTERED ( [PlanID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) @@ -39727,7 +39727,7 @@ CREATE TABLE [dbo].[IPAddresses]( [SubnetMask] [varchar](15) COLLATE Latin1_General_CI_AS NULL, [DefaultGateway] [varchar](15) COLLATE Latin1_General_CI_AS NULL, [PoolID] [int] NULL, - CONSTRAINT [PK_IPAddresses] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_IPAddresses] PRIMARY KEY CLUSTERED ( [AddressID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) @@ -39751,7 +39751,7 @@ CREATE TABLE [dbo].[LyncUserPlans]( [EnterpriseVoice] [bit] NOT NULL, [VoicePolicy] [int] NOT NULL, [IsDefault] [bit] NOT NULL, - CONSTRAINT [PK_LyncUserPlans] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_LyncUserPlans] PRIMARY KEY CLUSTERED ( [LyncUserPlanId] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) @@ -39769,7 +39769,7 @@ CREATE TABLE [dbo].[LyncUsers]( [CreatedDate] [datetime] NOT NULL, [ModifiedDate] [datetime] NOT NULL, [SipAddress] [nvarchar](300) COLLATE Latin1_General_CI_AS NULL, - CONSTRAINT [PK_LyncUsers] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_LyncUsers] PRIMARY KEY CLUSTERED ( [LyncUserID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) @@ -39786,7 +39786,7 @@ CREATE TABLE [dbo].[OCSUsers]( [InstanceID] [nvarchar](50) COLLATE Latin1_General_CI_AS NOT NULL, [CreatedDate] [datetime] NOT NULL, [ModifiedDate] [datetime] NOT NULL, - CONSTRAINT [PK_OCSUsers] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_OCSUsers] PRIMARY KEY CLUSTERED ( [OCSUserID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) @@ -39805,7 +39805,7 @@ CREATE TABLE [dbo].[PackageAddons]( [PurchaseDate] [datetime] NULL, [Comments] [ntext] COLLATE Latin1_General_CI_AS NULL, [StatusID] [int] NULL, - CONSTRAINT [PK_PackageAddons] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_PackageAddons] PRIMARY KEY CLUSTERED ( [PackageAddonID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) @@ -39822,7 +39822,7 @@ CREATE TABLE [dbo].[PackageIPAddresses]( [AddressID] [int] NOT NULL, [ItemID] [int] NULL, [IsPrimary] [bit] NULL, - CONSTRAINT [PK_PackageIPAddresses] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_PackageIPAddresses] PRIMARY KEY CLUSTERED ( [PackageAddressID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) @@ -39837,7 +39837,7 @@ CREATE TABLE [dbo].[PackageQuotas]( [PackageID] [int] NOT NULL, [QuotaID] [int] NOT NULL, [QuotaValue] [int] NOT NULL, - CONSTRAINT [PK_PackageQuotas] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_PackageQuotas] PRIMARY KEY CLUSTERED ( [PackageID] ASC, [QuotaID] ASC @@ -39854,7 +39854,7 @@ CREATE TABLE [dbo].[PackageResources]( [GroupID] [int] NOT NULL, [CalculateDiskspace] [bit] NOT NULL, [CalculateBandwidth] [bit] NOT NULL, - CONSTRAINT [PK_PackageResources_1] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_PackageResources_1] PRIMARY KEY CLUSTERED ( [PackageID] ASC, [GroupID] ASC @@ -39878,7 +39878,7 @@ CREATE TABLE [dbo].[Packages]( [PurchaseDate] [datetime] NULL, [OverrideQuotas] [bit] NOT NULL, [BandwidthUpdated] [datetime] NULL, - CONSTRAINT [PK_Packages] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_Packages] PRIMARY KEY CLUSTERED ( [PackageID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) @@ -39895,7 +39895,7 @@ CREATE TABLE [dbo].[PackagesBandwidth]( [LogDate] [datetime] NOT NULL, [BytesSent] [bigint] NOT NULL, [BytesReceived] [bigint] NOT NULL, - CONSTRAINT [PK_PackagesBandwidth] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_PackagesBandwidth] PRIMARY KEY CLUSTERED ( [PackageID] ASC, [GroupID] ASC, @@ -39912,7 +39912,7 @@ CREATE TABLE [dbo].[PackagesDiskspace]( [PackageID] [int] NOT NULL, [GroupID] [int] NOT NULL, [DiskSpace] [bigint] NOT NULL, - CONSTRAINT [PK_PackagesDiskspace] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_PackagesDiskspace] PRIMARY KEY CLUSTERED ( [PackageID] ASC, [GroupID] ASC @@ -39927,7 +39927,7 @@ GO CREATE TABLE [dbo].[PackageServices]( [PackageID] [int] NOT NULL, [ServiceID] [int] NOT NULL, - CONSTRAINT [PK_PackageServices] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_PackageServices] PRIMARY KEY CLUSTERED ( [PackageID] ASC, [ServiceID] ASC @@ -39944,7 +39944,7 @@ CREATE TABLE [dbo].[PackageSettings]( [SettingsName] [nvarchar](50) COLLATE Latin1_General_CI_AS NOT NULL, [PropertyName] [nvarchar](50) COLLATE Latin1_General_CI_AS NOT NULL, [PropertyValue] [ntext] COLLATE Latin1_General_CI_AS NULL, - CONSTRAINT [PK_PackageSettings] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_PackageSettings] PRIMARY KEY CLUSTERED ( [PackageID] ASC, [SettingsName] ASC, @@ -39972,7 +39972,7 @@ CREATE TABLE [dbo].[PrivateIPAddresses]( [ItemID] [int] NOT NULL, [IPAddress] [varchar](15) COLLATE Latin1_General_CI_AS NOT NULL, [IsPrimary] [bit] NOT NULL, - CONSTRAINT [PK_PrivateIPAddresses] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_PrivateIPAddresses] PRIMARY KEY CLUSTERED ( [PrivateAddressID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) @@ -39991,7 +39991,7 @@ CREATE TABLE [dbo].[Providers]( [ProviderType] [nvarchar](400) COLLATE Latin1_General_CI_AS NULL, [EditorControl] [nvarchar](100) COLLATE Latin1_General_CI_AS NULL, [DisableAutoDiscovery] [bit] NULL, - CONSTRAINT [PK_ServiceTypes] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_ServiceTypes] PRIMARY KEY CLUSTERED ( [ProviderID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) @@ -40012,7 +40012,7 @@ CREATE TABLE [dbo].[Quotas]( [ServiceQuota] [bit] NULL, [ItemTypeID] [int] NULL, [HideQuota] [bit] NULL, - CONSTRAINT [PK_Quotas] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_Quotas] PRIMARY KEY CLUSTERED ( [QuotaID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) @@ -40031,7 +40031,7 @@ CREATE TABLE [dbo].[ResourceGroupDnsRecords]( [RecordName] [nvarchar](50) COLLATE Latin1_General_CI_AS NOT NULL, [RecordData] [nvarchar](200) COLLATE Latin1_General_CI_AS NOT NULL, [MXPriority] [int] NULL, - CONSTRAINT [PK_ResourceGroupDnsRecords] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_ResourceGroupDnsRecords] PRIMARY KEY CLUSTERED ( [RecordID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) @@ -40048,7 +40048,7 @@ CREATE TABLE [dbo].[ResourceGroups]( [GroupOrder] [int] NOT NULL, [GroupController] [nvarchar](1000) COLLATE Latin1_General_CI_AS NULL, [ShowGroup] [bit] NULL, - CONSTRAINT [PK_ResourceGroups] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_ResourceGroups] PRIMARY KEY CLUSTERED ( [GroupID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) @@ -40076,7 +40076,7 @@ CREATE TABLE [dbo].[Schedule]( [HistoriesNumber] [int] NULL, [MaxExecutionTime] [int] NULL, [WeekMonthDay] [int] NULL, - CONSTRAINT [PK_Schedule] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_Schedule] PRIMARY KEY CLUSTERED ( [ScheduleID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) @@ -40091,7 +40091,7 @@ CREATE TABLE [dbo].[ScheduleParameters]( [ScheduleID] [int] NOT NULL, [ParameterID] [nvarchar](100) COLLATE Latin1_General_CI_AS NOT NULL, [ParameterValue] [nvarchar](1000) COLLATE Latin1_General_CI_AS NULL, - CONSTRAINT [PK_ScheduleParameters] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_ScheduleParameters] PRIMARY KEY CLUSTERED ( [ScheduleID] ASC, [ParameterID] ASC @@ -40109,7 +40109,7 @@ CREATE TABLE [dbo].[ScheduleTaskParameters]( [DataTypeID] [nvarchar](50) COLLATE Latin1_General_CI_AS NOT NULL, [DefaultValue] [nvarchar](140) COLLATE Latin1_General_CI_AS NULL, [ParameterOrder] [int] NOT NULL, - CONSTRAINT [PK_ScheduleTaskParameters] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_ScheduleTaskParameters] PRIMARY KEY CLUSTERED ( [TaskID] ASC, [ParameterID] ASC @@ -40125,7 +40125,7 @@ CREATE TABLE [dbo].[ScheduleTasks]( [TaskID] [nvarchar](100) COLLATE Latin1_General_CI_AS NOT NULL, [TaskType] [nvarchar](500) COLLATE Latin1_General_CI_AS NOT NULL, [RoleID] [int] NOT NULL, - CONSTRAINT [PK_ScheduleTasks] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_ScheduleTasks] PRIMARY KEY CLUSTERED ( [TaskID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) @@ -40141,7 +40141,7 @@ CREATE TABLE [dbo].[ScheduleTaskViewConfiguration]( [ConfigurationID] [nvarchar](100) COLLATE Latin1_General_CI_AS NOT NULL, [Environment] [nvarchar](100) COLLATE Latin1_General_CI_AS NOT NULL, [Description] [nvarchar](100) COLLATE Latin1_General_CI_AS NOT NULL, - CONSTRAINT [PK_ScheduleTaskViewConfiguration] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_ScheduleTaskViewConfiguration] PRIMARY KEY CLUSTERED ( [ConfigurationID] ASC, [TaskID] ASC @@ -40167,7 +40167,7 @@ CREATE TABLE [dbo].[Servers]( [ADPassword] [nvarchar](100) COLLATE Latin1_General_CI_AS NULL, [ADAuthenticationType] [varchar](50) COLLATE Latin1_General_CI_AS NULL, [ADEnabled] [bit] NULL, - CONSTRAINT [PK_Servers] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_Servers] PRIMARY KEY CLUSTERED ( [ServerID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) @@ -40182,7 +40182,7 @@ CREATE TABLE [dbo].[ServiceDefaultProperties]( [ProviderID] [int] NOT NULL, [PropertyName] [nvarchar](50) COLLATE Latin1_General_CI_AS NOT NULL, [PropertyValue] [nvarchar](1000) COLLATE Latin1_General_CI_AS NULL, - CONSTRAINT [PK_ServiceDefaultProperties_1] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_ServiceDefaultProperties_1] PRIMARY KEY CLUSTERED ( [ProviderID] ASC, [PropertyName] ASC @@ -40198,7 +40198,7 @@ CREATE TABLE [dbo].[ServiceItemProperties]( [ItemID] [int] NOT NULL, [PropertyName] [nvarchar](50) COLLATE Latin1_General_CI_AS NOT NULL, [PropertyValue] [nvarchar](3000) COLLATE Latin1_General_CI_AS NULL, - CONSTRAINT [PK_ServiceItemProperties] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_ServiceItemProperties] PRIMARY KEY CLUSTERED ( [ItemID] ASC, [PropertyName] ASC @@ -40217,7 +40217,7 @@ CREATE TABLE [dbo].[ServiceItems]( [ServiceID] [int] NULL, [ItemName] [nvarchar](500) COLLATE Latin1_General_CI_AS NULL, [CreatedDate] [datetime] NULL, - CONSTRAINT [PK_ServiceItems] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_ServiceItems] PRIMARY KEY CLUSTERED ( [ItemID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) @@ -40241,7 +40241,7 @@ CREATE TABLE [dbo].[ServiceItemTypes]( [Searchable] [bit] NULL, [Importable] [bit] NOT NULL, [Backupable] [bit] NOT NULL, - CONSTRAINT [PK_ServiceItemTypes] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_ServiceItemTypes] PRIMARY KEY CLUSTERED ( [ItemTypeID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) @@ -40256,7 +40256,7 @@ CREATE TABLE [dbo].[ServiceProperties]( [ServiceID] [int] NOT NULL, [PropertyName] [nvarchar](50) COLLATE Latin1_General_CI_AS NOT NULL, [PropertyValue] [nvarchar](1000) COLLATE Latin1_General_CI_AS NULL, - CONSTRAINT [PK_ServiceProperties_1] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_ServiceProperties_1] PRIMARY KEY CLUSTERED ( [ServiceID] ASC, [PropertyName] ASC @@ -40276,7 +40276,7 @@ CREATE TABLE [dbo].[Services]( [Comments] [ntext] COLLATE Latin1_General_CI_AS NULL, [ServiceQuotaValue] [int] NULL, [ClusterID] [int] NULL, - CONSTRAINT [PK_Services] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_Services] PRIMARY KEY CLUSTERED ( [ServiceID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) @@ -40316,7 +40316,7 @@ CREATE TABLE [dbo].[SystemSettings]( [SettingsName] [nvarchar](50) COLLATE Latin1_General_CI_AS NOT NULL, [PropertyName] [nvarchar](50) COLLATE Latin1_General_CI_AS NOT NULL, [PropertyValue] [ntext] COLLATE Latin1_General_CI_AS NULL, - CONSTRAINT [PK_SystemSettings] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_SystemSettings] PRIMARY KEY CLUSTERED ( [SettingsName] ASC, [PropertyName] ASC @@ -40360,7 +40360,7 @@ CREATE TABLE [dbo].[Users]( [LoginStatusId] [int] NULL, [FailedLogins] [int] NULL, [SubscriberNumber] [nvarchar](32) COLLATE Latin1_General_CI_AS NULL, - CONSTRAINT [PK_Users] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_Users] PRIMARY KEY CLUSTERED ( [UserID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) @@ -40376,7 +40376,7 @@ CREATE TABLE [dbo].[UserSettings]( [SettingsName] [nvarchar](50) COLLATE Latin1_General_CI_AS NOT NULL, [PropertyName] [nvarchar](50) COLLATE Latin1_General_CI_AS NOT NULL, [PropertyValue] [ntext] COLLATE Latin1_General_CI_AS NULL, - CONSTRAINT [PK_UserSettings] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_UserSettings] PRIMARY KEY CLUSTERED ( [UserID] ASC, [SettingsName] ASC, @@ -40392,7 +40392,7 @@ GO CREATE TABLE [dbo].[Versions]( [DatabaseVersion] [varchar](50) COLLATE Latin1_General_CI_AS NOT NULL, [BuildDate] [datetime] NOT NULL, - CONSTRAINT [PK_Versions] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_Versions] PRIMARY KEY CLUSTERED ( [DatabaseVersion] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) @@ -40409,7 +40409,7 @@ CREATE TABLE [dbo].[VirtualGroups]( [GroupID] [int] NOT NULL, [DistributionType] [int] NULL, [BindDistributionToPrimary] [bit] NULL, - CONSTRAINT [PK_VirtualGroups] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_VirtualGroups] PRIMARY KEY CLUSTERED ( [VirtualGroupID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) @@ -40424,7 +40424,7 @@ CREATE TABLE [dbo].[VirtualServices]( [VirtualServiceID] [int] IDENTITY(1,1) NOT NULL, [ServerID] [int] NOT NULL, [ServiceID] [int] NOT NULL, - CONSTRAINT [PK_VirtualServices] PRIMARY KEY CLUSTERED + CONSTRAINT [PK_VirtualServices] PRIMARY KEY CLUSTERED ( [VirtualServiceID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) @@ -40457,14 +40457,14 @@ GO CREATE VIEW [dbo].[ContractsInvoicesDetailed] AS -SELECT dbo.ecInvoice.InvoiceID, dbo.ecInvoice.ContractID, dbo.ecContracts.ResellerID, dbo.ecContracts.CustomerID, ISNULL(dbo.Users.Username, -dbo.ecContracts.AccountName) AS Username, dbo.ecContracts.Status, dbo.ecInvoice.Created, dbo.ecInvoice.DueDate, dbo.ecInvoice.Total, dbo.ecInvoice.SubTotal, -dbo.ecInvoice.TaxAmount, dbo.ecInvoice.Currency, dbo.ecInvoice.InvoiceNumber, dbo.ecInvoice.TaxationID, dbo.ecCustomersPayments.PaymentID, -dbo.ecCustomersPayments.StatusID, dbo.ecCustomersPayments.TransactionID, (CASE WHEN dbo.ecCustomersPayments.PaymentID IS NOT NULL AND +SELECT dbo.ecInvoice.InvoiceID, dbo.ecInvoice.ContractID, dbo.ecContracts.ResellerID, dbo.ecContracts.CustomerID, ISNULL(dbo.Users.Username, +dbo.ecContracts.AccountName) AS Username, dbo.ecContracts.Status, dbo.ecInvoice.Created, dbo.ecInvoice.DueDate, dbo.ecInvoice.Total, dbo.ecInvoice.SubTotal, +dbo.ecInvoice.TaxAmount, dbo.ecInvoice.Currency, dbo.ecInvoice.InvoiceNumber, dbo.ecInvoice.TaxationID, dbo.ecCustomersPayments.PaymentID, +dbo.ecCustomersPayments.StatusID, dbo.ecCustomersPayments.TransactionID, (CASE WHEN dbo.ecCustomersPayments.PaymentID IS NOT NULL AND dbo.ecCustomersPayments.StatusID = 1 THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END) AS Paid -FROM dbo.ecInvoice INNER JOIN -dbo.ecContracts ON dbo.ecInvoice.ContractID = dbo.ecContracts.ContractID LEFT OUTER JOIN -dbo.ecCustomersPayments ON dbo.ecInvoice.InvoiceID = dbo.ecCustomersPayments.InvoiceID LEFT OUTER JOIN +FROM dbo.ecInvoice INNER JOIN +dbo.ecContracts ON dbo.ecInvoice.ContractID = dbo.ecContracts.ContractID LEFT OUTER JOIN +dbo.ecCustomersPayments ON dbo.ecInvoice.InvoiceID = dbo.ecCustomersPayments.InvoiceID LEFT OUTER JOIN dbo.Users ON dbo.ecContracts.CustomerID = dbo.Users.UserID @@ -40520,11 +40520,11 @@ GO CREATE VIEW [dbo].[ContractsServicesDetailed] AS -SELECT dbo.ecService.ServiceID, ISNULL(dbo.Users.Username, dbo.ecContracts.AccountName) AS Username, dbo.ecContracts.CustomerID, dbo.ecService.ContractID, -dbo.ecContracts.ResellerID, dbo.ecService.ServiceName, dbo.ecService.TypeID, dbo.ecService.Status, dbo.ecService.Created, dbo.ecService.Modified, +SELECT dbo.ecService.ServiceID, ISNULL(dbo.Users.Username, dbo.ecContracts.AccountName) AS Username, dbo.ecContracts.CustomerID, dbo.ecService.ContractID, +dbo.ecContracts.ResellerID, dbo.ecService.ServiceName, dbo.ecService.TypeID, dbo.ecService.Status, dbo.ecService.Created, dbo.ecService.Modified, dbo.ecService.ParentID -FROM dbo.ecContracts INNER JOIN -dbo.ecService ON dbo.ecContracts.ContractID = dbo.ecService.ContractID LEFT OUTER JOIN +FROM dbo.ecContracts INNER JOIN +dbo.ecService ON dbo.ecContracts.ContractID = dbo.ecService.ContractID LEFT OUTER JOIN dbo.Users ON dbo.ecContracts.CustomerID = dbo.Users.UserID @@ -40579,13 +40579,13 @@ GO CREATE VIEW [dbo].[ServiceHandlersResponsesDetailed] AS -SELECT dbo.ecServiceHandlersResponses.ResponseID, dbo.ecServiceHandlersResponses.ServiceID, dbo.ecContracts.ResellerID, - dbo.ecServiceHandlersResponses.ContractID, dbo.ecServiceHandlersResponses.TextResponse, dbo.ecServiceHandlersResponses.Received, +SELECT dbo.ecServiceHandlersResponses.ResponseID, dbo.ecServiceHandlersResponses.ServiceID, dbo.ecContracts.ResellerID, + dbo.ecServiceHandlersResponses.ContractID, dbo.ecServiceHandlersResponses.TextResponse, dbo.ecServiceHandlersResponses.Received, dbo.ecServiceHandlersResponses.ErrorMessage, dbo.ecPaymentMethods.MethodName, dbo.ecServiceHandlersResponses.InvoiceID FROM dbo.ecContracts RIGHT OUTER JOIN dbo.ecPaymentMethods INNER JOIN dbo.ecSupportedPlugins ON dbo.ecPaymentMethods.PluginID = dbo.ecSupportedPlugins.PluginID RIGHT OUTER JOIN - dbo.ecServiceHandlersResponses ON dbo.ecSupportedPlugins.UniqueID = dbo.ecServiceHandlersResponses.ServiceID ON + dbo.ecServiceHandlersResponses ON dbo.ecSupportedPlugins.UniqueID = dbo.ecServiceHandlersResponses.ServiceID ON dbo.ecContracts.ContractID = dbo.ecServiceHandlersResponses.ContractID @@ -40623,8 +40623,8 @@ GO CREATE VIEW [dbo].[UsersDetailed] AS -SELECT U.UserID, U.RoleID, U.StatusID, U.LoginStatusId, U.SubscriberNumber, U.FailedLogins, U.OwnerID, U.Created, U.Changed, U.IsDemo, U.Comments, U.IsPeer, U.Username, U.FirstName, U.LastName, U.Email, - U.CompanyName, U.FirstName + ' ' + U.LastName AS FullName, UP.Username AS OwnerUsername, UP.FirstName AS OwnerFirstName, +SELECT U.UserID, U.RoleID, U.StatusID, U.LoginStatusId, U.SubscriberNumber, U.FailedLogins, U.OwnerID, U.Created, U.Changed, U.IsDemo, U.Comments, U.IsPeer, U.Username, U.FirstName, U.LastName, U.Email, + U.CompanyName, U.FirstName + ' ' + U.LastName AS FullName, UP.Username AS OwnerUsername, UP.FirstName AS OwnerFirstName, UP.LastName AS OwnerLastName, UP.RoleID AS OwnerRoleID, UP.FirstName + ' ' + UP.LastName AS OwnerFullName, UP.Email AS OwnerEmail, UP.RoleID AS Expr1, (SELECT COUNT(PackageID) AS Expr1 FROM dbo.Packages AS P @@ -41105,7 +41105,7 @@ INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUE GO INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'WEB_SITE', N'UPDATE_VDIR', N'Update virtual directory') GO -SET IDENTITY_INSERT [dbo].[ecProductType] ON +SET IDENTITY_INSERT [dbo].[ecProductType] ON GO INSERT [dbo].[ecProductType] ([TypeID], [TypeName], [ProvisioningController], [Created], [NativeItemType], [ServiceItemType]) VALUES (1, N'Hosting Plan', N'WebsitePanel.Ecommerce.EnterpriseServer.HostingPackageController,WebsitePanel.EnterpriseServer', CAST(0x0000993E010F2F0C AS DateTime), N'WebsitePanel.Ecommerce.EnterpriseServer.HostingPlan, WebsitePanel.EnterpriseServer', N'WebsitePanel.Ecommerce.EnterpriseServer.HostingPackageSvc, WebsitePanel.EnterpriseServer') @@ -41130,7 +41130,7 @@ INSERT [dbo].[ecStoreDefaultSettings] ([SettingsName], [PropertyName], [Property .Summary A { color: ##0153A4; } .Summary { font-family: Tahoma; font-size: 9pt; } .Summary H1 { font-size: 1.7em; color: ##1F4978; border-bottom: dotted 3px ##efefef; } - .Summary H2 { font-size: 1.2em; } + .Summary H2 { font-size: 1.2em; } .Summary TABLE { border: solid 1px ##e5e5e5; } .Summary TH, .Summary TD.Label { padding: 5px; font-size: 8pt; font-weight: bold; background-color: ##f5f5f5; } @@ -41228,7 +41228,7 @@ INSERT [dbo].[ecStoreDefaultSettings] ([SettingsName], [PropertyName], [Property .Summary A { color: ##0153A4; } .Summary { font-family: Tahoma; font-size: 9pt; } .Summary H1 { font-size: 1.7em; color: ##1F4978; border-bottom: dotted 3px ##efefef; } - .Summary H2 { font-size: 1.2em; } + .Summary H2 { font-size: 1.2em; } .Summary TABLE { border: solid 1px ##e5e5e5; } .Summary TH, .Summary TD.Label { padding: 5px; font-size: 8pt; font-weight: bold; background-color: ##f5f5f5; } @@ -41311,7 +41311,7 @@ INSERT [dbo].[ecStoreDefaultSettings] ([SettingsName], [PropertyName], [Property .Summary A { color: ##0153A4; } .Summary { font-family: Tahoma; font-size: 9pt; } .Summary H1 { font-size: 1.7em; color: ##1F4978; border-bottom: dotted 3px ##efefef; } - .Summary H2 { font-size: 1.2em; } + .Summary H2 { font-size: 1.2em; } .Summary TABLE { border: solid 1px ##e5e5e5; } .Summary TH, .Summary TD.Label { padding: 5px; font-size: 8pt; font-weight: bold; background-color: ##f5f5f5; } @@ -41332,7 +41332,7 @@ INSERT [dbo].[ecStoreDefaultSettings] ([SettingsName], [PropertyName], [Property

Hello #Customer["FirstName"]#,

-

We''ve created this invoice for services you ordered. You can find this invoice details under your user account +

We''ve created this invoice for services you ordered. You can find this invoice details under your user account and below is the summary information.

@@ -41437,7 +41437,7 @@ INSERT [dbo].[ecStoreDefaultSettings] ([SettingsName], [PropertyName], [Property Hello #Customer["FirstName"]#, -We''ve created this invoice for services you ordered. You can find this invoice details under your user account +We''ve created this invoice for services you ordered. You can find this invoice details under your user account and below is the summary information. @@ -41505,7 +41505,7 @@ INSERT [dbo].[ecStoreDefaultSettings] ([SettingsName], [PropertyName], [Property .Summary A { color: ##0153A4; } .Summary { font-family: Tahoma; font-size: 9pt; } .Summary H1 { font-size: 1.7em; color: ##1F4978; border-bottom: dotted 3px ##efefef; } - .Summary H2 { font-size: 1.2em; } + .Summary H2 { font-size: 1.2em; } .Summary TABLE { border: solid 1px ##e5e5e5; } .Summary TH, .Summary TD.Label { padding: 5px; font-size: 8pt; font-weight: bold; background-color: ##f5f5f5; } @@ -41643,7 +41643,7 @@ INSERT [dbo].[ecStoreDefaultSettings] ([SettingsName], [PropertyName], [Property .Summary A { color: ##0153A4; } .Summary { font-family: Tahoma; font-size: 9pt; } .Summary H1 { font-size: 1.7em; color: ##1F4978; border-bottom: dotted 3px ##efefef; } - .Summary H2 { font-size: 1.2em; } + .Summary H2 { font-size: 1.2em; } .Summary TABLE { border: solid 1px ##e5e5e5; } .Summary TH, .Summary TD.Label { padding: 5px; font-size: 8pt; font-weight: bold; background-color: ##f5f5f5; } @@ -41726,7 +41726,7 @@ INSERT [dbo].[ecStoreDefaultSettings] ([SettingsName], [PropertyName], [Property GO INSERT [dbo].[ecStoreDefaultSettings] ([SettingsName], [PropertyName], [PropertyValue]) VALUES (N'SystemSettings', N'SvcInvoiceThreshold', N'7') GO -SET IDENTITY_INSERT [dbo].[ecSupportedPlugins] ON +SET IDENTITY_INSERT [dbo].[ecSupportedPlugins] ON GO INSERT [dbo].[ecSupportedPlugins] ([PluginID], [PluginName], [DisplayName], [PluginGroup], [TypeName], [Interactive], [SupportedItems], [UniqueID]) VALUES (1, N'AuthorizeNet', N'Authorize.Net', N'CC_GATEWAY', N'WebsitePanel.Ecommerce.EnterpriseServer.AuthorizeNetProvider, WebsitePanel.Plugins.AuthorizeNet', 0, N'American Express=Amex,Discover,Master Card=MasterCard,Visa', NULL) @@ -41747,7 +41747,7 @@ INSERT [dbo].[ecSupportedPlugins] ([PluginID], [PluginName], [DisplayName], [Plu GO SET IDENTITY_INSERT [dbo].[ecSupportedPlugins] OFF GO -SET IDENTITY_INSERT [dbo].[Packages] ON +SET IDENTITY_INSERT [dbo].[Packages] ON GO INSERT [dbo].[Packages] ([PackageID], [ParentPackageID], [UserID], [PackageName], [PackageComments], [ServerID], [StatusID], [PlanID], [PurchaseDate], [OverrideQuotas], [BandwidthUpdated]) VALUES (1, NULL, 1, N'System', N'', NULL, 1, NULL, CAST(0x00009DB500D45272 AS DateTime), 0, NULL) @@ -42250,7 +42250,7 @@ INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDe GO INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (410, 1, 12, N'OS.AllowTenantCreateDomains', N'Allow Tenants to Create Top Level Domains', 1, 0, NULL, NULL) GO -SET IDENTITY_INSERT [dbo].[ResourceGroupDnsRecords] ON +SET IDENTITY_INSERT [dbo].[ResourceGroupDnsRecords] ON GO INSERT [dbo].[ResourceGroupDnsRecords] ([RecordID], [RecordOrder], [GroupID], [RecordType], [RecordName], [RecordData], [MXPriority]) VALUES (1, 1, 2, N'A', N'', N'[IP]', 0) @@ -42331,7 +42331,7 @@ INSERT [dbo].[ResourceGroups] ([GroupID], [GroupName], [GroupOrder], [GroupContr GO INSERT [dbo].[ResourceGroups] ([GroupID], [GroupName], [GroupOrder], [GroupController], [ShowGroup]) VALUES (41, N'Lync', 23, NULL, 1) GO -SET IDENTITY_INSERT [dbo].[Schedule] ON +SET IDENTITY_INSERT [dbo].[Schedule] ON GO INSERT [dbo].[Schedule] ([ScheduleID], [TaskID], [PackageID], [ScheduleName], [ScheduleTypeID], [Interval], [FromTime], [ToTime], [StartTime], [LastRun], [NextRun], [Enabled], [PriorityID], [HistoriesNumber], [MaxExecutionTime], [WeekMonthDay]) VALUES (1, N'SCHEDULE_TASK_CALCULATE_PACKAGES_DISKSPACE', 1, N'Calculate Disk Space', N'Daily', 0, CAST(0x00008EAC00C5C100 AS DateTime), CAST(0x00008EAC00C5C100 AS DateTime), CAST(0x00008EAC00CDFE60 AS DateTime), NULL, CAST(0x00009DB500F547F5 AS DateTime), 1, N'Normal', 7, 3600, 1) @@ -43179,7 +43179,7 @@ INSERT [dbo].[SystemSettings] ([SettingsName], [PropertyName], [PropertyValue]) GO INSERT [dbo].[SystemSettings] ([SettingsName], [PropertyName], [PropertyValue]) VALUES (N'SmtpSettings', N'SmtpUsername', N'postmaster') GO -SET IDENTITY_INSERT [dbo].[Users] ON +SET IDENTITY_INSERT [dbo].[Users] ON GO INSERT [dbo].[Users] ([UserID], [OwnerID], [RoleID], [StatusID], [IsDemo], [IsPeer], [Username], [Password], [FirstName], [LastName], [Email], [Created], [Changed], [Comments], [SecondaryEmail], [Address], [City], [State], [Country], [Zip], [PrimaryPhone], [SecondaryPhone], [Fax], [InstantMessenger], [HtmlMail], [CompanyName], [EcommerceEnabled], [AdditionalParams], [LoginStatusId], [FailedLogins], [SubscriberNumber]) VALUES (1, NULL, 1, 1, 0, 0, N'serveradmin', N'', N'Enterprise', N'Administrator', N'serveradmin@myhosting.com', CAST(0x00009DB500D45270 AS DateTime), CAST(0x00009DB500D45270 AS DateTime), N'', N'', N'', N'', N'', N'', N'', N'', N'', N'', N'', 1, NULL, 1, NULL, NULL, NULL, NULL) @@ -43201,7 +43201,7 @@ INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [Property .Summary A { color: ##0153A4; } .Summary { font-family: Tahoma; font-size: 9pt; } .Summary H1 { font-size: 1.7em; color: ##1F4978; border-bottom: dotted 3px ##efefef; } - .Summary H2 { font-size: 1.3em; color: ##1F4978; } + .Summary H2 { font-size: 1.3em; color: ##1F4978; } .Summary TABLE { border: solid 1px ##e5e5e5; } .Summary TH, .Summary TD.Label { padding: 5px; font-size: 8pt; font-weight: bold; background-color: ##f5f5f5; } @@ -43395,7 +43395,7 @@ INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [Property .Summary A { color: ##0153A4; } .Summary { font-family: Tahoma; font-size: 9pt; } .Summary H1 { font-size: 1.7em; color: ##1F4978; border-bottom: dotted 3px ##efefef; } - .Summary H2 { font-size: 1.2em; } + .Summary H2 { font-size: 1.2em; } .Summary TABLE { border: solid 1px ##e5e5e5; } .Summary TH, .Summary TD.Label { padding: 5px; font-size: 8pt; font-weight: bold; background-color: ##f5f5f5; } @@ -44147,7 +44147,7 @@ The following web sites have been created under hosting space: You can access your web sites right now using their respective temporary URLs (instant aliases). Temporary URL is a sub-domain of the form http://yourdomain.com.providerdomain.com where "yourdomain.com" is your domain and "providerdomain.com" is the domain of your hosting provider. You can use the following Temporary URL for all your web sites: - + http://YourDomain.com.#InstantAlias# @@ -44158,11 +44158,11 @@ Sometimes it is required to know the physical location of the hosting space fold Hosting space folder is the folder where all hosting space files such as web sites content, web logs, data files, etc. are located. The root of your hosting space on our HDD is here: - + #PackageRootFolder# - + By default the root folder of any web site within your hosting space is built as following (you can change it anytime from the control panel): - + #PackageRootFolder#\YourDomain.com\wwwroot @@ -44181,13 +44181,13 @@ Your hosting space allows working with your files by FTP. You can use the following FTP server to access your space files remotely: ftp://#FtpIP# - + Also, you can use the following domain names to access your FTP server: ftp://ftp.YourDomain.com - + During DNS propagation period (when domain name servers have been changed), similar to web sites, FTP server can be access with Temporary URL too: - + ftp://ftp.YourDomain.com.#InstantAlias# @@ -44215,11 +44215,11 @@ Maximum Number of Mailing Lists: SMTP/POP3 Server ---------------- Below is the IP address of your POP3/SMTP/IMAP server. You can always access your mailbox(es) using this IP address instead of actual POP3/SMTP/IMAP servers name: - + #MailRecords[0].ExternalIP# Also, you can use the following domain names to access SMTP/POP3 server from your favourite e-mail client software: - + mail.YourDomain.com During DNS propagation period (when domain name servers have been changed), similar to web sites, SMTP/POP3 server can be access with temporary domain too: @@ -44246,7 +44246,7 @@ Maximum Number of Databases: Maximum Number of Users: In order to connect to SQL Server 2000 from Management Studio, Enterprise Manager, Query Analyzer or other client software you can use the following SQL Server address: - + #MsSQL2000Address# @@ -44258,7 +44258,7 @@ Maximum Number of Databases: Maximum Number of Users: In order to connect to SQL Server 2005 from Management Studio, Enterprise Manager, Query Analyzer or other client software you can use the following SQL Server address: - + #MsSQL2005Address# @@ -44270,7 +44270,7 @@ Maximum Number of Databases: Maximum Number of Users: In order to connect to SQL Server 2008 from Management Studio, Enterprise Manager, Query Analyzer or other client software you can use the following SQL Server address: - + #MsSQL2008Address# @@ -44283,7 +44283,7 @@ Maximum Number of Databases: Maximum Number of Users: In order to connect to MySQL 4.x server you can use the following address: - + #MySQL4Address# @@ -44293,7 +44293,7 @@ Maximum Number of Databases: Maximum Number of Users: In order to connect to MySQL 5.x server you can use the following address: - + #MySQL5Address# @@ -44343,7 +44343,7 @@ INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [Property .Summary A { color: ##0153A4; } .Summary { font-family: Tahoma; font-size: 9pt; } .Summary H1 { font-size: 1.7em; color: ##1F4978; border-bottom: dotted 3px ##efefef; } - .Summary H2 { font-size: 1.3em; color: ##1F4978; } + .Summary H2 { font-size: 1.3em; color: ##1F4978; } .Summary TABLE { border: solid 1px ##e5e5e5; } .Summary TH, .Summary TD.Label { padding: 5px; font-size: 8pt; font-weight: bold; background-color: ##f5f5f5; } @@ -44578,7 +44578,7 @@ GO SET ANSI_PADDING ON GO -ALTER TABLE [dbo].[ecContracts] ADD CONSTRAINT [UQ_ecContracts_ContractID] UNIQUE NONCLUSTERED +ALTER TABLE [dbo].[ecContracts] ADD CONSTRAINT [UQ_ecContracts_ContractID] UNIQUE NONCLUSTERED ( [ContractID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) @@ -44586,7 +44586,7 @@ GO SET ANSI_PADDING ON GO -ALTER TABLE [dbo].[ecCustomersPayments] ADD CONSTRAINT [IX_ecCustomersPayments] UNIQUE NONCLUSTERED +ALTER TABLE [dbo].[ecCustomersPayments] ADD CONSTRAINT [IX_ecCustomersPayments] UNIQUE NONCLUSTERED ( [TransactionID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) @@ -44604,7 +44604,7 @@ GO SET ANSI_PADDING ON GO -ALTER TABLE [dbo].[ExchangeAccountEmailAddresses] ADD CONSTRAINT [IX_ExchangeAccountEmailAddresses_UniqueEmail] UNIQUE NONCLUSTERED +ALTER TABLE [dbo].[ExchangeAccountEmailAddresses] ADD CONSTRAINT [IX_ExchangeAccountEmailAddresses_UniqueEmail] UNIQUE NONCLUSTERED ( [EmailAddress] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) @@ -44612,17 +44612,17 @@ GO SET ANSI_PADDING ON GO -ALTER TABLE [dbo].[ExchangeAccounts] ADD CONSTRAINT [IX_ExchangeAccounts_UniqueAccountName] UNIQUE NONCLUSTERED +ALTER TABLE [dbo].[ExchangeAccounts] ADD CONSTRAINT [IX_ExchangeAccounts_UniqueAccountName] UNIQUE NONCLUSTERED ( [AccountName] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) GO -ALTER TABLE [dbo].[ExchangeMailboxPlans] ADD CONSTRAINT [IX_ExchangeMailboxPlans] UNIQUE NONCLUSTERED +ALTER TABLE [dbo].[ExchangeMailboxPlans] ADD CONSTRAINT [IX_ExchangeMailboxPlans] UNIQUE NONCLUSTERED ( [MailboxPlanId] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) GO -ALTER TABLE [dbo].[ExchangeOrganizationDomains] ADD CONSTRAINT [IX_ExchangeOrganizationDomains_UniqueDomain] UNIQUE NONCLUSTERED +ALTER TABLE [dbo].[ExchangeOrganizationDomains] ADD CONSTRAINT [IX_ExchangeOrganizationDomains_UniqueDomain] UNIQUE NONCLUSTERED ( [DomainID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) @@ -44630,12 +44630,12 @@ GO SET ANSI_PADDING ON GO -ALTER TABLE [dbo].[ExchangeOrganizations] ADD CONSTRAINT [IX_ExchangeOrganizations_UniqueOrg] UNIQUE NONCLUSTERED +ALTER TABLE [dbo].[ExchangeOrganizations] ADD CONSTRAINT [IX_ExchangeOrganizations_UniqueOrg] UNIQUE NONCLUSTERED ( [OrganizationID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) GO -ALTER TABLE [dbo].[LyncUserPlans] ADD CONSTRAINT [IX_LyncUserPlans] UNIQUE NONCLUSTERED +ALTER TABLE [dbo].[LyncUserPlans] ADD CONSTRAINT [IX_LyncUserPlans] UNIQUE NONCLUSTERED ( [LyncUserPlanId] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) @@ -44643,7 +44643,7 @@ GO SET ANSI_PADDING ON GO -ALTER TABLE [dbo].[Users] ADD CONSTRAINT [IX_Users_Username] UNIQUE NONCLUSTERED +ALTER TABLE [dbo].[Users] ADD CONSTRAINT [IX_Users_Username] UNIQUE NONCLUSTERED ( [Username] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) @@ -45305,4 +45305,4 @@ REFERENCES [dbo].[Services] ([ServiceID]) GO ALTER TABLE [dbo].[VirtualServices] CHECK CONSTRAINT [FK_VirtualServices_Services] GO - \ No newline at end of file + diff --git a/WebsitePanel/Database/wix_install_db.sql b/WebsitePanel/Database/wix_install_db.sql new file mode 100644 index 00000000..a058e413 --- /dev/null +++ b/WebsitePanel/Database/wix_install_db.sql @@ -0,0 +1,45307 @@ +GO + +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[AddAuditLogRecord] +( + @RecordID varchar(32), + @SeverityID int, + @UserID int, + @PackageID int, + @Username nvarchar(50), + @ItemID int, + @StartDate datetime, + @FinishDate datetime, + @SourceName varchar(50), + @TaskName varchar(50), + @ItemName nvarchar(50), + @ExecutionLog ntext +) +AS + +IF @ItemID = 0 SET @ItemID = NULL +IF @UserID = 0 OR @UserID = -1 SET @UserID = NULL + + +INSERT INTO AuditLog +( + RecordID, + SeverityID, + UserID, + PackageID, + Username, + ItemID, + SourceName, + StartDate, + FinishDate, + TaskName, + ItemName, + ExecutionLog +) +VALUES +( + @RecordID, + @SeverityID, + @UserID, + @PackageID, + @Username, + @ItemID, + @SourceName, + @StartDate, + @FinishDate, + @TaskName, + @ItemName, + @ExecutionLog +) +RETURN + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[AddBlackBerryUser] + @AccountID int +AS +BEGIN + SET NOCOUNT ON; + +INSERT INTO + dbo.BlackBerryUsers + ( + + AccountID, + CreatedDate, + ModifiedDate) +VALUES +( + @AccountID, + getdate(), + getdate() +) +END + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE AddCluster +( + @ClusterID int OUTPUT, + @ClusterName nvarchar(100) +) +AS +INSERT INTO Clusters +( + ClusterName +) +VALUES +( + @ClusterName +) + +SET @ClusterID = SCOPE_IDENTITY() +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE AddComment +( + @ActorID int, + @ItemTypeID varchar(50), + @ItemID int, + @CommentText nvarchar(1000), + @SeverityID int +) +AS +INSERT INTO Comments +( + ItemTypeID, + ItemID, + UserID, + CreatedDate, + CommentText, + SeverityID +) +VALUES +( + @ItemTypeID, + @ItemID, + @ActorID, + GETDATE(), + @CommentText, + @SeverityID +) +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + +CREATE PROCEDURE [dbo].[AddDnsRecord] +( + @ActorID int, + @ServiceID int, + @ServerID int, + @PackageID int, + @RecordType nvarchar(10), + @RecordName nvarchar(50), + @RecordData nvarchar(500), + @MXPriority int, + @SrvPriority int, + @SrvWeight int, + @SrvPort int, + @IPAddressID int +) +AS + +IF (@ServiceID > 0 OR @ServerID > 0) AND dbo.CheckIsUserAdmin(@ActorID) = 0 +RAISERROR('You should have administrator role to perform such operation', 16, 1) + +IF (@PackageID > 0) AND dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 +RAISERROR('You are not allowed to access this package', 16, 1) + +IF @ServiceID = 0 SET @ServiceID = NULL +IF @ServerID = 0 SET @ServerID = NULL +IF @PackageID = 0 SET @PackageID = NULL +IF @IPAddressID = 0 SET @IPAddressID = NULL + +IF EXISTS +( + SELECT RecordID FROM GlobalDnsRecords WHERE + ServiceID = @ServiceID AND ServerID = @ServerID AND PackageID = @PackageID + AND RecordName = @RecordName AND RecordType = @RecordType +) + + UPDATE GlobalDnsRecords + SET + RecordData = RecordData, + MXPriority = MXPriority, + SrvPriority = SrvPriority, + SrvWeight = SrvWeight, + SrvPort = SrvPort, + + IPAddressID = @IPAddressID + WHERE + ServiceID = @ServiceID AND ServerID = @ServerID AND PackageID = @PackageID +ELSE + INSERT INTO GlobalDnsRecords + ( + ServiceID, + ServerID, + PackageID, + RecordType, + RecordName, + RecordData, + MXPriority, + SrvPriority, + SrvWeight, + SrvPort, + IPAddressID + ) + VALUES + ( + @ServiceID, + @ServerID, + @PackageID, + @RecordType, + @RecordName, + @RecordData, + @MXPriority, + @SrvPriority, + @SrvWeight, + @SrvPort, + @IPAddressID + ) + +RETURN + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + + + + + + +CREATE PROCEDURE AddDomain +( + @DomainID int OUTPUT, + @ActorID int, + @PackageID int, + @ZoneItemID int, + @DomainName nvarchar(200), + @HostingAllowed bit, + @WebSiteID int, + @MailDomainID int, + @IsSubDomain bit, + @IsInstantAlias bit, + @IsDomainPointer bit +) +AS + +-- check rights +IF dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 +RAISERROR('You are not allowed to access this package', 16, 1) + +IF @ZoneItemID = 0 SET @ZoneItemID = NULL +IF @WebSiteID = 0 SET @WebSiteID = NULL +IF @MailDomainID = 0 SET @MailDomainID = NULL + +-- insert record +INSERT INTO Domains +( + PackageID, + ZoneItemID, + DomainName, + HostingAllowed, + WebSiteID, + MailDomainID, + IsSubDomain, + IsInstantAlias, + IsDomainPointer +) +VALUES +( + @PackageID, + @ZoneItemID, + @DomainName, + @HostingAllowed, + @WebSiteID, + @MailDomainID, + @IsSubDomain, + @IsInstantAlias, + @IsDomainPointer +) + +SET @DomainID = SCOPE_IDENTITY() +RETURN + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + +/****** Object: Table [dbo].[AddExchangeAccount] ******/ +CREATE PROCEDURE [dbo].[AddExchangeAccount] +( + @AccountID int OUTPUT, + @ItemID int, + @AccountType int, + @AccountName nvarchar(300), + @DisplayName nvarchar(300), + @PrimaryEmailAddress nvarchar(300), + @MailEnabledPublicFolder bit, + @MailboxManagerActions varchar(200), + @SamAccountName nvarchar(100), + @AccountPassword nvarchar(200), + @MailboxPlanId int, + @SubscriberNumber nvarchar(32) +) +AS + +INSERT INTO ExchangeAccounts +( + ItemID, + AccountType, + AccountName, + DisplayName, + PrimaryEmailAddress, + MailEnabledPublicFolder, + MailboxManagerActions, + SamAccountName, + AccountPassword, + MailboxPlanId, + SubscriberNumber, + UserPrincipalName +) +VALUES +( + @ItemID, + @AccountType, + @AccountName, + @DisplayName, + @PrimaryEmailAddress, + @MailEnabledPublicFolder, + @MailboxManagerActions, + @SamAccountName, + @AccountPassword, + @MailboxPlanId, + @SubscriberNumber, + @PrimaryEmailAddress +) + +SET @AccountID = SCOPE_IDENTITY() + +RETURN + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE AddExchangeAccountEmailAddress +( + @AccountID int, + @EmailAddress nvarchar(300) +) +AS +INSERT INTO ExchangeAccountEmailAddresses +( + AccountID, + EmailAddress +) +VALUES +( + @AccountID, + @EmailAddress +) +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + +CREATE PROCEDURE [dbo].[AddExchangeMailboxPlan] +( + @MailboxPlanId int OUTPUT, + @ItemID int, + @MailboxPlan nvarchar(300), + @EnableActiveSync bit, + @EnableIMAP bit, + @EnableMAPI bit, + @EnableOWA bit, + @EnablePOP bit, + @IsDefault bit, + @IssueWarningPct int, + @KeepDeletedItemsDays int, + @MailboxSizeMB int, + @MaxReceiveMessageSizeKB int, + @MaxRecipients int, + @MaxSendMessageSizeKB int, + @ProhibitSendPct int, + @ProhibitSendReceivePct int , + @HideFromAddressBook bit, + @MailboxPlanType int +) +AS + +IF (((SELECT Count(*) FROM ExchangeMailboxPlans WHERE ItemId = @ItemID) = 0) AND (@MailboxPlanType=0)) +BEGIN + SET @IsDefault = 1 +END +ELSE +BEGIN + IF ((@IsDefault = 1) AND (@MailboxPlanType=0)) + BEGIN + UPDATE ExchangeMailboxPlans SET IsDefault = 0 WHERE ItemID = @ItemID + END +END + +INSERT INTO ExchangeMailboxPlans +( + ItemID, + MailboxPlan, + EnableActiveSync, + EnableIMAP, + EnableMAPI, + EnableOWA, + EnablePOP, + IsDefault, + IssueWarningPct, + KeepDeletedItemsDays, + MailboxSizeMB, + MaxReceiveMessageSizeKB, + MaxRecipients, + MaxSendMessageSizeKB, + ProhibitSendPct, + ProhibitSendReceivePct, + HideFromAddressBook, + MailboxPlanType +) +VALUES +( + @ItemID, + @MailboxPlan, + @EnableActiveSync, + @EnableIMAP, + @EnableMAPI, + @EnableOWA, + @EnablePOP, + @IsDefault, + @IssueWarningPct, + @KeepDeletedItemsDays, + @MailboxSizeMB, + @MaxReceiveMessageSizeKB, + @MaxRecipients, + @MaxSendMessageSizeKB, + @ProhibitSendPct, + @ProhibitSendReceivePct, + @HideFromAddressBook, + @MailboxPlanType +) + +SET @MailboxPlanId = SCOPE_IDENTITY() + +RETURN + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[AddExchangeOrganization] +( + @ItemID int, + @OrganizationID nvarchar(128) +) +AS + +IF NOT EXISTS(SELECT * FROM ExchangeOrganizations WHERE OrganizationID = @OrganizationID) +BEGIN + INSERT INTO ExchangeOrganizations + (ItemID, OrganizationID) + VALUES + (@ItemID, @OrganizationID) +END + +RETURN + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE AddExchangeOrganizationDomain +( + @ItemID int, + @DomainID int, + @IsHost bit +) +AS +INSERT INTO ExchangeOrganizationDomains +(ItemID, DomainID, IsHost) +VALUES +(@ItemID, @DomainID, @IsHost) +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[AddIPAddress] +( + @AddressID int OUTPUT, + @ServerID int, + @ExternalIP varchar(24), + @InternalIP varchar(24), + @PoolID int, + @SubnetMask varchar(15), + @DefaultGateway varchar(15), + @Comments ntext +) +AS +BEGIN + IF @ServerID = 0 + SET @ServerID = NULL + + INSERT INTO IPAddresses (ServerID, ExternalIP, InternalIP, PoolID, SubnetMask, DefaultGateway, Comments) + VALUES (@ServerID, @ExternalIP, @InternalIP, @PoolID, @SubnetMask, @DefaultGateway, @Comments) + + SET @AddressID = SCOPE_IDENTITY() + + RETURN +END + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[AddItemIPAddress] +( + @ActorID int, + @ItemID int, + @PackageAddressID int +) +AS +BEGIN + UPDATE PackageIPAddresses + SET + ItemID = @ItemID, + IsPrimary = 0 + FROM PackageIPAddresses AS PIP + WHERE + PIP.PackageAddressID = @PackageAddressID + AND dbo.CheckActorPackageRights(@ActorID, PIP.PackageID) = 1 +END + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[AddItemPrivateIPAddress] +( + @ActorID int, + @ItemID int, + @IPAddress varchar(15) +) +AS + + +IF EXISTS (SELECT ItemID FROM ServiceItems AS SI WHERE dbo.CheckActorPackageRights(@ActorID, SI.PackageID) = 1) +BEGIN + + INSERT INTO PrivateIPAddresses + ( + ItemID, + IPAddress, + IsPrimary + ) + VALUES + ( + @ItemID, + @IPAddress, + 0 -- not primary + ) + +END + +RETURN + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + +CREATE PROCEDURE [dbo].[AddLyncUser] + @AccountID int, + @LyncUserPlanID int, + @SipAddress nvarchar(300) +AS +INSERT INTO + dbo.LyncUsers + (AccountID, + LyncUserPlanID, + CreatedDate, + ModifiedDate, + SipAddress) +VALUES +( + @AccountID, + @LyncUserPlanID, + getdate(), + getdate(), + @SipAddress +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + + + + +CREATE PROCEDURE [dbo].[AddLyncUserPlan] +( + @LyncUserPlanId int OUTPUT, + @ItemID int, + @LyncUserPlanName nvarchar(300), + @LyncUserPlanType int, + @IM bit, + @Mobility bit, + @MobilityEnableOutsideVoice bit, + @Federation bit, + @Conferencing bit, + @EnterpriseVoice bit, + @VoicePolicy int, + @IsDefault bit +) +AS + +IF (((SELECT Count(*) FROM LyncUserPlans WHERE ItemId = @ItemID) = 0) AND (@LyncUserPlanType=0)) +BEGIN + SET @IsDefault = 1 +END +ELSE +BEGIN + IF ((@IsDefault = 1) AND (@LyncUserPlanType=0)) + BEGIN + UPDATE LyncUserPlans SET IsDefault = 0 WHERE ItemID = @ItemID + END +END + + +INSERT INTO LyncUserPlans +( + ItemID, + LyncUserPlanName, + LyncUserPlanType, + IM, + Mobility, + MobilityEnableOutsideVoice, + Federation, + Conferencing, + EnterpriseVoice, + VoicePolicy, + IsDefault +) +VALUES +( + @ItemID, + @LyncUserPlanName, + @LyncUserPlanType, + @IM, + @Mobility, + @MobilityEnableOutsideVoice, + @Federation, + @Conferencing, + @EnterpriseVoice, + @VoicePolicy, + @IsDefault +) + +SET @LyncUserPlanId = SCOPE_IDENTITY() + +RETURN + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + +CREATE PROCEDURE [dbo].[AddOCSUser] + @AccountID int, + @InstanceID nvarchar(50) +AS +BEGIN + SET NOCOUNT ON; + +INSERT INTO + dbo.OCSUsers + ( + + AccountID, + InstanceID, + CreatedDate, + ModifiedDate) +VALUES +( + @AccountID, + @InstanceID, + getdate(), + getdate() +) +END + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[AddPackage] +( + @ActorID int, + @PackageID int OUTPUT, + @UserID int, + @PackageName nvarchar(300), + @PackageComments ntext, + @StatusID int, + @PlanID int, + @PurchaseDate datetime +) +AS + + +DECLARE @ParentPackageID int, @PlanServerID int +SELECT @ParentPackageID = PackageID, @PlanServerID = ServerID FROM HostingPlans +WHERE PlanID = @PlanID + +IF @ParentPackageID = 0 OR @ParentPackageID IS NULL +SELECT @ParentPackageID = PackageID FROM Packages +WHERE ParentPackageID IS NULL -- root space + +-- check rights +IF dbo.CheckActorPackageRights(@ActorID, @ParentPackageID) = 0 +BEGIN + RAISERROR('You are not allowed to access this package', 16, 1); + RETURN; +END + +BEGIN TRAN +-- insert package +INSERT INTO Packages +( + ParentPackageID, + UserID, + PackageName, + PackageComments, + ServerID, + StatusID, + PlanID, + PurchaseDate +) +VALUES +( + @ParentPackageID, + @UserID, + @PackageName, + @PackageComments, + @PlanServerID, + @StatusID, + @PlanID, + @PurchaseDate +) + +SET @PackageID = SCOPE_IDENTITY() + +-- add package to packages cache +INSERT INTO PackagesTreeCache (ParentPackageID, PackageID) +SELECT PackageID, @PackageID FROM dbo.PackageParents(@PackageID) + +DECLARE @ExceedingQuotas AS TABLE (QuotaID int, QuotaName nvarchar(50), QuotaValue int) +INSERT INTO @ExceedingQuotas +SELECT * FROM dbo.GetPackageExceedingQuotas(@ParentPackageID) WHERE QuotaValue > 0 + +SELECT * FROM @ExceedingQuotas + +IF EXISTS(SELECT * FROM @ExceedingQuotas) +BEGIN + ROLLBACK TRAN + RETURN +END + +COMMIT TRAN + +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE AddPackageAddon +( + @ActorID int, + @PackageAddonID int OUTPUT, + @PackageID int, + @PlanID int, + @Quantity int, + @StatusID int, + @PurchaseDate datetime, + @Comments ntext +) +AS + +-- check rights +IF dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 +RAISERROR('You are not allowed to access this package', 16, 1) + +BEGIN TRAN + +DECLARE @ParentPackageID int +SELECT @ParentPackageID = ParentPackageID FROM Packages +WHERE PackageID = @PackageID + +-- insert record +INSERT INTO PackageAddons +( + PackageID, + PlanID, + PurchaseDate, + Quantity, + StatusID, + Comments +) +VALUES +( + @PackageID, + @PlanID, + @PurchaseDate, + @Quantity, + @StatusID, + @Comments +) + +SET @PackageAddonID = SCOPE_IDENTITY() + +DECLARE @ExceedingQuotas AS TABLE (QuotaID int, QuotaName nvarchar(50), QuotaValue int) +INSERT INTO @ExceedingQuotas +SELECT * FROM dbo.GetPackageExceedingQuotas(@ParentPackageID) WHERE QuotaValue > 0 + +SELECT * FROM @ExceedingQuotas + +IF EXISTS(SELECT * FROM @ExceedingQuotas) +BEGIN + ROLLBACK TRAN + RETURN +END + +COMMIT TRAN +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + +CREATE PROCEDURE [dbo].[AddPFX] +( + @ActorID int, + @PackageID int, + @UserID int, + @WebSiteID int, + @FriendlyName nvarchar(255), + @HostName nvarchar(255), + @CSRLength int, + @DistinguishedName nvarchar(500), + @SerialNumber nvarchar(250), + @ValidFrom datetime, + @ExpiryDate datetime + +) +AS + +-- check rights +IF dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 +BEGIN + RAISERROR('You are not allowed to access this package', 16, 1) + RETURN +END + +-- insert record +INSERT INTO [dbo].[SSLCertificates] + ([UserID], [SiteID], [FriendlyName], [Hostname], [DistinguishedName], [CSRLength], [SerialNumber], [ValidFrom], [ExpiryDate], [Installed]) +VALUES + (@UserID, @WebSiteID, @FriendlyName, @HostName, @DistinguishedName, @CSRLength, @SerialNumber, @ValidFrom, @ExpiryDate, 1) + +RETURN + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE AddSchedule +( + @ActorID int, + @ScheduleID int OUTPUT, + @TaskID nvarchar(100), + @PackageID int, + @ScheduleName nvarchar(100), + @ScheduleTypeID nvarchar(50), + @Interval int, + @FromTime datetime, + @ToTime datetime, + @StartTime datetime, + @NextRun datetime, + @Enabled bit, + @PriorityID nvarchar(50), + @HistoriesNumber int, + @MaxExecutionTime int, + @WeekMonthDay int, + @XmlParameters ntext +) +AS + +-- check rights +IF dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 +RAISERROR('You are not allowed to access this package', 16, 1) + +-- insert record +BEGIN TRAN +INSERT INTO Schedule +( + TaskID, + PackageID, + ScheduleName, + ScheduleTypeID, + Interval, + FromTime, + ToTime, + StartTime, + NextRun, + Enabled, + PriorityID, + HistoriesNumber, + MaxExecutionTime, + WeekMonthDay +) +VALUES +( + @TaskID, + @PackageID, + @ScheduleName, + @ScheduleTypeID, + @Interval, + @FromTime, + @ToTime, + @StartTime, + @NextRun, + @Enabled, + @PriorityID, + @HistoriesNumber, + @MaxExecutionTime, + @WeekMonthDay +) + +SET @ScheduleID = SCOPE_IDENTITY() + +DECLARE @idoc int +--Create an internal representation of the XML document. +EXEC sp_xml_preparedocument @idoc OUTPUT, @XmlParameters + +-- Execute a SELECT statement that uses the OPENXML rowset provider. +DELETE FROM ScheduleParameters +WHERE ScheduleID = @ScheduleID + +INSERT INTO ScheduleParameters +( + ScheduleID, + ParameterID, + ParameterValue +) +SELECT + @ScheduleID, + ParameterID, + ParameterValue +FROM OPENXML(@idoc, '/parameters/parameter',1) WITH +( + ParameterID nvarchar(50) '@id', + ParameterValue nvarchar(3000) '@value' +) as PV + +-- remove document +exec sp_xml_removedocument @idoc + +COMMIT TRAN + +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE AddServer +( + @ServerID int OUTPUT, + @ServerName nvarchar(100), + @ServerUrl nvarchar(100), + @Password nvarchar(100), + @Comments ntext, + @VirtualServer bit, + @InstantDomainAlias nvarchar(200), + @PrimaryGroupID int, + @ADEnabled bit, + @ADRootDomain nvarchar(200), + @ADUsername nvarchar(100), + @ADPassword nvarchar(100), + @ADAuthenticationType varchar(50) +) +AS + +IF @PrimaryGroupID = 0 +SET @PrimaryGroupID = NULL + +INSERT INTO Servers +( + ServerName, + ServerUrl, + Password, + Comments, + VirtualServer, + InstantDomainAlias, + PrimaryGroupID, + ADEnabled, + ADRootDomain, + ADUsername, + ADPassword, + ADAuthenticationType +) +VALUES +( + @ServerName, + @ServerUrl, + @Password, + @Comments, + @VirtualServer, + @InstantDomainAlias, + @PrimaryGroupID, + @ADEnabled, + @ADRootDomain, + @ADUsername, + @ADPassword, + @ADAuthenticationType +) + +SET @ServerID = SCOPE_IDENTITY() + +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE AddService +( + @ServiceID int OUTPUT, + @ServerID int, + @ProviderID int, + @ServiceQuotaValue int, + @ServiceName nvarchar(50), + @ClusterID int, + @Comments ntext +) +AS +BEGIN + +BEGIN TRAN +IF @ClusterID = 0 SET @ClusterID = NULL + +INSERT INTO Services +( + ServerID, + ProviderID, + ServiceName, + ServiceQuotaValue, + ClusterID, + Comments +) +VALUES +( + @ServerID, + @ProviderID, + @ServiceName, + @ServiceQuotaValue, + @ClusterID, + @Comments +) + +SET @ServiceID = SCOPE_IDENTITY() + +-- copy default service settings +INSERT INTO ServiceProperties (ServiceID, PropertyName, PropertyValue) +SELECT @ServiceID, PropertyName, PropertyValue +FROM ServiceDefaultProperties +WHERE ProviderID = @ProviderID + +-- copy all default DNS records for the given service +DECLARE @GroupID int +SELECT @GroupID = GroupID FROM Providers +WHERE ProviderID = @ProviderID + +-- default IP address for added records +DECLARE @AddressID int +SELECT TOP 1 @AddressID = AddressID FROM IPAddresses +WHERE ServerID = @ServerID + +INSERT INTO GlobalDnsRecords +( + RecordType, + RecordName, + RecordData, + MXPriority, + IPAddressID, + ServiceID, + ServerID, + PackageID +) +SELECT + RecordType, + RecordName, + CASE WHEN RecordData = '[ip]' THEN '' + ELSE RecordData END, + MXPriority, + CASE WHEN RecordData = '[ip]' THEN @AddressID + ELSE NULL END, + @ServiceID, + NULL, -- server + NULL -- package +FROM + ResourceGroupDnsRecords +WHERE GroupID = @GroupID +ORDER BY RecordOrder +COMMIT TRAN + +END +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + +CREATE PROCEDURE [dbo].[AddServiceItem] +( + @ActorID int, + @PackageID int, + @ServiceID int, + @ItemName nvarchar(500), + @ItemTypeName nvarchar(200), + @ItemID int OUTPUT, + @XmlProperties ntext, + @CreatedDate datetime +) +AS +BEGIN TRAN + +-- check rights +IF dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 +RAISERROR('You are not allowed to access this package', 16, 1) + +-- get GroupID +DECLARE @GroupID int +SELECT + @GroupID = PROV.GroupID +FROM Services AS S +INNER JOIN Providers AS PROV ON S.ProviderID = PROV.ProviderID +WHERE S.ServiceID = @ServiceID + +DECLARE @ItemTypeID int +SELECT @ItemTypeID = ItemTypeID FROM ServiceItemTypes +WHERE TypeName = @ItemTypeName +AND ((@GroupID IS NULL) OR (@GroupID IS NOT NULL AND GroupID = @GroupID)) + +-- Fix to allow plans assigned to serveradmin +IF (@ItemTypeName = 'WebsitePanel.Providers.HostedSolution.Organization, WebsitePanel.Providers.Base') +BEGIN + IF NOT EXISTS (SELECT * FROM ServiceItems WHERE PackageID = 1) + BEGIN + INSERT INTO ServiceItems (PackageID, ItemTypeID,ServiceID,ItemName,CreatedDate) + VALUES(1, @ItemTypeID, @ServiceID, 'System', @CreatedDate) + + DECLARE @TempItemID int + + SET @TempItemID = SCOPE_IDENTITY() + INSERT INTO ExchangeOrganizations (ItemID, OrganizationID) + VALUES(@TempItemID, 'System') + END +END + + +-- add item +INSERT INTO ServiceItems +( + PackageID, + ServiceID, + ItemName, + ItemTypeID, + CreatedDate +) +VALUES +( + @PackageID, + @ServiceID, + @ItemName, + @ItemTypeID, + @CreatedDate +) + +SET @ItemID = SCOPE_IDENTITY() + +DECLARE @idoc int +--Create an internal representation of the XML document. +EXEC sp_xml_preparedocument @idoc OUTPUT, @XmlProperties + +-- Execute a SELECT statement that uses the OPENXML rowset provider. +DELETE FROM ServiceItemProperties +WHERE ItemID = @ItemID + +INSERT INTO ServiceItemProperties +( + ItemID, + PropertyName, + PropertyValue +) +SELECT + @ItemID, + PropertyName, + PropertyValue +FROM OPENXML(@idoc, '/properties/property',1) WITH +( + PropertyName nvarchar(50) '@name', + PropertyValue nvarchar(3000) '@value' +) as PV + +-- remove document +exec sp_xml_removedocument @idoc + +COMMIT TRAN +RETURN + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + +CREATE PROCEDURE [dbo].[AddSSLRequest] +( + @SSLID int OUTPUT, + @ActorID int, + @PackageID int, + @UserID int, + @WebSiteID int, + @FriendlyName nvarchar(255), + @HostName nvarchar(255), + @CSR ntext, + @CSRLength int, + @DistinguishedName nvarchar(500), + @IsRenewal bit = 0, + @PreviousId int = NULL + +) +AS + +-- check rights +IF dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 +BEGIN + RAISERROR('You are not allowed to access this package', 16, 1) + RETURN +END + +-- insert record +INSERT INTO [dbo].[SSLCertificates] + ([UserID], [SiteID], [FriendlyName], [Hostname], [DistinguishedName], [CSR], [CSRLength], [IsRenewal], [PreviousId]) +VALUES + (@UserID, @WebSiteID, @FriendlyName, @HostName, @DistinguishedName, @CSR, @CSRLength, @IsRenewal, @PreviousId) + +SET @SSLID = SCOPE_IDENTITY() +RETURN + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + + + +CREATE PROCEDURE [dbo].[AddUser] +( + @ActorID int, + @UserID int OUTPUT, + @OwnerID int, + @RoleID int, + @StatusID int, + @SubscriberNumber nvarchar(32), + @LoginStatusID int, + @IsDemo bit, + @IsPeer bit, + @Comments ntext, + @Username nvarchar(50), + @Password nvarchar(200), + @FirstName nvarchar(50), + @LastName nvarchar(50), + @Email nvarchar(255), + @SecondaryEmail nvarchar(255), + @Address nvarchar(200), + @City nvarchar(50), + @State nvarchar(50), + @Country nvarchar(50), + @Zip varchar(20), + @PrimaryPhone varchar(30), + @SecondaryPhone varchar(30), + @Fax varchar(30), + @InstantMessenger nvarchar(200), + @HtmlMail bit, + @CompanyName nvarchar(100), + @EcommerceEnabled bit +) +AS + +-- check if the user already exists +IF EXISTS(SELECT UserID FROM Users WHERE Username = @Username) +BEGIN + SET @UserID = -1 + RETURN +END + +-- check actor rights +IF dbo.CanCreateUser(@ActorID, @OwnerID) = 0 +BEGIN + SET @UserID = -2 + RETURN +END + +INSERT INTO Users +( + OwnerID, + RoleID, + StatusID, + SubscriberNumber, + LoginStatusID, + Created, + Changed, + IsDemo, + IsPeer, + Comments, + Username, + Password, + FirstName, + LastName, + Email, + SecondaryEmail, + Address, + City, + State, + Country, + Zip, + PrimaryPhone, + SecondaryPhone, + Fax, + InstantMessenger, + HtmlMail, + CompanyName, + EcommerceEnabled +) +VALUES +( + @OwnerID, + @RoleID, + @StatusID, + @SubscriberNumber, + @LoginStatusID, + GetDate(), + GetDate(), + @IsDemo, + @IsPeer, + @Comments, + @Username, + @Password, + @FirstName, + @LastName, + @Email, + @SecondaryEmail, + @Address, + @City, + @State, + @Country, + @Zip, + @PrimaryPhone, + @SecondaryPhone, + @Fax, + @InstantMessenger, + @HtmlMail, + @CompanyName, + @EcommerceEnabled +) + +SET @UserID = SCOPE_IDENTITY() + +RETURN + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE AddVirtualServices +( + @ServerID int, + @Xml ntext +) +AS + +/* +XML Format: + + + + + +*/ + +BEGIN TRAN +DECLARE @idoc int +--Create an internal representation of the XML document. +EXEC sp_xml_preparedocument @idoc OUTPUT, @xml + +-- update HP resources +INSERT INTO VirtualServices +( + ServerID, + ServiceID +) +SELECT + @ServerID, + ServiceID +FROM OPENXML(@idoc, '/services/service',1) WITH +( + ServiceID int '@id' +) as XS +WHERE XS.ServiceID NOT IN (SELECT ServiceID FROM VirtualServices WHERE ServerID = @ServerID) + +-- remove document +exec sp_xml_removedocument @idoc + +COMMIT TRAN +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[AllocatePackageIPAddresses] +( + @PackageID int, + @xml ntext +) +AS +BEGIN + SET NOCOUNT ON; + + DECLARE @idoc int + --Create an internal representation of the XML document. + EXEC sp_xml_preparedocument @idoc OUTPUT, @xml + + -- delete + DELETE FROM PackageIPAddresses + FROM PackageIPAddresses AS PIP + INNER JOIN OPENXML(@idoc, '/items/item', 1) WITH + ( + AddressID int '@id' + ) as PV ON PIP.AddressID = PV.AddressID + + + -- insert + INSERT INTO dbo.PackageIPAddresses + ( + PackageID, + AddressID + ) + SELECT + @PackageID, + AddressID + + FROM OPENXML(@idoc, '/items/item', 1) WITH + ( + AddressID int '@id' + ) as PV + + -- remove document + exec sp_xml_removedocument @idoc + +END + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + +CREATE PROCEDURE [dbo].ChangeExchangeAcceptedDomainType +( + @ItemID int, + @DomainID int, + @DomainTypeID int +) +AS +UPDATE ExchangeOrganizationDomains +SET DomainTypeID=@DomainTypeID +WHERE ItemID=ItemID AND DomainID=@DomainID +RETURN + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ChangeUserPassword] +( + @ActorID int, + @UserID int, + @Password nvarchar(200) +) +AS + +-- check actor rights +IF dbo.CanUpdateUserDetails(@ActorID, @UserID) = 0 +RETURN + +UPDATE Users +SET Password = @Password +WHERE UserID = @UserID + +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[CheckBlackBerryUserExists] + @AccountID int +AS +BEGIN + SELECT + COUNT(AccountID) + FROM + dbo.BlackBerryUsers + WHERE AccountID = @AccountID +END + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + + + +CREATE PROCEDURE [dbo].[CheckDomain] +( + @PackageID int, + @DomainName nvarchar(100), + @IsDomainPointer bit, + @Result int OUTPUT +) +AS + +/* +@Result values: + 0 - OK + -1 - already exists + -2 - sub-domain of prohibited domain +*/ + +SET @Result = 0 -- OK + +-- check if the domain already exists +IF EXISTS( +SELECT DomainID FROM Domains +WHERE DomainName = @DomainName AND IsDomainPointer = @IsDomainPointer +) +BEGIN + SET @Result = -1 + RETURN +END + +-- check if this is a sub-domain of other domain +-- that is not allowed for 3rd level hosting + +DECLARE @UserID int +SELECT @UserID = UserID FROM Packages +WHERE PackageID = @PackageID + +-- find sub-domains +DECLARE @DomainUserID int, @HostingAllowed bit +SELECT + @DomainUserID = P.UserID, + @HostingAllowed = D.HostingAllowed +FROM Domains AS D +INNER JOIN Packages AS P ON D.PackageID = P.PackageID +WHERE CHARINDEX('.' + DomainName, @DomainName) > 0 +AND (CHARINDEX('.' + DomainName, @DomainName) + LEN('.' + DomainName)) = LEN(@DomainName) + 1 +AND IsDomainPointer = 0 + +-- this is a domain of other user +IF @UserID <> @DomainUserID AND @HostingAllowed = 0 +BEGIN + SET @Result = -2 + RETURN +END + +RETURN + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO +CREATE PROCEDURE [dbo].[CheckDomainUsedByHostedOrganization] + @DomainName nvarchar(100), + @Result int OUTPUT +AS + SET @Result = 0 + IF EXISTS(SELECT 1 FROM ExchangeAccounts WHERE UserPrincipalName LIKE '%@'+ @DomainName) + BEGIN + SET @Result = 1 + END + ELSE + IF EXISTS(SELECT 1 FROM ExchangeAccountEmailAddresses WHERE EmailAddress LIKE '%@'+ @DomainName) + BEGIN + SET @Result = 1 + END + ELSE + IF EXISTS(SELECT 1 FROM LyncUsers WHERE SipAddress LIKE '%@'+ @DomainName) + BEGIN + SET @Result = 1 + END + + RETURN @Result +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + +CREATE PROCEDURE [dbo].[CheckLyncUserExists] + @AccountID int +AS +BEGIN + SELECT + COUNT(AccountID) + FROM + dbo.LyncUsers + WHERE AccountID = @AccountID +END + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + +CREATE PROCEDURE [dbo].[CheckOCSUserExists] + @AccountID int +AS +BEGIN + SELECT + COUNT(AccountID) + FROM + dbo.OCSUsers + WHERE AccountID = @AccountID +END + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE CheckServiceItemExists +( + @Exists bit OUTPUT, + @ItemName nvarchar(500), + @ItemTypeName nvarchar(200), + @GroupName nvarchar(100) = NULL +) +AS + +SET @Exists = 0 + +DECLARE @ItemTypeID int +SELECT @ItemTypeID = ItemTypeID FROM ServiceItemTypes +WHERE TypeName = @ItemTypeName + +IF EXISTS ( +SELECT ItemID FROM ServiceItems AS SI +INNER JOIN Services AS S ON SI.ServiceID = S.ServiceID +INNER JOIN Providers AS PROV ON S.ProviderID = PROV.ProviderID +INNER JOIN ResourceGroups AS RG ON PROV.GroupID = RG.GroupID +WHERE SI.ItemName = @ItemName AND SI.ItemTypeID = @ItemTypeID +AND ((@GroupName IS NULL) OR (@GroupName IS NOT NULL AND RG.GroupName = @GroupName)) +) +SET @Exists = 1 + +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE CheckServiceItemExistsInService +( + @Exists bit OUTPUT, + @ServiceID int, + @ItemName nvarchar(500), + @ItemTypeName nvarchar(200) +) +AS + +SET @Exists = 0 + +DECLARE @ItemTypeID int +SELECT @ItemTypeID = ItemTypeID FROM ServiceItemTypes +WHERE TypeName = @ItemTypeName + +IF EXISTS (SELECT ItemID FROM ServiceItems +WHERE ItemName = @ItemName AND ItemTypeID = @ItemTypeID AND ServiceID = @ServiceID) +SET @Exists = 1 + +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + +CREATE PROCEDURE [dbo].[CheckSSL] +( + @siteID int, + @Renewal bit = 0, + @Result int OUTPUT +) +AS + +/* +@Result values: + 0 - OK + -1 - already exists +*/ + +SET @Result = 0 -- OK + +-- check if a SSL Certificate is installed for domain +IF EXISTS(SELECT [ID] FROM [dbo].[SSLCertificates] WHERE [SiteID] = @siteID) +BEGIN + SET @Result = -1 + RETURN +END + +--To Do add renewal stuff + +RETURN + +SET ANSI_NULLS ON + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + +CREATE PROCEDURE [dbo].[CheckSSLExistsForWebsite] +( + @siteID int, + @SerialNumber nvarchar(250), + @Result bit OUTPUT +) +AS + +/* +@Result values: + 0 - OK + -1 - already exists +*/ + +SET @Result = 0 -- OK + +-- check if a SSL Certificate is installed for domain +IF EXISTS(SELECT [ID] FROM [dbo].[SSLCertificates] WHERE [SiteID] = @siteID +--AND SerialNumber=@SerialNumber +) +BEGIN + SET @Result = 1 + RETURN +END + +RETURN + +SET ANSI_NULLS ON + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE CheckUserExists +( + @Exists bit OUTPUT, + @Username nvarchar(100) +) +AS + +SET @Exists = 0 + +IF EXISTS (SELECT UserID FROM Users +WHERE Username = @Username) +SET @Exists = 1 + +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + +CREATE PROCEDURE [dbo].[CompleteSSLRequest] +( + @ActorID int, + @PackageID int, + @ID int, + @Certificate ntext, + @SerialNumber nvarchar(250), + @Hash ntext, + @DistinguishedName nvarchar(500), + @ValidFrom datetime, + @ExpiryDate datetime + +) +AS + +-- check rights +IF dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 +BEGIN + RAISERROR('You are not allowed to access this package', 16, 1) + RETURN +END + +-- insert record +UPDATE + [dbo].[SSLCertificates] +SET + [Certificate] = @Certificate, + [Installed] = 1, + [SerialNumber] = @SerialNumber, + [DistinguishedName] = @DistinguishedName, + [Hash] = @Hash, + [ValidFrom] = @ValidFrom, + [ExpiryDate] = @ExpiryDate +WHERE + [ID] = @ID; + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ConvertToExchangeOrganization] +( + @ItemID int +) +AS + +UPDATE + [dbo].[ServiceItems] +SET + [ItemTypeID] = 26 +WHERE + [ItemID] = @ItemID + +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[DeallocatePackageIPAddress] + @PackageAddressID int +AS +BEGIN + + SET NOCOUNT ON; + + -- check parent package + DECLARE @ParentPackageID int + + SELECT @ParentPackageID = P.ParentPackageID + FROM PackageIPAddresses AS PIP + INNER JOIN Packages AS P ON PIP.PackageID = P.PackageId + WHERE PIP.PackageAddressID = @PackageAddressID + + IF (@ParentPackageID = 1) -- "System" space + BEGIN + DELETE FROM dbo.PackageIPAddresses + WHERE PackageAddressID = @PackageAddressID + END + ELSE -- 2rd level space and below + BEGIN + UPDATE PackageIPAddresses + SET PackageID = @ParentPackageID + WHERE PackageAddressID = @PackageAddressID + END + +END + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE DeleteAllLogRecords +AS + +DELETE FROM Log + +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE DeleteAuditLogRecords +( + @ActorID int, + @UserID int, + @ItemID int, + @ItemName nvarchar(100), + @StartDate datetime, + @EndDate datetime, + @SeverityID int, + @SourceName varchar(100), + @TaskName varchar(100) +) +AS + +-- check rights +IF dbo.CheckActorUserRights(@ActorID, @UserID) = 0 +RAISERROR('You are not allowed to access this account', 16, 1) + +DECLARE @IsAdmin bit +SET @IsAdmin = 0 +IF EXISTS(SELECT UserID FROM Users WHERE UserID = @ActorID AND RoleID = 1) +SET @IsAdmin = 1 + +DELETE FROM AuditLog +WHERE (dbo.CheckUserParent(@UserID, UserID) = 1 OR (UserID IS NULL AND @IsAdmin = 1)) +AND StartDate BETWEEN @StartDate AND @EndDate +AND ((@SourceName = '') OR (@SourceName <> '' AND SourceName = @SourceName)) +AND ((@TaskName = '') OR (@TaskName <> '' AND TaskName = @TaskName)) +AND ((@ItemID = 0) OR (@ItemID > 0 AND ItemID = @ItemID)) +AND ((@ItemName = '') OR (@ItemName <> '' AND ItemName LIKE @ItemName)) + +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE DeleteAuditLogRecordsComplete +AS + +TRUNCATE TABLE AuditLog + +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[DeleteBlackBerryUser] +( + @AccountID int +) +AS + +DELETE FROM + BlackBerryUsers +WHERE + AccountID = @AccountID + +RETURN + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + +CREATE PROCEDURE [dbo].[DeleteCertificate] +( + @ActorID int, + @PackageID int, + @id int + +) +AS + +-- check rights +IF dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 +BEGIN + RAISERROR('You are not allowed to access this package', 16, 1) + RETURN +END + +-- insert record +DELETE FROM + [dbo].[SSLCertificates] +WHERE + [ID] = @id + +RETURN + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE DeleteCluster +( + @ClusterID int +) +AS + +-- reset cluster in services +UPDATE Services +SET ClusterID = NULL +WHERE ClusterID = @ClusterID + +-- delete cluster +DELETE FROM Clusters +WHERE ClusterID = @ClusterID +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + +CREATE PROCEDURE DeleteComment +( + @ActorID int, + @CommentID int +) +AS + +-- check rights +DECLARE @UserID int +SELECT @UserID = UserID FROM Comments +WHERE CommentID = @CommentID + +-- check rights +IF dbo.CheckActorUserRights(@ActorID, @UserID) = 0 +RAISERROR('You are not allowed to perform this operation', 16, 1) + + +-- delete comment +DELETE FROM Comments +WHERE CommentID = @CommentID + +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[DeleteCRMOrganization] + @ItemID int +AS +BEGIN + SET NOCOUNT ON +DELETE FROM dbo.CRMUsers WHERE AccountID IN (SELECT AccountID FROM dbo.ExchangeAccounts WHERE ItemID = @ItemID) +END + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE DeleteDnsRecord +( + @ActorID int, + @RecordID int +) +AS + +-- check rights +DECLARE @ServiceID int, @ServerID int, @PackageID int +SELECT + @ServiceID = ServiceID, + @ServerID = ServerID, + @PackageID = PackageID +FROM GlobalDnsRecords +WHERE + RecordID = @RecordID + +IF (@ServiceID > 0 OR @ServerID > 0) AND dbo.CheckIsUserAdmin(@ActorID) = 0 +RETURN + +IF (@PackageID > 0) AND dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 +RETURN + +-- delete record +DELETE FROM GlobalDnsRecords +WHERE RecordID = @RecordID + +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE DeleteDomain +( + @DomainID int, + @ActorID int +) +AS + +-- check rights +DECLARE @PackageID int +SELECT @PackageID = PackageID FROM Domains +WHERE DomainID = @DomainID + +IF dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 +RAISERROR('You are not allowed to access this package', 16, 1) + +DELETE FROM Domains +WHERE DomainID = @DomainID + +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE DeleteExchangeAccount +( + @ItemID int, + @AccountID int +) +AS + +-- delete e-mail addresses +DELETE FROM ExchangeAccountEmailAddresses +WHERE AccountID = @AccountID + +-- delete account +DELETE FROM ExchangeAccounts +WHERE ItemID = @ItemID AND AccountID = @AccountID + +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE DeleteExchangeAccountEmailAddress +( + @AccountID int, + @EmailAddress nvarchar(300) +) +AS +DELETE FROM ExchangeAccountEmailAddresses +WHERE AccountID = @AccountID AND EmailAddress = @EmailAddress +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[DeleteExchangeMailboxPlan] +( + @MailboxPlanId int +) +AS + +-- delete mailboxplan +DELETE FROM ExchangeMailboxPlans +WHERE MailboxPlanId = @MailboxPlanId + +RETURN + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[DeleteExchangeOrganization] +( + @ItemID int +) +AS +BEGIN TRAN + DELETE FROM ExchangeMailboxPlans WHERE ItemID = @ItemID + DELETE FROM ExchangeOrganizations WHERE ItemID = @ItemID +COMMIT TRAN +RETURN + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE DeleteExchangeOrganizationDomain +( + @ItemID int, + @DomainID int +) +AS +DELETE FROM ExchangeOrganizationDomains +WHERE DomainID = @DomainID AND ItemID = @ItemID +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE DeleteHostingPlan +( + @ActorID int, + @PlanID int, + @Result int OUTPUT +) +AS +SET @Result = 0 + +-- check rights +DECLARE @PackageID int +SELECT @PackageID = PackageID FROM HostingPlans +WHERE PlanID = @PlanID + +IF dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 +RAISERROR('You are not allowed to access this package', 16, 1) + +-- check if some packages uses this plan +IF EXISTS (SELECT PackageID FROM Packages WHERE PlanID = @PlanID) +BEGIN + SET @Result = -1 + RETURN +END + +-- check if some package addons uses this plan +IF EXISTS (SELECT PackageID FROM PackageAddons WHERE PlanID = @PlanID) +BEGIN + SET @Result = -2 + RETURN +END + +-- delete hosting plan +DELETE FROM HostingPlans +WHERE PlanID = @PlanID + +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[DeleteIPAddress] +( + @AddressID int, + @Result int OUTPUT +) +AS + +SET @Result = 0 + +IF EXISTS(SELECT RecordID FROM GlobalDnsRecords WHERE IPAddressID = @AddressID) +BEGIN + SET @Result = -1 + RETURN +END + +IF EXISTS(SELECT AddressID FROM PackageIPAddresses WHERE AddressID = @AddressID AND ItemID IS NOT NULL) +BEGIN + SET @Result = -2 + + RETURN +END + +-- delete package-IP relation +DELETE FROM PackageIPAddresses +WHERE AddressID = @AddressID + +-- delete IP address +DELETE FROM IPAddresses +WHERE AddressID = @AddressID + +RETURN + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[DeleteItemIPAddress] +( + @ActorID int, + @ItemID int, + @PackageAddressID int +) +AS +BEGIN + UPDATE PackageIPAddresses + SET + ItemID = NULL, + IsPrimary = 0 + FROM PackageIPAddresses AS PIP + WHERE + PIP.PackageAddressID = @PackageAddressID + AND dbo.CheckActorPackageRights(@ActorID, PIP.PackageID) = 1 +END + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[DeleteItemIPAddresses] +( + @ActorID int, + @ItemID int +) +AS +BEGIN + UPDATE PackageIPAddresses + SET + ItemID = NULL, + IsPrimary = 0 + FROM PackageIPAddresses AS PIP + WHERE + PIP.ItemID = @ItemID + AND dbo.CheckActorPackageRights(@ActorID, PIP.PackageID) = 1 +END + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + + + + + + + + + + +CREATE PROCEDURE DeleteItemPrivateIPAddress +( + @ActorID int, + @ItemID int, + @PrivateAddressID int +) +AS +BEGIN + DELETE FROM PrivateIPAddresses + FROM PrivateIPAddresses AS PIP + INNER JOIN ServiceItems AS SI ON PIP.ItemID = SI.ItemID + WHERE PIP.PrivateAddressID = @PrivateAddressID + AND dbo.CheckActorPackageRights(@ActorID, SI.PackageID) = 1 +END + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + + + + + + + + + + +CREATE PROCEDURE DeleteItemPrivateIPAddresses +( + @ActorID int, + @ItemID int +) +AS +BEGIN + DELETE FROM PrivateIPAddresses + FROM PrivateIPAddresses AS PIP + INNER JOIN ServiceItems AS SI ON PIP.ItemID = SI.ItemID + WHERE PIP.ItemID = @ItemID + AND dbo.CheckActorPackageRights(@ActorID, SI.PackageID) = 1 +END + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + +CREATE PROCEDURE [dbo].[DeleteLyncUser] +( + @AccountId int +) +AS + +DELETE FROM + LyncUsers +WHERE + AccountId = @AccountId + +RETURN + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + +CREATE PROCEDURE [dbo].[DeleteLyncUserPlan] +( + @LyncUserPlanId int +) +AS + +-- delete lyncuserplan +DELETE FROM LyncUserPlans +WHERE LyncUserPlanId = @LyncUserPlanId + +RETURN + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + +CREATE PROCEDURE [dbo].[DeleteOCSUser] +( + @InstanceId nvarchar(50) +) +AS + +DELETE FROM + OCSUsers +WHERE + InstanceId = @InstanceId + +RETURN + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[DeleteOrganizationUsers] + @ItemID int +AS +BEGIN + SET NOCOUNT ON; + + DELETE FROM ExchangeAccounts WHERE ItemID = @ItemID +END + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[DeletePackage] +( + @ActorID int, + @PackageID int +) +AS +BEGIN + -- check rights + IF dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 + RAISERROR('You are not allowed to access this package', 16, 1) + + BEGIN TRAN + + -- remove package from cache + DELETE FROM PackagesTreeCache + WHERE + ParentPackageID = @PackageID OR + PackageID = @PackageID + + -- delete package comments + DELETE FROM Comments + WHERE ItemID = @PackageID AND ItemTypeID = 'PACKAGE' + + -- delete diskspace + DELETE FROM PackagesDiskspace + WHERE PackageID = @PackageID + + -- delete bandwidth + DELETE FROM PackagesBandwidth + WHERE PackageID = @PackageID + + -- delete settings + DELETE FROM PackageSettings + WHERE PackageID = @PackageID + + -- delete domains + DELETE FROM Domains + WHERE PackageID = @PackageID + + -- delete package IP addresses + DELETE FROM PackageIPAddresses + WHERE PackageID = @PackageID + + -- delete service items + DELETE FROM ServiceItems + WHERE PackageID = @PackageID + + -- delete global DNS records + DELETE FROM GlobalDnsRecords + WHERE PackageID = @PackageID + + -- delete package services + DELETE FROM PackageServices + WHERE PackageID = @PackageID + + -- delete package quotas + DELETE FROM PackageQuotas + WHERE PackageID = @PackageID + + -- delete package resources + DELETE FROM PackageResources + WHERE PackageID = @PackageID + + -- delete package + DELETE FROM Packages + WHERE PackageID = @PackageID + + COMMIT TRAN +END + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE DeletePackageAddon +( + @ActorID int, + @PackageAddonID int +) +AS + +DECLARE @PackageID int +SELECT @PackageID = PackageID FROM PackageAddons +WHERE PackageAddonID = @PackageAddonID + +-- check rights +IF dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 +RAISERROR('You are not allowed to access this package', 16, 1) + +-- delete record +DELETE FROM PackageAddons +WHERE PackageAddonID = @PackageAddonID + +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE DeleteSchedule +( + @ActorID int, + @ScheduleID int +) +AS + +-- check rights +DECLARE @PackageID int +SELECT @PackageID = PackageID FROM Schedule +WHERE ScheduleID = @ScheduleID + +IF dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 +RAISERROR('You are not allowed to access this package', 16, 1) + +BEGIN TRAN +-- delete schedule parameters +DELETE FROM ScheduleParameters +WHERE ScheduleID = @ScheduleID + +-- delete schedule +DELETE FROM Schedule +WHERE ScheduleID = @ScheduleID + +COMMIT TRAN + +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE DeleteServer +( + @ServerID int, + @Result int OUTPUT +) +AS +SET @Result = 0 + +-- check related services +IF EXISTS (SELECT ServiceID FROM Services WHERE ServerID = @ServerID) +BEGIN + SET @Result = -1 + RETURN +END + +-- check related packages +IF EXISTS (SELECT PackageID FROM Packages WHERE ServerID = @ServerID) +BEGIN + SET @Result = -2 + RETURN +END + +-- check related hosting plans +IF EXISTS (SELECT PlanID FROM HostingPlans WHERE ServerID = @ServerID) +BEGIN + SET @Result = -3 + RETURN +END + +BEGIN TRAN + +-- delete IP addresses +DELETE FROM IPAddresses +WHERE ServerID = @ServerID + +-- delete global DNS records +DELETE FROM GlobalDnsRecords +WHERE ServerID = @ServerID + +-- delete server +DELETE FROM Servers +WHERE ServerID = @ServerID + +-- delete virtual services if any +DELETE FROM VirtualServices +WHERE ServerID = @ServerID +COMMIT TRAN + +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE DeleteService +( + @ServiceID int, + @Result int OUTPUT +) +AS + +SET @Result = 0 + +-- check related service items +IF EXISTS (SELECT ItemID FROM ServiceItems WHERE ServiceID = @ServiceID) +BEGIN + SET @Result = -1 + RETURN +END + +IF EXISTS (SELECT ServiceID FROM VirtualServices WHERE ServiceID = @ServiceID) +BEGIN + SET @Result = -2 + RETURN +END + +BEGIN TRAN +-- delete global DNS records +DELETE FROM GlobalDnsRecords +WHERE ServiceID = @ServiceID + +-- delete service +DELETE FROM Services +WHERE ServiceID = @ServiceID + +COMMIT TRAN + +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + +CREATE PROCEDURE [dbo].[DeleteServiceItem] +( + @ActorID int, + @ItemID int +) +AS + +-- check rights +DECLARE @PackageID int +SELECT PackageID = @PackageID FROM ServiceItems +WHERE ItemID = @ItemID + +IF dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 +RAISERROR('You are not allowed to access this package', 16, 1) + +BEGIN TRAN + +UPDATE Domains +SET ZoneItemID = NULL +WHERE ZoneItemID = @ItemID + +DELETE FROM Domains +WHERE WebSiteID = @ItemID AND IsDomainPointer = 1 + +UPDATE Domains +SET WebSiteID = NULL +WHERE WebSiteID = @ItemID + +UPDATE Domains +SET MailDomainID = NULL +WHERE MailDomainID = @ItemID + +-- delete item comments +DELETE FROM Comments +WHERE ItemID = @ItemID AND ItemTypeID = 'SERVICE_ITEM' + +-- delete item properties +DELETE FROM ServiceItemProperties +WHERE ItemID = @ItemID + +-- delete external IP addresses +EXEC dbo.DeleteItemIPAddresses @ActorID, @ItemID + +-- delete item +DELETE FROM ServiceItems +WHERE ItemID = @ItemID + +COMMIT TRAN + +RETURN + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[DeleteUser] +( + @ActorID int, + @UserID int +) +AS + +-- check actor rights +IF dbo.CanUpdateUserDetails(@ActorID, @UserID) = 0 +RETURN + +BEGIN TRAN +-- delete user comments +DELETE FROM Comments +WHERE ItemID = @UserID AND ItemTypeID = 'USER' + +IF (@@ERROR <> 0 ) + BEGIN + ROLLBACK TRANSACTION + RETURN -1 + END + +--delete reseller addon +DELETE FROM HostingPlans WHERE UserID = @UserID AND IsAddon = 'True' + +IF (@@ERROR <> 0 ) + BEGIN + ROLLBACK TRANSACTION + RETURN -1 + END + +-- delete user peers +DELETE FROM Users +WHERE IsPeer = 1 AND OwnerID = @UserID + +IF (@@ERROR <> 0 ) + BEGIN + ROLLBACK TRANSACTION + RETURN -1 + END + +-- delete user +DELETE FROM Users +WHERE UserID = @UserID + +IF (@@ERROR <> 0 ) + BEGIN + ROLLBACK TRANSACTION + RETURN -1 + END + +COMMIT TRAN + +RETURN + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + +-- ============================================= +-- Description: Delete user email addresses except primary email +-- ============================================= +CREATE PROCEDURE [dbo].[DeleteUserEmailAddresses] + @AccountId int, + @PrimaryEmailAddress nvarchar(300) +AS +BEGIN + +DELETE FROM + ExchangeAccountEmailAddresses +WHERE + AccountID = @AccountID AND LOWER(EmailAddress) <> LOWER(@PrimaryEmailAddress) +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[DeleteVirtualServices] +( + @ServerID int, + @Xml ntext +) +AS + +/* +XML Format: + + + + + +*/ + +BEGIN TRAN +DECLARE @idoc int +--Create an internal representation of the XML document. +EXEC sp_xml_preparedocument @idoc OUTPUT, @xml + +-- update HP resources +DELETE FROM VirtualServices +WHERE ServiceID IN ( +SELECT + ServiceID +FROM OPENXML(@idoc, '/services/service',1) WITH +( + ServiceID int '@id' +) as XS) +AND ServerID = @ServerID + +-- remove document +EXEC sp_xml_removedocument @idoc + +COMMIT TRAN +RETURN + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[DistributePackageServices] +( + @ActorID int, + @PackageID int +) +AS + +-- get primary distribution group +DECLARE @PrimaryGroupID int +DECLARE @VirtualServer bit +DECLARE @PlanID int +DECLARE @ServerID int +SELECT + @PrimaryGroupID = ISNULL(S.PrimaryGroupID, 0), + @VirtualServer = S.VirtualServer, + @PlanID = P.PlanID, + @ServerID = P.ServerID +FROM Packages AS P +INNER JOIN Servers AS S ON P.ServerID = S.ServerID +WHERE P.PackageID = @PackageID + + +-- get the list of available groups from hosting plan +DECLARE @Groups TABLE +( + GroupID int, + PrimaryGroup bit +) + +INSERT INTO @Groups (GroupID, PrimaryGroup) +SELECT + RG.GroupID, + CASE WHEN RG.GroupID = @PrimaryGroupID THEN 1 -- mark primary group + ELSE 0 + END +FROM ResourceGroups AS RG +WHERE dbo.GetPackageAllocatedResource(@PackageID, RG.GroupID, NULL) = 1 +AND RG.GroupID NOT IN +( + SELECT P.GroupID + FROM PackageServices AS PS + INNER JOIN Services AS S ON PS.ServiceID = S.ServiceID + INNER JOIN Providers AS P ON S.ProviderID = P.ProviderID + WHERE PS.PackageID = @PackageID +) + +IF @VirtualServer <> 1 +BEGIN + -- PHYSICAL SERVER + -- just return the list of services based on the plan + INSERT INTO PackageServices (PackageID, ServiceID) + SELECT + @PackageID, + S.ServiceID + FROM Services AS S + INNER JOIN Providers AS P ON S.ProviderID = P.ProviderID + INNER JOIN @Groups AS G ON P.GroupID = G.GroupID + WHERE S.ServerID = @ServerID + AND S.ServiceID NOT IN (SELECT ServiceID FROM PackageServices WHERE PackageID = @PackageID) +END +ELSE +BEGIN + -- VIRTUAL SERVER + + DECLARE @GroupID int, @PrimaryGroup int + DECLARE GroupsCursor CURSOR FOR + SELECT GroupID, PrimaryGroup FROM @Groups + ORDER BY PrimaryGroup DESC + + OPEN GroupsCursor + + WHILE (10 = 10) + BEGIN --LOOP 10: thru groups + FETCH NEXT FROM GroupsCursor + INTO @GroupID, @PrimaryGroup + + IF (@@fetch_status <> 0) + BEGIN + DEALLOCATE GroupsCursor + BREAK + END + + -- read group information + DECLARE @DistributionType int, @BindDistributionToPrimary int + SELECT + @DistributionType = DistributionType, + @BindDistributionToPrimary = BindDistributionToPrimary + FROM VirtualGroups AS VG + WHERE ServerID = @ServerID AND GroupID = @GroupID + + -- bind distribution to primary + IF @BindDistributionToPrimary = 1 AND @PrimaryGroup = 0 AND @PrimaryGroupID <> 0 + BEGIN + -- if only one service found just use it and do not distribute + IF (SELECT COUNT(*) FROM VirtualServices AS VS + INNER JOIN Services AS S ON VS.ServiceID = S.ServiceID + INNER JOIN Providers AS P ON S.ProviderID = P.ProviderID + WHERE VS.ServerID = @ServerID AND P.GroupID = @GroupID) = 1 + BEGIN + INSERT INTO PackageServices (PackageID, ServiceID) + SELECT + @PackageID, + VS.ServiceID + FROM VirtualServices AS VS + INNER JOIN Services AS S ON VS.ServiceID = S.ServiceID + INNER JOIN Providers AS P ON S.ProviderID = P.ProviderID + WHERE VS.ServerID = @ServerID AND P.GroupID = @GroupID + END + ELSE + BEGIN + DECLARE @PrimaryServerID int + -- try to get primary distribution server + SELECT + @PrimaryServerID = S.ServerID + FROM PackageServices AS PS + INNER JOIN Services AS S ON PS.ServiceID = S.ServiceID + INNER JOIN Providers AS P ON S.ProviderID = P.ProviderID + WHERE PS.PackageID = @PackageID AND P.GroupID = @PrimaryGroupID + + INSERT INTO PackageServices (PackageID, ServiceID) + SELECT + @PackageID, + VS.ServiceID + FROM VirtualServices AS VS + INNER JOIN Services AS S ON VS.ServiceID = S.ServiceID + INNER JOIN Providers AS P ON S.ProviderID = P.ProviderID + WHERE VS.ServerID = @ServerID AND P.GroupID = @GroupID AND S.ServerID = @PrimaryServerID + END + END + ELSE + BEGIN + + -- DISTRIBUTION + DECLARE @Services TABLE + ( + ServiceID int, + ItemsNumber int, + RandomNumber int + ) + + DELETE FROM @Services + + INSERT INTO @Services (ServiceID, ItemsNumber, RandomNumber) + SELECT + VS.ServiceID, + (SELECT COUNT(ItemID) FROM ServiceItems WHERE ServiceID = VS.ServiceID), + RAND() + FROM VirtualServices AS VS + INNER JOIN Services AS S ON VS.ServiceID = S.ServiceID + INNER JOIN Providers AS P ON S.ProviderID = P.ProviderID + WHERE VS.ServerID = @ServerID AND P.GroupID = @GroupID + + -- BALANCED DISTRIBUTION + IF @DistributionType = 1 + BEGIN + -- get the less allocated service + INSERT INTO PackageServices (PackageID, ServiceID) + SELECT TOP 1 + @PackageID, + ServiceID + FROM @Services + ORDER BY ItemsNumber + END + ELSE + -- RANDOMIZED DISTRIBUTION + BEGIN + -- get the less allocated service + INSERT INTO PackageServices (PackageID, ServiceID) + SELECT TOP 1 + @PackageID, + ServiceID + FROM @Services + ORDER BY RandomNumber + END + END + + IF @PrimaryGroup = 1 + SET @PrimaryGroupID = @GroupID + + END -- while groups + +END -- end virtual server + +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecAddBillingCycle] + @ActorID int, + @UserID int, + @CycleName nvarchar(255), + @BillingPeriod nvarchar(50), + @PeriodLength int, + @Result int OUTPUT +AS +BEGIN + -- check actor user rights + IF [dbo].[CheckUserParent](@ActorID, @UserID) = 0 + BEGIN + SET @Result = -1; + RAISERROR('You are not allowed to access this account', 16, 1); + RETURN; + END + + INSERT INTO [dbo].[ecBillingCycles] + ( + [ResellerID], + [CycleName], + [BillingPeriod], + [PeriodLength], + [Created] + ) + VALUES + ( + @UserID, + @CycleName, + @BillingPeriod, + @PeriodLength, + GETDATE() + ); + -- return result + SET @Result = SCOPE_IDENTITY(); + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecAddCategory] + @ActorID int, + @UserID int, + @CategoryName nvarchar(255), + @CategorySku nvarchar(50), + @ParentID int, + @ShortDescription ntext, + @FullDescription ntext, + @Result int OUTPUT +AS +BEGIN + IF [dbo].[CheckUserParent](@ActorID, @UserID) = 0 + BEGIN + SET @Result = -1; + RAISERROR('You are not allowed to access this account', 16, 1); + RETURN; + END + + SET NOCOUNT ON; + + DECLARE @Level int; + + IF @ParentID = -1 + SET @ParentID = NULL; + + -- identify category level + SELECT @Level = [Level] FROM [dbo].[ecCategory] WHERE [CategoryID] = @ParentID AND [ResellerID] = @UserID; + IF @Level >= 0 + SET @Level = @Level + 1; + ELSE + SET @Level = 0; + + INSERT INTO [dbo].[ecCategory] + ( + [CategoryName], + [CategorySku], + [ParentID], + [Level], + [ShortDescription], + [FullDescription], + [CreatorID], + [ResellerID] + ) + VALUES + ( + @CategoryName, + @CategorySku, + @ParentID, + @Level, + @ShortDescription, + @FullDescription, + @ActorID, + @UserID + ) + + SET @Result = SCOPE_IDENTITY(); + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecAddContract] + @ContractID nvarchar(50) OUTPUT, + @CustomerID int, + @ResellerID int, + @AccountName nvarchar(50), + @Status int, + @Balance money, + @FirstName nvarchar(50), + @LastName nvarchar(50), + @Email nvarchar(255), + @CompanyName nvarchar(50), + @PropertyNames ntext, + @PropertyValues ntext +AS +BEGIN + -- SET NOCOUNT ON added to prevent extra result sets from + -- interfering with SELECT statements. + SET NOCOUNT ON; + + IF @CustomerID < 1 + SET @CustomerID = NULL; + + SET @ContractID = CAST(NEWID() as nvarchar(50)); + + INSERT INTO [ecContracts] + ([ContractID],[CustomerID],[ResellerID],[AccountName],[Status],[Balance], + [FirstName],[LastName],[Email],[CompanyName],[PropertyNames],[PropertyValues]) + VALUES + (@ContractID, @CustomerID, @ResellerID, @AccountName, @Status, @Balance, @FirstName, + @LastName, @Email, @CompanyName, @PropertyNames, @PropertyValues); + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecAddCustomerPayment] + @ActorID int, + @ContractID nvarchar(50), + @InvoiceID int, + @TransactionID nvarchar(255), + @Total money, + @Currency nvarchar(3), + @MethodName nvarchar(50), + @StatusID int, + @Result int OUTPUT +AS +BEGIN + DECLARE @ResellerID int, @IssuerID int; + SELECT + @ResellerID = [ResellerID], + @IssuerID = ISNULL([CustomerID],[ResellerID]) FROM [dbo].[ecContracts] + WHERE + [ContractID] = @ContractID; + -- + IF [dbo].[CheckUserParent](@ActorID, @IssuerID) = 0 + BEGIN + RAISERROR('You are not allowed to perform this action', 16, 1); + RETURN; + END + + SET NOCOUNT ON; + + INSERT INTO [dbo].[ecCustomersPayments] + ( + [ContractID], + [InvoiceID], + [TransactionID], + [Total], + [Currency], + [MethodName], + [PluginID], + [StatusID] + ) + SELECT + @ContractID, + @InvoiceID, + @TransactionID, + @Total, + @Currency, + @MethodName, + [PluginID], + @StatusID + FROM + [dbo].[ecPaymentMethods] + WHERE + [MethodName] = @MethodName + AND + [ResellerID] = @ResellerID; + + SET @Result = SCOPE_IDENTITY(); + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecAddDomainNameSvc] + @ContractID nvarchar(50), + @ParentID int, + @ProductID int, + @FQDN nvarchar(64), + @CycleID int, + @Currency nvarchar(10), + @PropertyNames ntext, + @PropertyValues ntext, + @Result int OUTPUT +AS +BEGIN + DECLARE @ResellerID int; + SELECT + @ResellerID = [ResellerID] FROM [dbo].[ecContracts] + WHERE + [ContractID] = @ContractID; + +BEGIN TRAN ADD_TLD_SVC + -- add service + INSERT INTO [dbo].[ecService] + ([ContractID], [ParentID], [ServiceName], [TypeID], [Status], [Created]) + VALUES + (@ContractID, @ParentID, @FQDN, 3, 0, GETDATE()); + -- check error + IF @@ERROR <> 0 + GOTO ERROR_HANDLE; + -- obtain result + SET @Result = SCOPE_IDENTITY(); + + -- if product and cycle are defined + IF @ProductID > 0 OR @CycleID > 0 + BEGIN + DECLARE @SvcCycleID int; + -- insert svc life-cycle + INSERT INTO [dbo].[ecDomainSvcsCycles] + ( + [ServiceID], + [CycleName], + [BillingPeriod], + [PeriodLength], + [SetupFee], + [RecurringFee], + [Currency] + ) + SELECT + @Result, + [BC].[CycleName], + [BC].[BillingPeriod], + [BC].[PeriodLength], + [TLDC].[SetupFee], + [TLDC].[RecurringFee], + @Currency + FROM + [dbo].[ecTopLevelDomainsCycles] AS [TLDC] + INNER JOIN + [dbo].[ecBillingCycles] AS [BC] + ON + [BC].[CycleID] = [TLDC].[CycleID] + WHERE + [TLDC].[CycleID] = @CycleID + AND + [TLDC].[ProductID] = @ProductID + AND + [BC].[ResellerID] = @ResellerID; + -- check error + IF @@ROWCOUNT = 0 + GOTO ERROR_HANDLE; + -- obtain result + SET @SvcCycleID = SCOPE_IDENTITY(); + + -- add domain details + INSERT INTO [dbo].[ecDomainSvcs] + ( + [ServiceID], + [ProductID], + [PluginID], + [FQDN], + [SvcCycleID], + [PropertyNames], + [PropertyValues] + ) + SELECT + @Result, + @ProductID, + [PluginID], + @FQDN, + @SvcCycleID, + @PropertyNames, + @PropertyValues + FROM + [dbo].[ecTopLevelDomains] + WHERE + [ProductID] = @ProductID + AND + [ResellerID] = @ResellerID; + -- check error + IF @@ROWCOUNT = 0 + GOTO ERROR_HANDLE; + END + ELSE + BEGIN + INSERT INTO [dbo].[ecDomainSvcs] + ( + [ServiceID], + [ProductID], + [FQDN], + [SvcCycleID], + [PropertyNames], + [PropertyValues] + ) + SELECT @Result, NULL, @FQDN, NULL, @PropertyNames, @PropertyValues; + -- check error + IF @@ROWCOUNT = 0 + GOTO ERROR_HANDLE; + END + + -- commit + COMMIT TRAN ADD_TLD_SVC; + -- exit + RETURN; + +-- error handler +ERROR_HANDLE: +BEGIN + SET @Result = -1; + ROLLBACK TRAN ADD_TLD_SVC; + RETURN; +END + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecAddHostingAddon] + @ActorID int, + @UserID int, + @AddonName nvarchar(255), + @ProductSku nvarchar(50), + @TaxInclusive bit, + @Enabled bit, + @PlanID int, + @Recurring bit, + @DummyAddon bit, + @Countable bit, + @Description ntext, + @AddonCyclesXml xml, + @AssignedProductsXml xml, + @Result int OUTPUT +AS +BEGIN + -- check actor user rights + IF [dbo].[CheckUserParent](@ActorID, @UserID) = 0 + BEGIN + SET @Result = -1; + RAISERROR('You are not allowed to access this account', 16, 1); + RETURN; + END + -- dummy addon clause + IF @DummyAddon = 1 + SET @PlanID = NULL; + +BEGIN TRAN ADD_ADDON + DECLARE @XmlDocID int; + SET @XmlDocID = NULL; + + -- insert product first + INSERT INTO [dbo].[ecProduct] + ([ProductName], [ProductSKU], [TypeID], [TaxInclusive], [Description], [Created], [Enabled], [ResellerID]) + VALUES + (@AddonName, @ProductSku, 2, @TaxInclusive, @Description, GETDATE(), @Enabled, @UserID); + -- check errors + IF @@ERROR <> 0 + BEGIN + GOTO ERROR_HANDLE; + END + -- set product id created + SET @Result = SCOPE_IDENTITY(); + -- insert hosting addon details + INSERT INTO [dbo].[ecHostingAddons] + ([ProductID], [PlanID], [Recurring], [ResellerID], [DummyAddon], [Countable]) + VALUES + (@Result, @PlanID, @Recurring, @UserID, @DummyAddon, @Countable); + -- check errors + IF @@ERROR <> 0 + BEGIN + GOTO ERROR_HANDLE; + END +/* +XML Format: + + + + +*/ + -- save hosting addon cycles + IF @Recurring = 1 + -- insert cycles + INSERT INTO [dbo].[ecHostingAddonsCycles] + ([ProductID], [CycleID], [SetupFee], [RecurringFee], [SortOrder]) + SELECT + @Result, [SXML].[Data].value('@ID','int'), [SXML].[Data].value('@SetupFee','money'), + [SXML].[Data].value('@RecurringFee','money'), [SXML].[Data].value('@SortOrder','int') + FROM @AddonCyclesXml.nodes('/PlanCycles/Cycle') [SXML]([Data]) + ELSE + UPDATE + [dbo].[ecHostingAddons] + SET + [SetupFee] = [SXML].[Data].value('@SetupFee','money'), + [OneTimeFee] = [SXML].[Data].value('@RecurringFee','money') + FROM + @AddonCyclesXml.nodes('/PlanCycles/Cycle') [SXML]([Data]) + WHERE + [ResellerID] = @UserID AND [ProductID] = @Result; + -- check errors + IF @@ERROR <> 0 + BEGIN + GOTO ERROR_HANDLE; + END +/* +XML Format: + + + + +*/ + -- insert cycles + INSERT INTO [dbo].[ecAddonProducts] + ([AddonID], [ProductID], [ResellerID]) + SELECT + @Result, [SXML].[Data].value('@ID','int'), @UserID + FROM + @AssignedProductsXml.nodes('/AssignedProducts/Product') [SXML]([Data]) + -- check errors + IF @@ERROR <> 0 + BEGIN + GOTO ERROR_HANDLE; + END + -- + COMMIT TRAN ADD_ADDON; + -- + RETURN; + + +ERROR_HANDLE: +BEGIN + SET @Result = -1; + ROLLBACK TRAN ADD_ADDON; + RETURN; +END + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecAddHostingAddonSvc] + @ContractID nvarchar(50), + @ParentID int, + @ProductID int, + @Quantity int, + @AddonName nvarchar(255), + @CycleID int, + @Currency nvarchar(10), + @Result int OUTPUT +AS +BEGIN + DECLARE @ResellerID int; + SELECT + @ResellerID = [ResellerID] FROM [dbo].[ecContracts] + WHERE + [ContractID] = @ContractID; + +BEGIN TRAN ADD_ADDON_SVC + -- + INSERT INTO [dbo].[ecService] + ([ContractID], [ParentID], [ServiceName], [TypeID], [Status], [Created]) + VALUES + (@ContractID, @ParentID, @AddonName, 2, 0, GETDATE()); + -- obtain result + SET @Result = SCOPE_IDENTITY(); + + DECLARE @SvcCycleID int; + -- insert svc life-cycle + IF @CycleID > 0 + BEGIN + INSERT INTO [dbo].[ecHostingAddonSvcsCycles] + ( + [ServiceID], + [CycleName], + [BillingPeriod], + [PeriodLength], + [SetupFee], + [CyclePrice], + [Currency] + ) + SELECT + @Result, + [BC].[CycleName], + [BC].[BillingPeriod], + [BC].[PeriodLength], + [HAC].[SetupFee], + [HAC].[RecurringFee], + @Currency + FROM + [dbo].[ecHostingAddonsCycles] AS [HAC] + INNER JOIN + [dbo].[ecBillingCycles] AS [BC] + ON + [BC].[CycleID] = [HAC].[CycleID] + WHERE + [HAC].[CycleID] = @CycleID + AND + [HAC].[ProductID] = @ProductID + AND + [BC].[ResellerID] = @ResellerID; + -- check error + IF @@ROWCOUNT = 0 + GOTO ERROR_HANDLE; + -- obtain result + SET @SvcCycleID = SCOPE_IDENTITY(); + END + ELSE + BEGIN + INSERT INTO [dbo].[ecHostingAddonSvcsCycles] + ( + [ServiceID], + [CycleName], + [BillingPeriod], + [PeriodLength], + [SetupFee], + [CyclePrice], + [Currency] + ) + SELECT + @Result, + NULL, + NULL, + NULL, + [SetupFee], + [OneTimeFee], + @Currency + FROM + [dbo].[ecHostingAddons] + WHERE + [ProductID] = @ProductID + AND + [ResellerID] = @ResellerID; + -- check error + IF @@ROWCOUNT = 0 + GOTO ERROR_HANDLE; + -- obtain result + SET @SvcCycleID = SCOPE_IDENTITY(); + END + + -- insert addon svc details + INSERT INTO [dbo].[ecHostingAddonSvcs] + ( + [ServiceID], + [ProductID], + [PlanID], + [Quantity], + [Recurring], + [DummyAddon], + [SvcCycleID] + ) + SELECT + @Result, + @ProductID, + [PlanID], + @Quantity, + [Recurring], + [DummyAddon], + @SvcCycleID + FROM + [dbo].[ecHostingAddons] + WHERE + [ProductID] = @ProductID + AND + [ResellerID] = @ResellerID; + -- check error + IF @@ROWCOUNT = 0 + GOTO ERROR_HANDLE; + + -- commit tran + COMMIT TRAN ADD_ADDON_SVC; + -- exit + RETURN; +-- error handler +ERROR_HANDLE: +BEGIN + SET @Result = -1; + ROLLBACK TRAN ADD_ADDON_SVC; + RETURN; +END + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecAddHostingPlan] + @ActorID int, + @UserID int, + @PlanName nvarchar(255), + @ProductSku nvarchar(50), + @TaxInclusive bit, + @PlanID int, + @UserRole int, + @InitialStatus int, + @DomainOption int, + @Enabled bit, + @PlanDescription ntext, + @PlanCyclesXml xml, + @PlanHighlightsXml xml, + @PlanCategoriesXml xml, + @Result int OUTPUT +AS +BEGIN + -- check actor user rights + IF [dbo].[CheckUserParent](@ActorID, @UserID) = 0 + BEGIN + SET @Result = -1; + RAISERROR('You are not allowed to access this account', 16, 1); + RETURN; + END + +BEGIN TRAN ADD_PLAN + -- insert product first + INSERT INTO [dbo].[ecProduct] + ([ProductName], [ProductSKU], [TypeID], [TaxInclusive], [Description], [Created], [Enabled], [ResellerID]) + VALUES + (@PlanName, @ProductSku, 1, @TaxInclusive, @PlanDescription, GETDATE(), @Enabled, @UserID); + -- set product id created + SET @Result = SCOPE_IDENTITY(); + -- save hosting plan details + INSERT INTO [dbo].[ecHostingPlans] + ([ProductID], [ResellerID], [PlanID], [UserRole], [InitialStatus], [DomainOption]) + VALUES + (@Result, @UserID, @PlanID, @UserRole, @InitialStatus, @DomainOption); + -- check errors + IF @@ERROR <> 0 + BEGIN + GOTO ERROR_HANDLE; + END + +/* +XML Format: + + + + +*/ + -- insert cycles + INSERT INTO [dbo].[ecHostingPlansBillingCycles] + ([ProductID], [CycleID], [SetupFee], [RecurringFee], [SortOrder]) + SELECT + @Result, [SXML].[Data].value('@ID','int'), [SXML].[Data].value('@SetupFee','money'), + [SXML].[Data].value('@RecurringFee','money'), [SXML].[Data].value('@SortOrder','int') + FROM @PlanCyclesXml.nodes('/PlanCycles/Cycle') [SXML]([Data]) + -- check errors + IF @@ERROR <> 0 + BEGIN + GOTO ERROR_HANDLE; + END + +/* +XML Format: + + + + +*/ + -- insert cycles + INSERT INTO [dbo].[ecProductsHighlights] + ([ProductID], [HighlightText], [SortOrder]) + SELECT + @Result, [SXML].[Data].value('@Text','nvarchar(255)'), [SXML].[Data].value('@SortOrder','int') + FROM @PlanHighlightsXml.nodes('/PlanHighlights/Item') [SXML]([Data]) + -- check errors + IF @@ERROR <> 0 + BEGIN + GOTO ERROR_HANDLE; + END +/* +XML Format: + + + + +*/ + -- insert categories + INSERT INTO [dbo].[ecProductCategories] + ([ProductID], [CategoryID], [ResellerID]) + SELECT + @Result, [SXML].[Data].value('@ID','int'), @UserID FROM @PlanCategoriesXml.nodes('/PlanCategories/Category') [SXML]([Data]) + -- check errors + IF @@ERROR <> 0 + GOTO ERROR_HANDLE; + -- commit changes + COMMIT TRAN ADD_PLAN; + -- return result + RETURN; + +ERROR_HANDLE: +BEGIN + SET @Result = -1; + ROLLBACK TRAN ADD_PLAN; + RETURN; +END + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecAddHostingPlanSvc] + @ContractID nvarchar(50), + @ProductID int, + @PlanName nvarchar(255), + @CycleID int, + @Currency nvarchar(10), + @Result int OUTPUT +AS +BEGIN + DECLARE @ResellerID int; + SELECT + @ResellerID = [ResellerID] FROM [dbo].[ecContracts] + WHERE + [ContractID] = @ContractID; + +BEGIN TRAN ADD_HPLAN_SVC + -- add service + INSERT INTO [dbo].[ecService] + ([ContractID], [ServiceName], [TypeID], [Status], [Created]) + VALUES + (@ContractID, @PlanName, 1, 0, GETDATE()); + -- check error + IF @@ERROR <> 0 + GOTO ERROR_HANDLE; + -- obtain result + SET @Result = SCOPE_IDENTITY(); + + DECLARE @SvcCycleID int; + -- insert svc life-cycle + INSERT INTO [dbo].[ecHostingPackageSvcsCycles] + ( + [ServiceID], + [CycleName], + [BillingPeriod], + [PeriodLength], + [SetupFee], + [RecurringFee], + [Currency] + ) + SELECT + @Result, + [BC].[CycleName], + [BC].[BillingPeriod], + [BC].[PeriodLength], + [HPBC].[SetupFee], + [HPBC].[RecurringFee], + @Currency + FROM + [dbo].[ecHostingPlansBillingCycles] AS [HPBC] + INNER JOIN + [dbo].[ecBillingCycles] AS [BC] + ON + [BC].[CycleID] = [HPBC].[CycleID] + WHERE + [HPBC].[CycleID] = @CycleID + AND + [HPBC].[ProductID] = @ProductID + AND + [BC].[ResellerID] = @ResellerID; + -- check error + IF @@ROWCOUNT = 0 + GOTO ERROR_HANDLE; + -- obtain result + SET @SvcCycleID = SCOPE_IDENTITY(); + + -- add plan details + INSERT INTO [dbo].[ecHostingPackageSvcs] + ( + [ServiceID], + [ProductID], + [PlanID], + [UserRole], + [InitialStatus], + [SvcCycleID] + ) + SELECT + @Result, + @ProductID, + [PlanID], + [UserRole], + [InitialStatus], + @SvcCycleID + FROM + [dbo].[ecHostingPlans] + WHERE + [ProductID] = @ProductID + AND + [ResellerID] = @ResellerID; + -- check error + IF @@ROWCOUNT = 0 + GOTO ERROR_HANDLE; + + + -- commit tran + COMMIT TRAN ADD_HPLAN_SVC; + -- exit + RETURN; +-- error handler +ERROR_HANDLE: +BEGIN + SET @Result = -1; + ROLLBACK TRAN ADD_HPLAN_SVC; + RETURN; +END + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecAddInvoice] + @ContractID nvarchar(50), + @Created datetime, + @DueDate datetime, + @TaxationID int, + @TotalAmount money, + @SubTotalAmount money, + @TaxAmount money, + @Xml ntext, + @Currency nvarchar(3), + @Result int OUTPUT +AS +BEGIN +/* + XML Format: + + + +*/ + +BEGIN TRAN ADD_INVOICE + DECLARE @XmlDocID int; + SET @XmlDocID = NULL; + -- + IF @TaxationID < 1 + SET @TaxationID = NULL; + -- emit invoice + INSERT INTO [dbo].[ecInvoice] + ([ContractID], [Created], [DueDate], [TaxationID], [Total], [SubTotal], [TaxAmount], [Currency]) + VALUES + (@ContractID, @Created, @DueDate, @TaxationID, @TotalAmount, @SubTotalAmount, @TaxAmount, @Currency); + -- obtain result + SET @Result = SCOPE_IDENTITY(); + + --Create an internal representation of the XML document. + EXEC sp_xml_preparedocument @XmlDocID OUTPUT, @Xml;; + -- + INSERT INTO [dbo].[ecInvoiceItems] + ( + [InvoiceID], + [ServiceID], + [ItemName], + [TypeName], + [Quantity], + [Total], + [SubTotal], + [UnitPrice] + ) + SELECT + @Result, + CASE [XML].[ServiceID] + WHEN 0 THEN NULL + ELSE [XML].[ServiceID] + END, + [XML].[ItemName], + [XML].[TypeName], + [XML].[Quantity], + [XML].[Total], + [XML].[SubTotal], + [XML].[UnitPrice] + FROM OPENXML(@XmlDocID, '/items/item',1) WITH + ( + [ServiceID] int '@serviceid', + [ItemName] nvarchar(255) '@itemname', + [TypeName] nvarchar(255) '@typename', + [Quantity] int '@quantity', + [Total] money '@total', + [SubTotal] money '@subtotal', + [UnitPrice] money '@unitprice' + ) AS [XML]; + -- check errors + IF @@ERROR <> 0 + GOTO ERROR_HANDLE; + -- remove document + EXEC sp_xml_removedocument @XmlDocID; + + -- commit + COMMIT TRAN ADD_INVOICE; + -- exit + RETURN; +-- error handle +ERROR_HANDLE: +BEGIN + IF NOT @XmlDocID IS NULL + EXEC sp_xml_removedocument @XmlDocID; + + SET @Result = -1; + ROLLBACK TRAN ADD_INVOICE; + RETURN; +END + +END + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecAddServiceHandlerTextResponse] + @ServiceID nvarchar(50), + @ContractID nvarchar(50), + @InvoiceID int, + @DataReceived ntext +AS +BEGIN + -- SET NOCOUNT ON added to prevent extra result sets from + -- interfering with SELECT statements. + SET NOCOUNT ON; + + IF @InvoiceID = 0 + SET @InvoiceID = NULL; + + INSERT INTO [ecServiceHandlersResponses] ([ServiceID],[ContractID],[InvoiceID],[TextResponse]) + VALUES (@ServiceID,@ContractID,@InvoiceID,@DataReceived); + +END + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecAddServiceUsageRecord] + @ActorID int, + @ServiceID int, + @SvcCycleID int, + @StartDate datetime, + @EndDate datetime, + @Result int OUTPUT +AS +BEGIN + + -- SET NOCOUNT ON added to prevent extra result sets from + -- interfering with SELECT statements. + SET NOCOUNT ON; + + SET @Result = 0; + + INSERT INTO [dbo].[ecSvcsUsageLog] + ( + [ServiceID], + [SvcCycleID], + [StartDate], + [EndDate] + ) + VALUES + ( + @ServiceID, + @SvcCycleID, + @StartDate, + @EndDate + ); + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + +CREATE PROCEDURE [dbo].[ecAddSystemTrigger] + @ActorID int, + @OwnerID int, + @TriggerHandler nvarchar(512), + @ReferenceID nvarchar(50), + @Namespace nvarchar(255), + @Status nvarchar(50) +AS +BEGIN + IF [dbo].[CheckUserParent](@ActorID, @OwnerID) = 0 + BEGIN + RAISERROR('You are not allowed to perform this action', 16, 1); + RETURN; + END + -- SET NOCOUNT ON added to prevent extra result sets from + -- interfering with SELECT statements. + SET NOCOUNT ON; + + IF NOT EXISTS(SELECT * FROM [dbo].[ecSystemTriggers] WHERE [OwnerID] = @OwnerID AND + [TriggerHandler] = @TriggerHandler AND [ReferenceID] = @ReferenceID AND + [Namespace] = @Namespace AND [Status] = @Status) + BEGIN + INSERT INTO [dbo].[ecSystemTriggers] + ([OwnerID], [TriggerHandler], [ReferenceID], [Namespace], [Status]) + VALUES + (@OwnerID, @TriggerHandler, @ReferenceID, @Namespace, @Status); + END + +END + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecAddTaxation] + @ActorID int, + @UserID int, + @Country nvarchar(3), + @State nvarchar(50), + @Description nvarchar(50), + @TypeID int, + @Amount decimal(5,2), + @Active bit, + @Result int OUTPUT +AS +BEGIN + -- check actor user rights + IF [dbo].[CheckUserParent](@ActorID, @UserID) = 0 + BEGIN + RAISERROR('You are not allowed to access this account', 16, 1); + RETURN; + END + -- SET NOCOUNT ON added to prevent extra result sets from + -- interfering with SELECT statements. + SET NOCOUNT ON; + -- check before insert + IF EXISTS (SELECT [TaxationID] FROM [dbo].[ecTaxations] + WHERE [ResellerID] = @UserID AND [Country] = @Country AND [State] = @State) + BEGIN + SET @Result = -202; + RETURN; + END + + -- insert + INSERT INTO [dbo].[ecTaxations] + ( + [ResellerID], + [Country], + [State], + [Description], + [TypeID], + [Amount], + [Active] + ) + VALUES + ( + @UserID, + @Country, + @State, + @Description, + @TypeID, + @Amount, + @Active + ); + -- + SET @Result = SCOPE_IDENTITY(); + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecAddTopLevelDomain] + @ActorID int, + @UserID int, + @TopLevelDomain nvarchar(10), + @ProductSku nvarchar(50), + @TaxInclusive bit, + @PluginID int, + @Enabled bit, + @WhoisEnabled bit, + @DomainCyclesXml xml, + @Result int OUTPUT +AS +BEGIN + -- check actor user rights + IF [dbo].[CheckUserParent](@ActorID, @UserID) = 0 + BEGIN + SET @Result = -1; + RAISERROR('You are not allowed to access this account', 16, 1); + RETURN; + END + +BEGIN TRAN ADD_DOMAIN + -- insert product first + INSERT INTO [dbo].[ecProduct] + ( + [ProductName], + [ProductSKU], + [TypeID], + [Description], + [Created], + [Enabled], + [ResellerID], + [TaxInclusive] + ) + VALUES + ( + @TopLevelDomain, + @ProductSku, + 3, -- Domain Name type + NULL, + GETDATE(), + @Enabled, + @UserID, + @TaxInclusive + ); + + -- set product id created + SET @Result = SCOPE_IDENTITY(); + + -- save top level domain details + INSERT INTO [dbo].[ecTopLevelDomains] + ( + [ProductID], + [ResellerID], + [TopLevelDomain], + [PluginID], + [WhoisEnabled] + ) + VALUES + ( + @Result, + @UserID, + @TopLevelDomain, + @PluginID, + @WhoisEnabled + ); + -- check errors + IF @@ERROR <> 0 + BEGIN + GOTO ERROR_HANDLE; + END + +/* +XML Format: + + + + +*/ + -- insert cycles + INSERT INTO [dbo].[ecTopLevelDomainsCycles] + ( + [ProductID], + [CycleID], + [SetupFee], + [RecurringFee], + [TransferFee], + [SortOrder] + ) + SELECT + @Result, + [SXML].[Data].value('@ID','int'), + [SXML].[Data].value('@SetupFee','money'), + [SXML].[Data].value('@RecurringFee','money'), + [SXML].[Data].value('@TransferFee','money'), + [SXML].[Data].value('@SortOrder','int') + FROM @DomainCyclesXml.nodes('/DomainCycles/Cycle') [SXML]([Data]); + -- check errors + IF @@ERROR <> 0 + GOTO ERROR_HANDLE; + -- + COMMIT TRAN ADD_DOMAIN; + -- + RETURN; + +ERROR_HANDLE: +BEGIN + SET @Result = -1; + ROLLBACK TRAN ADD_DOMAIN; + RETURN; +END + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecBulkServiceDelete] + @ActorID int, + @ContractID nvarchar(50), + @SvcsXml xml, + @Result int OUTPUT +AS +BEGIN + DECLARE @IssuerID int; + SELECT + @IssuerID = ISNULL([CustomerID],[ResellerID]) FROM [dbo].[ecContracts] + WHERE + [ContractID] = @ContractID; + -- check actor user rights + IF [dbo].[CheckUserParent](@ActorID, @IssuerID) = 0 + BEGIN + RAISERROR('You are not allowed to access this information', 16, 1); + RETURN; + END + -- SET NOCOUNT ON added to prevent extra result sets from + -- interfering with SELECT statements. + SET NOCOUNT ON; + + DELETE + FROM [dbo].[ecService] + WHERE + [ServiceID] IN(SELECT [SXML].[Data].value('@id','int') FROM @SvcsXml.nodes('/Svcs/Svc') [SXML]([Data])); + -- + SET @Result = 0; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecChangeHostingPlanSvcCycle] + @ActorID int, + @ServiceID int, + @ProductID int, + @CycleID int, + @Currency nvarchar(3), + @Result int OUTPUT +AS +BEGIN + DECLARE @ResellerID int, @CustomerID int, @ContractID nvarchar(50); + SELECT + @ContractID = [ContractID] FROM [dbo].[ecService] + WHERE + [ServiceID] = @ServiceID; + SELECT + @CustomerID = [CustomerID], @ResellerID = [ResellerID] FROM [ecContracts] + WHERE + [ContractID] = @ContractID; + + -- check actor user rights + IF [dbo].[CanUpdateUserDetails](@ActorID, @CustomerID) = 0 + BEGIN + RAISERROR('You are not allowed to access this action', 16, 1); + RETURN; + END + +BEGIN TRAN CHNG_SVC_CYCLE + -- insert svc life-cycle + INSERT INTO [dbo].[ecHostingPackageSvcsCycles] + ( + [ServiceID], + [CycleName], + [BillingPeriod], + [PeriodLength], + [SetupFee], + [RecurringFee], + [Currency] + ) + SELECT + @Result, + [BC].[CycleName], + [BC].[BillingPeriod], + [BC].[PeriodLength], + [HPBC].[SetupFee], + [HPBC].[RecurringFee], + @Currency + FROM + [dbo].[ecHostingPlansBillingCycles] AS [HPBC] + INNER JOIN + [dbo].[ecBillingCycles] AS [BC] + ON + [BC].[CycleID] = [HPBC].[CycleID] + WHERE + [HPBC].[ProductID] = @ProductID + AND + [BC].[ResellerID] = @ResellerID; + -- check error + IF @@ERROR <> 0 + GOTO ERROR_HANDLE; + -- obtain result + SET @Result = SCOPE_IDENTITY(); + + -- update service + UPDATE + [dbo].[ecHostingPackageSvcs] + SET + [SvcCycleID] = @Result + WHERE + [ServiceID] = @ServiceID; + -- check error + IF @@ERROR <> 0 OR @@ROWCOUNT = 0 + GOTO ERROR_HANDLE; + + -- commit changes + COMMIT TRAN CHNG_SVC_CYCLE; + -- exit + RETURN; + +-- error handler +ERROR_HANDLE: +BEGIN + SET @Result = -1; + ROLLBACK TRAN CHNG_SVC_CYCLE; + RETURN; +END + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecCheckCustomerContractExists] + @CustomerID int, + @Result bit OUTPUT +AS +BEGIN + -- SET NOCOUNT ON added to prevent extra result sets from + -- interfering with SELECT statements. + SET NOCOUNT ON; + + IF EXISTS (SELECT * FROM [ecContracts] WHERE [CustomerID] = @CustomerID) + BEGIN + SET @Result = 1; + RETURN; + END + + SET @Result = 0; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecDeleteBillingCycle] + @ActorID int, + @UserID int, + @CycleID int, + @Result int OUTPUT +AS +BEGIN + -- check actor user rights + IF [dbo].[CheckUserParent](@ActorID, @UserID) = 0 + BEGIN + SET @Result = -1; + RAISERROR('You are not allowed to access this account', 16, 1); + RETURN; + END + + DELETE FROM [dbo].[ecBillingCycles] WHERE [ResellerID] = @UserID AND [CycleID] = @CycleID; + + SET @Result = 0; + RETURN; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecDeleteCategory] + @ActorID int, + @UserID int, + @CategoryID int, + @Result int OUTPUT +AS +BEGIN + IF [dbo].[CheckUserParent](@ActorID, @UserID) = 0 + BEGIN + SET @Result = -1; + RAISERROR('You are not allowed to access this account', 16, 1); + RETURN; + END + + SET NOCOUNT ON; + + SET @Result = 0; + + -- check whether the category doesn't empty + IF EXISTS( + SELECT + [ProductID] + FROM + [dbo].[ecProductCategories] + WHERE + [CategoryID] = @CategoryID + AND + [ResellerID] = @UserID + ) + BEGIN + SET @Result = -1; + RETURN; + END + + -- check if category has a sub-categories + IF EXISTS( + SELECT + [CategoryID] + FROM + [dbo].[ecCategory] + WHERE + [ParentID] = @CategoryID + AND + [ResellerID] = @UserID + ) + BEGIN + SET @Result = -2; + RETURN; + END + + -- delete a category + DELETE FROM + [dbo].[ecCategory] + WHERE + [CategoryID] = @CategoryID + AND + [ResellerID] = @UserID; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecDeleteContract] + @ContractID nvarchar(50), + @Result int OUTPUT +AS +BEGIN + -- SET NOCOUNT ON added to prevent extra result sets from + -- interfering with SELECT statements. + SET NOCOUNT ON; + + IF NOT EXISTS (SELECT * FROM [dbo].[ecContracts] WHERE [ContractID] = @ContractID) + BEGIN + SET @Result = -1; + RETURN; + END + + SET @Result = 0; + DELETE FROM [dbo].[ecContracts] WHERE [ContractID] = @ContractID; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecDeleteCustomerPayment] + @ActorID int, + @PaymentID int, + @Result int OUTPUT +AS +BEGIN + DECLARE @IssuerID int, @ContractID nvarchar(50); + SELECT + @ContractID = [ContractID] FROM [dbo].[ecCustomersPayments] + WHERE + [PaymentID] = @PaymentID + SELECT + @IssuerID = [ResellerID] FROM [dbo].[ecContracts] + WHERE + [ContractID] = @ContractID; + -- check actor user rights + IF [dbo].[CheckUserParent](@ActorID, @IssuerID) = 0 + BEGIN + RAISERROR('You are not allowed to access this action', 16, 1); + RETURN; + END + -- SET NOCOUNT ON added to prevent extra result sets from + -- interfering with SELECT statements. + SET NOCOUNT ON; + + SET @Result = 0; + + DELETE + FROM [dbo].[ecCustomersPayments] + WHERE + [PaymentID] = @PaymentID; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecDeleteCustomerService] + @ActorID int, + @ServiceID int, + @Result int OUTPUT +AS +BEGIN + DECLARE @IssuerID int, @ContractID nvarchar(50); + SELECT + @ContractID = [ContractID] FROM [dbo].[ecService] + WHERE + [ServiceID] = @ServiceID; + SELECT + @IssuerID = [ResellerID] FROM [dbo].[ecContracts] + WHERE + [ContractID] = @ContractID; + -- check actor user rights + IF [dbo].[CheckUserParent](@ActorID, @IssuerID) = 0 + BEGIN + RAISERROR('You are not allowed to access this action', 16, 1); + RETURN; + END + -- SET NOCOUNT ON added to prevent extra result sets from + -- interfering with SELECT statements. + SET NOCOUNT ON; + + SET @Result = 0; + + DELETE FROM [dbo].[ecService] WHERE [ServiceID] = @ServiceID; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecDeletePaymentMethod] + @ActorID int, + @UserID int, + @MethodName nvarchar(50), + @Result int OUTPUT +AS +BEGIN + -- check actor user rights + IF [dbo].[CheckUserParent](@ActorID, @UserID) = 0 + BEGIN + SET @Result = -1; + RAISERROR('You are not allowed to access this account', 16, 1); + RETURN; + END + -- SET NOCOUNT ON added to prevent extra result sets from + -- interfering with SELECT statements. + SET NOCOUNT ON; + -- + SET @Result = 0; + -- remove + DELETE FROM [dbo].[ecPaymentMethods] + WHERE [ResellerID] = @UserID AND [MethodName] = @MethodName; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecDeletePaymentProfile] + @ActorID int, + @ContractID nvarchar(50), + @Result int OUTPUT +AS +BEGIN + DECLARE @CustomerID int; + SELECT + @CustomerID = [CustomerID] FROM [dbo].[ecContracts] + WHERE + [ContractID] = @ContractID; + -- check actor user rights + IF [dbo].[CheckUserParent](@ActorID, @CustomerID) = 0 + BEGIN + RAISERROR('You are not allowed to perform this action', 16, 1); + RETURN; + END + + SET @Result = 0; + + DELETE FROM [dbo].[ecPaymentProfiles] WHERE [ContractID] = @ContractID; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecDeleteProduct] + @ActorID int, + @UserID int, + @ProductID int, + @Result int OUTPUT +AS +BEGIN + -- check actor user rights + IF [dbo].[CheckUserParent](@ActorID, @UserID) = 0 + BEGIN + SET @Result = -1; + RAISERROR('You are not allowed to access this account', 16, 1); + RETURN; + END + +BEGIN TRAN RMV_PRODUCT + -- remove product + DELETE FROM [dbo].[ecProduct] WHERE [ProductID] = @ProductID AND [ResellerID] = @UserID; + -- check errors + IF @@ERROR <> 0 + GOTO ERROR_HANDLE; + -- workaround for cyclic cascades + DELETE FROM [dbo].[ecAddonProducts] WHERE [ProductID] = @ProductID AND [ResellerID] = @UserID; + -- check errors + IF @@ERROR <> 0 + GOTO ERROR_HANDLE; + -- set result ok + SET @Result = 0; + -- commit actions + COMMIT TRAN RMV_PRODUCT; + -- exit routine + RETURN; + +ERROR_HANDLE: +BEGIN + SET @Result = -1; + ROLLBACK TRAN RMV_PRODUCT; + RETURN; +END + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecDeleteSystemTrigger] + @ActorID int, + @TriggerID nvarchar(50) +AS +BEGIN + DECLARE @OwnerID int; + SELECT + @OwnerID = [OwnerID] FROM [dbo].[ecSystemTriggers] + WHERE + [TriggerID] = @TriggerID; + -- + IF [dbo].[CheckUserParent](@ActorID, @OwnerID) = 0 + BEGIN + RAISERROR('You are not allowed to perform this action', 16, 1); + RETURN; + END + -- SET NOCOUNT ON added to prevent extra result sets from + -- interfering with SELECT statements. + SET NOCOUNT ON; + + DELETE FROM [dbo].[ecSystemTriggers] WHERE [TriggerID] = @TriggerID; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecDeleteTaxation] + @ActorID int, + @UserID int, + @TaxationID int, + @Result int OUTPUT +AS +BEGIN + -- + IF [dbo].[CheckUserParent](@ActorID, @UserID) = 0 + BEGIN + RAISERROR('You are not allowed to access this account', 16, 1); + RETURN; + END + -- SET NOCOUNT ON added to prevent extra result sets from + -- interfering with SELECT statements. + SET NOCOUNT ON; + -- + DELETE FROM [dbo].[ecTaxations] WHERE [ResellerID] = @UserID AND [TaxationID] = @TaxationID; + -- + SET @Result = 0; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecGetAddonProducts] + @UserID int, + @ProductID int +AS +BEGIN + + SELECT + [P].* + FROM + [dbo].[ecProduct] AS [P] + INNER JOIN [dbo].[ecAddonProducts] AS [ATP] + ON [P].[ProductID] = [ATP].[ProductID] + WHERE + [ATP].[AddonID] = @ProductID + AND + [P].[ResellerID] = @UserID; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecGetAddonProductsIds] + @UserID int, + @ProductID int +AS +BEGIN + + SELECT + [P].[ProductID] + FROM + [dbo].[ecProduct] AS [P] + INNER JOIN [dbo].[ecAddonProducts] AS [ATP] + ON [P].[ProductID] = [ATP].[ProductID] + WHERE + [ATP].[AddonID] = @ProductID + AND + [P].[ResellerID] = @UserID; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecGetBillingCycle] + @ActorID int, + @UserID int, + @CycleID int +AS +BEGIN + -- check actor user rights + IF [dbo].[CheckUserParent](@ActorID, @UserID) = 0 + BEGIN + RAISERROR('You are not allowed to access this account', 16, 1); + RETURN; + END + + SELECT * FROM [dbo].[ecBillingCycles] WHERE [ResellerID] = @UserID AND [CycleID] = @CycleID; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecGetBillingCyclesCount] + @ActorID int, + @UserID int, + @Count int OUTPUT +AS +BEGIN + -- check actor user rights + IF [dbo].[CheckUserParent](@ActorID, @UserID) = 0 + BEGIN + RAISERROR('You are not allowed to access this account', 16, 1); + RETURN; + END + + SELECT @Count = COUNT(*) FROM [dbo].[ecBillingCycles] WHERE [ResellerID] = @UserID; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecGetBillingCyclesFree] + @ActorID int, + @UserID int, + @CyclesTakenXml ntext +AS +BEGIN + -- check actor user rights + IF [dbo].[CheckUserParent](@ActorID, @UserID) = 0 + BEGIN + RAISERROR('You are not allowed to access this account', 16, 1); + RETURN; + END + + DECLARE @DocID int; + + EXEC sp_xml_preparedocument @DocID OUTPUT, @CyclesTakenXml; + + SELECT * FROM [dbo].[ecBillingCycles] WHERE [ResellerID] = @UserID AND [CycleID] NOT IN ( + SELECT [CycleTakenID] FROM OPENXML(@DocID, '/CyclesTaken/Cycle',1) WITH + ( + [CycleTakenID] int '@id' + ) + ); + + EXEC sp_xml_removedocument @DocID; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecGetBillingCyclesPaged] + @ActorID int, + @UserID int, + @MaximumRows int, + @StartRowIndex int +AS +BEGIN + + -- check actor user rights + IF [dbo].[CheckUserParent](@ActorID, @UserID) = 0 + BEGIN + RAISERROR('You are not allowed to access this account', 16, 1); + RETURN; + END + + DECLARE @EndIndex int; + + SET @EndIndex = @MaximumRows + @StartRowIndex; + SET @StartRowIndex = @StartRowIndex + 1; + + WITH [BillingCyclesCTE] AS ( + SELECT + ROW_NUMBER() OVER(ORDER BY [Created] DESC) AS [RowIndex], + * + FROM + [dbo].[ecBillingCycles] + WHERE + [ResellerID] = @UserID + ) + + SELECT + * + FROM + [BillingCyclesCTE] + WHERE + [RowIndex] BETWEEN @StartRowIndex AND @EndIndex; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecGetCategoriesCount] + @ActorID int, + @UserID int, + @ParentID int, + @Count int OUTPUT +AS + IF @ParentID > 0 + BEGIN + SELECT + @Count = COUNT([CategoryID]) + FROM + [ecCategory] + WHERE + [ParentID] = @ParentID + AND + [ResellerID] = @UserID; + END + ELSE + BEGIN + SELECT + @Count = COUNT([CategoryID]) + FROM + [ecCategory] + WHERE + [ParentID] IS NULL + AND + [ResellerID] = @UserID; + END + +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecGetCategoriesPaged] + @ActorID int, + @UserID int, + @ParentID int, + @MaximumRows int, + @StartRowIndex int +AS + -- check actor user rights + IF [dbo].[CheckUserParent](@ActorID, @UserID) = 0 + BEGIN + RAISERROR('You are not allowed to access this account', 16, 1); + RETURN; + END + + DECLARE @EndIndex int; + + SET @EndIndex = @MaximumRows + @StartRowIndex; + SET @StartRowIndex = @StartRowIndex + 1; + + IF @ParentID > 0 + BEGIN + WITH [CategoryCTE] AS ( + SELECT + ROW_NUMBER() OVER(ORDER BY [Created] DESC) AS [RowIndex], + * + FROM + [dbo].[ecCategory] + WHERE + [ParentID] = @ParentID + AND + [ResellerID] = @UserID + ) + + SELECT * FROM [CategoryCTE] WHERE [RowIndex] BETWEEN @StartRowIndex AND @EndIndex ORDER BY [CategoryName]; + END + ELSE + BEGIN + WITH [CategoryCTE] AS ( + SELECT + ROW_NUMBER() OVER(ORDER BY [Created] DESC) AS [RowIndex], + * + FROM + [dbo].[ecCategory] + WHERE + [ParentID] IS NULL + AND + [ResellerID] = @UserID + ) + + SELECT * FROM [CategoryCTE] WHERE [RowIndex] BETWEEN @StartRowIndex AND @EndIndex ORDER BY [CategoryID], [CategoryName]; + END + +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecGetCategory] + @ActorID int, + @UserID int, + @CategoryID int +AS +BEGIN + + SET NOCOUNT ON; + + SELECT + * + FROM + [dbo].[ecCategory] + WHERE + [CategoryID] = @CategoryID + AND + [ResellerID] = @UserID; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecGetContract] + @ContractID nvarchar(50) +AS +BEGIN + -- SET NOCOUNT ON added to prevent extra result sets from + -- interfering with SELECT statements. + SET NOCOUNT ON; + + SELECT * FROM [dbo].[ecContracts] WHERE [ContractID] = @ContractID; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecGetCustomerContract] + @CustomerID int +AS +BEGIN + -- SET NOCOUNT ON added to prevent extra result sets from + -- interfering with SELECT statements. + SET NOCOUNT ON; + + SELECT * FROM [dbo].[ecContracts] WHERE [CustomerID] = @CustomerID; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecGetCustomerInvoice] + @ActorID int, + @InvoiceID int +AS +BEGIN + DECLARE @IssuerID int, @ContractID nvarchar(50); + SELECT + @ContractID = [ContractID] FROM [dbo].[ecInvoice] + WHERE + [InvoiceID] = @InvoiceID; + SELECT + @IssuerID = ISNULL([CustomerID],[ResellerID]) FROM [dbo].[ecContracts] + WHERE + [ContractID] = @ContractID; + -- check actor rights + IF [dbo].[CheckUserParent](@ActorID, @IssuerID) = 0 + BEGIN + RAISERROR('You are not allowed to access the contract', 16, 1); + RETURN; + END + -- + SET NOCOUNT ON; + -- + SELECT + * FROM [dbo].[ContractsInvoicesDetailed] + WHERE + [InvoiceID] = @InvoiceID AND [ContractID] = @ContractID; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecGetCustomerInvoiceItems] + @ActorID int, + @InvoiceID int +AS +BEGIN + DECLARE @IssuerID int, @ContractID nvarchar(50); + SELECT + @ContractID = [ContractID] FROM [dbo].[ecInvoice] + WHERE + [InvoiceID] = @InvoiceID; + SELECT + @IssuerID = ISNULL([CustomerID],[ResellerID]) FROM [dbo].[ecContracts] + WHERE + [ContractID] = @ContractID; + -- check actor user rights + IF [dbo].[CheckUserParent](@ActorID,@IssuerID) = 0 + BEGIN + RAISERROR('You are not allowed to access the contract', 16, 1); + RETURN; + END + -- + SET NOCOUNT ON; + -- + SELECT + * FROM [dbo].[ecInvoiceItems] AS [II] + INNER JOIN + [ecInvoice] AS [I] ON [I].[InvoiceID] = [II].[InvoiceID] + WHERE + [I].[InvoiceID] = @InvoiceID; + +END + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecGetCustomerPayment] + @ActorID int, + @PaymentID int +AS +BEGIN + -- read an issuer information + DECLARE @ContractID nvarchar(50); + SELECT + @ContractID = [ContractID] FROM [dbo].[ecCustomersPayments] + WHERE + [PaymentID] = @PaymentID; + + SET NOCOUNT ON; + + SELECT + [P].*, [INV].[InvoiceNumber] FROM [dbo].[ecCustomersPayments] AS [P] + LEFT OUTER JOIN + [dbo].[ecInvoice] AS [INV] ON [INV].[InvoiceID] = [P].[InvoiceID] + WHERE + [P].[PaymentID] = @PaymentID AND [P].[ContractID] = @ContractID; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecGetCustomerService] + @ActorID int, + @ServiceID int +AS +BEGIN + DECLARE @IssuerID int, @ContractID nvarchar(50); + SELECT + @ContractID = [ContractID] FROM [dbo].[ecService] + WHERE + [ServiceID] = @ServiceID; + SELECT + @IssuerID = ISNULL([CustomerID],[ResellerID]) FROM [dbo].[ecContracts] + WHERE + [ContractID] = @ContractID; + -- check actor user rights + IF [dbo].[CheckUserParent](@ActorID, @IssuerID) = 0 + BEGIN + RAISERROR('You are not allowed to access this information', 16, 1); + RETURN; + END + + SELECT * FROM [dbo].[ecService] WHERE [ServiceID] = @ServiceID; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecGetCustomersInvoicesCount] + @ActorID int, + @UserID int, + @IsReseller bit, + @Result int OUTPUT +AS +BEGIN + + -- check user parent + IF [dbo].[CheckUserParent](@ActorID, @UserID) = 0 + BEGIN + RAISERROR('You are not allowed to access this information', 16, 1); + RETURN; + END + + SET NOCOUNT ON; + + IF @IsReseller = 1 + BEGIN + SELECT + @Result = COUNT([InvoiceID]) FROM [dbo].[ContractsInvoicesDetailed] + WHERE + [ResellerID] = @UserID; + RETURN; + END + + SELECT + @Result = COUNT([InvoiceID]) FROM [dbo].[ContractsInvoicesDetailed] + WHERE + [CustomerID] = @UserID; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecGetCustomersInvoicesPaged] + @ActorID int, + @UserID int, + @IsReseller bit, + @MaximumRows int, + @StartRowIndex int +AS +BEGIN + -- check actor rights + IF [dbo].[CheckUserParent](@ActorID, @UserID) = 0 + BEGIN + RAISERROR('You are not allowed to access this information', 16, 1); + RETURN; + END + + SET NOCOUNT ON; + + DECLARE @EndIndex int; + + SET @EndIndex = @MaximumRows + @StartRowIndex; + SET @StartRowIndex = @StartRowIndex + 1; + + IF @IsReseller = 1 + BEGIN + -- get reseller invoices + WITH [INVOICES] AS ( + SELECT + ROW_NUMBER() OVER(ORDER BY [Created] DESC) AS [RowIndex], * FROM [dbo].[ContractsInvoicesDetailed] + WHERE + [ResellerID] = @UserID + ) + + SELECT * FROM [INVOICES] + WHERE [RowIndex] BETWEEN @StartRowIndex AND @EndIndex + ORDER BY [Created] DESC; + + RETURN; + END; + + -- get customer invoices + WITH [INVOICES] AS ( + SELECT + ROW_NUMBER() OVER(ORDER BY [Created] DESC) AS [RowIndex], * FROM [dbo].[ContractsInvoicesDetailed] + WHERE + [CustomerID] = @UserID + ) + + SELECT * FROM [INVOICES] + WHERE [RowIndex] BETWEEN @StartRowIndex AND @EndIndex + ORDER BY [Created] DESC; + + RETURN; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecGetCustomersPaymentsCount] + @ActorID int, + @UserID int, + @IsReseller bit, + @Result int OUTPUT +AS +BEGIN + -- check actor user rights + IF [dbo].[CheckUserParent](@ActorID, @UserID) = 0 + BEGIN + RAISERROR('You are not allowed to access this information', 16, 1); + RETURN; + END + -- SET NOCOUNT ON added to prevent extra result sets from + -- interfering with SELECT statements. + SET NOCOUNT ON; + + IF @IsReseller = 1 + BEGIN + SELECT + @Result = COUNT([CP].[PaymentID]) FROM [dbo].[ecCustomersPayments] AS [CP] + INNER JOIN + [dbo].[ecContracts] AS [C] ON [C].[ContractID] = [CP].[ContractID] + WHERE + [C].[ResellerID] = @UserID; + RETURN; + END + + SELECT + @Result = COUNT([CP].[PaymentID]) FROM [dbo].[ecCustomersPayments] AS [CP] + INNER JOIN + [dbo].[ecContracts] AS [C] ON [C].[ContractID] = [CP].[ContractID] + WHERE + [C].[CustomerID] = @UserID; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecGetCustomersPaymentsPaged] + @ActorID int, + @UserID int, + @IsReseller bit, + @MaximumRows int, + @StartRowIndex int +AS +BEGIN + -- check actor user rights + IF [dbo].[CheckUserParent](@ActorID, @UserID) = 0 + BEGIN + RAISERROR('You are not allowed to access this information', 16, 1); + RETURN; + END + -- SET NOCOUNT ON added to prevent extra result sets from + -- interfering with SELECT statements. + SET NOCOUNT ON; + + DECLARE @EndIndex int; + + SET @EndIndex = @MaximumRows + @StartRowIndex; + SET @StartRowIndex = @StartRowIndex + 1; + + IF @IsReseller = 1 + BEGIN + WITH [PAYMENTS] AS ( + SELECT + ROW_NUMBER() OVER(ORDER BY [CP].[Created] DESC) AS [RowIndex], [CP].* FROM [dbo].[ecCustomersPayments] AS [CP] + INNER JOIN + [dbo].[ecContracts] AS [C] ON [C].[ContractID] = [CP].[ContractID] + WHERE + [C].[ResellerID] = @UserID + ) + + SELECT + [P].*, [INV].[InvoiceNumber], [SP].[DisplayName] AS [ProviderName] FROM [PAYMENTS] AS [P] + LEFT OUTER JOIN + [dbo].[ecSupportedPlugins] AS [SP] ON [SP].[PluginID] = [P].[PluginID] + LEFT OUTER JOIN + [dbo].[ecInvoice] AS [INV] ON [INV].[InvoiceID] = [P].[InvoiceID] + WHERE + [RowIndex] BETWEEN @StartRowIndex AND @EndIndex + ORDER BY + [Created] DESC; + + RETURN; + END; + + WITH [PAYMENTS] AS ( + SELECT + ROW_NUMBER() OVER(ORDER BY [CP].[Created] DESC) AS [RowIndex], [CP].* FROM [dbo].[ecCustomersPayments] AS [CP] + INNER JOIN + [dbo].[ecContracts] AS [C] ON [C].[ContractID] = [CP].[ContractID] + WHERE + [C].[CustomerID] = @UserID + ) + + SELECT + [P].*, [INV].[InvoiceNumber], [SP].[DisplayName] AS [ProviderName] FROM [PAYMENTS] AS [P] + LEFT OUTER JOIN + [dbo].[ecSupportedPlugins] AS [SP] ON [SP].[PluginID] = [P].[PluginID] + LEFT OUTER JOIN + [dbo].[ecInvoice] AS [INV] ON [INV].[InvoiceID] = [P].[InvoiceID] + WHERE + [RowIndex] BETWEEN @StartRowIndex AND @EndIndex + ORDER BY + [Created] DESC; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecGetCustomersServicesCount] + @ActorID int, + @UserID int, + @IsReseller bit, + @Result int OUTPUT +AS +BEGIN + -- check user parent + IF [dbo].[CheckUserParent](@ActorID, @UserID) = 0 + BEGIN + RAISERROR('You are not allowed to access this information', 16, 1); + RETURN; + END + + SET NOCOUNT ON; + + IF @IsReseller = 1 + BEGIN + SELECT + @Result = COUNT([ServiceID]) FROM [dbo].[ContractsServicesDetailed] + WHERE + [ResellerID] = @UserID; + RETURN; + END + + SELECT + @Result = COUNT([ServiceID]) FROM [dbo].[ContractsServicesDetailed] + WHERE + [CustomerID] = @UserID; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecGetCustomersServicesPaged] + @ActorID int, + @UserID int, + @IsReseller bit, + @MaximumRows int, + @StartRowIndex int +AS +BEGIN + -- check user parent + IF [dbo].[CheckUserParent](@ActorID, @UserID) = 0 + BEGIN + RAISERROR('You are not allowed to access this information', 16, 1); + RETURN; + END + + SET NOCOUNT ON; + + DECLARE @EndIndex int; + + SET @EndIndex = @MaximumRows + @StartRowIndex; + SET @StartRowIndex = @StartRowIndex + 1; + + IF @IsReseller = 1 + BEGIN + WITH [SERVICES] AS ( + SELECT + ROW_NUMBER() OVER(ORDER BY [Created] DESC) AS [RowIndex], * FROM [dbo].[ContractsServicesDetailed] + WHERE + [ResellerID] = @UserID + ) + + SELECT + * FROM [SERVICES] + WHERE + [RowIndex] BETWEEN @StartRowIndex AND @EndIndex ORDER BY [Created] DESC; + -- exit + RETURN; + END; + + WITH [SERVICES] AS ( + SELECT + ROW_NUMBER() OVER(ORDER BY [Created] DESC) AS [RowIndex], * FROM [dbo].[ContractsServicesDetailed] + WHERE + [CustomerID] = @UserID + ) + + SELECT + * FROM [SERVICES] + WHERE + [RowIndex] BETWEEN @StartRowIndex AND @EndIndex ORDER BY [Created] DESC; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecGetCustomerTaxation] + @ContractID nvarchar(50), + @Country nvarchar(50), + @State nvarchar(50) +AS +BEGIN + DECLARE @ResellerID int; + SELECT + @ResellerID = [ResellerID] FROM [dbo].[ecContracts] + WHERE + [ContractID] = @ContractID; + -- SET NOCOUNT ON added to prevent extra result sets from + -- interfering with SELECT statements. + SET NOCOUNT ON; + -- + SELECT TOP 1 + ROW_NUMBER() OVER (ORDER BY [TypeId] DESC, [State] ASC), + * + FROM + [dbo].[ecTaxations] + WHERE + [ResellerID] = @ResellerID + AND + ([Country] = @Country OR [Country] = '*') + AND + ([State] = @State OR [State] = '*') + AND + [Active] = 1; + +END + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecGetDomainNameSvc] + @ActorID int, + @ServiceID int +AS +BEGIN + DECLARE @IssuerID int, @ContractID nvarchar(50); + SELECT + @ContractID = [ContractID] FROM [dbo].[ecService] + WHERE + [ServiceID] = @ServiceID; + SELECT + @IssuerID = ISNULL([CustomerID],[ResellerID]) FROM [dbo].[ecContracts] + WHERE + [ContractID] = @ContractID; + -- check actor user rights + IF [dbo].[CheckUserParent](@ActorID, @IssuerID) = 0 + BEGIN + RAISERROR('You are not allowed to access this information', 16, 1); + RETURN; + END + + -- SET NOCOUNT ON added to prevent extra result sets from + -- interfering with SELECT statements. + SET NOCOUNT ON; + + SELECT + [SVC].*, + [DMSVC].[ProductID], + [DMSVC].[DomainID], + [DMSVC].[PluginID], + [DMSVC].[FQDN], + [DMSVC].[PropertyNames], + [DMSVC].[PropertyValues], + [DMSVC].[SvcCycleID], + [SPS].[DisplayName] AS [ProviderName], + [DMSC].[CycleName], + [DMSC].[BillingPeriod], + [DMSC].[PeriodLength], + [DMSC].[SetupFee], + [DMSC].[RecurringFee], + [DMSC].[Currency] + FROM + [dbo].[ecService] AS [SVC] + INNER JOIN + [dbo].[ecDomainSvcs] AS [DMSVC] + ON + [DMSVC].[ServiceID] = [SVC].[ServiceID] + LEFT JOIN + [dbo].[ecSupportedPlugins] AS [SPS] + ON + [SPS].[PluginID] = [DMSVC].[PluginID] + LEFT JOIN + [dbo].[ecDomainSvcsCycles] AS [DMSC] + ON + [DMSC].[SvcCycleID] = [DMSVC].[SvcCycleID] + WHERE + [SVC].[ServiceID] = @ServiceID; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecGetDomainNameSvcHistory] + @ActorID int, + @ServiceID int +AS +BEGIN + DECLARE @IssuerID int, @ContractID nvarchar(50); + SELECT + @ContractID = [ContractID] FROM [dbo].[ecService] + WHERE + [ServiceID] = @ServiceID; + SELECT + @IssuerID = ISNULL([CustomerID],[ResellerID]) FROM [dbo].[ecContracts] + WHERE + [ContractID] = @ContractID; + -- check actor user rights + IF [dbo].[CheckUserParent](@ActorID, @IssuerID) = 0 + BEGIN + RAISERROR('You are not allowed to access this information', 16, 1); + RETURN; + END + -- SET NOCOUNT ON added to prevent extra result sets from + -- interfering with SELECT statements. + SET NOCOUNT ON; + + SELECT + [DNC].[CycleName], + [DNC].[BillingPeriod], + [DNC].[PeriodLength], + [DNC].[SetupFee], + [DNC].[RecurringFee], + [DNC].[Currency], + [SUL].[StartDate], + [SUL].[EndDate] + FROM + [dbo].[ecDomainSvcsCycles] AS [DNC] + INNER JOIN + [dbo].[ecSvcsUsageLog] AS [SUL] + ON + [SUL].[ServiceID] = [DNC].[ServiceID] + AND + [SUL].[SvcCycleID] = [DNC].[SvcCycleID] + WHERE + [DNC].[ServiceID] = @ServiceID; +END + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecGetHostingAddon] + @UserID int, + @ProductID int +AS +BEGIN + + SELECT + [P].*, + [HA].*, + [HA].[2COID] AS [TCOID] + FROM + [dbo].[ecHostingAddons] AS [HA] + INNER JOIN + [dbo].[ecProduct] AS [P] + ON + [P].[ProductID] = [HA].[ProductID] + WHERE + [HA].[ResellerID] = @UserID + AND + [HA].[ProductID] = @ProductID; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecGetHostingAddonCycles] + @UserID int, + @ProductID int +AS +BEGIN + + SELECT + [BC].*, [HAC].[ProductID], [HAC].[SetupFee], [HAC].[RecurringFee] FROM [dbo].[ecHostingAddonsCycles] AS [HAC] + INNER JOIN + [dbo].[ecBillingCycles] AS [BC] ON [BC].[CycleID] = [HAC].[CycleID] + INNER JOIN + [dbo].[ecProduct] AS [PR] ON [HAC].[ProductID] = [PR].[ProductID] + WHERE + [PR].[ResellerID] = @UserID AND [HAC].[ProductID] = @ProductID + ORDER BY + [HAC].[SortOrder]; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecGetHostingAddonsTaken] + @ActorID int, + @UserID int +AS +BEGIN + -- check actor user rights + IF [dbo].[CheckUserParent](@ActorID, @UserID) = 0 + BEGIN + RAISERROR('You are not allowed to access this account', 16, 1); + RETURN; + END + + SELECT [PlanID] FROM [dbo].[ecHostingAddons] WHERE [ResellerID] = @UserID; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecGetHostingAddonSvc] + @ActorID int, + @ServiceID int +AS +BEGIN + DECLARE @IssuerID int, @ContractID nvarchar(50); + SELECT + @ContractID = [ContractID] FROM [dbo].[ecService] + WHERE + [ServiceID] = @ServiceID; + SELECT + @IssuerID = ISNULL([CustomerID],[ResellerID]) FROM [dbo].[ecContracts] + WHERE + [ContractID] = @ContractID; + -- check actor user rights + IF [dbo].[CheckUserParent](@ActorID, @IssuerID) = 0 + BEGIN + RAISERROR('You are not allowed to access this information', 16, 1); + RETURN; + END + -- SET NOCOUNT ON added to prevent extra result sets from + -- interfering with SELECT statements. + SET NOCOUNT ON; + + SELECT + [SVC].*, + [HASVC].*, + [HASC].[CycleName], + [HASC].[BillingPeriod], + [HASC].[PeriodLength], + [HASC].[SetupFee], + [HASC].[CyclePrice], + [HASC].[Currency] + FROM + [dbo].[ecService] AS [SVC] + INNER JOIN + [dbo].[ecHostingAddonSvcs] AS [HASVC] + ON + [HASVC].[ServiceID] = [SVC].[ServiceID] + INNER JOIN + [dbo].[ecHostingAddonSvcsCycles] AS [HASC] + ON + [HASC].[SvcCycleID] = [HASVC].[SvcCycleID] + WHERE + [SVC].[ServiceID] = @ServiceID; +END + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecGetHostingAddonSvcHistory] + @ActorID int, + @ServiceID int +AS +BEGIN + DECLARE @IssuerID int, @ContractID nvarchar(50); + SELECT + @ContractID = [ContractID] FROM [dbo].[ecService] + WHERE + [ServiceID] = @ServiceID; + SELECT + @IssuerID = ISNULL([CustomerID],[ResellerID]) FROM [dbo].[ecContracts] + WHERE + [ContractID] = @ContractID; + -- check actor user rights + IF [dbo].[CheckUserParent](@ActorID, @IssuerID) = 0 + BEGIN + RAISERROR('You are not allowed to access this information', 16, 1); + RETURN; + END + -- SET NOCOUNT ON added to prevent extra result sets from + -- interfering with SELECT statements. + SET NOCOUNT ON; + + SELECT + [HAC].[CycleName], + [HAC].[BillingPeriod], + [HAC].[PeriodLength], + [HAC].[SetupFee], + [HAC].[CyclePrice] AS [RecurringFee], + [HAC].[Currency], + [SUL].[StartDate], + [SUL].[EndDate] + FROM + [dbo].[ecHostingAddonSvcsCycles] AS [HAC] + INNER JOIN + [dbo].[ecSvcsUsageLog] AS [SUL] + ON + [SUL].[ServiceID] = [HAC].[ServiceID] + AND + [SUL].[SvcCycleID] = [HAC].[SvcCycleID] + WHERE + [HAC].[ServiceID] = @ServiceID; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecGetHostingPackageSvc] + @ActorID int, + @ServiceID int +AS +BEGIN + DECLARE @IssuerID int, @ContractID nvarchar(50); + SELECT + @ContractID = [ContractID] FROM [dbo].[ecService] + WHERE + [ServiceID] = @ServiceID; + SELECT + @IssuerID = ISNULL([CustomerID],[ResellerID]) FROM [dbo].[ecContracts] + WHERE + [ContractID] = @ContractID; + -- check actor user rights + IF [dbo].[CheckUserParent](@ActorID, @IssuerID) = 0 + BEGIN + RAISERROR('You are not allowed to access this information', 16, 1); + RETURN; + END + + -- + SET NOCOUNT ON; + + SELECT + [SVC].*, + [HPSVC].[ProductID], + [HPSVC].[PlanID], + [HPSVC].[PackageID], + [HPSVC].[UserRole], + [HPSVC].[InitialStatus], + [HPSVC].[SvcCycleID], + [HPSC].[CycleName], + [HPSC].[BillingPeriod], + [HPSC].[PeriodLength], + [HPSC].[SetupFee], + [HPSC].[RecurringFee], + [HPSC].[Currency] + FROM + [dbo].[ecService] AS [SVC] + INNER JOIN + [dbo].[ecHostingPackageSvcs] AS [HPSVC] + ON + [HPSVC].[ServiceID] = [SVC].[ServiceID] + INNER JOIN + [dbo].[ecHostingPackageSvcsCycles] AS [HPSC] + ON + [HPSC].[SvcCycleID] = [HPSVC].[SvcCycleID] + WHERE + [SVC].[ServiceID] = @ServiceID; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecGetHostingPackageSvcHistory] + @ActorID int, + @ServiceID int +AS +BEGIN + DECLARE @IssuerID int, @ContractID nvarchar(50); + SELECT + @ContractID = [ContractID] FROM [dbo].[ecService] + WHERE + [ServiceID] = @ServiceID; + SELECT + @IssuerID = ISNULL([CustomerID],[ResellerID]) FROM [dbo].[ecContracts] + WHERE + [ContractID] = @ContractID; + -- check actor user rights + IF [dbo].[CheckUserParent](@ActorID, @IssuerID) = 0 + BEGIN + RAISERROR('You are not allowed to access this information', 16, 1); + RETURN; + END + -- SET NOCOUNT ON added to prevent extra result sets from + -- interfering with SELECT statements. + SET NOCOUNT ON; + + SELECT + [HPC].[CycleName], + [HPC].[BillingPeriod], + [HPC].[PeriodLength], + [HPC].[SetupFee], + [HPC].[RecurringFee], + [HPC].[Currency], + [SUL].[StartDate], + [SUL].[EndDate] + FROM + [dbo].[ecHostingPackageSvcsCycles] AS [HPC] + INNER JOIN + [dbo].[ecSvcsUsageLog] AS [SUL] + ON + [SUL].[ServiceID] = [HPC].[ServiceID] + AND + [SUL].[SvcCycleID] = [HPC].[SvcCycleID] + WHERE + [HPC].[ServiceID] = @ServiceID; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecGetHostingPlan] + @UserID int, + @ProductID int +AS +BEGIN + + SELECT + [PR].*, + [HP].[PlanID], + [HP].[UserRole], + [HP].[InitialStatus], + [HP].[DomainOption] + FROM + [dbo].[ecHostingPlans] AS [HP] + INNER JOIN + [dbo].[ecProduct] AS [PR] + ON + [PR].[ProductID] = [HP].[ProductID] + WHERE + [HP].[ResellerID] = @UserID + AND + [HP].[ProductID] = @ProductID; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecGetHostingPlanCycles] + @UserID int, + @ProductID int +AS +BEGIN + + SELECT + [BC].*, [HPC].[ProductID], [HPC].[SetupFee], [HPC].[RecurringFee] FROM [dbo].[ecHostingPlansBillingCycles] AS [HPC] + INNER JOIN + [dbo].[ecBillingCycles] AS [BC] ON [BC].[CycleID] = [HPC].[CycleID] + INNER JOIN + [dbo].[ecProduct] AS [PR] ON [HPC].[ProductID] = [PR].[ProductID] + WHERE + [PR].[ResellerID] = @UserID AND [HPC].[ProductID] = @ProductID + ORDER BY + [HPC].[SortOrder]; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecGetHostingPlansTaken] + @ActorID int, + @UserID int +AS +BEGIN + -- check actor user rights + IF [dbo].[CheckUserParent](@ActorID, @UserID) = 0 + BEGIN + RAISERROR('You are not allowed to access this account', 16, 1); + RETURN; + END + + SELECT [PlanID] FROM [dbo].[ecHostingPlans] WHERE [ResellerID] = @UserID; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecGetInvoicesItemsOverdue] + @ActorID int, + @ResellerID int, + @DateOverdue datetime +AS +BEGIN + -- check user parent + IF [dbo].[CheckUserParent](@ActorID, @ResellerID) = 0 + BEGIN + RAISERROR('You are not allowed to access this information', 16, 1); + RETURN; + END + -- SET NOCOUNT ON added to prevent extra result sets from + -- interfering with SELECT statements. + SET NOCOUNT ON; + + -- lookup for paid invoices + WITH [OVERDUE_INVOICES] ([InvoiceID]) AS + ( + SELECT + [I].[InvoiceID] + FROM + [dbo].[ecInvoice] AS [I] + INNER JOIN + [dbo].[ecContracts] AS [C] ON [C].[ContractID] = [I].[ContractID] + WHERE + [C].[ResellerID] = @ResellerID + AND + DATEDIFF(second, [DueDate], @DateOverdue) >= 0 + EXCEPT + SELECT + [InvoiceID] + FROM + [dbo].[ecCustomersPayments] AS [CP] + INNER JOIN + [dbo].[ecContracts] AS [C] ON [C].[ContractID] = [CP].[ContractID] + WHERE + [C].[ResellerID] = @ResellerID + AND + [CP].[StatusID] = 1 -- Approved payments only + ) + SELECT * FROM [dbo].[ecInvoiceItems] + WHERE [ServiceID] IS NOT NULL + AND [InvoiceID] IN ( + SELECT [InvoiceID] FROM [OVERDUE_INVOICES] + ); + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecGetInvoicesItemsToActivate] + @ActorID int, + @ResellerID int +AS +BEGIN + + IF [dbo].[CheckUserParent](@ActorID, @ResellerID) = 0 + BEGIN + RAISERROR('You are not allowed to access this information', 16, 1); + RETURN; + END + + SET NOCOUNT ON; + + -- lookup for paid invoices + WITH [PAID_INVOICES] ([InvoiceID]) AS + ( + SELECT + [InvoiceID] FROM [dbo].[ecCustomersPayments] AS [CP] + INNER JOIN + [dbo].[ecContracts] AS [C] ON [C].[ContractID] = [CP].[ContractID] + WHERE + [C].[ResellerID] = @ResellerID AND [StatusID] = 1 -- Approved Payments Only + ) + SELECT + * FROM [dbo].[ecInvoiceItems] + WHERE + [ServiceID] IS NOT NULL AND [Processed] = 0 AND [InvoiceID] IN (SELECT [InvoiceID] FROM [PAID_INVOICES]); + + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecGetPaymentMethod] + @ActorID int, + @UserID int, + @MethodName nvarchar(50) +AS +BEGIN + -- check actor user rights + IF [dbo].[CheckUserParent](@ActorID, @UserID) = 0 + BEGIN + RAISERROR('You are not allowed to access this account', 16, 1); + RETURN; + END + -- SET NOCOUNT ON added to prevent extra result sets from + -- interfering with SELECT statements. + SET NOCOUNT ON; + + SELECT * FROM [dbo].[ecPaymentMethods] + WHERE [MethodName] = @MethodName AND [ResellerID] = @UserID; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecGetPaymentProfile] + @ActorID int, + @ContractID nvarchar(50) +AS +BEGIN + DECLARE @IssuerID int; + SELECT + @IssuerID = ISNULL([CustomerID],[ResellerID]) FROM [dbo].[ecContracts] + WHERE + [ContractID] = @ContractID; + -- check actor user rights + IF [dbo].[CheckUserParent](@ActorID, @IssuerID) = 0 + BEGIN + RAISERROR('You are not allowed to access this account', 16, 1); + RETURN; + END + -- SET NOCOUNT ON added to prevent extra result sets from + -- interfering with SELECT statements. + SET NOCOUNT ON; + -- + SELECT * FROM [dbo].[ecPaymentProfiles] WHERE [ContractID] = @ContractID; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecGetPluginProperties] + @ActorID int, + @UserID int, + @PluginID int +AS +BEGIN + -- check actor user rights + IF [dbo].[CheckUserParent](@ActorID, @UserID) = 0 + BEGIN + RAISERROR('You are not allowed to access this account', 16, 1); + RETURN; + END + + SET NOCOUNT ON; + + SELECT [PropertyName], [PropertyValue] FROM [dbo].[ecPluginsProperties] + WHERE [PluginID] = @PluginID AND [ResellerID] = @UserID; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecGetProductCategories] + @UserID int, + @ProductID int +AS +BEGIN + + SELECT + [C].* + FROM + [dbo].[ecCategories] AS [C] + INNER JOIN + [dbo].[ecProductCategories] AS [PC] + ON + [C].[CategoryID] = [PC].[CategoryID] + WHERE + [PC].[ProductID] = @ProductID + AND + [PC].[ResellerID] = @UserID; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecGetProductCategoriesIds] + @UserID int, + @ProductID int +AS +BEGIN + + SELECT [CategoryID] FROM [dbo].[ecProductCategories] WHERE [ResellerID] = @UserID AND [ProductID] = @ProductID; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecGetProductHighlights] + @ResellerID int, + @ProductID int +AS +BEGIN + + SELECT + [PH].[HighlightText] + FROM + [dbo].[ecProductsHighlights] AS [PH] + INNER JOIN + [dbo].[ecProduct] AS [P] + ON + [PH].[ProductID] = [P].[ProductID] + WHERE + [P].[ProductID] = @ProductID + AND + [P].[ResellerID] = @ResellerID + ORDER BY + [SortOrder]; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecGetProductsByType] + @UserID int, + @TypeID int +AS +BEGIN + + SELECT * FROM [dbo].[ecProduct] WHERE [ResellerID] = @UserID AND [TypeID] = @TypeID ORDER BY [ProductName]; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecGetProductsCountByType] + @ActorID int, + @UserID int, + @TypeID int, + @Count int OUTPUT +AS +BEGIN + -- check actor user rights + IF [dbo].[CheckUserParent](@ActorID, @UserID) = 0 + BEGIN + RAISERROR('You are not allowed to access this account', 16, 1); + RETURN; + END + + SELECT @Count = COUNT(*) FROM [dbo].[ecProduct] WHERE [TypeID] = @TypeID AND [ResellerID] = @UserID; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecGetProductsPagedByType] + @ActorID int, + @UserID int, + @TypeID int, + @MaximumRows int, + @StartRowIndex int +AS +BEGIN + -- check actor user rights + IF [dbo].[CheckUserParent](@ActorID, @UserID) = 0 + BEGIN + RAISERROR('You are not allowed to access this account', 16, 1); + RETURN; + END + + DECLARE @EndIndex int; + + SET @EndIndex = @MaximumRows + @StartRowIndex; + SET @StartRowIndex = @StartRowIndex + 1; + + WITH [ProductsCTE] AS ( + SELECT + ROW_NUMBER() OVER(ORDER BY [Created] DESC) AS [RowIndex], + * + FROM + [dbo].[ecProduct] + WHERE + [ResellerID] = @UserID + AND + [TypeID] = @TypeID + ) + + SELECT * FROM [ProductsCTE] WHERE [RowIndex] BETWEEN @StartRowIndex AND @EndIndex; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecGetProductType] + @TypeID int +AS +BEGIN + + SELECT * FROM [dbo].[ecProductType] WHERE [TypeID] = @TypeID; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecGetProductTypeControl] + @TypeID int, + @ControlKey nvarchar(50), + @ControlSrc nvarchar(512) OUTPUT +AS +BEGIN + + SET NOCOUNT ON; + + SELECT + @ControlSrc = [ControlSrc] + FROM + [dbo].[ecProductTypeControls] + WHERE + [TypeID] = @TypeID + AND + [ControlKey] = @ControlKey; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecGetResellerPaymentMethod] + @ResellerID int, + @MethodName nvarchar(50) +AS +BEGIN + -- SET NOCOUNT ON added to prevent extra result sets from + -- interfering with SELECT statements. + SET NOCOUNT ON; + + SELECT + [PM].[ResellerID], + [PM].[MethodName], + [PM].[DisplayName], + [PM].[SupportedItems], + [SP].[Interactive] + FROM + [dbo].[ecPaymentMethods] AS [PM] + INNER JOIN + [dbo].[ecSupportedPlugins] AS [SP] + ON + [SP].[PluginID] = [PM].[PluginID] + WHERE + [PM].[ResellerID] = @ResellerID + AND + [PM].[MethodName] = @MethodName; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecGetResellerPaymentMethods] + @ResellerID int +AS +BEGIN + + SELECT * FROM [dbo].[ecPaymentMethods] + WHERE [ResellerID] = @ResellerID; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecGetResellerPMPlugin] + @ResellerID int, + @MethodName nvarchar(50) +AS +BEGIN + -- SET NOCOUNT ON added to prevent extra result sets from + -- interfering with SELECT statements. + SET NOCOUNT ON; + + SELECT + [SP].* + FROM + [dbo].[ecPaymentMethods] AS [PM] + INNER JOIN + [dbo].[ecSupportedPlugins] AS [SP] + ON + [SP].[PluginID] = [PM].[PluginID] + WHERE + [PM].[MethodName] = @MethodName + AND + [PM].[ResellerID] = @ResellerID; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecGetResellerTopLevelDomain] + @ResellerID int, + @TLD nvarchar(10) +AS +BEGIN + -- SET NOCOUNT ON added to prevent extra result sets from + -- interfering with SELECT statements. + SET NOCOUNT ON; + + SELECT + [P].*, + [Tlds].[PluginID], + [Tlds].[WhoisEnabled] + FROM + [dbo].[ecProduct] AS [P] + INNER JOIN + [dbo].[ecTopLevelDomains] AS [Tlds] + ON + [Tlds].[ProductID] = [P].[ProductID] + WHERE + [P].[ResellerID] = @ResellerID + AND + [Tlds].[TopLevelDomain] = @TLD; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecGetServiceHandlersResponsesByReseller] + @ResellerID int +AS +BEGIN + -- SET NOCOUNT ON added to prevent extra result sets from + -- interfering with SELECT statements. + SET NOCOUNT ON; + + SELECT + * FROM [ServiceHandlersResponsesDetailed] + WHERE + [ResellerID] = @ResellerID AND [ErrorMessage] IS NULL +END + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecGetServiceItemType] + @ServiceID int +AS +BEGIN + + SELECT + [PT].* FROM [dbo].[ecProductType] AS [PT] + INNER JOIN + [dbo].[ecService] AS [S] ON [PT].[TypeID] = [S].[TypeID] + WHERE + [S].[ServiceID] = @ServiceID; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecGetServicesToInvoice] + @ActorID int, + @ResellerID int, + @TodayDate datetime, + @DaysOffset int +AS +BEGIN + -- check actor user rights + IF [dbo].[CheckUserParent](@ActorID, @ResellerID) = 0 + BEGIN + RAISERROR('You are not allowed to access this information', 16, 1); + RETURN; + END + + SET NOCOUNT ON; + + DECLARE @Svcs TABLE( + [ServiceID] int NOT NULL, + [MaxStartDate] datetime NOT NULL, + [MaxEndDate] datetime NOT NULL + ); + + -- filter service that don't have corresponding unpaid invoice and expired + INSERT INTO + @Svcs ([ServiceID], [MaxStartDate], [MaxEndDate]) + SELECT + [SUL].[ServiceID], MAX([SUL].[StartDate]), MAX([SUL].[EndDate]) FROM [dbo].[ecSvcsUsageLog] AS [SUL] + INNER JOIN + [dbo].[ecService] AS [S] ON [SUL].[ServiceID] = [S].[ServiceID] + INNER JOIN + [dbo].[ecContracts] AS [C] ON [C].[ContractID] = [S].[ContractID] + WHERE + [C].[ResellerID] = @ResellerID + AND + ISNULL([SUL].[PeriodClosed], 0) = 0 + GROUP BY + [SUL].[ServiceID]; + + SELECT + [S].* FROM [dbo].[ecService] AS [S] + INNER JOIN + @Svcs AS [SVCS] ON [S].[ServiceID] = [SVCS].[ServiceID] + WHERE + [S].[Status] = 1 AND @DaysOffset >= DATEDIFF(d, @TodayDate, [SVCS].[MaxEndDate]) + ORDER BY + [ContractID]; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecGetServiceSuspendDate] + @ActorID int, + @ServiceID int, + @SuspendDate datetime OUTPUT +AS +BEGIN + DECLARE @IssuerID int, @ContractID nvarchar(50); + SELECT + @ContractID = [ContractID] FROM [dbo].[ecService] + WHERE + [ServiceID] = @ServiceID; + SELECT + @IssuerID = [ResellerID] FROM [dbo].[ecContracts] + WHERE + [ContractID] = @ContractID; + -- check actor rights + IF [dbo].[CheckUserParent](@ActorID, @IssuerID) = 0 + BEGIN + RAISERROR('You are not allowed to access this information', 16, 1); + RETURN; + END + + SET NOCOUNT ON; + + SELECT @SuspendDate = ISNULL(MAX([EndDate]), GETDATE()) FROM [dbo].[ecSvcsUsageLog] + WHERE [ServiceID] = @ServiceID; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecGetStoreDefaultSettings] + @SettingsName nvarchar(50) +AS +BEGIN + -- SET NOCOUNT ON added to prevent extra result sets from + -- interfering with SELECT statements. + SET NOCOUNT ON; + + SELECT * FROM [dbo].[ecStoreDefaultSettings] + WHERE [SettingsName] = @SettingsName; +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecGetStorefrontCategories] + @ResellerID int, + @ParentID int +AS +BEGIN + + SET NOCOUNT ON; + + IF @ParentID < 1 OR @ParentID IS NULL + SET @ParentID = 0; + + SELECT + * + FROM + [dbo].[ecCategory] + WHERE + [ResellerID] = @ResellerID + AND + ISNULL([ParentID], 0) = @ParentID + ORDER BY + [ItemOrder] ASC; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecGetStorefrontCategory] + @ResellerID int, + @CategoryID int +AS +BEGIN + + SET NOCOUNT ON; + + SELECT + * + FROM + [dbo].[ecCategory] + WHERE + [ResellerID] = @ResellerID + AND + [CategoryID] = @CategoryID; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecGetStorefrontHostingPlanAddons] + @ResellerID int, + @PlanID int +AS +BEGIN + -- SET NOCOUNT ON added to prevent extra result sets from + -- interfering with SELECT statements. + SET NOCOUNT ON; + + SELECT + [P].*, + [HA].*, + [HA].[2COID] AS [TCOID] + FROM + [dbo].[ecHostingAddons] AS [HA] + INNER JOIN + [dbo].[ecProduct] AS [P] + ON + [P].[ProductID] = [HA].[ProductID] + INNER JOIN + [dbo].[ecAddonProducts] AS [AP] + ON + [P].[ProductID] = [AP].[AddonID] + WHERE + [AP].[ResellerID] = @ResellerID + AND + [P].[Enabled] = 1 + AND + [AP].[ProductID] = @PlanID; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecGetStorefrontPath] + @ResellerID int, + @CategoryID int +AS +BEGIN + + SET NOCOUNT ON; + + WITH [PathCTE] ([CategoryID]) AS ( + SELECT [ParentID] FROM [dbo].[ecCategory] + WHERE [CategoryID] = @CategoryID AND [ResellerID] = @ResellerID + UNION ALL + SELECT [ParentID] FROM [dbo].[ecCategory] AS [C] + INNER JOIN [PathCTE] AS [P] ON [C].[CategoryID] = [P].[CategoryID] + WHERE [ParentID] IS NOT NULL AND [ResellerID] = @ResellerID + ) + + SELECT + [CategoryID], [CategoryName] + FROM + [dbo].[ecCategory] + WHERE + ( + [CategoryID] IN ( + SELECT [CategoryID] FROM [PathCTE] + ) + OR + [CategoryID] = @CategoryID + ) + AND + [ResellerID] = @ResellerID + ORDER BY + [Level]; +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecGetStorefrontProduct] + @ResellerID int, + @ProductID int +AS +BEGIN + + SET NOCOUNT ON; + + SELECT + * + FROM + [dbo].[ecProduct] + WHERE + [ProductID] = @ProductID + AND + [ResellerID] = @ResellerID + AND + [Enabled] = 1; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecGetStorefrontProductsByType] + @UserID int, + @TypeID int +AS +BEGIN + + SELECT + * + FROM + [dbo].[ecProduct] + WHERE + [ResellerID] = @UserID + AND + [TypeID] = @TypeID + AND + [Enabled] = 1 + ORDER BY + [ProductName] ASC; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecGetStorefrontProductsInCategory] + @ResellerID int, + @CategoryID int +AS +BEGIN + -- SET NOCOUNT ON added to prevent extra result sets from + -- interfering with SELECT statements. + SET NOCOUNT ON; + + SELECT + [P].* + FROM + [dbo].[ecProduct] AS [P] + INNER JOIN + [dbo].[ecProductCategories] AS [PC] + ON + [P].[ProductID] = [PC].[ProductID] + WHERE + [PC].[CategoryID] = @CategoryID + AND + [P].[ResellerID] = @ResellerID + AND + [P].[Enabled] = 1; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecGetStoreSettings] + @ResellerID int, + @SettingsName nvarchar(50) +AS +BEGIN + + SET NOCOUNT ON; + + SELECT * FROM [dbo].[ecStoreSettings] + WHERE [SettingsName] = @SettingsName AND [ResellerID] = @ResellerID; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecGetSupportedPlugin] + @PluginName nvarchar(50), + @GroupName nvarchar(50) +AS +BEGIN + + SELECT * FROM [dbo].[ecSupportedPlugins] + WHERE [PluginName] = @PluginName AND [PluginGroup] = @GroupName; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecGetSupportedPluginByID] + @PluginID int +AS +BEGIN + -- SET NOCOUNT ON added to prevent extra result sets from + -- interfering with SELECT statements. + SET NOCOUNT ON; + + SELECT * FROM [dbo].[ecSupportedPlugins] WHERE [PluginID] = @PluginID; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecGetSupportedPluginsByGroup] + @GroupName nvarchar(50) +AS +BEGIN + + SELECT * FROM [dbo].[ecSupportedPlugins] + WHERE [PluginGroup] = @GroupName + ORDER BY [DisplayName]; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecGetSvcsSuspendDateAligned] + @ResellerID int, + @SvcsXml xml, + @DefaultValue datetime, + @Result datetime OUTPUT +AS +BEGIN + -- SET NOCOUNT ON added to prevent extra result sets from + -- interfering with SELECT statements. + SET NOCOUNT ON; + + SELECT + @Result = MAX([SUL].[EndDate]) FROM [dbo].[ecSvcsUsageLog] AS [SUL] + INNER JOIN + [dbo].[ecService] AS [S] ON [SUL].[ServiceID] = [S].[ServiceID] + INNER JOIn + [dbo].[ecContracts] AS [C] ON [C].[ContractID] = [S].[ContractID] + WHERE + [C].[ResellerID] = @ResellerID + AND + [S].[ServiceID] IN (SELECT [SXML].[Data].value('@id','int') FROM @SvcsXml.nodes('/Svcs/Svc') [SXML]([Data])); + + -- result is empty + SET @Result = ISNULL(@Result, @DefaultValue); + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecGetSystemTrigger] + @ActorID int, + @ReferenceID nvarchar(50), + @Namespace nvarchar(255) +AS +BEGIN + -- SET NOCOUNT ON added to prevent extra result sets from + -- interfering with SELECT statements. + SET NOCOUNT ON; + + SELECT + * FROM [dbo].[ecSystemTriggers] + WHERE + [OwnerID] = @ActorID AND [ReferenceID] = @ReferenceID AND [Namespace] = @Namespace; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecGetTaxation] + @ActorID int, + @UserID int, + @TaxationID int +AS +BEGIN + -- + IF [dbo].[CheckUserParent](@ActorID, @UserID) = 0 + BEGIN + RAISERROR('You are not allowed to access this account', 16, 1); + RETURN; + END + -- SET NOCOUNT ON added to prevent extra result sets from + -- interfering with SELECT statements. + SET NOCOUNT ON; + + -- + SELECT * FROM [dbo].[ecTaxations] WHERE [ResellerID] = @UserID AND [TaxationID] = @TaxationID; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecGetTaxationsCount] + @ActorID int, + @UserID int, + @Result int OUTPUT +AS +BEGIN + -- check actor user rights + IF [dbo].[CheckUserParent](@ActorID, @UserID) = 0 + BEGIN + RAISERROR('You are not allowed to access this account', 16, 1); + RETURN; + END + -- SET NOCOUNT ON added to prevent extra result sets from + -- interfering with SELECT statements. + SET NOCOUNT ON; + + SELECT @Result = COUNT([TaxationID]) FROM [dbo].[ecTaxations] WHERE [ResellerID] = @UserID; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecGetTaxationsPaged] + @ActorID int, + @UserID int, + @MaximumRows int, + @StartRowIndex int +AS +BEGIN + -- check actor user rights + IF [dbo].[CheckUserParent](@ActorID, @UserID) = 0 + BEGIN + RAISERROR('You are not allowed to access this account', 16, 1); + RETURN; + END + -- SET NOCOUNT ON added to prevent extra result sets from + -- interfering with SELECT statements. + SET NOCOUNT ON; + -- do some calculations + DECLARE @EndIndex int; + -- + SET @EndIndex = @MaximumRows + @StartRowIndex; + SET @StartRowIndex = @StartRowIndex + 1; + -- + WITH [TaxesCTE] AS ( + SELECT + ROW_NUMBER() OVER(ORDER BY [TaxationID] ASC) AS [RowIndex], + * + FROM + [dbo].[ecTaxations] + WHERE + [ResellerID] = @UserID + ) + -- + SELECT * FROM [TaxesCTE] WHERE [RowIndex] BETWEEN @StartRowIndex AND @EndIndex; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecGetTopLevelDomain] + @ActorID int, + @UserID int, + @ProductID int +AS +BEGIN + -- check actor user rights + IF [dbo].[CheckUserParent](@ActorID, @UserID) = 0 + BEGIN + RAISERROR('You are not allowed to access this account', 16, 1); + RETURN; + END + + SELECT + [P].*, + [Tlds].[PluginID], + [Tlds].[WhoisEnabled], + [PLG].[DisplayName] + FROM + [dbo].[ecProduct] AS [P] + INNER JOIN + [dbo].[ecTopLevelDomains] AS [Tlds] + ON + [Tlds].[ProductID] = [P].[ProductID] + INNER JOIN + [dbo].[ecSupportedPlugins] AS [PLG] + ON + [PLG].[PluginID] = [Tlds].[PluginID] + WHERE + [P].[ResellerID] = @UserID + AND + [P].[ProductID] = @ProductID; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecGetTopLevelDomainCycles] + @UserID int, + @ProductID int +AS +BEGIN + + SELECT + [BC].*, + [TLDC].[ProductID], + [TLDC].[SetupFee], + [TLDC].[RecurringFee], + [TLDC].[TransferFee] + FROM + [dbo].[ecTopLevelDomainsCycles] AS [TLDC] + INNER JOIN + [dbo].[ecBillingCycles] AS [BC] + ON + [BC].[CycleID] = [TLDC].[CycleID] + INNER JOIN + [dbo].[ecProduct] AS [PR] + ON + [TLDC].[ProductID] = [PR].[ProductID] + WHERE + [PR].[ResellerID] = @UserID + AND + [TLDC].[ProductID] = @ProductID + ORDER BY + [TLDC].[SortOrder]; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecGetTopLevelDomainsPaged] + @ActorID int, + @UserID int, + @MaximumRows int, + @StartRowIndex int +AS +BEGIN + + DECLARE @EndIndex int; + + SET @EndIndex = @MaximumRows + @StartRowIndex; + SET @StartRowIndex = @StartRowIndex + 1; + + WITH [TldsCTE] AS ( + SELECT + ROW_NUMBER() OVER(ORDER BY [Created] DESC) AS [RowIndex], + * + FROM + [dbo].[ecProduct] + WHERE + [ResellerID] = @UserID + AND + [TypeID] = 3 -- Top Level Domain + ) + + SELECT + [TldsCTE].*, + [Tlds].[PluginId], + [PLG].[DisplayName] + FROM + [TldsCTE] + INNER JOIN + [dbo].[ecTopLevelDomains] AS [Tlds] + ON + [Tlds].[ProductID] = [TldsCTE].[ProductID] + INNER JOIN + [dbo].[ecSupportedPlugins] AS [PLG] + ON + [PLG].[PluginID] = [Tlds].[PluginID] + WHERE + [TldsCTE].[RowIndex] BETWEEN @StartRowIndex AND @EndIndex; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecGetUnpaidInvoices] + @ActorID int, + @ResellerID int +AS +BEGIN + -- check actor user rights + IF [dbo].[CheckUserParent](@ActorID, @ResellerID) = 0 + BEGIN + RAISERROR('You are not allowed to access this information', 16, 1); + RETURN; + END + -- SET NOCOUNT ON added to prevent extra result sets from + -- interfering with SELECT statements. + SET NOCOUNT ON; + + -- lookup for paid invoices + WITH [UNPAID_INVOICES] ([InvoiceID]) AS + ( + SELECT + [I].[InvoiceID] + FROM + [dbo].[ecInvoice] AS [I] + INNER JOIN + [dbo].[ecContracts] AS [C] ON [C].[ContractID] = [I].[ContractID] + WHERE + [C].[ResellerID] = @ResellerID + EXCEPT + SELECT + [InvoiceID] + FROM + [dbo].[ecCustomersPayments] AS [CP] + INNER JOIN + [dbo].[ecContracts] AS [C] ON [C].[ContractID] = [CP].[ContractID] + WHERE + [C].[ResellerID] = @ResellerID + ) + -- select unpaid invoices + SELECT * FROM [dbo].[ecInvoice] WHERE [InvoiceID] IN ( + SELECT [InvoiceID] FROM [UNPAID_INVOICES] + ); + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecGetWholeCategoriesSet] + @ActorID int, + @UserID int +AS + IF [dbo].[CheckUserParent](@ActorID, @UserID) = 0 + BEGIN + RAISERROR('You are not allowed to access this account', 16, 1); + RETURN; + END + + SELECT * FROM [dbo].[ecCategory] WHERE [ResellerID] = @UserID ORDER BY [CategoryName]; + +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecIsSupportedPluginActive] + @ActorID int, + @ResellerID int, + @PluginID int, + @Active bit OUTPUT +AS +BEGIN + -- check user parent + IF [dbo].[CheckUserParent](@ActorID, @ResellerID) = 0 + BEGIN + RAISERROR('You are not allowed to access this account', 16, 1); + RETURN; + END + -- SET NOCOUNT ON added to prevent extra result sets from + -- interfering with SELECT statements. + SET NOCOUNT ON; + + IF EXISTS(SELECT * FROM [dbo].[ecPluginsProperties] + WHERE [ResellerID] = @ResellerID AND [PluginID] = @PluginID) + BEGIN + SET @Active = 1; + RETURN; + END + + SET @Active = 0; + RETURN; +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecLookupForTransaction] + @TransactionID nvarchar(255) +AS +BEGIN + -- SET NOCOUNT ON added to prevent extra result sets from + -- interfering with SELECT statements. + SET NOCOUNT ON; + + SELECT * FROM [dbo].[ecCustomersPayments] WHERE [TransactionID] = @TransactionID; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecPaymentProfileExists] + @ActorID int, + @ContractID nvarchar(50), + @Result bit OUTPUT +AS +BEGIN + DECLARE @IssuerID int; + SELECT + @IssuerID = ISNULL([CustomerID],[ResellerID]) FROM [dbo].[ecContracts] + WHERE + [ContractID] = @ContractID; + -- check actor user rights + IF [dbo].[CheckUserParent](@ActorID, @IssuerID) = 0 + BEGIN + RAISERROR('You are not allowed to access this account', 16, 1); + RETURN; + END + -- SET NOCOUNT ON added to prevent extra result sets from + -- interfering with SELECT statements. + SET NOCOUNT ON; + + IF EXISTS (SELECT [ContractID] FROM [dbo].[ecPaymentProfiles] WHERE [ContractID] = @ContractID) + BEGIN + SET @Result = 1; + RETURN; + END + -- + SET @Result = 0; +END + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecSetInvoiceItemProcessed] + @InvoiceID int, + @ItemID int, + @Result int OUTPUT +AS +BEGIN + + SET NOCOUNT ON; + + SET @Result = 0; + + UPDATE + [dbo].[ecInvoiceItems] + SET + [Processed] = 1 + WHERE + [InvoiceID] = @InvoiceID + AND + [ItemID] = @ItemID; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecSetPaymentMethod] + @ActorID int, + @UserID int, + @MethodName nvarchar(50), + @DisplayName nvarchar(50), + @PluginID int, + @Result int OUTPUT +AS +BEGIN + -- check actor user rights + IF [dbo].[CheckUserParent](@ActorID, @UserID) = 0 + BEGIN + SET @Result = -1; + RAISERROR('You are not allowed to access this account', 16, 1); + RETURN; + END + -- SET NOCOUNT ON added to prevent extra result sets from + -- interfering with SELECT statements. + SET NOCOUNT ON; + -- cleanup + DELETE FROM [dbo].[ecPaymentMethods] + WHERE [ResellerID] = @UserID AND [MethodName] = @MethodName; + -- add + INSERT INTO [dbo].[ecPaymentMethods] + ( + [ResellerID], + [MethodName], + [PluginID], + [DisplayName], + [SupportedItems] + ) + SELECT + @UserID, + @MethodName, + @PluginID, + @DisplayName, + [SupportedItems] + FROM + [dbo].[ecSupportedPlugins] + WHERE + [PluginID] = @PluginID; + -- + SET @Result = 0; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecSetPaymentProfile] + @ActorID int, + @ContractID nvarchar(50), + @PropertyNames ntext, + @PropertyValues ntext +AS +BEGIN + DECLARE @IssuerID int; + SELECT + @IssuerID = ISNULL([CustomerID],[ResellerID]) FROM [dbo].[ecContracts] + WHERE + [ContractID] = @ContractID; + -- check actor user rights + IF [dbo].[CheckUserParent](@ActorID, @IssuerID) = 0 + BEGIN + RAISERROR('You are not allowed to access this account', 16, 1); + RETURN; + END + -- SET NOCOUNT ON added to prevent extra result sets from + -- interfering with SELECT statements. + SET NOCOUNT ON; + + -- cleanup first + DELETE FROM [dbo].[ecPaymentProfiles] WHERE [ContractID] = @ContractID; + + -- + INSERT INTO [dbo].[ecPaymentProfiles] + ( + [ContractID], + [PropertyNames], + [PropertyValues] + ) + VALUES + ( + @ContractID, + @PropertyNames, + @PropertyValues + ); + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecSetPluginProperties] + @ActorID int, + @UserID int, + @PluginID int, + @Xml ntext, + @Result int OUTPUT +AS +BEGIN + -- check actor user rights + IF [dbo].[CheckUserParent](@ActorID, @UserID) = 0 + BEGIN + SET @Result = -1; + RAISERROR('You are not allowed to access this account', 16, 1); + RETURN; + END + -- SET NOCOUNT ON added to prevent extra result sets from + -- interfering with SELECT statements. + SET NOCOUNT ON; + +/* +XML Format: + + + +*/ + -- result is ok + SET @Result = 0; + -- + DECLARE @XmlDocID int; + --Create an internal representation of the XML document. + EXEC sp_xml_preparedocument @XmlDocID OUTPUT, @xml; + -- cleanup + DELETE FROM [dbo].[ecPluginsProperties] + WHERE [ResellerID] = @UserID AND [PluginID] = @PluginID; + -- insert + INSERT INTO [dbo].[ecPluginsProperties] + ( + [PluginID], + [ResellerID], + [PropertyName], + [PropertyValue] + ) + SELECT + @PluginID, + @UserID, + [XML].[PropertyName], + [XML].[PropertyValue] + FROM OPENXML(@XmlDocID, '/properties/property',1) WITH + ( + [PropertyName] nvarchar(50) '@name', + [PropertyValue] ntext '@value' + ) AS [XML]; + + -- remove document + EXEC sp_xml_removedocument @XmlDocID; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecSetStoreSettings] + @ActorID int, + @UserID int, + @SettingsName nvarchar(50), + @Xml ntext, + @Result int OUTPUT +AS +BEGIN +/* +XML Format: + + + + +*/ + -- check actor user rights + IF [dbo].[CheckUserParent](@ActorID, @UserID) = 0 + BEGIN + SET @Result = -1; + RAISERROR('You are not allowed to access this account', 16, 1); + RETURN; + END + -- + SET @Result = 0; + + DECLARE @docid int; + --Create an internal representation of the XML document. + EXEC sp_xml_preparedocument @docid OUTPUT, @Xml; + + -- cleanup + DELETE FROM [dbo].[ecStoreSettings] + WHERE [SettingsName] = @SettingsName AND [ResellerID] = @UserID; + + INSERT INTO [dbo].[ecStoreSettings] + ( + [ResellerID], + [SettingsName], + [PropertyName], + [PropertyValue] + ) + SELECT + @UserID, + @SettingsName, + [XML].[PropertyName], + [XML].[PropertyValue] + FROM OPENXML(@docid, '/settings/setting', 1) WITH + ( + [PropertyName] nvarchar(50) '@name', + [PropertyValue] ntext '@value' + ) AS [XML]; + + -- remove document + EXEC sp_xml_removedocument @docid; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecSetSvcsUsageRecordsClosed] + @ActorID int, + @XmlSvcs xml, + @Result int OUTPUT +AS +BEGIN + + -- SET NOCOUNT ON added to prevent extra result sets from + -- interfering with SELECT statements. + SET NOCOUNT ON; + + -- result is ok + SET @Result = 0; + -- update all svc records + UPDATE + [dbo].[ecSvcsUsageLog] + SET + [PeriodClosed] = 1 + WHERE + [ServiceID] IN ( + SELECT [SXML].[Data].value('@id','int') FROM @XmlSvcs.nodes('/records/record') [SXML]([Data])); + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecUpdateBillingCycle] + @ActorID int, + @UserID int, + @CycleID int, + @CycleName nvarchar(255), + @BillingPeriod nvarchar(50), + @PeriodLength int, + @Result int OUTPUT +AS +BEGIN + -- check actor user rights + IF [dbo].[CheckUserParent](@ActorID, @UserID) = 0 + BEGIN + SET @Result = -1; + RAISERROR('You are not allowed to access this account', 16, 1); + RETURN; + END + -- update cycle details + UPDATE + [dbo].[ecBillingCycles] + SET + [CycleName] = @CycleName, + [BillingPeriod] = @BillingPeriod, + [PeriodLength] = @PeriodLength + WHERE + [ResellerID] = @UserID + AND + [CycleID] = @CycleID; + + SET @Result = 0; + RETURN; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecUpdateCategory] + @ActorID int, + @UserID int, + @CategoryID int, + @CategoryName nvarchar(255), + @CategorySku nvarchar(50), + @ParentID int, + @ShortDescription ntext, + @FullDescription ntext, + @Result int OUTPUT +AS +BEGIN + -- check actor rights + IF [dbo].[CheckUserParent](@ActorID, @UserID) = 0 + BEGIN + SET @Result = -1; + RAISERROR('You are not allowed to access this account', 16, 1); + RETURN; + END + + SET NOCOUNT ON; + + SET @Result = 0; + + DECLARE @Level int; + + IF @ParentID <= 0 + SET @ParentID = NULL; + + -- check whether a category exists + IF NOT EXISTS( + SELECT + [CategoryName] + FROM + [dbo].[ecCategory] + WHERE + [CategoryID] = @CategoryID + AND + [ResellerID] = @UserID + ) + BEGIN + SET @Result = -1; + RETURN; + END + + -- check whether the update is correct + IF @ParentID = @CategoryID + BEGIN + SET @Result = -1; + RETURN; + END + + -- check consistency: sub-categories won't include a parent category + IF @ParentID IN ( + SELECT + [CategoryID] + FROM + [dbo].[ecCategory] + WHERE + [ParentID] = @CategoryID + AND + [ResellerID] = @UserID + ) + BEGIN + SET @Result = -1; + RETURN; + END + + -- category level updates + IF @ParentID = 0 + BEGIN + SET @ParentID = NULL; + SET @Level = 0; + END + ELSE + BEGIN + -- identify parent level + SELECT + @Level = [Level] + FROM + [dbo].[ecCategory] + WHERE + [CategoryID] = @ParentID + AND + [ResellerID] = @UserID; + + -- increase if necessary + IF @Level >= 0 + SET @Level = @Level + 1; + ELSE + SET @Level = 0; + END + + -- update a category + UPDATE + [dbo].[ecCategory] + SET + [CategoryName] = @CategoryName, + [CategorySku] = @CategorySku, + [ParentID] = @ParentID, + [Level] = @Level, + [ShortDescription] = @ShortDescription, + [FullDescription] = @FullDescription, + [Modified] = GETUTCDATE(), + [ModifierID] = @ActorID + WHERE + [CategoryID] = @CategoryID + AND + [ResellerID] = @UserID; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecUpdateContract] + @ContractID nvarchar(50), + @CustomerID int, + @AccountName nvarchar(50), + @Status int, + @Balance money, + @FirstName nvarchar(50), + @LastName nvarchar(50), + @Email nvarchar(255), + @CompanyName nvarchar(50), + @PropertyNames ntext, + @PropertyValues ntext, + @Result int OUTPUT +AS +BEGIN + -- SET NOCOUNT ON added to prevent extra result sets from + -- interfering with SELECT statements. + SET NOCOUNT ON; + + SET @Result = 0; + + IF @CustomerID < 1 + SET @CustomerID = NULL; + + UPDATE [dbo].[ecContracts] SET + [CustomerID] = @CustomerID, + [AccountName] = @AccountName, + [Status] = @Status, + [Balance] = @Balance, + [FirstName] = @FirstName, + [LastName] = @LastName, + [Email] = @Email, + [CompanyName] = @CompanyName, + [PropertyNames] = @PropertyNames, + [PropertyValues] = @PropertyValues + WHERE + [ContractID] = @ContractID; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecUpdateCustomerPayment] + @ActorID int, + @PaymentID int, + @InvoiceID int, + @TransactionID nvarchar(255), + @Total money, + @Currency nvarchar(3), + @MethodName nvarchar(50), + @PluginID int, + @StatusID int, + @Result int OUTPUT +AS +BEGIN + DECLARE @IssuerID int, @ContractID nvarchar(50); + SELECT + @ContractID = [ContractID] FROM [dbo].[ecCustomersPayments] + WHERE + [PaymentID] = @PaymentID; + SELECT + @IssuerID = ISNULL([CustomerID],[ResellerID]) FROM [dbo].[ecContracts] + WHERE + [ContractID] = @ContractID; + -- check actor user rights + IF [dbo].[CheckUserParent](@ActorID, @IssuerID) = 0 + BEGIN + RAISERROR('You are not allowed to access this account', 16, 1); + RETURN; + END + -- SET NOCOUNT ON added to prevent extra result sets from + -- interfering with SELECT statements. + SET NOCOUNT ON; + + SET @Result = 0; + + UPDATE [dbo].[ecCustomersPayments] + SET + [InvoiceID] = @InvoiceID, + [TransactionID] = @TransactionID, + [Total] = @Total, + [Currency] = @Currency, + [MethodName] = @MethodName, + [PluginID] = @PluginID, + [StatusID] = @StatusID + WHERE + [PaymentID] = @PaymentID; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecUpdateDomainNameSvc] + @ActorID int, + @ServiceID int, + @ProductID int, + @Status int, + @DomainID int, + @FQDN nvarchar(64), + @PropertyNames ntext, + @PropertyValues ntext, + @Result int OUTPUT +AS +BEGIN + DECLARE @IssuerID int, @ContractID nvarchar(50); + SELECT + @ContractID = [ContractID] FROM [dbo].[ecService] + WHERE + [ServiceID] = @ServiceID; + SELECT + @IssuerID = [ResellerID] FROM [dbo].[ecContracts] + WHERE + [ContractID] = @ContractID; + -- check actor user rights + IF [dbo].[CheckUserParent](@ActorID, @IssuerID) = 0 + BEGIN + RAISERROR('You are not allowed to access this action', 16, 1); + RETURN; + END + +BEGIN TRAN UPD_TLD_SVC + -- update tld svc + UPDATE + [dbo].[ecService] + SET + [ServiceName] = @FQDN, + [Status] = @Status, + [Modified] = GETDATE() + WHERE + [ServiceID] = @ServiceID; + + -- check error + IF @@ERROR <> 0 + GOTO ERROR_HANDLE; + -- update tld svc + IF @DomainID < 1 + SET @DomainID = NULL; + -- + UPDATE + [dbo].[ecDomainSvcs] + SET + [ProductID] = @ProductID, + [DomainID] = @DomainID, + [FQDN] = @FQDN, + [PropertyNames] = @PropertyNames, + [PropertyValues] = @PropertyValues + WHERE + [ServiceID] = @ServiceID; + -- check error + IF @@ERROR <> 0 + GOTO ERROR_HANDLE; + + -- set result ok + SET @Result = 0; + -- commit changes + COMMIT TRAN UPD_TLD_SVC; + -- exit + RETURN; + +-- error handler +ERROR_HANDLE: +BEGIN + SET @Result = -1; + ROLLBACK TRAN UPD_TLD_SVC; + RETURN; +END + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecUpdateHostingAddon] + @ActorID int, + @UserID int, + @ProductID int, + @AddonName nvarchar(255), + @ProductSku nvarchar(50), + @TaxInclusive bit, + @Enabled bit, + @PlanID int, + @Recurring bit, + @DummyAddon bit, + @Countable bit, + @Description ntext, + @AddonCyclesXml xml, + @AssignedProductsXml xml, + @Result int OUTPUT +AS +BEGIN + -- check actor user rights + IF [dbo].[CheckUserParent](@ActorID, @UserID) = 0 + BEGIN + SET @Result = -1; + RAISERROR('You are not allowed to access this account', 16, 1); + RETURN; + END + -- dummy addon clause + IF @DummyAddon = 1 + SET @PlanID = NULL; + +BEGIN TRAN UPDATE_ADDON + -- update product first + UPDATE [dbo].[ecProduct] + SET + [ProductName] = @AddonName, + [ProductSKU] = @ProductSku, + [Description] = @Description, + [Enabled] = @Enabled, + [TaxInclusive] = @TaxInclusive + WHERE + [ProductID] = @ProductID + AND + [ResellerID] = @UserID; + + -- update hosting addon details + UPDATE [dbo].[ecHostingAddons] + SET + [PlanID] = @PlanID, + [Recurring] = @Recurring, + [DummyAddon] = @DummyAddon, + [Countable] = @Countable + WHERE + [ProductID] = @ProductID + AND + [ResellerID] = @UserID; + + -- check errors + IF @@ERROR <> 0 + BEGIN + GOTO ERROR_HANDLE; + END +/* +XML Format: + + + + +*/ + -- cleanup hosting addon cycles first + DELETE FROM [dbo].[ecHostingAddonsCycles] WHERE [ProductID] = @ProductID; + + IF @Recurring = 1 + -- insert cycles + INSERT INTO [dbo].[ecHostingAddonsCycles] + ([ProductID], [CycleID], [SetupFee], [RecurringFee], [SortOrder]) + SELECT + @ProductID,[SXML].[Data].value('@ID','int'),[SXML].[Data].value('@SetupFee','money'), + [SXML].[Data].value('@RecurringFee','money'), [SXML].[Data].value('@SortOrder','int') + FROM @AddonCyclesXml.nodes('/PlanCycles/Cycle') [SXML]([Data]); + -- check errors + IF @@ERROR <> 0 + GOTO ERROR_HANDLE; + ELSE + UPDATE + [dbo].[ecHostingAddons] + SET + [SetupFee] = [SXML].[Data].value('@SetupFee','money'), + [OneTimeFee] = [SXML].[Data].value('@OneTimeFee','money') + FROM @AddonCyclesXml.nodes('/PlanCycles/Cycle') [SXML]([Data]) + WHERE + [ResellerID] = @UserID + AND + [ProductID] = @ProductID; + + -- check errors + IF @@ERROR <> 0 + GOTO ERROR_HANDLE; + +/* +XML Format: + + + + +*/ + -- cleanup addon products first + DELETE FROM [dbo].[ecAddonProducts] WHERE [AddonID] = @ProductID AND [ResellerID] = @UserID; + -- insert cycles + INSERT INTO [dbo].[ecAddonProducts] + ([AddonID], [ProductID], [ResellerID]) + SELECT + @ProductID,[SXML].[Data].value('@ID','int'),@UserID + FROM @AssignedProductsXml.nodes('/AssignedProducts/Product') [SXML]([Data]); + -- check errors + IF @@ERROR <> 0 + GOTO ERROR_HANDLE; + + -- set result ok + SET @Result = 0; + -- + COMMIT TRAN UPDATE_ADDON; + -- + RETURN; + + +ERROR_HANDLE: +BEGIN + SET @Result = -1; + ROLLBACK TRAN UPDATE_ADDON; + RETURN; + +END +END + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecUpdateHostingAddonSvc] + @ActorID int, + @ServiceID int, + @ProductID int, + @AddonName nvarchar(255), + @Status int, + @PlanID int, + @PackageAddonID int, + @Recurring bit, + @DummyAddon bit, + @Result int OUTPUT +AS +BEGIN + DECLARE @IssuerID int, @ContractID nvarchar(50); + SELECT + @ContractID = [ContractID] FROM [dbo].[ecService] + WHERE + [ServiceID] = @ServiceID; + SELECT + @IssuerID = [ResellerID] FROM [dbo].[ecContracts] + WHERE + [ContractID] = @ContractID; + -- check actor user rights + IF [dbo].[CheckUserParent](@ActorID, @IssuerID) = 0 + BEGIN + RAISERROR('You are not allowed to access this action', 16, 1); + RETURN; + END + + IF @PlanID < 1 + SET @PlanID = NULL; + +BEGIN TRAN UPD_HADDON_SVC + -- update addon svc + UPDATE + [dbo].[ecService] + SET + [ServiceName] = @AddonName, + [Status] = @Status, + [Modified] = GETDATE() + WHERE + [ServiceID] = @ServiceID; + + -- check error + IF @@ERROR <> 0 + GOTO ERROR_HANDLE; + -- update addon svc + IF @PackageAddonID < 1 + SET @PackageAddonID = NULL; + -- + UPDATE + [dbo].[ecHostingAddonSvcs] + SET + [ProductID] = @ProductID, + [PlanID] = @PlanID, + [PackageAddonID] = @PackageAddonID, + [Recurring] = @Recurring, + [DummyAddon] = @DummyAddon + WHERE + [ServiceID] = @ServiceID; + -- check error + IF @@ERROR <> 0 + GOTO ERROR_HANDLE; + + -- set result ok + SET @Result = 0; + -- commit changes + COMMIT TRAN UPD_HADDON_SVC; + -- exit + RETURN; + +-- error handler +ERROR_HANDLE: +BEGIN + SET @Result = -1; + ROLLBACK TRAN UPD_HADDON_SVC; + RETURN; +END +END + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecUpdateHostingPlan] + @ActorID int, + @UserID int, + @ProductID int, + @PlanName nvarchar(255), + @ProductSku nvarchar(50), + @TaxInclusive bit, + @PlanID int, + @UserRole int, + @InitialStatus int, + @DomainOption int, + @Enabled bit, + @PlanDescription ntext, + @PlanCyclesXml xml, + @PlanHighlightsXml xml, + @PlanCategoriesXml xml, + @Result int OUTPUT +AS +BEGIN + -- check actor user rights + IF [dbo].[CheckUserParent](@ActorID, @UserID) = 0 + BEGIN + SET @Result = -1; + RAISERROR('You are not allowed to access this account', 16, 1); + RETURN; + END + +BEGIN TRAN UPDATE_PLAN + -- update product first + UPDATE + [dbo].[ecProduct] + SET + [ProductName] = @PlanName, + [ProductSKU] = @ProductSku, + [Description] = @PlanDescription, + [Enabled] = @Enabled, + [TaxInclusive] = @TaxInclusive + WHERE + [ResellerID] = @UserID AND [ProductID] = @ProductID AND [TypeID] = 1; + + -- update hosting plan details + UPDATE + [dbo].[ecHostingPlans] + SET + [PlanID] = @PlanID, + [UserRole] = @UserRole, + [InitialStatus] = @InitialStatus, + [DomainOption] = @DomainOption + WHERE + [ResellerID] = @UserID AND [ProductID] = @ProductID; + -- check errors + IF @@ERROR <> 0 + BEGIN + GOTO ERROR_HANDLE; + END + +/* +XML Format: + + + + +*/ + -- cleanup cycles + DELETE FROM [dbo].[ecHostingPlansBillingCycles] WHERE [ProductID] = @ProductID; + -- insert cycles + INSERT INTO [dbo].[ecHostingPlansBillingCycles] + ([ProductID], [CycleID], [SetupFee], [RecurringFee], [SortOrder]) + SELECT + @ProductID,[SXML].[Data].value('@ID','int'),[SXML].[Data].value('@SetupFee','money'), + [SXML].[Data].value('@RecurringFee','money'), [SXML].[Data].value('@SortOrder','int') + FROM @PlanCyclesXml.nodes('/PlanCycles/Cycle') [SXML]([Data]); + -- check errors + IF @@ERROR <> 0 + GOTO ERROR_HANDLE; + +/* +XML Format: + + + + +*/ + -- cleanup highlights + DELETE FROM [dbo].[ecProductsHighlights] WHERE [ProductID] = @ProductID; + -- insert cycles + INSERT INTO [dbo].[ecProductsHighlights] + ([ProductID], [HighlightText], [SortOrder]) + SELECT + @ProductID, [SXML].[Data].value('@Text','nvarchar(255)'), [SXML].[Data].value('@SortOrder','int') + FROM @PlanHighlightsXml.nodes('/PlanHighlights/Item') [SXML]([Data]); + -- check errors + IF @@ERROR <> 0 + GOTO ERROR_HANDLE; + +/* +XML Format: + + + + +*/ + -- cleanup categories + DELETE FROM [dbo].[ecProductCategories] WHERE [ProductID] = @ProductID; + -- insert categories + INSERT INTO [dbo].[ecProductCategories] + ([ProductID], [CategoryID], [ResellerID]) + SELECT + @ProductID, [SXML].[Data].value('@ID','int'), @UserID + FROM @PlanCategoriesXml.nodes('/PlanCategories/Category') [SXML]([Data]); + -- check errors + IF @@ERROR <> 0 + GOTO ERROR_HANDLE; + -- + SET @Result = 0; + -- commit changes + COMMIT TRAN UPDATE_PLAN; + -- exit + RETURN; + +ERROR_HANDLE: +BEGIN + SET @Result = -1; + ROLLBACK TRAN UPDATE_PLAN; + RETURN; +END + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecUpdateHostingPlanSvc] + @ActorID int, + @ServiceID int, + @ProductID int, + @PlanName nvarchar(255), + @Status int, + @PlanID int, + @PackageID int, + @UserRole int, + @InitialStatus int, + @Result int OUTPUT +AS +BEGIN + DECLARE @IssuerID int, @ContractID nvarchar(50); + SELECT + @ContractID = [ContractID] FROM [dbo].[ecService] + WHERE + [ServiceID] = @ServiceID; + SELECT + @IssuerID = [ResellerID] FROM [dbo].[ecContracts] + WHERE + [ContractID] = @ContractID; + -- check actor user rights + IF [dbo].[CheckUserParent](@ActorID, @IssuerID) = 0 + BEGIN + RAISERROR('You are not allowed to access this action', 16, 1); + RETURN; + END + +BEGIN TRAN UPD_HPLAN_SVC + -- update plan svc + UPDATE + [dbo].[ecService] + SET + [ServiceName] = @PlanName, + [Status] = @Status, + [Modified] = GETDATE() + WHERE + [ServiceID] = @ServiceID; + + -- check error + IF @@ERROR <> 0 + GOTO ERROR_HANDLE; + -- update package svc + IF @PackageID < 1 + SET @PackageID = NULL; + -- + UPDATE + [dbo].[ecHostingPackageSvcs] + SET + [ProductID] = @ProductID, + [PlanID] = @PlanID, + [PackageID] = @PackageID, + [UserRole] = @UserRole, + [InitialStatus] = @InitialStatus + WHERE + [ServiceID] = @ServiceID; + -- check error + IF @@ERROR <> 0 + GOTO ERROR_HANDLE; + + -- set result ok + SET @Result = 0; + -- commit changes + COMMIT TRAN UPD_HPLAN_SVC; + -- exit + RETURN; + +-- error handler +ERROR_HANDLE: +BEGIN + SET @Result = -1; + ROLLBACK TRAN UPD_HPLAN_SVC; + RETURN; +END + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecUpdateInvoice] + @ActorID int, + @InvoiceID int, + @InvoiceNumber nvarchar(50), + @DueDate datetime, + @TaxationID int, + @Total money, + @SubTotal money, + @TaxAmount money, + @Currency nvarchar(3), + @Result int OUTPUT +AS +BEGIN + -- ensure an update request has been issued by the right person + DECLARE @ContractID nvarchar(50), @IssuerID int; + SELECT + @ContractID = [ContractID] FROM [dbo].[ecInvoice] + WHERE + [InvoiceID] = @InvoiceID; + SELECT + @IssuerID = [ResellerID] FROM [dbo].[ecContracts] + WHERE + [ContractID] = @ContractID; + -- check actor user rights + IF [dbo].[CheckUserParent](@ActorID, @IssuerID) = 0 + BEGIN + RAISERROR('You are not allowed to access this account', 16, 1); + RETURN; + END + + SET NOCOUNT ON; + + SET @Result = 0; + + UPDATE + [dbo].[ecInvoice] + SET + [InvoiceNumber] = @InvoiceNumber, + [DueDate] = @DueDate, + [Total] = @Total, + [SubTotal] = @SubTotal, + [TaxationID] = @TaxationID, + [TaxAmount] = @TaxAmount, + [Currency] = @Currency + WHERE + [InvoiceID] = @InvoiceID + AND + [ContractID] = @ContractID; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecUpdateServiceHandlersResponses] + @ResellerID int, + @XmlData xml +AS +BEGIN + -- SET NOCOUNT ON added to prevent extra result sets from + -- interfering with SELECT statements. + SET NOCOUNT ON; + +/* + + + + + + +*/ + DELETE + FROM [ecServiceHandlersResponses] + WHERE + [ResponseID] IN (SELECT [SXML].[Data].value('@ID','int') FROM @XmlData.nodes('/Succeed/Response') [SXML]([Data])) + + UPDATE + [ecServiceHandlersResponses] + SET + [ErrorMessage] = [SXML].[Data].value('@Error','nvarchar(255)') + FROM @XmlData.nodes('/Failed/Response') [SXML]([Data]) + WHERE + [ResponseID] = [SXML].[Data].value('@ID', 'int') +END + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecUpdateSystemTrigger] + @ActorID int, + @TriggerID nvarchar(50), + @TriggerHandler nvarchar(512), + @ReferenceID nvarchar(50), + @Namespace nvarchar(255), + @Status nvarchar(50) +AS +BEGIN + DECLARE @OwnerID int; + SELECT + @OwnerID = [OwnerID] FROM [dbo].[ecSystemTriggers] + WHERE + [TriggerID] = @TriggerID; + -- + IF [dbo].[CheckUserParent](@ActorID, @OwnerID) = 0 + BEGIN + RAISERROR('You are not allowed to perform this action', 16, 1); + RETURN; + END + -- SET NOCOUNT ON added to prevent extra result sets from + -- interfering with SELECT statements. + SET NOCOUNT ON; + + UPDATE [dbo].[ecSystemTriggers] SET + [TriggerHandler] = @TriggerHandler, + [ReferenceID] = @ReferenceID, + [Namespace] = @Namespace, + [Status] = @Status + WHERE + [TriggerID] = @TriggerID; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecUpdateTaxation] + @ActorID int, + @UserID int, + @TaxationID int, + @Country nvarchar(3), + @State nvarchar(50), + @Description nvarchar(50), + @TypeID int, + @Amount decimal(5,2), + @Active bit, + @Result int OUTPUT +AS +BEGIN + -- check actor user rights + IF [dbo].[CheckUserParent](@ActorID, @UserID) = 0 + BEGIN + RAISERROR('You are not allowed to access this account', 16, 1); + RETURN; + END + -- SET NOCOUNT ON added to prevent extra result sets from + -- interfering with SELECT statements. + SET NOCOUNT ON; + + -- + DECLARE @T_TaxationID int; + -- + SELECT @T_TaxationID = [TaxationID] FROM [dbo].[ecTaxations] WHERE [ResellerID] = @UserID AND [Country] = @Country AND [State] = @State; + -- + SET @T_TaxationID = ISNULL(@T_TaxationID, @TaxationID); + -- + IF @T_TaxationID = @TaxationID + BEGIN + -- insert + UPDATE + [dbo].[ecTaxations] + SET + [Country] = @Country, + [State] = @State, + [Description] = @Description, + [TypeID] = @TypeID, + [Amount] = @Amount, + [Active] = @Active + WHERE + [ResellerID] = @UserID + AND + [TaxationID] = @TaxationID; + -- + SET @Result = 0; + -- + RETURN; + END + + -- taxation update error + SET @Result = -202; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecUpdateTopLevelDomain] + @ActorID int, + @UserID int, + @ProductID int, + @TopLevelDomain nvarchar(10), + @ProductSku nvarchar(50), + @TaxInclusive bit, + @PluginID int, + @Enabled bit, + @WhoisEnabled bit, + @DomainCyclesXml xml, + @Result int OUTPUT +AS +BEGIN + -- check actor user rights + IF [dbo].[CheckUserParent](@ActorID, @UserID) = 0 + BEGIN + SET @Result = -1; + RAISERROR('You are not allowed to access this account', 16, 1); + RETURN; + END + +BEGIN TRAN UPDATE_DOMAIN + -- insert product first + UPDATE + [dbo].[ecProduct] + SET + [ProductName] = @TopLevelDomain, + [ProductSKU] = @ProductSku, + [Enabled] = @Enabled, + [TaxInclusive] = @TaxInclusive + WHERE + [ResellerID] = @UserID + AND + [ProductID] = @ProductID; + + -- save top level domain details + UPDATE + [dbo].[ecTopLevelDomains] + SET + [TopLevelDomain] = @TopLevelDomain, + [PluginID] = @PluginID, + [WhoisEnabled] = @WhoisEnabled + WHERE + [ResellerID] = @UserID + AND + [ProductID] = @ProductID; + -- check errors + IF @@ERROR <> 0 + BEGIN + GOTO ERROR_HANDLE; + END + +/* +XML Format: + + + + +*/ + -- cleanup cycles + DELETE FROM [dbo].[ecTopLevelDomainsCycles] WHERE [ProductID] = @ProductID; + -- insert cycles + INSERT INTO [dbo].[ecTopLevelDomainsCycles] + ( + [ProductID], + [CycleID], + [SetupFee], + [RecurringFee], + [TransferFee], + [SortOrder] + ) + SELECT + @ProductID, + [SXML].[Data].value('@ID','int'), + [SXML].[Data].value('@SetupFee','money'), + [SXML].[Data].value('@RecurringFee','money'), + [SXML].[Data].value('@TransferFee','money'), + [SXML].[Data].value('@SortOrder','int') + FROM @DomainCyclesXml.nodes('/DomainCycles/Cycle') [SXML]([Data]); + -- check errors + IF @@ERROR <> 0 + BEGIN + GOTO ERROR_HANDLE; + END + -- + SET @Result = 0; + -- + COMMIT TRAN UPDATE_DOMAIN; + -- + RETURN; + +ERROR_HANDLE: +BEGIN + SET @Result = -1; + ROLLBACK TRAN UPDATE_DOMAIN; + RETURN; +END + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecVoidCustomerInvoice] + @ActorID int, + @InvoiceID int +AS +BEGIN + -- load customer and reseller identities + DECLARE @ContractID nvarchar(50), @IssuerID int; + SELECT + @ContractID = [ContractID] FROM [dbo].[ecInvoice] + WHERE + [InvoiceID] = @InvoiceID; + SELECT + @IssuerID = [ResellerID] FROM [dbo].[ecContracts] + WHERE + [ContractID] = @ContractID; + -- check actor rights + IF [dbo].[CheckUserParent](@ActorID, @IssuerID) = 0 + BEGIN + RAISERROR('You are not allowed to access the contract', 16, 1); + RETURN; + END + -- + SET NOCOUNT ON; + -- void invoice + DELETE FROM [dbo].[ecInvoice] WHERE [InvoiceID] = @InvoiceID; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[ecWriteSupportedPluginLog] + @ContractID nvarchar(50), + @PluginID int, + @RecordType int, + @RawData ntext, + @Result int OUTPUT +AS +BEGIN + + SET NOCOUNT ON; + + INSERT INTO [dbo].[ecSupportedPluginLog] + ( + [PluginID], + [ContractID], + [RecordType], + [RawData] + ) + VALUES + ( + @PluginID, + @ContractID, + @RecordType, + @RawData + ); + + SET @Result = SCOPE_IDENTITY(); +END + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + +CREATE PROCEDURE [dbo].[ExchangeAccountEmailAddressExists] +( + @EmailAddress nvarchar(300), + @Exists bit OUTPUT +) +AS + + SET @Exists = 0 + IF EXISTS(SELECT * FROM [dbo].[ExchangeAccountEmailAddresses] WHERE [EmailAddress] = @EmailAddress) + BEGIN + SET @Exists = 1 + END + ELSE IF EXISTS(SELECT * FROM [dbo].[ExchangeAccounts] WHERE [PrimaryEmailAddress] = @EmailAddress AND [AccountType] <> 2) + BEGIN + SET @Exists = 1 + END + + RETURN + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + + + +CREATE PROCEDURE [dbo].[ExchangeAccountExists] +( + @AccountName nvarchar(20), + @Exists bit OUTPUT +) +AS +SET @Exists = 0 +IF EXISTS(SELECT * FROM ExchangeAccounts WHERE sAMAccountName LIKE '%\'+@AccountName) +BEGIN + SET @Exists = 1 +END + +RETURN + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE ExchangeOrganizationDomainExists +( + @DomainID int, + @Exists bit OUTPUT +) +AS +SET @Exists = 0 +IF EXISTS(SELECT * FROM ExchangeOrganizationDomains WHERE DomainID = @DomainID) +BEGIN + SET @Exists = 1 +END +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE ExchangeOrganizationExists +( + @OrganizationID nvarchar(10), + @Exists bit OUTPUT +) +AS +SET @Exists = 0 +IF EXISTS(SELECT * FROM ExchangeOrganizations WHERE OrganizationID = @OrganizationID) +BEGIN + SET @Exists = 1 +END + +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[GetAllServers] +( + @ActorID int +) +AS + +-- check rights +DECLARE @IsAdmin bit +SET @IsAdmin = dbo.CheckIsUserAdmin(@ActorID) + +SELECT + S.ServerID, + S.ServerName, + S.ServerUrl, + (SELECT COUNT(SRV.ServiceID) FROM VirtualServices AS SRV WHERE S.ServerID = SRV.ServerID) AS ServicesNumber, + S.Comments +FROM Servers AS S +WHERE @IsAdmin = 1 +ORDER BY S.VirtualServer, S.ServerName + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[GetAuditLogRecord] +( + @RecordID varchar(32) +) +AS + +SELECT + L.RecordID, + L.SeverityID, + L.StartDate, + L.FinishDate, + L.ItemID, + L.SourceName, + L.TaskName, + L.ItemName, + L.ExecutionLog, + + ISNULL(L.UserID, 0) AS UserID, + L.Username, + U.FirstName, + U.LastName, + U.FullName, + ISNULL(U.RoleID, 0) AS RoleID, + U.Email +FROM AuditLog AS L +LEFT OUTER JOIN UsersDetailed AS U ON L.UserID = U.UserID +WHERE RecordID = @RecordID +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[GetAuditLogRecordsPaged] +( + @ActorID int, + @UserID int, + @PackageID int, + @ItemID int, + @ItemName nvarchar(100), + @StartDate datetime, + @EndDate datetime, + @SeverityID int, + @SourceName varchar(100), + @TaskName varchar(100), + @SortColumn nvarchar(50), + @StartRow int, + @MaximumRows int +) +AS + +-- check rights +IF dbo.CheckActorUserRights(@ActorID, @UserID) = 0 +RAISERROR('You are not allowed to access this account', 16, 1) + +IF @SourceName IS NULL SET @SourceName = '' +IF @TaskName IS NULL SET @TaskName = '' +IF @ItemName IS NULL SET @ItemName = '' + +IF @SortColumn IS NULL OR @SortColumn = '' +SET @SortColumn = 'L.StartDate DESC' + +-- build query and run it to the temporary table +DECLARE @sql nvarchar(2000) + +SET @sql = ' +DECLARE @IsAdmin bit +SET @IsAdmin = 0 +IF EXISTS(SELECT UserID FROM Users WHERE UserID = @ActorID AND RoleID = 1) +SET @IsAdmin = 1 + +DECLARE @EndRow int +SET @EndRow = @StartRow + @MaximumRows +DECLARE @Records TABLE +( + ItemPosition int IDENTITY(1,1), + RecordID varchar(32) +) +INSERT INTO @Records (RecordID) +SELECT + L.RecordID +FROM AuditLog AS L +WHERE +((@PackageID = 0 AND dbo.CheckUserParent(@UserID, L.UserID) = 1 OR (L.UserID IS NULL AND @IsAdmin = 1)) + OR (@PackageID > 0 AND L.PackageID = @PackageID)) +AND L.StartDate BETWEEN @StartDate AND @EndDate +AND ((@SourceName = '''') OR (@SourceName <> '''' AND L.SourceName = @SourceName)) +AND ((@TaskName = '''') OR (@TaskName <> '''' AND L.TaskName = @TaskName)) +AND ((@ItemID = 0) OR (@ItemID > 0 AND L.ItemID = @ItemID)) +AND ((@ItemName = '''') OR (@ItemName <> '''' AND L.ItemName LIKE @ItemName)) +AND ((@SeverityID = -1) OR (@SeverityID > -1 AND L.SeverityID = @SeverityID)) ' + +IF @SortColumn <> '' AND @SortColumn IS NOT NULL +SET @sql = @sql + ' ORDER BY ' + @SortColumn + ' ' + +SET @sql = @sql + ' SELECT COUNT(RecordID) FROM @Records; +SELECT + TL.RecordID, + L.SeverityID, + L.StartDate, + L.FinishDate, + L.ItemID, + L.SourceName, + L.TaskName, + L.ItemName, + L.ExecutionLog, + + ISNULL(L.UserID, 0) AS UserID, + L.Username, + U.FirstName, + U.LastName, + U.FullName, + ISNULL(U.RoleID, 0) AS RoleID, + U.Email, + CASE U.IsPeer + WHEN 1 THEN U.OwnerID + ELSE U.UserID + END EffectiveUserID +FROM @Records AS TL +INNER JOIN AuditLog AS L ON TL.RecordID = L.RecordID +LEFT OUTER JOIN UsersDetailed AS U ON L.UserID = U.UserID +WHERE TL.ItemPosition BETWEEN @StartRow + 1 AND @EndRow' + +exec sp_executesql @sql, N'@TaskName varchar(100), @SourceName varchar(100), @PackageID int, @ItemID int, @ItemName nvarchar(100), @StartDate datetime, +@EndDate datetime, @StartRow int, @MaximumRows int, @UserID int, @ActorID int, @SeverityID int', +@TaskName, @SourceName, @PackageID, @ItemID, @ItemName, @StartDate, @EndDate, @StartRow, @MaximumRows, @UserID, @ActorID, +@SeverityID + + +RETURN + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE GetAuditLogSources +AS + +SELECT SourceName FROM AuditLogSources + +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE GetAuditLogTasks +( + @SourceName varchar(100) +) +AS + +IF @SourceName = '' SET @SourceName = NULL + +SELECT SourceName, TaskName FROM AuditLogTasks +WHERE (@SourceName = NULL OR @SourceName IS NOT NULL AND SourceName = @SourceName) + +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE GetAvailableVirtualServices +( + @ActorID int, + @ServerID int +) +AS + +-- check rights +DECLARE @IsAdmin bit +SET @IsAdmin = dbo.CheckIsUserAdmin(@ActorID) + + +SELECT + S.ServerID, + S.ServerName, + S.Comments +FROM Servers AS S +WHERE + VirtualServer = 0 -- get only physical servers + AND @IsAdmin = 1 + +-- services +SELECT + ServiceID, + ServerID, + ProviderID, + ServiceName, + Comments +FROM Services +WHERE + ServiceID NOT IN (SELECT ServiceID FROM VirtualServices WHERE ServerID = @ServerID) + AND @IsAdmin = 1 + +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + + + + + +CREATE PROCEDURE [dbo].[GetBlackBerryUsers] +( + @ItemID int, + @SortColumn nvarchar(40), + @SortDirection nvarchar(20), + @Name nvarchar(400), + @Email nvarchar(400), + @StartRow int, + @Count int +) +AS + +IF (@Name IS NULL) +BEGIN + SET @Name = '%' +END + +IF (@Email IS NULL) +BEGIN + SET @Email = '%' +END + +CREATE TABLE #TempBlackBerryUsers +( + [ID] [int] IDENTITY(1,1) NOT NULL, + [AccountID] [int], + [ItemID] [int] NOT NULL, + [AccountName] [nvarchar](300) NOT NULL, + [DisplayName] [nvarchar](300) NOT NULL, + [PrimaryEmailAddress] [nvarchar](300) NULL, + [SamAccountName] [nvarchar](100) NULL +) + + +IF (@SortColumn = 'DisplayName') +BEGIN + INSERT INTO + #TempBlackBerryUsers + SELECT + ea.AccountID, + ea.ItemID, + ea.AccountName, + ea.DisplayName, + ea.PrimaryEmailAddress, + ea.SamAccountName + FROM + ExchangeAccounts ea + INNER JOIN + BlackBerryUsers bu + ON + ea.AccountID = bu.AccountID + WHERE + ea.ItemID = @ItemID AND ea.DisplayName LIKE @Name AND ea.PrimaryEmailAddress LIKE @Email + ORDER BY + ea.DisplayName +END +ELSE +BEGIN + INSERT INTO + #TempBlackBerryUsers + SELECT + ea.AccountID, + ea.ItemID, + ea.AccountName, + ea.DisplayName, + ea.PrimaryEmailAddress, + ea.SamAccountName + FROM + ExchangeAccounts ea + INNER JOIN + BlackBerryUsers bu + ON + ea.AccountID = bu.AccountID + WHERE + ea.ItemID = @ItemID AND ea.DisplayName LIKE @Name AND ea.PrimaryEmailAddress LIKE @Email + ORDER BY + ea.PrimaryEmailAddress +END + +DECLARE @RetCount int +SELECT @RetCount = COUNT(ID) FROM #TempBlackBerryUsers + +IF (@SortDirection = 'ASC') +BEGIN + SELECT * FROM #TempBlackBerryUsers + WHERE ID > @StartRow AND ID <= (@StartRow + @Count) +END +ELSE +BEGIN + IF (@SortColumn = 'DisplayName') + BEGIN + SELECT * FROM #TempBlackBerryUsers + WHERE ID >@RetCount - @Count - @StartRow AND ID <= @RetCount- @StartRow ORDER BY DisplayName DESC + END + ELSE + BEGIN + SELECT * FROM #TempBlackBerryUsers + WHERE ID >@RetCount - @Count - @StartRow AND ID <= @RetCount- @StartRow ORDER BY PrimaryEmailAddress DESC + END + +END + + +DROP TABLE #TempBlackBerryUsers + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[GetBlackBerryUsersCount] +( + @ItemID int, + @Name nvarchar(400), + @Email nvarchar(400) + +) +AS + +IF (@Name IS NULL) +BEGIN + SET @Name = '%' +END + +IF (@Email IS NULL) +BEGIN + SET @Email = '%' +END + +SELECT + COUNT(ea.AccountID) +FROM + ExchangeAccounts ea +INNER JOIN + BlackBerryUsers bu +ON + ea.AccountID = bu.AccountID +WHERE + ea.ItemID = @ItemID AND ea.DisplayName LIKE @Name AND ea.PrimaryEmailAddress LIKE @Email + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + +CREATE PROCEDURE [dbo].[GetCertificatesForSite] +( + @ActorID int, + @PackageID int, + @websiteid int +) +AS + +-- check rights +IF dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 +BEGIN + RAISERROR('You are not allowed to access this package', 16, 1) + RETURN +END + +SELECT + [ID], [UserID], [SiteID], [FriendlyName], [Hostname], [DistinguishedName], + [CSR], [CSRLength], [ValidFrom], [ExpiryDate], [Installed], [IsRenewal], + [PreviousId], [SerialNumber] +FROM + [dbo].[SSLCertificates] +WHERE + [SiteID] = @websiteid +RETURN + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE GetClusters +( + @ActorID int +) +AS + +-- check rights +DECLARE @IsAdmin bit +SET @IsAdmin = dbo.CheckIsUserAdmin(@ActorID) + +-- get the list +SELECT + ClusterID, + ClusterName +FROM Clusters +WHERE @IsAdmin = 1 + +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE GetComments +( + @ActorID int, + @UserID int, + @ItemTypeID varchar(50), + @ItemID int +) +AS + +-- check rights +IF dbo.CheckActorUserRights(@ActorID, @UserID) = 0 +RAISERROR('You are not allowed to access this account', 16, 1) + +SELECT + C.CommentID, + C.ItemTypeID, + C.ItemID, + C.UserID, + C.CreatedDate, + C.CommentText, + C.SeverityID, + + -- user + U.Username, + U.FirstName, + U.LastName, + U.FullName, + U.RoleID, + U.Email +FROM Comments AS C +INNER JOIN UsersDetailed AS U ON C.UserID = U.UserID +WHERE + ItemTypeID = @ItemTypeID + AND ItemID = @ItemID + AND dbo.CheckUserParent(@UserID, C.UserID) = 1 +ORDER BY C.CreatedDate ASC +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[GetCRMOrganizationUsers] + @ItemID int +AS +BEGIN + SELECT + ea.AccountID, + ea.ItemID, + ea.AccountName, + ea.DisplayName, + ea.PrimaryEmailAddress, + ea.SamAccountName + FROM + ExchangeAccounts ea + INNER JOIN + CRMUsers cu + ON + ea.AccountID = cu.AccountID + WHERE + ea.ItemID = @ItemID +END + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[GetCRMUser] + @AccountID int +AS +BEGIN + SET NOCOUNT ON; +SELECT + CRMUserGUID as CRMUserID, + BusinessUnitID +FROM + CRMUsers +WHERE + AccountID = @AccountID +END + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + +CREATE PROCEDURE [dbo].[GetCRMUsers] +( + @ItemID int, + @SortColumn nvarchar(40), + @SortDirection nvarchar(20), + @Name nvarchar(400), + @Email nvarchar(400), + @StartRow int, + @Count int +) +AS + +IF (@Name IS NULL) +BEGIN + SET @Name = '%' +END + +IF (@Email IS NULL) +BEGIN + SET @Email = '%' +END + +CREATE TABLE #TempCRMUsers +( + [ID] [int] IDENTITY(1,1) NOT NULL, + [AccountID] [int], + [ItemID] [int] NOT NULL, + [AccountName] [nvarchar](300) NOT NULL, + [DisplayName] [nvarchar](300) NOT NULL, + [PrimaryEmailAddress] [nvarchar](300) NULL, + [SamAccountName] [nvarchar](100) NULL +) + + +IF (@SortColumn = 'DisplayName') +BEGIN + INSERT INTO + #TempCRMUsers + SELECT + ea.AccountID, + ea.ItemID, + ea.AccountName, + ea.DisplayName, + ea.PrimaryEmailAddress, + ea.SamAccountName + FROM + ExchangeAccounts ea + INNER JOIN + CRMUsers cu + ON + ea.AccountID = cu.AccountID + WHERE + ea.ItemID = @ItemID AND ea.DisplayName LIKE @Name AND ea.PrimaryEmailAddress LIKE @Email + ORDER BY + ea.DisplayName +END +ELSE +BEGIN + INSERT INTO + #TempCRMUsers + SELECT + ea.AccountID, + ea.ItemID, + ea.AccountName, + ea.DisplayName, + ea.PrimaryEmailAddress, + ea.SamAccountName + FROM + ExchangeAccounts ea + INNER JOIN + CRMUsers cu + ON + ea.AccountID = cu.AccountID + WHERE + ea.ItemID = @ItemID AND ea.DisplayName LIKE @Name AND ea.PrimaryEmailAddress LIKE @Email + ORDER BY + ea.PrimaryEmailAddress +END + +DECLARE @RetCount int +SELECT @RetCount = COUNT(ID) FROM #TempCRMUsers + +IF (@SortDirection = 'ASC') +BEGIN + SELECT * FROM #TempCRMUsers + WHERE ID > @StartRow AND ID <= (@StartRow + @Count) +END +ELSE +BEGIN + IF (@SortColumn = 'DisplayName') + BEGIN + SELECT * FROM #TempCRMUsers + WHERE ID >@RetCount - @Count - @StartRow AND ID <= @RetCount- @StartRow ORDER BY DisplayName DESC + END + ELSE + BEGIN + SELECT * FROM #TempCRMUsers + WHERE ID >@RetCount - @Count - @StartRow AND ID <= @RetCount- @StartRow ORDER BY PrimaryEmailAddress DESC + END + +END + + + +DROP TABLE #TempCRMUsers + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[GetCRMUsersCount] +( + @ItemID int, + @Name nvarchar(400), + @Email nvarchar(400) + +) +AS + +IF (@Name IS NULL) +BEGIN + SET @Name = '%' +END + +IF (@Email IS NULL) +BEGIN + SET @Email = '%' +END + +SELECT + COUNT(ea.AccountID) +FROM + ExchangeAccounts ea +INNER JOIN + CRMUsers cu +ON + ea.AccountID = cu.AccountID +WHERE + ea.ItemID = @ItemID AND ea.DisplayName LIKE @Name AND ea.PrimaryEmailAddress LIKE @Email + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + + + +CREATE PROCEDURE [dbo].[GetDnsRecord] +( + @ActorID int, + @RecordID int +) +AS + +-- check rights +DECLARE @ServiceID int, @ServerID int, @PackageID int +SELECT + @ServiceID = ServiceID, + @ServerID = ServerID, + @PackageID = PackageID +FROM GlobalDnsRecords +WHERE + RecordID = @RecordID + +IF (@ServiceID > 0 OR @ServerID > 0) AND dbo.CheckIsUserAdmin(@ActorID) = 0 +RAISERROR('You are not allowed to perform this operation', 16, 1) + +IF (@PackageID > 0) AND dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 +RAISERROR('You are not allowed to access this package', 16, 1) + +SELECT + NR.RecordID, + NR.ServiceID, + NR.ServerID, + NR.PackageID, + NR.RecordType, + NR.RecordName, + NR.RecordData, + NR.MXPriority, + NR.SrvPriority, + NR.SrvWeight, + NR.SrvPort, + NR.IPAddressID +FROM + GlobalDnsRecords AS NR +WHERE NR.RecordID = @RecordID +RETURN + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE GetDnsRecordsByGroup +( + @GroupID int +) +AS +SELECT + RGR.RecordID, + RGR.RecordOrder, + RGR.GroupID, + RGR.RecordType, + RGR.RecordName, + RGR.RecordData, + RGR.MXPriority +FROM + ResourceGroupDnsRecords AS RGR +WHERE RGR.GroupID = @GroupID +ORDER BY RGR.RecordOrder +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + + + +CREATE PROCEDURE [dbo].[GetDnsRecordsByPackage] +( + @ActorID int, + @PackageID int +) +AS + +-- check rights +IF dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 +RAISERROR('You are not allowed to access this package', 16, 1) + +SELECT + NR.RecordID, + NR.ServiceID, + NR.ServerID, + NR.PackageID, + NR.RecordType, + NR.RecordName, + NR.RecordData, + NR.MXPriority, + NR.SrvPriority, + NR.SrvWeight, + NR.SrvPort, + NR.IPAddressID, + CASE + WHEN NR.RecordType = 'A' AND NR.RecordData = '' THEN dbo.GetFullIPAddress(IP.ExternalIP, IP.InternalIP) + WHEN NR.RecordType = 'MX' THEN CONVERT(varchar(3), NR.MXPriority) + ', ' + NR.RecordData + WHEN NR.RecordType = 'SRV' THEN CONVERT(varchar(3), NR.SrvPort) + ', ' + NR.RecordData + ELSE NR.RecordData + END AS FullRecordData, + dbo.GetFullIPAddress(IP.ExternalIP, IP.InternalIP) AS IPAddress, + IP.ExternalIP, + IP.InternalIP +FROM + GlobalDnsRecords AS NR +LEFT OUTER JOIN IPAddresses AS IP ON NR.IPAddressID = IP.AddressID +WHERE NR.PackageID = @PackageID +RETURN + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + + + + + +CREATE PROCEDURE [dbo].[GetDnsRecordsByServer] +( + @ActorID int, + @ServerID int +) +AS + +SELECT + NR.RecordID, + NR.ServiceID, + NR.ServerID, + NR.PackageID, + NR.RecordType, + NR.RecordName, + NR.RecordData, + CASE + WHEN NR.RecordType = 'A' AND NR.RecordData = '' THEN dbo.GetFullIPAddress(IP.ExternalIP, IP.InternalIP) + WHEN NR.RecordType = 'MX' THEN CONVERT(varchar(3), NR.MXPriority) + ', ' + NR.RecordData + WHEN NR.RecordType = 'SRV' THEN CONVERT(varchar(3), NR.SrvPort) + ', ' + NR.RecordData + ELSE NR.RecordData + END AS FullRecordData, + NR.MXPriority, + NR.SrvPriority, + NR.SrvWeight, + NR.SrvPort, + NR.IPAddressID, + dbo.GetFullIPAddress(IP.ExternalIP, IP.InternalIP) AS IPAddress, + IP.ExternalIP, + IP.InternalIP +FROM + GlobalDnsRecords AS NR +LEFT OUTER JOIN IPAddresses AS IP ON NR.IPAddressID = IP.AddressID +WHERE + NR.ServerID = @ServerID +RETURN + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + + + + +CREATE PROCEDURE [dbo].[GetDnsRecordsByService] +( + @ActorID int, + @ServiceID int +) +AS + +SELECT + NR.RecordID, + NR.ServiceID, + NR.ServerID, + NR.PackageID, + NR.RecordType, + NR.RecordName, + CASE + WHEN NR.RecordType = 'A' AND NR.RecordData = '' THEN dbo.GetFullIPAddress(IP.ExternalIP, IP.InternalIP) + WHEN NR.RecordType = 'MX' THEN CONVERT(varchar(3), NR.MXPriority) + ', ' + NR.RecordData + WHEN NR.RecordType = 'SRV' THEN CONVERT(varchar(3), NR.SrvPort) + ', ' + NR.RecordData + ELSE NR.RecordData + END AS FullRecordData, + NR.RecordData, + NR.MXPriority, + NR.SrvPriority, + NR.SrvWeight, + NR.SrvPort, + NR.IPAddressID, + dbo.GetFullIPAddress(IP.ExternalIP, IP.InternalIP) AS IPAddress, + IP.ExternalIP, + IP.InternalIP +FROM + GlobalDnsRecords AS NR +LEFT OUTER JOIN IPAddresses AS IP ON NR.IPAddressID = IP.AddressID +WHERE + NR.ServiceID = @ServiceID +RETURN + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + +CREATE PROCEDURE [dbo].[GetDnsRecordsTotal] +( + @ActorID int, + @PackageID int +) +AS + +-- check rights +IF dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 +RAISERROR('You are not allowed to access this package', 16, 1) + +-- create temp table for DNS records +DECLARE @Records TABLE +( + RecordID int, + RecordType nvarchar(10) COLLATE Latin1_General_CI_AS, + RecordName nvarchar(50) COLLATE Latin1_General_CI_AS +) + +-- select PACKAGES DNS records +DECLARE @ParentPackageID int, @TmpPackageID int +SET @TmpPackageID = @PackageID + +WHILE 10 = 10 +BEGIN + + -- get DNS records for the current package + INSERT INTO @Records (RecordID, RecordType, RecordName) + SELECT + GR.RecordID, + GR.RecordType, + GR.RecordName + FROM GlobalDNSRecords AS GR + WHERE GR.PackageID = @TmpPackageID + AND GR.RecordType + GR.RecordName NOT IN (SELECT RecordType + RecordName FROM @Records) + + SET @ParentPackageID = NULL + + -- get parent package + SELECT + @ParentPackageID = ParentPackageID + FROM Packages + WHERE PackageID = @TmpPackageID + + IF @ParentPackageID IS NULL -- the last parent + BREAK + + SET @TmpPackageID = @ParentPackageID +END + +-- select VIRTUAL SERVER DNS records +DECLARE @ServerID int +SELECT @ServerID = ServerID FROM Packages +WHERE PackageID = @PackageID + +INSERT INTO @Records (RecordID, RecordType, RecordName) +SELECT + GR.RecordID, + GR.RecordType, + GR.RecordName +FROM GlobalDNSRecords AS GR +WHERE GR.ServerID = @ServerID +AND GR.RecordType + GR.RecordName NOT IN (SELECT RecordType + RecordName FROM @Records) + +-- select SERVER DNS records +INSERT INTO @Records (RecordID, RecordType, RecordName) +SELECT + GR.RecordID, + GR.RecordType, + GR.RecordName +FROM GlobalDNSRecords AS GR +WHERE GR.ServerID IN (SELECT + SRV.ServerID +FROM VirtualServices AS VS +INNER JOIN Services AS S ON VS.ServiceID = S.ServiceID +INNER JOIN Servers AS SRV ON S.ServerID = SRV.ServerID +WHERE VS.ServerID = @ServerID) +AND GR.RecordType + GR.RecordName NOT IN (SELECT RecordType + RecordName FROM @Records) + + + + + +-- select SERVICES DNS records +-- re-distribute package services +EXEC DistributePackageServices @ActorID, @PackageID + +--INSERT INTO @Records (RecordID, RecordType, RecordName) +--SELECT +-- GR.RecordID, +-- GR.RecordType, + -- GR.RecordName +-- FROM GlobalDNSRecords AS GR +-- WHERE GR.ServiceID IN (SELECT ServiceID FROM PackageServices WHERE PackageID = @PackageID) +-- AND GR.RecordType + GR.RecordName NOT IN (SELECT RecordType + RecordName FROM @Records) + + +SELECT + NR.RecordID, + NR.ServiceID, + NR.ServerID, + NR.PackageID, + NR.RecordType, + NR.RecordName, + NR.RecordData, + NR.MXPriority, + NR.SrvPriority, + NR.SrvWeight, + NR.SrvPort, + NR.IPAddressID, + ISNULL(IP.ExternalIP, '') AS ExternalIP, + ISNULL(IP.InternalIP, '') AS InternalIP, + CASE + WHEN NR.RecordType = 'A' AND NR.RecordData = '' THEN dbo.GetFullIPAddress(IP.ExternalIP, IP.InternalIP) + WHEN NR.RecordType = 'MX' THEN CONVERT(varchar(3), NR.MXPriority) + ', ' + NR.RecordData + WHEN NR.RecordType = 'SRV' THEN CONVERT(varchar(3), NR.SrvPort) + ', ' + NR.RecordData + ELSE NR.RecordData + END AS FullRecordData, + dbo.GetFullIPAddress(IP.ExternalIP, IP.InternalIP) AS IPAddress +FROM @Records AS TR +INNER JOIN GlobalDnsRecords AS NR ON TR.RecordID = NR.RecordID +LEFT OUTER JOIN IPAddresses AS IP ON NR.IPAddressID = IP.AddressID + +RETURN + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + +CREATE PROCEDURE [dbo].[GetDomain] +( + @ActorID int, + @DomainID int +) +AS + +SELECT + D.DomainID, + D.PackageID, + D.ZoneItemID, + D.DomainItemID, + D.DomainName, + D.HostingAllowed, + ISNULL(WS.ItemID, 0) AS WebSiteID, + WS.ItemName AS WebSiteName, + ISNULL(MD.ItemID, 0) AS MailDomainID, + MD.ItemName AS MailDomainName, + Z.ItemName AS ZoneName, + D.IsSubDomain, + D.IsInstantAlias, + D.IsDomainPointer +FROM Domains AS D +INNER JOIN Packages AS P ON D.PackageID = P.PackageID +LEFT OUTER JOIN ServiceItems AS WS ON D.WebSiteID = WS.ItemID +LEFT OUTER JOIN ServiceItems AS MD ON D.MailDomainID = MD.ItemID +LEFT OUTER JOIN ServiceItems AS Z ON D.ZoneItemID = Z.ItemID +WHERE + D.DomainID = @DomainID + AND dbo.CheckActorPackageRights(@ActorID, P.PackageID) = 1 +RETURN + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + +CREATE PROCEDURE [dbo].[GetDomainByName] +( + @ActorID int, + @DomainName nvarchar(100), + @SearchOnDomainPointer bit, + @IsDomainPointer bit +) +AS + +IF (@SearchOnDomainPointer = 1) +BEGIN + SELECT + D.DomainID, + D.PackageID, + D.ZoneItemID, + D.DomainItemID, + D.DomainName, + D.HostingAllowed, + ISNULL(D.WebSiteID, 0) AS WebSiteID, + WS.ItemName AS WebSiteName, + ISNULL(D.MailDomainID, 0) AS MailDomainID, + MD.ItemName AS MailDomainName, + Z.ItemName AS ZoneName, + D.IsSubDomain, + D.IsInstantAlias, + D.IsDomainPointer + FROM Domains AS D + INNER JOIN Packages AS P ON D.PackageID = P.PackageID + LEFT OUTER JOIN ServiceItems AS WS ON D.WebSiteID = WS.ItemID + LEFT OUTER JOIN ServiceItems AS MD ON D.MailDomainID = MD.ItemID + LEFT OUTER JOIN ServiceItems AS Z ON D.ZoneItemID = Z.ItemID + WHERE + D.DomainName = @DomainName + AND D.IsDomainPointer = @IsDomainPointer + AND dbo.CheckActorPackageRights(@ActorID, P.PackageID) = 1 + RETURN +END +ELSE +BEGIN + SELECT + D.DomainID, + D.PackageID, + D.ZoneItemID, + D.DomainItemID, + D.DomainName, + D.HostingAllowed, + ISNULL(D.WebSiteID, 0) AS WebSiteID, + WS.ItemName AS WebSiteName, + ISNULL(D.MailDomainID, 0) AS MailDomainID, + MD.ItemName AS MailDomainName, + Z.ItemName AS ZoneName, + D.IsSubDomain, + D.IsInstantAlias, + D.IsDomainPointer + FROM Domains AS D + INNER JOIN Packages AS P ON D.PackageID = P.PackageID + LEFT OUTER JOIN ServiceItems AS WS ON D.WebSiteID = WS.ItemID + LEFT OUTER JOIN ServiceItems AS MD ON D.MailDomainID = MD.ItemID + LEFT OUTER JOIN ServiceItems AS Z ON D.ZoneItemID = Z.ItemID + WHERE + D.DomainName = @DomainName + AND dbo.CheckActorPackageRights(@ActorID, P.PackageID) = 1 + RETURN +END + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + +CREATE PROCEDURE [dbo].[GetDomains] +( + @ActorID int, + @PackageID int, + @Recursive bit = 1 +) +AS + +-- check rights +IF dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 +RAISERROR('You are not allowed to access this package', 16, 1) + +SELECT + D.DomainID, + D.PackageID, + D.ZoneItemID, + D.DomainItemID, + D.DomainName, + D.HostingAllowed, + ISNULL(WS.ItemID, 0) AS WebSiteID, + WS.ItemName AS WebSiteName, + ISNULL(MD.ItemID, 0) AS MailDomainID, + MD.ItemName AS MailDomainName, + Z.ItemName AS ZoneName, + D.IsSubDomain, + D.IsInstantAlias, + D.IsDomainPointer +FROM Domains AS D +INNER JOIN PackagesTree(@PackageID, @Recursive) AS PT ON D.PackageID = PT.PackageID +LEFT OUTER JOIN ServiceItems AS WS ON D.WebSiteID = WS.ItemID +LEFT OUTER JOIN ServiceItems AS MD ON D.MailDomainID = MD.ItemID +LEFT OUTER JOIN ServiceItems AS Z ON D.ZoneItemID = Z.ItemID +RETURN + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO +CREATE PROCEDURE [dbo].[GetDomainsByDomainItemID] +( + @ActorID int, + @DomainID int +) +AS + +SELECT + D.DomainID, + D.PackageID, + D.ZoneItemID, + D.DomainItemID, + D.DomainName, + D.HostingAllowed, + ISNULL(D.WebSiteID, 0) AS WebSiteID, + WS.ItemName AS WebSiteName, + ISNULL(D.MailDomainID, 0) AS MailDomainID, + MD.ItemName AS MailDomainName, + Z.ItemName AS ZoneName, + D.IsSubDomain, + D.IsInstantAlias, + D.IsDomainPointer +FROM Domains AS D +INNER JOIN Packages AS P ON D.PackageID = P.PackageID +LEFT OUTER JOIN ServiceItems AS WS ON D.WebSiteID = WS.ItemID +LEFT OUTER JOIN ServiceItems AS MD ON D.MailDomainID = MD.ItemID +LEFT OUTER JOIN ServiceItems AS Z ON D.ZoneItemID = Z.ItemID +WHERE + D.DomainItemID = @DomainID + AND dbo.CheckActorPackageRights(@ActorID, P.PackageID) = 1 +RETURN +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + +CREATE PROCEDURE [dbo].[GetDomainsByZoneID] +( + @ActorID int, + @ZoneID int +) +AS + +SELECT + D.DomainID, + D.PackageID, + D.ZoneItemID, + D.DomainItemID, + D.DomainName, + D.HostingAllowed, + ISNULL(D.WebSiteID, 0) AS WebSiteID, + WS.ItemName AS WebSiteName, + ISNULL(D.MailDomainID, 0) AS MailDomainID, + MD.ItemName AS MailDomainName, + Z.ItemName AS ZoneName, + D.IsSubDomain, + D.IsInstantAlias, + D.IsDomainPointer +FROM Domains AS D +INNER JOIN Packages AS P ON D.PackageID = P.PackageID +LEFT OUTER JOIN ServiceItems AS WS ON D.WebSiteID = WS.ItemID +LEFT OUTER JOIN ServiceItems AS MD ON D.MailDomainID = MD.ItemID +LEFT OUTER JOIN ServiceItems AS Z ON D.ZoneItemID = Z.ItemID +WHERE + D.ZoneItemID = @ZoneID + AND dbo.CheckActorPackageRights(@ActorID, P.PackageID) = 1 +RETURN + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + +CREATE PROCEDURE [dbo].[GetDomainsPaged] +( + @ActorID int, + @PackageID int, + @ServerID int, + @Recursive bit, + @FilterColumn nvarchar(50) = '', + @FilterValue nvarchar(50) = '', + @SortColumn nvarchar(50), + @StartRow int, + @MaximumRows int +) +AS +SET NOCOUNT ON + +-- check rights +IF dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 +RAISERROR('You are not allowed to access this package', 16, 1) + +-- build query and run it to the temporary table +DECLARE @sql nvarchar(2000) + +IF @SortColumn = '' OR @SortColumn IS NULL +SET @SortColumn = 'DomainName' + +SET @sql = ' +DECLARE @Domains TABLE +( + ItemPosition int IDENTITY(1,1), + DomainID int +) +INSERT INTO @Domains (DomainID) +SELECT + D.DomainID +FROM Domains AS D +INNER JOIN Packages AS P ON D.PackageID = P.PackageID +INNER JOIN UsersDetailed AS U ON P.UserID = U.UserID +LEFT OUTER JOIN ServiceItems AS Z ON D.ZoneItemID = Z.ItemID +LEFT OUTER JOIN Services AS S ON Z.ServiceID = S.ServiceID +LEFT OUTER JOIN Servers AS SRV ON S.ServerID = SRV.ServerID +WHERE (D.IsInstantAlias = 0 AND D.IsDomainPointer = 0) AND + ((@Recursive = 0 AND D.PackageID = @PackageID) + OR (@Recursive = 1 AND dbo.CheckPackageParent(@PackageID, D.PackageID) = 1)) +AND (@ServerID = 0 OR (@ServerID > 0 AND S.ServerID = @ServerID)) +' + +IF @FilterColumn <> '' AND @FilterValue <> '' +SET @sql = @sql + ' AND ' + @FilterColumn + ' LIKE @FilterValue ' + +IF @SortColumn <> '' AND @SortColumn IS NOT NULL +SET @sql = @sql + ' ORDER BY ' + @SortColumn + ' ' + +SET @sql = @sql + ' SELECT COUNT(DomainID) FROM @Domains;SELECT + D.DomainID, + D.PackageID, + D.ZoneItemID, + D.DomainItemID, + D.DomainName, + D.HostingAllowed, + ISNULL(WS.ItemID, 0) AS WebSiteID, + WS.ItemName AS WebSiteName, + ISNULL(MD.ItemID, 0) AS MailDomainID, + MD.ItemName AS MailDomainName, + Z.ItemName AS ZoneName, + D.IsSubDomain, + D.IsInstantAlias, + D.IsDomainPointer, + + -- packages + P.PackageName, + + -- server + ISNULL(SRV.ServerID, 0) AS ServerID, + ISNULL(SRV.ServerName, '''') AS ServerName, + ISNULL(SRV.Comments, '''') AS ServerComments, + ISNULL(SRV.VirtualServer, 0) AS VirtualServer, + + -- user + P.UserID, + U.Username, + U.FirstName, + U.LastName, + U.FullName, + U.RoleID, + U.Email +FROM @Domains AS SD +INNER JOIN Domains AS D ON SD.DomainID = D.DomainID +INNER JOIN Packages AS P ON D.PackageID = P.PackageID +INNER JOIN UsersDetailed AS U ON P.UserID = U.UserID +LEFT OUTER JOIN ServiceItems AS WS ON D.WebSiteID = WS.ItemID +LEFT OUTER JOIN ServiceItems AS MD ON D.MailDomainID = MD.ItemID +LEFT OUTER JOIN ServiceItems AS Z ON D.ZoneItemID = Z.ItemID +LEFT OUTER JOIN Services AS S ON Z.ServiceID = S.ServiceID +LEFT OUTER JOIN Servers AS SRV ON S.ServerID = SRV.ServerID +WHERE SD.ItemPosition BETWEEN @StartRow + 1 AND @StartRow + @MaximumRows' + +exec sp_executesql @sql, N'@StartRow int, @MaximumRows int, @PackageID int, @FilterValue nvarchar(50), @ServerID int, @Recursive bit', +@StartRow, @MaximumRows, @PackageID, @FilterValue, @ServerID, @Recursive + + +RETURN + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + + + + + +CREATE PROCEDURE [dbo].[GetExchangeAccount] +( + @ItemID int, + @AccountID int +) +AS +SELECT + E.AccountID, + E.ItemID, + E.AccountType, + E.AccountName, + E.DisplayName, + E.PrimaryEmailAddress, + E.MailEnabledPublicFolder, + E.MailboxManagerActions, + E.SamAccountName, + E.AccountPassword, + E.MailboxPlanId, + P.MailboxPlan, + E.SubscriberNumber, + E.UserPrincipalName +FROM + ExchangeAccounts AS E +LEFT OUTER JOIN ExchangeMailboxPlans AS P ON E.MailboxPlanId = P.MailboxPlanId +WHERE + E.ItemID = @ItemID AND + E.AccountID = @AccountID +RETURN + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + +CREATE PROCEDURE [dbo].[GetExchangeAccountByAccountName] +( + @ItemID int, + @AccountName nvarchar(300) +) +AS +SELECT + E.AccountID, + E.ItemID, + E.AccountType, + E.AccountName, + E.DisplayName, + E.PrimaryEmailAddress, + E.MailEnabledPublicFolder, + E.MailboxManagerActions, + E.SamAccountName, + E.AccountPassword, + E.MailboxPlanId, + P.MailboxPlan, + E.SubscriberNumber, + E.UserPrincipalName +FROM + ExchangeAccounts AS E +LEFT OUTER JOIN ExchangeMailboxPlans AS P ON E.MailboxPlanId = P.MailboxPlanId +WHERE + E.ItemID = @ItemID AND + E.AccountName = @AccountName +RETURN + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + +CREATE PROCEDURE [dbo].[GetExchangeAccountByMailboxPlanId] +( + @ItemID int, + @MailboxPlanId int +) +AS + +IF (@MailboxPlanId < 0) +BEGIN +SELECT + E.AccountID, + E.ItemID, + E.AccountType, + E.AccountName, + E.DisplayName, + E.PrimaryEmailAddress, + E.MailEnabledPublicFolder, + E.MailboxManagerActions, + E.SamAccountName, + E.AccountPassword, + E.MailboxPlanId, + P.MailboxPlan, + E.SubscriberNumber, + E.UserPrincipalName +FROM + ExchangeAccounts AS E +LEFT OUTER JOIN ExchangeMailboxPlans AS P ON E.MailboxPlanId = P.MailboxPlanId +WHERE + E.ItemID = @ItemID AND + E.MailboxPlanId IS NULL AND + E.AccountType IN (1,5) +RETURN + +END +ELSE +IF (@ItemId = 0) +BEGIN +SELECT + E.AccountID, + E.ItemID, + E.AccountType, + E.AccountName, + E.DisplayName, + E.PrimaryEmailAddress, + E.MailEnabledPublicFolder, + E.MailboxManagerActions, + E.SamAccountName, + E.AccountPassword, + E.MailboxPlanId, + P.MailboxPlan, + E.SubscriberNumber, + E.UserPrincipalName +FROM + ExchangeAccounts AS E +LEFT OUTER JOIN ExchangeMailboxPlans AS P ON E.MailboxPlanId = P.MailboxPlanId +WHERE + E.MailboxPlanId = @MailboxPlanId AND + E.AccountType IN (1,5) +END +ELSE +BEGIN +SELECT + E.AccountID, + E.ItemID, + E.AccountType, + E.AccountName, + E.DisplayName, + E.PrimaryEmailAddress, + E.MailEnabledPublicFolder, + E.MailboxManagerActions, + E.SamAccountName, + E.AccountPassword, + E.MailboxPlanId, + P.MailboxPlan, + E.SubscriberNumber, + E.UserPrincipalName +FROM + ExchangeAccounts AS E +LEFT OUTER JOIN ExchangeMailboxPlans AS P ON E.MailboxPlanId = P.MailboxPlanId +WHERE + E.ItemID = @ItemID AND + E.MailboxPlanId = @MailboxPlanId AND + E.AccountType IN (1,5) +RETURN +END + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE GetExchangeAccountEmailAddresses +( + @AccountID int +) +AS +SELECT + AddressID, + AccountID, + EmailAddress +FROM + ExchangeAccountEmailAddresses +WHERE + AccountID = @AccountID +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[GetExchangeAccounts] +( + @ItemID int, + @AccountType int +) +AS +SELECT + E.AccountID, + E.ItemID, + E.AccountType, + E.AccountName, + E.DisplayName, + E.PrimaryEmailAddress, + E.MailEnabledPublicFolder, + E.MailboxPlanId, + P.MailboxPlan, + E.SubscriberNumber, + E.UserPrincipalName +FROM + ExchangeAccounts AS E +LEFT OUTER JOIN ExchangeMailboxPlans AS P ON E.MailboxPlanId = P.MailboxPlanId +WHERE + E.ItemID = @ItemID AND + (E.AccountType = @AccountType OR @AccountType IS NULL) +ORDER BY DisplayName +RETURN + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + + + + + +CREATE PROCEDURE [dbo].[GetExchangeAccountsPaged] +( + @ActorID int, + @ItemID int, + @AccountTypes nvarchar(30), + @FilterColumn nvarchar(50) = '', + @FilterValue nvarchar(50) = '', + @SortColumn nvarchar(50), + @StartRow int, + @MaximumRows int +) +AS + +DECLARE @PackageID int +SELECT @PackageID = PackageID FROM ServiceItems +WHERE ItemID = @ItemID + +-- check rights +IF dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 +RAISERROR('You are not allowed to access this package', 16, 1) + +-- start +DECLARE @condition nvarchar(700) +SET @condition = ' +EA.AccountType IN (' + @AccountTypes + ') +AND EA.ItemID = @ItemID +' + +IF @FilterColumn <> '' AND @FilterColumn IS NOT NULL +AND @FilterValue <> '' AND @FilterValue IS NOT NULL +BEGIN + IF @FilterColumn = 'PrimaryEmailAddress' AND @AccountTypes <> '2' + BEGIN + SET @condition = @condition + ' AND EA.AccountID IN (SELECT EAEA.AccountID FROM ExchangeAccountEmailAddresses EAEA WHERE EAEA.EmailAddress LIKE ''' + @FilterValue + ''')' + END + ELSE + BEGIN + SET @condition = @condition + ' AND ' + @FilterColumn + ' LIKE ''' + @FilterValue + '''' + END +END + +IF @SortColumn IS NULL OR @SortColumn = '' +SET @SortColumn = 'EA.DisplayName ASC' + +DECLARE @joincondition nvarchar(700) + SET @joincondition = ',P.MailboxPlan FROM ExchangeAccounts AS EA + LEFT OUTER JOIN ExchangeMailboxPlans AS P ON EA.MailboxPlanId = P.MailboxPlanId' + +DECLARE @sql nvarchar(3500) + +set @sql = ' +SELECT COUNT(EA.AccountID) FROM ExchangeAccounts AS EA +WHERE ' + @condition + '; + +WITH Accounts AS ( + SELECT ROW_NUMBER() OVER (ORDER BY ' + @SortColumn + ') as Row, + EA.AccountID, + EA.ItemID, + EA.AccountType, + EA.AccountName, + EA.DisplayName, + EA.PrimaryEmailAddress, + EA.MailEnabledPublicFolder, + EA.MailboxPlanId, + EA.SubscriberNumber, + EA.UserPrincipalName ' + @joincondition + + ' WHERE ' + @condition + ' +) + +SELECT * FROM Accounts +WHERE Row BETWEEN @StartRow + 1 and @StartRow + @MaximumRows +' + +print @sql + +exec sp_executesql @sql, N'@ItemID int, @StartRow int, @MaximumRows int', +@ItemID, @StartRow, @MaximumRows + +RETURN + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + + + + +CREATE PROCEDURE [dbo].[GetExchangeMailboxes] + @ItemID int +AS +BEGIN +SELECT + AccountID, + ItemID, + AccountType, + AccountName, + DisplayName, + PrimaryEmailAddress, + MailEnabledPublicFolder, + SubscriberNumber, + UserPrincipalName +FROM + ExchangeAccounts +WHERE + ItemID = @ItemID AND + (AccountType =1 OR AccountType=5 OR AccountType=6) +ORDER BY 1 + +END + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + +CREATE PROCEDURE [dbo].[GetExchangeMailboxPlan] +( + @MailboxPlanId int +) +AS +SELECT + MailboxPlanId, + ItemID, + MailboxPlan, + EnableActiveSync, + EnableIMAP, + EnableMAPI, + EnableOWA, + EnablePOP, + IsDefault, + IssueWarningPct, + KeepDeletedItemsDays, + MailboxSizeMB, + MaxReceiveMessageSizeKB, + MaxRecipients, + MaxSendMessageSizeKB, + ProhibitSendPct, + ProhibitSendReceivePct, + HideFromAddressBook, + MailboxPlanType +FROM + ExchangeMailboxPlans +WHERE + MailboxPlanId = @MailboxPlanId +RETURN + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + + + +CREATE PROCEDURE [dbo].[GetExchangeMailboxPlans] +( + @ItemID int +) +AS +SELECT + MailboxPlanId, + ItemID, + MailboxPlan, + EnableActiveSync, + EnableIMAP, + EnableMAPI, + EnableOWA, + EnablePOP, + IsDefault, + IssueWarningPct, + KeepDeletedItemsDays, + MailboxSizeMB, + MaxReceiveMessageSizeKB, + MaxRecipients, + MaxSendMessageSizeKB, + ProhibitSendPct, + ProhibitSendReceivePct, + HideFromAddressBook, + MailboxPlanType +FROM + ExchangeMailboxPlans +WHERE + ItemID = @ItemID +ORDER BY MailboxPlan +RETURN + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO +CREATE PROCEDURE [dbo].[GetExchangeOrganization] +( + @ItemID int +) +AS +SELECT + ItemID, + ExchangeMailboxPlanID, + LyncUserPlanID +FROM + ExchangeOrganizations +WHERE + ItemID = @ItemID +RETURN +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + +CREATE PROCEDURE [dbo].[GetExchangeOrganizationDomains] +( + @ItemID int +) +AS +SELECT + ED.DomainID, + D.DomainName, + ED.IsHost, + ED.DomainTypeID +FROM + ExchangeOrganizationDomains AS ED +INNER JOIN Domains AS D ON ED.DomainID = D.DomainID +WHERE ED.ItemID = @ItemID +RETURN + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[GetExchangeOrganizationStatistics] +( + @ItemID int +) +AS + +IF -1 IN (SELECT B.MailboxSizeMB FROM ExchangeAccounts AS A INNER JOIN ExchangeMailboxPlans AS B ON A.MailboxPlanId = B.MailboxPlanId WHERE A.ItemID=@ItemID) +BEGIN +SELECT + (SELECT COUNT(*) FROM ExchangeAccounts WHERE (AccountType = 1 OR AccountType = 5 OR AccountType = 6) AND ItemID = @ItemID) AS CreatedMailboxes, + (SELECT COUNT(*) FROM ExchangeAccounts WHERE AccountType = 2 AND ItemID = @ItemID) AS CreatedContacts, + (SELECT COUNT(*) FROM ExchangeAccounts WHERE AccountType = 3 AND ItemID = @ItemID) AS CreatedDistributionLists, + (SELECT COUNT(*) FROM ExchangeAccounts WHERE AccountType = 4 AND ItemID = @ItemID) AS CreatedPublicFolders, + (SELECT COUNT(*) FROM ExchangeOrganizationDomains WHERE ItemID = @ItemID) AS CreatedDomains, + (SELECT MIN(B.MailboxSizeMB) FROM ExchangeAccounts AS A INNER JOIN ExchangeMailboxPlans AS B ON A.MailboxPlanId = B.MailboxPlanId WHERE A.ItemID=@ItemID) AS UsedDiskSpace +END +ELSE +BEGIN +SELECT + (SELECT COUNT(*) FROM ExchangeAccounts WHERE (AccountType = 1 OR AccountType = 5 OR AccountType = 6) AND ItemID = @ItemID) AS CreatedMailboxes, + (SELECT COUNT(*) FROM ExchangeAccounts WHERE AccountType = 2 AND ItemID = @ItemID) AS CreatedContacts, + (SELECT COUNT(*) FROM ExchangeAccounts WHERE AccountType = 3 AND ItemID = @ItemID) AS CreatedDistributionLists, + (SELECT COUNT(*) FROM ExchangeAccounts WHERE AccountType = 4 AND ItemID = @ItemID) AS CreatedPublicFolders, + (SELECT COUNT(*) FROM ExchangeOrganizationDomains WHERE ItemID = @ItemID) AS CreatedDomains, + (SELECT SUM(B.MailboxSizeMB) FROM ExchangeAccounts AS A INNER JOIN ExchangeMailboxPlans AS B ON A.MailboxPlanId = B.MailboxPlanId WHERE A.ItemID=@ItemID) AS UsedDiskSpace +END + + +RETURN + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE GetGroupProviders +( + @GroupID int +) +AS +SELECT + PROV.ProviderID, + PROV.GroupID, + PROV.ProviderName, + PROV.DisplayName, + PROV.ProviderType, + RG.GroupName + ' - ' + PROV.DisplayName AS ProviderName +FROM Providers AS PROV +INNER JOIN ResourceGroups AS RG ON PROV.GroupID = RG.GroupID +WHERE RG.GroupID = @GroupId +ORDER BY RG.GroupOrder, PROV.DisplayName +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[GetHostingAddons] +( + @ActorID int, + @UserID int +) +AS + +-- check rights +IF dbo.CheckActorUserRights(@ActorID, @UserID) = 0 +RAISERROR('You are not allowed to access this account', 16, 1) + +SELECT + PlanID, + UserID, + PackageID, + PlanName, + PlanDescription, + Available, + SetupPrice, + RecurringPrice, + RecurrenceLength, + RecurrenceUnit, + IsAddon, + (SELECT COUNT(P.PackageID) FROM PackageAddons AS P WHERE P.PlanID = HP.PlanID) AS PackagesNumber +FROM + HostingPlans AS HP +WHERE + UserID = @UserID + AND IsAddon = 1 +ORDER BY PlanName +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE GetHostingPlan +( + @ActorID int, + @PlanID int +) +AS + +SELECT + PlanID, + UserID, + PackageID, + ServerID, + PlanName, + PlanDescription, + Available, + SetupPrice, + RecurringPrice, + RecurrenceLength, + RecurrenceUnit, + IsAddon +FROM HostingPlans AS HP +WHERE HP.PlanID = @PlanID + +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[GetHostingPlanQuotas] +( + @ActorID int, + @PlanID int, + @PackageID int, + @ServerID int +) +AS + +-- check rights +IF dbo.CheckActorParentPackageRights(@ActorID, @PackageID) = 0 +RAISERROR('You are not allowed to access this package', 16, 1) + +DECLARE @IsAddon bit + +IF @ServerID = 0 +SELECT @ServerID = ServerID FROM Packages +WHERE PackageID = @PackageID + +-- get resource groups +SELECT + RG.GroupID, + RG.GroupName, + CASE + WHEN HPR.CalculateDiskSpace IS NULL THEN CAST(0 as bit) + ELSE CAST(1 as bit) + END AS Enabled, + dbo.GetPackageAllocatedResource(@PackageID, RG.GroupID, @ServerID) AS ParentEnabled, + ISNULL(HPR.CalculateDiskSpace, 1) AS CalculateDiskSpace, + ISNULL(HPR.CalculateBandwidth, 1) AS CalculateBandwidth +FROM ResourceGroups AS RG +LEFT OUTER JOIN HostingPlanResources AS HPR ON RG.GroupID = HPR.GroupID AND HPR.PlanID = @PlanID +WHERE (RG.ShowGroup = 1) +ORDER BY RG.GroupOrder + +-- get quotas by groups +SELECT + Q.QuotaID, + Q.GroupID, + Q.QuotaName, + Q.QuotaDescription, + Q.QuotaTypeID, + ISNULL(HPQ.QuotaValue, 0) AS QuotaValue, + dbo.GetPackageAllocatedQuota(@PackageID, Q.QuotaID) AS ParentQuotaValue +FROM Quotas AS Q +LEFT OUTER JOIN HostingPlanQuotas AS HPQ ON Q.QuotaID = HPQ.QuotaID AND HPQ.PlanID = @PlanID +WHERE Q.HideQuota IS NULL OR Q.HideQuota = 0 +ORDER BY Q.QuotaOrder +RETURN + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[GetHostingPlans] +( + @ActorID int, + @UserID int +) +AS + +-- check rights +IF dbo.CheckActorUserRights(@ActorID, @UserID) = 0 +RAISERROR('You are not allowed to access this account', 16, 1) + +SELECT + HP.PlanID, + HP.UserID, + HP.PackageID, + HP.PlanName, + HP.PlanDescription, + HP.Available, + HP.SetupPrice, + HP.RecurringPrice, + HP.RecurrenceLength, + HP.RecurrenceUnit, + HP.IsAddon, + + (SELECT COUNT(P.PackageID) FROM Packages AS P WHERE P.PlanID = HP.PlanID) AS PackagesNumber, + + -- server + ISNULL(HP.ServerID, 0) AS ServerID, + ISNULL(S.ServerName, 'None') AS ServerName, + ISNULL(S.Comments, '') AS ServerComments, + ISNULL(S.VirtualServer, 1) AS VirtualServer, + + -- package + ISNULL(HP.PackageID, 0) AS PackageID, + ISNULL(P.PackageName, 'None') AS PackageName + +FROM HostingPlans AS HP +LEFT OUTER JOIN Servers AS S ON HP.ServerID = S.ServerID +LEFT OUTER JOIN Packages AS P ON HP.PackageID = P.PackageID +WHERE + HP.UserID = @UserID + AND HP.IsAddon = 0 +ORDER BY HP.PlanName +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + +CREATE PROCEDURE [dbo].[GetInstanceID] + @AccountID int +AS +BEGIN + SET NOCOUNT ON; + + SELECT InstanceID FROM OCSUsers WHERE AccountID = @AccountID +END + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[GetIPAddress] +( + @AddressID int +) +AS +BEGIN + + -- select + SELECT + AddressID, + ServerID, + ExternalIP, + InternalIP, + PoolID, + SubnetMask, + DefaultGateway, + Comments + FROM IPAddresses + WHERE + AddressID = @AddressID + + RETURN +END + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[GetIPAddresses] +( + @ActorID int, + @PoolID int, + @ServerID int +) +AS +BEGIN + +-- check rights +DECLARE @IsAdmin bit +SET @IsAdmin = dbo.CheckIsUserAdmin(@ActorID) + +SELECT + IP.AddressID, + IP.PoolID, + IP.ExternalIP, + IP.InternalIP, + IP.SubnetMask, + IP.DefaultGateway, + IP.Comments, + + IP.ServerID, + S.ServerName, + + PA.ItemID, + SI.ItemName, + + PA.PackageID, + P.PackageName, + + P.UserID, + U.UserName +FROM dbo.IPAddresses AS IP +LEFT JOIN Servers AS S ON IP.ServerID = S.ServerID +LEFT JOIN PackageIPAddresses AS PA ON IP.AddressID = PA.AddressID +LEFT JOIN ServiceItems SI ON PA.ItemId = SI.ItemID +LEFT JOIN dbo.Packages P ON PA.PackageID = P.PackageID +LEFT JOIN dbo.Users U ON U.UserID = P.UserID +WHERE @IsAdmin = 1 +AND (@PoolID = 0 OR @PoolID <> 0 AND IP.PoolID = @PoolID) + +AND (@ServerID = 0 OR @ServerID <> 0 AND IP.ServerID = @ServerID) + +END + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[GetIPAddressesPaged] +( + @ActorID int, + @PoolID int, + @ServerID int, + @FilterColumn nvarchar(50) = '', + @FilterValue nvarchar(50) = '', + @SortColumn nvarchar(50), + @StartRow int, + @MaximumRows int +) +AS +BEGIN + +-- check rights +DECLARE @IsAdmin bit +SET @IsAdmin = dbo.CheckIsUserAdmin(@ActorID) + +-- start +DECLARE @condition nvarchar(700) +SET @condition = ' +@IsAdmin = 1 +AND (@PoolID = 0 OR @PoolID <> 0 AND IP.PoolID = @PoolID) +AND (@ServerID = 0 OR @ServerID <> 0 AND IP.ServerID = @ServerID) +' + +IF @FilterColumn <> '' AND @FilterColumn IS NOT NULL +AND @FilterValue <> '' AND @FilterValue IS NOT NULL +SET @condition = @condition + ' AND ' + @FilterColumn + ' LIKE ''' + @FilterValue + '''' + +IF @SortColumn IS NULL OR @SortColumn = '' +SET @SortColumn = 'IP.ExternalIP ASC' + +DECLARE @sql nvarchar(3500) + +set @sql = ' +SELECT COUNT(IP.AddressID) +FROM dbo.IPAddresses AS IP +LEFT JOIN Servers AS S ON IP.ServerID = S.ServerID +LEFT JOIN PackageIPAddresses AS PA ON IP.AddressID = PA.AddressID +LEFT JOIN ServiceItems SI ON PA.ItemId = SI.ItemID +LEFT JOIN dbo.Packages P ON PA.PackageID = P.PackageID +LEFT JOIN dbo.Users U ON P.UserID = U.UserID +WHERE ' + @condition + ' + +DECLARE @Addresses AS TABLE +( + AddressID int +); + +WITH TempItems AS ( + SELECT ROW_NUMBER() OVER (ORDER BY ' + @SortColumn + ') as Row, + IP.AddressID + FROM dbo.IPAddresses AS IP + LEFT JOIN Servers AS S ON IP.ServerID = S.ServerID + LEFT JOIN PackageIPAddresses AS PA ON IP.AddressID = PA.AddressID + LEFT JOIN ServiceItems SI ON PA.ItemId = SI.ItemID + LEFT JOIN dbo.Packages P ON PA.PackageID = P.PackageID + LEFT JOIN dbo.Users U ON U.UserID = P.UserID + WHERE ' + @condition + ' +) + +INSERT INTO @Addresses +SELECT AddressID FROM TempItems +WHERE TempItems.Row BETWEEN @StartRow + 1 and @StartRow + @MaximumRows + +SELECT + IP.AddressID, + IP.PoolID, + IP.ExternalIP, + IP.InternalIP, + IP.SubnetMask, + IP.DefaultGateway, + IP.Comments, + + IP.ServerID, + S.ServerName, + + PA.ItemID, + SI.ItemName, + + PA.PackageID, + P.PackageName, + + P.UserID, + U.UserName +FROM @Addresses AS TA +INNER JOIN dbo.IPAddresses AS IP ON TA.AddressID = IP.AddressID +LEFT JOIN Servers AS S ON IP.ServerID = S.ServerID +LEFT JOIN PackageIPAddresses AS PA ON IP.AddressID = PA.AddressID +LEFT JOIN ServiceItems SI ON PA.ItemId = SI.ItemID +LEFT JOIN dbo.Packages P ON PA.PackageID = P.PackageID +LEFT JOIN dbo.Users U ON U.UserID = P.UserID +' + +exec sp_executesql @sql, N'@IsAdmin bit, @PoolID int, @ServerID int, @StartRow int, @MaximumRows int', +@IsAdmin, @PoolID, @ServerID, @StartRow, @MaximumRows + +END + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + +CREATE PROCEDURE [dbo].[GetItemIdByOrganizationId] + @OrganizationId nvarchar(128) +AS +BEGIN + SET NOCOUNT ON; + + SELECT + ItemID + FROM + dbo.ExchangeOrganizations + WHERE + OrganizationId = @OrganizationId +END + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + + + + + + +CREATE PROCEDURE [dbo].[GetItemIPAddresses] +( + @ActorID int, + @ItemID int, + @PoolID int +) +AS + +SELECT + PIP.PackageAddressID AS AddressID, + IP.ExternalIP AS IPAddress, + IP.InternalIP AS NATAddress, + IP.SubnetMask, + IP.DefaultGateway, + PIP.IsPrimary +FROM PackageIPAddresses AS PIP +INNER JOIN IPAddresses AS IP ON PIP.AddressID = IP.AddressID +INNER JOIN ServiceItems AS SI ON PIP.ItemID = SI.ItemID +WHERE PIP.ItemID = @ItemID +AND dbo.CheckActorPackageRights(@ActorID, SI.PackageID) = 1 +AND (@PoolID = 0 OR @PoolID <> 0 AND IP.PoolID = @PoolID) +ORDER BY PIP.IsPrimary DESC + +RETURN + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[GetItemPrivateIPAddresses] +( + @ActorID int, + @ItemID int +) +AS + +SELECT + PIP.PrivateAddressID AS AddressID, + PIP.IPAddress, + PIP.IsPrimary +FROM PrivateIPAddresses AS PIP +INNER JOIN ServiceItems AS SI ON PIP.ItemID = SI.ItemID +WHERE PIP.ItemID = @ItemID +AND dbo.CheckActorPackageRights(@ActorID, SI.PackageID) = 1 +ORDER BY PIP.IsPrimary DESC + +RETURN + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + +CREATE PROCEDURE [dbo].[GetLyncUserPlan] +( + @LyncUserPlanId int +) +AS +SELECT + LyncUserPlanId, + ItemID, + LyncUserPlanName, + LyncUserPlanType, + IM, + Mobility, + MobilityEnableOutsideVoice, + Federation, + Conferencing, + EnterpriseVoice, + VoicePolicy, + IsDefault +FROM + LyncUserPlans +WHERE + LyncUserPlanId = @LyncUserPlanId +RETURN + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + + +CREATE PROCEDURE [dbo].[GetLyncUserPlanByAccountId] +( + @AccountID int +) +AS +SELECT + LyncUserPlanId, + ItemID, + LyncUserPlanName, + LyncUserPlanType, + IM, + Mobility, + MobilityEnableOutsideVoice, + Federation, + Conferencing, + EnterpriseVoice, + VoicePolicy, + IsDefault +FROM + LyncUserPlans +WHERE + LyncUserPlanId IN (SELECT LyncUserPlanId FROM LyncUsers WHERE AccountID = @AccountID) +RETURN + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + +CREATE PROCEDURE [dbo].[GetLyncUserPlans] +( + @ItemID int +) +AS +SELECT + LyncUserPlanId, + ItemID, + LyncUserPlanName, + LyncUserPlanType, + IM, + Mobility, + MobilityEnableOutsideVoice, + Federation, + Conferencing, + EnterpriseVoice, + VoicePolicy, + IsDefault +FROM + LyncUserPlans +WHERE + ItemID = @ItemID +ORDER BY LyncUserPlanName +RETURN + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + +CREATE PROCEDURE [dbo].[GetLyncUsers] +( + @ItemID int, + @SortColumn nvarchar(40), + @SortDirection nvarchar(20), + @StartRow int, + @Count int +) +AS + +CREATE TABLE #TempLyncUsers +( + [ID] [int] IDENTITY(1,1) NOT NULL, + [AccountID] [int], + [ItemID] [int] NOT NULL, + [AccountName] [nvarchar](300) NOT NULL, + [DisplayName] [nvarchar](300) NOT NULL, + [UserPrincipalName] [nvarchar](300) NULL, + [SipAddress] [nvarchar](300) NULL, + [SamAccountName] [nvarchar](100) NULL, + [LyncUserPlanId] [int] NOT NULL, + [LyncUserPlanName] [nvarchar] (300) NOT NULL, +) + + +DECLARE @condition nvarchar(700) +SET @condition = '' + +IF (@SortColumn = 'DisplayName') +BEGIN + SET @condition = 'ORDER BY ea.DisplayName' +END + +IF (@SortColumn = 'UserPrincipalName') +BEGIN + SET @condition = 'ORDER BY ea.UserPrincipalName' +END + +IF (@SortColumn = 'SipAddress') +BEGIN + SET @condition = 'ORDER BY ou.SipAddress' +END + + +IF (@SortColumn = 'LyncUserPlanName') +BEGIN + SET @condition = 'ORDER BY lp.LyncUserPlanName' +END + +DECLARE @sql nvarchar(3500) + +set @sql = '' + INSERT INTO + #TempLyncUsers + SELECT + ea.AccountID, + ea.ItemID, + ea.AccountName, + ea.DisplayName, + ea.UserPrincipalName, + ou.SipAddress, + ea.SamAccountName, + ou.LyncUserPlanId, + lp.LyncUserPlanName + FROM + ExchangeAccounts ea + INNER JOIN + LyncUsers ou + INNER JOIN + LyncUserPlans lp + ON + ou.LyncUserPlanId = lp.LyncUserPlanId + ON + ea.AccountID = ou.AccountID + WHERE + ea.ItemID = @ItemID + @condition + +exec sp_executesql @sql, N'@ItemID int',@ItemID + +DECLARE @RetCount int +SELECT @RetCount = COUNT(ID) FROM #TempLyncUsers + +IF (@SortDirection = 'ASC') +BEGIN + SELECT * FROM #TempLyncUsers + WHERE ID > @StartRow AND ID <= (@StartRow + @Count) +END +ELSE +BEGIN + IF @SortColumn <> '' AND @SortColumn IS NOT NULL + BEGIN + IF (@SortColumn = 'DisplayName') + BEGIN + SELECT * FROM #TempLyncUsers + WHERE ID >@RetCount - @Count - @StartRow AND ID <= @RetCount- @StartRow ORDER BY DisplayName DESC + END + IF (@SortColumn = 'UserPrincipalName') + BEGIN + SELECT * FROM #TempLyncUsers + WHERE ID >@RetCount - @Count - @StartRow AND ID <= @RetCount- @StartRow ORDER BY UserPrincipalName DESC + END + + IF (@SortColumn = 'SipAddress') + BEGIN + SELECT * FROM #TempLyncUsers + WHERE ID >@RetCount - @Count - @StartRow AND ID <= @RetCount- @StartRow ORDER BY SipAddress DESC + END + + IF (@SortColumn = 'LyncUserPlanName') + BEGIN + SELECT * FROM #TempLyncUsers + WHERE ID >@RetCount - @Count - @StartRow AND ID <= @RetCount- @StartRow ORDER BY LyncUserPlanName DESC + END + END + ELSE + BEGIN + SELECT * FROM #TempLyncUsers + WHERE ID >@RetCount - @Count - @StartRow AND ID <= @RetCount- @StartRow ORDER BY UserPrincipalName DESC + END + + +END + +DROP TABLE #TempLyncUsers + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + + +CREATE PROCEDURE [dbo].[GetLyncUsersByPlanId] +( + @ItemID int, + @PlanId int +) +AS + + SELECT + ea.AccountID, + ea.ItemID, + ea.AccountName, + ea.DisplayName, + ea.UserPrincipalName, + ea.SamAccountName, + ou.LyncUserPlanId, + lp.LyncUserPlanName + FROM + ExchangeAccounts ea + INNER JOIN + LyncUsers ou + INNER JOIN + LyncUserPlans lp + ON + ou.LyncUserPlanId = lp.LyncUserPlanId + ON + ea.AccountID = ou.AccountID + WHERE + ea.ItemID = @ItemID AND + ou.LyncUserPlanId = @PlanId + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + +CREATE PROCEDURE [dbo].[GetLyncUsersCount] +( + @ItemID int +) +AS + +SELECT + COUNT(ea.AccountID) +FROM + ExchangeAccounts ea +INNER JOIN + LyncUsers ou +ON + ea.AccountID = ou.AccountID +WHERE + ea.ItemID = @ItemID + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + +CREATE PROCEDURE GetMyPackages +( + @ActorID int, + @UserID int +) +AS + +-- check rights +IF dbo.CheckActorUserRights(@ActorID, @UserID) = 0 +RAISERROR('You are not allowed to access this account', 16, 1) + +SELECT + P.PackageID, + P.ParentPackageID, + P.PackageName, + P.StatusID, + P.PlanID, + P.PurchaseDate, + + dbo.GetItemComments(P.PackageID, 'PACKAGE', @ActorID) AS Comments, + + -- server + ISNULL(P.ServerID, 0) AS ServerID, + ISNULL(S.ServerName, 'None') AS ServerName, + ISNULL(S.Comments, '') AS ServerComments, + ISNULL(S.VirtualServer, 1) AS VirtualServer, + + -- hosting plan + HP.PlanName, + + -- user + P.UserID, + U.Username, + U.FirstName, + U.LastName, + U.FullName, + U.RoleID, + U.Email +FROM Packages AS P +INNER JOIN UsersDetailed AS U ON P.UserID = U.UserID +LEFT OUTER JOIN Servers AS S ON P.ServerID = S.ServerID +LEFT OUTER JOIN HostingPlans AS HP ON P.PlanID = HP.PlanID +WHERE P.UserID = @UserID +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[GetNestedPackagesPaged] +( + @ActorID int, + @PackageID int, + @FilterColumn nvarchar(50) = '', + @FilterValue nvarchar(50) = '', + @StatusID int, + @PlanID int, + @ServerID int, + @SortColumn nvarchar(50), + @StartRow int, + @MaximumRows int +) +AS + +-- build query and run it to the temporary table +DECLARE @sql nvarchar(2000) + +SET @sql = ' +IF dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 +RAISERROR(''You are not allowed to access this package'', 16, 1) + +DECLARE @EndRow int +SET @EndRow = @StartRow + @MaximumRows +DECLARE @Packages TABLE +( + ItemPosition int IDENTITY(1,1), + PackageID int +) +INSERT INTO @Packages (PackageID) +SELECT + P.PackageID +FROM Packages AS P +INNER JOIN UsersDetailed AS U ON P.UserID = U.UserID +INNER JOIN Servers AS S ON P.ServerID = S.ServerID +INNER JOIN HostingPlans AS HP ON P.PlanID = HP.PlanID +WHERE + P.ParentPackageID = @PackageID + AND ((@StatusID = 0) OR (@StatusID > 0 AND P.StatusID = @StatusID)) + AND ((@PlanID = 0) OR (@PlanID > 0 AND P.PlanID = @PlanID)) + AND ((@ServerID = 0) OR (@ServerID > 0 AND P.ServerID = @ServerID)) ' + +IF @FilterColumn <> '' AND @FilterValue <> '' +SET @sql = @sql + ' AND ' + @FilterColumn + ' LIKE @FilterValue ' + +IF @SortColumn <> '' AND @SortColumn IS NOT NULL +SET @sql = @sql + ' ORDER BY ' + @SortColumn + ' ' + +SET @sql = @sql + ' SELECT COUNT(PackageID) FROM @Packages; +SELECT + P.PackageID, + P.PackageName, + P.StatusID, + P.PurchaseDate, + + dbo.GetItemComments(P.PackageID, ''PACKAGE'', @ActorID) AS Comments, + + -- server + P.ServerID, + ISNULL(S.ServerName, ''None'') AS ServerName, + ISNULL(S.Comments, '''') AS ServerComments, + ISNULL(S.VirtualServer, 1) AS VirtualServer, + + -- hosting plan + P.PlanID, + HP.PlanName, + + -- user + P.UserID, + U.Username, + U.FirstName, + U.LastName, + U.FullName, + U.RoleID, + U.Email +FROM @Packages AS TP +INNER JOIN Packages AS P ON TP.PackageID = P.PackageID +INNER JOIN UsersDetailed AS U ON P.UserID = U.UserID +INNER JOIN Servers AS S ON P.ServerID = S.ServerID +INNER JOIN HostingPlans AS HP ON P.PlanID = HP.PlanID +WHERE TP.ItemPosition BETWEEN @StartRow AND @EndRow' + +exec sp_executesql @sql, N'@StartRow int, @MaximumRows int, @PackageID int, @FilterValue nvarchar(50), @ActorID int, @StatusID int, @PlanID int, @ServerID int', +@StartRow, @MaximumRows, @PackageID, @FilterValue, @ActorID, @StatusID, @PlanID, @ServerID + + +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE GetNestedPackagesSummary +( + @ActorID int, + @PackageID int +) +AS +-- check rights +IF dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 +RAISERROR('You are not allowed to access this package', 16, 1) + +-- ALL spaces +SELECT COUNT(PackageID) AS PackagesNumber FROM Packages +WHERE ParentPackageID = @PackageID + +-- BY STATUS spaces +SELECT StatusID, COUNT(PackageID) AS PackagesNumber FROM Packages +WHERE ParentPackageID = @PackageID AND StatusID > 0 +GROUP BY StatusID +ORDER BY StatusID + +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE GetNextSchedule +AS + +-- find next schedule +DECLARE @ScheduleID int +DECLARE @TaskID nvarchar(100) +SELECT TOP 1 + @ScheduleID = ScheduleID, + @TaskID = TaskID +FROM Schedule AS S +WHERE Enabled = 1 +ORDER BY NextRun ASC + +-- select schedule +SELECT TOP 1 + S.ScheduleID, + S.TaskID, + S.PackageID, + S.ScheduleName, + S.ScheduleTypeID, + S.Interval, + S.FromTime, + S.ToTime, + S.StartTime, + S.LastRun, + S.NextRun, + S.Enabled, + S.HistoriesNumber, + S.PriorityID, + S.MaxExecutionTime, + S.WeekMonthDay, + 1 AS StatusID +FROM Schedule AS S +WHERE S.ScheduleID = @ScheduleID +ORDER BY NextRun ASC + +-- select task +SELECT + TaskID, + TaskType, + RoleID +FROM ScheduleTasks +WHERE TaskID = @TaskID + +-- select schedule parameters +SELECT + S.ScheduleID, + STP.ParameterID, + STP.DataTypeID, + ISNULL(SP.ParameterValue, STP.DefaultValue) AS ParameterValue +FROM Schedule AS S +INNER JOIN ScheduleTaskParameters AS STP ON S.TaskID = STP.TaskID +LEFT OUTER JOIN ScheduleParameters AS SP ON STP.ParameterID = SP.ParameterID AND SP.ScheduleID = S.ScheduleID +WHERE S.ScheduleID = @ScheduleID +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + + + + + +CREATE PROCEDURE [dbo].[GetOCSUsers] +( + @ItemID int, + @SortColumn nvarchar(40), + @SortDirection nvarchar(20), + @Name nvarchar(400), + @Email nvarchar(400), + @StartRow int, + @Count int +) +AS + +IF (@Name IS NULL) +BEGIN + SET @Name = '%' +END + +IF (@Email IS NULL) +BEGIN + SET @Email = '%' +END + +CREATE TABLE #TempOCSUsers +( + [ID] [int] IDENTITY(1,1) NOT NULL, + [AccountID] [int], + [ItemID] [int] NOT NULL, + [AccountName] [nvarchar](300) NOT NULL, + [DisplayName] [nvarchar](300) NOT NULL, + [InstanceID] [nvarchar](50) NOT NULL, + [PrimaryEmailAddress] [nvarchar](300) NULL, + [SamAccountName] [nvarchar](100) NULL +) + + +IF (@SortColumn = 'DisplayName') +BEGIN + INSERT INTO + #TempOCSUsers + SELECT + ea.AccountID, + ea.ItemID, + ea.AccountName, + ea.DisplayName, + ou.InstanceID, + ea.PrimaryEmailAddress, + ea.SamAccountName + FROM + ExchangeAccounts ea + INNER JOIN + OCSUsers ou + ON + ea.AccountID = ou.AccountID + WHERE + ea.ItemID = @ItemID AND ea.DisplayName LIKE @Name AND ea.PrimaryEmailAddress LIKE @Email + ORDER BY + ea.DisplayName +END +ELSE +BEGIN + INSERT INTO + #TempOCSUsers + SELECT + ea.AccountID, + ea.ItemID, + ea.AccountName, + ea.DisplayName, + ou.InstanceID, + ea.PrimaryEmailAddress, + ea.SamAccountName + FROM + ExchangeAccounts ea + INNER JOIN + OCSUsers ou + ON + ea.AccountID = ou.AccountID + WHERE + ea.ItemID = @ItemID AND ea.DisplayName LIKE @Name AND ea.PrimaryEmailAddress LIKE @Email + ORDER BY + ea.PrimaryEmailAddress +END + +DECLARE @RetCount int +SELECT @RetCount = COUNT(ID) FROM #TempOCSUsers + +IF (@SortDirection = 'ASC') +BEGIN + SELECT * FROM #TempOCSUsers + WHERE ID > @StartRow AND ID <= (@StartRow + @Count) +END +ELSE +BEGIN + IF (@SortColumn = 'DisplayName') + BEGIN + SELECT * FROM #TempOCSUsers + WHERE ID >@RetCount - @Count - @StartRow AND ID <= @RetCount- @StartRow ORDER BY DisplayName DESC + END + ELSE + BEGIN + SELECT * FROM #TempOCSUsers + WHERE ID >@RetCount - @Count - @StartRow AND ID <= @RetCount- @StartRow ORDER BY PrimaryEmailAddress DESC + END + +END + + +DROP TABLE #TempOCSUsers + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + +CREATE PROCEDURE [dbo].[GetOCSUsersCount] +( + @ItemID int, + @Name nvarchar(400), + @Email nvarchar(400) + +) +AS + +IF (@Name IS NULL) +BEGIN + SET @Name = '%' +END + +IF (@Email IS NULL) +BEGIN + SET @Email = '%' +END + +SELECT + COUNT(ea.AccountID) +FROM + ExchangeAccounts ea +INNER JOIN + OCSUsers ou +ON + ea.AccountID = ou.AccountID +WHERE + ea.ItemID = @ItemID AND ea.DisplayName LIKE @Name AND ea.PrimaryEmailAddress LIKE @Email + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[GetOrganizationCRMUserCount] + @ItemID int +AS +BEGIN +SELECT + COUNT(CRMUserID) +FROM + CrmUsers CU +INNER JOIN + ExchangeAccounts EA +ON + CU.AccountID = EA.AccountID +WHERE EA.ItemID = @ItemID +END + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[GetOrganizationStatistics] +( + @ItemID int +) +AS +SELECT + (SELECT COUNT(*) FROM ExchangeAccounts WHERE (AccountType = 7 OR AccountType = 1 OR AccountType = 6 OR AccountType = 5) AND ItemID = @ItemID) AS CreatedUsers, + (SELECT COUNT(*) FROM ExchangeOrganizationDomains WHERE ItemID = @ItemID) AS CreatedDomains +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[GetPackage] +( + @PackageID int, + @ActorID int +) +AS + +-- Note: ActorID is not verified +-- check both requested and parent package + +SELECT + P.PackageID, + P.ParentPackageID, + P.UserID, + P.PackageName, + P.PackageComments, + P.ServerID, + P.StatusID, + P.PlanID, + P.PurchaseDate, + P.OverrideQuotas +FROM Packages AS P +WHERE P.PackageID = @PackageID +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[GetPackageAddon] +( + @ActorID int, + @PackageAddonID int +) +AS + +-- check rights +DECLARE @PackageID int +SELECT @PackageID = @PackageID FROM PackageAddons +WHERE PackageAddonID = @PackageAddonID + +IF dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 +RAISERROR('You are not allowed to access this package', 16, 1) + +SELECT + PackageAddonID, + PackageID, + PlanID, + PurchaseDate, + Quantity, + StatusID, + Comments +FROM PackageAddons AS PA +WHERE PA.PackageAddonID = @PackageAddonID +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE GetPackageAddons +( + @ActorID int, + @PackageID int +) +AS + +-- check rights +IF dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 +RAISERROR('You are not allowed to access this package', 16, 1) + +SELECT + PA.PackageAddonID, + PA.PackageID, + PA.PlanID, + PA.Quantity, + PA.PurchaseDate, + PA.StatusID, + PA.Comments, + HP.PlanName, + HP.PlanDescription +FROM PackageAddons AS PA +INNER JOIN HostingPlans AS HP ON PA.PlanID = HP.PlanID +WHERE PA.PackageID = @PackageID +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE GetPackageBandwidth +( + @ActorID int, + @PackageID int, + @StartDate datetime, + @EndDate datetime +) +AS + +-- check rights +IF dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 +RAISERROR('You are not allowed to access this package', 16, 1) + +SELECT + RG.GroupID, + RG.GroupName, + ROUND(CONVERT(float, ISNULL(GB.BytesSent, 0)) / 1024 / 1024, 0) AS MegaBytesSent, + ROUND(CONVERT(float, ISNULL(GB.BytesReceived, 0)) / 1024 / 1024, 0) AS MegaBytesReceived, + ROUND(CONVERT(float, ISNULL(GB.BytesTotal, 0)) / 1024 / 1024, 0) AS MegaBytesTotal, + ISNULL(GB.BytesSent, 0) AS BytesSent, + ISNULL(GB.BytesReceived, 0) AS BytesReceived, + ISNULL(GB.BytesTotal, 0) AS BytesTotal +FROM ResourceGroups AS RG +LEFT OUTER JOIN +( + SELECT + PB.GroupID, + SUM(ISNULL(PB.BytesSent, 0)) AS BytesSent, + SUM(ISNULL(PB.BytesReceived, 0)) AS BytesReceived, + SUM(ISNULL(PB.BytesSent, 0)) + SUM(ISNULL(PB.BytesReceived, 0)) AS BytesTotal + FROM PackagesTreeCache AS PT + INNER JOIN PackagesBandwidth AS PB ON PT.PackageID = PB.PackageID + INNER JOIN Packages AS P ON PB.PackageID = P.PackageID + INNER JOIN HostingPlanResources AS HPR ON PB.GroupID = HPR.GroupID AND HPR.PlanID = P.PlanID + AND HPR.CalculateBandwidth = 1 + WHERE + PT.ParentPackageID = @PackageID + AND PB.LogDate BETWEEN @StartDate AND @EndDate + GROUP BY PB.GroupID +) AS GB ON RG.GroupID = GB.GroupID +WHERE GB.BytesTotal > 0 +ORDER BY RG.GroupOrder + +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE GetPackageBandwidthUpdate +( + @PackageID int, + @UpdateDate datetime OUTPUT +) +AS + SELECT @UpdateDate = BandwidthUpdated FROM Packages + WHERE PackageID = @PackageID +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE GetPackageDiskspace +( + @ActorID int, + @PackageID int +) +AS + +-- check rights +IF dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 +RAISERROR('You are not allowed to access this package', 16, 1) + +SELECT + RG.GroupID, + RG.GroupName, + ROUND(CONVERT(float, ISNULL(GD.Diskspace, 0)) / 1024 / 1024, 0) AS Diskspace, + ISNULL(GD.Diskspace, 0) AS DiskspaceBytes +FROM ResourceGroups AS RG +LEFT OUTER JOIN +( + SELECT + PD.GroupID, + SUM(ISNULL(PD.DiskSpace, 0)) AS Diskspace -- in megabytes + FROM PackagesTreeCache AS PT + INNER JOIN PackagesDiskspace AS PD ON PT.PackageID = PD.PackageID + INNER JOIN Packages AS P ON PT.PackageID = P.PackageID + INNER JOIN HostingPlanResources AS HPR ON PD.GroupID = HPR.GroupID + AND HPR.PlanID = P.PlanID AND HPR.CalculateDiskspace = 1 + WHERE PT.ParentPackageID = @PackageID + GROUP BY PD.GroupID +) AS GD ON RG.GroupID = GD.GroupID +WHERE GD.Diskspace <> 0 +ORDER BY RG.GroupOrder + +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[GetPackageIPAddress] + @PackageAddressID int +AS +BEGIN + + +SELECT + PA.PackageAddressID, + PA.AddressID, + IP.ExternalIP, + IP.InternalIP, + IP.SubnetMask, + IP.DefaultGateway, + PA.ItemID, + SI.ItemName, + PA.PackageID, + P.PackageName, + P.UserID, + U.UserName, + PA.IsPrimary +FROM dbo.PackageIPAddresses AS PA +INNER JOIN dbo.IPAddresses AS IP ON PA.AddressID = IP.AddressID +INNER JOIN dbo.Packages P ON PA.PackageID = P.PackageID +INNER JOIN dbo.Users U ON U.UserID = P.UserID +LEFT JOIN ServiceItems SI ON PA.ItemId = SI.ItemID +WHERE PA.PackageAddressID = @PackageAddressID + +END + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[GetPackageIPAddresses] +( + @PackageID int, + @FilterColumn nvarchar(50) = '', + @FilterValue nvarchar(50) = '', + @SortColumn nvarchar(50), + @StartRow int, + @MaximumRows int, + @PoolID int = 0, + @Recursive bit = 0 +) +AS +BEGIN + + +-- start +DECLARE @condition nvarchar(700) +SET @condition = ' +((@Recursive = 0 AND PA.PackageID = @PackageID) +OR (@Recursive = 1 AND dbo.CheckPackageParent(@PackageID, PA.PackageID) = 1)) +AND (@PoolID = 0 OR @PoolID <> 0 AND IP.PoolID = @PoolID) +' + +IF @FilterColumn <> '' AND @FilterColumn IS NOT NULL +AND @FilterValue <> '' AND @FilterValue IS NOT NULL +SET @condition = @condition + ' AND ' + @FilterColumn + ' LIKE ''' + @FilterValue + '''' + +IF @SortColumn IS NULL OR @SortColumn = '' +SET @SortColumn = 'IP.ExternalIP ASC' + +DECLARE @sql nvarchar(3500) + +set @sql = ' +SELECT COUNT(PA.PackageAddressID) +FROM dbo.PackageIPAddresses PA +INNER JOIN dbo.IPAddresses AS IP ON PA.AddressID = IP.AddressID +INNER JOIN dbo.Packages P ON PA.PackageID = P.PackageID +INNER JOIN dbo.Users U ON U.UserID = P.UserID +LEFT JOIN ServiceItems SI ON PA.ItemId = SI.ItemID +WHERE ' + @condition + ' + +DECLARE @Addresses AS TABLE +( + PackageAddressID int +); + +WITH TempItems AS ( + SELECT ROW_NUMBER() OVER (ORDER BY ' + @SortColumn + ') as Row, + PA.PackageAddressID + FROM dbo.PackageIPAddresses PA + INNER JOIN dbo.IPAddresses AS IP ON PA.AddressID = IP.AddressID + INNER JOIN dbo.Packages P ON PA.PackageID = P.PackageID + INNER JOIN dbo.Users U ON U.UserID = P.UserID + LEFT JOIN ServiceItems SI ON PA.ItemId = SI.ItemID + WHERE ' + @condition + ' +) + +INSERT INTO @Addresses +SELECT PackageAddressID FROM TempItems +WHERE TempItems.Row BETWEEN @StartRow + 1 and @StartRow + @MaximumRows + +SELECT + PA.PackageAddressID, + PA.AddressID, + IP.ExternalIP, + IP.InternalIP, + IP.SubnetMask, + IP.DefaultGateway, + PA.ItemID, + SI.ItemName, + PA.PackageID, + P.PackageName, + P.UserID, + U.UserName, + PA.IsPrimary +FROM @Addresses AS TA +INNER JOIN dbo.PackageIPAddresses AS PA ON TA.PackageAddressID = PA.PackageAddressID +INNER JOIN dbo.IPAddresses AS IP ON PA.AddressID = IP.AddressID +INNER JOIN dbo.Packages P ON PA.PackageID = P.PackageID +INNER JOIN dbo.Users U ON U.UserID = P.UserID +LEFT JOIN ServiceItems SI ON PA.ItemId = SI.ItemID +' + +print @sql + +exec sp_executesql @sql, N'@PackageID int, @StartRow int, @MaximumRows int, @Recursive bit, @PoolID int', +@PackageID, @StartRow, @MaximumRows, @Recursive, @PoolID + +END + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE GetPackagePackages +( + @ActorID int, + @PackageID int, + @Recursive bit +) +AS + +-- check rights +IF dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 +RAISERROR('You are not allowed to access this package', 16, 1) + +SELECT + P.PackageID, + P.ParentPackageID, + P.PackageName, + P.StatusID, + P.PurchaseDate, + + -- server + P.ServerID, + ISNULL(S.ServerName, 'None') AS ServerName, + ISNULL(S.Comments, '') AS ServerComments, + ISNULL(S.VirtualServer, 1) AS VirtualServer, + + -- hosting plan + P.PlanID, + HP.PlanName, + + -- user + P.UserID, + U.Username, + U.FirstName, + U.LastName, + U.RoleID, + U.Email +FROM Packages AS P +INNER JOIN Users AS U ON P.UserID = U.UserID +INNER JOIN Servers AS S ON P.ServerID = S.ServerID +INNER JOIN HostingPlans AS HP ON P.PlanID = HP.PlanID +WHERE + ((@Recursive = 1 AND dbo.CheckPackageParent(@PackageID, P.PackageID) = 1) + OR (@Recursive = 0 AND P.ParentPackageID = @PackageID)) + AND P.PackageID <> @PackageID +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[GetPackagePrivateIPAddresses] + @PackageID int +AS +BEGIN + + SELECT + PA.PrivateAddressID, + PA.IPAddress, + PA.ItemID, + SI.ItemName, + PA.IsPrimary + FROM PrivateIPAddresses AS PA + INNER JOIN ServiceItems AS SI ON PA.ItemID = SI.ItemID + WHERE SI.PackageID = @PackageID + +END + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[GetPackagePrivateIPAddressesPaged] + @PackageID int, + @FilterColumn nvarchar(50) = '', + @FilterValue nvarchar(50) = '', + @SortColumn nvarchar(50), + @StartRow int, + @MaximumRows int +AS +BEGIN + + +-- start +DECLARE @condition nvarchar(700) +SET @condition = ' +SI.PackageID = @PackageID +' + +IF @FilterColumn <> '' AND @FilterColumn IS NOT NULL +AND @FilterValue <> '' AND @FilterValue IS NOT NULL +SET @condition = @condition + ' AND ' + @FilterColumn + ' LIKE ''' + @FilterValue + '''' + +IF @SortColumn IS NULL OR @SortColumn = '' +SET @SortColumn = 'PA.IPAddress ASC' + +DECLARE @sql nvarchar(3500) + +set @sql = ' +SELECT COUNT(PA.PrivateAddressID) +FROM dbo.PrivateIPAddresses AS PA +INNER JOIN dbo.ServiceItems AS SI ON PA.ItemID = SI.ItemID +WHERE ' + @condition + ' + +DECLARE @Addresses AS TABLE +( + PrivateAddressID int +); + +WITH TempItems AS ( + SELECT ROW_NUMBER() OVER (ORDER BY ' + @SortColumn + ') as Row, + PA.PrivateAddressID + FROM dbo.PrivateIPAddresses AS PA + INNER JOIN dbo.ServiceItems AS SI ON PA.ItemID = SI.ItemID + WHERE ' + @condition + ' +) + +INSERT INTO @Addresses +SELECT PrivateAddressID FROM TempItems +WHERE TempItems.Row BETWEEN @StartRow + 1 and @StartRow + @MaximumRows + +SELECT + PA.PrivateAddressID, + PA.IPAddress, + PA.ItemID, + SI.ItemName, + PA.IsPrimary +FROM @Addresses AS TA +INNER JOIN dbo.PrivateIPAddresses AS PA ON TA.PrivateAddressID = PA.PrivateAddressID +INNER JOIN dbo.ServiceItems AS SI ON PA.ItemID = SI.ItemID +' + +print @sql + +exec sp_executesql @sql, N'@PackageID int, @StartRow int, @MaximumRows int', +@PackageID, @StartRow, @MaximumRows + +END + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[GetPackageQuota] +( + @ActorID int, + @PackageID int, + @QuotaName nvarchar(50) +) +AS + +-- check rights +IF dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 +RAISERROR('You are not allowed to access this package', 16, 1) + +-- return quota +SELECT + Q.QuotaID, + Q.QuotaName, + Q.QuotaDescription, + Q.QuotaTypeID, + ISNULL(dbo.GetPackageAllocatedQuota(@PackageId, Q.QuotaID), 0) AS QuotaAllocatedValue, + ISNULL(dbo.CalculateQuotaUsage(@PackageId, Q.QuotaID), 0) AS QuotaUsedValue +FROM Quotas AS Q +WHERE Q.QuotaName = @QuotaName + +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE GetPackageQuotas +( + @ActorID int, + @PackageID int +) +AS + +-- check rights +IF dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 +RAISERROR('You are not allowed to access this package', 16, 1) + +DECLARE @PlanID int, @ParentPackageID int +SELECT @PlanID = PlanID, @ParentPackageID = ParentPackageID FROM Packages +WHERE PackageID = @PackageID + +-- get resource groups +SELECT + RG.GroupID, + RG.GroupName, + ISNULL(HPR.CalculateDiskSpace, 0) AS CalculateDiskSpace, + ISNULL(HPR.CalculateBandwidth, 0) AS CalculateBandwidth, + dbo.GetPackageAllocatedResource(@ParentPackageID, RG.GroupID, 0) AS ParentEnabled +FROM ResourceGroups AS RG +LEFT OUTER JOIN HostingPlanResources AS HPR ON RG.GroupID = HPR.GroupID AND HPR.PlanID = @PlanID +WHERE dbo.GetPackageAllocatedResource(@PackageID, RG.GroupID, 0) = 1 +ORDER BY RG.GroupOrder + + +-- return quotas +SELECT + Q.QuotaID, + Q.GroupID, + Q.QuotaName, + Q.QuotaDescription, + Q.QuotaTypeID, + dbo.GetPackageAllocatedQuota(@PackageID, Q.QuotaID) AS QuotaValue, + dbo.GetPackageAllocatedQuota(@ParentPackageID, Q.QuotaID) AS ParentQuotaValue, + ISNULL(dbo.CalculateQuotaUsage(@PackageID, Q.QuotaID), 0) AS QuotaUsedValue +FROM Quotas AS Q +ORDER BY Q.QuotaOrder +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE GetPackageQuotasForEdit +( + @ActorID int, + @PackageID int +) +AS + +-- check rights +IF dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 +RAISERROR('You are not allowed to access this package', 16, 1) + +DECLARE @ServerID int, @ParentPackageID int, @PlanID int +SELECT @ServerID = ServerID, @ParentPackageID = ParentPackageID, @PlanID = PlanID FROM Packages +WHERE PackageID = @PackageID + +-- get resource groups +SELECT + RG.GroupID, + RG.GroupName, + ISNULL(PR.CalculateDiskSpace, ISNULL(HPR.CalculateDiskSpace, 0)) AS CalculateDiskSpace, + ISNULL(PR.CalculateBandwidth, ISNULL(HPR.CalculateBandwidth, 0)) AS CalculateBandwidth, + dbo.GetPackageAllocatedResource(@PackageID, RG.GroupID, @ServerID) AS Enabled, + dbo.GetPackageAllocatedResource(@ParentPackageID, RG.GroupID, @ServerID) AS ParentEnabled +FROM ResourceGroups AS RG +LEFT OUTER JOIN PackageResources AS PR ON RG.GroupID = PR.GroupID AND PR.PackageID = @PackageID +LEFT OUTER JOIN HostingPlanResources AS HPR ON RG.GroupID = HPR.GroupID AND HPR.PlanID = @PlanID +ORDER BY RG.GroupOrder + + +-- return quotas +SELECT + Q.QuotaID, + Q.GroupID, + Q.QuotaName, + Q.QuotaDescription, + Q.QuotaTypeID, + CASE + WHEN PQ.QuotaValue IS NULL THEN dbo.GetPackageAllocatedQuota(@PackageID, Q.QuotaID) + ELSE PQ.QuotaValue + END QuotaValue, + dbo.GetPackageAllocatedQuota(@ParentPackageID, Q.QuotaID) AS ParentQuotaValue +FROM Quotas AS Q +LEFT OUTER JOIN PackageQuotas AS PQ ON PQ.QuotaID = Q.QuotaID AND PQ.PackageID = @PackageID +ORDER BY Q.QuotaOrder + +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + + + + + +CREATE PROCEDURE [dbo].[GetPackages] +( + @ActorID int, + @UserID int +) +AS + +SELECT + P.PackageID, + P.ParentPackageID, + P.PackageName, + P.StatusID, + P.PurchaseDate, + + -- server + ISNULL(P.ServerID, 0) AS ServerID, + ISNULL(S.ServerName, 'None') AS ServerName, + ISNULL(S.Comments, '') AS ServerComments, + ISNULL(S.VirtualServer, 1) AS VirtualServer, + + -- hosting plan + P.PlanID, + HP.PlanName, + + -- user + P.UserID, + U.Username, + U.FirstName, + U.LastName, + U.RoleID, + U.Email +FROM Packages AS P +INNER JOIN Users AS U ON P.UserID = U.UserID +INNER JOIN Servers AS S ON P.ServerID = S.ServerID +INNER JOIN HostingPlans AS HP ON P.PlanID = HP.PlanID +WHERE + P.UserID = @UserID +RETURN + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE GetPackagesBandwidthPaged +( + @ActorID int, + @UserID int, + @PackageID int, + @StartDate datetime, + @EndDate datetime, + @SortColumn nvarchar(50), + @StartRow int, + @MaximumRows int +) +AS + +-- check rights +IF dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 +RAISERROR('You are not allowed to access this package', 16, 1) + +DECLARE @sql nvarchar(4000) + +SET @sql = ' +DECLARE @EndRow int +SET @EndRow = @StartRow + @MaximumRows + +DECLARE @Report TABLE +( + ItemPosition int IDENTITY(0,1), + PackageID int, + QuotaValue int, + Bandwidth int, + UsagePercentage int, + PackagesNumber int +) + +INSERT INTO @Report (PackageID, QuotaValue, Bandwidth, UsagePercentage, PackagesNumber) +SELECT + P.PackageID, + PB.QuotaValue, + PB.Bandwidth, + UsagePercentage = CASE + WHEN PB.QuotaValue = -1 THEN 0 + WHEN PB.QuotaValue <> 0 THEN PB.Bandwidth * 100 / PB.QuotaValue + ELSE 0 + END, + (SELECT COUNT(NP.PackageID) FROM Packages AS NP WHERE NP.ParentPackageID = P.PackageID) AS PackagesNumber +FROM Packages AS P +LEFT OUTER JOIN +( + SELECT + P.PackageID, + dbo.GetPackageAllocatedQuota(P.PackageID, 51) AS QuotaValue, -- bandwidth + ROUND(CONVERT(float, SUM(ISNULL(PB.BytesSent + PB.BytesReceived, 0))) / 1024 / 1024, 0) AS Bandwidth -- in megabytes + FROM Packages AS P + INNER JOIN PackagesTreeCache AS PT ON P.PackageID = PT.ParentPackageID + INNER JOIN Packages AS PC ON PT.PackageID = PC.PackageID + INNER JOIN PackagesBandwidth AS PB ON PT.PackageID = PB.PackageID + INNER JOIN HostingPlanResources AS HPR ON PB.GroupID = HPR.GroupID + AND HPR.PlanID = PC.PlanID + WHERE PB.LogDate BETWEEN @StartDate AND @EndDate + AND HPR.CalculateBandwidth = 1 + GROUP BY P.PackageID +) AS PB ON P.PackageID = PB.PackageID +WHERE (@PackageID = -1 AND P.UserID = @UserID) OR + (@PackageID <> -1 AND P.ParentPackageID = @PackageID) ' + +IF @SortColumn = '' OR @SortColumn IS NULL +SET @SortColumn = 'UsagePercentage DESC' + +SET @sql = @sql + ' ORDER BY ' + @SortColumn + ' ' + +SET @sql = @sql + ' +SELECT COUNT(PackageID) FROM @Report + +SELECT + R.PackageID, + ISNULL(R.QuotaValue, 0) AS QuotaValue, + ISNULL(R.Bandwidth, 0) AS Bandwidth, + ISNULL(R.UsagePercentage, 0) AS UsagePercentage, + + -- package + P.PackageName, + ISNULL(R.PackagesNumber, 0) AS PackagesNumber, + P.StatusID, + + -- user + P.UserID, + U.Username, + U.FirstName, + U.LastName, + U.FullName, + U.RoleID, + U.Email, + dbo.GetItemComments(U.UserID, ''USER'', @ActorID) AS UserComments +FROM @Report AS R +INNER JOIN Packages AS P ON R.PackageID = P.PackageID +INNER JOIN UsersDetailed AS U ON P.UserID = U.UserID +WHERE R.ItemPosition BETWEEN @StartRow AND @EndRow +' + +exec sp_executesql @sql, N'@ActorID int, @UserID int, @PackageID int, @StartDate datetime, @EndDate datetime, @StartRow int, @MaximumRows int', +@ActorID, @UserID, @PackageID, @StartDate, @EndDate, @StartRow, @MaximumRows + +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE GetPackagesDiskspacePaged +( + @ActorID int, + @UserID int, + @PackageID int, + @SortColumn nvarchar(50), + @StartRow int, + @MaximumRows int +) +AS + +IF dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 +RAISERROR('You are not allowed to access this package', 16, 1) + +DECLARE @sql nvarchar(4000) + +SET @sql = ' +DECLARE @EndRow int +SET @EndRow = @StartRow + @MaximumRows + +DECLARE @Report TABLE +( + ItemPosition int IDENTITY(0,1), + PackageID int, + QuotaValue int, + Diskspace int, + UsagePercentage int, + PackagesNumber int +) + +INSERT INTO @Report (PackageID, QuotaValue, Diskspace, UsagePercentage, PackagesNumber) +SELECT + P.PackageID, + PD.QuotaValue, + PD.Diskspace, + UsagePercentage = CASE + WHEN PD.QuotaValue = -1 THEN 0 + WHEN PD.QuotaValue <> 0 THEN PD.Diskspace * 100 / PD.QuotaValue + ELSE 0 + END, + (SELECT COUNT(NP.PackageID) FROM Packages AS NP WHERE NP.ParentPackageID = P.PackageID) AS PackagesNumber +FROM Packages AS P +LEFT OUTER JOIN +( + SELECT + P.PackageID, + dbo.GetPackageAllocatedQuota(P.PackageID, 52) AS QuotaValue, -- diskspace + ROUND(CONVERT(float, SUM(ISNULL(PD.DiskSpace, 0))) / 1024 / 1024, 0) AS Diskspace -- in megabytes + FROM Packages AS P + INNER JOIN PackagesTreeCache AS PT ON P.PackageID = PT.ParentPackageID + INNER JOIN Packages AS PC ON PT.PackageID = PC.PackageID + INNER JOIN PackagesDiskspace AS PD ON PT.PackageID = PD.PackageID + INNER JOIN HostingPlanResources AS HPR ON PD.GroupID = HPR.GroupID + AND HPR.PlanID = PC.PlanID + WHERE HPR.CalculateDiskspace = 1 + GROUP BY P.PackageID +) AS PD ON P.PackageID = PD.PackageID +WHERE (@PackageID = -1 AND P.UserID = @UserID) OR + (@PackageID <> -1 AND P.ParentPackageID = @PackageID) +' + +IF @SortColumn = '' OR @SortColumn IS NULL +SET @SortColumn = 'UsagePercentage DESC' + +SET @sql = @sql + ' ORDER BY ' + @SortColumn + ' ' + +SET @sql = @sql + ' +SELECT COUNT(PackageID) FROM @Report + +SELECT + R.PackageID, + ISNULL(R.QuotaValue, 0) AS QuotaValue, + ISNULL(R.Diskspace, 0) AS Diskspace, + ISNULL(R.UsagePercentage, 0) AS UsagePercentage, + + -- package + P.PackageName, + ISNULL(R.PackagesNumber, 0) AS PackagesNumber, + P.StatusID, + + -- user + P.UserID, + U.Username, + U.FirstName, + U.LastName, + U.FullName, + U.RoleID, + U.Email, + dbo.GetItemComments(U.UserID, ''USER'', @ActorID) AS UserComments +FROM @Report AS R +INNER JOIN Packages AS P ON R.PackageID = P.PackageID +INNER JOIN UsersDetailed AS U ON P.UserID = U.UserID +WHERE R.ItemPosition BETWEEN @StartRow AND @EndRow +' + +exec sp_executesql @sql, N'@ActorID int, @UserID int, @PackageID int, @StartRow int, @MaximumRows int', +@ActorID, @UserID, @PackageID, @StartRow, @MaximumRows + +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE GetPackageServiceID +( + @ActorID int, + @PackageID int, + @GroupName nvarchar(100), + @ServiceID int OUTPUT +) +AS + +-- check rights +IF dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 +RAISERROR('You are not allowed to access this package', 16, 1) + +SET @ServiceID = 0 + +-- load group info +DECLARE @GroupID int +SELECT @GroupID = GroupID FROM ResourceGroups +WHERE GroupName = @GroupName + +-- check if user has this resource enabled +IF dbo.GetPackageAllocatedResource(@PackageID, @GroupID, NULL) = 0 +BEGIN + -- remove all resource services from the space + DELETE FROM PackageServices FROM PackageServices AS PS + INNER JOIN Services AS S ON PS.ServiceID = S.ServiceID + INNER JOIN Providers AS P ON S.ProviderID = P.ProviderID + WHERE P.GroupID = @GroupID AND PS.PackageID = @PackageID + RETURN +END + +-- check if the service is already distributed +SELECT + @ServiceID = PS.ServiceID +FROM PackageServices AS PS +INNER JOIN Services AS S ON PS.ServiceID = S.ServiceID +INNER JOIN Providers AS P ON S.ProviderID = P.ProviderID +WHERE PS.PackageID = @PackageID AND P.GroupID = @GroupID + +IF @ServiceID <> 0 +RETURN + +-- distribute services +EXEC DistributePackageServices @ActorID, @PackageID + +-- get distributed service again +SELECT + @ServiceID = PS.ServiceID +FROM PackageServices AS PS +INNER JOIN Services AS S ON PS.ServiceID = S.ServiceID +INNER JOIN Providers AS P ON S.ProviderID = P.ProviderID +WHERE PS.PackageID = @PackageID AND P.GroupID = @GroupID + +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE GetPackageSettings +( + @ActorID int, + @PackageID int, + @SettingsName nvarchar(50) +) +AS + +-- check rights +IF dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 +RAISERROR('You are not allowed to access this package', 16, 1) + +DECLARE @ParentPackageID int, @TmpPackageID int +SET @TmpPackageID = @PackageID + +WHILE 10 = 10 +BEGIN + IF @TmpPackageID < 2 -- system package + BEGIN + SELECT + @TmpPackageID AS PackageID, + 'Dump' AS PropertyName, + '' AS PropertyValue + END + ELSE + BEGIN + -- user package + IF EXISTS + ( + SELECT PropertyName FROM PackageSettings + WHERE SettingsName = @SettingsName AND PackageID = @TmpPackageID + ) + BEGIN + SELECT + PackageID, + PropertyName, + PropertyValue + FROM + PackageSettings + WHERE + PackageID = @TmpPackageID AND + SettingsName = @SettingsName + + BREAK + END + END + + + SET @ParentPackageID = NULL --reset var + + -- get owner + SELECT + @ParentPackageID = ParentPackageID + FROM Packages + WHERE PackageID = @TmpPackageID + + IF @ParentPackageID IS NULL -- the last parent + BREAK + + SET @TmpPackageID = @ParentPackageID +END + +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[GetPackagesPaged] +( + @ActorID int, + @UserID int, + @FilterColumn nvarchar(50) = '', + @FilterValue nvarchar(50) = '', + @SortColumn nvarchar(50), + @StartRow int, + @MaximumRows int +) +AS + +-- build query and run it to the temporary table +DECLARE @sql nvarchar(2000) + +SET @sql = ' +DECLARE @HasUserRights bit +SET @HasUserRights = dbo.CheckActorUserRights(@ActorID, @UserID) + +DECLARE @EndRow int +SET @EndRow = @StartRow + @MaximumRows +DECLARE @Packages TABLE +( + ItemPosition int IDENTITY(1,1), + PackageID int +) +INSERT INTO @Packages (PackageID) +SELECT + P.PackageID +FROM Packages AS P +--INNER JOIN UsersTree(@UserID, 1) AS UT ON P.UserID = UT.UserID +INNER JOIN UsersDetailed AS U ON P.UserID = U.UserID +INNER JOIN Servers AS S ON P.ServerID = S.ServerID +INNER JOIN HostingPlans AS HP ON P.PlanID = HP.PlanID +WHERE + P.UserID <> @UserID AND dbo.CheckUserParent(@UserID, P.UserID) = 1 + AND @HasUserRights = 1 ' + +IF @FilterColumn <> '' AND @FilterValue <> '' +SET @sql = @sql + ' AND ' + @FilterColumn + ' LIKE @FilterValue ' + +IF @SortColumn <> '' AND @SortColumn IS NOT NULL +SET @sql = @sql + ' ORDER BY ' + @SortColumn + ' ' + +SET @sql = @sql + ' SELECT COUNT(PackageID) FROM @Packages; +SELECT + P.PackageID, + P.PackageName, + P.StatusID, + P.PurchaseDate, + + dbo.GetItemComments(P.PackageID, ''PACKAGE'', @ActorID) AS Comments, + + -- server + P.ServerID, + ISNULL(S.ServerName, ''None'') AS ServerName, + ISNULL(S.Comments, '''') AS ServerComments, + ISNULL(S.VirtualServer, 1) AS VirtualServer, + + -- hosting plan + P.PlanID, + HP.PlanName, + + -- user + P.UserID, + U.Username, + U.FirstName, + U.LastName, + U.FullName, + U.RoleID, + U.Email +FROM @Packages AS TP +INNER JOIN Packages AS P ON TP.PackageID = P.PackageID +INNER JOIN UsersDetailed AS U ON P.UserID = U.UserID +INNER JOIN Servers AS S ON P.ServerID = S.ServerID +INNER JOIN HostingPlans AS HP ON P.PlanID = HP.PlanID +WHERE TP.ItemPosition BETWEEN @StartRow AND @EndRow' + +exec sp_executesql @sql, N'@StartRow int, @MaximumRows int, @UserID int, @FilterValue nvarchar(50), @ActorID int', +@StartRow, @MaximumRows, @UserID, @FilterValue, @ActorID + + +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[GetPackageUnassignedIPAddresses] +( + @ActorID int, + @PackageID int, + @PoolID int = 0 +) +AS +BEGIN + SELECT + PIP.PackageAddressID, + IP.AddressID, + IP.ExternalIP, + IP.InternalIP, + IP.ServerID, + IP.PoolID, + PIP.IsPrimary, + IP.SubnetMask, + IP.DefaultGateway + FROM PackageIPAddresses AS PIP + INNER JOIN IPAddresses AS IP ON PIP.AddressID = IP.AddressID + WHERE + PIP.ItemID IS NULL + AND PIP.PackageID = @PackageID + AND (@PoolID = 0 OR @PoolID <> 0 AND IP.PoolID = @PoolID) + AND dbo.CheckActorPackageRights(@ActorID, PIP.PackageID) = 1 + ORDER BY IP.DefaultGateway, IP.ExternalIP +END + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + +CREATE PROCEDURE [dbo].[GetPendingSSLForWebsite] +( + @ActorID int, + @PackageID int, + @websiteid int, + @Recursive bit = 1 +) +AS + +-- check rights +IF dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 +BEGIN + RAISERROR('You are not allowed to access this package', 16, 1) + RETURN +END + +SELECT + [ID], [UserID], [SiteID], [Hostname], [CSR], [Certificate], [Hash], [Installed] +FROM + [dbo].[SSLCertificates] +WHERE + @websiteid = 2 AND [Installed] = 0 AND [IsRenewal] = 0 + +RETURN + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE GetProvider +( + @ProviderID int +) +AS +SELECT + ProviderID, + GroupID, + ProviderName, + EditorControl, + DisplayName, + ProviderType +FROM Providers +WHERE + ProviderID = @ProviderID + +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE GetProviderByServiceID +( + @ServiceID int +) +AS +SELECT + P.ProviderID, + P.GroupID, + P.DisplayName, + P.EditorControl, + P.ProviderType +FROM Services AS S +INNER JOIN Providers AS P ON S.ProviderID = P.ProviderID +WHERE + S.ServiceID = @ServiceID + +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[GetProviders] +AS +SELECT + PROV.ProviderID, + PROV.GroupID, + PROV.ProviderName, + PROV.EditorControl, + PROV.DisplayName, + PROV.ProviderType, + RG.GroupName + ' - ' + PROV.DisplayName AS ProviderName, + PROV.DisableAutoDiscovery +FROM Providers AS PROV +INNER JOIN ResourceGroups AS RG ON PROV.GroupID = RG.GroupID +ORDER BY RG.GroupOrder, PROV.DisplayName +RETURN + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE GetProviderServiceQuota +( + @ProviderID int +) +AS + +SELECT TOP 1 + Q.QuotaID, + Q.GroupID, + Q.QuotaName, + Q.QuotaDescription, + Q.QuotaTypeID, + Q.ServiceQuota +FROM Providers AS P +INNER JOIN Quotas AS Q ON P.GroupID = Q.GroupID +WHERE P.ProviderID = @ProviderID AND Q.ServiceQuota = 1 + + +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE GetQuotas +AS +SELECT + Q.GroupID, + Q.QuotaID, + RG.GroupName, + Q.QuotaDescription, + Q.QuotaTypeID +FROM Quotas AS Q +INNER JOIN ResourceGroups AS RG ON Q.GroupID = RG.GroupID +ORDER BY RG.GroupOrder, Q.QuotaOrder +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[GetRawServicesByServerID] +( + @ActorID int, + @ServerID int +) +AS + +-- check rights +DECLARE @IsAdmin bit +SET @IsAdmin = dbo.CheckIsUserAdmin(@ActorID) + +-- resource groups +SELECT + GroupID, + GroupName +FROM ResourceGroups +WHERE @IsAdmin = 1 AND (ShowGroup = 1) +ORDER BY GroupOrder + +-- services +SELECT + S.ServiceID, + S.ServerID, + S.ServiceName, + S.Comments, + RG.GroupID, + PROV.DisplayName AS ProviderName +FROM Services AS S +INNER JOIN Providers AS PROV ON S.ProviderID = PROV.ProviderID +INNER JOIN ResourceGroups AS RG ON PROV.GroupID = RG.GroupID +WHERE + S.ServerID = @ServerID + AND @IsAdmin = 1 +ORDER BY RG.GroupOrder + +RETURN + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE GetResellerDomains +( + @ActorID int, + @PackageID int +) +AS + +-- check rights +IF dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 +RAISERROR('You are not allowed to access this package', 16, 1) + +-- load parent package +DECLARE @ParentPackageID int +SELECT @ParentPackageID = ParentPackageID FROM Packages +WHERE PackageID = @PackageID + +SELECT + D.DomainID, + D.PackageID, + D.ZoneItemID, + D.DomainName, + D.HostingAllowed, + D.WebSiteID, + WS.ItemName, + D.MailDomainID, + MD.ItemName +FROM Domains AS D +INNER JOIN PackagesTree(@ParentPackageID, 0) AS PT ON D.PackageID = PT.PackageID +LEFT OUTER JOIN ServiceItems AS WS ON D.WebSiteID = WS.ItemID +LEFT OUTER JOIN ServiceItems AS MD ON D.MailDomainID = MD.ItemID +WHERE HostingAllowed = 1 +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE GetResourceGroup +( + @GroupID int +) +AS +SELECT + RG.GroupID, + RG.GroupOrder, + RG.GroupName, + RG.GroupController +FROM ResourceGroups AS RG +WHERE RG.GroupID = @GroupID + +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE GetResourceGroups +AS +SELECT + GroupID, + GroupName, + GroupController +FROM ResourceGroups +ORDER BY GroupOrder +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE GetSchedule +( + @ActorID int, + @ScheduleID int +) +AS + +-- select schedule +SELECT TOP 1 + S.ScheduleID, + S.TaskID, + S.PackageID, + S.ScheduleName, + S.ScheduleTypeID, + S.Interval, + S.FromTime, + S.ToTime, + S.StartTime, + S.LastRun, + S.NextRun, + S.Enabled, + S.HistoriesNumber, + S.PriorityID, + S.MaxExecutionTime, + S.WeekMonthDay, + 1 AS StatusID +FROM Schedule AS S +WHERE + S.ScheduleID = @ScheduleID + AND dbo.CheckActorPackageRights(@ActorID, S.PackageID) = 1 + +-- select task +SELECT + ST.TaskID, + ST.TaskType, + ST.RoleID +FROM Schedule AS S +INNER JOIN ScheduleTasks AS ST ON S.TaskID = ST.TaskID +WHERE + S.ScheduleID = @ScheduleID + AND dbo.CheckActorPackageRights(@ActorID, S.PackageID) = 1 + +-- select schedule parameters +SELECT + S.ScheduleID, + STP.ParameterID, + STP.DataTypeID, + ISNULL(SP.ParameterValue, STP.DefaultValue) AS ParameterValue +FROM Schedule AS S +INNER JOIN ScheduleTaskParameters AS STP ON S.TaskID = STP.TaskID +LEFT OUTER JOIN ScheduleParameters AS SP ON STP.ParameterID = SP.ParameterID AND SP.ScheduleID = S.ScheduleID +WHERE + S.ScheduleID = @ScheduleID + AND dbo.CheckActorPackageRights(@ActorID, S.PackageID) = 1 + +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE GetScheduleInternal +( + @ScheduleID int +) +AS + +-- select schedule +SELECT + S.ScheduleID, + S.TaskID, + ST.TaskType, + ST.RoleID, + S.PackageID, + S.ScheduleName, + S.ScheduleTypeID, + S.Interval, + S.FromTime, + S.ToTime, + S.StartTime, + S.LastRun, + S.NextRun, + S.Enabled, + 1 AS StatusID, + S.PriorityID, + S.HistoriesNumber, + S.MaxExecutionTime, + S.WeekMonthDay +FROM Schedule AS S +INNER JOIN ScheduleTasks AS ST ON S.TaskID = ST.TaskID +WHERE ScheduleID = @ScheduleID +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[GetScheduleParameters] +( + @ActorID int, + @TaskID nvarchar(100), + @ScheduleID int +) +AS + +-- check rights +DECLARE @PackageID int +SELECT @PackageID = PackageID FROM Schedule +WHERE ScheduleID = @ScheduleID + +IF dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 +RAISERROR('You are not allowed to access this package', 16, 1) + +SELECT + @ScheduleID AS ScheduleID, + STP.ParameterID, + STP.DataTypeID, + SP.ParameterValue, + STP.DefaultValue +FROM ScheduleTaskParameters AS STP +LEFT OUTER JOIN ScheduleParameters AS SP ON STP.ParameterID = SP.ParameterID AND SP.ScheduleID = @ScheduleID +WHERE STP.TaskID = @TaskID +ORDER BY STP.ParameterOrder + +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE GetSchedules +( + @ActorID int, + @PackageID int, + @Recursive bit +) +AS + +-- check rights +IF dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 +RAISERROR('You are not allowed to access this package', 16, 1) + +DECLARE @Schedules TABLE +( + ScheduleID int +) + +INSERT INTO @Schedules (ScheduleID) +SELECT + S.ScheduleID +FROM Schedule AS S +INNER JOIN PackagesTree(@PackageID, @Recursive) AS PT ON S.PackageID = PT.PackageID +ORDER BY S.Enabled DESC, S.NextRun + + +-- select schedules +SELECT + S.ScheduleID, + S.TaskID, + ST.TaskType, + ST.RoleID, + S.PackageID, + S.ScheduleName, + S.ScheduleTypeID, + S.Interval, + S.FromTime, + S.ToTime, + S.StartTime, + S.LastRun, + S.NextRun, + S.Enabled, + 1 AS StatusID, + S.PriorityID, + S.MaxExecutionTime, + S.WeekMonthDay, + ISNULL(0, (SELECT TOP 1 SeverityID FROM AuditLog WHERE ItemID = S.ScheduleID AND SourceName = 'SCHEDULER' ORDER BY StartDate DESC)) AS LastResult, + + U.Username, + U.FirstName, + U.LastName, + U.FullName, + U.RoleID, + U.Email +FROM @Schedules AS STEMP +INNER JOIN Schedule AS S ON STEMP.ScheduleID = S.ScheduleID +INNER JOIN Packages AS P ON S.PackageID = P.PackageID +INNER JOIN ScheduleTasks AS ST ON S.TaskID = ST.TaskID +INNER JOIN UsersDetailed AS U ON P.UserID = U.UserID + +-- select schedule parameters +SELECT + S.ScheduleID, + STP.ParameterID, + STP.DataTypeID, + ISNULL(SP.ParameterValue, STP.DefaultValue) AS ParameterValue +FROM @Schedules AS STEMP +INNER JOIN Schedule AS S ON STEMP.ScheduleID = S.ScheduleID +INNER JOIN ScheduleTaskParameters AS STP ON S.TaskID = STP.TaskID +LEFT OUTER JOIN ScheduleParameters AS SP ON STP.ParameterID = SP.ParameterID AND SP.ScheduleID = S.ScheduleID +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE GetSchedulesPaged +( + @ActorID int, + @PackageID int, + @Recursive bit, + @FilterColumn nvarchar(50) = '', + @FilterValue nvarchar(50) = '', + @SortColumn nvarchar(50), + @StartRow int, + @MaximumRows int +) +AS +BEGIN + +-- check rights +IF dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 +RAISERROR('You are not allowed to access this package', 16, 1) + +DECLARE @condition nvarchar(400) +SET @condition = ' 1 = 1 ' + +IF @FilterColumn <> '' AND @FilterColumn IS NOT NULL +AND @FilterValue <> '' AND @FilterValue IS NOT NULL +SET @condition = @condition + ' AND ' + @FilterColumn + ' LIKE ''' + @FilterValue + '''' + +IF @SortColumn IS NULL OR @SortColumn = '' +SET @SortColumn = 'S.ScheduleName ASC' + +DECLARE @sql nvarchar(3500) + +set @sql = ' +SELECT COUNT(S.ScheduleID) FROM Schedule AS S +INNER JOIN PackagesTree(@PackageID, @Recursive) AS PT ON S.PackageID = PT.PackageID +INNER JOIN Packages AS P ON S.PackageID = P.PackageID +INNER JOIN UsersDetailed AS U ON P.UserID = U.UserID +WHERE ' + @condition + ' + +DECLARE @Schedules AS TABLE +( + ScheduleID int +); + +WITH TempSchedules AS ( + SELECT ROW_NUMBER() OVER (ORDER BY ' + @SortColumn + ') as Row, + S.ScheduleID + FROM Schedule AS S + INNER JOIN Packages AS P ON S.PackageID = P.PackageID + INNER JOIN PackagesTree(@PackageID, @Recursive) AS PT ON S.PackageID = PT.PackageID + INNER JOIN UsersDetailed AS U ON P.UserID = U.UserID + WHERE ' + @condition + ' +) + +INSERT INTO @Schedules +SELECT ScheduleID FROM TempSchedules +WHERE TempSchedules.Row BETWEEN @StartRow and @StartRow + @MaximumRows - 1 + +SELECT + S.ScheduleID, + S.TaskID, + ST.TaskType, + ST.RoleID, + S.ScheduleName, + S.ScheduleTypeID, + S.Interval, + S.FromTime, + S.ToTime, + S.StartTime, + S.LastRun, + S.NextRun, + S.Enabled, + 1 AS StatusID, + S.PriorityID, + S.MaxExecutionTime, + S.WeekMonthDay, + ISNULL(0, (SELECT TOP 1 SeverityID FROM AuditLog WHERE ItemID = S.ScheduleID AND SourceName = ''SCHEDULER'' ORDER BY StartDate DESC)) AS LastResult, + + -- packages + P.PackageID, + P.PackageName, + + -- user + P.UserID, + U.Username, + U.FirstName, + U.LastName, + U.FullName, + U.RoleID, + U.Email +FROM @Schedules AS STEMP +INNER JOIN Schedule AS S ON STEMP.ScheduleID = S.ScheduleID +INNER JOIN ScheduleTasks AS ST ON S.TaskID = ST.TaskID +INNER JOIN Packages AS P ON S.PackageID = P.PackageID +INNER JOIN UsersDetailed AS U ON P.UserID = U.UserID' + +exec sp_executesql @sql, N'@PackageID int, @StartRow int, @MaximumRows int, @Recursive bit', +@PackageID, @StartRow, @MaximumRows, @Recursive + +END +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE GetScheduleTask +( + @ActorID int, + @TaskID nvarchar(100) +) +AS + +-- get user role +DECLARE @RoleID int +SELECT @RoleID = RoleID FROM Users +WHERE UserID = @ActorID + +SELECT + TaskID, + TaskType, + RoleID +FROM ScheduleTasks +WHERE + TaskID = @TaskID + AND @RoleID >= RoleID +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE GetScheduleTasks +( + @ActorID int +) +AS + +-- get user role +DECLARE @RoleID int +SELECT @RoleID = RoleID FROM Users +WHERE UserID = @ActorID + +SELECT + TaskID, + TaskType, + RoleID +FROM ScheduleTasks +WHERE @RoleID <= RoleID +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + + + + + + + + + + + + + + + + + + + + +/****** Object: StoredProcedure [dbo].[GetScheduleTaskViewConfigurations] Script Date: 09/10/2007 17:53:56 ******/ + +CREATE PROCEDURE [dbo].[GetScheduleTaskViewConfigurations] +( + @TaskID nvarchar(100) +) +AS + +SELECT + @TaskID AS TaskID, + STVC.ConfigurationID, + STVC.Environment, + STVC.Description +FROM ScheduleTaskViewConfiguration AS STVC +WHERE STVC.TaskID = @TaskID + +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE GetSearchableServiceItemTypes + +AS +SELECT + ItemTypeID, + DisplayName +FROM + ServiceItemTypes +WHERE Searchable = 1 +ORDER BY TypeOrder +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[GetServer] +( + @ActorID int, + @ServerID int +) +AS +-- check rights +DECLARE @IsAdmin bit +SET @IsAdmin = dbo.CheckIsUserAdmin(@ActorID) + +SELECT + ServerID, + ServerName, + ServerUrl, + Password, + Comments, + VirtualServer, + InstantDomainAlias, + PrimaryGroupID, + ADEnabled, + ADRootDomain, + ADUsername, + ADPassword, + ADAuthenticationType +FROM Servers +WHERE + ServerID = @ServerID + AND @IsAdmin = 1 + +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE GetServerByName +( + @ActorID int, + @ServerName nvarchar(100) +) +AS +-- check rights +DECLARE @IsAdmin bit +SET @IsAdmin = dbo.CheckIsUserAdmin(@ActorID) + +SELECT + ServerID, + ServerName, + ServerUrl, + Password, + Comments, + VirtualServer, + InstantDomainAlias, + PrimaryGroupID, + ADRootDomain, + ADUsername, + ADPassword, + ADAuthenticationType +FROM Servers +WHERE + ServerName = @ServerName + AND @IsAdmin = 1 + +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE GetServerInternal +( + @ServerID int +) +AS +SELECT + ServerID, + ServerName, + ServerUrl, + Password, + Comments, + VirtualServer, + InstantDomainAlias, + PrimaryGroupID, + ADEnabled, + ADRootDomain, + ADUsername, + ADPassword, + ADAuthenticationType +FROM Servers +WHERE + ServerID = @ServerID + +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE GetServers +( + @ActorID int +) +AS +-- check rights +DECLARE @IsAdmin bit +SET @IsAdmin = dbo.CheckIsUserAdmin(@ActorID) + +SELECT + S.ServerID, + S.ServerName, + S.ServerUrl, + (SELECT COUNT(SRV.ServiceID) FROM Services AS SRV WHERE S.ServerID = SRV.ServerID) AS ServicesNumber, + S.Comments, + PrimaryGroupID, + S.ADEnabled +FROM Servers AS S +WHERE VirtualServer = 0 +AND @IsAdmin = 1 +ORDER BY S.ServerName + +-- services +SELECT + S.ServiceID, + S.ServerID, + S.ProviderID, + S.ServiceName, + S.Comments +FROM Services AS S +INNER JOIN Providers AS P ON S.ProviderID = P.ProviderID +INNER JOIN ResourceGroups AS RG ON P.GroupID = RG.GroupID +WHERE @IsAdmin = 1 +ORDER BY RG.GroupOrder + +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE GetServerShortDetails +( + @ServerID int +) +AS + +SELECT + ServerID, + ServerName, + Comments, + VirtualServer, + InstantDomainAlias +FROM Servers +WHERE + ServerID = @ServerID + +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + +CREATE PROCEDURE [dbo].[GetService] +( + @ActorID int, + @ServiceID int +) +AS + +SELECT + ServiceID, + Services.ServerID, + ProviderID, + ServiceName, + ServiceQuotaValue, + ClusterID, + Services.Comments, + Servers.ServerName +FROM Services INNER JOIN Servers ON Services.ServerID = Servers.ServerID +WHERE + ServiceID = @ServiceID + +RETURN + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[GetServiceItem] +( + @ActorID int, + @ItemID int +) +AS + +DECLARE @Items TABLE +( + ItemID int +) + +-- find service items +INSERT INTO @Items +SELECT + SI.ItemID +FROM ServiceItems AS SI +INNER JOIN Packages AS P ON SI.PackageID = P.PackageID +WHERE + SI.ItemID = @ItemID + AND dbo.CheckActorPackageRights(@ActorID, SI.PackageID) = 1 + + +-- select service items +SELECT + SI.ItemID, + SI.ItemName, + SI.ItemTypeID, + SIT.TypeName, + SI.ServiceID, + SI.PackageID, + P.PackageName, + S.ServiceID, + S.ServiceName, + SRV.ServerID, + SRV.ServerName, + RG.GroupName, + U.UserID, + U.Username, + U.FullName AS UserFullName, + SI.CreatedDate +FROM @Items AS FI +INNER JOIN ServiceItems AS SI ON FI.ItemID = SI.ItemID +INNER JOIN ServiceItemTypes AS SIT ON SI.ItemTypeID = SIT.ItemTypeID +INNER JOIN Packages AS P ON SI.PackageID = P.PackageID +INNER JOIN Services AS S ON SI.ServiceID = S.ServiceID +INNER JOIN Servers AS SRV ON S.ServerID = SRV.ServerID +INNER JOIN Providers AS PROV ON S.ProviderID = PROV.ProviderID +INNER JOIN ResourceGroups AS RG ON PROV.GroupID = RG.GroupID +INNER JOIN UsersDetailed AS U ON P.UserID = U.UserID + +-- select item properties +-- get corresponding item properties +SELECT + IP.ItemID, + IP.PropertyName, + IP.PropertyValue +FROM ServiceItemProperties AS IP +INNER JOIN @Items AS FI ON IP.ItemID = FI.ItemID + + +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[GetServiceItemByName] +( + @ActorID int, + @PackageID int, + @ItemName nvarchar(500), + @GroupName nvarchar(100) = NULL, + @ItemTypeName nvarchar(200) +) +AS + +-- check rights +IF dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 +RAISERROR('You are not allowed to access this package', 16, 1) + +DECLARE @Items TABLE +( + ItemID int +) + +-- find service items +INSERT INTO @Items +SELECT + SI.ItemID +FROM ServiceItems AS SI +INNER JOIN ServiceItemTypes AS SIT ON SI.ItemTypeID = SIT.ItemTypeID +INNER JOIN ResourceGroups AS RG ON SIT.GroupID = RG.GroupID +WHERE SI.PackageID = @PackageID AND SIT.TypeName = @ItemTypeName +AND SI.ItemName = @ItemName +AND ((@GroupName IS NULL) OR (@GroupName IS NOT NULL AND RG.GroupName = @GroupName)) + + +-- select service items +SELECT + SI.ItemID, + SI.ItemName, + SI.ItemTypeID, + SIT.TypeName, + SI.ServiceID, + SI.PackageID, + P.PackageName, + S.ServiceID, + S.ServiceName, + SRV.ServerID, + SRV.ServerName, + RG.GroupName, + U.UserID, + U.Username, + U.FullName AS UserFullName, + SI.CreatedDate +FROM @Items AS FI +INNER JOIN ServiceItems AS SI ON FI.ItemID = SI.ItemID +INNER JOIN ServiceItemTypes AS SIT ON SI.ItemTypeID = SIT.ItemTypeID +INNER JOIN Packages AS P ON SI.PackageID = P.PackageID +INNER JOIN Services AS S ON SI.ServiceID = S.ServiceID +INNER JOIN Servers AS SRV ON S.ServerID = SRV.ServerID +INNER JOIN Providers AS PROV ON S.ProviderID = PROV.ProviderID +INNER JOIN ResourceGroups AS RG ON PROV.GroupID = RG.GroupID +INNER JOIN UsersDetailed AS U ON P.UserID = U.UserID + +-- select item properties +-- get corresponding item properties +SELECT + IP.ItemID, + IP.PropertyName, + IP.PropertyValue +FROM ServiceItemProperties AS IP +INNER JOIN @Items AS FI ON IP.ItemID = FI.ItemID + + +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[GetServiceItems] +( + @ActorID int, + @PackageID int, + @ItemTypeName nvarchar(200), + @GroupName nvarchar(100) = NULL, + @Recursive bit +) +AS + +-- check rights +IF dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 +RAISERROR('You are not allowed to access this package', 16, 1) + +DECLARE @Items TABLE +( + ItemID int +) + +-- find service items +INSERT INTO @Items +SELECT + SI.ItemID +FROM ServiceItems AS SI +INNER JOIN PackagesTree(@PackageID, @Recursive) AS PT ON SI.PackageID = PT.PackageID +INNER JOIN ServiceItemTypes AS IT ON SI.ItemTypeID = IT.ItemTypeID +INNER JOIN ResourceGroups AS RG ON IT.GroupID = RG.GroupID +WHERE IT.TypeName = @ItemTypeName +AND ((@GroupName IS NULL) OR (@GroupName IS NOT NULL AND RG.GroupName = @GroupName)) + + +-- select service items +SELECT + SI.ItemID, + SI.ItemName, + SI.ItemTypeID, + SIT.TypeName, + SI.ServiceID, + SI.PackageID, + P.PackageName, + S.ServiceID, + S.ServiceName, + SRV.ServerID, + SRV.ServerName, + RG.GroupName, + U.UserID, + U.Username, + (U.FirstName + U.LastName) AS UserFullName, + SI.CreatedDate +FROM @Items AS FI +INNER JOIN ServiceItems AS SI ON FI.ItemID = SI.ItemID +INNER JOIN ServiceItemTypes AS SIT ON SI.ItemTypeID = SIT.ItemTypeID +INNER JOIN Packages AS P ON SI.PackageID = P.PackageID +INNER JOIN Services AS S ON SI.ServiceID = S.ServiceID +INNER JOIN Servers AS SRV ON S.ServerID = SRV.ServerID +INNER JOIN ResourceGroups AS RG ON SIT.GroupID = RG.GroupID +INNER JOIN Users AS U ON P.UserID = U.UserID + +-- select item properties +-- get corresponding item properties +SELECT + IP.ItemID, + IP.PropertyName, + IP.PropertyValue +FROM ServiceItemProperties AS IP +INNER JOIN @Items AS FI ON IP.ItemID = FI.ItemID + +RETURN + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[GetServiceItemsByName] +( + @ActorID int, + @PackageID int, + @ItemName nvarchar(500) +) +AS + +-- check rights +IF dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 +RAISERROR('You are not allowed to access this package', 16, 1) + +DECLARE @Items TABLE +( + ItemID int +) + +-- find service items +INSERT INTO @Items +SELECT + SI.ItemID +FROM ServiceItems AS SI +INNER JOIN ServiceItemTypes AS SIT ON SI.ItemTypeID = SIT.ItemTypeID +WHERE SI.PackageID = @PackageID +AND SI.ItemName LIKE @ItemName + + +-- select service items +SELECT + SI.ItemID, + SI.ItemName, + SI.ItemTypeID, + SIT.TypeName, + SI.ServiceID, + SI.PackageID, + P.PackageName, + S.ServiceID, + S.ServiceName, + SRV.ServerID, + SRV.ServerName, + RG.GroupName, + U.UserID, + U.Username, + U.FullName AS UserFullName, + SI.CreatedDate +FROM @Items AS FI +INNER JOIN ServiceItems AS SI ON FI.ItemID = SI.ItemID +INNER JOIN ServiceItemTypes AS SIT ON SI.ItemTypeID = SIT.ItemTypeID +INNER JOIN Packages AS P ON SI.PackageID = P.PackageID +INNER JOIN Services AS S ON SI.ServiceID = S.ServiceID +INNER JOIN Servers AS SRV ON S.ServerID = SRV.ServerID +INNER JOIN ResourceGroups AS RG ON SIT.GroupID = RG.GroupID +INNER JOIN UsersDetailed AS U ON P.UserID = U.UserID + +-- select item properties +-- get corresponding item properties +SELECT + IP.ItemID, + IP.PropertyName, + IP.PropertyValue +FROM ServiceItemProperties AS IP +INNER JOIN @Items AS FI ON IP.ItemID = FI.ItemID + + +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[GetServiceItemsByPackage] +( + @ActorID int, + @PackageID int +) +AS + +-- check rights +IF dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 +RAISERROR('You are not allowed to access this package', 16, 1) + +DECLARE @Items TABLE +( + ItemID int +) + +-- find service items +INSERT INTO @Items +SELECT + SI.ItemID +FROM ServiceItems AS SI +WHERE SI.PackageID = @PackageID + + +-- select service items +SELECT + SI.ItemID, + SI.ItemName, + SI.ItemTypeID, + SIT.TypeName, + SIT.DisplayName, + SI.ServiceID, + SI.PackageID, + P.PackageName, + S.ServiceID, + S.ServiceName, + SRV.ServerID, + SRV.ServerName, + RG.GroupName, + U.UserID, + U.Username, + (U.FirstName + U.LastName) AS UserFullName, + SI.CreatedDate +FROM @Items AS FI +INNER JOIN ServiceItems AS SI ON FI.ItemID = SI.ItemID +INNER JOIN ServiceItemTypes AS SIT ON SI.ItemTypeID = SIT.ItemTypeID +INNER JOIN Packages AS P ON SI.PackageID = P.PackageID +INNER JOIN Services AS S ON SI.ServiceID = S.ServiceID +INNER JOIN Servers AS SRV ON S.ServerID = SRV.ServerID +INNER JOIN ResourceGroups AS RG ON SIT.GroupID = RG.GroupID +INNER JOIN Users AS U ON P.UserID = U.UserID + +-- select item properties +-- get corresponding item properties +SELECT + IP.ItemID, + IP.PropertyName, + IP.PropertyValue +FROM ServiceItemProperties AS IP +INNER JOIN @Items AS FI ON IP.ItemID = FI.ItemID + +RETURN + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[GetServiceItemsByService] +( + @ActorID int, + @ServiceID int +) +AS + +-- check rights +DECLARE @IsAdmin bit +SET @IsAdmin = dbo.CheckIsUserAdmin(@ActorID) + +DECLARE @Items TABLE +( + ItemID int +) + +-- find service items +INSERT INTO @Items +SELECT + SI.ItemID +FROM ServiceItems AS SI +WHERE SI.ServiceID = @ServiceID + + +-- select service items +SELECT + SI.ItemID, + SI.ItemName, + SI.ItemTypeID, + SIT.TypeName, + SI.ServiceID, + SI.PackageID, + P.PackageName, + S.ServiceID, + S.ServiceName, + SRV.ServerID, + SRV.ServerName, + RG.GroupName, + U.UserID, + U.Username, + (U.FirstName + U.LastName) AS UserFullName, + SI.CreatedDate +FROM @Items AS FI +INNER JOIN ServiceItems AS SI ON FI.ItemID = SI.ItemID +INNER JOIN ServiceItemTypes AS SIT ON SI.ItemTypeID = SIT.ItemTypeID +INNER JOIN Packages AS P ON SI.PackageID = P.PackageID +INNER JOIN Services AS S ON SI.ServiceID = S.ServiceID +INNER JOIN Servers AS SRV ON S.ServerID = SRV.ServerID +INNER JOIN ResourceGroups AS RG ON SIT.GroupID = RG.GroupID +INNER JOIN Users AS U ON P.UserID = U.UserID +WHERE @IsAdmin = 1 + +-- select item properties +-- get corresponding item properties +SELECT + IP.ItemID, + IP.PropertyName, + IP.PropertyValue +FROM ServiceItemProperties AS IP +INNER JOIN @Items AS FI ON IP.ItemID = FI.ItemID +WHERE @IsAdmin = 1 + +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[GetServiceItemsCount] +( + @ItemTypeName nvarchar(200), + @GroupName nvarchar(100) = NULL, + @ServiceID int = 0, + @TotalNumber int OUTPUT +) +AS + +SET @TotalNumber = 0 + +-- find service items +SELECT + @TotalNumber = COUNT(SI.ItemID) +FROM ServiceItems AS SI +INNER JOIN ServiceItemTypes AS IT ON SI.ItemTypeID = IT.ItemTypeID +INNER JOIN ResourceGroups AS RG ON IT.GroupID = RG.GroupID +WHERE IT.TypeName = @ItemTypeName +AND ((@GroupName IS NULL) OR (@GroupName IS NOT NULL AND RG.GroupName = @GroupName)) +AND ((@ServiceID = 0) OR (@ServiceID > 0 AND SI.ServiceID = @ServiceID)) + +RETURN + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[GetServiceItemsForStatistics] +( + @ActorID int, + @ServiceID int, + @PackageID int, + @CalculateDiskspace bit, + @CalculateBandwidth bit, + @Suspendable bit, + @Disposable bit +) +AS +DECLARE @Items TABLE +( + ItemID int +) + +-- find service items +INSERT INTO @Items +SELECT + SI.ItemID +FROM ServiceItems AS SI +INNER JOIN ServiceItemTypes AS SIT ON SI.ItemTypeID = SIT.ItemTypeID +WHERE + ((@ServiceID = 0) OR (@ServiceID > 0 AND SI.ServiceID = @ServiceID)) + AND ((@PackageID = 0) OR (@PackageID > 0 AND SI.PackageID = @PackageID)) + AND ((@CalculateDiskspace = 0) OR (@CalculateDiskspace = 1 AND SIT.CalculateDiskspace = @CalculateDiskspace)) + AND ((@CalculateBandwidth = 0) OR (@CalculateBandwidth = 1 AND SIT.CalculateBandwidth = @CalculateBandwidth)) + AND ((@Suspendable = 0) OR (@Suspendable = 1 AND SIT.Suspendable = @Suspendable)) + AND ((@Disposable = 0) OR (@Disposable = 1 AND SIT.Disposable = @Disposable)) + +-- select service items +SELECT + SI.ItemID, + SI.ItemName, + SI.ItemTypeID, + RG.GroupName, + SIT.TypeName, + SI.ServiceID, + SI.PackageID, + SI.CreatedDate +FROM @Items AS FI +INNER JOIN ServiceItems AS SI ON FI.ItemID = SI.ItemID +INNER JOIN ServiceItemTypes AS SIT ON SI.ItemTypeID = SIT.ItemTypeID +INNER JOIN ResourceGroups AS RG ON SIT.GroupID = RG.GroupID +ORDER BY RG.GroupOrder DESC, SI.ItemName + +-- select item properties +-- get corresponding item properties +SELECT + IP.ItemID, + IP.PropertyName, + IP.PropertyValue +FROM ServiceItemProperties AS IP +INNER JOIN @Items AS FI ON IP.ItemID = FI.ItemID + +RETURN + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[GetServiceItemsPaged] +( + @ActorID int, + @PackageID int, + @ItemTypeName nvarchar(200), + @GroupName nvarchar(100) = NULL, + @ServerID int, + @Recursive bit, + @FilterColumn nvarchar(50) = '', + @FilterValue nvarchar(50) = '', + @SortColumn nvarchar(50), + @StartRow int, + @MaximumRows int +) +AS + + +-- check rights +IF dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 +RAISERROR('You are not allowed to access this package', 16, 1) + +-- start +DECLARE @GroupID int +SELECT @GroupID = GroupID FROM ResourceGroups +WHERE GroupName = @GroupName + +DECLARE @ItemTypeID int +SELECT @ItemTypeID = ItemTypeID FROM ServiceItemTypes +WHERE TypeName = @ItemTypeName +AND ((@GroupID IS NULL) OR (@GroupID IS NOT NULL AND GroupID = @GroupID)) + +DECLARE @condition nvarchar(700) +SET @condition = 'SI.ItemTypeID = @ItemTypeID +AND ((@Recursive = 0 AND P.PackageID = @PackageID) + OR (@Recursive = 1 AND dbo.CheckPackageParent(@PackageID, P.PackageID) = 1)) +AND ((@GroupID IS NULL) OR (@GroupID IS NOT NULL AND IT.GroupID = @GroupID)) +AND (@ServerID = 0 OR (@ServerID > 0 AND S.ServerID = @ServerID)) +' + +IF @FilterColumn <> '' AND @FilterColumn IS NOT NULL +AND @FilterValue <> '' AND @FilterValue IS NOT NULL +SET @condition = @condition + ' AND ' + @FilterColumn + ' LIKE ''' + @FilterValue + '''' + +IF @SortColumn IS NULL OR @SortColumn = '' +SET @SortColumn = 'SI.ItemName ASC' + +DECLARE @sql nvarchar(3500) + +set @sql = ' +SELECT COUNT(SI.ItemID) FROM Packages AS P +INNER JOIN ServiceItems AS SI ON P.PackageID = SI.PackageID +INNER JOIN UsersDetailed AS U ON P.UserID = U.UserID +INNER JOIN ServiceItemTypes AS IT ON SI.ItemTypeID = IT.ItemTypeID +INNER JOIN Services AS S ON SI.ServiceID = S.ServiceID +WHERE ' + @condition + ' + +DECLARE @Items AS TABLE +( + ItemID int +); + +WITH TempItems AS ( + SELECT ROW_NUMBER() OVER (ORDER BY ' + @SortColumn + ') as Row, + SI.ItemID + FROM Packages AS P + INNER JOIN ServiceItems AS SI ON P.PackageID = SI.PackageID + INNER JOIN UsersDetailed AS U ON P.UserID = U.UserID + INNER JOIN ServiceItemTypes AS IT ON SI.ItemTypeID = IT.ItemTypeID + INNER JOIN Services AS S ON SI.ServiceID = S.ServiceID + INNER JOIN Servers AS SRV ON S.ServerID = SRV.ServerID + WHERE ' + @condition + ' +) + +INSERT INTO @Items +SELECT ItemID FROM TempItems +WHERE TempItems.Row BETWEEN @StartRow + 1 and @StartRow + @MaximumRows + +SELECT + SI.ItemID, + SI.ItemName, + SI.ItemTypeID, + IT.TypeName, + SI.ServiceID, + SI.PackageID, + SI.CreatedDate, + RG.GroupName, + + -- packages + P.PackageName, + + -- server + ISNULL(SRV.ServerID, 0) AS ServerID, + ISNULL(SRV.ServerName, '''') AS ServerName, + ISNULL(SRV.Comments, '''') AS ServerComments, + ISNULL(SRV.VirtualServer, 0) AS VirtualServer, + + -- user + P.UserID, + U.Username, + U.FirstName, + U.LastName, + U.FullName, + U.RoleID, + U.Email +FROM @Items AS TSI +INNER JOIN ServiceItems AS SI ON TSI.ItemID = SI.ItemID +INNER JOIN ServiceItemTypes AS IT ON SI.ItemTypeID = IT.ItemTypeID +INNER JOIN Packages AS P ON SI.PackageID = P.PackageID +INNER JOIN UsersDetailed AS U ON P.UserID = U.UserID +INNER JOIN Services AS S ON SI.ServiceID = S.ServiceID +INNER JOIN Servers AS SRV ON S.ServerID = SRV.ServerID +INNER JOIN ResourceGroups AS RG ON IT.GroupID = RG.GroupID + + +SELECT + IP.ItemID, + IP.PropertyName, + IP.PropertyValue +FROM ServiceItemProperties AS IP +INNER JOIN @Items AS TSI ON IP.ItemID = TSI.ItemID' + +--print @sql + +exec sp_executesql @sql, N'@ItemTypeID int, @PackageID int, @GroupID int, @StartRow int, @MaximumRows int, @Recursive bit, @ServerID int', +@ItemTypeID, @PackageID, @GroupID, @StartRow, @MaximumRows, @Recursive, @ServerID + +RETURN + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[GetServiceItemType] +( + @ItemTypeID int +) +AS +SELECT + [ItemTypeID], + [GroupID], + [DisplayName], + [TypeName], + [TypeOrder], + [CalculateDiskspace], + [CalculateBandwidth], + [Suspendable], + [Disposable], + [Searchable], + [Importable], + [Backupable] +FROM + [ServiceItemTypes] +WHERE + [ItemTypeID] = @ItemTypeID + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[GetServiceItemTypes] +AS +SELECT + [ItemTypeID], + [GroupID], + [DisplayName], + [TypeName], + [TypeOrder], + [CalculateDiskspace], + [CalculateBandwidth], + [Suspendable], + [Disposable], + [Searchable], + [Importable], + [Backupable] +FROM + [ServiceItemTypes] +ORDER BY TypeOrder + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE GetServiceProperties +( + @ActorID int, + @ServiceID int +) +AS + + +SELECT ServiceID, PropertyName, PropertyValue +FROM ServiceProperties +WHERE + ServiceID = @ServiceID + +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE GetServicesByGroupID +( + @ActorID int, + @GroupID int +) +AS +-- check rights +DECLARE @IsAdmin bit +SET @IsAdmin = dbo.CheckIsUserAdmin(@ActorID) + +SELECT + S.ServiceID, + S.ServiceName, + S.ServerID, + S.ServiceQuotaValue, + SRV.ServerName, + S.ProviderID, + S.ServiceName+' on '+SRV.ServerName AS FullServiceName +FROM Services AS S +INNER JOIN Providers AS PROV ON S.ProviderID = PROV.ProviderID +INNER JOIN Servers AS SRV ON S.ServerID = SRV.ServerID +WHERE + PROV.GroupID = @GroupID + AND @IsAdmin = 1 +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + +CREATE PROCEDURE [dbo].[GetServicesByGroupName] +( + @ActorID int, + @GroupName nvarchar(100) +) +AS +-- check rights +DECLARE @IsAdmin bit +SET @IsAdmin = dbo.CheckIsUserAdmin(@ActorID) + +SELECT + S.ServiceID, + S.ServiceName, + S.ServerID, + S.ServiceQuotaValue, + SRV.ServerName, + S.ProviderID, + PROV.ProviderName, + S.ServiceName + ' on ' + SRV.ServerName AS FullServiceName +FROM Services AS S +INNER JOIN Providers AS PROV ON S.ProviderID = PROV.ProviderID +INNER JOIN Servers AS SRV ON S.ServerID = SRV.ServerID +INNER JOIN ResourceGroups AS RG ON PROV.GroupID = RG.GroupID +WHERE + RG.GroupName = @GroupName + AND @IsAdmin = 1 +RETURN + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE GetServicesByServerID +( + @ActorID int, + @ServerID int +) +AS + +-- check rights +DECLARE @IsAdmin bit +SET @IsAdmin = dbo.CheckIsUserAdmin(@ActorID) + + +SELECT + S.ServiceID, + S.ServerID, + S.ServiceName, + S.Comments, + S.ServiceQuotaValue, + RG.GroupName, + S.ProviderID, + PROV.DisplayName AS ProviderName +FROM Services AS S +INNER JOIN Providers AS PROV ON S.ProviderID = PROV.ProviderID +INNER JOIN ResourceGroups AS RG ON PROV.GroupID = RG.GroupID +WHERE + S.ServerID = @ServerID + AND @IsAdmin = 1 +ORDER BY RG.GroupOrder + +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE GetServicesByServerIDGroupName +( + @ActorID int, + @ServerID int, + @GroupName nvarchar(50) +) +AS + +-- check rights +DECLARE @IsAdmin bit +SET @IsAdmin = dbo.CheckIsUserAdmin(@ActorID) + +SELECT + S.ServiceID, + S.ServerID, + S.ServiceName, + S.Comments, + S.ServiceQuotaValue, + RG.GroupName, + PROV.DisplayName AS ProviderName +FROM Services AS S +INNER JOIN Providers AS PROV ON S.ProviderID = PROV.ProviderID +INNER JOIN ResourceGroups AS RG ON PROV.GroupID = RG.GroupID +WHERE + S.ServerID = @ServerID AND RG.GroupName = @GroupName + AND @IsAdmin = 1 +ORDER BY RG.GroupOrder + +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + +CREATE PROCEDURE [dbo].[GetSiteCert] +( + @ActorID int, + @ID int +) +AS + +SELECT + [UserID], [SiteID], [Hostname], [CSR], [Certificate], [Hash], [Installed], [IsRenewal] +FROM + [dbo].[SSLCertificates] +INNER JOIN + [dbo].[ServiceItems] AS [SI] ON [SSLCertificates].[SiteID] = [SI].[ItemID] +WHERE + [SiteID] = @ID AND [Installed] = 1 AND [dbo].CheckActorPackageRights(@ActorID, [SI].[PackageID]) = 1 +RETURN + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + +CREATE PROCEDURE [dbo].[GetSSLCertificateByID] +( + @ActorID int, + @ID int +) +AS + +SELECT + [ID], [UserID], [SiteID], [Hostname], [FriendlyName], [CSR], [Certificate], [Hash], [Installed], [IsRenewal], [PreviousId] +FROM + [dbo].[SSLCertificates] +INNER JOIN + [dbo].[ServiceItems] AS [SI] ON [SSLCertificates].[SiteID] = [SI].[ItemID] +WHERE + [ID] = @ID AND [dbo].CheckActorPackageRights(@ActorID, [SI].[PackageID]) = 1 + +RETURN + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE GetSystemSettings + @SettingsName nvarchar(50) +AS +BEGIN + + SET NOCOUNT ON; + + SELECT + [PropertyName], + [PropertyValue] + FROM + [dbo].[SystemSettings] + WHERE + [SettingsName] = @SettingsName; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + +CREATE PROCEDURE [dbo].[GetUnallottedIPAddresses] + @PackageID int, + @ServiceID int, + @PoolID int = 0 +AS +BEGIN + + DECLARE @ParentPackageID int + DECLARE @ServerID int + + SELECT + @ParentPackageID = ParentPackageID, + @ServerID = ServerID + FROM Packages + WHERE PackageID = @PackageId + + IF (@ParentPackageID = 1 OR @PoolID = 4 /* management network */) -- "System" space + BEGIN + -- check if server is physical + IF EXISTS(SELECT * FROM Servers WHERE ServerID = @ServerID AND VirtualServer = 0) + BEGIN + -- physical server + SELECT + IP.AddressID, + IP.ExternalIP, + IP.InternalIP, + IP.ServerID, + IP.PoolID, + IP.SubnetMask, + IP.DefaultGateway + FROM dbo.IPAddresses AS IP + WHERE + IP.ServerID = @ServerID + AND IP.AddressID NOT IN (SELECT PIP.AddressID FROM dbo.PackageIPAddresses AS PIP) + AND (@PoolID = 0 OR @PoolID <> 0 AND IP.PoolID = @PoolID) + ORDER BY IP.DefaultGateway, IP.ExternalIP + END + ELSE + BEGIN + -- virtual server + -- get resource group by service + DECLARE @GroupID int + SELECT @GroupID = P.GroupID FROM Services AS S + INNER JOIN Providers AS P ON S.ProviderID = P.ProviderID + WHERE S.ServiceID = @ServiceID + + SELECT + IP.AddressID, + IP.ExternalIP, + IP.InternalIP, + IP.ServerID, + IP.PoolID, + IP.SubnetMask, + IP.DefaultGateway + FROM dbo.IPAddresses AS IP + WHERE + IP.ServerID IN ( + SELECT SVC.ServerID FROM [dbo].[Services] AS SVC + INNER JOIN [dbo].[Providers] AS P ON SVC.ProviderID = P.ProviderID + WHERE [SVC].[ServiceID] = @ServiceId AND P.GroupID = @GroupID + ) + AND IP.AddressID NOT IN (SELECT PIP.AddressID FROM dbo.PackageIPAddresses AS PIP) + AND (@PoolID = 0 OR @PoolID <> 0 AND IP.PoolID = @PoolID) + ORDER BY IP.DefaultGateway, IP.ExternalIP + END + END + ELSE -- 2rd level space and below + BEGIN + -- get service location + SELECT @ServerID = S.ServerID FROM Services AS S + WHERE S.ServiceID = @ServiceID + + SELECT + IP.AddressID, + IP.ExternalIP, + IP.InternalIP, + IP.ServerID, + IP.PoolID, + IP.SubnetMask, + IP.DefaultGateway + FROM dbo.PackageIPAddresses AS PIP + INNER JOIN IPAddresses AS IP ON PIP.AddressID = IP.AddressID + WHERE + PIP.PackageID = @ParentPackageID + AND PIP.ItemID IS NULL + AND (@PoolID = 0 OR @PoolID <> 0 AND IP.PoolID = @PoolID) + AND IP.ServerID = @ServerID + ORDER BY IP.DefaultGateway, IP.ExternalIP + END +END + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE GetUserAvailableHostingAddons +( + @ActorID int, + @UserID int +) +AS + +-- user should see the plans only of his reseller +-- also user can create packages based on his own plans (admins and resellers) + +DECLARE @Plans TABLE +( + PlanID int +) + +-- check rights +IF dbo.CheckActorUserRights(@ActorID, @UserID) = 0 +RAISERROR('You are not allowed to access this account', 16, 1) + +DECLARE @OwnerID int +SELECT @OwnerID = OwnerID FROM Users +WHERE UserID = @UserID + +SELECT + HP.PlanID, + HP.PackageID, + HP.PlanName, + HP.PlanDescription, + HP.Available, + HP.ServerID, + HP.SetupPrice, + HP.RecurringPrice, + HP.RecurrenceLength, + HP.RecurrenceUnit, + HP.IsAddon +FROM + HostingPlans AS HP +WHERE HP.UserID = @OwnerID +AND HP.IsAddon = 1 +ORDER BY PlanName +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE GetUserAvailableHostingPlans +( + @ActorID int, + @UserID int +) +AS + +-- user should see the plans only of his reseller +-- also user can create packages based on his own plans (admins and resellers) + +DECLARE @Plans TABLE +( + PlanID int +) + +-- check rights +IF dbo.CheckActorUserRights(@ActorID, @UserID) = 0 +RAISERROR('You are not allowed to access this account', 16, 1) + +DECLARE @OwnerID int +SELECT @OwnerID = OwnerID FROM Users +WHERE UserID = @UserID + +SELECT + HP.PlanID, + HP.PackageID, + HP.PlanName, + HP.PlanDescription, + HP.Available, + HP.ServerID, + HP.SetupPrice, + HP.RecurringPrice, + HP.RecurrenceLength, + HP.RecurrenceUnit, + HP.IsAddon +FROM + HostingPlans AS HP +WHERE HP.UserID = @OwnerID +AND HP.IsAddon = 0 +ORDER BY PlanName +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + +CREATE PROCEDURE [dbo].[GetUserByExchangeOrganizationIdInternally] +( + @ItemID int +) +AS + SELECT + U.UserID, + U.RoleID, + U.StatusID, + U.SubscriberNumber, + U.LoginStatusId, + U.FailedLogins, + U.OwnerID, + U.Created, + U.Changed, + U.IsDemo, + U.Comments, + U.IsPeer, + U.Username, + U.Password, + U.FirstName, + U.LastName, + U.Email, + U.SecondaryEmail, + U.Address, + U.City, + U.State, + U.Country, + U.Zip, + U.PrimaryPhone, + U.SecondaryPhone, + U.Fax, + U.InstantMessenger, + U.HtmlMail, + U.CompanyName, + U.EcommerceEnabled, + U.[AdditionalParams] + FROM Users AS U + WHERE U.UserID IN (SELECT UserID FROM Packages WHERE PackageID IN ( + SELECT PackageID FROM ServiceItems WHERE ItemID = @ItemID)) + +RETURN + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + +CREATE PROCEDURE [dbo].[GetUserById] +( + @ActorID int, + @UserID int +) +AS + -- user can retrieve his own account, his users accounts + -- and his reseller account (without pasword) + SELECT + U.UserID, + U.RoleID, + U.StatusID, + U.SubscriberNumber, + U.LoginStatusId, + U.FailedLogins, + U.OwnerID, + U.Created, + U.Changed, + U.IsDemo, + U.Comments, + U.IsPeer, + U.Username, + CASE WHEN dbo.CanGetUserPassword(@ActorID, @UserID) = 1 THEN U.Password + ELSE '' END AS Password, + U.FirstName, + U.LastName, + U.Email, + U.SecondaryEmail, + U.Address, + U.City, + U.State, + U.Country, + U.Zip, + U.PrimaryPhone, + U.SecondaryPhone, + U.Fax, + U.InstantMessenger, + U.HtmlMail, + U.CompanyName, + U.EcommerceEnabled, + U.[AdditionalParams] + FROM Users AS U + WHERE U.UserID = @UserID + AND dbo.CanGetUserDetails(@ActorID, @UserID) = 1 -- actor user rights + + RETURN + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[GetUserByIdInternally] +( + @UserID int +) +AS + SELECT + U.UserID, + U.RoleID, + U.StatusID, + U.SubscriberNumber, + U.LoginStatusId, + U.FailedLogins, + U.OwnerID, + U.Created, + U.Changed, + U.IsDemo, + U.Comments, + U.IsPeer, + U.Username, + U.Password, + U.FirstName, + U.LastName, + U.Email, + U.SecondaryEmail, + U.Address, + U.City, + U.State, + U.Country, + U.Zip, + U.PrimaryPhone, + U.SecondaryPhone, + U.Fax, + U.InstantMessenger, + U.HtmlMail, + U.CompanyName, + U.EcommerceEnabled, + U.[AdditionalParams] + FROM Users AS U + WHERE U.UserID = @UserID + + RETURN + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + + + + + +CREATE PROCEDURE [dbo].[GetUserByUsername] +( + @ActorID int, + @Username nvarchar(50) +) +AS + + SELECT + U.UserID, + U.RoleID, + U.StatusID, + U.SubscriberNumber, + U.LoginStatusId, + U.FailedLogins, + U.OwnerID, + U.Created, + U.Changed, + U.IsDemo, + U.Comments, + U.IsPeer, + U.Username, + CASE WHEN dbo.CanGetUserPassword(@ActorID, UserID) = 1 THEN U.Password + ELSE '' END AS Password, + U.FirstName, + U.LastName, + U.Email, + U.SecondaryEmail, + U.Address, + U.City, + U.State, + U.Country, + U.Zip, + U.PrimaryPhone, + U.SecondaryPhone, + U.Fax, + U.InstantMessenger, + U.HtmlMail, + U.CompanyName, + U.EcommerceEnabled, + U.[AdditionalParams] + FROM Users AS U + WHERE U.Username = @Username + AND dbo.CanGetUserDetails(@ActorID, UserID) = 1 -- actor user rights + + RETURN + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + + + +CREATE PROCEDURE [dbo].[GetUserByUsernameInternally] +( + @Username nvarchar(50) +) +AS + SELECT + U.UserID, + U.RoleID, + U.StatusID, + U.SubscriberNumber, + U.LoginStatusId, + U.FailedLogins, + U.OwnerID, + U.Created, + U.Changed, + U.IsDemo, + U.Comments, + U.IsPeer, + U.Username, + U.Password, + U.FirstName, + U.LastName, + U.Email, + U.SecondaryEmail, + U.Address, + U.City, + U.State, + U.Country, + U.Zip, + U.PrimaryPhone, + U.SecondaryPhone, + U.Fax, + U.InstantMessenger, + U.HtmlMail, + U.CompanyName, + U.EcommerceEnabled, + U.[AdditionalParams] + FROM Users AS U + WHERE U.Username = @Username + + RETURN + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[GetUserDomainsPaged] +( + @ActorID int, + @UserID int, + @FilterColumn nvarchar(50) = '', + @FilterValue nvarchar(50) = '', + @SortColumn nvarchar(50), + @StartRow int, + @MaximumRows int +) +AS +-- build query and run it to the temporary table +DECLARE @sql nvarchar(2000) + +SET @sql = ' +DECLARE @HasUserRights bit +SET @HasUserRights = dbo.CheckActorUserRights(@ActorID, @UserID) + +DECLARE @EndRow int +SET @EndRow = @StartRow + @MaximumRows +DECLARE @Users TABLE +( + ItemPosition int IDENTITY(1,1), + UserID int, + DomainID int +) +INSERT INTO @Users (UserID, DomainID) +SELECT + U.UserID, + D.DomainID +FROM Users AS U +INNER JOIN UsersTree(@UserID, 1) AS UT ON U.UserID = UT.UserID +LEFT OUTER JOIN Packages AS P ON U.UserID = P.UserID +LEFT OUTER JOIN Domains AS D ON P.PackageID = D.PackageID +WHERE + U.UserID <> @UserID AND U.IsPeer = 0 + AND @HasUserRights = 1 ' + +IF @FilterColumn <> '' AND @FilterValue <> '' +SET @sql = @sql + ' AND ' + @FilterColumn + ' LIKE @FilterValue ' + +IF @SortColumn <> '' AND @SortColumn IS NOT NULL +SET @sql = @sql + ' ORDER BY ' + @SortColumn + ' ' + +SET @sql = @sql + ' SELECT COUNT(UserID) FROM @Users; +SELECT + U.UserID, + U.RoleID, + U.StatusID, + U.SubscriberNumber, + U.LoginStatusId, + U.FailedLogins, + U.OwnerID, + U.Created, + U.Changed, + U.IsDemo, + U.Comments, + U.IsPeer, + U.Username, + U.FirstName, + U.LastName, + U.Email, + D.DomainName +FROM @Users AS TU +INNER JOIN Users AS U ON TU.UserID = U.UserID +LEFT OUTER JOIN Domains AS D ON TU.DomainID = D.DomainID +WHERE TU.ItemPosition BETWEEN @StartRow AND @EndRow' + +exec sp_executesql @sql, N'@StartRow int, @MaximumRows int, @UserID int, @FilterValue nvarchar(50), @ActorID int', +@StartRow, @MaximumRows, @UserID, @FilterValue, @ActorID + + +RETURN + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[GetUserParents] +( + @ActorID int, + @UserID int +) +AS + +-- check rights +IF dbo.CheckActorUserRights(@ActorID, @UserID) = 0 +RAISERROR('You are not allowed to access this account', 16, 1) + +SELECT + U.UserID, + U.RoleID, + U.StatusID, + U.SubscriberNumber, + U.LoginStatusId, + U.FailedLogins, + U.OwnerID, + U.Created, + U.Changed, + U.IsDemo, + U.Comments, + U.IsPeer, + U.Username, + U.FirstName, + U.LastName, + U.Email, + U.CompanyName, + U.EcommerceEnabled +FROM UserParents(@ActorID, @UserID) AS UP +INNER JOIN Users AS U ON UP.UserID = U.UserID +ORDER BY UP.UserOrder DESC +RETURN + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[GetUserPeers] +( + @ActorID int, + @UserID int +) +AS + +DECLARE @CanGetDetails bit +SET @CanGetDetails = dbo.CanGetUserDetails(@ActorID, @UserID) + +SELECT + U.UserID, + U.RoleID, + U.StatusID, + U.LoginStatusId, + U.FailedLogins, + U.OwnerID, + U.Created, + U.Changed, + U.IsDemo, + U.Comments, + U.IsPeer, + U.Username, + U.FirstName, + U.LastName, + U.Email, + U.FullName, + (U.FirstName + ' ' + U.LastName) AS FullName, + U.CompanyName, + U.EcommerceEnabled +FROM UsersDetailed AS U +WHERE U.OwnerID = @UserID AND IsPeer = 1 +AND @CanGetDetails = 1 -- actor rights + +RETURN + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[GetUsers] +( + @ActorID int, + @OwnerID int, + @Recursive bit = 0 +) +AS + +DECLARE @CanGetDetails bit +SET @CanGetDetails = dbo.CanGetUserDetails(@ActorID, @OwnerID) + +SELECT + U.UserID, + U.RoleID, + U.StatusID, + U.SubscriberNumber, + U.LoginStatusId, + U.FailedLogins, + U.OwnerID, + U.Created, + U.Changed, + U.IsDemo, + U.Comments, + U.IsPeer, + U.Username, + U.FirstName, + U.LastName, + U.Email, + U.FullName, + U.OwnerUsername, + U.OwnerFirstName, + U.OwnerLastName, + U.OwnerRoleID, + U.OwnerFullName, + U.PackagesNumber, + U.CompanyName, + U.EcommerceEnabled +FROM UsersDetailed AS U +WHERE U.UserID <> @OwnerID AND +((@Recursive = 1 AND dbo.CheckUserParent(@OwnerID, U.UserID) = 1) OR +(@Recursive = 0 AND U.OwnerID = @OwnerID)) +AND U.IsPeer = 0 +AND @CanGetDetails = 1 -- actor user rights + +RETURN + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +/* +Algorythm: + 0. Get the primary distribution resource from hosting plan + 1. Check whether user has Resource of requested type in his user plans/add-ons + EXCEPTION "The requested service is not available for the user. The resource of the requested type {type} should be assigned to him through hosting plan or add-on" + 1.1 If the number of returned reources is greater than 1 + EXCEPTION "User has several resources assigned of the requested type" + + 2. If the requested resource has 0 services + EXCEPTION "The resource {name} of type {type} should contain atleast one service + 3. If the requested resource has one service + remember the ID of this single service + 4. If the requested resource has several services DO distribution: + + 4.1. If the resource is NOT BOUNDED or is PRIMARY DISTRIBUTION RESOURCE + if PRIMARY DISTRIBUTION RESOURCE and exists in UserServices + return serviceId from UserServices table + + remember any service from that resource according to distribution type ("BALANCED" or "RANDOM") - get the number of ServiceItems for each service + + 4.2. If the resource is BOUNDED to primary distribution resource + - If the primary distribution resource is NULL + EXCEPTION "Requested resource marked as bound to primary distribution resource, but there is no any resources in hosting plan marked as primary" + + - Get the service id of the primary distribution resource + GetServiceId(userId, primaryResourceId) + + + Get from user assigned hosting plan + + 5. If it is PRIMARY DISTRIBUTION RESOURCE + Save it's ID to UserServices table + + 6. return serviceId + +ERROR CODES: + -1 - there are several hosting plans with PDR assigned to that user + -2 - The requested service is not available for the user. The resource of the + requested type {type} should be assigned to him through hosting plan or add-on + -3 - several resources of the same type was assigned through hosting plan or add-on + -4 - The resource {name} of type {type} should contain atleast one service + -5 - Requested resource marked as bound to primary distribution resource, + but there is no any resources in hosting plan marked as primary + -6 - the server where PDR is located doesn't contain the service of requested resource type +*/ +CREATE PROCEDURE GetUserServiceID +( + @UserID int, + @TypeName nvarchar(1000), + @ServiceID int OUTPUT +) +AS + DECLARE @PrimaryResourceID int -- primary distribution resource assigned through hosting plan + + ---------------------------------------- + -- Get the primary distribution resource + ---------------------------------------- + IF (SELECT COUNT (HP.PrimaryResourceID) FROM PurchasedHostingPlans AS PHP + INNER JOIN HostingPlans AS HP ON PHP.PlanID = HP.PlanID + WHERE PHP.UserID = @UserID AND HP.PrimaryResourceID IS NOT NULL AND HP.PrimaryResourceID <> 0) > 1 + BEGIN + SET @ServiceID = -1 + RETURN + END + + SELECT @PrimaryResourceID = HP.PrimaryResourceID FROM PurchasedHostingPlans AS PHP + INNER JOIN HostingPlans AS HP ON PHP.PlanID = HP.PlanID + WHERE PHP.UserID = @UserID AND HP.PrimaryResourceID IS NOT NULL AND HP.PrimaryResourceID <> 0 + + + ---------------------------------------------- + -- Check whether user has a resource + -- of this type in his hosting plans or addons + ---------------------------------------------- + DECLARE @UserResourcesTable TABLE + ( + ResourceID int + ) + INSERT INTO @UserResourcesTable + SELECT DISTINCT HPR.ResourceID FROM PurchasedHostingPlans AS PHP + INNER JOIN HostingPlans AS HP ON PHP.PlanID = HP.PlanID + INNER JOIN HostingPlanResources AS HPR ON HP.PlanID = HPR.PlanID + INNER JOIN Resources AS R ON HPR.ResourceID = R.ResourceID + INNER JOIN ServiceTypes AS ST ON R.ServiceTypeID = ST.ServiceTypeID + WHERE PHP.UserID = @UserID AND (ST.ImplementedTypeNames LIKE @TypeName OR ST.TypeName LIKE @TypeName) + + ---------------------------------------- + -- Check resources number + ---------------------------------------- + DECLARE @ResourcesCount int + SET @ResourcesCount = @@ROWCOUNT + IF @ResourcesCount = 0 + BEGIN + SET @ServiceID = -2 -- user doesn't have requested service assigned + RETURN + END + IF @ResourcesCount > 1 + BEGIN + SET @ServiceID = -3 -- several resources of the same type was assigned + RETURN + END + + ---------------------------------------- + -- Check services number + ---------------------------------------- + DECLARE @ResourceID int + SET @ResourceID = (SELECT TOP 1 ResourceID FROM @UserResourcesTable) + + DECLARE @UserServicesTable TABLE + ( + ServiceID int, + ServerID int, + ItemsNumber int, + Randomizer float + ) + INSERT INTO @UserServicesTable + SELECT + RS.ServiceID, + S.ServerID, + (SELECT COUNT(ItemID) FROM ServiceItems AS SI WHERE SI.ServiceID = RS.ServiceID), + RAND() + FROM ResourceServices AS RS + INNER JOIN Services AS S ON RS.ServiceID = S.ServiceID + WHERE RS.ResourceID = @ResourceID + + DECLARE @ServicesCount int + SET @ServicesCount = @@ROWCOUNT + IF @ServicesCount = 0 + BEGIN + SET @ServiceID = -4 -- The resource {name} of type {type} should contain atleast one service + RETURN + END + + -- try to return from UserServices + -- if it is a PDR + IF @ResourceID = @PrimaryResourceID + BEGIN + -- check in UserServices table + SELECT @ServiceID = US.ServiceID FROM ResourceServices AS RS + INNER JOIN UserServices AS US ON RS.ServiceID = US.ServiceID + WHERE RS.ResourceID = @ResourceID AND US.UserID = @UserID + + -- check validness of the current primary service id + IF @ServiceID IS NOT NULL + BEGIN + IF EXISTS(SELECT ResourceServiceID FROM ResourceServices + WHERE ResourceID = @ResourceID AND ServiceID = @ServiceID) + RETURN + ELSE -- invalidate service + DELETE FROM UserServices WHERE UserID = @UserID + END + END + + IF @ServicesCount = 1 + BEGIN + -- nothing to distribute + -- just remember this single service id + SET @ServiceID = (SELECT TOP 1 ServiceID FROM @UserServicesTable) + END + ELSE + BEGIN + -- the service should be distributed + DECLARE @DistributionTypeID int + DECLARE @BoundToPrimaryResource bit + SELECT @DistributionTypeID = R.DistributionTypeID, @BoundToPrimaryResource = R.BoundToPrimaryResource + FROM Resources AS R WHERE R.ResourceID = @ResourceID + + IF @BoundToPrimaryResource = 0 OR @ResourceID = @PrimaryResourceID + BEGIN + IF @ResourceID = @PrimaryResourceID -- it's PDR itself + BEGIN + -- check in UserServices table + SELECT @ServiceID = US.ServiceID FROM ResourceServices AS RS + INNER JOIN UserServices AS US ON RS.ServiceID = US.ServiceID + WHERE RS.ResourceID = @ResourceID AND US.UserID = @UserID + + -- check validness of the current primary service id + IF @ServiceID IS NOT NULL + BEGIN + IF EXISTS(SELECT ResourceServiceID FROM ResourceServices + WHERE ResourceID = @ResourceID AND ServiceID = @ServiceID) + RETURN + ELSE -- invalidate service + DELETE FROM UserServices WHERE UserID = @UserID + END + END + + -- distribute + IF @DistributionTypeID = 1 -- BALANCED distribution + SELECT @ServiceID = ServiceID FROM @UserServicesTable + ORDER BY ItemsNumber ASC + ELSE -- RANDOM distribution + SELECT @ServiceID = ServiceID FROM @UserServicesTable + ORDER BY Randomizer + END + ELSE -- BOUND to PDR resource + BEGIN + IF @PrimaryResourceID IS NULL + BEGIN + SET @ServiceID = -5 -- Requested resource marked as bound to primary distribution resource, + -- but there is no any resources in hosting plan marked as primary + RETURN + END + + -- get the type of primary resource + DECLARE @PrimaryTypeName nvarchar(200) + SELECT @PrimaryTypeName = ST.TypeName FROM Resources AS R + INNER JOIN ServiceTypes AS ST ON R.ServiceTypeID = ST.ServiceTypeID + WHERE R.ResourceID = @PrimaryResourceID + + + DECLARE @PrimaryServiceID int + EXEC GetUserServiceID @UserID, @PrimaryTypeName, @PrimaryServiceID OUTPUT + + IF @PrimaryServiceID < 0 + BEGIN + SET @ServiceID = @PrimaryServiceID + RETURN + END + + DECLARE @ServerID int + SET @ServerID = (SELECT ServerID FROM Services WHERE ServiceID = @PrimaryServiceID) + + -- try to get the service of the requested type on PDR server + SET @ServiceID = (SELECT ServiceID FROM @UserServicesTable WHERE ServerID = @ServerID) + + IF @ServiceID IS NULL + BEGIN + SET @ServiceID = -6 -- the server where PDR is located doesn't contain the service of requested resource type + END + END + END + + IF @ResourceID = @PrimaryResourceID -- it's PDR + BEGIN + DELETE FROM UserServices WHERE UserID = @UserID + + INSERT INTO UserServices (UserID, ServiceID) + VALUES (@UserID, @ServiceID) + END + +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE GetUserSettings +( + @ActorID int, + @UserID int, + @SettingsName nvarchar(50) +) +AS + +-- check rights +IF dbo.CheckActorUserRights(@ActorID, @UserID) = 0 +RAISERROR('You are not allowed to access this account', 16, 1) + +-- find which parent package has overriden NS +DECLARE @ParentUserID int, @TmpUserID int +SET @TmpUserID = @UserID + +WHILE 10 = 10 +BEGIN + + IF EXISTS + ( + SELECT PropertyName FROM UserSettings + WHERE SettingsName = @SettingsName AND UserID = @TmpUserID + ) + BEGIN + SELECT + UserID, + PropertyName, + PropertyValue + FROM + UserSettings + WHERE + UserID = @TmpUserID AND + SettingsName = @SettingsName + + BREAK + END + + SET @ParentUserID = NULL --reset var + + -- get owner + SELECT + @ParentUserID = OwnerID + FROM Users + WHERE UserID = @TmpUserID + + IF @ParentUserID IS NULL -- the last parent + BREAK + + SET @TmpUserID = @ParentUserID +END + +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + + + + + +CREATE PROCEDURE [dbo].[GetUsersPaged] +( + @ActorID int, + @UserID int, + @FilterColumn nvarchar(50) = '', + @FilterValue nvarchar(50) = '', + @StatusID int, + @RoleID int, + @SortColumn nvarchar(50), + @StartRow int, + @MaximumRows int, + @Recursive bit +) +AS +-- build query and run it to the temporary table +DECLARE @sql nvarchar(2000) + +SET @sql = ' + +DECLARE @HasUserRights bit +SET @HasUserRights = dbo.CheckActorUserRights(@ActorID, @UserID) + +DECLARE @EndRow int +SET @EndRow = @StartRow + @MaximumRows +DECLARE @Users TABLE +( + ItemPosition int IDENTITY(0,1), + UserID int +) +INSERT INTO @Users (UserID) +SELECT + U.UserID +FROM UsersDetailed AS U +WHERE + U.UserID <> @UserID AND U.IsPeer = 0 AND + ( + (@Recursive = 0 AND OwnerID = @UserID) OR + (@Recursive = 1 AND dbo.CheckUserParent(@UserID, U.UserID) = 1) + ) + AND ((@StatusID = 0) OR (@StatusID > 0 AND U.StatusID = @StatusID)) + AND ((@RoleID = 0) OR (@RoleID > 0 AND U.RoleID = @RoleID)) + AND @HasUserRights = 1 ' + +IF @FilterColumn <> '' AND @FilterValue <> '' +SET @sql = @sql + ' AND ' + @FilterColumn + ' LIKE @FilterValue ' + +IF @SortColumn <> '' AND @SortColumn IS NOT NULL +SET @sql = @sql + ' ORDER BY ' + @SortColumn + ' ' + +SET @sql = @sql + ' SELECT COUNT(UserID) FROM @Users; +SELECT + U.UserID, + U.RoleID, + U.StatusID, + U.SubscriberNumber, + U.LoginStatusId, + U.FailedLogins, + U.OwnerID, + U.Created, + U.Changed, + U.IsDemo, + dbo.GetItemComments(U.UserID, ''USER'', @ActorID) AS Comments, + U.IsPeer, + U.Username, + U.FirstName, + U.LastName, + U.Email, + U.FullName, + U.OwnerUsername, + U.OwnerFirstName, + U.OwnerLastName, + U.OwnerRoleID, + U.OwnerFullName, + U.OwnerEmail, + U.PackagesNumber, + U.CompanyName, + U.EcommerceEnabled +FROM @Users AS TU +INNER JOIN UsersDetailed AS U ON TU.UserID = U.UserID +WHERE TU.ItemPosition BETWEEN @StartRow AND @EndRow' + +exec sp_executesql @sql, N'@StartRow int, @MaximumRows int, @UserID int, @FilterValue nvarchar(50), @ActorID int, @Recursive bit, @StatusID int, @RoleID int', +@StartRow, @MaximumRows, @UserID, @FilterValue, @ActorID, @Recursive, @StatusID, @RoleID + + +RETURN + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE GetUsersSummary +( + @ActorID int, + @UserID int +) +AS +-- check rights +IF dbo.CheckActorUserRights(@ActorID, @UserID) = 0 +RAISERROR('You are not allowed to access this account', 16, 1) + +-- ALL users +SELECT COUNT(UserID) AS UsersNumber FROM Users +WHERE OwnerID = @UserID AND IsPeer = 0 + +-- BY STATUS users +SELECT StatusID, COUNT(UserID) AS UsersNumber FROM Users +WHERE OwnerID = @UserID AND IsPeer = 0 +GROUP BY StatusID +ORDER BY StatusID + +-- BY ROLE users +SELECT RoleID, COUNT(UserID) AS UsersNumber FROM Users +WHERE OwnerID = @UserID AND IsPeer = 0 +GROUP BY RoleID +ORDER BY RoleID DESC + +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[GetVirtualMachinesPaged] +( + @ActorID int, + @PackageID int, + @FilterColumn nvarchar(50) = '', + @FilterValue nvarchar(50) = '', + @SortColumn nvarchar(50), + @StartRow int, + @MaximumRows int, + @Recursive bit +) +AS + + +-- check rights +IF dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 +RAISERROR('You are not allowed to access this package', 16, 1) + +-- start +DECLARE @condition nvarchar(700) +SET @condition = ' +SI.ItemTypeID = 33 -- VPS +AND ((@Recursive = 0 AND P.PackageID = @PackageID) +OR (@Recursive = 1 AND dbo.CheckPackageParent(@PackageID, P.PackageID) = 1)) +' + +IF @FilterColumn <> '' AND @FilterColumn IS NOT NULL +AND @FilterValue <> '' AND @FilterValue IS NOT NULL +SET @condition = @condition + ' AND ' + @FilterColumn + ' LIKE ''' + @FilterValue + '''' + +IF @SortColumn IS NULL OR @SortColumn = '' +SET @SortColumn = 'SI.ItemName ASC' + +DECLARE @sql nvarchar(3500) + +set @sql = ' +SELECT COUNT(SI.ItemID) FROM Packages AS P +INNER JOIN ServiceItems AS SI ON P.PackageID = SI.PackageID +INNER JOIN Users AS U ON P.UserID = U.UserID +LEFT OUTER JOIN ( + SELECT PIP.ItemID, IP.ExternalIP FROM PackageIPAddresses AS PIP + INNER JOIN IPAddresses AS IP ON PIP.AddressID = IP.AddressID + WHERE PIP.IsPrimary = 1 AND IP.PoolID = 3 -- external IP addresses +) AS EIP ON SI.ItemID = EIP.ItemID +LEFT OUTER JOIN PrivateIPAddresses AS PIP ON PIP.ItemID = SI.ItemID AND PIP.IsPrimary = 1 +WHERE ' + @condition + ' + +DECLARE @Items AS TABLE +( + ItemID int +); + +WITH TempItems AS ( + SELECT ROW_NUMBER() OVER (ORDER BY ' + @SortColumn + ') as Row, + SI.ItemID + FROM Packages AS P + INNER JOIN ServiceItems AS SI ON P.PackageID = SI.PackageID + INNER JOIN Users AS U ON P.UserID = U.UserID + LEFT OUTER JOIN ( + SELECT PIP.ItemID, IP.ExternalIP FROM PackageIPAddresses AS PIP + INNER JOIN IPAddresses AS IP ON PIP.AddressID = IP.AddressID + WHERE PIP.IsPrimary = 1 AND IP.PoolID = 3 -- external IP addresses + ) AS EIP ON SI.ItemID = EIP.ItemID + LEFT OUTER JOIN PrivateIPAddresses AS PIP ON PIP.ItemID = SI.ItemID AND PIP.IsPrimary = 1 + WHERE ' + @condition + ' +) + +INSERT INTO @Items +SELECT ItemID FROM TempItems +WHERE TempItems.Row BETWEEN @StartRow + 1 and @StartRow + @MaximumRows + +SELECT + SI.ItemID, + SI.ItemName, + SI.PackageID, + P.PackageName, + P.UserID, + U.Username, + + EIP.ExternalIP, + PIP.IPAddress +FROM @Items AS TSI +INNER JOIN ServiceItems AS SI ON TSI.ItemID = SI.ItemID +INNER JOIN Packages AS P ON SI.PackageID = P.PackageID +INNER JOIN Users AS U ON P.UserID = U.UserID +LEFT OUTER JOIN ( + SELECT PIP.ItemID, IP.ExternalIP FROM PackageIPAddresses AS PIP + INNER JOIN IPAddresses AS IP ON PIP.AddressID = IP.AddressID + WHERE PIP.IsPrimary = 1 AND IP.PoolID = 3 -- external IP addresses +) AS EIP ON SI.ItemID = EIP.ItemID +LEFT OUTER JOIN PrivateIPAddresses AS PIP ON PIP.ItemID = SI.ItemID AND PIP.IsPrimary = 1 +' + +--print @sql + +exec sp_executesql @sql, N'@PackageID int, @StartRow int, @MaximumRows int, @Recursive bit', +@PackageID, @StartRow, @MaximumRows, @Recursive + +RETURN + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + +CREATE PROCEDURE [dbo].[GetVirtualMachinesPagedForPC] +( + @ActorID int, + @PackageID int, + @FilterColumn nvarchar(50) = '', + @FilterValue nvarchar(50) = '', + @SortColumn nvarchar(50), + @StartRow int, + @MaximumRows int, + @Recursive bit +) +AS + + +-- check rights +IF dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 +BEGIN + RAISERROR('You are not allowed to access this package', 16, 1) + RETURN +END + +-- start +DECLARE @condition nvarchar(700) +SET @condition = ' +SI.ItemTypeID = 35 -- VPS +AND ((@Recursive = 0 AND P.PackageID = @PackageID) +OR (@Recursive = 1 AND dbo.CheckPackageParent(@PackageID, P.PackageID) = 1)) +' + +IF @FilterColumn <> '' AND @FilterColumn IS NOT NULL +AND @FilterValue <> '' AND @FilterValue IS NOT NULL +SET @condition = @condition + ' AND ' + @FilterColumn + ' LIKE ''' + @FilterValue + '''' + +IF @SortColumn IS NULL OR @SortColumn = '' +SET @SortColumn = 'SI.ItemName ASC' + +DECLARE @sql nvarchar(3500) + +set @sql = ' +SELECT COUNT(SI.ItemID) FROM Packages AS P +INNER JOIN ServiceItems AS SI ON P.PackageID = SI.PackageID +INNER JOIN Users AS U ON P.UserID = U.UserID +LEFT OUTER JOIN ( + SELECT PIP.ItemID, IP.ExternalIP FROM PackageIPAddresses AS PIP + INNER JOIN IPAddresses AS IP ON PIP.AddressID = IP.AddressID + WHERE PIP.IsPrimary = 1 AND IP.PoolID = 3 -- external IP addresses +) AS EIP ON SI.ItemID = EIP.ItemID +LEFT OUTER JOIN PrivateIPAddresses AS PIP ON PIP.ItemID = SI.ItemID AND PIP.IsPrimary = 1 +WHERE ' + @condition + ' + +DECLARE @Items AS TABLE +( + ItemID int +); + +WITH TempItems AS ( + SELECT ROW_NUMBER() OVER (ORDER BY ' + @SortColumn + ') as Row, + SI.ItemID + FROM Packages AS P + INNER JOIN ServiceItems AS SI ON P.PackageID = SI.PackageID + INNER JOIN Users AS U ON P.UserID = U.UserID + LEFT OUTER JOIN ( + SELECT PIP.ItemID, IP.ExternalIP FROM PackageIPAddresses AS PIP + INNER JOIN IPAddresses AS IP ON PIP.AddressID = IP.AddressID + WHERE PIP.IsPrimary = 1 AND IP.PoolID = 3 -- external IP addresses + ) AS EIP ON SI.ItemID = EIP.ItemID + LEFT OUTER JOIN PrivateIPAddresses AS PIP ON PIP.ItemID = SI.ItemID AND PIP.IsPrimary = 1 + WHERE ' + @condition + ' +) + +INSERT INTO @Items +SELECT ItemID FROM TempItems +WHERE TempItems.Row BETWEEN @StartRow + 1 and @StartRow + @MaximumRows + +SELECT + SI.ItemID, + SI.ItemName, + SI.PackageID, + P.PackageName, + P.UserID, + U.Username, + + EIP.ExternalIP, + PIP.IPAddress +FROM @Items AS TSI +INNER JOIN ServiceItems AS SI ON TSI.ItemID = SI.ItemID +INNER JOIN Packages AS P ON SI.PackageID = P.PackageID +INNER JOIN Users AS U ON P.UserID = U.UserID +LEFT OUTER JOIN ( + SELECT PIP.ItemID, IP.ExternalIP FROM PackageIPAddresses AS PIP + INNER JOIN IPAddresses AS IP ON PIP.AddressID = IP.AddressID + WHERE PIP.IsPrimary = 1 AND IP.PoolID = 3 -- external IP addresses +) AS EIP ON SI.ItemID = EIP.ItemID +LEFT OUTER JOIN PrivateIPAddresses AS PIP ON PIP.ItemID = SI.ItemID AND PIP.IsPrimary = 1 +' + +--print @sql + +exec sp_executesql @sql, N'@PackageID int, @StartRow int, @MaximumRows int, @Recursive bit', +@PackageID, @StartRow, @MaximumRows, @Recursive + +RETURN + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[GetVirtualServers] +( + @ActorID int +) +AS + +-- check rights +DECLARE @IsAdmin bit +SET @IsAdmin = dbo.CheckIsUserAdmin(@ActorID) + + +SELECT + S.ServerID, + S.ServerName, + S.ServerUrl, + (SELECT COUNT(SRV.ServiceID) FROM VirtualServices AS SRV WHERE S.ServerID = SRV.ServerID) AS ServicesNumber, + S.Comments, + PrimaryGroupID +FROM Servers AS S +WHERE + VirtualServer = 1 + AND @IsAdmin = 1 +ORDER BY S.ServerName + +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[GetVirtualServices] +( + @ActorID int, + @ServerID int +) +AS + +-- check rights +DECLARE @IsAdmin bit +SET @IsAdmin = dbo.CheckIsUserAdmin(@ActorID) + +-- virtual groups +SELECT + VRG.VirtualGroupID, + RG.GroupID, + RG.GroupName, + ISNULL(VRG.DistributionType, 1) AS DistributionType, + ISNULL(VRG.BindDistributionToPrimary, 1) AS BindDistributionToPrimary +FROM ResourceGroups AS RG +LEFT OUTER JOIN VirtualGroups AS VRG ON RG.GroupID = VRG.GroupID AND VRG.ServerID = @ServerID +WHERE + @IsAdmin = 1 AND (ShowGroup = 1) +ORDER BY RG.GroupOrder + +-- services +SELECT + VS.ServiceID, + S.ServiceName, + S.Comments, + P.GroupID, + P.DisplayName, + SRV.ServerName +FROM VirtualServices AS VS +INNER JOIN Services AS S ON VS.ServiceID = S.ServiceID +INNER JOIN Servers AS SRV ON S.ServerID = SRV.ServerID +INNER JOIN Providers AS P ON S.ProviderID = P.ProviderID +WHERE + VS.ServerID = @ServerID + AND @IsAdmin = 1 + +RETURN + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[InsertCRMUser] + @ItemID int, + @CrmUserID uniqueidentifier, + @BusinessUnitID uniqueidentifier +AS +BEGIN + SET NOCOUNT ON; + +INSERT INTO + CRMUsers +( + AccountID, + CRMUserGuid, + BusinessUnitID +) +VALUES +( + @ItemID, + @CrmUserID, + @BusinessUnitID +) + + + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + +CREATE PROCEDURE [dbo].[LyncUserExists] +( + @AccountID int, + @SipAddress nvarchar(300), + @Exists bit OUTPUT +) +AS + + SET @Exists = 0 + IF EXISTS(SELECT * FROM [dbo].[ExchangeAccountEmailAddresses] WHERE [EmailAddress] = @SipAddress AND [AccountID] <> @AccountID) + BEGIN + SET @Exists = 1 + END + ELSE IF EXISTS(SELECT * FROM [dbo].[ExchangeAccounts] WHERE [PrimaryEmailAddress] = @SipAddress AND [AccountID] <> @AccountID) + BEGIN + SET @Exists = 1 + END + ELSE IF EXISTS(SELECT * FROM [dbo].[ExchangeAccounts] WHERE [UserPrincipalName] = @SipAddress AND [AccountID] <> @AccountID) + BEGIN + SET @Exists = 1 + END + ELSE IF EXISTS(SELECT * FROM [dbo].[ExchangeAccounts] WHERE [AccountName] = @SipAddress AND [AccountID] <> @AccountID) + BEGIN + SET @Exists = 1 + END + ELSE IF EXISTS(SELECT * FROM [dbo].[LyncUsers] WHERE [SipAddress] = @SipAddress) + BEGIN + SET @Exists = 1 + END + + + RETURN + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + + +CREATE PROCEDURE [dbo].[MoveServiceItem] +( + @ActorID int, + @ItemID int, + @DestinationServiceID int +) +AS + +-- check rights +DECLARE @PackageID int +SELECT PackageID = @PackageID FROM ServiceItems +WHERE ItemID = @ItemID + +IF dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 +RAISERROR('You are not allowed to access this package', 16, 1) + +BEGIN TRAN + +UPDATE ServiceItems +SET ServiceID = @DestinationServiceID +WHERE ItemID = @ItemID + +COMMIT TRAN + +RETURN + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[OrganizationExists] +( + @OrganizationID nvarchar(10), + @Exists bit OUTPUT +) +AS +SET @Exists = 0 +IF EXISTS(SELECT * FROM Organizations WHERE OrganizationID = @OrganizationID) +BEGIN + SET @Exists = 1 +END + +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[OrganizationUserExists] +( + @LoginName nvarchar(20), + @Exists bit OUTPUT +) +AS +SET @Exists = 0 +IF EXISTS(SELECT * FROM ExchangeAccounts WHERE AccountName = @LoginName) +BEGIN + SET @Exists = 1 +END + +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[SearchExchangeAccount] +( + @ActorID int, + @AccountType int, + @PrimaryEmailAddress nvarchar(300) +) +AS + +DECLARE @PackageID int +DECLARE @ItemID int +DECLARE @AccountID int + +SELECT + @AccountID = AccountID, + @ItemID = ItemID +FROM ExchangeAccounts +WHERE PrimaryEmailAddress = @PrimaryEmailAddress +AND AccountType = @AccountType + + +-- check space rights +SELECT @PackageID = PackageID FROM ServiceItems +WHERE ItemID = @ItemID + +IF dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 +RAISERROR('You are not allowed to access this package', 16, 1) + +SELECT + AccountID, + ItemID, + @PackageID AS PackageID, + AccountType, + AccountName, + DisplayName, + PrimaryEmailAddress, + MailEnabledPublicFolder, + MailboxManagerActions, + SamAccountName, + AccountPassword, + SubscriberNumber, + UserPrincipalName +FROM ExchangeAccounts +WHERE AccountID = @AccountID + +RETURN + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + + + + + + +CREATE PROCEDURE [dbo].[SearchExchangeAccounts] +( + @ActorID int, + @ItemID int, + @IncludeMailboxes bit, + @IncludeContacts bit, + @IncludeDistributionLists bit, + @IncludeRooms bit, + @IncludeEquipment bit, + @FilterColumn nvarchar(50) = '', + @FilterValue nvarchar(50) = '', + @SortColumn nvarchar(50) +) +AS +DECLARE @PackageID int +SELECT @PackageID = PackageID FROM ServiceItems +WHERE ItemID = @ItemID + +-- check rights +IF dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 +RAISERROR('You are not allowed to access this package', 16, 1) + +-- start +DECLARE @condition nvarchar(700) +SET @condition = ' +((@IncludeMailboxes = 1 AND EA.AccountType = 1) +OR (@IncludeContacts = 1 AND EA.AccountType = 2) +OR (@IncludeDistributionLists = 1 AND EA.AccountType = 3) +OR (@IncludeRooms = 1 AND EA.AccountType = 5) +OR (@IncludeEquipment = 1 AND EA.AccountType = 6)) +AND EA.ItemID = @ItemID +' + +IF @FilterColumn <> '' AND @FilterColumn IS NOT NULL +AND @FilterValue <> '' AND @FilterValue IS NOT NULL +SET @condition = @condition + ' AND ' + @FilterColumn + ' LIKE ''' + @FilterValue + '''' + +IF @SortColumn IS NULL OR @SortColumn = '' +SET @SortColumn = 'EA.DisplayName ASC' + +DECLARE @sql nvarchar(3500) + +set @sql = ' +SELECT + EA.AccountID, + EA.ItemID, + EA.AccountType, + EA.AccountName, + EA.DisplayName, + EA.PrimaryEmailAddress, + EA.MailEnabledPublicFolder, + EA.SubscriberNumber, + EA.UserPrincipalName +FROM ExchangeAccounts AS EA +WHERE ' + @condition + +print @sql + +exec sp_executesql @sql, N'@ItemID int, @IncludeMailboxes int, @IncludeContacts int, + @IncludeDistributionLists int, @IncludeRooms bit, @IncludeEquipment bit', +@ItemID, @IncludeMailboxes, @IncludeContacts, @IncludeDistributionLists, @IncludeRooms, @IncludeEquipment + +RETURN + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[SearchOrganizationAccounts] +( + @ActorID int, + @ItemID int, + @FilterColumn nvarchar(50) = '', + @FilterValue nvarchar(50) = '', + @SortColumn nvarchar(50), + @IncludeMailboxes bit +) +AS +DECLARE @PackageID int +SELECT @PackageID = PackageID FROM ServiceItems +WHERE ItemID = @ItemID + +-- check rights +IF dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 +RAISERROR('You are not allowed to access this package', 16, 1) + +-- start +DECLARE @condition nvarchar(700) +SET @condition = ' +(EA.AccountType = 7 OR (EA.AccountType = 1 AND @IncludeMailboxes = 1) ) +AND EA.ItemID = @ItemID +' + +IF @FilterColumn <> '' AND @FilterColumn IS NOT NULL +AND @FilterValue <> '' AND @FilterValue IS NOT NULL +SET @condition = @condition + ' AND ' + @FilterColumn + ' LIKE ''' + @FilterValue + '''' + +IF @SortColumn IS NULL OR @SortColumn = '' +SET @SortColumn = 'EA.DisplayName ASC' + +DECLARE @sql nvarchar(3500) + +set @sql = ' +SELECT + EA.AccountID, + EA.ItemID, + EA.AccountType, + EA.AccountName, + EA.DisplayName, + EA.PrimaryEmailAddress, + EA.SubscriberNumber, + EA.UserPrincipalName +FROM ExchangeAccounts AS EA +WHERE ' + @condition + +print @sql + +exec sp_executesql @sql, N'@ItemID int, @IncludeMailboxes bit', +@ItemID, @IncludeMailboxes + +RETURN + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + +CREATE PROCEDURE [dbo].[SearchServiceItemsPaged] +( + @ActorID int, + @UserID int, + @ItemTypeID int, + @FilterValue nvarchar(50) = '', + @SortColumn nvarchar(50), + @StartRow int, + @MaximumRows int +) +AS + + +-- check rights +IF dbo.CheckActorUserRights(@ActorID, @UserID) = 0 +RAISERROR('You are not allowed to access this account', 16, 1) + +-- build query and run it to the temporary table +DECLARE @sql nvarchar(2000) + +IF @ItemTypeID <> 13 +BEGIN + SET @sql = ' + DECLARE @EndRow int + SET @EndRow = @StartRow + @MaximumRows + DECLARE @Items TABLE + ( + ItemPosition int IDENTITY(1,1), + ItemID int + ) + INSERT INTO @Items (ItemID) + SELECT + SI.ItemID + FROM ServiceItems AS SI + INNER JOIN Packages AS P ON P.PackageID = SI.PackageID + INNER JOIN UsersDetailed AS U ON P.UserID = U.UserID + WHERE + dbo.CheckUserParent(@UserID, P.UserID) = 1 + AND SI.ItemTypeID = @ItemTypeID + ' + + IF @FilterValue <> '' + SET @sql = @sql + ' AND SI.ItemName LIKE @FilterValue ' + + IF @SortColumn = '' OR @SortColumn IS NULL + SET @SortColumn = 'ItemName' + + SET @sql = @sql + ' ORDER BY ' + @SortColumn + ' ' + + SET @sql = @sql + ' SELECT COUNT(ItemID) FROM @Items; + SELECT + + SI.ItemID, + SI.ItemName, + + P.PackageID, + P.PackageName, + P.StatusID, + P.PurchaseDate, + + -- user + P.UserID, + U.Username, + U.FirstName, + U.LastName, + U.FullName, + U.RoleID, + U.Email + FROM @Items AS I + INNER JOIN ServiceItems AS SI ON I.ItemID = SI.ItemID + INNER JOIN Packages AS P ON SI.PackageID = P.PackageID + INNER JOIN UsersDetailed AS U ON P.UserID = U.UserID + WHERE I.ItemPosition BETWEEN @StartRow AND @EndRow' +END +ELSE +BEGIN + + SET @SortColumn = REPLACE(@SortColumn, 'ItemName', 'DomainName') + + SET @sql = ' + DECLARE @EndRow int + SET @EndRow = @StartRow + @MaximumRows + DECLARE @Items TABLE + ( + ItemPosition int IDENTITY(1,1), + ItemID int + ) + INSERT INTO @Items (ItemID) + SELECT + D.DomainID + FROM Domains AS D + INNER JOIN Packages AS P ON P.PackageID = D.PackageID + INNER JOIN UsersDetailed AS U ON P.UserID = U.UserID + WHERE + dbo.CheckUserParent(@UserID, P.UserID) = 1 + ' + + IF @FilterValue <> '' + SET @sql = @sql + ' AND D.DomainName LIKE @FilterValue ' + + IF @SortColumn = '' OR @SortColumn IS NULL + SET @SortColumn = 'DomainName' + + SET @sql = @sql + ' ORDER BY ' + @SortColumn + ' ' + + SET @sql = @sql + ' SELECT COUNT(ItemID) FROM @Items; + SELECT + + D.DomainID AS ItemID, + D.DomainName AS ItemName, + + P.PackageID, + P.PackageName, + P.StatusID, + P.PurchaseDate, + + -- user + P.UserID, + U.Username, + U.FirstName, + U.LastName, + U.FullName, + U.RoleID, + U.Email + FROM @Items AS I + INNER JOIN Domains AS D ON I.ItemID = D.DomainID + INNER JOIN Packages AS P ON D.PackageID = P.PackageID + INNER JOIN UsersDetailed AS U ON P.UserID = U.UserID + WHERE I.ItemPosition BETWEEN @StartRow AND @EndRow AND D.IsDomainPointer=0' +END + +exec sp_executesql @sql, N'@StartRow int, @MaximumRows int, @UserID int, @FilterValue nvarchar(50), @ItemTypeID int, @ActorID int', +@StartRow, @MaximumRows, @UserID, @FilterValue, @ItemTypeID, @ActorID + +RETURN + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[SetExchangeAccountMailboxplan] +( + @AccountID int, + @MailboxPlanId int +) +AS + +UPDATE ExchangeAccounts SET + MailboxPlanId = @MailboxPlanId +WHERE + AccountID = @AccountID + +RETURN + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[SetItemPrimaryIPAddress] +( + @ActorID int, + @ItemID int, + @PackageAddressID int +) +AS +BEGIN + + -- read item pool + DECLARE @PoolID int + SELECT @PoolID = IP.PoolID FROM PackageIPAddresses AS PIP + INNER JOIN IPAddresses AS IP ON PIP.AddressID = IP.AddressID + WHERE PIP.PackageAddressID = @PackageAddressID + + -- update all IP addresses of the specified pool + UPDATE PackageIPAddresses + SET IsPrimary = CASE PIP.PackageAddressID WHEN @PackageAddressID THEN 1 ELSE 0 END + FROM PackageIPAddresses AS PIP + INNER JOIN IPAddresses AS IP ON PIP.AddressID = IP.AddressID + WHERE PIP.ItemID = @ItemID + AND IP.PoolID = @PoolID + AND dbo.CheckActorPackageRights(@ActorID, PIP.PackageID) = 1 +END + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[SetItemPrivatePrimaryIPAddress] +( + @ActorID int, + @ItemID int, + @PrivateAddressID int +) +AS +BEGIN + UPDATE PrivateIPAddresses + SET IsPrimary = CASE PIP.PrivateAddressID WHEN @PrivateAddressID THEN 1 ELSE 0 END + FROM PrivateIPAddresses AS PIP + INNER JOIN ServiceItems AS SI ON PIP.ItemID = SI.ItemID + WHERE PIP.ItemID = @ItemID + AND dbo.CheckActorPackageRights(@ActorID, SI.PackageID) = 1 +END + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + +CREATE PROCEDURE [dbo].[SetLyncUserLyncUserPlan] +( + @AccountID int, + @LyncUserPlanId int +) +AS + +UPDATE LyncUsers SET + LyncUserPlanId = @LyncUserPlanId +WHERE + AccountID = @AccountID + +RETURN + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + +CREATE PROCEDURE [dbo].[SetOrganizationDefaultExchangeMailboxPlan] +( + @ItemID int, + @MailboxPlanId int +) +AS + +UPDATE ExchangeOrganizations SET + ExchangeMailboxPlanID = @MailboxPlanId +WHERE + ItemID = @ItemID + +RETURN + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + + + +CREATE PROCEDURE [dbo].[SetOrganizationDefaultLyncUserPlan] +( + @ItemID int, + @LyncUserPlanId int +) +AS + +UPDATE ExchangeOrganizations SET + LyncUserPlanID = @LyncUserPlanId +WHERE + ItemID = @ItemID + +RETURN + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[SetSystemSettings] + @SettingsName nvarchar(50), + @Xml ntext +AS +BEGIN +/* +XML Format: + + + +*/ + SET NOCOUNT ON; + + BEGIN TRAN + DECLARE @idoc int; + --Create an internal representation of the XML document. + EXEC sp_xml_preparedocument @idoc OUTPUT, @xml; + + DELETE FROM [dbo].[SystemSettings] WHERE [SettingsName] = @SettingsName; + + INSERT INTO [dbo].[SystemSettings] + ( + [SettingsName], + [PropertyName], + [PropertyValue] + ) + SELECT + @SettingsName, + [XML].[PropertyName], + [XML].[PropertyValue] + FROM OPENXML(@idoc, '/properties/property',1) WITH + ( + [PropertyName] nvarchar(50) '@name', + [PropertyValue] ntext '@value' + ) AS XML; + + -- remove document + EXEC sp_xml_removedocument @idoc; + + COMMIT TRAN; + +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + + + + + +CREATE PROCEDURE [dbo].[UpdateDnsRecord] +( + @ActorID int, + @RecordID int, + @RecordType nvarchar(10), + @RecordName nvarchar(50), + @RecordData nvarchar(500), + @MXPriority int, + @SrvPriority int, + @SrvWeight int, + @SrvPort int, + @IPAddressID int +) +AS + +IF @IPAddressID = 0 SET @IPAddressID = NULL + +-- check rights +DECLARE @ServiceID int, @ServerID int, @PackageID int +SELECT + @ServiceID = ServiceID, + @ServerID = ServerID, + @PackageID = PackageID +FROM GlobalDnsRecords +WHERE + RecordID = @RecordID + +IF (@ServiceID > 0 OR @ServerID > 0) AND dbo.CheckIsUserAdmin(@ActorID) = 0 +RAISERROR('You are not allowed to perform this operation', 16, 1) + +IF (@PackageID > 0) AND dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 +RAISERROR('You are not allowed to access this package', 16, 1) + + +-- update record +UPDATE GlobalDnsRecords +SET + RecordType = @RecordType, + RecordName = @RecordName, + RecordData = @RecordData, + MXPriority = @MXPriority, + SrvPriority = @SrvPriority, + SrvWeight = @SrvWeight, + SrvPort = @SrvPort, + IPAddressID = @IPAddressID +WHERE + RecordID = @RecordID +RETURN + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + +CREATE PROCEDURE [dbo].[UpdateDomain] +( + @DomainID int, + @ActorID int, + @ZoneItemID int, + @HostingAllowed bit, + @WebSiteID int, + @MailDomainID int, + @DomainItemID int +) +AS + +-- check rights +DECLARE @PackageID int +SELECT @PackageID = PackageID FROM Domains +WHERE DomainID = @DomainID + +IF dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 +RAISERROR('You are not allowed to access this package', 16, 1) + +IF @ZoneItemID = 0 SET @ZoneItemID = NULL +IF @WebSiteID = 0 SET @WebSiteID = NULL +IF @MailDomainID = 0 SET @MailDomainID = NULL + +-- update record +UPDATE Domains +SET + ZoneItemID = @ZoneItemID, + HostingAllowed = @HostingAllowed, + WebSiteID = @WebSiteID, + MailDomainID = @MailDomainID, + DomainItemID = @DomainItemID +WHERE + DomainID = @DomainID + RETURN + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[UpdateExchangeAccount] +( + @AccountID int, + @AccountName nvarchar(300), + @DisplayName nvarchar(300), + @PrimaryEmailAddress nvarchar(300), + @AccountType int, + @SamAccountName nvarchar(100), + @MailEnabledPublicFolder bit, + @MailboxManagerActions varchar(200), + @Password varchar(200), + @MailboxPlanId int, + @SubscriberNumber varchar(32) +) +AS + +BEGIN TRAN + +IF (@MailboxPlanId = -1) +BEGIN + SET @MailboxPlanId = NULL +END + +UPDATE ExchangeAccounts SET + AccountName = @AccountName, + DisplayName = @DisplayName, + PrimaryEmailAddress = @PrimaryEmailAddress, + MailEnabledPublicFolder = @MailEnabledPublicFolder, + MailboxManagerActions = @MailboxManagerActions, + AccountType =@AccountType, + SamAccountName = @SamAccountName, + MailboxPlanId = @MailboxPlanId, + SubscriberNumber = @SubscriberNumber + +WHERE + AccountID = @AccountID + +IF (@@ERROR <> 0 ) + BEGIN + ROLLBACK TRANSACTION + RETURN -1 + END + +UPDATE ExchangeAccounts SET + AccountPassword = @Password WHERE AccountID = @AccountID AND @Password IS NOT NULL + +IF (@@ERROR <> 0 ) + BEGIN + ROLLBACK TRANSACTION + RETURN -1 + END +COMMIT TRAN +RETURN + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + CREATE PROCEDURE [dbo].[UpdateExchangeAccountUserPrincipalName] +( + @AccountID int, + @UserPrincipalName nvarchar(300) +) +AS + +UPDATE ExchangeAccounts SET + UserPrincipalName = @UserPrincipalName +WHERE + AccountID = @AccountID + +RETURN +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + +CREATE PROCEDURE [dbo].[UpdateExchangeMailboxPlan] +( + @MailboxPlanId int, + @MailboxPlan nvarchar(300), + @EnableActiveSync bit, + @EnableIMAP bit, + @EnableMAPI bit, + @EnableOWA bit, + @EnablePOP bit, + @IsDefault bit, + @IssueWarningPct int, + @KeepDeletedItemsDays int, + @MailboxSizeMB int, + @MaxReceiveMessageSizeKB int, + @MaxRecipients int, + @MaxSendMessageSizeKB int, + @ProhibitSendPct int, + @ProhibitSendReceivePct int , + @HideFromAddressBook bit, + @MailboxPlanType int +) +AS + +UPDATE ExchangeMailboxPlans SET + MailboxPlan = @MailboxPlan, + EnableActiveSync = @EnableActiveSync, + EnableIMAP = @EnableIMAP, + EnableMAPI = @EnableMAPI, + EnableOWA = @EnableOWA, + EnablePOP = @EnablePOP, + IsDefault = @IsDefault, + IssueWarningPct= @IssueWarningPct, + KeepDeletedItemsDays = @KeepDeletedItemsDays, + MailboxSizeMB= @MailboxSizeMB, + MaxReceiveMessageSizeKB= @MaxReceiveMessageSizeKB, + MaxRecipients= @MaxRecipients, + MaxSendMessageSizeKB= @MaxSendMessageSizeKB, + ProhibitSendPct= @ProhibitSendPct, + ProhibitSendReceivePct = @ProhibitSendReceivePct, + HideFromAddressBook = @HideFromAddressBook, + MailboxPlanType = @MailboxPlanType +WHERE MailboxPlanId = @MailboxPlanId + +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE UpdateHostingPlanQuotas +( + @ActorID int, + @PlanID int, + @Xml ntext +) +AS + +/* +XML Format: + + + + + + + + + + +*/ + +-- check rights +DECLARE @UserID int +SELECT @UserID = UserID FROM HostingPlans +WHERE PlanID = @PlanID + +-- check rights +IF dbo.CheckActorUserRights(@ActorID, @UserID) = 0 +RAISERROR('You are not allowed to access this account', 16, 1) + +DECLARE @idoc int +--Create an internal representation of the XML document. +EXEC sp_xml_preparedocument @idoc OUTPUT, @xml + +-- delete old HP resources +DELETE FROM HostingPlanResources +WHERE PlanID = @PlanID + +-- delete old HP quotas +DELETE FROM HostingPlanQuotas +WHERE PlanID = @PlanID + +-- update HP resources +INSERT INTO HostingPlanResources +( + PlanID, + GroupID, + CalculateDiskSpace, + CalculateBandwidth +) +SELECT + @PlanID, + GroupID, + CalculateDiskSpace, + CalculateBandwidth +FROM OPENXML(@idoc, '/plan/groups/group',1) WITH +( + GroupID int '@id', + CalculateDiskSpace bit '@calculateDiskSpace', + CalculateBandwidth bit '@calculateBandwidth' +) as XRG + +-- update HP quotas +INSERT INTO HostingPlanQuotas +( + PlanID, + QuotaID, + QuotaValue +) +SELECT + @PlanID, + QuotaID, + QuotaValue +FROM OPENXML(@idoc, '/plan/quotas/quota',1) WITH +( + QuotaID int '@id', + QuotaValue int '@value' +) as PV + +-- remove document +exec sp_xml_removedocument @idoc + +RETURN + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + +CREATE PROCEDURE UpdateHostingPlan +( + @ActorID int, + @PlanID int, + @PackageID int, + @ServerID int, + @PlanName nvarchar(200), + @PlanDescription ntext, + @Available bit, + @SetupPrice money, + @RecurringPrice money, + @RecurrenceLength int, + @RecurrenceUnit int, + @QuotasXml ntext +) +AS + +-- check rights +DECLARE @UserID int +SELECT @UserID = UserID FROM HostingPlans +WHERE PlanID = @PlanID + +-- check rights +IF dbo.CheckActorUserRights(@ActorID, @UserID) = 0 +RAISERROR('You are not allowed to access this account', 16, 1) + +IF @ServerID = 0 +SELECT @ServerID = ServerID FROM Packages +WHERE PackageID = @PackageID + +IF @PackageID = 0 SET @PackageID = NULL +IF @ServerID = 0 SET @ServerID = NULL + +-- update record +UPDATE HostingPlans SET + PackageID = @PackageID, + ServerID = @ServerID, + PlanName = @PlanName, + PlanDescription = @PlanDescription, + Available = @Available, + SetupPrice = @SetupPrice, + RecurringPrice = @RecurringPrice, + RecurrenceLength = @RecurrenceLength, + RecurrenceUnit = @RecurrenceUnit +WHERE PlanID = @PlanID + +BEGIN TRAN + +-- update quotas +EXEC UpdateHostingPlanQuotas @ActorID, @PlanID, @QuotasXml + +DECLARE @ExceedingQuotas AS TABLE (QuotaID int, QuotaName nvarchar(50), QuotaValue int) +INSERT INTO @ExceedingQuotas +SELECT * FROM dbo.GetPackageExceedingQuotas(@PackageID) WHERE QuotaValue > 0 + +SELECT * FROM @ExceedingQuotas + +IF EXISTS(SELECT * FROM @ExceedingQuotas) +BEGIN + ROLLBACK TRAN + RETURN +END + +COMMIT TRAN + +RETURN + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + +CREATE PROCEDURE AddHostingPlan +( + @ActorID int, + @PlanID int OUTPUT, + @UserID int, + @PackageID int, + @PlanName nvarchar(200), + @PlanDescription ntext, + @Available bit, + @ServerID int, + @SetupPrice money, + @RecurringPrice money, + @RecurrenceLength int, + @RecurrenceUnit int, + @IsAddon bit, + @QuotasXml ntext +) +AS + +-- check rights +IF dbo.CheckActorUserRights(@ActorID, @UserID) = 0 +RAISERROR('You are not allowed to access this account', 16, 1) + +BEGIN TRAN + +IF @ServerID = 0 +SELECT @ServerID = ServerID FROM Packages +WHERE PackageID = @PackageID + +IF @IsAddon = 1 +SET @ServerID = NULL + +IF @PackageID = 0 SET @PackageID = NULL + +INSERT INTO HostingPlans +( + UserID, + PackageID, + PlanName, + PlanDescription, + Available, + ServerID, + SetupPrice, + RecurringPrice, + RecurrenceLength, + RecurrenceUnit, + IsAddon +) +VALUES +( + @UserID, + @PackageID, + @PlanName, + @PlanDescription, + @Available, + @ServerID, + @SetupPrice, + @RecurringPrice, + @RecurrenceLength, + @RecurrenceUnit, + @IsAddon +) + +SET @PlanID = SCOPE_IDENTITY() + +-- save quotas +EXEC UpdateHostingPlanQuotas @ActorID, @PlanID, @QuotasXml + +COMMIT TRAN +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[UpdateIPAddress] +( + @AddressID int, + @ServerID int, + @ExternalIP varchar(24), + @InternalIP varchar(24), + @PoolID int, + @SubnetMask varchar(15), + @DefaultGateway varchar(15), + @Comments ntext +) +AS +BEGIN + IF @ServerID = 0 + SET @ServerID = NULL + + UPDATE IPAddresses SET + ExternalIP = @ExternalIP, + InternalIP = @InternalIP, + ServerID = @ServerID, + PoolID = @PoolID, + SubnetMask = @SubnetMask, + DefaultGateway = @DefaultGateway, + Comments = @Comments + WHERE AddressID = @AddressID + + RETURN +END + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[UpdateIPAddresses] +( + @xml ntext, + @PoolID int, + @ServerID int, + @SubnetMask varchar(15), + @DefaultGateway varchar(15), + @Comments ntext +) +AS +BEGIN + SET NOCOUNT ON; + + IF @ServerID = 0 + SET @ServerID = NULL + + DECLARE @idoc int + --Create an internal representation of the XML document. + EXEC sp_xml_preparedocument @idoc OUTPUT, @xml + + -- update + UPDATE IPAddresses SET + ServerID = @ServerID, + PoolID = @PoolID, + SubnetMask = @SubnetMask, + DefaultGateway = @DefaultGateway, + Comments = @Comments + FROM IPAddresses AS IP + INNER JOIN OPENXML(@idoc, '/items/item', 1) WITH + ( + AddressID int '@id' + ) as PV ON IP.AddressID = PV.AddressID + + -- remove document + exec sp_xml_removedocument @idoc +END + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO +CREATE PROCEDURE [dbo].[UpdateLyncUser] +( + @AccountID int, + @SipAddress nvarchar(300) +) +AS + +UPDATE LyncUsers SET + SipAddress = @SipAddress +WHERE + AccountID = @AccountID + +RETURN +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + +CREATE PROCEDURE [dbo].[UpdateLyncUserPlan] +( + @LyncUserPlanId int, + @LyncUserPlanName nvarchar(300), + @LyncUserPlanType int, + @IM bit, + @Mobility bit, + @MobilityEnableOutsideVoice bit, + @Federation bit, + @Conferencing bit, + @EnterpriseVoice bit, + @VoicePolicy int, + @IsDefault bit +) +AS + +UPDATE LyncUserPlans SET + LyncUserPlanName = @LyncUserPlanName, + LyncUserPlanType = @LyncUserPlanType, + IM = @IM, + Mobility = @Mobility, + MobilityEnableOutsideVoice = @MobilityEnableOutsideVoice, + Federation = @Federation, + Conferencing =@Conferencing, + EnterpriseVoice = @EnterpriseVoice, + VoicePolicy = @VoicePolicy, + IsDefault = @IsDefault +WHERE LyncUserPlanId = @LyncUserPlanId + + +RETURN + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE UpdatePackageAddon +( + @ActorID int, + @PackageAddonID int, + @PlanID int, + @Quantity int, + @PurchaseDate datetime, + @StatusID int, + @Comments ntext +) +AS + +DECLARE @PackageID int +SELECT @PackageID = PackageID FROM PackageAddons +WHERE PackageAddonID = @PackageAddonID + +-- check rights +IF dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 +RAISERROR('You are not allowed to access this package', 16, 1) + +BEGIN TRAN + +DECLARE @ParentPackageID int +SELECT @ParentPackageID = ParentPackageID FROM Packages +WHERE PackageID = @PackageID + +-- update record +UPDATE PackageAddons SET + PlanID = @PlanID, + Quantity = @Quantity, + PurchaseDate = @PurchaseDate, + StatusID = @StatusID, + Comments = @Comments +WHERE PackageAddonID = @PackageAddonID + +DECLARE @ExceedingQuotas AS TABLE (QuotaID int, QuotaName nvarchar(50), QuotaValue int) +INSERT INTO @ExceedingQuotas +SELECT * FROM dbo.GetPackageExceedingQuotas(@ParentPackageID) WHERE QuotaValue > 0 + +SELECT * FROM @ExceedingQuotas + +IF EXISTS(SELECT * FROM @ExceedingQuotas) +BEGIN + ROLLBACK TRAN + RETURN +END + +COMMIT TRAN + +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE UpdatePackageBandwidth +( + @PackageID int, + @xml ntext +) +AS +DECLARE @idoc int +--Create an internal representation of the XML document. +EXEC sp_xml_preparedocument @idoc OUTPUT, @xml + + +DECLARE @Items TABLE +( + ItemID int, + LogDate datetime, + BytesSent bigint, + BytesReceived bigint +) + +INSERT INTO @Items +( + ItemID, + LogDate, + BytesSent, + BytesReceived +) +SELECT + ItemID, + CONVERT(datetime, LogDate, 101), + BytesSent, + BytesReceived +FROM OPENXML(@idoc, '/items/item',1) WITH +( + ItemID int '@id', + LogDate nvarchar(10) '@date', + BytesSent bigint '@sent', + BytesReceived bigint '@received' +) + +-- delete current statistics +DELETE FROM PackagesBandwidth +FROM PackagesBandwidth AS PB +INNER JOIN ( + SELECT + SIT.GroupID, + I.LogDate + FROM @Items AS I + INNER JOIN ServiceItems AS SI ON I.ItemID = SI.ItemID + INNER JOIN ServiceItemTypes AS SIT ON SI.ItemTypeID = SIT.ItemTypeID + GROUP BY I.LogDate, SIT.GroupID +) AS STAT ON PB.LogDate = STAT.LogDate AND PB.GroupID = STAT.GroupID +WHERE PB.PackageID = @PackageID + +-- insert new statistics +INSERT INTO PackagesBandwidth (PackageID, GroupID, LogDate, BytesSent, BytesReceived) +SELECT + @PackageID, + SIT.GroupID, + I.LogDate, + SUM(I.BytesSent), + SUM(I.BytesReceived) +FROM @Items AS I +INNER JOIN ServiceItems AS SI ON I.ItemID = SI.ItemID +INNER JOIN ServiceItemTypes AS SIT ON SI.ItemTypeID = SIT.ItemTypeID +GROUP BY I.LogDate, SIT.GroupID + +-- remove document +exec sp_xml_removedocument @idoc + +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE UpdatePackageBandwidthUpdate +( + @PackageID int, + @UpdateDate datetime +) +AS + +UPDATE Packages SET BandwidthUpdated = @UpdateDate +WHERE PackageID = @PackageID + +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE UpdatePackageDiskSpace +( + @PackageID int, + @xml ntext +) +AS +DECLARE @idoc int +--Create an internal representation of the XML document. +EXEC sp_xml_preparedocument @idoc OUTPUT, @xml +-- Execute a SELECT statement that uses the OPENXML rowset provider. + +DECLARE @Items TABLE +( + ItemID int, + Bytes bigint +) + +INSERT INTO @Items (ItemID, Bytes) +SELECT ItemID, DiskSpace FROM OPENXML (@idoc, '/items/item',1) +WITH +( + ItemID int '@id', + DiskSpace bigint '@bytes' +) as XSI + +-- remove current diskspace +DELETE FROM PackagesDiskspace +WHERE PackageID = @PackageID + +-- update package diskspace +INSERT INTO PackagesDiskspace (PackageID, GroupID, Diskspace) +SELECT + @PackageID, + SIT.GroupID, + SUM(I.Bytes) +FROM @Items AS I +INNER JOIN ServiceItems AS SI ON I.ItemID = SI.ItemID +INNER JOIN ServiceItemTypes AS SIT ON SI.ItemTypeID = SIT.ItemTypeID +GROUP BY SIT.GroupID + +-- remove document +exec sp_xml_removedocument @idoc + +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE UpdatePackageName +( + @ActorID int, + @PackageID int, + @PackageName nvarchar(300), + @PackageComments ntext +) +AS + +-- check rights +DECLARE @UserID int +SELECT @UserID = UserID FROM Packages +WHERE PackageID = @PackageID + +IF NOT(dbo.CheckActorPackageRights(@ActorID, @PackageID) = 1 + OR @UserID = @ActorID + OR EXISTS(SELECT UserID FROM Users WHERE UserID = @ActorID AND OwnerID = @UserID AND IsPeer = 1)) +RAISERROR('You are not allowed to access this package', 16, 1) + +-- update package +UPDATE Packages SET + PackageName = @PackageName, + PackageComments = @PackageComments +WHERE + PackageID = @PackageID + +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE UpdatePackageQuotas +( + @ActorID int, + @PackageID int, + @Xml ntext +) +AS + +/* +XML Format: + + + + + + + + + + +*/ + +-- check rights +IF dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 +RAISERROR('You are not allowed to access this package', 16, 1) + +DECLARE @OverrideQuotas bit +SELECT @OverrideQuotas = OverrideQuotas FROM Packages +WHERE PackageID = @PackageID + +IF @OverrideQuotas = 0 +BEGIN + -- delete old Package resources + DELETE FROM PackageResources + WHERE PackageID = @PackageID + + -- delete old Package quotas + DELETE FROM PackageQuotas + WHERE PackageID = @PackageID +END + +IF @OverrideQuotas = 1 AND @Xml IS NOT NULL +BEGIN + -- delete old Package resources + DELETE FROM PackageResources + WHERE PackageID = @PackageID + + -- delete old Package quotas + DELETE FROM PackageQuotas + WHERE PackageID = @PackageID + + DECLARE @idoc int + --Create an internal representation of the XML document. + EXEC sp_xml_preparedocument @idoc OUTPUT, @xml + + -- update Package resources + INSERT INTO PackageResources + ( + PackageID, + GroupID, + CalculateDiskSpace, + CalculateBandwidth + ) + SELECT + @PackageID, + GroupID, + CalculateDiskSpace, + CalculateBandwidth + FROM OPENXML(@idoc, '/plan/groups/group',1) WITH + ( + GroupID int '@id', + CalculateDiskSpace bit '@calculateDiskSpace', + CalculateBandwidth bit '@calculateBandwidth' + ) as XRG + + -- update Package quotas + INSERT INTO PackageQuotas + ( + PackageID, + QuotaID, + QuotaValue + ) + SELECT + @PackageID, + QuotaID, + QuotaValue + FROM OPENXML(@idoc, '/plan/quotas/quota',1) WITH + ( + QuotaID int '@id', + QuotaValue int '@value' + ) as PV + + -- remove document + exec sp_xml_removedocument @idoc +END +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE UpdatePackageSettings +( + @ActorID int, + @PackageID int, + @SettingsName nvarchar(50), + @Xml ntext +) +AS + +-- check rights +IF dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 +RAISERROR('You are not allowed to access this package', 16, 1) + +-- delete old properties +BEGIN TRAN +DECLARE @idoc int +--Create an internal representation of the XML document. +EXEC sp_xml_preparedocument @idoc OUTPUT, @xml + +-- Execute a SELECT statement that uses the OPENXML rowset provider. +DELETE FROM PackageSettings +WHERE PackageID = @PackageID AND SettingsName = @SettingsName + +INSERT INTO PackageSettings +( + PackageID, + SettingsName, + PropertyName, + PropertyValue +) +SELECT + @PackageID, + @SettingsName, + PropertyName, + PropertyValue +FROM OPENXML(@idoc, '/properties/property',1) WITH +( + PropertyName nvarchar(50) '@name', + PropertyValue ntext '@value' +) as PV + +-- remove document +exec sp_xml_removedocument @idoc + +COMMIT TRAN + +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE UpdateSchedule +( + @ActorID int, + @ScheduleID int, + @TaskID nvarchar(100), + @ScheduleName nvarchar(100), + @ScheduleTypeID nvarchar(50), + @Interval int, + @FromTime datetime, + @ToTime datetime, + @StartTime datetime, + @LastRun datetime, + @NextRun datetime, + @Enabled bit, + @PriorityID nvarchar(50), + @HistoriesNumber int, + @MaxExecutionTime int, + @WeekMonthDay int, + @XmlParameters ntext +) +AS + +-- check rights +DECLARE @PackageID int +SELECT @PackageID = PackageID FROM Schedule +WHERE ScheduleID = @ScheduleID + +IF dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 +RAISERROR('You are not allowed to access this package', 16, 1) + +BEGIN TRAN + +UPDATE Schedule +SET + TaskID = @TaskID, + ScheduleName = @ScheduleName, + ScheduleTypeID = @ScheduleTypeID, + Interval = @Interval, + FromTime = @FromTime, + ToTime = @ToTime, + StartTime = @StartTime, + LastRun = @LastRun, + NextRun = @NextRun, + Enabled = @Enabled, + PriorityID = @PriorityID, + HistoriesNumber = @HistoriesNumber, + MaxExecutionTime = @MaxExecutionTime, + WeekMonthDay = @WeekMonthDay +WHERE + ScheduleID = @ScheduleID + +DECLARE @idoc int +--Create an internal representation of the XML document. +EXEC sp_xml_preparedocument @idoc OUTPUT, @XmlParameters + +-- Execute a SELECT statement that uses the OPENXML rowset provider. +DELETE FROM ScheduleParameters +WHERE ScheduleID = @ScheduleID + +INSERT INTO ScheduleParameters +( + ScheduleID, + ParameterID, + ParameterValue +) +SELECT + @ScheduleID, + ParameterID, + ParameterValue +FROM OPENXML(@idoc, '/parameters/parameter',1) WITH +( + ParameterID nvarchar(50) '@id', + ParameterValue nvarchar(3000) '@value' +) as PV + +-- remove document +exec sp_xml_removedocument @idoc + +COMMIT TRAN +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE UpdateServer +( + @ServerID int, + @ServerName nvarchar(100), + @ServerUrl nvarchar(100), + @Password nvarchar(100), + @Comments ntext, + @InstantDomainAlias nvarchar(200), + @PrimaryGroupID int, + @ADEnabled bit, + @ADRootDomain nvarchar(200), + @ADUsername nvarchar(100), + @ADPassword nvarchar(100), + @ADAuthenticationType varchar(50) +) +AS + +IF @PrimaryGroupID = 0 +SET @PrimaryGroupID = NULL + +UPDATE Servers SET + ServerName = @ServerName, + ServerUrl = @ServerUrl, + Password = @Password, + Comments = @Comments, + InstantDomainAlias = @InstantDomainAlias, + PrimaryGroupID = @PrimaryGroupID, + ADEnabled = @ADEnabled, + ADRootDomain = @ADRootDomain, + ADUsername = @ADUsername, + ADPassword = @ADPassword, + ADAuthenticationType = @ADAuthenticationType +WHERE ServerID = @ServerID +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE UpdateService +( + @ServiceID int, + @ServiceName nvarchar(50), + @Comments ntext, + @ServiceQuotaValue int, + @ClusterID int +) +AS + +IF @ClusterID = 0 SET @ClusterID = NULL + +UPDATE Services +SET + ServiceName = @ServiceName, + ServiceQuotaValue = @ServiceQuotaValue, + Comments = @Comments, + ClusterID = @ClusterID +WHERE ServiceID = @ServiceID + +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE UpdateServiceItem +( + @ActorID int, + @ItemID int, + @ItemName nvarchar(500), + @XmlProperties ntext +) +AS +BEGIN TRAN + +-- check rights +DECLARE @PackageID int +SELECT PackageID = @PackageID FROM ServiceItems +WHERE ItemID = @ItemID + +IF dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 +RAISERROR('You are not allowed to access this package', 16, 1) + +-- update item +UPDATE ServiceItems SET ItemName = @ItemName +WHERE ItemID=@ItemID + +DECLARE @idoc int +--Create an internal representation of the XML document. +EXEC sp_xml_preparedocument @idoc OUTPUT, @XmlProperties + +-- Execute a SELECT statement that uses the OPENXML rowset provider. +DELETE FROM ServiceItemProperties +WHERE ItemID = @ItemID + +-- Add the xml data into a temp table for the capability and robust +IF OBJECT_ID('tempdb..#TempTable') IS NOT NULL DROP TABLE #TempTable + +CREATE TABLE #TempTable( + ItemID int, + PropertyName nvarchar(50), + PropertyValue nvarchar(3000)) + +INSERT INTO #TempTable (ItemID, PropertyName, PropertyValue) +SELECT + @ItemID, + PropertyName, + PropertyValue +FROM OPENXML(@idoc, '/properties/property',1) WITH +( + PropertyName nvarchar(50) '@name', + PropertyValue nvarchar(3000) '@value' +) as PV + +-- Move data from temp table to real table +INSERT INTO ServiceItemProperties +( + ItemID, + PropertyName, + PropertyValue +) +SELECT + ItemID, + PropertyName, + PropertyValue +FROM #TempTable + +DROP TABLE #TempTable + +-- remove document +exec sp_xml_removedocument @idoc + +COMMIT TRAN + +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE dbo.UpdateServiceProperties +( + @ServiceID int, + @Xml ntext +) +AS + +-- delete old properties +BEGIN TRAN +DECLARE @idoc int +--Create an internal representation of the XML document. +EXEC sp_xml_preparedocument @idoc OUTPUT, @xml + +-- Execute a SELECT statement that uses the OPENXML rowset provider. +DELETE FROM ServiceProperties +WHERE ServiceID = @ServiceID +AND PropertyName COLLATE Latin1_General_CI_AS IN +( + SELECT PropertyName + FROM OPENXML(@idoc, '/properties/property', 1) + WITH (PropertyName nvarchar(50) '@name') +) + +INSERT INTO ServiceProperties +( + ServiceID, + PropertyName, + PropertyValue +) +SELECT + @ServiceID, + PropertyName, + PropertyValue +FROM OPENXML(@idoc, '/properties/property',1) WITH +( + PropertyName nvarchar(50) '@name', + PropertyValue nvarchar(1000) '@value' +) as PV + +-- remove document +exec sp_xml_removedocument @idoc + +COMMIT TRAN +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + + + +CREATE PROCEDURE [dbo].[UpdateUser] +( + @ActorID int, + @UserID int, + @RoleID int, + @StatusID int, + @SubscriberNumber nvarchar(32), + @LoginStatusId int, + @IsDemo bit, + @IsPeer bit, + @Comments ntext, + @FirstName nvarchar(50), + @LastName nvarchar(50), + @Email nvarchar(255), + @SecondaryEmail nvarchar(255), + @Address nvarchar(200), + @City nvarchar(50), + @State nvarchar(50), + @Country nvarchar(50), + @Zip varchar(20), + @PrimaryPhone varchar(30), + @SecondaryPhone varchar(30), + @Fax varchar(30), + @InstantMessenger nvarchar(200), + @HtmlMail bit, + @CompanyName nvarchar(100), + @EcommerceEnabled BIT, + @AdditionalParams NVARCHAR(max) +) +AS + + -- check actor rights + IF dbo.CanUpdateUserDetails(@ActorID, @UserID) = 0 + BEGIN + RETURN + END + + IF @LoginStatusId = 0 + BEGIN + UPDATE Users SET + FailedLogins = 0 + WHERE UserID = @UserID + END + + UPDATE Users SET + RoleID = @RoleID, + StatusID = @StatusID, + SubscriberNumber = @SubscriberNumber, + LoginStatusId = @LoginStatusId, + Changed = GetDate(), + IsDemo = @IsDemo, + IsPeer = @IsPeer, + Comments = @Comments, + FirstName = @FirstName, + LastName = @LastName, + Email = @Email, + SecondaryEmail = @SecondaryEmail, + Address = @Address, + City = @City, + State = @State, + Country = @Country, + Zip = @Zip, + PrimaryPhone = @PrimaryPhone, + SecondaryPhone = @SecondaryPhone, + Fax = @Fax, + InstantMessenger = @InstantMessenger, + HtmlMail = @HtmlMail, + CompanyName = @CompanyName, + EcommerceEnabled = @EcommerceEnabled, + [AdditionalParams] = @AdditionalParams + WHERE UserID = @UserID + + RETURN + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + +CREATE PROCEDURE [dbo].[UpdateUserFailedLoginAttempt] +( + @UserID int, + @LockOut int, + @Reset int +) +AS + +IF (@Reset = 1) +BEGIN + UPDATE Users SET FailedLogins = 0 WHERE UserID = @UserID +END +ELSE +BEGIN + IF (@LockOut <= (SELECT FailedLogins FROM USERS WHERE UserID = @UserID)) + BEGIN + UPDATE Users SET LoginStatusId = 2 WHERE UserID = @UserID + END + ELSE + BEGIN + IF ((SELECT FailedLogins FROM Users WHERE UserID = @UserID) IS NULL) + BEGIN + UPDATE Users SET FailedLogins = 1 WHERE UserID = @UserID + END + ELSE + UPDATE Users SET FailedLogins = FailedLogins + 1 WHERE UserID = @UserID + END +END + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE UpdateUserSettings +( + @ActorID int, + @UserID int, + @SettingsName nvarchar(50), + @Xml ntext +) +AS + +-- check rights +IF dbo.CheckActorUserRights(@ActorID, @UserID) = 0 +RAISERROR('You are not allowed to access this account', 16, 1) + +-- delete old properties +BEGIN TRAN +DECLARE @idoc int +--Create an internal representation of the XML document. +EXEC sp_xml_preparedocument @idoc OUTPUT, @xml + +-- Execute a SELECT statement that uses the OPENXML rowset provider. +DELETE FROM UserSettings +WHERE UserID = @UserID AND SettingsName = @SettingsName + +INSERT INTO UserSettings +( + UserID, + SettingsName, + PropertyName, + PropertyValue +) +SELECT + @UserID, + @SettingsName, + PropertyName, + PropertyValue +FROM OPENXML(@idoc, '/properties/property',1) WITH +( + PropertyName nvarchar(50) '@name', + PropertyValue ntext '@value' +) as PV + +-- remove document +exec sp_xml_removedocument @idoc + +COMMIT TRAN + +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE PROCEDURE UpdateVirtualGroups +( + @ServerID int, + @Xml ntext +) +AS + + +/* +XML Format: + + + + + +*/ + +BEGIN TRAN +DECLARE @idoc int +--Create an internal representation of the XML document. +EXEC sp_xml_preparedocument @idoc OUTPUT, @xml + +-- delete old virtual groups +DELETE FROM VirtualGroups +WHERE ServerID = @ServerID + +-- update HP resources +INSERT INTO VirtualGroups +( + ServerID, + GroupID, + DistributionType, + BindDistributionToPrimary +) +SELECT + @ServerID, + GroupID, + DistributionType, + BindDistributionToPrimary +FROM OPENXML(@idoc, '/groups/group',1) WITH +( + GroupID int '@id', + DistributionType int '@distributionType', + BindDistributionToPrimary bit '@bindDistributionToPrimary' +) as XRG + +-- remove document +exec sp_xml_removedocument @idoc + +COMMIT TRAN +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE FUNCTION CalculatePackageBandwidth +( + @PackageID int +) +RETURNS int +AS +BEGIN + +DECLARE @d datetime, @StartDate datetime, @EndDate datetime +SET @d = GETDATE() +SET @StartDate = DATEADD(Day, -DAY(@d) + 1, @d) +SET @EndDate = DATEADD(Day, -1, DATEADD(Month, 1, @StartDate)) +--SET @EndDate = GETDATE() +--SET @StartDate = DATEADD(month, -1, @EndDate) + +-- remove hours and minutes +SET @StartDate = CONVERT(datetime, CONVERT(nvarchar, @StartDate, 112)) +SET @EndDate = CONVERT(datetime, CONVERT(nvarchar, @EndDate, 112)) + +DECLARE @Bandwidth int +SELECT + @Bandwidth = ROUND(CONVERT(float, SUM(ISNULL(PB.BytesSent + PB.BytesReceived, 0))) / 1024 / 1024, 0) -- in megabytes +FROM PackagesTreeCache AS PT +INNER JOIN Packages AS P ON PT.PackageID = P.PackageID +INNER JOIN PackagesBandwidth AS PB ON PT.PackageID = PB.PackageID +INNER JOIN HostingPlanResources AS HPR ON PB.GroupID = HPR.GroupID + AND HPR.PlanID = P.PlanID AND HPR.CalculateBandwidth = 1 +WHERE + PT.ParentPackageID = @PackageID + AND PB.LogDate BETWEEN @StartDate AND @EndDate + +IF @Bandwidth IS NULL +SET @Bandwidth = 0 + +RETURN @Bandwidth +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE FUNCTION CalculatePackageDiskspace +( + @PackageID int +) +RETURNS int +AS +BEGIN + +DECLARE @Diskspace int + +SELECT + @Diskspace = ROUND(CONVERT(float, SUM(ISNULL(PD.DiskSpace, 0))) / 1024 / 1024, 0) -- in megabytes +FROM PackagesTreeCache AS PT +INNER JOIN Packages AS P ON PT.PackageID = P.PackageID +INNER JOIN PackagesDiskspace AS PD ON P.PackageID = PD.PackageID +INNER JOIN HostingPlanResources AS HPR ON PD.GroupID = HPR.GroupID + AND HPR.PlanID = P.PlanID AND HPR.CalculateDiskspace = 1 +WHERE PT.ParentPackageID = @PackageID + +RETURN @Diskspace +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + + + + + + + + + + + +CREATE FUNCTION [dbo].[CalculateQuotaUsage] +( + @PackageID int, + @QuotaID int +) +RETURNS int +AS + BEGIN + + DECLARE @QuotaTypeID int + SELECT @QuotaTypeID = QuotaTypeID FROM Quotas + WHERE QuotaID = @QuotaID + + IF @QuotaTypeID <> 2 + RETURN 0 + + DECLARE @Result int + + IF @QuotaID = 52 -- diskspace + SET @Result = dbo.CalculatePackageDiskspace(@PackageID) + ELSE IF @QuotaID = 51 -- bandwidth + SET @Result = dbo.CalculatePackageBandwidth(@PackageID) + ELSE IF @QuotaID = 53 -- domains + SET @Result = (SELECT COUNT(D.DomainID) FROM PackagesTreeCache AS PT + INNER JOIN Domains AS D ON D.PackageID = PT.PackageID + WHERE IsSubDomain = 0 AND IsInstantAlias = 0 AND IsDomainPointer = 0 AND PT.ParentPackageID = @PackageID) + ELSE IF @QuotaID = 54 -- sub-domains + SET @Result = (SELECT COUNT(D.DomainID) FROM PackagesTreeCache AS PT + INNER JOIN Domains AS D ON D.PackageID = PT.PackageID + WHERE IsSubDomain = 1 AND IsInstantAlias = 0 AND IsDomainPointer = 0 AND PT.ParentPackageID = @PackageID) + ELSE IF @QuotaID = 220 -- domain pointers + SET @Result = (SELECT COUNT(D.DomainID) FROM PackagesTreeCache AS PT + INNER JOIN Domains AS D ON D.PackageID = PT.PackageID + WHERE IsDomainPointer = 1 AND PT.ParentPackageID = @PackageID) + ELSE IF @QuotaID = 71 -- scheduled tasks + SET @Result = (SELECT COUNT(S.ScheduleID) FROM PackagesTreeCache AS PT + INNER JOIN Schedule AS S ON S.PackageID = PT.PackageID + WHERE PT.ParentPackageID = @PackageID) + ELSE IF @QuotaID = 305 -- RAM of VPS + SET @Result = (SELECT SUM(CAST(SIP.PropertyValue AS int)) FROM ServiceItemProperties AS SIP + INNER JOIN ServiceItems AS SI ON SIP.ItemID = SI.ItemID + INNER JOIN PackagesTreeCache AS PT ON SI.PackageID = PT.PackageID + WHERE SIP.PropertyName = 'RamSize' AND PT.ParentPackageID = @PackageID) + ELSE IF @QuotaID = 306 -- HDD of VPS + SET @Result = (SELECT SUM(CAST(SIP.PropertyValue AS int)) FROM ServiceItemProperties AS SIP + INNER JOIN ServiceItems AS SI ON SIP.ItemID = SI.ItemID + INNER JOIN PackagesTreeCache AS PT ON SI.PackageID = PT.PackageID + WHERE SIP.PropertyName = 'HddSize' AND PT.ParentPackageID = @PackageID) + ELSE IF @QuotaID = 309 -- External IP addresses of VPS + SET @Result = (SELECT COUNT(PIP.PackageAddressID) FROM PackageIPAddresses AS PIP + INNER JOIN IPAddresses AS IP ON PIP.AddressID = IP.AddressID + INNER JOIN PackagesTreeCache AS PT ON PIP.PackageID = PT.PackageID + WHERE PT.ParentPackageID = @PackageID AND IP.PoolID = 3) + ELSE IF @QuotaID = 100 -- Dedicated Web IP addresses + SET @Result = (SELECT COUNT(PIP.PackageAddressID) FROM PackageIPAddresses AS PIP + INNER JOIN IPAddresses AS IP ON PIP.AddressID = IP.AddressID + INNER JOIN PackagesTreeCache AS PT ON PIP.PackageID = PT.PackageID + WHERE PT.ParentPackageID = @PackageID AND IP.PoolID = 2) + ELSE IF @QuotaID = 350 -- RAM of VPSforPc + SET @Result = (SELECT SUM(CAST(SIP.PropertyValue AS int)) FROM ServiceItemProperties AS SIP + INNER JOIN ServiceItems AS SI ON SIP.ItemID = SI.ItemID + INNER JOIN PackagesTreeCache AS PT ON SI.PackageID = PT.PackageID + WHERE SIP.PropertyName = 'Memory' AND PT.ParentPackageID = @PackageID) + ELSE IF @QuotaID = 351 -- HDD of VPSforPc + SET @Result = (SELECT SUM(CAST(SIP.PropertyValue AS int)) FROM ServiceItemProperties AS SIP + INNER JOIN ServiceItems AS SI ON SIP.ItemID = SI.ItemID + INNER JOIN PackagesTreeCache AS PT ON SI.PackageID = PT.PackageID + WHERE SIP.PropertyName = 'HddSize' AND PT.ParentPackageID = @PackageID) + ELSE IF @QuotaID = 354 -- External IP addresses of VPSforPc + SET @Result = (SELECT COUNT(PIP.PackageAddressID) FROM PackageIPAddresses AS PIP + INNER JOIN IPAddresses AS IP ON PIP.AddressID = IP.AddressID + INNER JOIN PackagesTreeCache AS PT ON PIP.PackageID = PT.PackageID + WHERE PT.ParentPackageID = @PackageID AND IP.PoolID = 3) + ELSE IF @QuotaID = 319 -- BB Users + SET @Result = (SELECT COUNT(ea.AccountID) FROM ExchangeAccounts ea + INNER JOIN BlackBerryUsers bu ON ea.AccountID = bu.AccountID + INNER JOIN ServiceItems si ON ea.ItemID = si.ItemID + INNER JOIN PackagesTreeCache pt ON si.PackageID = pt.PackageID + WHERE pt.ParentPackageID = @PackageID) + ELSE IF @QuotaID = 320 -- OCS Users + SET @Result = (SELECT COUNT(ea.AccountID) FROM ExchangeAccounts ea + INNER JOIN OCSUsers ocs ON ea.AccountID = ocs.AccountID + INNER JOIN ServiceItems si ON ea.ItemID = si.ItemID + INNER JOIN PackagesTreeCache pt ON si.PackageID = pt.PackageID + WHERE pt.ParentPackageID = @PackageID) + ELSE IF @QuotaID = 206 -- HostedSolution.Users + SET @Result = (SELECT COUNT(ea.AccountID) FROM ExchangeAccounts AS ea + INNER JOIN ServiceItems si ON ea.ItemID = si.ItemID + INNER JOIN PackagesTreeCache pt ON si.PackageID = pt.PackageID + WHERE pt.ParentPackageID = @PackageID AND ea.AccountType IN (1,5,6,7)) + ELSE IF @QuotaID = 78 -- Exchange2007.Mailboxes + SET @Result = (SELECT COUNT(ea.AccountID) FROM ExchangeAccounts AS ea + INNER JOIN ServiceItems si ON ea.ItemID = si.ItemID + INNER JOIN PackagesTreeCache pt ON si.PackageID = pt.PackageID + WHERE pt.ParentPackageID = @PackageID + AND ea.AccountType IN (1) + AND ea.MailboxPlanId IS NOT NULL) + ELSE IF @QuotaID = 77 -- Exchange2007.DiskSpace + SET @Result = (SELECT SUM(B.MailboxSizeMB) FROM ExchangeAccounts AS ea + INNER JOIN ExchangeMailboxPlans AS B ON ea.MailboxPlanId = B.MailboxPlanId + INNER JOIN ServiceItems si ON ea.ItemID = si.ItemID + INNER JOIN PackagesTreeCache pt ON si.PackageID = pt.PackageID + WHERE pt.ParentPackageID = @PackageID) + ELSE IF @QuotaID = 370 -- Lync.Users + SET @Result = (SELECT COUNT(ea.AccountID) FROM ExchangeAccounts AS ea + INNER JOIN LyncUsers lu ON ea.AccountID = lu.AccountID + INNER JOIN ServiceItems si ON ea.ItemID = si.ItemID + INNER JOIN PackagesTreeCache pt ON si.PackageID = pt.PackageID + WHERE pt.ParentPackageID = @PackageID) + ELSE IF @QuotaID = 376 -- Lync.EVUsers + SET @Result = (SELECT COUNT(ea.AccountID) FROM ExchangeAccounts AS ea + INNER JOIN LyncUsers lu ON ea.AccountID = lu.AccountID + INNER JOIN LyncUserPlans lp ON lu.LyncUserPlanId = lp.LyncUserPlanId + INNER JOIN ServiceItems si ON ea.ItemID = si.ItemID + INNER JOIN PackagesTreeCache pt ON si.PackageID = pt.PackageID + WHERE pt.ParentPackageID = @PackageID AND lp.EnterpriseVoice = 1) + ELSE + SET @Result = (SELECT COUNT(SI.ItemID) FROM Quotas AS Q + INNER JOIN ServiceItems AS SI ON SI.ItemTypeID = Q.ItemTypeID + INNER JOIN PackagesTreeCache AS PT ON SI.PackageID = PT.PackageID AND PT.ParentPackageID = @PackageID + WHERE Q.QuotaID = @QuotaID) + + RETURN @Result + END + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE FUNCTION [dbo].[CanCreateUser] +( + @ActorID int, + @UserID int +) +RETURNS bit +AS +BEGIN + +IF @ActorID = -1 +RETURN 1 + +-- check if the user requests himself +IF @ActorID = @UserID +RETURN 1 + +DECLARE @IsPeer bit +DECLARE @OwnerID int + +SELECT @IsPeer = IsPeer, @OwnerID = OwnerID FROM Users +WHERE UserID = @ActorID + +IF @IsPeer = 1 +BEGIN + SET @ActorID = @OwnerID +END + +IF @ActorID = @UserID +RETURN 1 + +DECLARE @ParentUserID int, @TmpUserID int +SET @TmpUserID = @UserID + +WHILE 10 = 10 +BEGIN + + SET @ParentUserID = NULL --reset var + + -- get owner + SELECT + @ParentUserID = OwnerID + FROM Users + WHERE UserID = @TmpUserID + + IF @ParentUserID IS NULL -- the last parent + BREAK + + IF @ParentUserID = @ActorID + RETURN 1 + + SET @TmpUserID = @ParentUserID +END + +RETURN 0 +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE FUNCTION [dbo].[CanGetUserDetails] +( + @ActorID int, + @UserID int +) +RETURNS bit +AS +BEGIN + +IF @ActorID = -1 +RETURN 1 + +-- check if the user requests himself +IF @ActorID = @UserID +BEGIN + RETURN 1 +END + +DECLARE @IsPeer bit +DECLARE @OwnerID int + +SELECT @IsPeer = IsPeer, @OwnerID = OwnerID FROM Users +WHERE UserID = @ActorID + +IF @IsPeer = 1 +SET @ActorID = @OwnerID + +-- get user's owner +SELECT @OwnerID = OwnerID FROM Users +WHERE UserID = @ActorID + +IF @UserID = @OwnerID +RETURN 1 -- user can get the details of his owner + +-- check if the user requests himself +IF @ActorID = @UserID +BEGIN + RETURN 1 +END + +DECLARE @ParentUserID int, @TmpUserID int +SET @TmpUserID = @UserID + +WHILE 10 = 10 +BEGIN + + SET @ParentUserID = NULL --reset var + + -- get owner + SELECT + @ParentUserID = OwnerID + FROM Users + WHERE UserID = @TmpUserID + + IF @ParentUserID IS NULL -- the last parent + BREAK + + IF @ParentUserID = @ActorID + RETURN 1 + + SET @TmpUserID = @ParentUserID +END + +RETURN 0 +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE FUNCTION [dbo].[CanGetUserPassword] +( + @ActorID int, + @UserID int +) +RETURNS bit +AS +BEGIN + +IF @ActorID = -1 +RETURN 1 -- unauthenticated mode + +-- check if the user requests himself +IF @ActorID = @UserID +BEGIN + RETURN 1 +END + +DECLARE @IsPeer bit +DECLARE @OwnerID int + +SELECT @IsPeer = IsPeer, @OwnerID = OwnerID FROM Users +WHERE UserID = @ActorID + +IF @IsPeer = 1 +BEGIN + -- peer can't get the password of his peers + -- and his owner + IF @UserID = @OwnerID + RETURN 0 + + IF EXISTS ( + SELECT UserID FROM Users + WHERE IsPeer = 1 AND OwnerID = @OwnerID AND UserID = @UserID + ) RETURN 0 + + -- set actor to his owner + SET @ActorID = @OwnerID +END + +-- get user's owner +SELECT @OwnerID = OwnerID FROM Users +WHERE UserID = @ActorID + +IF @UserID = @OwnerID +RETURN 0 -- user can't get the password of his owner + +DECLARE @ParentUserID int, @TmpUserID int +SET @TmpUserID = @UserID + +WHILE 10 = 10 +BEGIN + + SET @ParentUserID = NULL --reset var + + -- get owner + SELECT + @ParentUserID = OwnerID + FROM Users + WHERE UserID = @TmpUserID + + IF @ParentUserID IS NULL -- the last parent + BREAK + + IF @ParentUserID = @ActorID + RETURN 1 + + SET @TmpUserID = @ParentUserID +END + +RETURN 0 +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + +CREATE PROCEDURE [dbo].[UpdatePackage] +( + @ActorID int, + @PackageID int, + @PackageName nvarchar(300), + @PackageComments ntext, + @StatusID int, + @PlanID int, + @PurchaseDate datetime, + @OverrideQuotas bit, + @QuotasXml ntext +) +AS + +-- check rights +IF dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 +RAISERROR('You are not allowed to access this package', 16, 1) + +BEGIN TRAN + +DECLARE @ParentPackageID int +DECLARE @OldPlanID int + +SELECT @ParentPackageID = ParentPackageID, @OldPlanID = PlanID FROM Packages +WHERE PackageID = @PackageID + +-- update package +UPDATE Packages SET + PackageName = @PackageName, + PackageComments = @PackageComments, + StatusID = @StatusID, + PlanID = @PlanID, + PurchaseDate = @PurchaseDate, + OverrideQuotas = @OverrideQuotas +WHERE + PackageID = @PackageID + +-- update quotas (if required) +EXEC UpdatePackageQuotas @ActorID, @PackageID, @QuotasXml + +-- check resulting quotas +DECLARE @ExceedingQuotas AS TABLE (QuotaID int, QuotaName nvarchar(50), QuotaValue int) + +-- check exceeding quotas if plan has been changed +IF (@OldPlanID <> @PlanID) OR (@OverrideQuotas = 1) +BEGIN + INSERT INTO @ExceedingQuotas + SELECT * FROM dbo.GetPackageExceedingQuotas(@ParentPackageID) WHERE QuotaValue > 0 +END + +SELECT * FROM @ExceedingQuotas + +IF EXISTS(SELECT * FROM @ExceedingQuotas) +BEGIN + ROLLBACK TRAN + RETURN +END + + +COMMIT TRAN +RETURN + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE FUNCTION [dbo].[CanUpdatePackageDetails] +( + @ActorID int, + @PackageID int +) +RETURNS bit +AS +BEGIN + +IF @ActorID = -1 +RETURN 1 + +DECLARE @UserID int +SELECT @UserID = UserID FROM Packages +WHERE PackageID = @PackageID + +-- check if the user requests himself +IF @ActorID = @UserID +RETURN 1 + + +DECLARE @IsPeer bit +DECLARE @OwnerID int + +SELECT @IsPeer = IsPeer, @OwnerID = OwnerID FROM Users +WHERE UserID = @ActorID + +IF @IsPeer = 1 +SET @ActorID = @OwnerID + +IF @ActorID = @UserID +RETURN 1 + +DECLARE @ParentUserID int, @TmpUserID int +SET @TmpUserID = @UserID + +WHILE 10 = 10 +BEGIN + + SET @ParentUserID = NULL --reset var + + -- get owner + SELECT + @ParentUserID = OwnerID + FROM Users + WHERE UserID = @TmpUserID + + IF @ParentUserID IS NULL -- the last parent + BREAK + + IF @ParentUserID = @ActorID + RETURN 1 + + SET @TmpUserID = @ParentUserID +END + +RETURN 0 +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE FUNCTION [dbo].[CanUpdateUserDetails] +( + @ActorID int, + @UserID int +) +RETURNS bit +AS +BEGIN + +IF @ActorID = -1 +RETURN 1 + +-- check if the user requests himself +IF @ActorID = @UserID +BEGIN + RETURN 1 +END + +DECLARE @IsPeer bit +DECLARE @OwnerID int + +SELECT @IsPeer = IsPeer, @OwnerID = OwnerID FROM Users +WHERE UserID = @ActorID + +IF @IsPeer = 1 +BEGIN + -- check if the peer is trying to update his owner + IF @UserID = @OwnerID + RETURN 0 + + -- check if the peer is trying to update his peers + IF EXISTS (SELECT UserID FROM Users + WHERE IsPeer = 1 AND OwnerID = @OwnerID AND UserID = @UserID) + RETURN 0 + + SET @ActorID = @OwnerID +END + +DECLARE @ParentUserID int, @TmpUserID int +SET @TmpUserID = @UserID + +WHILE 10 = 10 +BEGIN + + SET @ParentUserID = NULL --reset var + + -- get owner + SELECT + @ParentUserID = OwnerID + FROM Users + WHERE UserID = @TmpUserID + + IF @ParentUserID IS NULL -- the last parent + BREAK + + IF @ParentUserID = @ActorID + RETURN 1 + + SET @TmpUserID = @ParentUserID +END + +RETURN 0 +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE FUNCTION [dbo].[CheckActorPackageRights] +( + @ActorID int, + @PackageID int +) +RETURNS bit +AS +BEGIN + +IF @ActorID = -1 OR @PackageID IS NULL +RETURN 1 + +-- check if this is a 'system' package +IF @PackageID < 2 AND @PackageID > -1 AND dbo.CheckIsUserAdmin(@ActorID) = 0 +RETURN 0 + +-- get package owner +DECLARE @UserID int +SELECT @UserID = UserID FROM Packages +WHERE PackageID = @PackageID + +IF @UserID IS NULL +RETURN 1 -- unexisting package + +-- check user +RETURN dbo.CheckActorUserRights(@ActorID, @UserID) + +RETURN 0 +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE FUNCTION [dbo].[CheckActorParentPackageRights] +( + @ActorID int, + @PackageID int +) +RETURNS bit +AS +BEGIN + +IF @ActorID = -1 OR @PackageID IS NULL +RETURN 1 + +-- get package owner +DECLARE @UserID int +SELECT @UserID = UserID FROM Packages +WHERE PackageID = @PackageID + +IF @UserID IS NULL +RETURN 1 -- unexisting package + +-- check user +RETURN dbo.CanGetUserDetails(@ActorID, @UserID) + +RETURN 0 +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE FUNCTION [dbo].[CheckActorUserRights] +( + @ActorID int, + @UserID int +) +RETURNS bit +AS +BEGIN + +IF @ActorID = -1 OR @UserID IS NULL +RETURN 1 + + +-- check if the user requests himself +IF @ActorID = @UserID +BEGIN + RETURN 1 +END + +DECLARE @IsPeer bit +DECLARE @OwnerID int + +SELECT @IsPeer = IsPeer, @OwnerID = OwnerID FROM Users +WHERE UserID = @ActorID + +IF @IsPeer = 1 +SET @ActorID = @OwnerID + +-- check if the user requests his owner +/* +IF @ActorID = @UserID +BEGIN + RETURN 0 +END +*/ +IF @ActorID = @UserID +BEGIN + RETURN 1 +END + +DECLARE @ParentUserID int, @TmpUserID int +SET @TmpUserID = @UserID + +WHILE 10 = 10 +BEGIN + + SET @ParentUserID = NULL --reset var + + -- get owner + SELECT + @ParentUserID = OwnerID + FROM Users + WHERE UserID = @TmpUserID + + IF @ParentUserID IS NULL -- the last parent + BREAK + + IF @ParentUserID = @ActorID + RETURN 1 + + SET @TmpUserID = @ParentUserID +END + + +RETURN 0 +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + + +CREATE FUNCTION dbo.CheckExceedingQuota +( + @PackageID int, + @QuotaID int, + @QuotaTypeID int +) +RETURNS int +AS +BEGIN + +DECLARE @ExceedValue int +SET @ExceedValue = 0 + +DECLARE @PackageQuotaValue int +SET @PackageQuotaValue = dbo.GetPackageAllocatedQuota(@PackageID, @QuotaID) + +-- check boolean quota +IF @QuotaTypeID = 1-- AND @PackageQuotaValue > 0 -- enabled +RETURN 0 -- can exceed + +-- check numeric quota +IF @QuotaTypeID = 2 AND @PackageQuotaValue = -1 -- unlimited +RETURN 0 -- can exceed + +-- get summary usage for the numeric quota +DECLARE @UsedQuantity int +DECLARE @UsedPlans int +DECLARE @UsedOverrides int +DECLARE @UsedAddons int + + -- limited by hosting plans + SELECT @UsedPlans = SUM(HPQ.QuotaValue) FROM Packages AS P + INNER JOIN HostingPlanQuotas AS HPQ ON P.PlanID = HPQ.PlanID + WHERE HPQ.QuotaID = @QuotaID + AND P.ParentPackageID = @PackageID + AND P.OverrideQuotas = 0 + + -- overrides + SELECT @UsedOverrides = SUM(PQ.QuotaValue) FROM Packages AS P + INNER JOIN PackageQuotas AS PQ ON P.PackageID = PQ.PackageID AND PQ.QuotaID = @QuotaID + WHERE P.ParentPackageID = @PackageID + AND P.OverrideQuotas = 1 + + -- addons + SELECT @UsedAddons = SUM(HPQ.QuotaValue * PA.Quantity) + FROM Packages AS P + INNER JOIN PackageAddons AS PA ON P.PackageID = PA.PackageID + INNER JOIN HostingPlanQuotas AS HPQ ON PA.PlanID = HPQ.PlanID + WHERE P.ParentPackageID = @PackageID AND HPQ.QuotaID = @QuotaID AND PA.StatusID = 1 -- active + +--SET @UsedQuantity = (SELECT SUM(dbo.GetPackageAllocatedQuota(PackageID, @QuotaID)) FROM Packages WHERE ParentPackageID = @PackageID) + +SET @UsedQuantity = @UsedPlans + @UsedOverrides + @UsedAddons + +IF @UsedQuantity IS NULL +RETURN 0 -- can exceed + +SET @ExceedValue = @UsedQuantity - @PackageQuotaValue + +RETURN @ExceedValue +END + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE FUNCTION [dbo].[CheckIsUserAdmin] +( + @UserID int +) +RETURNS bit +AS +BEGIN + +IF @UserID = -1 +RETURN 1 + +IF EXISTS (SELECT UserID FROM Users +WHERE UserID = @UserID AND RoleID = 1) -- administrator +RETURN 1 + +RETURN 0 +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE FUNCTION [dbo].[CheckPackageParent] +( + @ParentPackageID int, + @PackageID int +) +RETURNS bit +AS +BEGIN + +-- check if the user requests hiself +IF @ParentPackageID = @PackageID +BEGIN + RETURN 1 +END + +DECLARE @TmpParentPackageID int, @TmpPackageID int +SET @TmpPackageID = @PackageID + +WHILE 10 = 10 +BEGIN + + SET @TmpParentPackageID = NULL --reset var + + -- get owner + SELECT + @TmpParentPackageID = ParentPackageID + FROM Packages + WHERE PackageID = @TmpPackageID + + IF @TmpParentPackageID IS NULL -- the last parent package + BREAK + + IF @TmpParentPackageID = @ParentPackageID + RETURN 1 + + SET @TmpPackageID = @TmpParentPackageID +END + + +RETURN 0 +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE FUNCTION [dbo].[CheckUserParent] +( + @OwnerID int, + @UserID int +) +RETURNS bit +AS +BEGIN + +-- check if the user requests himself +IF @OwnerID = @UserID +BEGIN + RETURN 1 +END + +-- check if the owner is peer +DECLARE @IsPeer int, @TmpOwnerID int +SELECT @IsPeer = IsPeer, @TmpOwnerID = OwnerID FROM Users +WHERE UserID = @OwnerID + +IF @IsPeer = 1 +SET @OwnerID = @TmpOwnerID + +-- check if the user requests himself +IF @OwnerID = @UserID +BEGIN + RETURN 1 +END + +DECLARE @ParentUserID int, @TmpUserID int +SET @TmpUserID = @UserID + +WHILE 10 = 10 +BEGIN + + SET @ParentUserID = NULL --reset var + + -- get owner + SELECT + @ParentUserID = OwnerID + FROM Users + WHERE UserID = @TmpUserID + + IF @ParentUserID IS NULL -- the last parent + BREAK + + IF @ParentUserID = @OwnerID + RETURN 1 + + SET @TmpUserID = @ParentUserID +END + + +RETURN 0 +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE FUNCTION GetFullIPAddress +( + @ExternalIP varchar(24), + @InternalIP varchar(24) +) +RETURNS varchar(60) +AS +BEGIN +DECLARE @IP varchar(60) +SET @IP = '' + +IF @ExternalIP IS NOT NULL AND @ExternalIP <> '' +SET @IP = @ExternalIP + +IF @InternalIP IS NOT NULL AND @InternalIP <> '' +SET @IP = @IP + ' (' + @InternalIP + ')' + +RETURN @IP +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE FUNCTION GetItemComments +( + @ItemID int, + @ItemTypeID varchar(50), + @ActorID int +) +RETURNS nvarchar(3000) +AS +BEGIN +DECLARE @text nvarchar(3000) +SET @text = '' + +SELECT @text = @text + U.Username + ' - ' + CONVERT(nvarchar(50), C.CreatedDate) + ' +' + CommentText + ' +-------------------------------------- +' FROM Comments AS C +INNER JOIN UsersDetailed AS U ON C.UserID = U.UserID +WHERE + ItemID = @ItemID + AND ItemTypeID = @ItemTypeID + AND dbo.CheckUserParent(@ActorID, C.UserID) = 1 +ORDER BY C.CreatedDate DESC + +RETURN @text +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE FUNCTION dbo.GetPackageAllocatedQuota +( + @PackageID int, + @QuotaID int +) +RETURNS int +AS +BEGIN + +DECLARE @Result int + +DECLARE @QuotaTypeID int +SELECT @QuotaTypeID = QuotaTypeID FROM Quotas +WHERE QuotaID = @QuotaID + +IF @QuotaTypeID = 1 + SET @Result = 1 -- enabled +ELSE + SET @Result = -1 -- unlimited + +DECLARE @PID int, @ParentPackageID int +SET @PID = @PackageID + +DECLARE @OverrideQuotas bit + +WHILE 1 = 1 +BEGIN + + DECLARE @QuotaValue int + + -- get package info + SELECT + @ParentPackageID = ParentPackageID, + @OverrideQuotas = OverrideQuotas + FROM Packages WHERE PackageID = @PID + + SET @QuotaValue = NULL + + -- check if this is a root 'System' package + IF @ParentPackageID IS NULL + BEGIN + IF @QuotaTypeID = 1 -- boolean + SET @QuotaValue = 1 -- enabled + ELSE IF @QuotaTypeID > 1 -- numeric + SET @QuotaValue = -1 -- unlimited + END + ELSE + BEGIN + -- check the current package + IF @OverrideQuotas = 1 + SELECT @QuotaValue = QuotaValue FROM PackageQuotas WHERE QuotaID = @QuotaID AND PackageID = @PID + ELSE + SELECT @QuotaValue = HPQ.QuotaValue FROM Packages AS P + INNER JOIN HostingPlanQuotas AS HPQ ON P.PlanID = HPQ.PlanID + WHERE HPQ.QuotaID = @QuotaID AND P.PackageID = @PID + + IF @QuotaValue IS NULL + SET @QuotaValue = 0 + + -- check package addons + DECLARE @QuotaAddonValue int + SELECT + @QuotaAddonValue = SUM(HPQ.QuotaValue * PA.Quantity) + FROM PackageAddons AS PA + INNER JOIN HostingPlanQuotas AS HPQ ON PA.PlanID = HPQ.PlanID + WHERE PA.PackageID = @PID AND HPQ.QuotaID = @QuotaID AND PA.StatusID = 1 -- active + + -- process bool quota + IF @QuotaAddonValue IS NOT NULL + BEGIN + IF @QuotaTypeID = 1 + BEGIN + IF @QuotaAddonValue > 0 AND @QuotaValue = 0 -- enabled + SET @QuotaValue = 1 + END + ELSE + BEGIN -- numeric quota + IF @QuotaAddonValue < 0 -- unlimited + SET @QuotaValue = -1 + ELSE + SET @QuotaValue = @QuotaValue + @QuotaAddonValue + END + END + END + + -- process bool quota + IF @QuotaTypeID = 1 + BEGIN + IF @QuotaValue = 0 OR @QuotaValue IS NULL -- disabled + RETURN 0 + END + ELSE + BEGIN -- numeric quota + IF @QuotaValue = 0 OR @QuotaValue IS NULL -- zero quantity + RETURN 0 + + IF (@QuotaValue <> -1 AND @Result = -1) OR (@QuotaValue < @Result AND @QuotaValue <> -1) + SET @Result = @QuotaValue + END + + IF @ParentPackageID IS NULL + RETURN @Result -- exit from the loop + + SET @PID = @ParentPackageID + +END -- end while + +RETURN @Result +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE FUNCTION dbo.GetPackageAllocatedResource +( + @PackageID int, + @GroupID int, + @ServerID int +) +RETURNS bit +AS +BEGIN + +IF @PackageID IS NULL +RETURN 1 + +DECLARE @Result bit +SET @Result = 1 -- enabled + +DECLARE @PID int, @ParentPackageID int +SET @PID = @PackageID + +DECLARE @OverrideQuotas bit + +IF @ServerID IS NULL OR @ServerID = 0 +SELECT @ServerID = ServerID FROM Packages +WHERE PackageID = @PackageID + +WHILE 1 = 1 +BEGIN + + DECLARE @GroupEnabled int + + -- get package info + SELECT + @ParentPackageID = ParentPackageID, + @OverrideQuotas = OverrideQuotas + FROM Packages WHERE PackageID = @PID + + -- check if this is a root 'System' package + SET @GroupEnabled = 1 -- enabled + IF @ParentPackageID IS NULL + BEGIN + + IF @ServerID = -1 OR @ServerID IS NULL + RETURN 1 + + IF EXISTS (SELECT VirtualServer FROM Servers WHERE ServerID = @ServerID AND VirtualServer = 1) + BEGIN + IF NOT EXISTS( + SELECT + DISTINCT(PROV.GroupID) + FROM VirtualServices AS VS + INNER JOIN Services AS S ON VS.ServiceID = S.ServiceID + INNER JOIN Providers AS PROV ON S.ProviderID = PROV.ProviderID + WHERE PROV.GroupID = @GroupID AND VS.ServerID = @ServerID + ) + SET @GroupEnabled = 0 + END + ELSE + BEGIN + IF NOT EXISTS( + SELECT + DISTINCT(PROV.GroupID) + FROM Services AS S + INNER JOIN Providers AS PROV ON S.ProviderID = PROV.ProviderID + WHERE PROV.GroupID = @GroupID AND S.ServerID = @ServerID + ) + SET @GroupEnabled = 0 + END + + RETURN @GroupEnabled -- exit from the loop + END + ELSE -- parentpackage is not null + BEGIN + -- check the current package + IF @OverrideQuotas = 1 + BEGIN + IF NOT EXISTS( + SELECT GroupID FROM PackageResources WHERE GroupID = @GroupID AND PackageID = @PID + ) + SET @GroupEnabled = 0 + END + ELSE + BEGIN + IF NOT EXISTS( + SELECT HPR.GroupID FROM Packages AS P + INNER JOIN HostingPlanResources AS HPR ON P.PlanID = HPR.PlanID + WHERE HPR.GroupID = @GroupID AND P.PackageID = @PID + ) + SET @GroupEnabled = 0 + END + + -- check addons + IF EXISTS( + SELECT HPR.GroupID FROM PackageAddons AS PA + INNER JOIN HostingPlanResources AS HPR ON PA.PlanID = HPR.PlanID + WHERE HPR.GroupID = @GroupID AND PA.PackageID = @PID + AND PA.StatusID = 1 -- active add-on + ) + SET @GroupEnabled = 1 + END + + IF @GroupEnabled = 0 + RETURN 0 + + SET @PID = @ParentPackageID + +END -- end while + +RETURN @Result +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + +CREATE FUNCTION dbo.GetPackageExceedingQuotas +( + @PackageID int +) +RETURNS @quotas TABLE (QuotaID int, QuotaName nvarchar(50), QuotaValue int) +AS +BEGIN + +DECLARE @ParentPackageID int +DECLARE @PlanID int +DECLARE @OverrideQuotas bit + +SELECT + @ParentPackageID = ParentPackageID, + @PlanID = PlanID, + @OverrideQuotas = OverrideQuotas +FROM Packages WHERE PackageID = @PackageID + + +IF @ParentPackageID IS NOT NULL -- not root package +BEGIN + + IF @OverrideQuotas = 0 -- hosting plan quotas + BEGIN + INSERT INTO @quotas (QuotaID, QuotaName, QuotaValue) + SELECT + Q.QuotaID, + Q.QuotaName, + dbo.CheckExceedingQuota(@PackageID, Q.QuotaID, Q.QuotaTypeID) AS QuotaValue + FROM HostingPlanQuotas AS HPQ + INNER JOIN Quotas AS Q ON HPQ.QuotaID = Q.QuotaID + WHERE HPQ.PlanID = @PlanID AND Q.QuotaTypeID <> 3 + END + ELSE -- overriden quotas + BEGIN + INSERT INTO @quotas (QuotaID, QuotaName, QuotaValue) + SELECT + Q.QuotaID, + Q.QuotaName, + dbo.CheckExceedingQuota(@PackageID, Q.QuotaID, Q.QuotaTypeID) AS QuotaValue + FROM PackageQuotas AS PQ + INNER JOIN Quotas AS Q ON PQ.QuotaID = Q.QuotaID + WHERE PQ.PackageID = @PackageID AND Q.QuotaTypeID <> 3 + END +END -- if 'root' package + +RETURN +END + + + + + + + + +GO +SET ANSI_NULLS OFF +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE FUNCTION dbo.PackageParents +( + @PackageID int +) +RETURNS @T TABLE (PackageOrder int IDENTITY(1,1), PackageID int) +AS +BEGIN + -- insert current user + INSERT @T VALUES (@PackageID) + + -- owner + DECLARE @ParentPackageID int, @TmpPackageID int + SET @TmpPackageID = @PackageID + + WHILE 10 = 10 + BEGIN + + SET @ParentPackageID = NULL --reset var + SELECT @ParentPackageID = ParentPackageID FROM Packages + WHERE PackageID = @TmpPackageID + + IF @ParentPackageID IS NULL -- parent not found + BREAK + + INSERT @T VALUES (@ParentPackageID) + + SET @TmpPackageID = @ParentPackageID + END + +RETURN +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE FUNCTION dbo.PackagesTree +( + @PackageID int, + @Recursive bit = 0 +) +RETURNS @T TABLE (PackageID int) +AS +BEGIN + +INSERT INTO @T VALUES (@PackageID) + +IF @Recursive = 1 +BEGIN + WITH RecursivePackages(ParentPackageID, PackageID, PackageLevel) AS + ( + SELECT ParentPackageID, PackageID, 0 AS PackageLevel + FROM Packages + WHERE ParentPackageID = @PackageID + UNION ALL + SELECT p.ParentPackageID, p.PackageID, PackageLevel + 1 + FROM Packages p + INNER JOIN RecursivePackages d + ON p.ParentPackageID = d.PackageID + WHERE @Recursive = 1 + ) + INSERT INTO @T + SELECT PackageID + FROM RecursivePackages +END + +RETURN +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE FUNCTION dbo.UserParents +( + @ActorID int, + @UserID int +) +RETURNS @T TABLE (UserOrder int IDENTITY(1,1), UserID int) +AS +BEGIN + -- insert current user + INSERT @T VALUES (@UserID) + + DECLARE @TopUserID int + IF @ActorID = -1 + BEGIN + SELECT @TopUserID = UserID FROM Users WHERE OwnerID IS NULL + END + ELSE + BEGIN + SET @TopUserID = @ActorID + + IF EXISTS (SELECT UserID FROM Users WHERE UserID = @ActorID AND IsPeer = 1) + SELECT @TopUserID = OwnerID FROM Users WHERE UserID = @ActorID AND IsPeer = 1 + END + + -- owner + DECLARE @OwnerID int, @TmpUserID int + + SET @TmpUserID = @UserID + + WHILE (@TmpUserID <> @TopUserID) + BEGIN + + SET @OwnerID = NULL + SELECT @OwnerID = OwnerID FROM Users WHERE UserID = @TmpUserID + + IF @OwnerID IS NOT NULL + BEGIN + INSERT @T VALUES (@OwnerID) + SET @TmpUserID = @OwnerID + END + END + +RETURN +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS OFF +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +CREATE FUNCTION dbo.UsersTree +( + @OwnerID int, + @Recursive bit = 0 +) +RETURNS @T TABLE (UserID int) +AS +BEGIN + + IF @Recursive = 1 + BEGIN + -- insert "root" user + INSERT @T VALUES(@OwnerID) + + -- get all children recursively + WHILE @@ROWCOUNT > 0 + BEGIN + INSERT @T SELECT UserID + FROM Users + WHERE OwnerID IN(SELECT UserID from @T) AND UserID NOT IN(SELECT UserID FROM @T) + END + END + ELSE + BEGIN + INSERT @T VALUES(@OwnerID) + END + +RETURN +END + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[AuditLog]( + [RecordID] [varchar](32) COLLATE Latin1_General_CI_AS NOT NULL, + [UserID] [int] NULL, + [Username] [nvarchar](50) COLLATE Latin1_General_CI_AS NULL, + [ItemID] [int] NULL, + [SeverityID] [int] NOT NULL, + [StartDate] [datetime] NOT NULL, + [FinishDate] [datetime] NOT NULL, + [SourceName] [varchar](50) COLLATE Latin1_General_CI_AS NOT NULL, + [TaskName] [varchar](50) COLLATE Latin1_General_CI_AS NOT NULL, + [ItemName] [nvarchar](100) COLLATE Latin1_General_CI_AS NULL, + [ExecutionLog] [ntext] COLLATE Latin1_General_CI_AS NULL, + [PackageID] [int] NULL, + CONSTRAINT [PK_Log] PRIMARY KEY CLUSTERED +( + [RecordID] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[AuditLogSources]( + [SourceName] [varchar](100) COLLATE Latin1_General_CI_AS NOT NULL, + CONSTRAINT [PK_AuditLogSources] PRIMARY KEY CLUSTERED +( + [SourceName] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[AuditLogTasks]( + [SourceName] [varchar](100) COLLATE Latin1_General_CI_AS NOT NULL, + [TaskName] [varchar](100) COLLATE Latin1_General_CI_AS NOT NULL, + [TaskDescription] [nvarchar](100) COLLATE Latin1_General_CI_AS NULL, + CONSTRAINT [PK_LogActions] PRIMARY KEY CLUSTERED +( + [SourceName] ASC, + [TaskName] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[BlackBerryUsers]( + [BlackBerryUserId] [int] IDENTITY(1,1) NOT NULL, + [AccountId] [int] NOT NULL, + [CreatedDate] [datetime] NOT NULL, + [ModifiedDate] [datetime] NOT NULL, + CONSTRAINT [PK_BlackBerryUsers] PRIMARY KEY CLUSTERED +( + [BlackBerryUserId] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[Clusters]( + [ClusterID] [int] IDENTITY(1,1) NOT NULL, + [ClusterName] [nvarchar](100) COLLATE Latin1_General_CI_AS NOT NULL, + CONSTRAINT [PK_Clusters] PRIMARY KEY CLUSTERED +( + [ClusterID] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[Comments]( + [CommentID] [int] IDENTITY(1,1) NOT NULL, + [ItemTypeID] [varchar](50) COLLATE Latin1_General_CI_AS NOT NULL, + [ItemID] [int] NOT NULL, + [UserID] [int] NOT NULL, + [CreatedDate] [datetime] NOT NULL, + [CommentText] [nvarchar](1000) COLLATE Latin1_General_CI_AS NULL, + [SeverityID] [int] NULL, + CONSTRAINT [PK_Comments] PRIMARY KEY CLUSTERED +( + [CommentID] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[CRMUsers]( + [CRMUserID] [int] IDENTITY(1,1) NOT NULL, + [AccountID] [int] NOT NULL, + [CreatedDate] [datetime] NOT NULL, + [ChangedDate] [datetime] NOT NULL, + [CRMUserGuid] [uniqueidentifier] NULL, + [BusinessUnitID] [uniqueidentifier] NULL, + CONSTRAINT [PK_CRMUsers] PRIMARY KEY CLUSTERED +( + [CRMUserID] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[Domains]( + [DomainID] [int] IDENTITY(1,1) NOT NULL, + [PackageID] [int] NOT NULL, + [ZoneItemID] [int] NULL, + [DomainName] [nvarchar](100) COLLATE Latin1_General_CI_AS NOT NULL, + [HostingAllowed] [bit] NOT NULL, + [WebSiteID] [int] NULL, + [MailDomainID] [int] NULL, + [IsSubDomain] [bit] NOT NULL, + [IsInstantAlias] [bit] NOT NULL, + [IsDomainPointer] [bit] NOT NULL, + [DomainItemId] [int] NULL, + CONSTRAINT [PK_Domains] PRIMARY KEY CLUSTERED +( + [DomainID] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[ecAddonProducts]( + [AddonID] [int] NOT NULL, + [ProductID] [int] NOT NULL, + [ResellerID] [int] NOT NULL, + CONSTRAINT [PK_ecAddonProducts] PRIMARY KEY CLUSTERED +( + [AddonID] ASC, + [ProductID] ASC, + [ResellerID] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[ecBillingCycles]( + [CycleID] [int] IDENTITY(1,1) NOT NULL, + [ResellerID] [int] NOT NULL, + [CycleName] [nvarchar](255) COLLATE Latin1_General_CI_AS NOT NULL, + [BillingPeriod] [nvarchar](50) COLLATE Latin1_General_CI_AS NOT NULL, + [PeriodLength] [int] NOT NULL, + [Created] [datetime] NOT NULL, + CONSTRAINT [PK_ecBillingCycles] PRIMARY KEY CLUSTERED +( + [CycleID] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[ecCategory]( + [CategoryID] [int] IDENTITY(1,1) NOT NULL, + [CategoryName] [nvarchar](255) COLLATE Latin1_General_CI_AS NOT NULL, + [CategorySku] [nvarchar](50) COLLATE Latin1_General_CI_AS NOT NULL, + [ParentID] [int] NULL, + [Level] [int] NOT NULL, + [ShortDescription] [nvarchar](255) COLLATE Latin1_General_CI_AS NULL, + [FullDescription] [ntext] COLLATE Latin1_General_CI_AS NULL, + [Created] [datetime] NOT NULL, + [Modified] [datetime] NULL, + [CreatorID] [int] NOT NULL, + [ModifierID] [int] NULL, + [ItemOrder] [int] NULL, + [ResellerID] [int] NOT NULL, + CONSTRAINT [PK_EC_Categories] PRIMARY KEY CLUSTERED +( + [CategoryID] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[ecContracts]( + [ContractID] [nvarchar](50) COLLATE Latin1_General_CI_AS NOT NULL, + [CustomerID] [int] NULL, + [ResellerID] [int] NOT NULL, + [AccountName] [nvarchar](50) COLLATE Latin1_General_CI_AS NOT NULL, + [OpenedDate] [datetime] NOT NULL, + [Status] [int] NOT NULL, + [ClosedDate] [datetime] NULL, + [Balance] [money] NOT NULL, + [FirstName] [nvarchar](50) COLLATE Latin1_General_CI_AS NOT NULL, + [LastName] [nvarchar](50) COLLATE Latin1_General_CI_AS NOT NULL, + [Email] [nvarchar](255) COLLATE Latin1_General_CI_AS NOT NULL, + [CompanyName] [nvarchar](50) COLLATE Latin1_General_CI_AS NULL, + [PropertyNames] [ntext] COLLATE Latin1_General_CI_AS NULL, + [PropertyValues] [ntext] COLLATE Latin1_General_CI_AS NULL, + CONSTRAINT [PK_ecContracts] PRIMARY KEY CLUSTERED +( + [ContractID] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[ecCustomersPayments]( + [PaymentID] [int] IDENTITY(1,1) NOT NULL, + [InvoiceID] [int] NOT NULL, + [TransactionID] [nvarchar](255) COLLATE Latin1_General_CI_AS NOT NULL, + [Total] [money] NOT NULL, + [Currency] [nvarchar](3) COLLATE Latin1_General_CI_AS NOT NULL, + [Created] [datetime] NOT NULL, + [MethodName] [nvarchar](50) COLLATE Latin1_General_CI_AS NOT NULL, + [PluginID] [int] NOT NULL, + [StatusID] [int] NOT NULL, + [ContractID] [nvarchar](50) COLLATE Latin1_General_CI_AS NOT NULL, + CONSTRAINT [PK_EC_Payments] PRIMARY KEY CLUSTERED +( + [PaymentID] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[ecDomainSvcs]( + [ServiceID] [int] NOT NULL, + [ProductID] [int] NULL, + [DomainID] [int] NULL, + [PluginID] [int] NULL, + [FQDN] [nvarchar](64) COLLATE Latin1_General_CI_AS NOT NULL, + [SvcCycleID] [int] NULL, + [PropertyNames] [ntext] COLLATE Latin1_General_CI_AS NULL, + [PropertyValues] [ntext] COLLATE Latin1_General_CI_AS NULL, + CONSTRAINT [PK_ecDomainsSvcs] PRIMARY KEY CLUSTERED +( + [ServiceID] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[ecDomainSvcsCycles]( + [SvcCycleID] [int] IDENTITY(1,1) NOT NULL, + [ServiceID] [int] NOT NULL, + [CycleName] [nvarchar](255) COLLATE Latin1_General_CI_AS NOT NULL, + [BillingPeriod] [nvarchar](50) COLLATE Latin1_General_CI_AS NOT NULL, + [PeriodLength] [int] NOT NULL, + [SetupFee] [money] NOT NULL, + [RecurringFee] [money] NOT NULL, + [Currency] [nvarchar](3) COLLATE Latin1_General_CI_AS NOT NULL, + CONSTRAINT [PK_ecDomainsSvcsCycles] PRIMARY KEY CLUSTERED +( + [SvcCycleID] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[ecHostingAddons]( + [ProductID] [int] NOT NULL, + [PlanID] [int] NULL, + [Recurring] [bit] NOT NULL, + [DummyAddon] [bit] NOT NULL, + [Countable] [bit] NOT NULL, + [SetupFee] [money] NULL, + [OneTimeFee] [money] NULL, + [2COID] [nvarchar](50) COLLATE Latin1_General_CI_AS NULL, + [ResellerID] [int] NOT NULL +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[ecHostingAddonsCycles]( + [ProductID] [int] NOT NULL, + [CycleID] [int] NOT NULL, + [SetupFee] [money] NOT NULL, + [RecurringFee] [money] NOT NULL, + [SortOrder] [int] NOT NULL, + CONSTRAINT [PK_ecHostingAddonsCycles] PRIMARY KEY CLUSTERED +( + [ProductID] ASC, + [CycleID] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[ecHostingAddonSvcs]( + [ServiceID] [int] NOT NULL, + [ProductID] [int] NOT NULL, + [PlanID] [int] NULL, + [PackageAddonID] [int] NULL, + [Quantity] [int] NOT NULL, + [Recurring] [bit] NOT NULL, + [DummyAddon] [bit] NOT NULL, + [SvcCycleID] [int] NOT NULL, + CONSTRAINT [PK_ecAddonPackagesSvcs] PRIMARY KEY CLUSTERED +( + [ServiceID] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[ecHostingAddonSvcsCycles]( + [SvcCycleID] [int] IDENTITY(1,1) NOT NULL, + [ServiceID] [int] NOT NULL, + [CycleName] [nvarchar](255) COLLATE Latin1_General_CI_AS NULL, + [BillingPeriod] [nvarchar](50) COLLATE Latin1_General_CI_AS NULL, + [PeriodLength] [int] NULL, + [SetupFee] [money] NULL, + [CyclePrice] [money] NOT NULL, + [Currency] [nvarchar](3) COLLATE Latin1_General_CI_AS NOT NULL, + CONSTRAINT [PK_ecAddonPackagesSvcsCycles] PRIMARY KEY CLUSTERED +( + [SvcCycleID] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[ecHostingPackageSvcs]( + [ServiceID] [int] NOT NULL, + [ProductID] [int] NOT NULL, + [PlanID] [int] NOT NULL, + [PackageID] [int] NULL, + [UserRole] [int] NOT NULL, + [InitialStatus] [int] NOT NULL, + [SvcCycleID] [int] NOT NULL, + CONSTRAINT [PK_ecPackagesSvcs] PRIMARY KEY CLUSTERED +( + [ServiceID] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[ecHostingPackageSvcsCycles]( + [SvcCycleID] [int] IDENTITY(1,1) NOT NULL, + [ServiceID] [int] NOT NULL, + [CycleName] [nvarchar](255) COLLATE Latin1_General_CI_AS NOT NULL, + [BillingPeriod] [nvarchar](50) COLLATE Latin1_General_CI_AS NOT NULL, + [PeriodLength] [int] NOT NULL, + [SetupFee] [money] NULL, + [RecurringFee] [money] NOT NULL, + [Currency] [nvarchar](3) COLLATE Latin1_General_CI_AS NOT NULL, + CONSTRAINT [PK_ecPackagesSvcsCycles] PRIMARY KEY CLUSTERED +( + [SvcCycleID] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[ecHostingPlans]( + [ProductID] [int] NOT NULL, + [ResellerID] [int] NOT NULL, + [PlanID] [int] NOT NULL, + [UserRole] [int] NOT NULL, + [InitialStatus] [int] NOT NULL, + [DomainOption] [int] NOT NULL, + CONSTRAINT [PK_ecHostingPlans] PRIMARY KEY CLUSTERED +( + [ProductID] ASC, + [ResellerID] ASC, + [PlanID] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[ecHostingPlansBillingCycles]( + [ProductID] [int] NOT NULL, + [CycleID] [int] NOT NULL, + [SetupFee] [money] NOT NULL, + [RecurringFee] [money] NOT NULL, + [SortOrder] [int] NOT NULL, + CONSTRAINT [PK_ecHostingPlansBillingCycles] PRIMARY KEY CLUSTERED +( + [ProductID] ASC, + [CycleID] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[ecInvoice]( + [InvoiceID] [int] IDENTITY(1,1) NOT NULL, + [Created] [datetime] NOT NULL, + [DueDate] [datetime] NOT NULL, + [Total] [money] NOT NULL, + [SubTotal] [money] NOT NULL, + [TaxAmount] [money] NULL, + [Currency] [nvarchar](3) COLLATE Latin1_General_CI_AS NOT NULL, + [InvoiceNumber] [nvarchar](50) COLLATE Latin1_General_CI_AS NULL, + [TaxationID] [int] NULL, + [ContractID] [nvarchar](50) COLLATE Latin1_General_CI_AS NOT NULL, + CONSTRAINT [PK_EC_Invoices] PRIMARY KEY CLUSTERED +( + [InvoiceID] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[ecInvoiceItems]( + [ItemID] [int] IDENTITY(1,1) NOT NULL, + [InvoiceID] [int] NOT NULL, + [ServiceID] [int] NULL, + [ItemName] [nvarchar](255) COLLATE Latin1_General_CI_AS NOT NULL, + [TypeName] [nvarchar](255) COLLATE Latin1_General_CI_AS NOT NULL, + [Quantity] [int] NOT NULL, + [Total] [money] NOT NULL, + [SubTotal] [money] NOT NULL, + [UnitPrice] [money] NOT NULL, + [Processed] [bit] NOT NULL, + CONSTRAINT [PK_EC_InvoiceItems] PRIMARY KEY CLUSTERED +( + [ItemID] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[ecPaymentMethods]( + [ResellerID] [int] NOT NULL, + [MethodName] [nvarchar](50) COLLATE Latin1_General_CI_AS NOT NULL, + [PluginID] [int] NOT NULL, + [DisplayName] [nvarchar](50) COLLATE Latin1_General_CI_AS NOT NULL, + [SupportedItems] [nvarchar](255) COLLATE Latin1_General_CI_AS NULL, + CONSTRAINT [PK_ecPaymentMethods] PRIMARY KEY CLUSTERED +( + [ResellerID] ASC, + [MethodName] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[ecPaymentProfiles]( + [PropertyNames] [ntext] COLLATE Latin1_General_CI_AS NOT NULL, + [PropertyValues] [ntext] COLLATE Latin1_General_CI_AS NOT NULL, + [Created] [datetime] NOT NULL, + [ContractID] [nvarchar](50) COLLATE Latin1_General_CI_AS NOT NULL, + CONSTRAINT [PK_ecPaymentProfiles] PRIMARY KEY CLUSTERED +( + [ContractID] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[ecPluginsProperties]( + [PluginID] [int] NOT NULL, + [PropertyName] [nvarchar](50) COLLATE Latin1_General_CI_AS NOT NULL, + [PropertyValue] [nvarchar](512) COLLATE Latin1_General_CI_AS NULL, + [ResellerID] [int] NOT NULL, + CONSTRAINT [PK_ecPluginsSettings] PRIMARY KEY CLUSTERED +( + [PluginID] ASC, + [ResellerID] ASC, + [PropertyName] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[ecProduct]( + [ProductID] [int] IDENTITY(1,1) NOT NULL, + [ProductName] [nvarchar](255) COLLATE Latin1_General_CI_AS NOT NULL, + [ProductSKU] [nvarchar](50) COLLATE Latin1_General_CI_AS NOT NULL, + [TypeID] [int] NULL, + [Description] [ntext] COLLATE Latin1_General_CI_AS NULL, + [Created] [datetime] NOT NULL, + [Enabled] [bit] NOT NULL, + [ResellerID] [int] NOT NULL, + [TaxInclusive] [bit] NULL, + CONSTRAINT [PK_EC_Products] PRIMARY KEY CLUSTERED +( + [ProductID] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[ecProductCategories]( + [ProductID] [int] NOT NULL, + [CategoryID] [int] NOT NULL, + [ResellerID] [int] NOT NULL, + CONSTRAINT [PK_ecProductCategories] PRIMARY KEY CLUSTERED +( + [ProductID] ASC, + [CategoryID] ASC, + [ResellerID] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[ecProductsHighlights]( + [ProductID] [int] NOT NULL, + [HighlightText] [nvarchar](255) COLLATE Latin1_General_CI_AS NOT NULL, + [SortOrder] [int] NOT NULL +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[ecProductType]( + [TypeID] [int] IDENTITY(1,1) NOT NULL, + [TypeName] [nvarchar](255) COLLATE Latin1_General_CI_AS NULL, + [ProvisioningController] [nvarchar](512) COLLATE Latin1_General_CI_AS NULL, + [Created] [datetime] NOT NULL, + [NativeItemType] [nvarchar](512) COLLATE Latin1_General_CI_AS NOT NULL, + [ServiceItemType] [nvarchar](512) COLLATE Latin1_General_CI_AS NOT NULL, + CONSTRAINT [PK_EC_ProductTypes] PRIMARY KEY CLUSTERED +( + [TypeID] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[ecProductTypeControls]( + [TypeID] [int] NOT NULL, + [ControlKey] [nvarchar](50) COLLATE Latin1_General_CI_AS NOT NULL, + [ControlSrc] [nvarchar](512) COLLATE Latin1_General_CI_AS NOT NULL, + CONSTRAINT [PK_ecProductTypeControls] PRIMARY KEY CLUSTERED +( + [TypeID] ASC, + [ControlKey] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[ecService]( + [ServiceID] [int] IDENTITY(1,1) NOT NULL, + [ServiceName] [nvarchar](255) COLLATE Latin1_General_CI_AS NOT NULL, + [TypeID] [int] NULL, + [Status] [int] NOT NULL, + [Created] [datetime] NOT NULL, + [Modified] [datetime] NULL, + [ParentID] [int] NULL, + [ContractID] [nvarchar](50) COLLATE Latin1_General_CI_AS NOT NULL, + CONSTRAINT [PK_SpaceInstances] PRIMARY KEY CLUSTERED +( + [ServiceID] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[ecServiceHandlersResponses]( + [ResponseID] [int] IDENTITY(1,1) NOT NULL, + [ServiceID] [nvarchar](50) COLLATE Latin1_General_CI_AS NOT NULL, + [ContractID] [nvarchar](50) COLLATE Latin1_General_CI_AS NULL, + [InvoiceID] [int] NULL, + [TextResponse] [ntext] COLLATE Latin1_General_CI_AS NULL, + [Received] [datetime] NOT NULL, + [ErrorMessage] [nvarchar](255) COLLATE Latin1_General_CI_AS NULL, + CONSTRAINT [PK_ecServiceHandlersResponses] PRIMARY KEY CLUSTERED +( + [ResponseID] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[ecStoreDefaultSettings]( + [SettingsName] [nvarchar](50) COLLATE Latin1_General_CI_AS NOT NULL, + [PropertyName] [nvarchar](50) COLLATE Latin1_General_CI_AS NOT NULL, + [PropertyValue] [ntext] COLLATE Latin1_General_CI_AS NULL, + CONSTRAINT [PK_ecSpaceDefaultSettings] PRIMARY KEY CLUSTERED +( + [SettingsName] ASC, + [PropertyName] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[ecStoreSettings]( + [SettingsName] [nvarchar](50) COLLATE Latin1_General_CI_AS NOT NULL, + [PropertyName] [nvarchar](50) COLLATE Latin1_General_CI_AS NOT NULL, + [PropertyValue] [ntext] COLLATE Latin1_General_CI_AS NULL, + [ResellerID] [int] NOT NULL, + CONSTRAINT [PK_ecSystemSettings] PRIMARY KEY CLUSTERED +( + [ResellerID] ASC, + [SettingsName] ASC, + [PropertyName] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[ecSupportedPluginLog]( + [RecordID] [int] IDENTITY(1,1) NOT NULL, + [PluginID] [int] NOT NULL, + [RecordType] [int] NOT NULL, + [RawData] [ntext] COLLATE Latin1_General_CI_AS NOT NULL, + [Created] [datetime] NOT NULL, + [ContractID] [nvarchar](50) COLLATE Latin1_General_CI_AS NOT NULL, + CONSTRAINT [PK_ecSpacePluginLog] PRIMARY KEY CLUSTERED +( + [RecordID] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[ecSupportedPlugins]( + [PluginID] [int] IDENTITY(1,1) NOT NULL, + [PluginName] [nvarchar](50) COLLATE Latin1_General_CI_AS NOT NULL, + [DisplayName] [nvarchar](50) COLLATE Latin1_General_CI_AS NOT NULL, + [PluginGroup] [nvarchar](50) COLLATE Latin1_General_CI_AS NOT NULL, + [TypeName] [nvarchar](255) COLLATE Latin1_General_CI_AS NOT NULL, + [Interactive] [bit] NOT NULL, + [SupportedItems] [nvarchar](255) COLLATE Latin1_General_CI_AS NULL, + [UniqueID] [nvarchar](50) COLLATE Latin1_General_CI_AS NULL, + CONSTRAINT [PK_ecSupportedPlugins] PRIMARY KEY CLUSTERED +( + [PluginID] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[ecSvcsUsageLog]( + [ServiceID] [int] NOT NULL, + [StartDate] [datetime] NOT NULL, + [EndDate] [datetime] NOT NULL, + [SvcCycleID] [int] NOT NULL, + [PeriodClosed] [bit] NULL, + CONSTRAINT [PK_ecServicesLifeCyclesLog] PRIMARY KEY CLUSTERED +( + [ServiceID] ASC, + [SvcCycleID] ASC, + [StartDate] ASC, + [EndDate] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[ecSystemTriggers]( + [TriggerID] [nvarchar](50) COLLATE Latin1_General_CI_AS NOT NULL, + [OwnerID] [int] NOT NULL, + [TriggerHandler] [nvarchar](512) COLLATE Latin1_General_CI_AS NOT NULL, + [ReferenceID] [nvarchar](50) COLLATE Latin1_General_CI_AS NOT NULL, + [Namespace] [nvarchar](255) COLLATE Latin1_General_CI_AS NOT NULL, + [Status] [nvarchar](50) COLLATE Latin1_General_CI_AS NULL, + CONSTRAINT [PK_ecSystemTriggers] PRIMARY KEY CLUSTERED +( + [TriggerID] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[ecTaxations]( + [TaxationID] [int] IDENTITY(1,1) NOT NULL, + [ResellerID] [int] NOT NULL, + [Country] [nvarchar](3) COLLATE Latin1_General_CI_AS NOT NULL, + [State] [nvarchar](50) COLLATE Latin1_General_CI_AS NOT NULL, + [Description] [nvarchar](50) COLLATE Latin1_General_CI_AS NOT NULL, + [TypeID] [int] NOT NULL, + [Amount] [decimal](5, 2) NOT NULL, + [Active] [bit] NOT NULL, + CONSTRAINT [PK_ecTaxations_1] PRIMARY KEY CLUSTERED +( + [TaxationID] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[ecTopLevelDomains]( + [TopLevelDomain] [nvarchar](10) COLLATE Latin1_General_CI_AS NOT NULL, + [ProductID] [int] NOT NULL, + [PluginID] [int] NOT NULL, + [ResellerID] [int] NOT NULL, + [WhoisEnabled] [bit] NULL, + CONSTRAINT [PK_ecTopLevelDomains] PRIMARY KEY CLUSTERED +( + [TopLevelDomain] ASC, + [ResellerID] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[ecTopLevelDomainsCycles]( + [ProductID] [int] NOT NULL, + [CycleID] [int] NOT NULL, + [SetupFee] [money] NOT NULL, + [RecurringFee] [money] NOT NULL, + [TransferFee] [money] NULL, + [SortOrder] [int] NOT NULL +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[ExchangeAccountEmailAddresses]( + [AddressID] [int] IDENTITY(1,1) NOT NULL, + [AccountID] [int] NOT NULL, + [EmailAddress] [nvarchar](300) COLLATE Latin1_General_CI_AS NOT NULL, + CONSTRAINT [PK_ExchangeAccountEmailAddresses] PRIMARY KEY CLUSTERED +( + [AddressID] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[ExchangeAccounts]( + [AccountID] [int] IDENTITY(1,1) NOT NULL, + [ItemID] [int] NOT NULL, + [AccountType] [int] NOT NULL, + [AccountName] [nvarchar](300) COLLATE Latin1_General_CI_AS NOT NULL, + [DisplayName] [nvarchar](300) COLLATE Latin1_General_CI_AS NOT NULL, + [PrimaryEmailAddress] [nvarchar](300) COLLATE Latin1_General_CI_AS NULL, + [MailEnabledPublicFolder] [bit] NULL, + [MailboxManagerActions] [varchar](200) COLLATE Latin1_General_CI_AS NULL, + [SamAccountName] [nvarchar](100) COLLATE Latin1_General_CI_AS NULL, + [AccountPassword] [nvarchar](200) COLLATE Latin1_General_CI_AS NULL, + [CreatedDate] [datetime] NOT NULL, + [MailboxPlanId] [int] NULL, + [SubscriberNumber] [nvarchar](32) COLLATE Latin1_General_CI_AS NULL, + [UserPrincipalName] [nvarchar](300) COLLATE Latin1_General_CI_AS NULL, + CONSTRAINT [PK_ExchangeAccounts] PRIMARY KEY CLUSTERED +( + [AccountID] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[ExchangeMailboxPlans]( + [MailboxPlanId] [int] IDENTITY(1,1) NOT NULL, + [ItemID] [int] NOT NULL, + [MailboxPlan] [nvarchar](300) COLLATE Latin1_General_CI_AS NOT NULL, + [MailboxPlanType] [int] NULL, + [EnableActiveSync] [bit] NOT NULL, + [EnableIMAP] [bit] NOT NULL, + [EnableMAPI] [bit] NOT NULL, + [EnableOWA] [bit] NOT NULL, + [EnablePOP] [bit] NOT NULL, + [IsDefault] [bit] NOT NULL, + [IssueWarningPct] [int] NOT NULL, + [KeepDeletedItemsDays] [int] NOT NULL, + [MailboxSizeMB] [int] NOT NULL, + [MaxReceiveMessageSizeKB] [int] NOT NULL, + [MaxRecipients] [int] NOT NULL, + [MaxSendMessageSizeKB] [int] NOT NULL, + [ProhibitSendPct] [int] NOT NULL, + [ProhibitSendReceivePct] [int] NOT NULL, + [HideFromAddressBook] [bit] NOT NULL, + CONSTRAINT [PK_ExchangeMailboxPlans] PRIMARY KEY CLUSTERED +( + [MailboxPlanId] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[ExchangeOrganizationDomains]( + [OrganizationDomainID] [int] IDENTITY(1,1) NOT NULL, + [ItemID] [int] NOT NULL, + [DomainID] [int] NULL, + [IsHost] [bit] NULL, + [DomainTypeID] [int] NOT NULL, + CONSTRAINT [PK_ExchangeOrganizationDomains] PRIMARY KEY CLUSTERED +( + [OrganizationDomainID] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[ExchangeOrganizations]( + [ItemID] [int] NOT NULL, + [OrganizationID] [nvarchar](128) COLLATE Latin1_General_CI_AS NOT NULL, + [ExchangeMailboxPlanID] [int] NULL, + [LyncUserPlanID] [int] NULL, + CONSTRAINT [PK_ExchangeOrganizations] PRIMARY KEY CLUSTERED +( + [ItemID] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[GlobalDnsRecords]( + [RecordID] [int] IDENTITY(1,1) NOT NULL, + [RecordType] [varchar](10) COLLATE Latin1_General_CI_AS NOT NULL, + [RecordName] [nvarchar](50) COLLATE Latin1_General_CI_AS NOT NULL, + [RecordData] [nvarchar](500) COLLATE Latin1_General_CI_AS NOT NULL, + [MXPriority] [int] NOT NULL, + [ServiceID] [int] NULL, + [ServerID] [int] NULL, + [PackageID] [int] NULL, + [IPAddressID] [int] NULL, + [SrvPriority] [int] NULL, + [SrvWeight] [int] NULL, + [SrvPort] [int] NULL, + CONSTRAINT [PK_GlobalDnsRecords] PRIMARY KEY CLUSTERED +( + [RecordID] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[HostingPlanQuotas]( + [PlanID] [int] NOT NULL, + [QuotaID] [int] NOT NULL, + [QuotaValue] [int] NOT NULL, + CONSTRAINT [PK_HostingPlanQuotas_1] PRIMARY KEY CLUSTERED +( + [PlanID] ASC, + [QuotaID] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[HostingPlanResources]( + [PlanID] [int] NOT NULL, + [GroupID] [int] NOT NULL, + [CalculateDiskSpace] [bit] NULL, + [CalculateBandwidth] [bit] NULL, + CONSTRAINT [PK_HostingPlanResources] PRIMARY KEY CLUSTERED +( + [PlanID] ASC, + [GroupID] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[HostingPlans]( + [PlanID] [int] IDENTITY(1,1) NOT NULL, + [UserID] [int] NULL, + [PackageID] [int] NULL, + [ServerID] [int] NULL, + [PlanName] [nvarchar](200) COLLATE Latin1_General_CI_AS NOT NULL, + [PlanDescription] [ntext] COLLATE Latin1_General_CI_AS NULL, + [Available] [bit] NOT NULL, + [SetupPrice] [money] NULL, + [RecurringPrice] [money] NULL, + [RecurrenceUnit] [int] NULL, + [RecurrenceLength] [int] NULL, + [IsAddon] [bit] NULL, + CONSTRAINT [PK_HostingPlans] PRIMARY KEY CLUSTERED +( + [PlanID] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[IPAddresses]( + [AddressID] [int] IDENTITY(1,1) NOT NULL, + [ExternalIP] [varchar](24) COLLATE Latin1_General_CI_AS NOT NULL, + [InternalIP] [varchar](24) COLLATE Latin1_General_CI_AS NULL, + [ServerID] [int] NULL, + [Comments] [ntext] COLLATE Latin1_General_CI_AS NULL, + [SubnetMask] [varchar](15) COLLATE Latin1_General_CI_AS NULL, + [DefaultGateway] [varchar](15) COLLATE Latin1_General_CI_AS NULL, + [PoolID] [int] NULL, + CONSTRAINT [PK_IPAddresses] PRIMARY KEY CLUSTERED +( + [AddressID] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[LyncUserPlans]( + [LyncUserPlanId] [int] IDENTITY(1,1) NOT NULL, + [ItemID] [int] NOT NULL, + [LyncUserPlanName] [nvarchar](300) COLLATE Latin1_General_CI_AS NOT NULL, + [LyncUserPlanType] [int] NULL, + [IM] [bit] NOT NULL, + [Mobility] [bit] NOT NULL, + [MobilityEnableOutsideVoice] [bit] NOT NULL, + [Federation] [bit] NOT NULL, + [Conferencing] [bit] NOT NULL, + [EnterpriseVoice] [bit] NOT NULL, + [VoicePolicy] [int] NOT NULL, + [IsDefault] [bit] NOT NULL, + CONSTRAINT [PK_LyncUserPlans] PRIMARY KEY CLUSTERED +( + [LyncUserPlanId] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[LyncUsers]( + [LyncUserID] [int] IDENTITY(1,1) NOT NULL, + [AccountID] [int] NOT NULL, + [LyncUserPlanID] [int] NOT NULL, + [CreatedDate] [datetime] NOT NULL, + [ModifiedDate] [datetime] NOT NULL, + [SipAddress] [nvarchar](300) COLLATE Latin1_General_CI_AS NULL, + CONSTRAINT [PK_LyncUsers] PRIMARY KEY CLUSTERED +( + [LyncUserID] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[OCSUsers]( + [OCSUserID] [int] IDENTITY(1,1) NOT NULL, + [AccountID] [int] NOT NULL, + [InstanceID] [nvarchar](50) COLLATE Latin1_General_CI_AS NOT NULL, + [CreatedDate] [datetime] NOT NULL, + [ModifiedDate] [datetime] NOT NULL, + CONSTRAINT [PK_OCSUsers] PRIMARY KEY CLUSTERED +( + [OCSUserID] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[PackageAddons]( + [PackageAddonID] [int] IDENTITY(1,1) NOT NULL, + [PackageID] [int] NULL, + [PlanID] [int] NULL, + [Quantity] [int] NULL, + [PurchaseDate] [datetime] NULL, + [Comments] [ntext] COLLATE Latin1_General_CI_AS NULL, + [StatusID] [int] NULL, + CONSTRAINT [PK_PackageAddons] PRIMARY KEY CLUSTERED +( + [PackageAddonID] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[PackageIPAddresses]( + [PackageAddressID] [int] IDENTITY(1,1) NOT NULL, + [PackageID] [int] NOT NULL, + [AddressID] [int] NOT NULL, + [ItemID] [int] NULL, + [IsPrimary] [bit] NULL, + CONSTRAINT [PK_PackageIPAddresses] PRIMARY KEY CLUSTERED +( + [PackageAddressID] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[PackageQuotas]( + [PackageID] [int] NOT NULL, + [QuotaID] [int] NOT NULL, + [QuotaValue] [int] NOT NULL, + CONSTRAINT [PK_PackageQuotas] PRIMARY KEY CLUSTERED +( + [PackageID] ASC, + [QuotaID] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[PackageResources]( + [PackageID] [int] NOT NULL, + [GroupID] [int] NOT NULL, + [CalculateDiskspace] [bit] NOT NULL, + [CalculateBandwidth] [bit] NOT NULL, + CONSTRAINT [PK_PackageResources_1] PRIMARY KEY CLUSTERED +( + [PackageID] ASC, + [GroupID] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[Packages]( + [PackageID] [int] IDENTITY(1,1) NOT NULL, + [ParentPackageID] [int] NULL, + [UserID] [int] NOT NULL, + [PackageName] [nvarchar](300) COLLATE Latin1_General_CI_AS NULL, + [PackageComments] [ntext] COLLATE Latin1_General_CI_AS NULL, + [ServerID] [int] NULL, + [StatusID] [int] NOT NULL, + [PlanID] [int] NULL, + [PurchaseDate] [datetime] NULL, + [OverrideQuotas] [bit] NOT NULL, + [BandwidthUpdated] [datetime] NULL, + CONSTRAINT [PK_Packages] PRIMARY KEY CLUSTERED +( + [PackageID] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[PackagesBandwidth]( + [PackageID] [int] NOT NULL, + [GroupID] [int] NOT NULL, + [LogDate] [datetime] NOT NULL, + [BytesSent] [bigint] NOT NULL, + [BytesReceived] [bigint] NOT NULL, + CONSTRAINT [PK_PackagesBandwidth] PRIMARY KEY CLUSTERED +( + [PackageID] ASC, + [GroupID] ASC, + [LogDate] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[PackagesDiskspace]( + [PackageID] [int] NOT NULL, + [GroupID] [int] NOT NULL, + [DiskSpace] [bigint] NOT NULL, + CONSTRAINT [PK_PackagesDiskspace] PRIMARY KEY CLUSTERED +( + [PackageID] ASC, + [GroupID] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[PackageServices]( + [PackageID] [int] NOT NULL, + [ServiceID] [int] NOT NULL, + CONSTRAINT [PK_PackageServices] PRIMARY KEY CLUSTERED +( + [PackageID] ASC, + [ServiceID] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[PackageSettings]( + [PackageID] [int] NOT NULL, + [SettingsName] [nvarchar](50) COLLATE Latin1_General_CI_AS NOT NULL, + [PropertyName] [nvarchar](50) COLLATE Latin1_General_CI_AS NOT NULL, + [PropertyValue] [ntext] COLLATE Latin1_General_CI_AS NULL, + CONSTRAINT [PK_PackageSettings] PRIMARY KEY CLUSTERED +( + [PackageID] ASC, + [SettingsName] ASC, + [PropertyName] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[PackagesTreeCache]( + [ParentPackageID] [int] NOT NULL, + [PackageID] [int] NOT NULL +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[PrivateIPAddresses]( + [PrivateAddressID] [int] IDENTITY(1,1) NOT NULL, + [ItemID] [int] NOT NULL, + [IPAddress] [varchar](15) COLLATE Latin1_General_CI_AS NOT NULL, + [IsPrimary] [bit] NOT NULL, + CONSTRAINT [PK_PrivateIPAddresses] PRIMARY KEY CLUSTERED +( + [PrivateAddressID] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[Providers]( + [ProviderID] [int] NOT NULL, + [GroupID] [int] NOT NULL, + [ProviderName] [nvarchar](100) COLLATE Latin1_General_CI_AS NULL, + [DisplayName] [nvarchar](200) COLLATE Latin1_General_CI_AS NOT NULL, + [ProviderType] [nvarchar](400) COLLATE Latin1_General_CI_AS NULL, + [EditorControl] [nvarchar](100) COLLATE Latin1_General_CI_AS NULL, + [DisableAutoDiscovery] [bit] NULL, + CONSTRAINT [PK_ServiceTypes] PRIMARY KEY CLUSTERED +( + [ProviderID] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[Quotas]( + [QuotaID] [int] NOT NULL, + [GroupID] [int] NOT NULL, + [QuotaOrder] [int] NOT NULL, + [QuotaName] [nvarchar](50) COLLATE Latin1_General_CI_AS NOT NULL, + [QuotaDescription] [nvarchar](200) COLLATE Latin1_General_CI_AS NULL, + [QuotaTypeID] [int] NOT NULL, + [ServiceQuota] [bit] NULL, + [ItemTypeID] [int] NULL, + [HideQuota] [bit] NULL, + CONSTRAINT [PK_Quotas] PRIMARY KEY CLUSTERED +( + [QuotaID] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[ResourceGroupDnsRecords]( + [RecordID] [int] IDENTITY(1,1) NOT NULL, + [RecordOrder] [int] NOT NULL, + [GroupID] [int] NOT NULL, + [RecordType] [varchar](50) COLLATE Latin1_General_CI_AS NOT NULL, + [RecordName] [nvarchar](50) COLLATE Latin1_General_CI_AS NOT NULL, + [RecordData] [nvarchar](200) COLLATE Latin1_General_CI_AS NOT NULL, + [MXPriority] [int] NULL, + CONSTRAINT [PK_ResourceGroupDnsRecords] PRIMARY KEY CLUSTERED +( + [RecordID] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[ResourceGroups]( + [GroupID] [int] NOT NULL, + [GroupName] [nvarchar](100) COLLATE Latin1_General_CI_AS NOT NULL, + [GroupOrder] [int] NOT NULL, + [GroupController] [nvarchar](1000) COLLATE Latin1_General_CI_AS NULL, + [ShowGroup] [bit] NULL, + CONSTRAINT [PK_ResourceGroups] PRIMARY KEY CLUSTERED +( + [GroupID] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[Schedule]( + [ScheduleID] [int] IDENTITY(1,1) NOT NULL, + [TaskID] [nvarchar](100) COLLATE Latin1_General_CI_AS NOT NULL, + [PackageID] [int] NULL, + [ScheduleName] [nvarchar](100) COLLATE Latin1_General_CI_AS NULL, + [ScheduleTypeID] [nvarchar](50) COLLATE Latin1_General_CI_AS NULL, + [Interval] [int] NULL, + [FromTime] [datetime] NULL, + [ToTime] [datetime] NULL, + [StartTime] [datetime] NULL, + [LastRun] [datetime] NULL, + [NextRun] [datetime] NULL, + [Enabled] [bit] NOT NULL, + [PriorityID] [nvarchar](50) COLLATE Latin1_General_CI_AS NULL, + [HistoriesNumber] [int] NULL, + [MaxExecutionTime] [int] NULL, + [WeekMonthDay] [int] NULL, + CONSTRAINT [PK_Schedule] PRIMARY KEY CLUSTERED +( + [ScheduleID] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[ScheduleParameters]( + [ScheduleID] [int] NOT NULL, + [ParameterID] [nvarchar](100) COLLATE Latin1_General_CI_AS NOT NULL, + [ParameterValue] [nvarchar](1000) COLLATE Latin1_General_CI_AS NULL, + CONSTRAINT [PK_ScheduleParameters] PRIMARY KEY CLUSTERED +( + [ScheduleID] ASC, + [ParameterID] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[ScheduleTaskParameters]( + [TaskID] [nvarchar](100) COLLATE Latin1_General_CI_AS NOT NULL, + [ParameterID] [nvarchar](100) COLLATE Latin1_General_CI_AS NOT NULL, + [DataTypeID] [nvarchar](50) COLLATE Latin1_General_CI_AS NOT NULL, + [DefaultValue] [nvarchar](140) COLLATE Latin1_General_CI_AS NULL, + [ParameterOrder] [int] NOT NULL, + CONSTRAINT [PK_ScheduleTaskParameters] PRIMARY KEY CLUSTERED +( + [TaskID] ASC, + [ParameterID] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[ScheduleTasks]( + [TaskID] [nvarchar](100) COLLATE Latin1_General_CI_AS NOT NULL, + [TaskType] [nvarchar](500) COLLATE Latin1_General_CI_AS NOT NULL, + [RoleID] [int] NOT NULL, + CONSTRAINT [PK_ScheduleTasks] PRIMARY KEY CLUSTERED +( + [TaskID] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[ScheduleTaskViewConfiguration]( + [TaskID] [nvarchar](100) COLLATE Latin1_General_CI_AS NOT NULL, + [ConfigurationID] [nvarchar](100) COLLATE Latin1_General_CI_AS NOT NULL, + [Environment] [nvarchar](100) COLLATE Latin1_General_CI_AS NOT NULL, + [Description] [nvarchar](100) COLLATE Latin1_General_CI_AS NOT NULL, + CONSTRAINT [PK_ScheduleTaskViewConfiguration] PRIMARY KEY CLUSTERED +( + [ConfigurationID] ASC, + [TaskID] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[Servers]( + [ServerID] [int] IDENTITY(1,1) NOT NULL, + [ServerName] [nvarchar](100) COLLATE Latin1_General_CI_AS NOT NULL, + [ServerUrl] [nvarchar](100) COLLATE Latin1_General_CI_AS NULL, + [Password] [nvarchar](100) COLLATE Latin1_General_CI_AS NULL, + [Comments] [ntext] COLLATE Latin1_General_CI_AS NULL, + [VirtualServer] [bit] NOT NULL, + [InstantDomainAlias] [nvarchar](200) COLLATE Latin1_General_CI_AS NULL, + [PrimaryGroupID] [int] NULL, + [ADRootDomain] [nvarchar](200) COLLATE Latin1_General_CI_AS NULL, + [ADUsername] [nvarchar](100) COLLATE Latin1_General_CI_AS NULL, + [ADPassword] [nvarchar](100) COLLATE Latin1_General_CI_AS NULL, + [ADAuthenticationType] [varchar](50) COLLATE Latin1_General_CI_AS NULL, + [ADEnabled] [bit] NULL, + CONSTRAINT [PK_Servers] PRIMARY KEY CLUSTERED +( + [ServerID] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[ServiceDefaultProperties]( + [ProviderID] [int] NOT NULL, + [PropertyName] [nvarchar](50) COLLATE Latin1_General_CI_AS NOT NULL, + [PropertyValue] [nvarchar](1000) COLLATE Latin1_General_CI_AS NULL, + CONSTRAINT [PK_ServiceDefaultProperties_1] PRIMARY KEY CLUSTERED +( + [ProviderID] ASC, + [PropertyName] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[ServiceItemProperties]( + [ItemID] [int] NOT NULL, + [PropertyName] [nvarchar](50) COLLATE Latin1_General_CI_AS NOT NULL, + [PropertyValue] [nvarchar](3000) COLLATE Latin1_General_CI_AS NULL, + CONSTRAINT [PK_ServiceItemProperties] PRIMARY KEY CLUSTERED +( + [ItemID] ASC, + [PropertyName] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[ServiceItems]( + [ItemID] [int] IDENTITY(1,1) NOT NULL, + [PackageID] [int] NULL, + [ItemTypeID] [int] NULL, + [ServiceID] [int] NULL, + [ItemName] [nvarchar](500) COLLATE Latin1_General_CI_AS NULL, + [CreatedDate] [datetime] NULL, + CONSTRAINT [PK_ServiceItems] PRIMARY KEY CLUSTERED +( + [ItemID] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[ServiceItemTypes]( + [ItemTypeID] [int] NOT NULL, + [GroupID] [int] NULL, + [DisplayName] [nvarchar](50) COLLATE Latin1_General_CI_AS NULL, + [TypeName] [nvarchar](200) COLLATE Latin1_General_CI_AS NULL, + [TypeOrder] [int] NOT NULL, + [CalculateDiskspace] [bit] NULL, + [CalculateBandwidth] [bit] NULL, + [Suspendable] [bit] NULL, + [Disposable] [bit] NULL, + [Searchable] [bit] NULL, + [Importable] [bit] NOT NULL, + [Backupable] [bit] NOT NULL, + CONSTRAINT [PK_ServiceItemTypes] PRIMARY KEY CLUSTERED +( + [ItemTypeID] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[ServiceProperties]( + [ServiceID] [int] NOT NULL, + [PropertyName] [nvarchar](50) COLLATE Latin1_General_CI_AS NOT NULL, + [PropertyValue] [nvarchar](1000) COLLATE Latin1_General_CI_AS NULL, + CONSTRAINT [PK_ServiceProperties_1] PRIMARY KEY CLUSTERED +( + [ServiceID] ASC, + [PropertyName] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[Services]( + [ServiceID] [int] IDENTITY(1,1) NOT NULL, + [ServerID] [int] NOT NULL, + [ProviderID] [int] NOT NULL, + [ServiceName] [nvarchar](50) COLLATE Latin1_General_CI_AS NOT NULL, + [Comments] [ntext] COLLATE Latin1_General_CI_AS NULL, + [ServiceQuotaValue] [int] NULL, + [ClusterID] [int] NULL, + CONSTRAINT [PK_Services] PRIMARY KEY CLUSTERED +( + [ServiceID] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[SSLCertificates]( + [ID] [int] IDENTITY(1,1) NOT NULL, + [UserID] [int] NOT NULL, + [SiteID] [int] NOT NULL, + [FriendlyName] [nvarchar](255) COLLATE Latin1_General_CI_AS NULL, + [Hostname] [nvarchar](255) COLLATE Latin1_General_CI_AS NULL, + [DistinguishedName] [nvarchar](500) COLLATE Latin1_General_CI_AS NULL, + [CSR] [ntext] COLLATE Latin1_General_CI_AS NULL, + [CSRLength] [int] NULL, + [Certificate] [ntext] COLLATE Latin1_General_CI_AS NULL, + [Hash] [ntext] COLLATE Latin1_General_CI_AS NULL, + [Installed] [bit] NULL, + [IsRenewal] [bit] NULL, + [ValidFrom] [datetime] NULL, + [ExpiryDate] [datetime] NULL, + [SerialNumber] [nvarchar](250) COLLATE Latin1_General_CI_AS NULL, + [Pfx] [ntext] COLLATE Latin1_General_CI_AS NULL, + [PreviousId] [int] NULL +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[SystemSettings]( + [SettingsName] [nvarchar](50) COLLATE Latin1_General_CI_AS NOT NULL, + [PropertyName] [nvarchar](50) COLLATE Latin1_General_CI_AS NOT NULL, + [PropertyValue] [ntext] COLLATE Latin1_General_CI_AS NULL, + CONSTRAINT [PK_SystemSettings] PRIMARY KEY CLUSTERED +( + [SettingsName] ASC, + [PropertyName] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[Users]( + [UserID] [int] IDENTITY(1,1) NOT NULL, + [OwnerID] [int] NULL, + [RoleID] [int] NOT NULL, + [StatusID] [int] NOT NULL, + [IsDemo] [bit] NOT NULL, + [IsPeer] [bit] NOT NULL, + [Username] [nvarchar](50) COLLATE Latin1_General_CI_AS NULL, + [Password] [nvarchar](200) COLLATE Latin1_General_CI_AS NULL, + [FirstName] [nvarchar](50) COLLATE Latin1_General_CI_AS NULL, + [LastName] [nvarchar](50) COLLATE Latin1_General_CI_AS NULL, + [Email] [nvarchar](255) COLLATE Latin1_General_CI_AS NULL, + [Created] [datetime] NULL, + [Changed] [datetime] NULL, + [Comments] [ntext] COLLATE Latin1_General_CI_AS NULL, + [SecondaryEmail] [nvarchar](255) COLLATE Latin1_General_CI_AS NULL, + [Address] [nvarchar](200) COLLATE Latin1_General_CI_AS NULL, + [City] [nvarchar](50) COLLATE Latin1_General_CI_AS NULL, + [State] [nvarchar](50) COLLATE Latin1_General_CI_AS NULL, + [Country] [nvarchar](50) COLLATE Latin1_General_CI_AS NULL, + [Zip] [varchar](20) COLLATE Latin1_General_CI_AS NULL, + [PrimaryPhone] [varchar](30) COLLATE Latin1_General_CI_AS NULL, + [SecondaryPhone] [varchar](30) COLLATE Latin1_General_CI_AS NULL, + [Fax] [varchar](30) COLLATE Latin1_General_CI_AS NULL, + [InstantMessenger] [varchar](100) COLLATE Latin1_General_CI_AS NULL, + [HtmlMail] [bit] NULL, + [CompanyName] [nvarchar](100) COLLATE Latin1_General_CI_AS NULL, + [EcommerceEnabled] [bit] NULL, + [AdditionalParams] [nvarchar](max) COLLATE Latin1_General_CI_AS NULL, + [LoginStatusId] [int] NULL, + [FailedLogins] [int] NULL, + [SubscriberNumber] [nvarchar](32) COLLATE Latin1_General_CI_AS NULL, + CONSTRAINT [PK_Users] PRIMARY KEY CLUSTERED +( + [UserID] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[UserSettings]( + [UserID] [int] NOT NULL, + [SettingsName] [nvarchar](50) COLLATE Latin1_General_CI_AS NOT NULL, + [PropertyName] [nvarchar](50) COLLATE Latin1_General_CI_AS NOT NULL, + [PropertyValue] [ntext] COLLATE Latin1_General_CI_AS NULL, + CONSTRAINT [PK_UserSettings] PRIMARY KEY CLUSTERED +( + [UserID] ASC, + [SettingsName] ASC, + [PropertyName] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[Versions]( + [DatabaseVersion] [varchar](50) COLLATE Latin1_General_CI_AS NOT NULL, + [BuildDate] [datetime] NOT NULL, + CONSTRAINT [PK_Versions] PRIMARY KEY CLUSTERED +( + [DatabaseVersion] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[VirtualGroups]( + [VirtualGroupID] [int] IDENTITY(1,1) NOT NULL, + [ServerID] [int] NOT NULL, + [GroupID] [int] NOT NULL, + [DistributionType] [int] NULL, + [BindDistributionToPrimary] [bit] NULL, + CONSTRAINT [PK_VirtualGroups] PRIMARY KEY CLUSTERED +( + [VirtualGroupID] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[VirtualServices]( + [VirtualServiceID] [int] IDENTITY(1,1) NOT NULL, + [ServerID] [int] NOT NULL, + [ServiceID] [int] NOT NULL, + CONSTRAINT [PK_VirtualServices] PRIMARY KEY CLUSTERED +( + [VirtualServiceID] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + +CREATE VIEW [dbo].[ContractsInvoicesDetailed] +AS +SELECT dbo.ecInvoice.InvoiceID, dbo.ecInvoice.ContractID, dbo.ecContracts.ResellerID, dbo.ecContracts.CustomerID, ISNULL(dbo.Users.Username, +dbo.ecContracts.AccountName) AS Username, dbo.ecContracts.Status, dbo.ecInvoice.Created, dbo.ecInvoice.DueDate, dbo.ecInvoice.Total, dbo.ecInvoice.SubTotal, +dbo.ecInvoice.TaxAmount, dbo.ecInvoice.Currency, dbo.ecInvoice.InvoiceNumber, dbo.ecInvoice.TaxationID, dbo.ecCustomersPayments.PaymentID, +dbo.ecCustomersPayments.StatusID, dbo.ecCustomersPayments.TransactionID, (CASE WHEN dbo.ecCustomersPayments.PaymentID IS NOT NULL AND +dbo.ecCustomersPayments.StatusID = 1 THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END) AS Paid +FROM dbo.ecInvoice INNER JOIN +dbo.ecContracts ON dbo.ecInvoice.ContractID = dbo.ecContracts.ContractID LEFT OUTER JOIN +dbo.ecCustomersPayments ON dbo.ecInvoice.InvoiceID = dbo.ecCustomersPayments.InvoiceID LEFT OUTER JOIN +dbo.Users ON dbo.ecContracts.CustomerID = dbo.Users.UserID + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + + +CREATE VIEW [dbo].[ContractsServicesDetailed] +AS +SELECT dbo.ecService.ServiceID, ISNULL(dbo.Users.Username, dbo.ecContracts.AccountName) AS Username, dbo.ecContracts.CustomerID, dbo.ecService.ContractID, +dbo.ecContracts.ResellerID, dbo.ecService.ServiceName, dbo.ecService.TypeID, dbo.ecService.Status, dbo.ecService.Created, dbo.ecService.Modified, +dbo.ecService.ParentID +FROM dbo.ecContracts INNER JOIN +dbo.ecService ON dbo.ecContracts.ContractID = dbo.ecService.ContractID LEFT OUTER JOIN +dbo.Users ON dbo.ecContracts.CustomerID = dbo.Users.UserID + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + + + + + + + + + + + +CREATE VIEW [dbo].[ServiceHandlersResponsesDetailed] +AS +SELECT dbo.ecServiceHandlersResponses.ResponseID, dbo.ecServiceHandlersResponses.ServiceID, dbo.ecContracts.ResellerID, + dbo.ecServiceHandlersResponses.ContractID, dbo.ecServiceHandlersResponses.TextResponse, dbo.ecServiceHandlersResponses.Received, + dbo.ecServiceHandlersResponses.ErrorMessage, dbo.ecPaymentMethods.MethodName, dbo.ecServiceHandlersResponses.InvoiceID +FROM dbo.ecContracts RIGHT OUTER JOIN + dbo.ecPaymentMethods INNER JOIN + dbo.ecSupportedPlugins ON dbo.ecPaymentMethods.PluginID = dbo.ecSupportedPlugins.PluginID RIGHT OUTER JOIN + dbo.ecServiceHandlersResponses ON dbo.ecSupportedPlugins.UniqueID = dbo.ecServiceHandlersResponses.ServiceID ON + dbo.ecContracts.ContractID = dbo.ecServiceHandlersResponses.ContractID + + + + + + + + + + + + + + + + + + + + + + + + + + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + + +CREATE VIEW [dbo].[UsersDetailed] +AS +SELECT U.UserID, U.RoleID, U.StatusID, U.LoginStatusId, U.SubscriberNumber, U.FailedLogins, U.OwnerID, U.Created, U.Changed, U.IsDemo, U.Comments, U.IsPeer, U.Username, U.FirstName, U.LastName, U.Email, + U.CompanyName, U.FirstName + ' ' + U.LastName AS FullName, UP.Username AS OwnerUsername, UP.FirstName AS OwnerFirstName, + UP.LastName AS OwnerLastName, UP.RoleID AS OwnerRoleID, UP.FirstName + ' ' + UP.LastName AS OwnerFullName, UP.Email AS OwnerEmail, UP.RoleID AS Expr1, + (SELECT COUNT(PackageID) AS Expr1 + FROM dbo.Packages AS P + WHERE (UserID = U.UserID)) AS PackagesNumber, U.EcommerceEnabled +FROM dbo.Users AS U LEFT OUTER JOIN + dbo.Users AS UP ON U.OwnerID = UP.UserID + +GO +INSERT [dbo].[AuditLogSources] ([SourceName]) VALUES (N'APP_INSTALLER') +GO +INSERT [dbo].[AuditLogSources] ([SourceName]) VALUES (N'BACKUP') +GO +INSERT [dbo].[AuditLogSources] ([SourceName]) VALUES (N'DNS_ZONE') +GO +INSERT [dbo].[AuditLogSources] ([SourceName]) VALUES (N'DOMAIN') +GO +INSERT [dbo].[AuditLogSources] ([SourceName]) VALUES (N'EXCHANGE') +GO +INSERT [dbo].[AuditLogSources] ([SourceName]) VALUES (N'FILES') +GO +INSERT [dbo].[AuditLogSources] ([SourceName]) VALUES (N'FTP_ACCOUNT') +GO +INSERT [dbo].[AuditLogSources] ([SourceName]) VALUES (N'GLOBAL_DNS') +GO +INSERT [dbo].[AuditLogSources] ([SourceName]) VALUES (N'IMPORT') +GO +INSERT [dbo].[AuditLogSources] ([SourceName]) VALUES (N'IP_ADDRESS') +GO +INSERT [dbo].[AuditLogSources] ([SourceName]) VALUES (N'MAIL_ACCOUNT') +GO +INSERT [dbo].[AuditLogSources] ([SourceName]) VALUES (N'MAIL_DOMAIN') +GO +INSERT [dbo].[AuditLogSources] ([SourceName]) VALUES (N'MAIL_FORWARDING') +GO +INSERT [dbo].[AuditLogSources] ([SourceName]) VALUES (N'MAIL_GROUP') +GO +INSERT [dbo].[AuditLogSources] ([SourceName]) VALUES (N'MAIL_LIST') +GO +INSERT [dbo].[AuditLogSources] ([SourceName]) VALUES (N'ODBC_DSN') +GO +INSERT [dbo].[AuditLogSources] ([SourceName]) VALUES (N'SCHEDULER') +GO +INSERT [dbo].[AuditLogSources] ([SourceName]) VALUES (N'SERVER') +GO +INSERT [dbo].[AuditLogSources] ([SourceName]) VALUES (N'SHAREPOINT') +GO +INSERT [dbo].[AuditLogSources] ([SourceName]) VALUES (N'SPACE') +GO +INSERT [dbo].[AuditLogSources] ([SourceName]) VALUES (N'SQL_DATABASE') +GO +INSERT [dbo].[AuditLogSources] ([SourceName]) VALUES (N'SQL_USER') +GO +INSERT [dbo].[AuditLogSources] ([SourceName]) VALUES (N'STATS_SITE') +GO +INSERT [dbo].[AuditLogSources] ([SourceName]) VALUES (N'USER') +GO +INSERT [dbo].[AuditLogSources] ([SourceName]) VALUES (N'VIRTUAL_SERVER') +GO +INSERT [dbo].[AuditLogSources] ([SourceName]) VALUES (N'VPS') +GO +INSERT [dbo].[AuditLogSources] ([SourceName]) VALUES (N'WEB_SITE') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'APP_INSTALLER', N'INSTALL_APPLICATION', N'Install application') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'BACKUP', N'BACKUP', N'Backup') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'BACKUP', N'RESTORE', N'Restore') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'DNS_ZONE', N'ADD_RECORD', N'Add record') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'DNS_ZONE', N'DELETE_RECORD', N'Delete record') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'DNS_ZONE', N'UPDATE_RECORD', N'Update record') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'DOMAIN', N'ADD', N'Add') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'DOMAIN', N'DELETE', N'Delete') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'DOMAIN', N'UPDATE', N'Update') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'EXCHANGE', N'ADD_DISTR_LIST_ADDRESS', N'Add distribution list e-mail address') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'EXCHANGE', N'ADD_DOMAIN', N'Add organization domain') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'EXCHANGE', N'ADD_MAILBOX_ADDRESS', N'Add mailbox e-mail address') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'EXCHANGE', N'ADD_PUBLIC_FOLDER_ADDRESS', N'Add public folder e-mail address') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'EXCHANGE', N'CALCULATE_DISKSPACE', N'Calculate organization disk space') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'EXCHANGE', N'CREATE_CONTACT', N'Create contact') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'EXCHANGE', N'CREATE_DISTR_LIST', N'Create distribution list') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'EXCHANGE', N'CREATE_MAILBOX', N'Create mailbox') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'EXCHANGE', N'CREATE_ORG', N'Create organization') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'EXCHANGE', N'CREATE_PUBLIC_FOLDER', N'Create public folder') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'EXCHANGE', N'DELETE_CONTACT', N'Delete contact') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'EXCHANGE', N'DELETE_DISTR_LIST', N'Delete distribution list') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'EXCHANGE', N'DELETE_DISTR_LIST_ADDRESSES', N'Delete distribution list e-mail addresses') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'EXCHANGE', N'DELETE_DOMAIN', N'Delete organization domain') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'EXCHANGE', N'DELETE_MAILBOX', N'Delete mailbox') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'EXCHANGE', N'DELETE_MAILBOX_ADDRESSES', N'Delete mailbox e-mail addresses') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'EXCHANGE', N'DELETE_ORG', N'Delete organization') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'EXCHANGE', N'DELETE_PUBLIC_FOLDER', N'Delete public folder') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'EXCHANGE', N'DELETE_PUBLIC_FOLDER_ADDRESSES', N'Delete public folder e-mail addresses') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'EXCHANGE', N'DISABLE_MAIL_PUBLIC_FOLDER', N'Disable mail public folder') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'EXCHANGE', N'ENABLE_MAIL_PUBLIC_FOLDER', N'Enable mail public folder') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'EXCHANGE', N'GET_CONTACT_GENERAL', N'Get contact general settings') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'EXCHANGE', N'GET_CONTACT_MAILFLOW', N'Get contact mail flow settings') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'EXCHANGE', N'GET_DISTR_LIST_ADDRESSES', N'Get distribution list e-mail addresses') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'EXCHANGE', N'GET_DISTR_LIST_GENERAL', N'Get distribution list general settings') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'EXCHANGE', N'GET_DISTR_LIST_MAILFLOW', N'Get distribution list mail flow settings') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'EXCHANGE', N'GET_FOLDERS_STATS', N'Get organization public folder statistics') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'EXCHANGE', N'GET_MAILBOX_ADDRESSES', N'Get mailbox e-mail addresses') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'EXCHANGE', N'GET_MAILBOX_ADVANCED', N'Get mailbox advanced settings') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'EXCHANGE', N'GET_MAILBOX_GENERAL', N'Get mailbox general settings') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'EXCHANGE', N'GET_MAILBOX_MAILFLOW', N'Get mailbox mail flow settings') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'EXCHANGE', N'GET_MAILBOXES_STATS', N'Get organization mailboxes statistics') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'EXCHANGE', N'GET_ORG_LIMITS', N'Get organization storage limits') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'EXCHANGE', N'GET_ORG_STATS', N'Get organization statistics') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'EXCHANGE', N'GET_PUBLIC_FOLDER_ADDRESSES', N'Get public folder e-mail addresses') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'EXCHANGE', N'GET_PUBLIC_FOLDER_GENERAL', N'Get public folder general settings') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'EXCHANGE', N'GET_PUBLIC_FOLDER_MAILFLOW', N'Get public folder mail flow settings') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'EXCHANGE', N'SET_ORG_LIMITS', N'Update organization storage limits') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'EXCHANGE', N'SET_PRIMARY_DISTR_LIST_ADDRESS', N'Set distribution list primary e-mail address') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'EXCHANGE', N'SET_PRIMARY_MAILBOX_ADDRESS', N'Set mailbox primary e-mail address') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'EXCHANGE', N'SET_PRIMARY_PUBLIC_FOLDER_ADDRESS', N'Set public folder primary e-mail address') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'EXCHANGE', N'UPDATE_CONTACT_GENERAL', N'Update contact general settings') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'EXCHANGE', N'UPDATE_CONTACT_MAILFLOW', N'Update contact mail flow settings') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'EXCHANGE', N'UPDATE_DISTR_LIST_GENERAL', N'Update distribution list general settings') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'EXCHANGE', N'UPDATE_DISTR_LIST_MAILFLOW', N'Update distribution list mail flow settings') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'EXCHANGE', N'UPDATE_MAILBOX_ADVANCED', N'Update mailbox advanced settings') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'EXCHANGE', N'UPDATE_MAILBOX_GENERAL', N'Update mailbox general settings') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'EXCHANGE', N'UPDATE_MAILBOX_MAILFLOW', N'Update mailbox mail flow settings') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'EXCHANGE', N'UPDATE_PUBLIC_FOLDER_GENERAL', N'Update public folder general settings') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'EXCHANGE', N'UPDATE_PUBLIC_FOLDER_MAILFLOW', N'Update public folder mail flow settings') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'FILES', N'COPY_FILES', N'Copy files') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'FILES', N'CREATE_ACCESS_DATABASE', N'Create MS Access database') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'FILES', N'CREATE_FILE', N'Create file') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'FILES', N'CREATE_FOLDER', N'Create folder') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'FILES', N'DELETE_FILES', N'Delete files') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'FILES', N'MOVE_FILES', N'Move files') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'FILES', N'RENAME_FILE', N'Rename file') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'FILES', N'SET_PERMISSIONS', NULL) +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'FILES', N'UNZIP_FILES', N'Unzip files') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'FILES', N'UPDATE_BINARY_CONTENT', N'Update file binary content') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'FILES', N'ZIP_FILES', N'Zip files') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'FTP_ACCOUNT', N'ADD', N'Add') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'FTP_ACCOUNT', N'DELETE', N'Delete') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'FTP_ACCOUNT', N'UPDATE', N'Update') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'GLOBAL_DNS', N'ADD', N'Add') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'GLOBAL_DNS', N'DELETE', N'Delete') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'GLOBAL_DNS', N'UPDATE', N'Update') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'IMPORT', N'IMPORT', N'Import') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'IP_ADDRESS', N'ADD', N'Add') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'IP_ADDRESS', N'ADD_RANGE', N'Add range') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'IP_ADDRESS', N'ALLOCATE_PACKAGE_IP', N'Allocate package IP addresses') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'IP_ADDRESS', N'DEALLOCATE_PACKAGE_IP', N'Deallocate package IP addresses') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'IP_ADDRESS', N'DELETE', N'Delete') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'IP_ADDRESS', N'DELETE_RANGE', N'Delete IP Addresses') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'IP_ADDRESS', N'UPDATE', N'Update') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'IP_ADDRESS', N'UPDATE_RANGE', N'Update IP Addresses') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'MAIL_ACCOUNT', N'ADD', N'Add') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'MAIL_ACCOUNT', N'DELETE', N'Delete') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'MAIL_ACCOUNT', N'UPDATE', N'Update') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'MAIL_DOMAIN', N'ADD', N'Add') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'MAIL_DOMAIN', N'ADD_POINTER', N'Add pointer') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'MAIL_DOMAIN', N'DELETE', N'Delete') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'MAIL_DOMAIN', N'DELETE_POINTER', N'Update pointer') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'MAIL_DOMAIN', N'UPDATE', N'Update') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'MAIL_FORWARDING', N'ADD', N'Add') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'MAIL_FORWARDING', N'DELETE', N'Delete') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'MAIL_FORWARDING', N'UPDATE', N'Update') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'MAIL_GROUP', N'ADD', N'Add') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'MAIL_GROUP', N'DELETE', N'Delete') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'MAIL_GROUP', N'UPDATE', N'Update') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'MAIL_LIST', N'ADD', N'Add') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'MAIL_LIST', N'DELETE', N'Delete') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'MAIL_LIST', N'UPDATE', N'Update') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'ODBC_DSN', N'ADD', N'Add') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'ODBC_DSN', N'DELETE', N'Delete') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'ODBC_DSN', N'UPDATE', N'Update') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'SCHEDULER', N'RUN_SCHEDULE', NULL) +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'SERVER', N'ADD', N'Add') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'SERVER', N'ADD_SERVICE', N'Add service') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'SERVER', N'CHANGE_WINDOWS_SERVICE_STATUS', N'Change Windows service status') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'SERVER', N'CHECK_AVAILABILITY', N'Check availability') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'SERVER', N'CLEAR_EVENT_LOG', N'Clear Windows event log') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'SERVER', N'DELETE', N'Delete') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'SERVER', N'DELETE_SERVICE', N'Delete service') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'SERVER', N'REBOOT', N'Reboot') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'SERVER', N'RESET_TERMINAL_SESSION', N'Reset terminal session') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'SERVER', N'TERMINATE_SYSTEM_PROCESS', N'Terminate system process') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'SERVER', N'UPDATE', N'Update') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'SERVER', N'UPDATE_AD_PASSWORD', N'Update active directory password') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'SERVER', N'UPDATE_PASSWORD', N'Update access password') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'SERVER', N'UPDATE_SERVICE', N'Update service') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'SHAREPOINT', N'ADD_GROUP', N'Add group') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'SHAREPOINT', N'ADD_SITE', N'Add site') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'SHAREPOINT', N'ADD_USER', N'Add user') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'SHAREPOINT', N'BACKUP_SITE', N'Backup site') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'SHAREPOINT', N'DELETE_GROUP', N'Delete group') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'SHAREPOINT', N'DELETE_SITE', N'Delete site') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'SHAREPOINT', N'DELETE_USER', N'Delete user') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'SHAREPOINT', N'INSTALL_WEBPARTS', N'Install Web Parts package') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'SHAREPOINT', N'RESTORE_SITE', N'Restore site') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'SHAREPOINT', N'UNINSTALL_WEBPARTS', N'Uninstall Web Parts package') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'SHAREPOINT', N'UPDATE_GROUP', N'Update group') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'SHAREPOINT', N'UPDATE_USER', N'Update user') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'SPACE', N'CALCULATE_DISKSPACE', N'Calculate disk space') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'SPACE', N'CHANGE_ITEMS_STATUS', N'Change hosting items status') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'SPACE', N'CHANGE_STATUS', N'Change hostng space status') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'SPACE', N'DELETE', N'Delete hosting space') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'SPACE', N'DELETE_ITEMS', N'Delete hosting items') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'SQL_DATABASE', N'ADD', N'Add') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'SQL_DATABASE', N'BACKUP', N'Backup') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'SQL_DATABASE', N'DELETE', N'Delete') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'SQL_DATABASE', N'RESTORE', N'Restore') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'SQL_DATABASE', N'TRUNCATE', N'Truncate') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'SQL_DATABASE', N'UPDATE', N'Update') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'SQL_USER', N'ADD', N'Add') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'SQL_USER', N'DELETE', N'Delete') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'SQL_USER', N'UPDATE', N'Update') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'STATS_SITE', N'ADD', N'Add statistics site') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'STATS_SITE', N'DELETE', N'Delete statistics site') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'STATS_SITE', N'UPDATE', N'Update statistics site') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'USER', N'ADD', N'Add') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'USER', N'AUTHENTICATE', N'Authenticate') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'USER', N'CHANGE_PASSWORD', N'Change password') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'USER', N'CHANGE_PASSWORD_BY_USERNAME_PASSWORD', N'Change password by username/password') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'USER', N'CHANGE_STATUS', N'Change status') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'USER', N'DELETE', N'Delete') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'USER', N'GET_BY_USERNAME_PASSWORD', N'Get by username/password') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'USER', N'SEND_REMINDER', N'Send password reminder') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'USER', N'UPDATE', N'Update') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'USER', N'UPDATE_SETTINGS', N'Update settings') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'VIRTUAL_SERVER', N'ADD_SERVICES', N'Add services') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'VIRTUAL_SERVER', N'DELETE_SERVICES', N'Delete services') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'VPS', N'ADD_EXTERNAL_IP', N'Add external IP') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'VPS', N'ADD_PRIVATE_IP', N'Add private IP') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'VPS', N'APPLY_SNAPSHOT', N'Apply VPS snapshot') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'VPS', N'CANCEL_JOB', N'Cancel Job') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'VPS', N'CHANGE_ADMIN_PASSWORD', N'Change administrator password') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'VPS', N'CHANGE_STATE', N'Change VPS state') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'VPS', N'CREATE', N'Create VPS') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'VPS', N'DELETE', N'Delete VPS') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'VPS', N'DELETE_EXTERNAL_IP', N'Delete external IP') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'VPS', N'DELETE_PRIVATE_IP', N'Delete private IP') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'VPS', N'DELETE_SNAPSHOT', N'Delete VPS snapshot') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'VPS', N'DELETE_SNAPSHOT_SUBTREE', N'Delete VPS snapshot subtree') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'VPS', N'EJECT_DVD_DISK', N'Eject DVD disk') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'VPS', N'INSERT_DVD_DISK', N'Insert DVD disk') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'VPS', N'REINSTALL', N'Re-install VPS') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'VPS', N'RENAME_SNAPSHOT', N'Rename VPS snapshot') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'VPS', N'SEND_SUMMARY_LETTER', N'Send VPS summary letter') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'VPS', N'SET_PRIMARY_EXTERNAL_IP', N'Set primary external IP') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'VPS', N'SET_PRIMARY_PRIVATE_IP', N'Set primary private IP') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'VPS', N'TAKE_SNAPSHOT', N'Take VPS snapshot') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'VPS', N'UPDATE_CONFIGURATION', N'Update VPS configuration') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'VPS', N'UPDATE_HOSTNAME', N'Update host name') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'VPS', N'UPDATE_IP', N'Update IP Address') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'VPS', N'UPDATE_PERMISSIONS', N'Update VPS permissions') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'VPS', N'UPDATE_VDC_PERMISSIONS', N'Update space permissions') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'WEB_SITE', N'ADD', N'Add') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'WEB_SITE', N'ADD_POINTER', N'Add domain pointer') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'WEB_SITE', N'ADD_SSL_FOLDER', N'Add shared SSL folder') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'WEB_SITE', N'ADD_VDIR', N'Add virtual directory') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'WEB_SITE', N'CHANGE_FP_PASSWORD', N'Change FrontPage account password') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'WEB_SITE', N'CHANGE_STATE', N'Change state') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'WEB_SITE', N'DELETE', N'Delete') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'WEB_SITE', N'DELETE_POINTER', N'Delete domain pointer') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'WEB_SITE', N'DELETE_SECURED_FOLDER', N'Delete secured folder') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'WEB_SITE', N'DELETE_SECURED_GROUP', N'Delete secured group') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'WEB_SITE', N'DELETE_SECURED_USER', N'Delete secured user') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'WEB_SITE', N'DELETE_SSL_FOLDER', N'Delete shared SSL folder') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'WEB_SITE', N'DELETE_VDIR', N'Delete virtual directory') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'WEB_SITE', N'INSTALL_FP', N'Install FrontPage Extensions') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'WEB_SITE', N'INSTALL_SECURED_FOLDERS', N'Install secured folders') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'WEB_SITE', N'UNINSTALL_FP', N'Uninstall FrontPage Extensions') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'WEB_SITE', N'UNINSTALL_SECURED_FOLDERS', N'Uninstall secured folders') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'WEB_SITE', N'UPDATE', N'Update') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'WEB_SITE', N'UPDATE_SECURED_FOLDER', N'Add/update secured folder') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'WEB_SITE', N'UPDATE_SECURED_GROUP', N'Add/update secured group') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'WEB_SITE', N'UPDATE_SECURED_USER', N'Add/update secured user') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'WEB_SITE', N'UPDATE_SSL_FOLDER', N'Update shared SSL folder') +GO +INSERT [dbo].[AuditLogTasks] ([SourceName], [TaskName], [TaskDescription]) VALUES (N'WEB_SITE', N'UPDATE_VDIR', N'Update virtual directory') +GO +SET IDENTITY_INSERT [dbo].[ecProductType] ON + +GO +INSERT [dbo].[ecProductType] ([TypeID], [TypeName], [ProvisioningController], [Created], [NativeItemType], [ServiceItemType]) VALUES (1, N'Hosting Plan', N'WebsitePanel.Ecommerce.EnterpriseServer.HostingPackageController,WebsitePanel.EnterpriseServer', CAST(0x0000993E010F2F0C AS DateTime), N'WebsitePanel.Ecommerce.EnterpriseServer.HostingPlan, WebsitePanel.EnterpriseServer', N'WebsitePanel.Ecommerce.EnterpriseServer.HostingPackageSvc, WebsitePanel.EnterpriseServer') +GO +INSERT [dbo].[ecProductType] ([TypeID], [TypeName], [ProvisioningController], [Created], [NativeItemType], [ServiceItemType]) VALUES (2, N'Hosting Add-On', N'WebsitePanel.Ecommerce.EnterpriseServer.HostingAddonController,WebsitePanel.EnterpriseServer', CAST(0x0000993E010F2F0C AS DateTime), N'WebsitePanel.Ecommerce.EnterpriseServer.HostingAddon, WebsitePanel.EnterpriseServer', N'WebsitePanel.Ecommerce.EnterpriseServer.HostingAddonSvc, WebsitePanel.EnterpriseServer') +GO +INSERT [dbo].[ecProductType] ([TypeID], [TypeName], [ProvisioningController], [Created], [NativeItemType], [ServiceItemType]) VALUES (3, N'Domain Name', N'WebsitePanel.Ecommerce.EnterpriseServer.DomainNameController,WebsitePanel.EnterpriseServer', CAST(0x0000993E010F2F0C AS DateTime), N'WebsitePanel.Ecommerce.EnterpriseServer.DomainName, WebsitePanel.EnterpriseServer', N'WebsitePanel.Ecommerce.EnterpriseServer.DomainNameSvc, WebsitePanel.EnterpriseServer') +GO +SET IDENTITY_INSERT [dbo].[ecProductType] OFF +GO +INSERT [dbo].[ecStoreDefaultSettings] ([SettingsName], [PropertyName], [PropertyValue]) VALUES (N'ActivateServicesTemplate', N'CC', N'info@acmehosting.com') +GO +INSERT [dbo].[ecStoreDefaultSettings] ([SettingsName], [PropertyName], [PropertyValue]) VALUES (N'ActivateServicesTemplate', N'From', N'support@acmehosting.com') +GO +INSERT [dbo].[ecStoreDefaultSettings] ([SettingsName], [PropertyName], [PropertyValue]) VALUES (N'ActivateServicesTemplate', N'HtmlBody', N' + + + Activated Service Summary Information + + + +
+ + + +
+ Activated Service Information +
+ +

Hello #customer["FirstName"]#,

+ +

"#service.ServiceName#" service has been activated under your user account +and below is the summary information.

+ +

Service Overview

+ + + + + + + + + + + + + + + + + + +
Service Name:#service.ServiceName#
Created:#service.Created#
Setup fee:#service.Currency# #format(service.SetupFee, "0.00")#
Recurring fee:#service.Currency# #format(service.RecurringFee, "0.00")#
+ +

+If you have any questions regarding your hosting account, feel free to contact our sales department at any time. +

+ +

+Best regards,
+ACME Hosting Inc.
+Web Site: www.acmehosting.com
+E-Mail: support@acmehosting.com

+ +
+ +') +GO +INSERT [dbo].[ecStoreDefaultSettings] ([SettingsName], [PropertyName], [PropertyValue]) VALUES (N'ActivateServicesTemplate', N'Subject', N'Activate Service Notification') +GO +INSERT [dbo].[ecStoreDefaultSettings] ([SettingsName], [PropertyName], [PropertyValue]) VALUES (N'ActivateServicesTemplate', N'TextBody', N' +================================ + Activated Service Information +================================ + +Hello #Customer["FirstName"]#, + +"#service.ServiceName#" service has been activated under your user account +and below is the summary information. + +Service Overview +============= +Service Name: #service.ServiceName# +Created: #service.Created# +Setup fee: #service.Currency# #format(service.SetupFee, "0.00")# +Recurring fee: #service.Currency# #format(service.RecurringFee, "0.00")# + +If you have any questions regarding your hosting account, feel free to contact our support department at any time. + +Best regards, +ACME Hosting Inc. +Web Site: http://www.acmehosting.com +E-Mail: support@acmehosting.com') +GO +INSERT [dbo].[ecStoreDefaultSettings] ([SettingsName], [PropertyName], [PropertyValue]) VALUES (N'CancelServicesTemplate', N'CC', N'sales@acmehosting.com') +GO +INSERT [dbo].[ecStoreDefaultSettings] ([SettingsName], [PropertyName], [PropertyValue]) VALUES (N'CancelServicesTemplate', N'From', N'support@acmehosting.com') +GO +INSERT [dbo].[ecStoreDefaultSettings] ([SettingsName], [PropertyName], [PropertyValue]) VALUES (N'CancelServicesTemplate', N'HtmlBody', N' + + + Cancel Service Summary Information + + + +
+ + + +
+ Cancelled Service Information +
+ +

Hello #customer["FirstName"]#,

+ +

"#service.ServiceName#" service has been cancelled under your user account +and below is the summary information.

+

Service Overview

+ + + + + + + + + + +
Service Name:#service.ServiceName#
Created:#service.Created#
+ +

+If you have any questions regarding your hosting account, feel free to contact our sales department at any time. +

+ +

+Best regards,
+ACME Hosting Inc.
+Web Site: www.acmehosting.com
+E-Mail: support@acmehosting.com

+ +
+ +') +GO +INSERT [dbo].[ecStoreDefaultSettings] ([SettingsName], [PropertyName], [PropertyValue]) VALUES (N'CancelServicesTemplate', N'Subject', N'Cancel Service Notificaton') +GO +INSERT [dbo].[ecStoreDefaultSettings] ([SettingsName], [PropertyName], [PropertyValue]) VALUES (N'CancelServicesTemplate', N'TextBody', N' +================================ + Cancelled Service Information +================================ + +Hello #Customer["FirstName"]#, + +"#service.ServiceName#" service has been cancelled under your user account +and below is the summary information. + +Service Overview +============= +Service Name: #service.ServiceName# +Created: #service.Created# + +If you have any questions regarding your hosting account, feel free to contact our support department at any time. + +Best regards, +ACME Hosting Inc. +Web Site: http://www.acmehosting.com +E-Mail: support@acmehosting.com') +GO +INSERT [dbo].[ecStoreDefaultSettings] ([SettingsName], [PropertyName], [PropertyValue]) VALUES (N'EmitInvoiceTemplate', N'CC', N'info@acmehosting.com') +GO +INSERT [dbo].[ecStoreDefaultSettings] ([SettingsName], [PropertyName], [PropertyValue]) VALUES (N'EmitInvoiceTemplate', N'From', N'sales@acmehosting.com') +GO +INSERT [dbo].[ecStoreDefaultSettings] ([SettingsName], [PropertyName], [PropertyValue]) VALUES (N'EmitInvoiceTemplate', N'HtmlBody', N' +
+ + + +
+ Invoice Summary Information +
+ +

Hello #Customer["FirstName"]#,

+ +

We''ve created this invoice for services you ordered. You can find this invoice details under your user account +and below is the summary information.

+ + + +

You may use the following link to pay for invoice later #ExtraArgs["InvoiceDirectURL"]#.

+
+
+ +

Invoice Overview

+ + + + + + + + + + + + + + + + + +
Invoice ##:#Invoice.InvoiceId##Invoice.InvoiceNumber#
Terms:Due Upon Receipt
Invoice Date:#Invoice.Created.ToShortDateString()#
+

Invoice Items

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
DescriptionTypeQtyUnit PriceTotal
#Line.ItemName##Line.TypeName##Line.Quantity##Invoice.Currency# #Line.UnitPrice.ToString("C")##Invoice.Currency# #Line.Total.ToString("C")#
Sub Total #Invoice.Currency# #Invoice.SubTotal.ToString("C")#
Taxes #format(0.00, "#.##")#%#Invoice.Currency# #format(0.00, "C")#
#Tax.Description##Invoice.Currency# #Tax.Amount.ToString("C")#
#Tax.Description# #Tax.Amount.ToString("#.##")#%#Invoice.Currency# #Invoice.TaxAmount.ToString("C")#
#Tax.Description# #Tax.Amount.ToString("#.##")#%#Invoice.Currency# #Invoice.TaxAmount.ToString("C")#
Total #Invoice.Currency# #Invoice.Total.ToString("C")#
+

+If you have any questions regarding your hosting account or this invoice, feel free to contact our sales department at any time. +

+ +

Some notes regarding invoice or how to apply your enquiries...

+ +

+Best regards,
+ACME Hosting Inc.
+Web Site: www.acmehosting.com
+E-Mail: support@acmehosting.com

+ +
+ + + + +  (#Service.PeriodLength# #Service.BillingPeriod#) + +') +GO +INSERT [dbo].[ecStoreDefaultSettings] ([SettingsName], [PropertyName], [PropertyValue]) VALUES (N'EmitInvoiceTemplate', N'Subject', N'Invoice Summary Information') +GO +INSERT [dbo].[ecStoreDefaultSettings] ([SettingsName], [PropertyName], [PropertyValue]) VALUES (N'EmitInvoiceTemplate', N'TextBody', N'================================ + Invoice Summary Information +================================ + +Hello #Customer["FirstName"]#, + +We''ve created this invoice for services you ordered. You can find this invoice details under your user account +and below is the summary information. + + + +You may copy and paste the following link to the browser in order to pay for invoice later #ExtraArgs["InvoiceDirectURL"]#. + + + +Invoice Overview +============= +Invoice ##: #Invoice.InvoiceId##Invoice.InvoiceNumber# +Terms: Due Upon Receipt +Invoice Date: #Invoice.Created.ToShortDateString()# +Invoice SubTotal: #Invoice.Currency# #Invoice.SubTotal.ToString("C")# + +Taxes #format(0.00, "#.##")#%: #Invoice.Currency# #format(0.00, "C")# + +#Tax.Description#: #Invoice.Currency# #Tax.Amount.ToString("C")# + +#Tax.Description# #Tax.Amount.ToString("#.##")#%: #Invoice.Currency# #Invoice.TaxAmount.ToString("C")# + +#Tax.Description# #Tax.Amount.ToString("#.##")#%: #Invoice.Currency# #Invoice.TaxAmount.ToString("C")# + +Invoice Total: #Invoice.Currency# #Invoice.Total.ToString("C")# + + +Invoice Items +============= + +#Line.ItemName# + Type: #Line.TypeName# + Quantity: #Line.Quantity# + Unit Price: #Invoice.Currency# #Line.UnitPrice.ToString("C")# + Total: #Invoice.Currency# #Line.Total.ToString("C")# + + + +If you have any questions regarding your hosting account, feel free to contact our sales department at any time. + +Some notes regarding invoice or how to apply your enquiries... + + +Best regards, +ACME Hosting Inc. +Web Site: http://www.acmehosting.com +E-Mail: support@acmehosting.com + + + + + (#Service.PeriodLength# #Service.BillingPeriod#) + +') +GO +INSERT [dbo].[ecStoreDefaultSettings] ([SettingsName], [PropertyName], [PropertyValue]) VALUES (N'PaymentReceivedTemplate', N'CC', N'info@acmehosting.com') +GO +INSERT [dbo].[ecStoreDefaultSettings] ([SettingsName], [PropertyName], [PropertyValue]) VALUES (N'PaymentReceivedTemplate', N'From', N'sales@acmehosting.com') +GO +INSERT [dbo].[ecStoreDefaultSettings] ([SettingsName], [PropertyName], [PropertyValue]) VALUES (N'PaymentReceivedTemplate', N'HtmlBody', N' + + Received Payment Summary Information + + + +
+ +
+ Received Payment Information +
+

+ Hello #Customer["FirstName"]#,

+

+ We''ve received your payment successfully. You can find this payment details under + your user account and below is the summary information.

+

+ Payment Overview

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Payment ##: + + #payment.paymentid# +
+ Invoice ##: + + #payment.invoiceid# +
+ Transaction ID ##: + + #payment.transactionid# +
+ Created: + + #payment.created# +
+ Payment Method: + + #payment.methodname# +
+ Payment Status: + + #payment.status.ToString()# +
+ Payment Total: + + #payment.currency# #format(payment.total, "C")# +
+

+ If you have any questions regarding your hosting account, feel free to contact our + sales department at any time. +

+

+ Best regards,
+ ACME Hosting Inc.
+ Web Site: www.acmehosting.com
+ E-Mail: support@acmehosting.com

+
+ + +') +GO +INSERT [dbo].[ecStoreDefaultSettings] ([SettingsName], [PropertyName], [PropertyValue]) VALUES (N'PaymentReceivedTemplate', N'Subject', N'Payment Received Notification') +GO +INSERT [dbo].[ecStoreDefaultSettings] ([SettingsName], [PropertyName], [PropertyValue]) VALUES (N'PaymentReceivedTemplate', N'TextBody', N'================================ Received Payment Information ================================ +Hello #Customer["FirstName"]#, + +We''ve received your payment successfully. You can find this payment details under your user account and below is the summary information. + +Payment Overview +============= +Payment ##: #payment.paymentid# +Invoice ##: #payment.invoiceid# +Transaction ID ##: #payment.transactionid# +Created: #payment.created# +Payment Method: #payment.methodname# +Payment Status: #payment.status.ToString()# +Payment Total: #payment.currency# #format(payment.total, "C")# + +If you have any questions regarding your hosting account, feel free to contact our sales department at any time. + +Best regards, +ACME Hosting Inc. +Web Site: http://www.acmehosting.com +E-Mail: support@acmehosting.com') +GO +INSERT [dbo].[ecStoreDefaultSettings] ([SettingsName], [PropertyName], [PropertyValue]) VALUES (N'SignupSettings', N'NewbieStatus', N'4') +GO +INSERT [dbo].[ecStoreDefaultSettings] ([SettingsName], [PropertyName], [PropertyValue]) VALUES (N'SignupSettings', N'RegDomainMode', N'OPT_DOM_AVAIL') +GO +INSERT [dbo].[ecStoreDefaultSettings] ([SettingsName], [PropertyName], [PropertyValue]) VALUES (N'SignupSettings', N'SendRegistrationEmail', N'true') +GO +INSERT [dbo].[ecStoreDefaultSettings] ([SettingsName], [PropertyName], [PropertyValue]) VALUES (N'SuspendServicesTemplate', N'CC', N'sales@acmehosting.com') +GO +INSERT [dbo].[ecStoreDefaultSettings] ([SettingsName], [PropertyName], [PropertyValue]) VALUES (N'SuspendServicesTemplate', N'From', N'support@acmehosting.com') +GO +INSERT [dbo].[ecStoreDefaultSettings] ([SettingsName], [PropertyName], [PropertyValue]) VALUES (N'SuspendServicesTemplate', N'HtmlBody', N' + + + Suspend Service Summary Information + + + +
+ + + +
+ Suspended Service Information +
+ +

Hello #Customer["FirstName"]#,

+ +

"#service.ServiceName#" service has been suspended under your user account +and below is the summary information.

+

Service Overview

+ + + + + + + + + + +
Service Name:#service.ServiceName#
Created:#service.Created#
+ +

+If you have any questions regarding your hosting account, feel free to contact our sales department at any time. +

+ +

+Best regards,
+ACME Hosting Inc.
+Web Site: www.acmehosting.com
+E-Mail: support@acmehosting.com

+ +
+ +') +GO +INSERT [dbo].[ecStoreDefaultSettings] ([SettingsName], [PropertyName], [PropertyValue]) VALUES (N'SuspendServicesTemplate', N'Subject', N'Suspend Service Notification') +GO +INSERT [dbo].[ecStoreDefaultSettings] ([SettingsName], [PropertyName], [PropertyValue]) VALUES (N'SuspendServicesTemplate', N'TextBody', N' +================================ + Suspended Service Information +================================ + +Hello #Customer["FirstName"]#, + +"#service.ServiceName#" service has been suspended under your user account +and below is the summary information. + +Service Overview +============= +Service Name: #service.ServiceName# +Created: #service.Created# + +If you have any questions regarding your hosting account, feel free to contact our support department at any time. + +Best regards, +ACME Hosting Inc. +Web Site: http://www.acmehosting.com +E-Mail: support@acmehosting.com') +GO +INSERT [dbo].[ecStoreDefaultSettings] ([SettingsName], [PropertyName], [PropertyValue]) VALUES (N'SystemSettings', N'BaseCurrency', N'USD') +GO +INSERT [dbo].[ecStoreDefaultSettings] ([SettingsName], [PropertyName], [PropertyValue]) VALUES (N'SystemSettings', N'InvoiceGracePeriod', N'2') +GO +INSERT [dbo].[ecStoreDefaultSettings] ([SettingsName], [PropertyName], [PropertyValue]) VALUES (N'SystemSettings', N'ServiceSuspendThreshold', N'3') +GO +INSERT [dbo].[ecStoreDefaultSettings] ([SettingsName], [PropertyName], [PropertyValue]) VALUES (N'SystemSettings', N'SvcCancelThreshold', N'3') +GO +INSERT [dbo].[ecStoreDefaultSettings] ([SettingsName], [PropertyName], [PropertyValue]) VALUES (N'SystemSettings', N'SvcInvoiceThreshold', N'7') +GO +SET IDENTITY_INSERT [dbo].[ecSupportedPlugins] ON + +GO +INSERT [dbo].[ecSupportedPlugins] ([PluginID], [PluginName], [DisplayName], [PluginGroup], [TypeName], [Interactive], [SupportedItems], [UniqueID]) VALUES (1, N'AuthorizeNet', N'Authorize.Net', N'CC_GATEWAY', N'WebsitePanel.Ecommerce.EnterpriseServer.AuthorizeNetProvider, WebsitePanel.Plugins.AuthorizeNet', 0, N'American Express=Amex,Discover,Master Card=MasterCard,Visa', NULL) +GO +INSERT [dbo].[ecSupportedPlugins] ([PluginID], [PluginName], [DisplayName], [PluginGroup], [TypeName], [Interactive], [SupportedItems], [UniqueID]) VALUES (2, N'PayPalPro', N'PayPal Pro', N'CC_GATEWAY', N'WebsitePanel.Ecommerce.EnterpriseServer.PayPalProProvider, WebsitePanel.Plugins.PayPalPro', 0, N'Visa,Master Card=MasterCard,Discover,American Express=Amex,Switch,Solo', NULL) +GO +INSERT [dbo].[ecSupportedPlugins] ([PluginID], [PluginName], [DisplayName], [PluginGroup], [TypeName], [Interactive], [SupportedItems], [UniqueID]) VALUES (3, N'2Checkout', N'2Checkout', N'2CO', N'WebsitePanel.Ecommerce.EnterpriseServer.TCOProvider, WebsitePanel.Plugins.2Checkout', 1, NULL, N'6A847B61-6178-445d-93FC-1929E86984DF') +GO +INSERT [dbo].[ecSupportedPlugins] ([PluginID], [PluginName], [DisplayName], [PluginGroup], [TypeName], [Interactive], [SupportedItems], [UniqueID]) VALUES (4, N'PayPalStandard', N'PayPal Standard', N'PP_ACCOUNT', N'WebsitePanel.Ecommerce.EnterpriseServer.PayPalStandardProvider, WebsitePanel.Plugins.PayPalStandard', 1, NULL, N'C7EA147E-880D-46f4-88C0-90A9D58BB8C0') +GO +INSERT [dbo].[ecSupportedPlugins] ([PluginID], [PluginName], [DisplayName], [PluginGroup], [TypeName], [Interactive], [SupportedItems], [UniqueID]) VALUES (5, N'OfflinePayment', N'Offline Payment', N'OFFLINE', N'WebsitePanel.Ecommerce.EnterpriseServer.OfflinePayment, WebsitePanel.Plugins.OfflinePayment', 0, NULL, NULL) +GO +INSERT [dbo].[ecSupportedPlugins] ([PluginID], [PluginName], [DisplayName], [PluginGroup], [TypeName], [Interactive], [SupportedItems], [UniqueID]) VALUES (6, N'Enom', N'Enom', N'DOMAIN_REGISTRAR', N'WebsitePanel.Ecommerce.EnterpriseServer.EnomRegistrar, WebsitePanel.Plugins.Enom', 0, NULL, NULL) +GO +INSERT [dbo].[ecSupportedPlugins] ([PluginID], [PluginName], [DisplayName], [PluginGroup], [TypeName], [Interactive], [SupportedItems], [UniqueID]) VALUES (7, N'Directi', N'Directi', N'DOMAIN_REGISTRAR', N'WebsitePanel.Ecommerce.EnterpriseServer.DirectiRegistrar, WebsitePanel.Plugins.Directi', 0, NULL, NULL) +GO +INSERT [dbo].[ecSupportedPlugins] ([PluginID], [PluginName], [DisplayName], [PluginGroup], [TypeName], [Interactive], [SupportedItems], [UniqueID]) VALUES (8, N'OfflineRegistrar', N'Offline Registrar', N'DOMAIN_REGISTRAR', N'WebsitePanel.Ecommerce.EnterpriseServer.OfflineRegistrar, WebsitePanel.Plugins.OfflineRegistrar', 0, NULL, NULL) +GO +SET IDENTITY_INSERT [dbo].[ecSupportedPlugins] OFF +GO +SET IDENTITY_INSERT [dbo].[Packages] ON + +GO +INSERT [dbo].[Packages] ([PackageID], [ParentPackageID], [UserID], [PackageName], [PackageComments], [ServerID], [StatusID], [PlanID], [PurchaseDate], [OverrideQuotas], [BandwidthUpdated]) VALUES (1, NULL, 1, N'System', N'', NULL, 1, NULL, CAST(0x00009DB500D45272 AS DateTime), 0, NULL) +GO +SET IDENTITY_INSERT [dbo].[Packages] OFF +GO +INSERT [dbo].[PackagesTreeCache] ([ParentPackageID], [PackageID]) VALUES (1, 1) +GO +INSERT [dbo].[Providers] ([ProviderID], [GroupID], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery]) VALUES (1, 1, N'Windows2003', N'Windows Server 2003', N'WebsitePanel.Providers.OS.Windows2003, WebsitePanel.Providers.OS.Windows2003', N'Windows2003', NULL) +GO +INSERT [dbo].[Providers] ([ProviderID], [GroupID], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery]) VALUES (2, 2, N'IIS60', N'Internet Information Services 6.0', N'WebsitePanel.Providers.Web.IIs60, WebsitePanel.Providers.Web.IIs60', N'IIS60', NULL) +GO +INSERT [dbo].[Providers] ([ProviderID], [GroupID], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery]) VALUES (3, 3, N'MSFTP60', N'Microsoft FTP Server 6.0', N'WebsitePanel.Providers.FTP.MsFTP, WebsitePanel.Providers.FTP.IIs60', N'MSFTP60', NULL) +GO +INSERT [dbo].[Providers] ([ProviderID], [GroupID], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery]) VALUES (4, 4, N'MailEnable', N'MailEnable Server 1.x - 7.x', N'WebsitePanel.Providers.Mail.MailEnable, WebsitePanel.Providers.Mail.MailEnable', N'MailEnable', NULL) +GO +INSERT [dbo].[Providers] ([ProviderID], [GroupID], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery]) VALUES (5, 5, N'MSSQL', N'Microsoft SQL Server 2000', N'WebsitePanel.Providers.Database.MsSqlServer, WebsitePanel.Providers.Database.SqlServer', N'MSSQL', NULL) +GO +INSERT [dbo].[Providers] ([ProviderID], [GroupID], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery]) VALUES (6, 6, N'MySQL', N'MySQL Server 4.x', N'WebsitePanel.Providers.Database.MySqlServer, WebsitePanel.Providers.Database.MySQL', N'MySQL', NULL) +GO +INSERT [dbo].[Providers] ([ProviderID], [GroupID], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery]) VALUES (7, 7, N'MSDNS', N'Microsoft DNS Server', N'WebsitePanel.Providers.DNS.MsDNS, WebsitePanel.Providers.DNS.MsDNS', N'MSDNS', NULL) +GO +INSERT [dbo].[Providers] ([ProviderID], [GroupID], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery]) VALUES (8, 8, N'AWStats', N'AWStats Statistics Service', N'WebsitePanel.Providers.Statistics.AWStats, WebsitePanel.Providers.Statistics.AWStats', N'AWStats', NULL) +GO +INSERT [dbo].[Providers] ([ProviderID], [GroupID], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery]) VALUES (9, 7, N'SimpleDNS', N'SimpleDNS Plus 4.x', N'WebsitePanel.Providers.DNS.SimpleDNS, WebsitePanel.Providers.DNS.SimpleDNS', N'SimpleDNS', NULL) +GO +INSERT [dbo].[Providers] ([ProviderID], [GroupID], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery]) VALUES (10, 8, N'SmarterStats', N'SmarterStats 3.x', N'WebsitePanel.Providers.Statistics.SmarterStats, WebsitePanel.Providers.Statistics.SmarterStats', N'SmarterStats', NULL) +GO +INSERT [dbo].[Providers] ([ProviderID], [GroupID], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery]) VALUES (11, 4, N'SmarterMail', N'SmarterMail 2.x', N'WebsitePanel.Providers.Mail.SmarterMail2, WebsitePanel.Providers.Mail.SmarterMail2', N'SmarterMail', NULL) +GO +INSERT [dbo].[Providers] ([ProviderID], [GroupID], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery]) VALUES (12, 3, N'Gene6FTP', N'Gene6 FTP Server 3.x', N'WebsitePanel.Providers.FTP.Gene6, WebsitePanel.Providers.FTP.Gene6', N'Gene6FTP', NULL) +GO +INSERT [dbo].[Providers] ([ProviderID], [GroupID], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery]) VALUES (13, 4, N'Merak', N'Merak Mail Server 8.0.3 - 9.2.x', N'WebsitePanel.Providers.Mail.Merak, WebsitePanel.Providers.Mail.Merak', N'Merak', NULL) +GO +INSERT [dbo].[Providers] ([ProviderID], [GroupID], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery]) VALUES (14, 4, N'SmarterMail', N'SmarterMail 3.x - 4.x', N'WebsitePanel.Providers.Mail.SmarterMail3, WebsitePanel.Providers.Mail.SmarterMail3', N'SmarterMail', NULL) +GO +INSERT [dbo].[Providers] ([ProviderID], [GroupID], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery]) VALUES (15, 9, N'Sps20', N'Windows SharePoint Services 2.0', N'WebsitePanel.Providers.SharePoint.Sps20, WebsitePanel.Providers.SharePoint.Sps20', N'Sps20', 1) +GO +INSERT [dbo].[Providers] ([ProviderID], [GroupID], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery]) VALUES (16, 10, N'MSSQL', N'Microsoft SQL Server 2005', N'WebsitePanel.Providers.Database.MsSqlServer2005, WebsitePanel.Providers.Database.SqlServer', N'MSSQL', NULL) +GO +INSERT [dbo].[Providers] ([ProviderID], [GroupID], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery]) VALUES (17, 11, N'MySQL', N'MySQL Server 5.0', N'WebsitePanel.Providers.Database.MySqlServer50, WebsitePanel.Providers.Database.MySQL', N'MySQL', NULL) +GO +INSERT [dbo].[Providers] ([ProviderID], [GroupID], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery]) VALUES (18, 4, N'MDaemon', N'MDaemon 9.x - 11.x', N'WebsitePanel.Providers.Mail.MDaemon, WebsitePanel.Providers.Mail.MDaemon', N'MDaemon', NULL) +GO +INSERT [dbo].[Providers] ([ProviderID], [GroupID], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery]) VALUES (19, 4, N'ArgoMail', N'ArGoSoft Mail Server 1.x', N'WebsitePanel.Providers.Mail.ArgoMail, WebsitePanel.Providers.Mail.ArgoMail', N'ArgoMail', 1) +GO +INSERT [dbo].[Providers] ([ProviderID], [GroupID], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery]) VALUES (20, 4, N'hMailServer', N'hMailServer 4.2', N'WebsitePanel.Providers.Mail.hMailServer, WebsitePanel.Providers.Mail.hMailServer', N'hMailServer', NULL) +GO +INSERT [dbo].[Providers] ([ProviderID], [GroupID], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery]) VALUES (21, 4, N'AbilityMailServer', N'Ability Mail Server 2.x', N'WebsitePanel.Providers.Mail.AbilityMailServer, WebsitePanel.Providers.Mail.AbilityMailServer', N'AbilityMailServer', NULL) +GO +INSERT [dbo].[Providers] ([ProviderID], [GroupID], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery]) VALUES (22, 4, N'hMailServer43', N'hMailServer 4.3', N'WebsitePanel.Providers.Mail.hMailServer43, WebsitePanel.Providers.Mail.hMailServer43', N'hMailServer43', NULL) +GO +INSERT [dbo].[Providers] ([ProviderID], [GroupID], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery]) VALUES (23, 9, N'Sps20', N'Windows SharePoint Services 3.0', N'WebsitePanel.Providers.SharePoint.Sps30, WebsitePanel.Providers.SharePoint.Sps30', N'Sps20', NULL) +GO +INSERT [dbo].[Providers] ([ProviderID], [GroupID], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery]) VALUES (24, 7, N'Bind', N'ISC BIND 8.x - 9.x', N'WebsitePanel.Providers.DNS.IscBind, WebsitePanel.Providers.DNS.Bind', N'Bind', NULL) +GO +INSERT [dbo].[Providers] ([ProviderID], [GroupID], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery]) VALUES (25, 3, N'ServU', N'Serv-U FTP 6.x', N'WebsitePanel.Providers.FTP.ServU, WebsitePanel.Providers.FTP.ServU', N'ServU', NULL) +GO +INSERT [dbo].[Providers] ([ProviderID], [GroupID], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery]) VALUES (26, 3, N'FileZilla', N'FileZilla FTP Server 0.9', N'WebsitePanel.Providers.FTP.FileZilla, WebsitePanel.Providers.FTP.FileZilla', N'FileZilla', NULL) +GO +INSERT [dbo].[Providers] ([ProviderID], [GroupID], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery]) VALUES (27, 12, N'Exchange2007', N'Hosted Microsoft Exchange Server 2007', N'WebsitePanel.Providers.HostedSolution.Exchange2007, WebsitePanel.Providers.HostedSolution', N'Exchange', NULL) +GO +INSERT [dbo].[Providers] ([ProviderID], [GroupID], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery]) VALUES (28, 7, N'SimpleDNS', N'SimpleDNS Plus 5.x', N'WebsitePanel.Providers.DNS.SimpleDNS5, WebsitePanel.Providers.DNS.SimpleDNS50', N'SimpleDNS', NULL) +GO +INSERT [dbo].[Providers] ([ProviderID], [GroupID], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery]) VALUES (29, 4, N'SmarterMail', N'SmarterMail 5.x', N'WebsitePanel.Providers.Mail.SmarterMail5, WebsitePanel.Providers.Mail.SmarterMail5', N'SmarterMail50', NULL) +GO +INSERT [dbo].[Providers] ([ProviderID], [GroupID], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery]) VALUES (30, 11, N'MySQL', N'MySQL Server 5.1', N'WebsitePanel.Providers.Database.MySqlServer51, WebsitePanel.Providers.Database.MySQL', N'MySQL', NULL) +GO +INSERT [dbo].[Providers] ([ProviderID], [GroupID], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery]) VALUES (31, 8, N'SmarterStats', N'SmarterStats 4.x', N'WebsitePanel.Providers.Statistics.SmarterStats4, WebsitePanel.Providers.Statistics.SmarterStats', N'SmarterStats', NULL) +GO +INSERT [dbo].[Providers] ([ProviderID], [GroupID], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery]) VALUES (32, 12, N'Exchange2010', N'Hosted Microsoft Exchange Server 2010', N'WebsitePanel.Providers.HostedSolution.Exchange2010, WebsitePanel.Providers.HostedSolution', N'Exchange', NULL) +GO +INSERT [dbo].[Providers] ([ProviderID], [GroupID], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery]) VALUES (55, 7, N'NetticaDNS', N'Nettica DNS', N'WebsitePanel.Providers.DNS.Nettica, WebsitePanel.Providers.DNS.Nettica', N'NetticaDNS', 1) +GO +INSERT [dbo].[Providers] ([ProviderID], [GroupID], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery]) VALUES (56, 7, N'PowerDNS', N'PowerDNS', N'WebsitePanel.Providers.DNS.PowerDNS, WebsitePanel.Providers.DNS.PowerDNS', N'PowerDNS', NULL) +GO +INSERT [dbo].[Providers] ([ProviderID], [GroupID], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery]) VALUES (60, 4, N'SmarterMail', N'SmarterMail 6.x', N'WebsitePanel.Providers.Mail.SmarterMail6, WebsitePanel.Providers.Mail.SmarterMail6', N'SmarterMail60', NULL) +GO +INSERT [dbo].[Providers] ([ProviderID], [GroupID], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery]) VALUES (61, 4, N'Merak', N'Merak Mail Server 10.x', N'WebsitePanel.Providers.Mail.Merak10, WebsitePanel.Providers.Mail.Merak10', N'Merak', NULL) +GO +INSERT [dbo].[Providers] ([ProviderID], [GroupID], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery]) VALUES (62, 8, N'SmarterStats', N'SmarterStats 5.x +', N'WebsitePanel.Providers.Statistics.SmarterStats5, WebsitePanel.Providers.Statistics.SmarterStats', N'SmarterStats', NULL) +GO +INSERT [dbo].[Providers] ([ProviderID], [GroupID], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery]) VALUES (63, 4, N'hMailServer5', N'hMailServer 5.x', N'WebsitePanel.Providers.Mail.hMailServer5, WebsitePanel.Providers.Mail.hMailServer5', N'hMailServer5', NULL) +GO +INSERT [dbo].[Providers] ([ProviderID], [GroupID], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery]) VALUES (64, 4, N'SmarterMail', N'SmarterMail 7.x - 8.x', N'WebsitePanel.Providers.Mail.SmarterMail7, WebsitePanel.Providers.Mail.SmarterMail7', N'SmarterMail60', NULL) +GO +INSERT [dbo].[Providers] ([ProviderID], [GroupID], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery]) VALUES (65, 4, N'SmarterMail', N'SmarterMail 9.x', N'WebsitePanel.Providers.Mail.SmarterMail9, WebsitePanel.Providers.Mail.SmarterMail9', N'SmarterMail60', NULL) +GO +INSERT [dbo].[Providers] ([ProviderID], [GroupID], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery]) VALUES (66, 4, N'SmarterMail', N'SmarterMail 10.x +', N'WebsitePanel.Providers.Mail.SmarterMail10, WebsitePanel.Providers.Mail.SmarterMail10', N'SmarterMail100', NULL) +GO +INSERT [dbo].[Providers] ([ProviderID], [GroupID], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery]) VALUES (90, 12, N'Exchange2010SP2', N'Hosted Microsoft Exchange Server 2010 SP2', N'WebsitePanel.Providers.HostedSolution.Exchange2010SP2, WebsitePanel.Providers.HostedSolution', N'Exchange', NULL) +GO +INSERT [dbo].[Providers] ([ProviderID], [GroupID], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery]) VALUES (100, 1, N'Windows2008', N'Windows Server 2008', N'WebsitePanel.Providers.OS.Windows2008, WebsitePanel.Providers.OS.Windows2008', N'Windows2008', NULL) +GO +INSERT [dbo].[Providers] ([ProviderID], [GroupID], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery]) VALUES (101, 2, N'IIS70', N'Internet Information Services 7.0', N'WebsitePanel.Providers.Web.IIs70, WebsitePanel.Providers.Web.IIs70', N'IIS70', NULL) +GO +INSERT [dbo].[Providers] ([ProviderID], [GroupID], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery]) VALUES (102, 3, N'MSFTP70', N'Microsoft FTP Server 7.0', N'WebsitePanel.Providers.FTP.MsFTP, WebsitePanel.Providers.FTP.IIs70', N'MSFTP70', NULL) +GO +INSERT [dbo].[Providers] ([ProviderID], [GroupID], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery]) VALUES (103, 13, N'Organizations', N'Hosted Organizations', N'WebsitePanel.Providers.HostedSolution.OrganizationProvider, WebsitePanel.Providers.HostedSolution', N'Organizations', NULL) +GO +INSERT [dbo].[Providers] ([ProviderID], [GroupID], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery]) VALUES (104, 1, N'Windows2012', N'Windows Server 2012', N'WebsitePanel.Providers.OS.Windows2012, WebsitePanel.Providers.OS.Windows2012', N'Windows2008', NULL) +GO +INSERT [dbo].[Providers] ([ProviderID], [GroupID], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery]) VALUES (105, 2, N'IIS80', N'Internet Information Services 8.0', N'WebsitePanel.Providers.Web.IIs80, WebsitePanel.Providers.Web.IIs80', N'IIS70', NULL) +GO +INSERT [dbo].[Providers] ([ProviderID], [GroupID], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery]) VALUES (106, 3, N'MSFTP80', N'Microsoft FTP Server 8.0', N'WebsitePanel.Providers.FTP.MsFTP80, WebsitePanel.Providers.FTP.IIs80', N'MSFTP70', NULL) +GO +INSERT [dbo].[Providers] ([ProviderID], [GroupID], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery]) VALUES (200, 20, N'HostedSharePoint30', N'Hosted Windows SharePoint Services 3.0', N'WebsitePanel.Providers.HostedSolution.HostedSharePointServer, WebsitePanel.Providers.HostedSolution', N'HostedSharePoint30', NULL) +GO +INSERT [dbo].[Providers] ([ProviderID], [GroupID], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery]) VALUES (201, 21, N'CRM', N'Hosted MS CRM 4.0', N'WebsitePanel.Providers.HostedSolution.CRMProvider, WebsitePanel.Providers.HostedSolution', N'CRM', NULL) +GO +INSERT [dbo].[Providers] ([ProviderID], [GroupID], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery]) VALUES (202, 22, N'MsSQL', N'Microsoft SQL Server 2008', N'WebsitePanel.Providers.Database.MsSqlServer2008, WebsitePanel.Providers.Database.SqlServer', N'MSSQL', NULL) +GO +INSERT [dbo].[Providers] ([ProviderID], [GroupID], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery]) VALUES (203, 31, N'BlackBerry 4.1', N'BlackBerry 4.1', N'WebsitePanel.Providers.HostedSolution.BlackBerryProvider, WebsitePanel.Providers.HostedSolution', N'BlackBerry', 1) +GO +INSERT [dbo].[Providers] ([ProviderID], [GroupID], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery]) VALUES (204, 31, N'BlackBerry 5.0', N'BlackBerry 5.0', N'WebsitePanel.Providers.HostedSolution.BlackBerry5Provider, WebsitePanel.Providers.HostedSolution', N'BlackBerry5', 1) +GO +INSERT [dbo].[Providers] ([ProviderID], [GroupID], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery]) VALUES (205, 32, N'OCS', N'Office Communications Server 2007 R2', N'WebsitePanel.Providers.HostedSolution.OCS2007R2, WebsitePanel.Providers.HostedSolution', N'OCS', 1) +GO +INSERT [dbo].[Providers] ([ProviderID], [GroupID], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery]) VALUES (206, 32, N'OCSEdge', N'OCS Edge server', N'WebsitePanel.Providers.HostedSolution.OCSEdge2007R2, WebsitePanel.Providers.HostedSolution', N'OCS_Edge', 1) +GO +INSERT [dbo].[Providers] ([ProviderID], [GroupID], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery]) VALUES (208, 20, N'HostedSharePoint2010', N'Hosted SharePoint Foundation 2010', N'WebsitePanel.Providers.HostedSolution.HostedSharePointServer2010, WebsitePanel.Providers.HostedSolution', N'HostedSharePoint30', NULL) +GO +INSERT [dbo].[Providers] ([ProviderID], [GroupID], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery]) VALUES (209, 23, N'MsSQL', N'Microsoft SQL Server 2012', N'WebsitePanel.Providers.Database.MsSqlServer2012, WebsitePanel.Providers.Database.SqlServer', N'MSSQL', NULL) +GO +INSERT [dbo].[Providers] ([ProviderID], [GroupID], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery]) VALUES (250, 41, N'Lync2010', N'Microsoft Lync Server 2010 Multitenant Hosting Pack', N'WebsitePanel.Providers.HostedSolution.Lync2010, WebsitePanel.Providers.HostedSolution', N'Lync', NULL) +GO +INSERT [dbo].[Providers] ([ProviderID], [GroupID], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery]) VALUES (300, 30, N'HyperV', N'Microsoft Hyper-V', N'WebsitePanel.Providers.Virtualization.HyperV, WebsitePanel.Providers.Virtualization.HyperV', N'HyperV', 1) +GO +INSERT [dbo].[Providers] ([ProviderID], [GroupID], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery]) VALUES (301, 11, N'MySQL', N'MySQL Server 5.5', N'WebsitePanel.Providers.Database.MySqlServer55, WebsitePanel.Providers.Database.MySQL', N'MySQL', NULL) +GO +INSERT [dbo].[Providers] ([ProviderID], [GroupID], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery]) VALUES (400, 40, N'HyperVForPC', N'Microsoft Hyper-V For Private Cloud', N'WebsitePanel.Providers.VirtualizationForPC.HyperVForPC, WebsitePanel.Providers.VirtualizationForPC.HyperVForPC', N'HyperVForPrivateCloud', 1) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (2, 6, 1, N'MySQL4.Databases', N'Databases', 2, 1, 7, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (3, 5, 1, N'MsSQL2000.Databases', N'Databases', 2, 1, 5, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (4, 3, 1, N'FTP.Accounts', N'FTP Accounts', 2, 1, 9, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (11, 9, 2, N'SharePoint.Users', N'SharePoint Users', 2, 0, 1, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (12, 8, 1, N'Stats.Sites', N'Statistics Sites', 2, 1, 14, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (13, 2, 1, N'Web.Sites', N'Web Sites', 2, 1, 10, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (14, 4, 1, N'Mail.Accounts', N'Mail Accounts', 2, 1, 15, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (15, 5, 2, N'MsSQL2000.Users', N'Users', 2, 0, 6, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (18, 4, 3, N'Mail.Forwardings', N'Mail Forwardings', 2, 0, 16, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (19, 6, 2, N'MySQL4.Users', N'Users', 2, 0, 8, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (20, 4, 6, N'Mail.Lists', N'Mail Lists', 2, 0, 17, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (22, 9, 3, N'SharePoint.Groups', N'SharePoint Groups', 2, 0, 3, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (24, 4, 4, N'Mail.Groups', N'Mail Groups', 2, 0, 18, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (25, 2, 3, N'Web.AspNet11', N'ASP.NET 1.1', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (26, 2, 4, N'Web.AspNet20', N'ASP.NET 2.0', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (27, 2, 2, N'Web.Asp', N'ASP', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (28, 2, 5, N'Web.Php4', N'PHP 4.x', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (29, 2, 6, N'Web.Php5', N'PHP 5.x', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (30, 2, 7, N'Web.Perl', N'Perl', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (31, 2, 8, N'Web.Python', N'Python', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (32, 2, 9, N'Web.VirtualDirs', N'Virtual Directories', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (33, 2, 10, N'Web.FrontPage', N'FrontPage', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (34, 2, 11, N'Web.Security', N'Custom Security Settings', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (35, 2, 12, N'Web.DefaultDocs', N'Custom Default Documents', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (36, 2, 13, N'Web.AppPools', N'Dedicated Application Pools', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (37, 2, 14, N'Web.Headers', N'Custom Headers', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (38, 2, 15, N'Web.Errors', N'Custom Errors', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (39, 2, 16, N'Web.Mime', N'Custom MIME Types', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (40, 4, 2, N'Mail.MaxBoxSize', N'Max Mailbox Size', 3, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (41, 5, 3, N'MsSQL2000.MaxDatabaseSize', N'Max Database Size', 3, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (42, 5, 5, N'MsSQL2000.Backup', N'Database Backups', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (43, 5, 6, N'MsSQL2000.Restore', N'Database Restores', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (44, 5, 7, N'MsSQL2000.Truncate', N'Database Truncate', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (45, 6, 4, N'MySQL4.Backup', N'Database Backups', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (47, 1, 6, N'OS.ODBC', N'ODBC DSNs', 2, 0, 20, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (48, 7, 1, N'DNS.Editor', N'DNS Editor', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (49, 4, 5, N'Mail.MaxGroupMembers', N'Max Group Recipients', 3, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (50, 4, 7, N'Mail.MaxListMembers', N'Max List Recipients', 3, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (51, 1, 2, N'OS.Bandwidth', N'Bandwidth, MB', 2, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (52, 1, 1, N'OS.Diskspace', N'Disk space, MB', 2, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (53, 1, 3, N'OS.Domains', N'Domains', 2, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (54, 1, 4, N'OS.SubDomains', N'Sub-Domains', 2, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (55, 1, 6, N'OS.FileManager', N'File Manager', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (56, 9, 1, N'SharePoint.Sites', N'SharePoint Sites', 2, 0, 19, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (57, 2, 8, N'Web.CgiBin', N'CGI-BIN Folder', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (58, 2, 8, N'Web.SecuredFolders', N'Secured Folders', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (59, 2, 8, N'Web.SharedSSL', N'Shared SSL Folders', 2, 0, 25, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (60, 2, 8, N'Web.Redirections', N'Web Sites Redirection', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (61, 2, 8, N'Web.HomeFolders', N'Changing Sites Root Folders', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (62, 10, 1, N'MsSQL2005.Databases', N'Databases', 2, 0, 21, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (63, 10, 2, N'MsSQL2005.Users', N'Users', 2, 0, 22, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (64, 10, 3, N'MsSQL2005.MaxDatabaseSize', N'Max Database Size', 3, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (65, 10, 5, N'MsSQL2005.Backup', N'Database Backups', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (66, 10, 6, N'MsSQL2005.Restore', N'Database Restores', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (67, 10, 7, N'MsSQL2005.Truncate', N'Database Truncate', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (68, 11, 1, N'MySQL5.Databases', N'Databases', 2, 0, 23, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (69, 11, 2, N'MySQL5.Users', N'Users', 2, 0, 24, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (70, 11, 4, N'MySQL5.Backup', N'Database Backups', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (71, 1, 9, N'OS.ScheduledTasks', N'Scheduled Tasks', 2, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (72, 1, 10, N'OS.ScheduledIntervalTasks', N'Interval Tasks Allowed', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (73, 1, 11, N'OS.MinimumTaskInterval', N'Minimum Tasks Interval, minutes', 3, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (74, 1, 7, N'OS.AppInstaller', N'Applications Installer', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (75, 1, 8, N'OS.ExtraApplications', N'Extra Application Packs', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (77, 12, 2, N'Exchange2007.DiskSpace', N'Organization Disk Space, MB', 2, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (78, 12, 3, N'Exchange2007.Mailboxes', N'Mailboxes per Organization', 2, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (79, 12, 4, N'Exchange2007.Contacts', N'Contacts per Organization', 3, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (80, 12, 5, N'Exchange2007.DistributionLists', N'Distribution Lists per Organization', 3, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (81, 12, 6, N'Exchange2007.PublicFolders', N'Public Folders per Organization', 3, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (83, 12, 9, N'Exchange2007.POP3Allowed', N'POP3 Access', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (84, 12, 11, N'Exchange2007.IMAPAllowed', N'IMAP Access', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (85, 12, 13, N'Exchange2007.OWAAllowed', N'OWA/HTTP Access', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (86, 12, 15, N'Exchange2007.MAPIAllowed', N'MAPI Access', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (87, 12, 17, N'Exchange2007.ActiveSyncAllowed', N'ActiveSync Access', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (88, 12, 8, N'Exchange2007.MailEnabledPublicFolders', N'Mail Enabled Public Folders Allowed', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (94, 2, 17, N'Web.ColdFusion', N'ColdFusion', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (95, 2, 1, N'Web.WebAppGallery', N'Web Application Gallery', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (96, 2, 18, N'Web.CFVirtualDirectories', N'ColdFusion Virtual Directories', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (97, 2, 20, N'Web.RemoteManagement', N'Remote web management allowed', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (100, 2, 19, N'Web.IPAddresses', N'Dedicated IP Addresses', 2, 1, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (102, 4, 8, N'Mail.DisableSizeEdit', N'Disable Mailbox Size Edit', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (103, 6, 3, N'MySQL4.MaxDatabaseSize', N'Max Database Size', 3, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (104, 6, 5, N'MySQL4.Restore', N'Database Restores', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (105, 6, 6, N'MySQL4.Truncate', N'Database Truncate', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (106, 11, 3, N'MySQL5.MaxDatabaseSize', N'Max Database Size', 3, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (107, 11, 5, N'MySQL5.Restore', N'Database Restores', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (108, 11, 6, N'MySQL5.Truncate', N'Database Truncate', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (200, 20, 1, N'HostedSharePoint.Sites', N'SharePoint Site Collections', 2, 0, 200, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (203, 10, 4, N'MsSQL2005.MaxLogSize', N'Max Log Size', 3, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (204, 5, 4, N'MsSQL2000.MaxLogSize', N'Max Log Size', 3, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (205, 13, 1, N'HostedSolution.Organizations', N'Organizations', 2, 0, 29, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (206, 13, 2, N'HostedSolution.Users', N'Users', 2, 0, 30, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (207, 13, 3, N'HostedSolution.Domains', N'Domains per Organizations', 3, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (208, 20, 2, N'HostedSharePoint.MaxStorage', N'Max site storage, MB', 3, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (209, 21, 2, N'HostedCRM.Users', N'Users', 3, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (210, 21, 1, N'HostedCRM.Organization', N'CRM Organization', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (211, 22, 1, N'MsSQL2008.Databases', N'Databases', 2, 0, 31, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (212, 22, 2, N'MsSQL2008.Users', N'Users', 2, 0, 32, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (213, 22, 3, N'MsSQL2008.MaxDatabaseSize', N'Max Database Size', 3, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (214, 22, 5, N'MsSQL2008.Backup', N'Database Backups', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (215, 22, 6, N'MsSQL2008.Restore', N'Database Restores', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (216, 22, 7, N'MsSQL2008.Truncate', N'Database Truncate', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (217, 22, 4, N'MsSQL2008.MaxLogSize', N'Max Log Size', 3, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (218, 23, 1, N'MsSQL2012.Databases', N'Databases', 2, 0, 37, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (219, 23, 2, N'MsSQL2012.Users', N'Users', 2, 0, 38, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (220, 1, 5, N'OS.DomainPointers', N'Domain Pointers', 2, 0, NULL, 1) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (221, 23, 3, N'MsSQL2012.MaxDatabaseSize', N'Max Database Size', 3, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (222, 23, 5, N'MsSQL2012.Backup', N'Database Backups', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (223, 23, 6, N'MsSQL2012.Restore', N'Database Restores', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (224, 23, 7, N'MsSQL2012.Truncate', N'Database Truncate', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (225, 23, 4, N'MsSQL2012.MaxLogSize', N'Max Log Size', 3, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (230, 13, 4, N'HostedSolution.AllowChangeUPN', N'Allow to Change UserPrincipalName', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (300, 30, 1, N'VPS.ServersNumber', N'Number of VPS', 2, 0, 33, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (301, 30, 2, N'VPS.ManagingAllowed', N'Allow user to create VPS', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (302, 30, 3, N'VPS.CpuNumber', N'Number of CPU cores', 3, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (303, 30, 7, N'VPS.BootCdAllowed', N'Boot from CD allowed', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (304, 30, 8, N'VPS.BootCdEnabled', N'Boot from CD', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (305, 30, 4, N'VPS.Ram', N'RAM size, MB', 2, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (306, 30, 5, N'VPS.Hdd', N'Hard Drive size, GB', 2, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (307, 30, 6, N'VPS.DvdEnabled', N'DVD drive', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (308, 30, 10, N'VPS.ExternalNetworkEnabled', N'External Network', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (309, 30, 11, N'VPS.ExternalIPAddressesNumber', N'Number of External IP addresses', 2, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (310, 30, 13, N'VPS.PrivateNetworkEnabled', N'Private Network', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (311, 30, 14, N'VPS.PrivateIPAddressesNumber', N'Number of Private IP addresses per VPS', 3, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (312, 30, 9, N'VPS.SnapshotsNumber', N'Number of Snaphots', 3, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (313, 30, 15, N'VPS.StartShutdownAllowed', N'Allow user to Start, Turn off and Shutdown VPS', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (314, 30, 16, N'VPS.PauseResumeAllowed', N'Allow user to Pause, Resume VPS', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (315, 30, 17, N'VPS.RebootAllowed', N'Allow user to Reboot VPS', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (316, 30, 18, N'VPS.ResetAlowed', N'Allow user to Reset VPS', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (317, 30, 19, N'VPS.ReinstallAllowed', N'Allow user to Re-install VPS', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (318, 30, 12, N'VPS.Bandwidth', N'Monthly bandwidth, GB', 2, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (319, 31, 1, N'BlackBerry.Users', NULL, 2, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (320, 32, 1, N'OCS.Users', NULL, 2, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (321, 32, 2, N'OCS.Federation', NULL, 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (322, 32, 3, N'OCS.FederationByDefault', NULL, 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (323, 32, 4, N'OCS.PublicIMConnectivity', NULL, 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (324, 32, 5, N'OCS.PublicIMConnectivityByDefault', NULL, 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (325, 32, 6, N'OCS.ArchiveIMConversation', NULL, 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (326, 32, 7, N'OCS.ArchiveIMConvervationByDefault', NULL, 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (327, 32, 8, N'OCS.ArchiveFederatedIMConversation', NULL, 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (328, 32, 9, N'OCS.ArchiveFederatedIMConversationByDefault', NULL, 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (329, 32, 10, N'OCS.PresenceAllowed', NULL, 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (330, 32, 10, N'OCS.PresenceAllowedByDefault', NULL, 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (331, 2, 4, N'Web.AspNet40', N'ASP.NET 4.0', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (332, 2, 21, N'Web.SSL', N'SSL', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (333, 2, 22, N'Web.AllowIPAddressModeSwitch', N'Allow IP Address Mode Switch', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (334, 2, 23, N'Web.EnableHostNameSupport', N'Enable Hostname Support', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (344, 2, 9, N'Web.Htaccess', N'htaccess', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (345, 40, 1, N'VPSForPC.ServersNumber', N'Number of VPS', 2, 0, 35, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (346, 40, 2, N'VPSForPC.ManagingAllowed', N'Allow user to create VPS', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (347, 40, 3, N'VPSForPC.CpuNumber', N'Number of CPU cores', 3, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (348, 40, 7, N'VPSForPC.BootCdAllowed', N'Boot from CD allowed', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (349, 40, 7, N'VPSForPC.BootCdEnabled', N'Boot from CD', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (350, 40, 4, N'VPSForPC.Ram', N'RAM size, MB', 2, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (351, 40, 5, N'VPSForPC.Hdd', N'Hard Drive size, GB', 2, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (352, 40, 6, N'VPSForPC.DvdEnabled', N'DVD drive', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (353, 40, 10, N'VPSForPC.ExternalNetworkEnabled', N'External Network', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (354, 40, 11, N'VPSForPC.ExternalIPAddressesNumber', N'Number of External IP addresses', 2, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (355, 40, 13, N'VPSForPC.PrivateNetworkEnabled', N'Private Network', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (356, 40, 14, N'VPSForPC.PrivateIPAddressesNumber', N'Number of Private IP addresses per VPS', 3, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (357, 40, 9, N'VPSForPC.SnapshotsNumber', N'Number of Snaphots', 3, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (358, 40, 15, N'VPSForPC.StartShutdownAllowed', N'Allow user to Start, Turn off and Shutdown VPS', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (359, 40, 16, N'VPSForPC.PauseResumeAllowed', N'Allow user to Pause, Resume VPS', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (360, 40, 17, N'VPSForPC.RebootAllowed', N'Allow user to Reboot VPS', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (361, 40, 18, N'VPSForPC.ResetAlowed', N'Allow user to Reset VPS', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (362, 40, 19, N'VPSForPC.ReinstallAllowed', N'Allow user to Re-install VPS', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (363, 40, 12, N'VPSForPC.Bandwidth', N'Monthly bandwidth, GB', 2, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (364, 12, 19, N'Exchange2007.KeepDeletedItemsDays', N'Keep Deleted Items (days)', 3, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (365, 12, 20, N'Exchange2007.MaxRecipients', N'Maximum Recipients', 3, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (366, 12, 21, N'Exchange2007.MaxSendMessageSizeKB', N'Maximum Send Message Size (Kb)', 3, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (367, 12, 22, N'Exchange2007.MaxReceiveMessageSizeKB', N'Maximum Receive Message Size (Kb)', 3, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (368, 12, 1, N'Exchange2007.IsConsumer', N'Is Consumer Organization', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (369, 12, 23, N'Exchange2007.EnablePlansEditing', N'Enable Plans Editing', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (370, 41, 1, N'Lync.Users', N'Users', 2, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (371, 41, 2, N'Lync.Federation', N'Allow Federation', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (372, 41, 3, N'Lync.Conferencing', N'Allow Conferencing', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (373, 41, 4, N'Lync.MaxParticipants', N'Maximum Conference Particiapants', 3, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (374, 41, 5, N'Lync.AllowVideo', N'Allow Video in Conference', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (375, 41, 6, N'Lync.EnterpriseVoice', N'Allow EnterpriseVoice', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (376, 41, 7, N'Lync.EVUsers', N'Number of Enterprise Voice Users', 2, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (377, 41, 8, N'Lync.EVNational', N'Allow National Calls', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (378, 41, 9, N'Lync.EVMobile', N'Allow Mobile Calls', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (379, 41, 10, N'Lync.EVInternational', N'Allow International Calls', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (380, 41, 11, N'Lync.EnablePlansEditing', N'Enable Plans Editing', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (400, 20, 3, N'HostedSharePoint.UseSharedSSL', N'Use shared SSL Root', 1, 0, NULL, NULL) +GO +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (410, 1, 12, N'OS.AllowTenantCreateDomains', N'Allow Tenants to Create Top Level Domains', 1, 0, NULL, NULL) +GO +SET IDENTITY_INSERT [dbo].[ResourceGroupDnsRecords] ON + +GO +INSERT [dbo].[ResourceGroupDnsRecords] ([RecordID], [RecordOrder], [GroupID], [RecordType], [RecordName], [RecordData], [MXPriority]) VALUES (1, 1, 2, N'A', N'', N'[IP]', 0) +GO +INSERT [dbo].[ResourceGroupDnsRecords] ([RecordID], [RecordOrder], [GroupID], [RecordType], [RecordName], [RecordData], [MXPriority]) VALUES (2, 2, 2, N'A', N'*', N'[IP]', 0) +GO +INSERT [dbo].[ResourceGroupDnsRecords] ([RecordID], [RecordOrder], [GroupID], [RecordType], [RecordName], [RecordData], [MXPriority]) VALUES (3, 3, 2, N'A', N'www', N'[IP]', 0) +GO +INSERT [dbo].[ResourceGroupDnsRecords] ([RecordID], [RecordOrder], [GroupID], [RecordType], [RecordName], [RecordData], [MXPriority]) VALUES (4, 1, 3, N'A', N'ftp', N'[IP]', 0) +GO +INSERT [dbo].[ResourceGroupDnsRecords] ([RecordID], [RecordOrder], [GroupID], [RecordType], [RecordName], [RecordData], [MXPriority]) VALUES (5, 1, 4, N'A', N'mail', N'[IP]', 0) +GO +INSERT [dbo].[ResourceGroupDnsRecords] ([RecordID], [RecordOrder], [GroupID], [RecordType], [RecordName], [RecordData], [MXPriority]) VALUES (6, 2, 4, N'A', N'mail2', N'[IP]', 0) +GO +INSERT [dbo].[ResourceGroupDnsRecords] ([RecordID], [RecordOrder], [GroupID], [RecordType], [RecordName], [RecordData], [MXPriority]) VALUES (7, 3, 4, N'MX', N'', N'mail.[DOMAIN_NAME]', 10) +GO +INSERT [dbo].[ResourceGroupDnsRecords] ([RecordID], [RecordOrder], [GroupID], [RecordType], [RecordName], [RecordData], [MXPriority]) VALUES (9, 4, 4, N'MX', N'', N'mail2.[DOMAIN_NAME]', 21) +GO +INSERT [dbo].[ResourceGroupDnsRecords] ([RecordID], [RecordOrder], [GroupID], [RecordType], [RecordName], [RecordData], [MXPriority]) VALUES (10, 1, 5, N'A', N'mssql', N'[IP]', 0) +GO +INSERT [dbo].[ResourceGroupDnsRecords] ([RecordID], [RecordOrder], [GroupID], [RecordType], [RecordName], [RecordData], [MXPriority]) VALUES (11, 1, 6, N'A', N'mysql', N'[IP]', 0) +GO +INSERT [dbo].[ResourceGroupDnsRecords] ([RecordID], [RecordOrder], [GroupID], [RecordType], [RecordName], [RecordData], [MXPriority]) VALUES (12, 1, 8, N'A', N'stats', N'[IP]', 0) +GO +INSERT [dbo].[ResourceGroupDnsRecords] ([RecordID], [RecordOrder], [GroupID], [RecordType], [RecordName], [RecordData], [MXPriority]) VALUES (13, 5, 4, N'TXT', N'', N'v=spf1 a mx -all', 0) +GO +INSERT [dbo].[ResourceGroupDnsRecords] ([RecordID], [RecordOrder], [GroupID], [RecordType], [RecordName], [RecordData], [MXPriority]) VALUES (14, 1, 12, N'A', N'smtp', N'[IP]', 0) +GO +INSERT [dbo].[ResourceGroupDnsRecords] ([RecordID], [RecordOrder], [GroupID], [RecordType], [RecordName], [RecordData], [MXPriority]) VALUES (15, 2, 12, N'MX', N'', N'smtp.[DOMAIN_NAME]', 10) +GO +INSERT [dbo].[ResourceGroupDnsRecords] ([RecordID], [RecordOrder], [GroupID], [RecordType], [RecordName], [RecordData], [MXPriority]) VALUES (16, 3, 12, N'CNAME', N'autodiscover', N'', 0) +GO +INSERT [dbo].[ResourceGroupDnsRecords] ([RecordID], [RecordOrder], [GroupID], [RecordType], [RecordName], [RecordData], [MXPriority]) VALUES (17, 4, 12, N'CNAME', N'owa', N'', 0) +GO +SET IDENTITY_INSERT [dbo].[ResourceGroupDnsRecords] OFF +GO +INSERT [dbo].[ResourceGroups] ([GroupID], [GroupName], [GroupOrder], [GroupController], [ShowGroup]) VALUES (1, N'OS', 1, N'WebsitePanel.EnterpriseServer.OperatingSystemController', 1) +GO +INSERT [dbo].[ResourceGroups] ([GroupID], [GroupName], [GroupOrder], [GroupController], [ShowGroup]) VALUES (2, N'Web', 2, N'WebsitePanel.EnterpriseServer.WebServerController', 1) +GO +INSERT [dbo].[ResourceGroups] ([GroupID], [GroupName], [GroupOrder], [GroupController], [ShowGroup]) VALUES (3, N'FTP', 3, N'WebsitePanel.EnterpriseServer.FtpServerController', 1) +GO +INSERT [dbo].[ResourceGroups] ([GroupID], [GroupName], [GroupOrder], [GroupController], [ShowGroup]) VALUES (4, N'Mail', 4, N'WebsitePanel.EnterpriseServer.MailServerController', 1) +GO +INSERT [dbo].[ResourceGroups] ([GroupID], [GroupName], [GroupOrder], [GroupController], [ShowGroup]) VALUES (5, N'MsSQL2000', 7, N'WebsitePanel.EnterpriseServer.DatabaseServerController', 1) +GO +INSERT [dbo].[ResourceGroups] ([GroupID], [GroupName], [GroupOrder], [GroupController], [ShowGroup]) VALUES (6, N'MySQL4', 11, N'WebsitePanel.EnterpriseServer.DatabaseServerController', 1) +GO +INSERT [dbo].[ResourceGroups] ([GroupID], [GroupName], [GroupOrder], [GroupController], [ShowGroup]) VALUES (7, N'DNS', 16, N'WebsitePanel.EnterpriseServer.DnsServerController', 1) +GO +INSERT [dbo].[ResourceGroups] ([GroupID], [GroupName], [GroupOrder], [GroupController], [ShowGroup]) VALUES (8, N'Statistics', 17, N'WebsitePanel.EnterpriseServer.StatisticsServerController', 1) +GO +INSERT [dbo].[ResourceGroups] ([GroupID], [GroupName], [GroupOrder], [GroupController], [ShowGroup]) VALUES (9, N'SharePoint', 13, N'WebsitePanel.EnterpriseServer.SharePointServerController', 1) +GO +INSERT [dbo].[ResourceGroups] ([GroupID], [GroupName], [GroupOrder], [GroupController], [ShowGroup]) VALUES (10, N'MsSQL2005', 8, N'WebsitePanel.EnterpriseServer.DatabaseServerController', 1) +GO +INSERT [dbo].[ResourceGroups] ([GroupID], [GroupName], [GroupOrder], [GroupController], [ShowGroup]) VALUES (11, N'MySQL5', 12, N'WebsitePanel.EnterpriseServer.DatabaseServerController', 1) +GO +INSERT [dbo].[ResourceGroups] ([GroupID], [GroupName], [GroupOrder], [GroupController], [ShowGroup]) VALUES (12, N'Exchange', 5, NULL, 1) +GO +INSERT [dbo].[ResourceGroups] ([GroupID], [GroupName], [GroupOrder], [GroupController], [ShowGroup]) VALUES (13, N'Hosted Organizations', 6, NULL, 1) +GO +INSERT [dbo].[ResourceGroups] ([GroupID], [GroupName], [GroupOrder], [GroupController], [ShowGroup]) VALUES (20, N'Hosted SharePoint', 14, N'WebsitePanel.EnterpriseServer.HostedSharePointServerController', 1) +GO +INSERT [dbo].[ResourceGroups] ([GroupID], [GroupName], [GroupOrder], [GroupController], [ShowGroup]) VALUES (21, N'Hosted CRM', 15, NULL, 1) +GO +INSERT [dbo].[ResourceGroups] ([GroupID], [GroupName], [GroupOrder], [GroupController], [ShowGroup]) VALUES (22, N'MsSQL2008', 9, N'WebsitePanel.EnterpriseServer.DatabaseServerController', 1) +GO +INSERT [dbo].[ResourceGroups] ([GroupID], [GroupName], [GroupOrder], [GroupController], [ShowGroup]) VALUES (23, N'MsSQL2012', 10, N'WebsitePanel.EnterpriseServer.DatabaseServerController', 1) +GO +INSERT [dbo].[ResourceGroups] ([GroupID], [GroupName], [GroupOrder], [GroupController], [ShowGroup]) VALUES (30, N'VPS', 18, NULL, 1) +GO +INSERT [dbo].[ResourceGroups] ([GroupID], [GroupName], [GroupOrder], [GroupController], [ShowGroup]) VALUES (31, N'BlackBerry', 20, NULL, 1) +GO +INSERT [dbo].[ResourceGroups] ([GroupID], [GroupName], [GroupOrder], [GroupController], [ShowGroup]) VALUES (32, N'OCS', 21, NULL, 1) +GO +INSERT [dbo].[ResourceGroups] ([GroupID], [GroupName], [GroupOrder], [GroupController], [ShowGroup]) VALUES (40, N'VPSForPC', 19, NULL, 1) +GO +INSERT [dbo].[ResourceGroups] ([GroupID], [GroupName], [GroupOrder], [GroupController], [ShowGroup]) VALUES (41, N'Lync', 23, NULL, 1) +GO +SET IDENTITY_INSERT [dbo].[Schedule] ON + +GO +INSERT [dbo].[Schedule] ([ScheduleID], [TaskID], [PackageID], [ScheduleName], [ScheduleTypeID], [Interval], [FromTime], [ToTime], [StartTime], [LastRun], [NextRun], [Enabled], [PriorityID], [HistoriesNumber], [MaxExecutionTime], [WeekMonthDay]) VALUES (1, N'SCHEDULE_TASK_CALCULATE_PACKAGES_DISKSPACE', 1, N'Calculate Disk Space', N'Daily', 0, CAST(0x00008EAC00C5C100 AS DateTime), CAST(0x00008EAC00C5C100 AS DateTime), CAST(0x00008EAC00CDFE60 AS DateTime), NULL, CAST(0x00009DB500F547F5 AS DateTime), 1, N'Normal', 7, 3600, 1) +GO +INSERT [dbo].[Schedule] ([ScheduleID], [TaskID], [PackageID], [ScheduleName], [ScheduleTypeID], [Interval], [FromTime], [ToTime], [StartTime], [LastRun], [NextRun], [Enabled], [PriorityID], [HistoriesNumber], [MaxExecutionTime], [WeekMonthDay]) VALUES (2, N'SCHEDULE_TASK_CALCULATE_PACKAGES_BANDWIDTH', 1, N'Calculate Bandwidth', N'Daily', 0, CAST(0x00008EAC00C5C100 AS DateTime), CAST(0x00008EAC00C5C100 AS DateTime), CAST(0x00008EAC00C5C100 AS DateTime), NULL, CAST(0x00009DB500F547F7 AS DateTime), 1, N'Normal', 7, 3600, 1) +GO +SET IDENTITY_INSERT [dbo].[Schedule] OFF +GO +INSERT [dbo].[ScheduleParameters] ([ScheduleID], [ParameterID], [ParameterValue]) VALUES (1, N'SUSPEND_OVERUSED', N'false') +GO +INSERT [dbo].[ScheduleParameters] ([ScheduleID], [ParameterID], [ParameterValue]) VALUES (2, N'SUSPEND_OVERUSED', N'false') +GO +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_BACKUP', N'BACKUP_FILE_NAME', N'String', N'', 1) +GO +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_BACKUP', N'DELETE_TEMP_BACKUP', N'Boolean', N'true', 1) +GO +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_BACKUP', N'STORE_PACKAGE_FOLDER', N'String', N'\', 1) +GO +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_BACKUP', N'STORE_PACKAGE_ID', N'String', N'', 1) +GO +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_BACKUP', N'STORE_SERVER_FOLDER', N'String', N'', 1) +GO +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_BACKUP_DATABASE', N'BACKUP_FOLDER', N'String', N'\backups', 3) +GO +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_BACKUP_DATABASE', N'BACKUP_NAME', N'String', N'database_backup.bak', 4) +GO +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_BACKUP_DATABASE', N'DATABASE_GROUP', N'List', N'MsSQL2000=SQL Server 2000;MsSQL2005=SQL Server 2005;MsSQL2008=SQL Server 2008;MsSQL2012=SQL Server 2012;MySQL4=MySQL 4.0;MySQL5=MySQL 5.0', 1) +GO +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_BACKUP_DATABASE', N'DATABASE_NAME', N'String', N'', 2) +GO +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_BACKUP_DATABASE', N'ZIP_BACKUP', N'List', N'true=Yes;false=No', 5) +GO +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_CHECK_WEBSITE', N'MAIL_BODY', N'MultiString', N'', 10) +GO +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_CHECK_WEBSITE', N'MAIL_FROM', N'String', N'admin@mysite.com', 7) +GO +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_CHECK_WEBSITE', N'MAIL_SUBJECT', N'String', N'Web Site is unavailable', 9) +GO +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_CHECK_WEBSITE', N'MAIL_TO', N'String', N'admin@mysite.com', 8) +GO +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_CHECK_WEBSITE', N'PASSWORD', N'String', NULL, 3) +GO +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_CHECK_WEBSITE', N'RESPONSE_CONTAIN', N'String', NULL, 5) +GO +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_CHECK_WEBSITE', N'RESPONSE_DOESNT_CONTAIN', N'String', NULL, 6) +GO +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_CHECK_WEBSITE', N'RESPONSE_STATUS', N'String', N'500', 4) +GO +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_CHECK_WEBSITE', N'URL', N'String', N'http://', 1) +GO +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_CHECK_WEBSITE', N'USE_RESPONSE_CONTAIN', N'Boolean', N'false', 1) +GO +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_CHECK_WEBSITE', N'USE_RESPONSE_DOESNT_CONTAIN', N'Boolean', N'false', 1) +GO +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_CHECK_WEBSITE', N'USE_RESPONSE_STATUS', N'Boolean', N'false', 1) +GO +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_CHECK_WEBSITE', N'USERNAME', N'String', NULL, 2) +GO +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_FTP_FILES', N'FILE_PATH', N'String', N'\', 1) +GO +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_FTP_FILES', N'FTP_FOLDER', N'String', NULL, 5) +GO +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_FTP_FILES', N'FTP_PASSWORD', N'String', NULL, 4) +GO +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_FTP_FILES', N'FTP_SERVER', N'String', N'ftp.myserver.com', 2) +GO +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_FTP_FILES', N'FTP_USERNAME', N'String', NULL, 3) +GO +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_HOSTED_SOLUTION_REPORT', N'CRM_REPORT', N'Boolean', N'true', 3) +GO +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_HOSTED_SOLUTION_REPORT', N'EMAIL', N'String', NULL, 5) +GO +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_HOSTED_SOLUTION_REPORT', N'EXCHANGE_REPORT', N'Boolean', N'true', 1) +GO +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_HOSTED_SOLUTION_REPORT', N'LYNC_REPORT', N'Boolean', N'true', 5) +GO +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_HOSTED_SOLUTION_REPORT', N'ORGANIZATION_REPORT', N'Boolean', N'true', 4) +GO +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_HOSTED_SOLUTION_REPORT', N'SHAREPOINT_REPORT', N'Boolean', N'true', 2) +GO +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_NOTIFY_OVERUSED_DATABASES', N'MSSQL_OVERUSED', N'Boolean', N'true', 1) +GO +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_NOTIFY_OVERUSED_DATABASES', N'MYSQL_OVERUSED', N'Boolean', N'true', 1) +GO +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_NOTIFY_OVERUSED_DATABASES', N'OVERUSED_MAIL_BCC', N'String', N'', 1) +GO +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_NOTIFY_OVERUSED_DATABASES', N'OVERUSED_MAIL_BODY', N'String', N'', 1) +GO +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_NOTIFY_OVERUSED_DATABASES', N'OVERUSED_MAIL_FROM', N'String', N'', 1) +GO +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_NOTIFY_OVERUSED_DATABASES', N'OVERUSED_MAIL_SUBJECT', N'String', N'', 1) +GO +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_NOTIFY_OVERUSED_DATABASES', N'OVERUSED_USAGE_THRESHOLD', N'String', N'100', 1) +GO +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_NOTIFY_OVERUSED_DATABASES', N'SEND_OVERUSED_EMAIL', N'Boolean', N'true', 1) +GO +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_NOTIFY_OVERUSED_DATABASES', N'SEND_WARNING_EMAIL', N'Boolean', N'true', 1) +GO +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_NOTIFY_OVERUSED_DATABASES', N'WARNING_MAIL_BCC', N'String', N'', 1) +GO +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_NOTIFY_OVERUSED_DATABASES', N'WARNING_MAIL_BODY', N'String', N'', 1) +GO +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_NOTIFY_OVERUSED_DATABASES', N'WARNING_MAIL_FROM', N'String', N'', 1) +GO +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_NOTIFY_OVERUSED_DATABASES', N'WARNING_MAIL_SUBJECT', N'String', N'', 1) +GO +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_NOTIFY_OVERUSED_DATABASES', N'WARNING_USAGE_THRESHOLD', N'String', N'80', 1) +GO +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_RUN_SYSTEM_COMMAND', N'EXECUTABLE_PARAMS', N'String', N'', 3) +GO +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_RUN_SYSTEM_COMMAND', N'EXECUTABLE_PATH', N'String', N'Executable.exe', 2) +GO +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_RUN_SYSTEM_COMMAND', N'SERVER_NAME', N'String', NULL, 1) +GO +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_SEND_MAIL', N'MAIL_BODY', N'MultiString', NULL, 4) +GO +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_SEND_MAIL', N'MAIL_FROM', N'String', NULL, 1) +GO +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_SEND_MAIL', N'MAIL_SUBJECT', N'String', NULL, 3) +GO +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_SEND_MAIL', N'MAIL_TO', N'String', NULL, 2) +GO +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_SUSPEND_PACKAGES', N'BANDWIDTH_OVERUSED', N'Boolean', N'true', 1) +GO +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_SUSPEND_PACKAGES', N'DISKSPACE_OVERUSED', N'Boolean', N'true', 1) +GO +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_SUSPEND_PACKAGES', N'SEND_SUSPENSION_EMAIL', N'Boolean', N'true', 1) +GO +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_SUSPEND_PACKAGES', N'SEND_WARNING_EMAIL', N'Boolean', N'true', 1) +GO +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_SUSPEND_PACKAGES', N'SUSPEND_OVERUSED', N'Boolean', N'true', 1) +GO +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_SUSPEND_PACKAGES', N'SUSPENSION_MAIL_BCC', N'String', NULL, 1) +GO +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_SUSPEND_PACKAGES', N'SUSPENSION_MAIL_BODY', N'String', NULL, 1) +GO +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_SUSPEND_PACKAGES', N'SUSPENSION_MAIL_FROM', N'String', NULL, 1) +GO +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_SUSPEND_PACKAGES', N'SUSPENSION_MAIL_SUBJECT', N'String', NULL, 1) +GO +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_SUSPEND_PACKAGES', N'SUSPENSION_USAGE_THRESHOLD', N'String', N'100', 1) +GO +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_SUSPEND_PACKAGES', N'WARNING_MAIL_BCC', N'String', NULL, 1) +GO +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_SUSPEND_PACKAGES', N'WARNING_MAIL_BODY', N'String', NULL, 1) +GO +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_SUSPEND_PACKAGES', N'WARNING_MAIL_FROM', N'String', NULL, 1) +GO +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_SUSPEND_PACKAGES', N'WARNING_MAIL_SUBJECT', N'String', NULL, 1) +GO +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_SUSPEND_PACKAGES', N'WARNING_USAGE_THRESHOLD', N'String', N'80', 1) +GO +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_ZIP_FILES', N'FOLDER', N'String', NULL, 1) +GO +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_ZIP_FILES', N'ZIP_FILE', N'String', N'\archive.zip', 2) +GO +INSERT [dbo].[ScheduleTasks] ([TaskID], [TaskType], [RoleID]) VALUES (N'SCHEDULE_TASK_ACTIVATE_PAID_INVOICES', N'WebsitePanel.Ecommerce.EnterpriseServer.ActivatePaidInvoicesTask, WebsitePanel.EnterpriseServer', 2) +GO +INSERT [dbo].[ScheduleTasks] ([TaskID], [TaskType], [RoleID]) VALUES (N'SCHEDULE_TASK_BACKUP', N'WebsitePanel.EnterpriseServer.BackupTask, WebsitePanel.EnterpriseServer', 1) +GO +INSERT [dbo].[ScheduleTasks] ([TaskID], [TaskType], [RoleID]) VALUES (N'SCHEDULE_TASK_BACKUP_DATABASE', N'WebsitePanel.EnterpriseServer.BackupDatabaseTask, WebsitePanel.EnterpriseServer', 3) +GO +INSERT [dbo].[ScheduleTasks] ([TaskID], [TaskType], [RoleID]) VALUES (N'SCHEDULE_TASK_CALCULATE_EXCHANGE_DISKSPACE', N'WebsitePanel.EnterpriseServer.CalculateExchangeDiskspaceTask, WebsitePanel.EnterpriseServer', 2) +GO +INSERT [dbo].[ScheduleTasks] ([TaskID], [TaskType], [RoleID]) VALUES (N'SCHEDULE_TASK_CALCULATE_PACKAGES_BANDWIDTH', N'WebsitePanel.EnterpriseServer.CalculatePackagesBandwidthTask, WebsitePanel.EnterpriseServer', 1) +GO +INSERT [dbo].[ScheduleTasks] ([TaskID], [TaskType], [RoleID]) VALUES (N'SCHEDULE_TASK_CALCULATE_PACKAGES_DISKSPACE', N'WebsitePanel.EnterpriseServer.CalculatePackagesDiskspaceTask, WebsitePanel.EnterpriseServer', 1) +GO +INSERT [dbo].[ScheduleTasks] ([TaskID], [TaskType], [RoleID]) VALUES (N'SCHEDULE_TASK_CANCEL_OVERDUE_INVOICES', N'WebsitePanel.Ecommerce.EnterpriseServer.CancelOverdueInvoicesTask, WebsitePanel.EnterpriseServer', 2) +GO +INSERT [dbo].[ScheduleTasks] ([TaskID], [TaskType], [RoleID]) VALUES (N'SCHEDULE_TASK_CHECK_WEBSITE', N'WebsitePanel.EnterpriseServer.CheckWebSiteTask, WebsitePanel.EnterpriseServer', 3) +GO +INSERT [dbo].[ScheduleTasks] ([TaskID], [TaskType], [RoleID]) VALUES (N'SCHEDULE_TASK_FTP_FILES', N'WebsitePanel.EnterpriseServer.FTPFilesTask, WebsitePanel.EnterpriseServer', 3) +GO +INSERT [dbo].[ScheduleTasks] ([TaskID], [TaskType], [RoleID]) VALUES (N'SCHEDULE_TASK_GENERATE_INVOICES', N'WebsitePanel.Ecommerce.EnterpriseServer.GenerateInvoicesTask, WebsitePanel.EnterpriseServer', 2) +GO +INSERT [dbo].[ScheduleTasks] ([TaskID], [TaskType], [RoleID]) VALUES (N'SCHEDULE_TASK_HOSTED_SOLUTION_REPORT', N'WebsitePanel.EnterpriseServer.HostedSolutionReportTask, WebsitePanel.EnterpriseServer', 2) +GO +INSERT [dbo].[ScheduleTasks] ([TaskID], [TaskType], [RoleID]) VALUES (N'SCHEDULE_TASK_NOTIFY_OVERUSED_DATABASES', N'WebsitePanel.EnterpriseServer.NotifyOverusedDatabasesTask, WebsitePanel.EnterpriseServer', 2) +GO +INSERT [dbo].[ScheduleTasks] ([TaskID], [TaskType], [RoleID]) VALUES (N'SCHEDULE_TASK_RUN_PAYMENT_QUEUE', N'WebsitePanel.Ecommerce.EnterpriseServer.RunPaymentQueueTask, WebsitePanel.EnterpriseServer', 2) +GO +INSERT [dbo].[ScheduleTasks] ([TaskID], [TaskType], [RoleID]) VALUES (N'SCHEDULE_TASK_RUN_SYSTEM_COMMAND', N'WebsitePanel.EnterpriseServer.RunSystemCommandTask, WebsitePanel.EnterpriseServer', 1) +GO +INSERT [dbo].[ScheduleTasks] ([TaskID], [TaskType], [RoleID]) VALUES (N'SCHEDULE_TASK_SEND_MAIL', N'WebsitePanel.EnterpriseServer.SendMailNotificationTask, WebsitePanel.EnterpriseServer', 3) +GO +INSERT [dbo].[ScheduleTasks] ([TaskID], [TaskType], [RoleID]) VALUES (N'SCHEDULE_TASK_SUSPEND_OVERDUE_INVOICES', N'WebsitePanel.Ecommerce.EnterpriseServer.SuspendOverdueInvoicesTask, WebsitePanel.EnterpriseServer', 2) +GO +INSERT [dbo].[ScheduleTasks] ([TaskID], [TaskType], [RoleID]) VALUES (N'SCHEDULE_TASK_SUSPEND_PACKAGES', N'WebsitePanel.EnterpriseServer.SuspendOverusedPackagesTask, WebsitePanel.EnterpriseServer', 2) +GO +INSERT [dbo].[ScheduleTasks] ([TaskID], [TaskType], [RoleID]) VALUES (N'SCHEDULE_TASK_ZIP_FILES', N'WebsitePanel.EnterpriseServer.ZipFilesTask, WebsitePanel.EnterpriseServer', 3) +GO +INSERT [dbo].[ScheduleTaskViewConfiguration] ([TaskID], [ConfigurationID], [Environment], [Description]) VALUES (N'SCHEDULE_TASK_ACTIVATE_PAID_INVOICES', N'ASP_NET', N'ASP.NET', N'~/DesktopModules/WebsitePanel/ScheduleTaskControls/EmptyView.ascx') +GO +INSERT [dbo].[ScheduleTaskViewConfiguration] ([TaskID], [ConfigurationID], [Environment], [Description]) VALUES (N'SCHEDULE_TASK_BACKUP', N'ASP_NET', N'ASP.NET', N'~/DesktopModules/WebsitePanel/ScheduleTaskControls/Backup.ascx') +GO +INSERT [dbo].[ScheduleTaskViewConfiguration] ([TaskID], [ConfigurationID], [Environment], [Description]) VALUES (N'SCHEDULE_TASK_BACKUP_DATABASE', N'ASP_NET', N'ASP.NET', N'~/DesktopModules/WebsitePanel/ScheduleTaskControls/BackupDatabase.ascx') +GO +INSERT [dbo].[ScheduleTaskViewConfiguration] ([TaskID], [ConfigurationID], [Environment], [Description]) VALUES (N'SCHEDULE_TASK_CALCULATE_EXCHANGE_DISKSPACE', N'ASP_NET', N'ASP.NET', N'~/DesktopModules/WebsitePanel/ScheduleTaskControls/EmptyView.ascx') +GO +INSERT [dbo].[ScheduleTaskViewConfiguration] ([TaskID], [ConfigurationID], [Environment], [Description]) VALUES (N'SCHEDULE_TASK_CALCULATE_PACKAGES_BANDWIDTH', N'ASP_NET', N'ASP.NET', N'~/DesktopModules/WebsitePanel/ScheduleTaskControls/EmptyView.ascx') +GO +INSERT [dbo].[ScheduleTaskViewConfiguration] ([TaskID], [ConfigurationID], [Environment], [Description]) VALUES (N'SCHEDULE_TASK_CALCULATE_PACKAGES_DISKSPACE', N'ASP_NET', N'ASP.NET', N'~/DesktopModules/WebsitePanel/ScheduleTaskControls/EmptyView.ascx') +GO +INSERT [dbo].[ScheduleTaskViewConfiguration] ([TaskID], [ConfigurationID], [Environment], [Description]) VALUES (N'SCHEDULE_TASK_CANCEL_OVERDUE_INVOICES', N'ASP_NET', N'ASP.NET', N'~/DesktopModules/WebsitePanel/ScheduleTaskControls/EmptyView.ascx') +GO +INSERT [dbo].[ScheduleTaskViewConfiguration] ([TaskID], [ConfigurationID], [Environment], [Description]) VALUES (N'SCHEDULE_TASK_CHECK_WEBSITE', N'ASP_NET', N'ASP.NET', N'~/DesktopModules/WebsitePanel/ScheduleTaskControls/CheckWebsite.ascx') +GO +INSERT [dbo].[ScheduleTaskViewConfiguration] ([TaskID], [ConfigurationID], [Environment], [Description]) VALUES (N'SCHEDULE_TASK_FTP_FILES', N'ASP_NET', N'ASP.NET', N'~/DesktopModules/WebsitePanel/ScheduleTaskControls/SendFilesViaFtp.ascx') +GO +INSERT [dbo].[ScheduleTaskViewConfiguration] ([TaskID], [ConfigurationID], [Environment], [Description]) VALUES (N'SCHEDULE_TASK_GENERATE_INVOICES', N'ASP_NET', N'ASP.NET', N'~/DesktopModules/WebsitePanel/ScheduleTaskControls/EmptyView.ascx') +GO +INSERT [dbo].[ScheduleTaskViewConfiguration] ([TaskID], [ConfigurationID], [Environment], [Description]) VALUES (N'SCHEDULE_TASK_HOSTED_SOLUTION_REPORT', N'ASP_NET', N'ASP.NET', N'~/DesktopModules/WebsitePanel/ScheduleTaskControls/HostedSolutionReport.ascx') +GO +INSERT [dbo].[ScheduleTaskViewConfiguration] ([TaskID], [ConfigurationID], [Environment], [Description]) VALUES (N'SCHEDULE_TASK_NOTIFY_OVERUSED_DATABASES', N'ASP_NET', N'ASP.NET', N'~/DesktopModules/WebsitePanel/ScheduleTaskControls/NotifyOverusedDatabases.ascx') +GO +INSERT [dbo].[ScheduleTaskViewConfiguration] ([TaskID], [ConfigurationID], [Environment], [Description]) VALUES (N'SCHEDULE_TASK_RUN_PAYMENT_QUEUE', N'ASP_NET', N'ASP.NET', N'~/DesktopModules/WebsitePanel/ScheduleTaskControls/EmptyView.ascx') +GO +INSERT [dbo].[ScheduleTaskViewConfiguration] ([TaskID], [ConfigurationID], [Environment], [Description]) VALUES (N'SCHEDULE_TASK_RUN_SYSTEM_COMMAND', N'ASP_NET', N'ASP.NET', N'~/DesktopModules/WebsitePanel/ScheduleTaskControls/ExecuteSystemCommand.ascx') +GO +INSERT [dbo].[ScheduleTaskViewConfiguration] ([TaskID], [ConfigurationID], [Environment], [Description]) VALUES (N'SCHEDULE_TASK_SEND_MAIL', N'ASP_NET', N'ASP.NET', N'~/DesktopModules/WebsitePanel/ScheduleTaskControls/SendEmailNotification.ascx') +GO +INSERT [dbo].[ScheduleTaskViewConfiguration] ([TaskID], [ConfigurationID], [Environment], [Description]) VALUES (N'SCHEDULE_TASK_SUSPEND_OVERDUE_INVOICES', N'ASP_NET', N'ASP.NET', N'~/DesktopModules/WebsitePanel/ScheduleTaskControls/EmptyView.ascx') +GO +INSERT [dbo].[ScheduleTaskViewConfiguration] ([TaskID], [ConfigurationID], [Environment], [Description]) VALUES (N'SCHEDULE_TASK_SUSPEND_PACKAGES', N'ASP_NET', N'ASP.NET', N'~/DesktopModules/WebsitePanel/ScheduleTaskControls/SuspendOverusedSpaces.ascx') +GO +INSERT [dbo].[ScheduleTaskViewConfiguration] ([TaskID], [ConfigurationID], [Environment], [Description]) VALUES (N'SCHEDULE_TASK_ZIP_FILES', N'ASP_NET', N'ASP.NET', N'~/DesktopModules/WebsitePanel/ScheduleTaskControls/ZipFiles.ascx') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (1, N'UsersHome', N'%SYSTEMDRIVE%\HostingSpaces') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (2, N'AspNet11Path', N'%SYSTEMROOT%\Microsoft.NET\Framework\v1.1.4322\aspnet_isapi.dll') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (2, N'AspNet11Pool', N'ASP.NET V1.1') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (2, N'AspNet20Path', N'%SYSTEMROOT%\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (2, N'AspNet20Pool', N'ASP.NET V2.0') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (2, N'AspNet40Path', N'%SYSTEMROOT%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (2, N'AspNet40Pool', N'ASP.NET V4.0') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (2, N'AspPath', N'%SYSTEMROOT%\System32\InetSrv\asp.dll') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (2, N'CFFlashRemotingDirectory', N'C:\ColdFusion9\runtime\lib\wsconfig\1') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (2, N'CFScriptsDirectory', N'C:\Inetpub\wwwroot\CFIDE') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (2, N'ColdFusionPath', N'C:\ColdFusion9\runtime\lib\wsconfig\jrun_iis6.dll') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (2, N'GalleryXmlFeedUrl', N'') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (2, N'PerlPath', N'%SYSTEMDRIVE%\Perl\bin\Perl.exe') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (2, N'Php4Path', N'%PROGRAMFILES%\PHP\php.exe') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (2, N'Php5Path', N'%PROGRAMFILES%\PHP\php-cgi.exe') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (2, N'ProtectedAccessFile', N'.htaccess') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (2, N'ProtectedFoldersFile', N'.htfolders') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (2, N'ProtectedGroupsFile', N'.htgroup') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (2, N'ProtectedUsersFile', N'.htpasswd') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (2, N'PythonPath', N'%SYSTEMDRIVE%\Python\python.exe') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (2, N'SecuredFoldersFilterPath', N'%SYSTEMROOT%\System32\InetSrv\IISPasswordFilter.dll') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (2, N'WebGroupName', N'WSPWebUsers') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (3, N'FtpGroupName', N'WSPFtpUsers') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (3, N'SiteId', N'MSFTPSVC/1') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (5, N'DatabaseLocation', N'%SYSTEMDRIVE%\SQL2000Databases\[USER_NAME]') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (5, N'ExternalAddress', N'(local)') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (5, N'InternalAddress', N'(local)') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (5, N'SaLogin', N'sa') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (5, N'SaPassword', N'') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (5, N'UseDefaultDatabaseLocation', N'True') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (5, N'UseTrustedConnection', N'True') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (6, N'ExternalAddress', N'localhost') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (6, N'InstallFolder', N'%PROGRAMFILES%\MySQL\MySQL Server 4.1') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (6, N'InternalAddress', N'localhost,3306') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (6, N'RootLogin', N'root') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (6, N'RootPassword', N'') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (7, N'ExpireLimit', N'1209600') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (7, N'MinimumTTL', N'86400') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (7, N'NameServers', N'ns1.yourdomain.com;ns2.yourdomain.com') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (7, N'RefreshInterval', N'3600') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (7, N'ResponsiblePerson', N'hostmaster.[DOMAIN_NAME]') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (7, N'RetryDelay', N'600') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (8, N'AwStatsFolder', N'%SYSTEMDRIVE%\AWStats\wwwroot\cgi-bin') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (8, N'BatchFileName', N'UpdateStats.bat') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (8, N'BatchLineTemplate', N'%SYSTEMDRIVE%\perl\bin\perl.exe awstats.pl config=[DOMAIN_NAME] -update') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (8, N'ConfigFileName', N'awstats.[DOMAIN_NAME].conf') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (8, N'ConfigFileTemplate', N'LogFormat = "%time2 %other %other %other %method %url %other %other %logname %host %other %ua %other %referer %other %code %other %other %bytesd %other %other" +LogSeparator = " " +DNSLookup = 2 +DirCgi = "/cgi-bin" +DirIcons = "/icon" +AllowFullYearView=3 +AllowToUpdateStatsFromBrowser = 0 +UseFramesWhenCGI = 1 +ShowFlagLinks = "en fr de it nl es" +LogFile = "[LOGS_FOLDER]\ex%YY-3%MM-3%DD-3.log" +DirData = "%SYSTEMDRIVE%\AWStats\data" +SiteDomain = "[DOMAIN_NAME]" +HostAliases = [DOMAIN_ALIASES]') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (8, N'StatisticsURL', N'http://127.0.0.1/AWStats/cgi-bin/awstats.pl?config=[domain_name]') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (9, N'AdminLogin', N'Admin') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (9, N'ExpireLimit', N'1209600') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (9, N'MinimumTTL', N'86400') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (9, N'NameServers', N'ns1.yourdomain.com;ns2.yourdomain.com') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (9, N'RefreshInterval', N'3600') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (9, N'ResponsiblePerson', N'hostmaster.[DOMAIN_NAME]') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (9, N'RetryDelay', N'600') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (9, N'SimpleDnsUrl', N'http://127.0.0.1:8053') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (10, N'LogDeleteDays', N'0') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (10, N'LogFormat', N'W3Cex') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (10, N'LogWildcard', N'*.log') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (10, N'Password', N'') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (10, N'ServerID', N'1') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (10, N'SmarterLogDeleteMonths', N'0') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (10, N'SmarterLogsPath', N'%SYSTEMDRIVE%\SmarterLogs') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (10, N'SmarterUrl', N'http://127.0.0.1:9999/services') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (10, N'StatisticsURL', N'http://127.0.0.1:9999/Login.aspx?txtSiteID=[site_id]&txtUser=[username]&txtPass=[password]&shortcutLink=autologin') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (10, N'TimeZoneId', N'27') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (10, N'Username', N'Admin') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (11, N'AdminPassword', N'') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (11, N'AdminUsername', N'admin') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (11, N'DomainsPath', N'%SYSTEMDRIVE%\SmarterMail') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (11, N'ServerIPAddress', N'127.0.0.1;127.0.0.1') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (11, N'ServiceUrl', N'http://127.0.0.1:9998/services') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (12, N'InstallFolder', N'%PROGRAMFILES%\Gene6 FTP Server') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (12, N'LogsFolder', N'%PROGRAMFILES%\Gene6 FTP Server\Log') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (14, N'AdminPassword', N'') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (14, N'AdminUsername', N'admin') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (14, N'DomainsPath', N'%SYSTEMDRIVE%\SmarterMail') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (14, N'ServerIPAddress', N'127.0.0.1;127.0.0.1') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (14, N'ServiceUrl', N'http://127.0.0.1:9998/services') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (16, N'BrowseMethod', N'POST') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (16, N'BrowseParameters', N'ServerName=[SERVER] +Login=[USER] +Password=[PASSWORD] +Protocol=dbmssocn') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (16, N'BrowseURL', N'http://localhost/MLA/silentlogon.aspx') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (16, N'DatabaseLocation', N'%SYSTEMDRIVE%\SQL2005Databases\[USER_NAME]') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (16, N'ExternalAddress', N'(local)') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (16, N'InternalAddress', N'(local)') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (16, N'SaLogin', N'sa') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (16, N'SaPassword', N'') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (16, N'UseDefaultDatabaseLocation', N'True') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (16, N'UseTrustedConnection', N'True') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (17, N'ExternalAddress', N'localhost') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (17, N'InstallFolder', N'%PROGRAMFILES%\MySQL\MySQL Server 5.0') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (17, N'InternalAddress', N'localhost,3306') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (17, N'RootLogin', N'root') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (17, N'RootPassword', N'') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (22, N'AdminPassword', N'') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (22, N'AdminUsername', N'Administrator') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (24, N'BindConfigPath', N'c:\BIND\dns\etc\named.conf') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (24, N'BindReloadBatch', N'c:\BIND\dns\reload.bat') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (24, N'ExpireLimit', N'1209600') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (24, N'MinimumTTL', N'86400') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (24, N'NameServers', N'ns1.yourdomain.com;ns2.yourdomain.com') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (24, N'RefreshInterval', N'3600') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (24, N'ResponsiblePerson', N'hostmaster.[DOMAIN_NAME]') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (24, N'RetryDelay', N'600') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (24, N'ZoneFileNameTemplate', N'db.[domain_name].txt') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (24, N'ZonesFolderPath', N'c:\BIND\dns\zones') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (25, N'DomainId', N'1') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (27, N'KeepDeletedItemsDays', N'14') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (27, N'KeepDeletedMailboxesDays', N'30') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (27, N'MailboxDatabase', N'Hosted Exchange Database') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (27, N'RootOU', N'WSP Hosting') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (27, N'StorageGroup', N'Hosted Exchange Storage Group') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (27, N'TempDomain', N'my-temp-domain.com') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (28, N'AdminLogin', N'Admin') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (28, N'ExpireLimit', N'1209600') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (28, N'MinimumTTL', N'86400') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (28, N'NameServers', N'ns1.yourdomain.com;ns2.yourdomain.com') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (28, N'RefreshInterval', N'3600') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (28, N'ResponsiblePerson', N'hostmaster.[DOMAIN_NAME]') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (28, N'RetryDelay', N'600') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (28, N'SimpleDnsUrl', N'http://127.0.0.1:8053') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (29, N'AdminPassword', N' ') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (29, N'AdminUsername', N'admin') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (29, N'DomainsPath', N'%SYSTEMDRIVE%\SmarterMail') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (29, N'ServerIPAddress', N'127.0.0.1;127.0.0.1') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (29, N'ServiceUrl', N'http://localhost:9998/services/') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (30, N'ExternalAddress', N'localhost') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (30, N'InstallFolder', N'%PROGRAMFILES%\MySQL\MySQL Server 5.1') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (30, N'InternalAddress', N'localhost,3306') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (30, N'RootLogin', N'root') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (30, N'RootPassword', N'') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (31, N'LogDeleteDays', N'0') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (31, N'LogFormat', N'W3Cex') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (31, N'LogWildcard', N'*.log') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (31, N'Password', N'') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (31, N'ServerID', N'1') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (31, N'SmarterLogDeleteMonths', N'0') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (31, N'SmarterLogsPath', N'%SYSTEMDRIVE%\SmarterLogs') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (31, N'SmarterUrl', N'http://127.0.0.1:9999/services') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (31, N'StatisticsURL', N'http://127.0.0.1:9999/Login.aspx?txtSiteID=[site_id]&txtUser=[username]&txtPass=[password]&shortcutLink=autologin') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (31, N'TimeZoneId', N'27') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (31, N'Username', N'Admin') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (32, N'KeepDeletedItemsDays', N'14') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (32, N'KeepDeletedMailboxesDays', N'30') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (32, N'MailboxDatabase', N'Hosted Exchange Database') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (32, N'RootOU', N'WSP Hosting') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (32, N'TempDomain', N'my-temp-domain.com') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (56, N'ExpireLimit', N'1209600') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (56, N'MinimumTTL', N'86400') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (56, N'NameServers', N'ns1.yourdomain.com;ns2.yourdomain.com') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (56, N'PDNSDbName', N'pdnsdb') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (56, N'PDNSDbPort', N'3306') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (56, N'PDNSDbServer', N'localhost') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (56, N'PDNSDbUser', N'root') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (56, N'RefreshInterval', N'3600') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (56, N'ResponsiblePerson', N'hostmaster.[DOMAIN_NAME]') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (56, N'RetryDelay', N'600') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (60, N'AdminPassword', N' ') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (60, N'AdminUsername', N'admin') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (60, N'DomainsPath', N'%SYSTEMDRIVE%\SmarterMail') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (60, N'ServerIPAddress', N'127.0.0.1;127.0.0.1') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (60, N'ServiceUrl', N'http://localhost:9998/services/') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (62, N'LogDeleteDays', N'0') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (62, N'LogFormat', N'W3Cex') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (62, N'LogWildcard', N'*.log') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (62, N'Password', N'') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (62, N'ServerID', N'1') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (62, N'SmarterLogDeleteMonths', N'0') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (62, N'SmarterLogsPath', N'%SYSTEMDRIVE%\SmarterLogs') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (62, N'SmarterUrl', N'http://127.0.0.1:9999/services') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (62, N'StatisticsURL', N'http://127.0.0.1:9999/Login.aspx?txtSiteID=[site_id]&txtUser=[username]&txtPass=[password]&shortcutLink=autologin') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (62, N'TimeZoneId', N'27') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (62, N'Username', N'Admin') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (63, N'AdminPassword', N'') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (63, N'AdminUsername', N'Administrator') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (64, N'AdminPassword', N'') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (64, N'AdminUsername', N'admin') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (64, N'DomainsPath', N'%SYSTEMDRIVE%\SmarterMail') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (64, N'ServerIPAddress', N'127.0.0.1;127.0.0.1') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (64, N'ServiceUrl', N'http://localhost:9998/services/') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (65, N'AdminPassword', N'') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (65, N'AdminUsername', N'admin') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (65, N'DomainsPath', N'%SYSTEMDRIVE%\SmarterMail') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (65, N'ServerIPAddress', N'127.0.0.1;127.0.0.1') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (65, N'ServiceUrl', N'http://localhost:9998/services/') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (66, N'AdminPassword', N'') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (66, N'AdminUsername', N'admin') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (66, N'DomainsPath', N'%SYSTEMDRIVE%\SmarterMail') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (66, N'ServerIPAddress', N'127.0.0.1;127.0.0.1') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (66, N'ServiceUrl', N'http://localhost:9998/services/') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (100, N'UsersHome', N'%SYSTEMDRIVE%\HostingSpaces') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (101, N'AspNet11Pool', N'ASP.NET 1.1') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (101, N'AspNet40Path', N'%WINDIR%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (101, N'AspNet40x64Path', N'%WINDIR%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (101, N'AspNetBitnessMode', N'32') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (101, N'CFFlashRemotingDirectory', N'C:\ColdFusion9\runtime\lib\wsconfig\1') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (101, N'CFScriptsDirectory', N'C:\Inetpub\wwwroot\CFIDE') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (101, N'ClassicAspNet20Pool', N'ASP.NET 2.0 (Classic)') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (101, N'ClassicAspNet40Pool', N'ASP.NET 4.0 (Classic)') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (101, N'ColdFusionPath', N'C:\ColdFusion9\runtime\lib\wsconfig\jrun_iis6.dll') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (101, N'GalleryXmlFeedUrl', N'') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (101, N'IntegratedAspNet20Pool', N'ASP.NET 2.0 (Integrated)') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (101, N'IntegratedAspNet40Pool', N'ASP.NET 4.0 (Integrated)') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (101, N'PerlPath', N'%SYSTEMDRIVE%\Perl\bin\PerlEx30.dll') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (101, N'Php4Path', N'%PROGRAMFILES(x86)%\PHP\php.exe') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (101, N'PhpMode', N'FastCGI') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (101, N'PhpPath', N'%PROGRAMFILES(x86)%\PHP\php-cgi.exe') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (101, N'ProtectedGroupsFile', N'.htgroup') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (101, N'ProtectedUsersFile', N'.htpasswd') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (101, N'SecureFoldersModuleAssembly', N'WebsitePanel.IIsModules.SecureFolders, WebsitePanel.IIsModules, Version=1.0.0.0, Culture=Neutral, PublicKeyToken=37f9c58a0aa32ff0') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (101, N'WebGroupName', N'WSP_IUSRS') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (101, N'WmSvc.CredentialsMode', N'WINDOWS') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (101, N'WmSvc.Port', N'8172') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (102, N'FtpGroupName', N'WSPFtpUsers') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (102, N'SiteId', N'Default FTP Site') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (104, N'UsersHome', N'%SYSTEMDRIVE%\HostingSpaces') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (105, N'AspNet11Pool', N'ASP.NET 1.1') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (105, N'AspNet40Path', N'%WINDIR%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (105, N'AspNet40x64Path', N'%WINDIR%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (105, N'AspNetBitnessMode', N'32') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (105, N'CFFlashRemotingDirectory', N'C:\ColdFusion9\runtime\lib\wsconfig\1') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (105, N'CFScriptsDirectory', N'C:\Inetpub\wwwroot\CFIDE') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (105, N'ClassicAspNet20Pool', N'ASP.NET 2.0 (Classic)') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (105, N'ClassicAspNet40Pool', N'ASP.NET 4.0 (Classic)') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (105, N'ColdFusionPath', N'C:\ColdFusion9\runtime\lib\wsconfig\jrun_iis6.dll') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (105, N'GalleryXmlFeedUrl', N'') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (105, N'IntegratedAspNet20Pool', N'ASP.NET 2.0 (Integrated)') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (105, N'IntegratedAspNet40Pool', N'ASP.NET 4.0 (Integrated)') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (105, N'PerlPath', N'%SYSTEMDRIVE%\Perl\bin\PerlEx30.dll') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (105, N'Php4Path', N'%PROGRAMFILES(x86)%\PHP\php.exe') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (105, N'PhpMode', N'FastCGI') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (105, N'PhpPath', N'%PROGRAMFILES(x86)%\PHP\php-cgi.exe') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (105, N'ProtectedGroupsFile', N'.htgroup') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (105, N'ProtectedUsersFile', N'.htpasswd') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (105, N'SecureFoldersModuleAssembly', N'WebsitePanel.IIsModules.SecureFolders, WebsitePanel.IIsModules, Version=1.0.0.0, Culture=Neutral, PublicKeyToken=37f9c58a0aa32ff0') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (105, N'WebGroupName', N'WSP_IUSRS') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (105, N'WmSvc.CredentialsMode', N'WINDOWS') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (105, N'WmSvc.Port', N'8172') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (106, N'FtpGroupName', N'WSPFtpUsers') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (106, N'SiteId', N'Default FTP Site') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (200, N'RootWebApplicationIpAddress', N'') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (204, N'UserName', N'admin') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (204, N'UtilityPath', N'C:\Program Files\Research In Motion\BlackBerry Enterprise Server Resource Kit\BlackBerry Enterprise Server User Administration Tool') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (300, N'CpuLimit', N'100') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (300, N'CpuReserve', N'0') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (300, N'CpuWeight', N'100') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (300, N'DvdLibraryPath', N'C:\Hyper-V\Library') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (300, N'ExportedVpsPath', N'C:\Hyper-V\Exported') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (300, N'HostnamePattern', N'vps[user_id].hosterdomain.com') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (300, N'OsTemplatesPath', N'C:\Hyper-V\Templates') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (300, N'PrivateNetworkFormat', N'192.168.0.1/16') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (300, N'RootFolder', N'C:\Hyper-V\VirtualMachines\[VPS_HOSTNAME]') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (300, N'StartAction', N'start') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (300, N'StartupDelay', N'0') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (300, N'StopAction', N'shutDown') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (300, N'VirtualDiskType', N'dynamic') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (301, N'ExternalAddress', N'localhost') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (301, N'InstallFolder', N'%PROGRAMFILES%\MySQL\MySQL Server 5.5') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (301, N'InternalAddress', N'localhost,3306') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (301, N'RootLogin', N'root') +GO +INSERT [dbo].[ServiceDefaultProperties] ([ProviderID], [PropertyName], [PropertyValue]) VALUES (301, N'RootPassword', N'') +GO +INSERT [dbo].[ServiceItemTypes] ([ItemTypeID], [GroupID], [DisplayName], [TypeName], [TypeOrder], [CalculateDiskspace], [CalculateBandwidth], [Suspendable], [Disposable], [Searchable], [Importable], [Backupable]) VALUES (1, 9, N'SharePointUser', N'WebsitePanel.Providers.OS.SystemUser, WebsitePanel.Providers.Base', 19, 0, 0, 1, 1, 1, 1, 1) +GO +INSERT [dbo].[ServiceItemTypes] ([ItemTypeID], [GroupID], [DisplayName], [TypeName], [TypeOrder], [CalculateDiskspace], [CalculateBandwidth], [Suspendable], [Disposable], [Searchable], [Importable], [Backupable]) VALUES (2, 1, N'HomeFolder', N'WebsitePanel.Providers.OS.HomeFolder, WebsitePanel.Providers.Base', 15, 1, 0, 0, 1, 0, 0, 1) +GO +INSERT [dbo].[ServiceItemTypes] ([ItemTypeID], [GroupID], [DisplayName], [TypeName], [TypeOrder], [CalculateDiskspace], [CalculateBandwidth], [Suspendable], [Disposable], [Searchable], [Importable], [Backupable]) VALUES (3, 9, N'SharePointGroup', N'WebsitePanel.Providers.OS.SystemGroup, WebsitePanel.Providers.Base', 20, 0, 0, 0, 1, 1, 1, 1) +GO +INSERT [dbo].[ServiceItemTypes] ([ItemTypeID], [GroupID], [DisplayName], [TypeName], [TypeOrder], [CalculateDiskspace], [CalculateBandwidth], [Suspendable], [Disposable], [Searchable], [Importable], [Backupable]) VALUES (5, 5, N'MsSQL2000Database', N'WebsitePanel.Providers.Database.SqlDatabase, WebsitePanel.Providers.Base', 9, 1, 0, 0, 1, 1, 1, 1) +GO +INSERT [dbo].[ServiceItemTypes] ([ItemTypeID], [GroupID], [DisplayName], [TypeName], [TypeOrder], [CalculateDiskspace], [CalculateBandwidth], [Suspendable], [Disposable], [Searchable], [Importable], [Backupable]) VALUES (6, 5, N'MsSQL2000User', N'WebsitePanel.Providers.Database.SqlUser, WebsitePanel.Providers.Base', 10, 0, 0, 1, 1, 1, 1, 1) +GO +INSERT [dbo].[ServiceItemTypes] ([ItemTypeID], [GroupID], [DisplayName], [TypeName], [TypeOrder], [CalculateDiskspace], [CalculateBandwidth], [Suspendable], [Disposable], [Searchable], [Importable], [Backupable]) VALUES (7, 6, N'MySQL4Database', N'WebsitePanel.Providers.Database.SqlDatabase, WebsitePanel.Providers.Base', 13, 1, 0, 0, 1, 1, 1, 1) +GO +INSERT [dbo].[ServiceItemTypes] ([ItemTypeID], [GroupID], [DisplayName], [TypeName], [TypeOrder], [CalculateDiskspace], [CalculateBandwidth], [Suspendable], [Disposable], [Searchable], [Importable], [Backupable]) VALUES (8, 6, N'MySQL4User', N'WebsitePanel.Providers.Database.SqlUser, WebsitePanel.Providers.Base', 14, 0, 0, 0, 1, 1, 1, 1) +GO +INSERT [dbo].[ServiceItemTypes] ([ItemTypeID], [GroupID], [DisplayName], [TypeName], [TypeOrder], [CalculateDiskspace], [CalculateBandwidth], [Suspendable], [Disposable], [Searchable], [Importable], [Backupable]) VALUES (9, 3, N'FTPAccount', N'WebsitePanel.Providers.FTP.FtpAccount, WebsitePanel.Providers.Base', 3, 0, 1, 1, 1, 1, 1, 1) +GO +INSERT [dbo].[ServiceItemTypes] ([ItemTypeID], [GroupID], [DisplayName], [TypeName], [TypeOrder], [CalculateDiskspace], [CalculateBandwidth], [Suspendable], [Disposable], [Searchable], [Importable], [Backupable]) VALUES (10, 2, N'WebSite', N'WebsitePanel.Providers.Web.WebSite, WebsitePanel.Providers.Base', 2, 1, 1, 1, 1, 1, 1, 1) +GO +INSERT [dbo].[ServiceItemTypes] ([ItemTypeID], [GroupID], [DisplayName], [TypeName], [TypeOrder], [CalculateDiskspace], [CalculateBandwidth], [Suspendable], [Disposable], [Searchable], [Importable], [Backupable]) VALUES (11, 4, N'MailDomain', N'WebsitePanel.Providers.Mail.MailDomain, WebsitePanel.Providers.Base', 8, 0, 1, 1, 1, 1, 1, 1) +GO +INSERT [dbo].[ServiceItemTypes] ([ItemTypeID], [GroupID], [DisplayName], [TypeName], [TypeOrder], [CalculateDiskspace], [CalculateBandwidth], [Suspendable], [Disposable], [Searchable], [Importable], [Backupable]) VALUES (12, 7, N'DNSZone', N'WebsitePanel.Providers.DNS.DnsZone, WebsitePanel.Providers.Base', 0, 0, 0, 1, 1, 0, 1, 1) +GO +INSERT [dbo].[ServiceItemTypes] ([ItemTypeID], [GroupID], [DisplayName], [TypeName], [TypeOrder], [CalculateDiskspace], [CalculateBandwidth], [Suspendable], [Disposable], [Searchable], [Importable], [Backupable]) VALUES (13, 1, N'Domain', N'WebsitePanel.Providers.OS.Domain, WebsitePanel.Providers.Base', 1, 0, 0, 0, 0, 1, 0, 0) +GO +INSERT [dbo].[ServiceItemTypes] ([ItemTypeID], [GroupID], [DisplayName], [TypeName], [TypeOrder], [CalculateDiskspace], [CalculateBandwidth], [Suspendable], [Disposable], [Searchable], [Importable], [Backupable]) VALUES (14, 8, N'StatisticsSite', N'WebsitePanel.Providers.Statistics.StatsSite, WebsitePanel.Providers.Base', 17, 0, 0, 0, 1, 1, 1, 1) +GO +INSERT [dbo].[ServiceItemTypes] ([ItemTypeID], [GroupID], [DisplayName], [TypeName], [TypeOrder], [CalculateDiskspace], [CalculateBandwidth], [Suspendable], [Disposable], [Searchable], [Importable], [Backupable]) VALUES (15, 4, N'MailAccount', N'WebsitePanel.Providers.Mail.MailAccount, WebsitePanel.Providers.Base', 4, 1, 0, 0, 0, 1, 0, 0) +GO +INSERT [dbo].[ServiceItemTypes] ([ItemTypeID], [GroupID], [DisplayName], [TypeName], [TypeOrder], [CalculateDiskspace], [CalculateBandwidth], [Suspendable], [Disposable], [Searchable], [Importable], [Backupable]) VALUES (16, 4, N'MailAlias', N'WebsitePanel.Providers.Mail.MailAlias, WebsitePanel.Providers.Base', 5, 0, 0, 0, 0, 1, 0, 0) +GO +INSERT [dbo].[ServiceItemTypes] ([ItemTypeID], [GroupID], [DisplayName], [TypeName], [TypeOrder], [CalculateDiskspace], [CalculateBandwidth], [Suspendable], [Disposable], [Searchable], [Importable], [Backupable]) VALUES (17, 4, N'MailList', N'WebsitePanel.Providers.Mail.MailList, WebsitePanel.Providers.Base', 7, 0, 0, 0, 0, 1, 0, 0) +GO +INSERT [dbo].[ServiceItemTypes] ([ItemTypeID], [GroupID], [DisplayName], [TypeName], [TypeOrder], [CalculateDiskspace], [CalculateBandwidth], [Suspendable], [Disposable], [Searchable], [Importable], [Backupable]) VALUES (18, 4, N'MailGroup', N'WebsitePanel.Providers.Mail.MailGroup, WebsitePanel.Providers.Base', 6, 0, 0, 0, 0, 1, 0, 0) +GO +INSERT [dbo].[ServiceItemTypes] ([ItemTypeID], [GroupID], [DisplayName], [TypeName], [TypeOrder], [CalculateDiskspace], [CalculateBandwidth], [Suspendable], [Disposable], [Searchable], [Importable], [Backupable]) VALUES (19, 9, N'SharePointSite', N'WebsitePanel.Providers.SharePoint.SharePointSite, WebsitePanel.Providers.Base', 18, 0, 0, 0, 1, 1, 0, 0) +GO +INSERT [dbo].[ServiceItemTypes] ([ItemTypeID], [GroupID], [DisplayName], [TypeName], [TypeOrder], [CalculateDiskspace], [CalculateBandwidth], [Suspendable], [Disposable], [Searchable], [Importable], [Backupable]) VALUES (20, 1, N'ODBCDSN', N'WebsitePanel.Providers.OS.SystemDSN, WebsitePanel.Providers.Base', 22, 0, 0, 0, 1, 1, 1, 1) +GO +INSERT [dbo].[ServiceItemTypes] ([ItemTypeID], [GroupID], [DisplayName], [TypeName], [TypeOrder], [CalculateDiskspace], [CalculateBandwidth], [Suspendable], [Disposable], [Searchable], [Importable], [Backupable]) VALUES (21, 10, N'MsSQL2005Database', N'WebsitePanel.Providers.Database.SqlDatabase, WebsitePanel.Providers.Base', 11, 1, 0, 0, 1, 1, 1, 1) +GO +INSERT [dbo].[ServiceItemTypes] ([ItemTypeID], [GroupID], [DisplayName], [TypeName], [TypeOrder], [CalculateDiskspace], [CalculateBandwidth], [Suspendable], [Disposable], [Searchable], [Importable], [Backupable]) VALUES (22, 10, N'MsSQL2005User', N'WebsitePanel.Providers.Database.SqlUser, WebsitePanel.Providers.Base', 12, 0, 0, 1, 1, 1, 1, 1) +GO +INSERT [dbo].[ServiceItemTypes] ([ItemTypeID], [GroupID], [DisplayName], [TypeName], [TypeOrder], [CalculateDiskspace], [CalculateBandwidth], [Suspendable], [Disposable], [Searchable], [Importable], [Backupable]) VALUES (23, 11, N'MySQL5Database', N'WebsitePanel.Providers.Database.SqlDatabase, WebsitePanel.Providers.Base', 15, 1, 0, 0, 1, 1, 1, 1) +GO +INSERT [dbo].[ServiceItemTypes] ([ItemTypeID], [GroupID], [DisplayName], [TypeName], [TypeOrder], [CalculateDiskspace], [CalculateBandwidth], [Suspendable], [Disposable], [Searchable], [Importable], [Backupable]) VALUES (24, 11, N'MySQL5User', N'WebsitePanel.Providers.Database.SqlUser, WebsitePanel.Providers.Base', 16, 0, 0, 0, 1, 1, 1, 1) +GO +INSERT [dbo].[ServiceItemTypes] ([ItemTypeID], [GroupID], [DisplayName], [TypeName], [TypeOrder], [CalculateDiskspace], [CalculateBandwidth], [Suspendable], [Disposable], [Searchable], [Importable], [Backupable]) VALUES (25, 2, N'SharedSSLFolder', N'WebsitePanel.Providers.Web.SharedSSLFolder, WebsitePanel.Providers.Base', 21, 0, 0, 0, 1, 1, 0, 1) +GO +INSERT [dbo].[ServiceItemTypes] ([ItemTypeID], [GroupID], [DisplayName], [TypeName], [TypeOrder], [CalculateDiskspace], [CalculateBandwidth], [Suspendable], [Disposable], [Searchable], [Importable], [Backupable]) VALUES (28, 7, N'SecondaryDNSZone', N'WebsitePanel.Providers.DNS.SecondaryDnsZone, WebsitePanel.Providers.Base', 0, 0, 0, 1, 1, 0, 0, 1) +GO +INSERT [dbo].[ServiceItemTypes] ([ItemTypeID], [GroupID], [DisplayName], [TypeName], [TypeOrder], [CalculateDiskspace], [CalculateBandwidth], [Suspendable], [Disposable], [Searchable], [Importable], [Backupable]) VALUES (29, 13, N'Organization', N'WebsitePanel.Providers.HostedSolution.Organization, WebsitePanel.Providers.Base', 1, 1, 0, 1, 1, 1, 0, 1) +GO +INSERT [dbo].[ServiceItemTypes] ([ItemTypeID], [GroupID], [DisplayName], [TypeName], [TypeOrder], [CalculateDiskspace], [CalculateBandwidth], [Suspendable], [Disposable], [Searchable], [Importable], [Backupable]) VALUES (30, 13, N'OrganizationDomain', N'WebsitePanel.Providers.HostedSolution.OrganizationDomain, WebsitePanel.Providers.Base', 1, NULL, NULL, NULL, NULL, NULL, 0, 1) +GO +INSERT [dbo].[ServiceItemTypes] ([ItemTypeID], [GroupID], [DisplayName], [TypeName], [TypeOrder], [CalculateDiskspace], [CalculateBandwidth], [Suspendable], [Disposable], [Searchable], [Importable], [Backupable]) VALUES (31, 22, N'MsSQL2008Database', N'WebsitePanel.Providers.Database.SqlDatabase, WebsitePanel.Providers.Base', 1, 1, 0, 0, 1, 1, 1, 1) +GO +INSERT [dbo].[ServiceItemTypes] ([ItemTypeID], [GroupID], [DisplayName], [TypeName], [TypeOrder], [CalculateDiskspace], [CalculateBandwidth], [Suspendable], [Disposable], [Searchable], [Importable], [Backupable]) VALUES (32, 22, N'MsSQL2008User', N'WebsitePanel.Providers.Database.SqlUser, WebsitePanel.Providers.Base', 1, 0, 0, 0, 1, 1, 1, 1) +GO +INSERT [dbo].[ServiceItemTypes] ([ItemTypeID], [GroupID], [DisplayName], [TypeName], [TypeOrder], [CalculateDiskspace], [CalculateBandwidth], [Suspendable], [Disposable], [Searchable], [Importable], [Backupable]) VALUES (33, 30, N'VirtualMachine', N'WebsitePanel.Providers.Virtualization.VirtualMachine, WebsitePanel.Providers.Base', 1, 0, 0, 1, 1, 1, 0, 0) +GO +INSERT [dbo].[ServiceItemTypes] ([ItemTypeID], [GroupID], [DisplayName], [TypeName], [TypeOrder], [CalculateDiskspace], [CalculateBandwidth], [Suspendable], [Disposable], [Searchable], [Importable], [Backupable]) VALUES (34, 30, N'VirtualSwitch', N'WebsitePanel.Providers.Virtualization.VirtualSwitch, WebsitePanel.Providers.Base', 2, 0, 0, 1, 1, 1, 0, 0) +GO +INSERT [dbo].[ServiceItemTypes] ([ItemTypeID], [GroupID], [DisplayName], [TypeName], [TypeOrder], [CalculateDiskspace], [CalculateBandwidth], [Suspendable], [Disposable], [Searchable], [Importable], [Backupable]) VALUES (35, 40, N'VMInfo', N'WebsitePanel.Providers.Virtualization.VMInfo, WebsitePanel.Providers.Base', 1, 0, 0, 1, 1, 1, 0, 0) +GO +INSERT [dbo].[ServiceItemTypes] ([ItemTypeID], [GroupID], [DisplayName], [TypeName], [TypeOrder], [CalculateDiskspace], [CalculateBandwidth], [Suspendable], [Disposable], [Searchable], [Importable], [Backupable]) VALUES (36, 40, N'VirtualSwitch', N'WebsitePanel.Providers.Virtualization.VirtualSwitch, WebsitePanel.Providers.Base', 2, 0, 0, 1, 1, 1, 0, 0) +GO +INSERT [dbo].[ServiceItemTypes] ([ItemTypeID], [GroupID], [DisplayName], [TypeName], [TypeOrder], [CalculateDiskspace], [CalculateBandwidth], [Suspendable], [Disposable], [Searchable], [Importable], [Backupable]) VALUES (37, 23, N'MsSQL2012Database', N'WebsitePanel.Providers.Database.SqlDatabase, WebsitePanel.Providers.Base', 1, 1, 0, 0, 1, 1, 1, 1) +GO +INSERT [dbo].[ServiceItemTypes] ([ItemTypeID], [GroupID], [DisplayName], [TypeName], [TypeOrder], [CalculateDiskspace], [CalculateBandwidth], [Suspendable], [Disposable], [Searchable], [Importable], [Backupable]) VALUES (38, 23, N'MsSQL2012User', N'WebsitePanel.Providers.Database.SqlUser, WebsitePanel.Providers.Base', 1, 0, 0, 0, 1, 1, 1, 1) +GO +INSERT [dbo].[ServiceItemTypes] ([ItemTypeID], [GroupID], [DisplayName], [TypeName], [TypeOrder], [CalculateDiskspace], [CalculateBandwidth], [Suspendable], [Disposable], [Searchable], [Importable], [Backupable]) VALUES (200, 20, N'SharePointSiteCollection', N'WebsitePanel.Providers.SharePoint.SharePointSiteCollection, WebsitePanel.Providers.Base', 25, 1, 0, 0, 1, 1, 1, 1) +GO +INSERT [dbo].[SystemSettings] ([SettingsName], [PropertyName], [PropertyValue]) VALUES (N'BackupSettings', N'BackupsPath', N'c:\HostingBackups') +GO +INSERT [dbo].[SystemSettings] ([SettingsName], [PropertyName], [PropertyValue]) VALUES (N'SmtpSettings', N'SmtpEnableSsl', N'False') +GO +INSERT [dbo].[SystemSettings] ([SettingsName], [PropertyName], [PropertyValue]) VALUES (N'SmtpSettings', N'SmtpPort', N'25') +GO +INSERT [dbo].[SystemSettings] ([SettingsName], [PropertyName], [PropertyValue]) VALUES (N'SmtpSettings', N'SmtpServer', N'127.0.0.1') +GO +INSERT [dbo].[SystemSettings] ([SettingsName], [PropertyName], [PropertyValue]) VALUES (N'SmtpSettings', N'SmtpUsername', N'postmaster') +GO +SET IDENTITY_INSERT [dbo].[Users] ON + +GO +INSERT [dbo].[Users] ([UserID], [OwnerID], [RoleID], [StatusID], [IsDemo], [IsPeer], [Username], [Password], [FirstName], [LastName], [Email], [Created], [Changed], [Comments], [SecondaryEmail], [Address], [City], [State], [Country], [Zip], [PrimaryPhone], [SecondaryPhone], [Fax], [InstantMessenger], [HtmlMail], [CompanyName], [EcommerceEnabled], [AdditionalParams], [LoginStatusId], [FailedLogins], [SubscriberNumber]) VALUES (1, NULL, 1, 1, 0, 0, N'serveradmin', N'', N'Enterprise', N'Administrator', N'serveradmin@myhosting.com', CAST(0x00009DB500D45270 AS DateTime), CAST(0x00009DB500D45270 AS DateTime), N'', N'', N'', N'', N'', N'', N'', N'', N'', N'', N'', 1, NULL, 1, NULL, NULL, NULL, NULL) +GO +SET IDENTITY_INSERT [dbo].[Users] OFF +GO +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'AccountSummaryLetter', N'CC', N'support@HostingCompany.com') +GO +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'AccountSummaryLetter', N'EnableLetter', N'False') +GO +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'AccountSummaryLetter', N'From', N'support@HostingCompany.com') +GO +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'AccountSummaryLetter', N'HtmlBody', N' + + Account Summary Information + + + +
+ + +
+ Hosting Account Information +
+ + +

+Hello #user.FirstName#, +

+ +

+New user account has been created and below you can find its summary information. +

+ +

Control Panel URL

+ + + + + + + + + + + + + + + +
Control Panel URLUsernamePassword
http://panel.HostingCompany.com#user.Username##user.Password#
+
+ +

Hosting Spaces

+

+ The following hosting spaces have been created under your account: +

+ +

#Space.PackageName#

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Hosting Plan: + #Plans[Space.PlanId].PlanName#System +
Purchase Date: + #Space.PurchaseDate# +
Disk Space, MB:
Bandwidth, MB/Month:
Maximum Number of Domains:
Maximum Number of Sub-Domains:
+
+ + +

+If you have any questions regarding your hosting account, feel free to contact our support department at any time. +

+ +

+Best regards,
+ACME Hosting Inc.
+Web Site: www.AcmeHosting.com
+E-Mail: support@AcmeHosting.com +

+
+ + + + #space.Quotas[quota].QuotaAllocatedValue#Unlimited + + 0 + + + +
+ +') +GO +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'AccountSummaryLetter', N'Priority', N'Normal') +GO +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'AccountSummaryLetter', N'Subject', N'WebsitePanel account has been created forWebsitePanel account summary for #user.FirstName# #user.LastName#') +GO +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'AccountSummaryLetter', N'TextBody', N'================================= + Hosting Account Information +================================= +Hello #user.FirstName#, + +New user account has been created and below you can find its summary information. + +Control Panel URL: http://panel.AcmeHosting.com +Username: #user.Username# +Password: #user.Password# + + +Hosting Spaces +============== +The following hosting spaces have been created under your account: + + +=== #Space.PackageName# === +Hosting Plan: #Plans[Space.PlanId].PlanName#System +Purchase Date: #Space.PurchaseDate# +Disk Space, MB: +Bandwidth, MB/Month: +Maximum Number of Domains: +Maximum Number of Sub-Domains: + + + +If you have any questions regarding your hosting account, feel free to contact our support department at any time. + +Best regards, +ACME Hosting Inc. +Web Site: http://www.AcmeHosting.com"> +E-Mail: support@AcmeHosting.com +#space.Quotas[quota].QuotaAllocatedValue#Unlimited0') +GO +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'DisplayPreferences', N'GridItems', N'11') +GO +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'ExchangePolicy', N'MailboxPasswordPolicy', N'True;8;20;0;2;0;True') +GO +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'FtpPolicy', N'UserNamePolicy', N'True;-;1;20;;;') +GO +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'FtpPolicy', N'UserPasswordPolicy', N'True;5;20;0;1;0;True') +GO +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'MailPolicy', N'AccountNamePolicy', N'True;;1;50;;;') +GO +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'MailPolicy', N'AccountPasswordPolicy', N'True;5;20;0;1;0;False') +GO +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'MailPolicy', N'CatchAllName', N'mail') +GO +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'MsSqlPolicy', N'DatabaseNamePolicy', N'True;-;1;120;;;') +GO +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'MsSqlPolicy', N'UserNamePolicy', N'True;-;1;120;;;') +GO +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'MsSqlPolicy', N'UserPasswordPolicy', N'True;5;20;0;1;0;True') +GO +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'MySqlPolicy', N'DatabaseNamePolicy', N'True;;1;40;;;') +GO +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'MySqlPolicy', N'UserNamePolicy', N'True;;1;16;;;') +GO +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'MySqlPolicy', N'UserPasswordPolicy', N'True;5;20;0;1;0;False') +GO +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'OsPolicy', N'DsnNamePolicy', N'True;-;2;40;;;') +GO +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'PackageSummaryLetter', N'CC', N'support@HostingCompany.com') +GO +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'PackageSummaryLetter', N'EnableLetter', N'True') +GO +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'PackageSummaryLetter', N'From', N'support@HostingCompany.com') +GO +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'PackageSummaryLetter', N'HtmlBody', N' + + Hosting Space Summary Information + + + +
+ + + +
+ Hosting Space Information +
+ + +

+Hello #user.FirstName#, +

+ +

+"#space.Package.PackageName#" hosting space has been created under your user account +and below is the summary information for its resources. +

+
+ + + + + +

Control Panel URL

+ + + + + + + + + + + + + + + +
Control Panel URLUsernamePassword
http://panel.HostingCompany.com#user.Username##user.Password#
+
+ + +

Hosting Space Overview

+ +

+ General hosting space limits: +

+ + + + + + + + + + + + + + + + + +
Disk Space, MB:
Bandwidth, MB/Month:
Maximum Number of Domains:
Maximum Number of Sub-Domains:
+ + + +

Web

+ +

+ Limits +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Maximum Number of Web Sites:
Web Application Gallery:
Classic ASP:
ASP.NET 1.1:
ASP.NET 2.0:
ASP.NET 4.0:
PHP 4:
PHP 5:
Perl:
CGI-BIN:
+ + + +

Name Servers

+

+ In order to point your domain to the web site in this hosting space you should use the following Name Servers: +

+ + + + + + +
#NameServer#
+

+ You should change the name servers in domain registrar (Register.com, GoDaddy.com, etc.) control panel. + Please, study domain registrar''s user manual for directions how to change name servers or contact your domain + registrar directly by e-mail or phone. +

+

+ Please note, the changes in domain registrar database do not reflect immediately and sometimes it requires from + 12 to 48 hours till the end of DNS propagation. +

+ + +

Web Sites

+

+ The following web sites have been created under hosting space: +

+ + + + + + +
http://#WebSite.Name#
+

+ * Please note, your web sites may not be accessible from 12 to 48 hours after you''ve changed name servers for their respective domains. +

+ + + +

Temporary URL

+

+ You can access your web sites right now using their respective temporary URLs (instant aliases). + Temporary URL is a sub-domain of the form http://yourdomain.com.providerdomain.com where "yourdomain.com" is your + domain and "providerdomain.com" is the domain of your hosting provider. +

+

+ You can use the following Temporary URL for all your web sites: +

+ + + + +
+ http://YourDomain.com.#InstantAlias# +
+
+ + +

Files Location

+

+ Sometimes it is required to know the physical location of the hosting space folder (absolute path). + Hosting space folder is the folder where all hosting space files such as web sites content, web logs, data files, etc. are located. +

+

+ The root of your hosting space on our HDD is here: +

+ + + + +
+ #PackageRootFolder# +
+

+ By default the root folder of any web site within your hosting space is built as following (you can change it anytime from the control panel): +

+ + + + +
+ #PackageRootFolder#\YourDomain.com\wwwroot +
+
+ + + + +

FTP

+ + +

Limits

+ + + + + +
Maximum Number of FTP Accounts:
+ + + +

FTP Server

+

+Your hosting space allows working with your files by FTP. +You can use the following FTP server to access your space files remotely: +

+ + + + +
ftp://#FtpIP#
+

+ Also, you can use the following domain names to access your FTP server: +

+ + + + +
ftp://ftp.YourDomain.com
+ +

+ During DNS propagation period (when domain name servers have been changed), similar to web sites, FTP server can be access with Temporary URL too: +

+ + + + +
ftp://ftp.YourDomain.com.#InstantAlias#
+
+ +

FTP Accounts

+

+ The following FTP accounts have been created under your hosting space and can be used to access FTP server: +

+ + + + + + + + + + + + + + + + + + + + + +
UsernamePasswordFolder
#FtpAcocunt.Name# + #FtpAcocunt.Password# + #FtpAcocunt.Folder#
+
+ + + + +

Mail

+ + +

Limits

+ + + + + + + + + + + + + + + + + +
Maximum Number of Mail Accounts:
Maximum Number of Mail Forwardings:
Maximum Number of Mail Groups (Aliases):
Maximum Number of Mailing Lists:
+ + +

SMTP/POP3 Server

+

+Below is the IP address of your POP3/SMTP/IMAP server. You can always access your mailbox(es) +using this IP address instead of actual POP3/SMTP/IMAP servers name: +

+ + + + +
+ #MailRecords[0].ExternalIP# +
+ +

+ Also, you can use the following domain names to access SMTP/POP3 server from your favourite e-mail client software: +

+ + + + +
mail.YourDomain.com
+ + +

+ During DNS propagation period (when domain name servers have been changed), similar to web sites, SMTP/POP3 server can be access with temporary domain too: +

+ + + + +
mail.YourDomain.com.#InstantAlias#
+
+ + +

Mail Accounts

+

+ The following mail accounts have been created under your hosting space: +

+ + + + + + + + + + + + + + + + + + + + + +
E-mailUsername (for POP3/SMTP/IMAP/WebMail)Password
#MailAccount.Name##MailAccount.Name# + #MailAccount.Password# +
+
+ + +

Databases

+ +

+ You can create databases and database users on "Space Home -> Databases" screen in the control panel. +

+ + + + +

SQL Server 2000

+ + + + + + + + + + +
Maximum Number of Databases:
Maximum Number of Users:
+ +

+ In order to connect to SQL Server 2000 from Management Studio, Enterprise Manager, Query Analyzer + or other client software you can use the following SQL Server address: +

+ + + + +
#MsSQL2000Address#
+ +
+ + + + +

SQL Server 2005

+ + + + + + + + + + +
Maximum Number of Databases:
Maximum Number of Users:
+ +

+ In order to connect to SQL Server 2005 from Management Studio, Enterprise Manager, Query Analyzer + or other client software you can use the following SQL Server address: +

+ + + + +
#MsSQL2005Address#
+ +
+ + + + +

SQL Server 2008

+ + + + + + + + + + +
Maximum Number of Databases:
Maximum Number of Users:
+ +

+ In order to connect to SQL Server 2008 from Management Studio, Enterprise Manager, Query Analyzer + or other client software you can use the following SQL Server address: +

+ + + + +
#MsSQL2008Address#
+ +
+ + + + +

SQL Server 2012

+ + + + + + + + + + +
Maximum Number of Databases:
Maximum Number of Users:
+ +

+ In order to connect to SQL Server 2012 from Management Studio, Enterprise Manager, Query Analyzer + or other client software you can use the following SQL Server address: +

+ + + + +
#MsSQL2012Address#
+ +
+ + + +

MySQL 4.x

+ + + + + + + + + + +
Maximum Number of Databases:
Maximum Number of Users:
+ +

+ In order to connect to MySQL 4.x server you can use the following address: +

+ + + + +
#MySQL4Address#
+
+ + + + +

MySQL 5.x

+ + + + + + + + + + +
Maximum Number of Databases:
Maximum Number of Users:
+ +

+ In order to connect to MySQL 5.x server you can use the following address: +

+ + + + +
#MySQL5Address#
+
+ + + +

Microsoft Access

+

+ Microsoft Access database are automatically allowed in any hosting plan. You can create/upload any number of Access + database from File Manager in control panel. +

+ + + + +

Web Statistics

+ + + + + + +
Maximum Number of Statistics Sites:
+ +

+ You can view advanced statistics from your domain using URL of the following form: +

+ + + + +
http://stats.YourDomain.com
+ +

+ During DNS propagation period (when domain name servers have been changed), you can access web site statistics with Temporary URL: +

+ + + + +
http://stats.YourDomain.com.#InstantAlias#
+
+
+ + +

+If you have any questions regarding your hosting account, feel free to contact our support department at any time. +

+ +

+Best regards,
+ACME Hosting Inc.
+Web Site: www.AcmeHosting.com
+E-Mail: support@AcmeHosting.com +

+
+ + + +

+ You may also use SQL Server address above in your application connection strings, for example: +

+ + + + + + + + + +
Classic ASP (ADO Library)Provider=SQLOLEDB;Data source=#server#;Initial catalog=databaseName;User Id=userName;Password=password;
ASP.NET (ADO.NET Library)Server=#server#;Database=databaseName;Uid=userName;Password=password;
+
+ + + + #space.Quotas[quota].QuotaAllocatedValue#Unlimited + + 0 + + + + + + EnabledDisabled + + Disabled + + + +
+ +') +GO +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'PackageSummaryLetter', N'Priority', N'Normal') +GO +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'PackageSummaryLetter', N'Subject', N'"#space.Package.PackageName#" hosting space has been created forhosting space summary for #user.FirstName# #user.LastName#') +GO +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'PackageSummaryLetter', N'TextBody', N'================================ + Hosting Space Information +================================ + + +Hello #user.FirstName#, + +"#space.Package.PackageName#" hosting space has been created under your user account +and below is the summary information for its resources. + + +Control Panel +============= +Control Panel URL: http://panel.AcmeHosting.com +Username: #user.Username# +Password: #user.Password# + + +Hosting Space Overview +====================== +General hosting space limits: +Disk Space, MB: +Bandwidth, MB/Month: +Maximum Number of Domains: +Maximum Number of Sub-Domains: + +Web +====== + +Limits +------ +Maximum Number of Web Sites: +Web Application Gallery: +Classic ASP: +ASP.NET 1.1: +ASP.NET 2.0: +ASP.NET 4.0: +PHP 4: +PHP 5: +Perl: +CGI-BIN: + +Name Servers +------------ +In order to point your domain to the web site in this hosting space you should use the following Name Servers: + + #NameServer# + +You should change the name servers in domain registrar (Register.com, GoDaddy.com, etc.) control panel. Please, study domain registrar''s user manual for directions how to change name servers or contact your domain registrar directly by e-mail or phone. + +Please note, the changes in domain registrar database do not reflect immediately and sometimes it requires from 12 to 48 hours till the end of DNS propagation. + + +Web Sites +--------- +The following web sites have been created under hosting space: + + http://#WebSite.Name# + +* Please note, your web sites may not be accessible from 12 to 48 hours after you''ve changed name servers for their respective domains. + +Temporary URL +------------- +You can access your web sites right now using their respective temporary URLs (instant aliases). Temporary URL is a sub-domain of the form http://yourdomain.com.providerdomain.com where "yourdomain.com" is your domain and "providerdomain.com" is the domain of your hosting provider. + +You can use the following Temporary URL for all your web sites: + + http://YourDomain.com.#InstantAlias# + + + +Files Location +-------------- +Sometimes it is required to know the physical location of the hosting space folder (absolute path). +Hosting space folder is the folder where all hosting space files such as web sites content, web logs, data files, etc. are located. + +The root of your hosting space on our HDD is here: + + #PackageRootFolder# + +By default the root folder of any web site within your hosting space is built as following (you can change it anytime from the control panel): + + #PackageRootFolder#\YourDomain.com\wwwroot + + + + +FTP +===== + +Limits +------ +Maximum Number of FTP Accounts: + +FTP Server +---------- +Your hosting space allows working with your files by FTP. +You can use the following FTP server to access your space files remotely: + + ftp://#FtpIP# + +Also, you can use the following domain names to access your FTP server: + + ftp://ftp.YourDomain.com + +During DNS propagation period (when domain name servers have been changed), similar to web sites, FTP server can be access with Temporary URL too: + + ftp://ftp.YourDomain.com.#InstantAlias# + + +FTP Accounts +------------ +The following FTP accounts have been created under your hosting space and can be used to access FTP server: + +Username: #FtpAcocunt.Name# +Password: #FtpAcocunt.Password# +Folder: #FtpAcocunt.Folder# + + + + +Mail +======== + +Limits +------ +Maximum Number of Mail Accounts: +Maximum Number of Mail Forwardings: +Maximum Number of Mail Groups (Aliases): +Maximum Number of Mailing Lists: + +SMTP/POP3 Server +---------------- +Below is the IP address of your POP3/SMTP/IMAP server. You can always access your mailbox(es) using this IP address instead of actual POP3/SMTP/IMAP servers name: + + #MailRecords[0].ExternalIP# + +Also, you can use the following domain names to access SMTP/POP3 server from your favourite e-mail client software: + + mail.YourDomain.com + +During DNS propagation period (when domain name servers have been changed), similar to web sites, SMTP/POP3 server can be access with temporary domain too: + + mail.YourDomain.com.#InstantAlias# + + +Mail Accounts +------------- +The following mail accounts have been created under your hosting space: +E-mail: #MailAccount.Name# +Password: #MailAccount.Password# + + + + +Databases +========= +You can create databases and database users on "Space Home -> Databases" screen in the control panel. + +SQL Server 2000 +--------------- +Maximum Number of Databases: +Maximum Number of Users: + +In order to connect to SQL Server 2000 from Management Studio, Enterprise Manager, Query Analyzer or other client software you can use the following SQL Server address: + + #MsSQL2000Address# + + + + +SQL Server 2005 +--------------- +Maximum Number of Databases: +Maximum Number of Users: + +In order to connect to SQL Server 2005 from Management Studio, Enterprise Manager, Query Analyzer or other client software you can use the following SQL Server address: + + #MsSQL2005Address# + + + + +SQL Server 2008 +--------------- +Maximum Number of Databases: +Maximum Number of Users: + +In order to connect to SQL Server 2008 from Management Studio, Enterprise Manager, Query Analyzer or other client software you can use the following SQL Server address: + + #MsSQL2008Address# + + + + + +MySQL 4.x +--------- +Maximum Number of Databases: +Maximum Number of Users: + +In order to connect to MySQL 4.x server you can use the following address: + + #MySQL4Address# + + +MySQL 5.x +--------- +Maximum Number of Databases: +Maximum Number of Users: + +In order to connect to MySQL 5.x server you can use the following address: + + #MySQL5Address# + + +Microsoft Access +---------------- +Microsoft Access database are automatically allowed in any hosting plan. You can create/upload any number of Access database from File Manager in control panel. + +Web Statistics +============== +Maximum Number of Statistics Sites: + +You can view advanced statistics from your domain using URL of the following form: + + http://stats.YourDomain.com + +During DNS propagation period (when domain name servers have been changed), you can access web site statistics with Temporary URL: + + http://stats.YourDomain.com.#InstantAlias# + + + +If you have any questions regarding your hosting account, feel free to contact our support department at any time. + +Best regards, +ACME Hosting Inc. +Web Site: http://www.AcmeHosting.com" +E-Mail: support@AcmeHosting.com + +You may also use SQL Server address above in your application connection strings, for example: + +Classic ASP (ADO Library): Provider=SQLOLEDB;Data source=#server#;Initial catalog=databaseName;User Id=userName;Password=password; +ASP.NET (ADO.NET Library): Server=#server#;Database=databaseName;Uid=userName;Password=password; + +#space.Quotas[quota].QuotaAllocatedValue#Unlimited0 +EnabledDisabledDisabled') +GO +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'PasswordReminderLetter', N'CC', N'') +GO +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'PasswordReminderLetter', N'From', N'support@HostingCompany.com') +GO +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'PasswordReminderLetter', N'HtmlBody', N' + + Account Summary Information + + + +
+ + +
+ Hosting Account Information +
+ +

+Hello #user.FirstName#, +

+ +

+Please, find below details of your control panel account. +

+ +

Control Panel URL

+ + + + + + + + + + + + + + + +
Control Panel URLUsernamePassword
http://panel.HostingCompany.com#user.Username##user.Password#
+ + +

+If you have any questions regarding your hosting account, feel free to contact our support department at any time. +

+ +

+Best regards,
+ACME Hosting Inc.
+Web Site: www.AcmeHosting.com
+E-Mail: support@AcmeHosting.com +

+ +
+ +') +GO +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'PasswordReminderLetter', N'Priority', N'Normal') +GO +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'PasswordReminderLetter', N'Subject', N'Password reminder for #user.FirstName# #user.LastName#') +GO +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'PasswordReminderLetter', N'TextBody', N'================================= + Hosting Account Information +================================= + +Hello #user.FirstName#, + +Please, find below details of your control panel account. + +Control Panel URL: http://panel.AcmeHosting.com +Username: #user.Username# +Password: #user.Password# + +If you have any questions regarding your hosting account, feel free to contact our support department at any time. + +Best regards, +ACME Hosting Inc. +Web Site: http://www.AcmeHosting.com" +E-Mail: support@AcmeHosting.com') +GO +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'SharePointPolicy', N'GroupNamePolicy', N'True;-;1;20;;;') +GO +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'SharePointPolicy', N'UserNamePolicy', N'True;-;1;20;;;') +GO +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'SharePointPolicy', N'UserPasswordPolicy', N'True;5;20;0;1;0;True') +GO +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'WebPolicy', N'AddParkingPage', N'True') +GO +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'WebPolicy', N'AddRandomDomainString', N'False') +GO +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'WebPolicy', N'AnonymousAccountPolicy', N'True;;5;20;;_web;') +GO +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'WebPolicy', N'AspInstalled', N'True') +GO +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'WebPolicy', N'AspNetInstalled', N'2') +GO +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'WebPolicy', N'CgiBinInstalled', N'False') +GO +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'WebPolicy', N'DefaultDocuments', N'Default.htm,Default.asp,index.htm,Default.aspx') +GO +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'WebPolicy', N'EnableAnonymousAccess', N'True') +GO +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'WebPolicy', N'EnableBasicAuthentication', N'False') +GO +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'WebPolicy', N'EnableDedicatedPool', N'False') +GO +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'WebPolicy', N'EnableDirectoryBrowsing', N'False') +GO +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'WebPolicy', N'EnableParentPaths', N'False') +GO +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'WebPolicy', N'EnableParkingPageTokens', N'False') +GO +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'WebPolicy', N'EnableWindowsAuthentication', N'True') +GO +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'WebPolicy', N'EnableWritePermissions', N'False') +GO +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'WebPolicy', N'FrontPageAccountPolicy', N'True;;1;20;;;') +GO +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'WebPolicy', N'FrontPagePasswordPolicy', N'True;5;20;0;1;0;False') +GO +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'WebPolicy', N'ParkingPageContent', N' + + The web site is under construction + + + +
+

This web site has just been created from WebsitePanel and it is still under construction.

+

The web site is hosted by AcmeHosting.

+
+ +') +GO +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'WebPolicy', N'ParkingPageName', N'default.aspx') +GO +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'WebPolicy', N'PerlInstalled', N'False') +GO +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'WebPolicy', N'PhpInstalled', N'') +GO +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'WebPolicy', N'PublishingProfile', N' + + + SQLServerDBConnectionString="server=#MsSqlServerExternalAddress#;database=#MsSqlDatabase.Name#;uid=#MsSqlUser.Name#;pwd=#MsSqlUser.Password#" + mySQLDBConnectionString="server=#MySqlAddress#;database=#MySqlDatabase.Name#;uid=#MySqlUser.Name#;pwd=#MySqlUser.Password#" + hostingProviderForumLink="http://support.acmehosting.com/" + controlPanelLink="http://cp.acmehosting.com/" + /> + + + SQLServerDBConnectionString="server=#MsSqlServerExternalAddress#;database=#MsSqlDatabase.Name#;uid=#MsSqlUser.Name#;pwd=#MsSqlUser.Password#" + mySQLDBConnectionString="server=#MySqlAddress#;database=#MySqlDatabase.Name#;uid=#MySqlUser.Name#;pwd=#MySqlUser.Password#" + hostingProviderForumLink="http://support.acmehosting.com/" + controlPanelLink="http://cp.acmehosting.com/" + /> + + + +') +GO +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'WebPolicy', N'PythonInstalled', N'False') +GO +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'WebPolicy', N'SecuredGroupNamePolicy', N'True;;1;20;;;') +GO +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'WebPolicy', N'SecuredUserNamePolicy', N'True;;1;20;;;') +GO +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'WebPolicy', N'SecuredUserPasswordPolicy', N'True;5;20;0;1;0;False') +GO +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'WebPolicy', N'VirtDirNamePolicy', N'True;-;3;50;;;') +GO +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'WebPolicy', N'WebDataFolder', N'\[DOMAIN_NAME]\data') +GO +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'WebPolicy', N'WebLogsFolder', N'\[DOMAIN_NAME]\logs') +GO +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'WebPolicy', N'WebRootFolder', N'\[DOMAIN_NAME]\wwwroot') +GO +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'WebsitePanelPolicy', N'DemoMessage', N'When user account is in demo mode the majority of operations are +disabled, especially those ones that modify or delete records. +You are welcome to ask your questions or place comments about +this demo on WebsitePanel Support Forum') +GO +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'WebsitePanelPolicy', N'ForbiddenIP', N'') +GO +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'WebsitePanelPolicy', N'PasswordPolicy', N'True;6;20;0;1;0;True') +GO +INSERT [dbo].[Versions] ([DatabaseVersion], [BuildDate]) VALUES (N'1.0', CAST(0x00009D5400000000 AS DateTime)) +GO +INSERT [dbo].[Versions] ([DatabaseVersion], [BuildDate]) VALUES (N'1.0.1.0', CAST(0x00009DB500D453BD AS DateTime)) +GO +INSERT [dbo].[Versions] ([DatabaseVersion], [BuildDate]) VALUES (N'1.0.2.0', CAST(0x00009DE600000000 AS DateTime)) +GO +INSERT [dbo].[Versions] ([DatabaseVersion], [BuildDate]) VALUES (N'1.1.0.9', CAST(0x00009E3000000000 AS DateTime)) +GO +INSERT [dbo].[Versions] ([DatabaseVersion], [BuildDate]) VALUES (N'1.1.2.13', CAST(0x00009EC600000000 AS DateTime)) +GO +INSERT [dbo].[Versions] ([DatabaseVersion], [BuildDate]) VALUES (N'1.2.0.38', CAST(0x00009F1F00000000 AS DateTime)) +GO +INSERT [dbo].[Versions] ([DatabaseVersion], [BuildDate]) VALUES (N'1.2.1.6', CAST(0x0000A02300000000 AS DateTime)) +GO +INSERT [dbo].[Versions] ([DatabaseVersion], [BuildDate]) VALUES (N'2.0.0.228', CAST(0x0000A12000000000 AS DateTime)) +GO +SET ANSI_PADDING ON + +GO +ALTER TABLE [dbo].[ecContracts] ADD CONSTRAINT [UQ_ecContracts_ContractID] UNIQUE NONCLUSTERED +( + [ContractID] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +GO +SET ANSI_PADDING ON + +GO +ALTER TABLE [dbo].[ecCustomersPayments] ADD CONSTRAINT [IX_ecCustomersPayments] UNIQUE NONCLUSTERED +( + [TransactionID] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +GO +SET ANSI_PADDING ON + +GO +CREATE UNIQUE NONCLUSTERED INDEX [IX_ecTaxations] ON [dbo].[ecTaxations] +( + [ResellerID] ASC, + [Country] ASC, + [State] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +GO +SET ANSI_PADDING ON + +GO +ALTER TABLE [dbo].[ExchangeAccountEmailAddresses] ADD CONSTRAINT [IX_ExchangeAccountEmailAddresses_UniqueEmail] UNIQUE NONCLUSTERED +( + [EmailAddress] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +GO +SET ANSI_PADDING ON + +GO +ALTER TABLE [dbo].[ExchangeAccounts] ADD CONSTRAINT [IX_ExchangeAccounts_UniqueAccountName] UNIQUE NONCLUSTERED +( + [AccountName] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +GO +ALTER TABLE [dbo].[ExchangeMailboxPlans] ADD CONSTRAINT [IX_ExchangeMailboxPlans] UNIQUE NONCLUSTERED +( + [MailboxPlanId] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +GO +ALTER TABLE [dbo].[ExchangeOrganizationDomains] ADD CONSTRAINT [IX_ExchangeOrganizationDomains_UniqueDomain] UNIQUE NONCLUSTERED +( + [DomainID] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +GO +SET ANSI_PADDING ON + +GO +ALTER TABLE [dbo].[ExchangeOrganizations] ADD CONSTRAINT [IX_ExchangeOrganizations_UniqueOrg] UNIQUE NONCLUSTERED +( + [OrganizationID] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +GO +ALTER TABLE [dbo].[LyncUserPlans] ADD CONSTRAINT [IX_LyncUserPlans] UNIQUE NONCLUSTERED +( + [LyncUserPlanId] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +GO +SET ANSI_PADDING ON + +GO +ALTER TABLE [dbo].[Users] ADD CONSTRAINT [IX_Users_Username] UNIQUE NONCLUSTERED +( + [Username] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +GO +ALTER TABLE [dbo].[BlackBerryUsers] ADD CONSTRAINT [DF_BlackBerryUsers_CreatedDate] DEFAULT (getdate()) FOR [CreatedDate] +GO +ALTER TABLE [dbo].[Comments] ADD CONSTRAINT [DF_Comments_CreatedDate] DEFAULT (getdate()) FOR [CreatedDate] +GO +ALTER TABLE [dbo].[CRMUsers] ADD CONSTRAINT [DF_Table_1_CreateDate] DEFAULT (getdate()) FOR [CreatedDate] +GO +ALTER TABLE [dbo].[CRMUsers] ADD CONSTRAINT [DF_CRMUsers_ChangedDate] DEFAULT (getdate()) FOR [ChangedDate] +GO +ALTER TABLE [dbo].[Domains] ADD CONSTRAINT [DF_Domains_AllowedForHosting] DEFAULT ((0)) FOR [HostingAllowed] +GO +ALTER TABLE [dbo].[Domains] ADD CONSTRAINT [DF_Domains_SubDomainID] DEFAULT ((0)) FOR [IsSubDomain] +GO +ALTER TABLE [dbo].[Domains] ADD CONSTRAINT [DF_Domains_IsInstantAlias] DEFAULT ((0)) FOR [IsInstantAlias] +GO +ALTER TABLE [dbo].[ecBillingCycles] ADD CONSTRAINT [DF_ecBillingCycles_Created] DEFAULT (getdate()) FOR [Created] +GO +ALTER TABLE [dbo].[ecCategory] ADD CONSTRAINT [DF_EC_Categories_Level] DEFAULT ((0)) FOR [Level] +GO +ALTER TABLE [dbo].[ecCategory] ADD CONSTRAINT [DF_ecCategory_Created] DEFAULT (getutcdate()) FOR [Created] +GO +ALTER TABLE [dbo].[ecCategory] ADD CONSTRAINT [DF_EC_Categories_CategoryOrder] DEFAULT ((0)) FOR [ItemOrder] +GO +ALTER TABLE [dbo].[ecContracts] ADD CONSTRAINT [DF__ecContrac__Opene__668030F6] DEFAULT (getdate()) FOR [OpenedDate] +GO +ALTER TABLE [dbo].[ecContracts] ADD CONSTRAINT [DF__ecContrac__Balan__6774552F] DEFAULT ((0)) FOR [Balance] +GO +ALTER TABLE [dbo].[ecCustomersPayments] ADD CONSTRAINT [DF_EC_Payments_PaymentDate] DEFAULT (getdate()) FOR [Created] +GO +ALTER TABLE [dbo].[ecCustomersPayments] ADD CONSTRAINT [DF_EC_Payments_GatewayID] DEFAULT ((0)) FOR [PluginID] +GO +ALTER TABLE [dbo].[ecHostingPlansBillingCycles] ADD CONSTRAINT [DF_ecPlanBillingCycles_SetupFee] DEFAULT ((0)) FOR [SetupFee] +GO +ALTER TABLE [dbo].[ecHostingPlansBillingCycles] ADD CONSTRAINT [DF_ecPlanBillingCycles_RecurringFee] DEFAULT ((0)) FOR [RecurringFee] +GO +ALTER TABLE [dbo].[ecInvoice] ADD CONSTRAINT [DF_EC_Invoices_CreatedDate] DEFAULT (getutcdate()) FOR [Created] +GO +ALTER TABLE [dbo].[ecInvoice] ADD CONSTRAINT [DF_ecInvoice_Total] DEFAULT ((0)) FOR [Total] +GO +ALTER TABLE [dbo].[ecInvoice] ADD CONSTRAINT [DF_ecInvoice_SubTotal] DEFAULT ((0)) FOR [SubTotal] +GO +ALTER TABLE [dbo].[ecInvoice] ADD CONSTRAINT [DF__ecInvoice__Taxat__4119A21D] DEFAULT ((0)) FOR [TaxationID] +GO +ALTER TABLE [dbo].[ecInvoiceItems] ADD CONSTRAINT [DF_ecInvoiceItems_Total] DEFAULT ((0)) FOR [Total] +GO +ALTER TABLE [dbo].[ecInvoiceItems] ADD CONSTRAINT [DF_ecInvoiceItems_SubTotal] DEFAULT ((0)) FOR [SubTotal] +GO +ALTER TABLE [dbo].[ecInvoiceItems] ADD CONSTRAINT [DF_ecInvoiceItems_UnitPrice] DEFAULT ((0)) FOR [UnitPrice] +GO +ALTER TABLE [dbo].[ecInvoiceItems] ADD CONSTRAINT [DF_ecInvoiceItems_Processed] DEFAULT ((0)) FOR [Processed] +GO +ALTER TABLE [dbo].[ecPaymentProfiles] ADD CONSTRAINT [DF_ecPaymentProfiles_Created] DEFAULT (getdate()) FOR [Created] +GO +ALTER TABLE [dbo].[ecProduct] ADD CONSTRAINT [DF_ecProduct_Created] DEFAULT (getutcdate()) FOR [Created] +GO +ALTER TABLE [dbo].[ecProductType] ADD CONSTRAINT [DF_ecProductType_Created] DEFAULT (getutcdate()) FOR [Created] +GO +ALTER TABLE [dbo].[ecService] ADD CONSTRAINT [DF_ecService_Status] DEFAULT ((0)) FOR [Status] +GO +ALTER TABLE [dbo].[ecService] ADD CONSTRAINT [DF_SpaceInstance_CreatedDate] DEFAULT (getutcdate()) FOR [Created] +GO +ALTER TABLE [dbo].[ecService] ADD CONSTRAINT [DF_SpaceInstance_ModifiedDate] DEFAULT (getutcdate()) FOR [Modified] +GO +ALTER TABLE [dbo].[ecServiceHandlersResponses] ADD CONSTRAINT [DF_ecServiceHandlerResponses_Received] DEFAULT (getdate()) FOR [Received] +GO +ALTER TABLE [dbo].[ecSupportedPluginLog] ADD CONSTRAINT [DF_ecSpacePluginLog_Created] DEFAULT (getdate()) FOR [Created] +GO +ALTER TABLE [dbo].[ecSystemTriggers] ADD CONSTRAINT [DF_ecSystemTriggers_TriggerID] DEFAULT (newid()) FOR [TriggerID] +GO +ALTER TABLE [dbo].[ExchangeAccounts] ADD CONSTRAINT [DF__ExchangeA__Creat__59B045BD] DEFAULT (getdate()) FOR [CreatedDate] +GO +ALTER TABLE [dbo].[ExchangeOrganizationDomains] ADD CONSTRAINT [DF_ExchangeOrganizationDomains_IsHost] DEFAULT ((0)) FOR [IsHost] +GO +ALTER TABLE [dbo].[ExchangeOrganizationDomains] ADD CONSTRAINT [DF_ExchangeOrganizationDomains_DomainTypeID] DEFAULT ((0)) FOR [DomainTypeID] +GO +ALTER TABLE [dbo].[LyncUsers] ADD CONSTRAINT [DF_LyncUsers_CreatedDate] DEFAULT (getdate()) FOR [CreatedDate] +GO +ALTER TABLE [dbo].[LyncUsers] ADD CONSTRAINT [DF_LyncUsers_ChangedDate] DEFAULT (getdate()) FOR [ModifiedDate] +GO +ALTER TABLE [dbo].[OCSUsers] ADD CONSTRAINT [DF_OCSUsers_CreatedDate] DEFAULT (getdate()) FOR [CreatedDate] +GO +ALTER TABLE [dbo].[OCSUsers] ADD CONSTRAINT [DF_OCSUsers_ChangedDate] DEFAULT (getdate()) FOR [ModifiedDate] +GO +ALTER TABLE [dbo].[Packages] ADD CONSTRAINT [DF_Packages_OverrideQuotas] DEFAULT ((0)) FOR [OverrideQuotas] +GO +ALTER TABLE [dbo].[Quotas] ADD CONSTRAINT [DF_ResourceGroupQuotas_QuotaOrder] DEFAULT ((1)) FOR [QuotaOrder] +GO +ALTER TABLE [dbo].[Quotas] ADD CONSTRAINT [DF_ResourceGroupQuotas_QuotaTypeID] DEFAULT ((2)) FOR [QuotaTypeID] +GO +ALTER TABLE [dbo].[Quotas] ADD CONSTRAINT [DF_Quotas_ServiceQuota] DEFAULT ((0)) FOR [ServiceQuota] +GO +ALTER TABLE [dbo].[ResourceGroupDnsRecords] ADD CONSTRAINT [DF_ResourceGroupDnsRecords_RecordOrder] DEFAULT ((1)) FOR [RecordOrder] +GO +ALTER TABLE [dbo].[ResourceGroups] ADD CONSTRAINT [DF_ResourceGroups_GroupOrder] DEFAULT ((1)) FOR [GroupOrder] +GO +ALTER TABLE [dbo].[ScheduleTaskParameters] ADD CONSTRAINT [DF_ScheduleTaskParameters_ParameterOrder] DEFAULT ((0)) FOR [ParameterOrder] +GO +ALTER TABLE [dbo].[Servers] ADD CONSTRAINT [DF_Servers_DisplayName] DEFAULT ('') FOR [ServerUrl] +GO +ALTER TABLE [dbo].[Servers] ADD CONSTRAINT [DF_Servers_VirtualServer] DEFAULT ((0)) FOR [VirtualServer] +GO +ALTER TABLE [dbo].[Servers] ADD CONSTRAINT [DF_Servers_ADEnabled] DEFAULT ((0)) FOR [ADEnabled] +GO +ALTER TABLE [dbo].[ServiceItemTypes] ADD CONSTRAINT [DF_ServiceItemTypes_TypeOrder] DEFAULT ((1)) FOR [TypeOrder] +GO +ALTER TABLE [dbo].[ServiceItemTypes] ADD CONSTRAINT [DF_ServiceItemTypes_Importable] DEFAULT ((1)) FOR [Importable] +GO +ALTER TABLE [dbo].[ServiceItemTypes] ADD CONSTRAINT [DF_ServiceItemTypes_Backup] DEFAULT ((1)) FOR [Backupable] +GO +ALTER TABLE [dbo].[Users] ADD CONSTRAINT [DF_Users_Demo] DEFAULT ((0)) FOR [IsDemo] +GO +ALTER TABLE [dbo].[Users] ADD CONSTRAINT [DF_Users_IsPeer] DEFAULT ((0)) FOR [IsPeer] +GO +ALTER TABLE [dbo].[Users] ADD CONSTRAINT [DF_Users_HtmlLetters] DEFAULT ((1)) FOR [HtmlMail] +GO +ALTER TABLE [dbo].[BlackBerryUsers] WITH CHECK ADD CONSTRAINT [FK_BlackBerryUsers_ExchangeAccounts] FOREIGN KEY([AccountId]) +REFERENCES [dbo].[ExchangeAccounts] ([AccountID]) +GO +ALTER TABLE [dbo].[BlackBerryUsers] CHECK CONSTRAINT [FK_BlackBerryUsers_ExchangeAccounts] +GO +ALTER TABLE [dbo].[Comments] WITH CHECK ADD CONSTRAINT [FK_Comments_Users] FOREIGN KEY([UserID]) +REFERENCES [dbo].[Users] ([UserID]) +ON DELETE CASCADE +GO +ALTER TABLE [dbo].[Comments] CHECK CONSTRAINT [FK_Comments_Users] +GO +ALTER TABLE [dbo].[CRMUsers] WITH CHECK ADD CONSTRAINT [FK_CRMUsers_ExchangeAccounts] FOREIGN KEY([AccountID]) +REFERENCES [dbo].[ExchangeAccounts] ([AccountID]) +GO +ALTER TABLE [dbo].[CRMUsers] CHECK CONSTRAINT [FK_CRMUsers_ExchangeAccounts] +GO +ALTER TABLE [dbo].[Domains] WITH CHECK ADD CONSTRAINT [FK_Domains_Packages] FOREIGN KEY([PackageID]) +REFERENCES [dbo].[Packages] ([PackageID]) +ON DELETE CASCADE +GO +ALTER TABLE [dbo].[Domains] CHECK CONSTRAINT [FK_Domains_Packages] +GO +ALTER TABLE [dbo].[Domains] WITH CHECK ADD CONSTRAINT [FK_Domains_ServiceItems_MailDomain] FOREIGN KEY([MailDomainID]) +REFERENCES [dbo].[ServiceItems] ([ItemID]) +GO +ALTER TABLE [dbo].[Domains] CHECK CONSTRAINT [FK_Domains_ServiceItems_MailDomain] +GO +ALTER TABLE [dbo].[Domains] WITH CHECK ADD CONSTRAINT [FK_Domains_ServiceItems_WebSite] FOREIGN KEY([WebSiteID]) +REFERENCES [dbo].[ServiceItems] ([ItemID]) +GO +ALTER TABLE [dbo].[Domains] CHECK CONSTRAINT [FK_Domains_ServiceItems_WebSite] +GO +ALTER TABLE [dbo].[Domains] WITH CHECK ADD CONSTRAINT [FK_Domains_ServiceItems_ZoneItem] FOREIGN KEY([ZoneItemID]) +REFERENCES [dbo].[ServiceItems] ([ItemID]) +GO +ALTER TABLE [dbo].[Domains] CHECK CONSTRAINT [FK_Domains_ServiceItems_ZoneItem] +GO +ALTER TABLE [dbo].[ecAddonProducts] WITH CHECK ADD CONSTRAINT [FK_ecAddonProducts_ecProduct] FOREIGN KEY([AddonID]) +REFERENCES [dbo].[ecProduct] ([ProductID]) +ON DELETE CASCADE +GO +ALTER TABLE [dbo].[ecAddonProducts] CHECK CONSTRAINT [FK_ecAddonProducts_ecProduct] +GO +ALTER TABLE [dbo].[ecCategory] WITH CHECK ADD CONSTRAINT [FK_ecCategory_ecCategory] FOREIGN KEY([ParentID]) +REFERENCES [dbo].[ecCategory] ([CategoryID]) +GO +ALTER TABLE [dbo].[ecCategory] CHECK CONSTRAINT [FK_ecCategory_ecCategory] +GO +ALTER TABLE [dbo].[ecDomainSvcs] WITH CHECK ADD CONSTRAINT [FK_ecDomainsSvcs_ecService] FOREIGN KEY([ServiceID]) +REFERENCES [dbo].[ecService] ([ServiceID]) +ON DELETE CASCADE +GO +ALTER TABLE [dbo].[ecDomainSvcs] CHECK CONSTRAINT [FK_ecDomainsSvcs_ecService] +GO +ALTER TABLE [dbo].[ecDomainSvcsCycles] WITH CHECK ADD CONSTRAINT [FK_ecDomainsSvcsCycles_ecService] FOREIGN KEY([ServiceID]) +REFERENCES [dbo].[ecService] ([ServiceID]) +ON DELETE CASCADE +GO +ALTER TABLE [dbo].[ecDomainSvcsCycles] CHECK CONSTRAINT [FK_ecDomainsSvcsCycles_ecService] +GO +ALTER TABLE [dbo].[ecHostingAddons] WITH CHECK ADD CONSTRAINT [FK_ecHostingAddons_ecProduct] FOREIGN KEY([ProductID]) +REFERENCES [dbo].[ecProduct] ([ProductID]) +ON DELETE CASCADE +GO +ALTER TABLE [dbo].[ecHostingAddons] CHECK CONSTRAINT [FK_ecHostingAddons_ecProduct] +GO +ALTER TABLE [dbo].[ecHostingAddonsCycles] WITH CHECK ADD CONSTRAINT [FK_ecHostingAddonsCycles_ecBillingCycles] FOREIGN KEY([CycleID]) +REFERENCES [dbo].[ecBillingCycles] ([CycleID]) +ON DELETE CASCADE +GO +ALTER TABLE [dbo].[ecHostingAddonsCycles] CHECK CONSTRAINT [FK_ecHostingAddonsCycles_ecBillingCycles] +GO +ALTER TABLE [dbo].[ecHostingAddonsCycles] WITH CHECK ADD CONSTRAINT [FK_ecHostingAddonsCycles_ecProduct] FOREIGN KEY([ProductID]) +REFERENCES [dbo].[ecProduct] ([ProductID]) +ON DELETE CASCADE +GO +ALTER TABLE [dbo].[ecHostingAddonsCycles] CHECK CONSTRAINT [FK_ecHostingAddonsCycles_ecProduct] +GO +ALTER TABLE [dbo].[ecHostingAddonSvcs] WITH CHECK ADD CONSTRAINT [FK_ecAddonPackagesSvcs_ecService] FOREIGN KEY([ServiceID]) +REFERENCES [dbo].[ecService] ([ServiceID]) +ON DELETE CASCADE +GO +ALTER TABLE [dbo].[ecHostingAddonSvcs] CHECK CONSTRAINT [FK_ecAddonPackagesSvcs_ecService] +GO +ALTER TABLE [dbo].[ecHostingAddonSvcsCycles] WITH CHECK ADD CONSTRAINT [FK_ecAddonPackagesSvcsCycles_ecService] FOREIGN KEY([ServiceID]) +REFERENCES [dbo].[ecService] ([ServiceID]) +ON DELETE CASCADE +GO +ALTER TABLE [dbo].[ecHostingAddonSvcsCycles] CHECK CONSTRAINT [FK_ecAddonPackagesSvcsCycles_ecService] +GO +ALTER TABLE [dbo].[ecHostingPackageSvcs] WITH CHECK ADD CONSTRAINT [FK_ecPackagesSvcs_ecService] FOREIGN KEY([ServiceID]) +REFERENCES [dbo].[ecService] ([ServiceID]) +ON DELETE CASCADE +GO +ALTER TABLE [dbo].[ecHostingPackageSvcs] CHECK CONSTRAINT [FK_ecPackagesSvcs_ecService] +GO +ALTER TABLE [dbo].[ecHostingPackageSvcsCycles] WITH CHECK ADD CONSTRAINT [FK_ecPackagesSvcsCycles_ecService] FOREIGN KEY([ServiceID]) +REFERENCES [dbo].[ecService] ([ServiceID]) +ON DELETE CASCADE +GO +ALTER TABLE [dbo].[ecHostingPackageSvcsCycles] CHECK CONSTRAINT [FK_ecPackagesSvcsCycles_ecService] +GO +ALTER TABLE [dbo].[ecHostingPlans] WITH CHECK ADD CONSTRAINT [FK_ecHostingPlans_ecProduct] FOREIGN KEY([ProductID]) +REFERENCES [dbo].[ecProduct] ([ProductID]) +ON DELETE CASCADE +GO +ALTER TABLE [dbo].[ecHostingPlans] CHECK CONSTRAINT [FK_ecHostingPlans_ecProduct] +GO +ALTER TABLE [dbo].[ecHostingPlansBillingCycles] WITH CHECK ADD CONSTRAINT [FK_ecHostingPlansBillingCycles_ecBillingCycles] FOREIGN KEY([CycleID]) +REFERENCES [dbo].[ecBillingCycles] ([CycleID]) +ON DELETE CASCADE +GO +ALTER TABLE [dbo].[ecHostingPlansBillingCycles] CHECK CONSTRAINT [FK_ecHostingPlansBillingCycles_ecBillingCycles] +GO +ALTER TABLE [dbo].[ecHostingPlansBillingCycles] WITH CHECK ADD CONSTRAINT [FK_ecHostingPlansBillingCycles_ecProduct] FOREIGN KEY([ProductID]) +REFERENCES [dbo].[ecProduct] ([ProductID]) +ON DELETE CASCADE +GO +ALTER TABLE [dbo].[ecHostingPlansBillingCycles] CHECK CONSTRAINT [FK_ecHostingPlansBillingCycles_ecProduct] +GO +ALTER TABLE [dbo].[ecInvoiceItems] WITH CHECK ADD CONSTRAINT [FK_ecInvoiceItems_ecInvoice] FOREIGN KEY([InvoiceID]) +REFERENCES [dbo].[ecInvoice] ([InvoiceID]) +ON DELETE CASCADE +GO +ALTER TABLE [dbo].[ecInvoiceItems] CHECK CONSTRAINT [FK_ecInvoiceItems_ecInvoice] +GO +ALTER TABLE [dbo].[ecPaymentMethods] WITH CHECK ADD CONSTRAINT [FK_ecPaymentMethods_ecSupportedPlugins] FOREIGN KEY([PluginID]) +REFERENCES [dbo].[ecSupportedPlugins] ([PluginID]) +GO +ALTER TABLE [dbo].[ecPaymentMethods] CHECK CONSTRAINT [FK_ecPaymentMethods_ecSupportedPlugins] +GO +ALTER TABLE [dbo].[ecProduct] WITH CHECK ADD CONSTRAINT [FK_ecProduct_ecProductType] FOREIGN KEY([TypeID]) +REFERENCES [dbo].[ecProductType] ([TypeID]) +GO +ALTER TABLE [dbo].[ecProduct] CHECK CONSTRAINT [FK_ecProduct_ecProductType] +GO +ALTER TABLE [dbo].[ecProductCategories] WITH CHECK ADD CONSTRAINT [FK_EC_ProductsToCategories_EC_Categories] FOREIGN KEY([CategoryID]) +REFERENCES [dbo].[ecCategory] ([CategoryID]) +ON DELETE CASCADE +GO +ALTER TABLE [dbo].[ecProductCategories] CHECK CONSTRAINT [FK_EC_ProductsToCategories_EC_Categories] +GO +ALTER TABLE [dbo].[ecProductCategories] WITH CHECK ADD CONSTRAINT [FK_EC_ProductsToCategories_EC_Products] FOREIGN KEY([ProductID]) +REFERENCES [dbo].[ecProduct] ([ProductID]) +ON DELETE CASCADE +GO +ALTER TABLE [dbo].[ecProductCategories] CHECK CONSTRAINT [FK_EC_ProductsToCategories_EC_Products] +GO +ALTER TABLE [dbo].[ecProductsHighlights] WITH CHECK ADD CONSTRAINT [FK_ecProductsHighlights_ecProduct] FOREIGN KEY([ProductID]) +REFERENCES [dbo].[ecProduct] ([ProductID]) +ON DELETE CASCADE +GO +ALTER TABLE [dbo].[ecProductsHighlights] CHECK CONSTRAINT [FK_ecProductsHighlights_ecProduct] +GO +ALTER TABLE [dbo].[ecService] WITH CHECK ADD CONSTRAINT [FK_ecService_ecProductType] FOREIGN KEY([TypeID]) +REFERENCES [dbo].[ecProductType] ([TypeID]) +GO +ALTER TABLE [dbo].[ecService] CHECK CONSTRAINT [FK_ecService_ecProductType] +GO +ALTER TABLE [dbo].[ecSvcsUsageLog] WITH CHECK ADD CONSTRAINT [FK_ecSvcsUsageLog_ecService] FOREIGN KEY([ServiceID]) +REFERENCES [dbo].[ecService] ([ServiceID]) +ON DELETE CASCADE +GO +ALTER TABLE [dbo].[ecSvcsUsageLog] CHECK CONSTRAINT [FK_ecSvcsUsageLog_ecService] +GO +ALTER TABLE [dbo].[ecTopLevelDomains] WITH CHECK ADD CONSTRAINT [FK_ecTopLevelDomains_ecProduct] FOREIGN KEY([ProductID]) +REFERENCES [dbo].[ecProduct] ([ProductID]) +ON DELETE CASCADE +GO +ALTER TABLE [dbo].[ecTopLevelDomains] CHECK CONSTRAINT [FK_ecTopLevelDomains_ecProduct] +GO +ALTER TABLE [dbo].[ecTopLevelDomainsCycles] WITH CHECK ADD CONSTRAINT [FK_ecTopLevelDomainsCycles_ecProduct] FOREIGN KEY([ProductID]) +REFERENCES [dbo].[ecProduct] ([ProductID]) +ON DELETE CASCADE +GO +ALTER TABLE [dbo].[ecTopLevelDomainsCycles] CHECK CONSTRAINT [FK_ecTopLevelDomainsCycles_ecProduct] +GO +ALTER TABLE [dbo].[ExchangeAccountEmailAddresses] WITH CHECK ADD CONSTRAINT [FK_ExchangeAccountEmailAddresses_ExchangeAccounts] FOREIGN KEY([AccountID]) +REFERENCES [dbo].[ExchangeAccounts] ([AccountID]) +ON DELETE CASCADE +GO +ALTER TABLE [dbo].[ExchangeAccountEmailAddresses] CHECK CONSTRAINT [FK_ExchangeAccountEmailAddresses_ExchangeAccounts] +GO +ALTER TABLE [dbo].[ExchangeAccounts] WITH CHECK ADD CONSTRAINT [FK_ExchangeAccounts_ExchangeMailboxPlans] FOREIGN KEY([MailboxPlanId]) +REFERENCES [dbo].[ExchangeMailboxPlans] ([MailboxPlanId]) +GO +ALTER TABLE [dbo].[ExchangeAccounts] CHECK CONSTRAINT [FK_ExchangeAccounts_ExchangeMailboxPlans] +GO +ALTER TABLE [dbo].[ExchangeAccounts] WITH CHECK ADD CONSTRAINT [FK_ExchangeAccounts_ServiceItems] FOREIGN KEY([ItemID]) +REFERENCES [dbo].[ServiceItems] ([ItemID]) +ON DELETE CASCADE +GO +ALTER TABLE [dbo].[ExchangeAccounts] CHECK CONSTRAINT [FK_ExchangeAccounts_ServiceItems] +GO +ALTER TABLE [dbo].[ExchangeMailboxPlans] WITH CHECK ADD CONSTRAINT [FK_ExchangeMailboxPlans_ExchangeOrganizations] FOREIGN KEY([ItemID]) +REFERENCES [dbo].[ExchangeOrganizations] ([ItemID]) +ON DELETE CASCADE +GO +ALTER TABLE [dbo].[ExchangeMailboxPlans] CHECK CONSTRAINT [FK_ExchangeMailboxPlans_ExchangeOrganizations] +GO +ALTER TABLE [dbo].[ExchangeOrganizationDomains] WITH CHECK ADD CONSTRAINT [FK_ExchangeOrganizationDomains_ServiceItems] FOREIGN KEY([ItemID]) +REFERENCES [dbo].[ServiceItems] ([ItemID]) +ON DELETE CASCADE +GO +ALTER TABLE [dbo].[ExchangeOrganizationDomains] CHECK CONSTRAINT [FK_ExchangeOrganizationDomains_ServiceItems] +GO +ALTER TABLE [dbo].[ExchangeOrganizations] WITH CHECK ADD CONSTRAINT [FK_ExchangeOrganizations_ServiceItems] FOREIGN KEY([ItemID]) +REFERENCES [dbo].[ServiceItems] ([ItemID]) +ON DELETE CASCADE +GO +ALTER TABLE [dbo].[ExchangeOrganizations] CHECK CONSTRAINT [FK_ExchangeOrganizations_ServiceItems] +GO +ALTER TABLE [dbo].[GlobalDnsRecords] WITH CHECK ADD CONSTRAINT [FK_GlobalDnsRecords_IPAddresses] FOREIGN KEY([IPAddressID]) +REFERENCES [dbo].[IPAddresses] ([AddressID]) +GO +ALTER TABLE [dbo].[GlobalDnsRecords] CHECK CONSTRAINT [FK_GlobalDnsRecords_IPAddresses] +GO +ALTER TABLE [dbo].[GlobalDnsRecords] WITH CHECK ADD CONSTRAINT [FK_GlobalDnsRecords_Packages] FOREIGN KEY([PackageID]) +REFERENCES [dbo].[Packages] ([PackageID]) +ON DELETE CASCADE +GO +ALTER TABLE [dbo].[GlobalDnsRecords] CHECK CONSTRAINT [FK_GlobalDnsRecords_Packages] +GO +ALTER TABLE [dbo].[GlobalDnsRecords] WITH CHECK ADD CONSTRAINT [FK_GlobalDnsRecords_Servers] FOREIGN KEY([ServerID]) +REFERENCES [dbo].[Servers] ([ServerID]) +GO +ALTER TABLE [dbo].[GlobalDnsRecords] CHECK CONSTRAINT [FK_GlobalDnsRecords_Servers] +GO +ALTER TABLE [dbo].[GlobalDnsRecords] WITH CHECK ADD CONSTRAINT [FK_GlobalDnsRecords_Services] FOREIGN KEY([ServiceID]) +REFERENCES [dbo].[Services] ([ServiceID]) +ON DELETE CASCADE +GO +ALTER TABLE [dbo].[GlobalDnsRecords] CHECK CONSTRAINT [FK_GlobalDnsRecords_Services] +GO +ALTER TABLE [dbo].[HostingPlanQuotas] WITH CHECK ADD CONSTRAINT [FK_HostingPlanQuotas_HostingPlans] FOREIGN KEY([PlanID]) +REFERENCES [dbo].[HostingPlans] ([PlanID]) +ON DELETE CASCADE +GO +ALTER TABLE [dbo].[HostingPlanQuotas] CHECK CONSTRAINT [FK_HostingPlanQuotas_HostingPlans] +GO +ALTER TABLE [dbo].[HostingPlanQuotas] WITH CHECK ADD CONSTRAINT [FK_HostingPlanQuotas_Quotas] FOREIGN KEY([QuotaID]) +REFERENCES [dbo].[Quotas] ([QuotaID]) +GO +ALTER TABLE [dbo].[HostingPlanQuotas] CHECK CONSTRAINT [FK_HostingPlanQuotas_Quotas] +GO +ALTER TABLE [dbo].[HostingPlanResources] WITH CHECK ADD CONSTRAINT [FK_HostingPlanResources_HostingPlans] FOREIGN KEY([PlanID]) +REFERENCES [dbo].[HostingPlans] ([PlanID]) +ON DELETE CASCADE +GO +ALTER TABLE [dbo].[HostingPlanResources] CHECK CONSTRAINT [FK_HostingPlanResources_HostingPlans] +GO +ALTER TABLE [dbo].[HostingPlanResources] WITH CHECK ADD CONSTRAINT [FK_HostingPlanResources_ResourceGroups] FOREIGN KEY([GroupID]) +REFERENCES [dbo].[ResourceGroups] ([GroupID]) +GO +ALTER TABLE [dbo].[HostingPlanResources] CHECK CONSTRAINT [FK_HostingPlanResources_ResourceGroups] +GO +ALTER TABLE [dbo].[HostingPlans] WITH CHECK ADD CONSTRAINT [FK_HostingPlans_Packages] FOREIGN KEY([PackageID]) +REFERENCES [dbo].[Packages] ([PackageID]) +ON DELETE CASCADE +GO +ALTER TABLE [dbo].[HostingPlans] CHECK CONSTRAINT [FK_HostingPlans_Packages] +GO +ALTER TABLE [dbo].[HostingPlans] WITH CHECK ADD CONSTRAINT [FK_HostingPlans_Servers] FOREIGN KEY([ServerID]) +REFERENCES [dbo].[Servers] ([ServerID]) +GO +ALTER TABLE [dbo].[HostingPlans] CHECK CONSTRAINT [FK_HostingPlans_Servers] +GO +ALTER TABLE [dbo].[HostingPlans] WITH CHECK ADD CONSTRAINT [FK_HostingPlans_Users] FOREIGN KEY([UserID]) +REFERENCES [dbo].[Users] ([UserID]) +GO +ALTER TABLE [dbo].[HostingPlans] CHECK CONSTRAINT [FK_HostingPlans_Users] +GO +ALTER TABLE [dbo].[IPAddresses] WITH CHECK ADD CONSTRAINT [FK_IPAddresses_Servers] FOREIGN KEY([ServerID]) +REFERENCES [dbo].[Servers] ([ServerID]) +ON DELETE CASCADE +GO +ALTER TABLE [dbo].[IPAddresses] CHECK CONSTRAINT [FK_IPAddresses_Servers] +GO +ALTER TABLE [dbo].[LyncUserPlans] WITH CHECK ADD CONSTRAINT [FK_LyncUserPlans_ExchangeOrganizations] FOREIGN KEY([ItemID]) +REFERENCES [dbo].[ExchangeOrganizations] ([ItemID]) +ON DELETE CASCADE +GO +ALTER TABLE [dbo].[LyncUserPlans] CHECK CONSTRAINT [FK_LyncUserPlans_ExchangeOrganizations] +GO +ALTER TABLE [dbo].[LyncUsers] WITH CHECK ADD CONSTRAINT [FK_LyncUsers_LyncUserPlans] FOREIGN KEY([LyncUserPlanID]) +REFERENCES [dbo].[LyncUserPlans] ([LyncUserPlanId]) +GO +ALTER TABLE [dbo].[LyncUsers] CHECK CONSTRAINT [FK_LyncUsers_LyncUserPlans] +GO +ALTER TABLE [dbo].[PackageAddons] WITH CHECK ADD CONSTRAINT [FK_PackageAddons_HostingPlans] FOREIGN KEY([PlanID]) +REFERENCES [dbo].[HostingPlans] ([PlanID]) +GO +ALTER TABLE [dbo].[PackageAddons] CHECK CONSTRAINT [FK_PackageAddons_HostingPlans] +GO +ALTER TABLE [dbo].[PackageAddons] WITH CHECK ADD CONSTRAINT [FK_PackageAddons_Packages] FOREIGN KEY([PackageID]) +REFERENCES [dbo].[Packages] ([PackageID]) +ON DELETE CASCADE +GO +ALTER TABLE [dbo].[PackageAddons] CHECK CONSTRAINT [FK_PackageAddons_Packages] +GO +ALTER TABLE [dbo].[PackageIPAddresses] WITH CHECK ADD CONSTRAINT [FK_PackageIPAddresses_IPAddresses] FOREIGN KEY([AddressID]) +REFERENCES [dbo].[IPAddresses] ([AddressID]) +GO +ALTER TABLE [dbo].[PackageIPAddresses] CHECK CONSTRAINT [FK_PackageIPAddresses_IPAddresses] +GO +ALTER TABLE [dbo].[PackageIPAddresses] WITH CHECK ADD CONSTRAINT [FK_PackageIPAddresses_Packages] FOREIGN KEY([PackageID]) +REFERENCES [dbo].[Packages] ([PackageID]) +ON DELETE CASCADE +GO +ALTER TABLE [dbo].[PackageIPAddresses] CHECK CONSTRAINT [FK_PackageIPAddresses_Packages] +GO +ALTER TABLE [dbo].[PackageIPAddresses] WITH CHECK ADD CONSTRAINT [FK_PackageIPAddresses_ServiceItems] FOREIGN KEY([ItemID]) +REFERENCES [dbo].[ServiceItems] ([ItemID]) +GO +ALTER TABLE [dbo].[PackageIPAddresses] CHECK CONSTRAINT [FK_PackageIPAddresses_ServiceItems] +GO +ALTER TABLE [dbo].[PackageQuotas] WITH CHECK ADD CONSTRAINT [FK_PackageQuotas_Packages] FOREIGN KEY([PackageID]) +REFERENCES [dbo].[Packages] ([PackageID]) +GO +ALTER TABLE [dbo].[PackageQuotas] CHECK CONSTRAINT [FK_PackageQuotas_Packages] +GO +ALTER TABLE [dbo].[PackageQuotas] WITH CHECK ADD CONSTRAINT [FK_PackageQuotas_Quotas] FOREIGN KEY([QuotaID]) +REFERENCES [dbo].[Quotas] ([QuotaID]) +GO +ALTER TABLE [dbo].[PackageQuotas] CHECK CONSTRAINT [FK_PackageQuotas_Quotas] +GO +ALTER TABLE [dbo].[PackageResources] WITH CHECK ADD CONSTRAINT [FK_PackageResources_Packages] FOREIGN KEY([PackageID]) +REFERENCES [dbo].[Packages] ([PackageID]) +GO +ALTER TABLE [dbo].[PackageResources] CHECK CONSTRAINT [FK_PackageResources_Packages] +GO +ALTER TABLE [dbo].[PackageResources] WITH CHECK ADD CONSTRAINT [FK_PackageResources_ResourceGroups] FOREIGN KEY([GroupID]) +REFERENCES [dbo].[ResourceGroups] ([GroupID]) +GO +ALTER TABLE [dbo].[PackageResources] CHECK CONSTRAINT [FK_PackageResources_ResourceGroups] +GO +ALTER TABLE [dbo].[Packages] WITH CHECK ADD CONSTRAINT [FK_Packages_HostingPlans] FOREIGN KEY([PlanID]) +REFERENCES [dbo].[HostingPlans] ([PlanID]) +GO +ALTER TABLE [dbo].[Packages] CHECK CONSTRAINT [FK_Packages_HostingPlans] +GO +ALTER TABLE [dbo].[Packages] WITH CHECK ADD CONSTRAINT [FK_Packages_Packages] FOREIGN KEY([ParentPackageID]) +REFERENCES [dbo].[Packages] ([PackageID]) +GO +ALTER TABLE [dbo].[Packages] CHECK CONSTRAINT [FK_Packages_Packages] +GO +ALTER TABLE [dbo].[Packages] WITH CHECK ADD CONSTRAINT [FK_Packages_Servers] FOREIGN KEY([ServerID]) +REFERENCES [dbo].[Servers] ([ServerID]) +GO +ALTER TABLE [dbo].[Packages] CHECK CONSTRAINT [FK_Packages_Servers] +GO +ALTER TABLE [dbo].[Packages] WITH CHECK ADD CONSTRAINT [FK_Packages_Users] FOREIGN KEY([UserID]) +REFERENCES [dbo].[Users] ([UserID]) +GO +ALTER TABLE [dbo].[Packages] CHECK CONSTRAINT [FK_Packages_Users] +GO +ALTER TABLE [dbo].[PackagesBandwidth] WITH CHECK ADD CONSTRAINT [FK_PackagesBandwidth_Packages] FOREIGN KEY([PackageID]) +REFERENCES [dbo].[Packages] ([PackageID]) +GO +ALTER TABLE [dbo].[PackagesBandwidth] CHECK CONSTRAINT [FK_PackagesBandwidth_Packages] +GO +ALTER TABLE [dbo].[PackagesBandwidth] WITH CHECK ADD CONSTRAINT [FK_PackagesBandwidth_ResourceGroups] FOREIGN KEY([GroupID]) +REFERENCES [dbo].[ResourceGroups] ([GroupID]) +GO +ALTER TABLE [dbo].[PackagesBandwidth] CHECK CONSTRAINT [FK_PackagesBandwidth_ResourceGroups] +GO +ALTER TABLE [dbo].[PackagesDiskspace] WITH CHECK ADD CONSTRAINT [FK_PackagesDiskspace_Packages] FOREIGN KEY([PackageID]) +REFERENCES [dbo].[Packages] ([PackageID]) +GO +ALTER TABLE [dbo].[PackagesDiskspace] CHECK CONSTRAINT [FK_PackagesDiskspace_Packages] +GO +ALTER TABLE [dbo].[PackagesDiskspace] WITH CHECK ADD CONSTRAINT [FK_PackagesDiskspace_ResourceGroups] FOREIGN KEY([GroupID]) +REFERENCES [dbo].[ResourceGroups] ([GroupID]) +GO +ALTER TABLE [dbo].[PackagesDiskspace] CHECK CONSTRAINT [FK_PackagesDiskspace_ResourceGroups] +GO +ALTER TABLE [dbo].[PackageServices] WITH CHECK ADD CONSTRAINT [FK_PackageServices_Packages] FOREIGN KEY([PackageID]) +REFERENCES [dbo].[Packages] ([PackageID]) +ON DELETE CASCADE +GO +ALTER TABLE [dbo].[PackageServices] CHECK CONSTRAINT [FK_PackageServices_Packages] +GO +ALTER TABLE [dbo].[PackageServices] WITH CHECK ADD CONSTRAINT [FK_PackageServices_Services] FOREIGN KEY([ServiceID]) +REFERENCES [dbo].[Services] ([ServiceID]) +ON DELETE CASCADE +GO +ALTER TABLE [dbo].[PackageServices] CHECK CONSTRAINT [FK_PackageServices_Services] +GO +ALTER TABLE [dbo].[PackagesTreeCache] WITH CHECK ADD CONSTRAINT [FK_PackagesTreeCache_Packages] FOREIGN KEY([ParentPackageID]) +REFERENCES [dbo].[Packages] ([PackageID]) +GO +ALTER TABLE [dbo].[PackagesTreeCache] CHECK CONSTRAINT [FK_PackagesTreeCache_Packages] +GO +ALTER TABLE [dbo].[PackagesTreeCache] WITH CHECK ADD CONSTRAINT [FK_PackagesTreeCache_Packages1] FOREIGN KEY([PackageID]) +REFERENCES [dbo].[Packages] ([PackageID]) +GO +ALTER TABLE [dbo].[PackagesTreeCache] CHECK CONSTRAINT [FK_PackagesTreeCache_Packages1] +GO +ALTER TABLE [dbo].[PrivateIPAddresses] WITH CHECK ADD CONSTRAINT [FK_PrivateIPAddresses_ServiceItems] FOREIGN KEY([ItemID]) +REFERENCES [dbo].[ServiceItems] ([ItemID]) +ON DELETE CASCADE +GO +ALTER TABLE [dbo].[PrivateIPAddresses] CHECK CONSTRAINT [FK_PrivateIPAddresses_ServiceItems] +GO +ALTER TABLE [dbo].[Providers] WITH CHECK ADD CONSTRAINT [FK_Providers_ResourceGroups] FOREIGN KEY([GroupID]) +REFERENCES [dbo].[ResourceGroups] ([GroupID]) +GO +ALTER TABLE [dbo].[Providers] CHECK CONSTRAINT [FK_Providers_ResourceGroups] +GO +ALTER TABLE [dbo].[Quotas] WITH CHECK ADD CONSTRAINT [FK_Quotas_ResourceGroups] FOREIGN KEY([GroupID]) +REFERENCES [dbo].[ResourceGroups] ([GroupID]) +ON DELETE CASCADE +GO +ALTER TABLE [dbo].[Quotas] CHECK CONSTRAINT [FK_Quotas_ResourceGroups] +GO +ALTER TABLE [dbo].[Quotas] WITH CHECK ADD CONSTRAINT [FK_Quotas_ServiceItemTypes] FOREIGN KEY([ItemTypeID]) +REFERENCES [dbo].[ServiceItemTypes] ([ItemTypeID]) +GO +ALTER TABLE [dbo].[Quotas] CHECK CONSTRAINT [FK_Quotas_ServiceItemTypes] +GO +ALTER TABLE [dbo].[ResourceGroupDnsRecords] WITH CHECK ADD CONSTRAINT [FK_ResourceGroupDnsRecords_ResourceGroups] FOREIGN KEY([GroupID]) +REFERENCES [dbo].[ResourceGroups] ([GroupID]) +ON DELETE CASCADE +GO +ALTER TABLE [dbo].[ResourceGroupDnsRecords] CHECK CONSTRAINT [FK_ResourceGroupDnsRecords_ResourceGroups] +GO +ALTER TABLE [dbo].[Schedule] WITH CHECK ADD CONSTRAINT [FK_Schedule_Packages] FOREIGN KEY([PackageID]) +REFERENCES [dbo].[Packages] ([PackageID]) +ON DELETE CASCADE +GO +ALTER TABLE [dbo].[Schedule] CHECK CONSTRAINT [FK_Schedule_Packages] +GO +ALTER TABLE [dbo].[Schedule] WITH CHECK ADD CONSTRAINT [FK_Schedule_ScheduleTasks] FOREIGN KEY([TaskID]) +REFERENCES [dbo].[ScheduleTasks] ([TaskID]) +GO +ALTER TABLE [dbo].[Schedule] CHECK CONSTRAINT [FK_Schedule_ScheduleTasks] +GO +ALTER TABLE [dbo].[ScheduleParameters] WITH CHECK ADD CONSTRAINT [FK_ScheduleParameters_Schedule] FOREIGN KEY([ScheduleID]) +REFERENCES [dbo].[Schedule] ([ScheduleID]) +ON DELETE CASCADE +GO +ALTER TABLE [dbo].[ScheduleParameters] CHECK CONSTRAINT [FK_ScheduleParameters_Schedule] +GO +ALTER TABLE [dbo].[ScheduleTaskParameters] WITH CHECK ADD CONSTRAINT [FK_ScheduleTaskParameters_ScheduleTasks] FOREIGN KEY([TaskID]) +REFERENCES [dbo].[ScheduleTasks] ([TaskID]) +GO +ALTER TABLE [dbo].[ScheduleTaskParameters] CHECK CONSTRAINT [FK_ScheduleTaskParameters_ScheduleTasks] +GO +ALTER TABLE [dbo].[ScheduleTaskViewConfiguration] WITH CHECK ADD CONSTRAINT [FK_ScheduleTaskViewConfiguration_ScheduleTaskViewConfiguration] FOREIGN KEY([TaskID]) +REFERENCES [dbo].[ScheduleTasks] ([TaskID]) +GO +ALTER TABLE [dbo].[ScheduleTaskViewConfiguration] CHECK CONSTRAINT [FK_ScheduleTaskViewConfiguration_ScheduleTaskViewConfiguration] +GO +ALTER TABLE [dbo].[Servers] WITH CHECK ADD CONSTRAINT [FK_Servers_ResourceGroups] FOREIGN KEY([PrimaryGroupID]) +REFERENCES [dbo].[ResourceGroups] ([GroupID]) +GO +ALTER TABLE [dbo].[Servers] CHECK CONSTRAINT [FK_Servers_ResourceGroups] +GO +ALTER TABLE [dbo].[ServiceDefaultProperties] WITH CHECK ADD CONSTRAINT [FK_ServiceDefaultProperties_Providers] FOREIGN KEY([ProviderID]) +REFERENCES [dbo].[Providers] ([ProviderID]) +GO +ALTER TABLE [dbo].[ServiceDefaultProperties] CHECK CONSTRAINT [FK_ServiceDefaultProperties_Providers] +GO +ALTER TABLE [dbo].[ServiceItemProperties] WITH CHECK ADD CONSTRAINT [FK_ServiceItemProperties_ServiceItems] FOREIGN KEY([ItemID]) +REFERENCES [dbo].[ServiceItems] ([ItemID]) +ON DELETE CASCADE +GO +ALTER TABLE [dbo].[ServiceItemProperties] CHECK CONSTRAINT [FK_ServiceItemProperties_ServiceItems] +GO +ALTER TABLE [dbo].[ServiceItems] WITH CHECK ADD CONSTRAINT [FK_ServiceItems_Packages] FOREIGN KEY([PackageID]) +REFERENCES [dbo].[Packages] ([PackageID]) +GO +ALTER TABLE [dbo].[ServiceItems] CHECK CONSTRAINT [FK_ServiceItems_Packages] +GO +ALTER TABLE [dbo].[ServiceItems] WITH CHECK ADD CONSTRAINT [FK_ServiceItems_ServiceItemTypes] FOREIGN KEY([ItemTypeID]) +REFERENCES [dbo].[ServiceItemTypes] ([ItemTypeID]) +GO +ALTER TABLE [dbo].[ServiceItems] CHECK CONSTRAINT [FK_ServiceItems_ServiceItemTypes] +GO +ALTER TABLE [dbo].[ServiceItems] WITH CHECK ADD CONSTRAINT [FK_ServiceItems_Services] FOREIGN KEY([ServiceID]) +REFERENCES [dbo].[Services] ([ServiceID]) +GO +ALTER TABLE [dbo].[ServiceItems] CHECK CONSTRAINT [FK_ServiceItems_Services] +GO +ALTER TABLE [dbo].[ServiceItemTypes] WITH CHECK ADD CONSTRAINT [FK_ServiceItemTypes_ResourceGroups] FOREIGN KEY([GroupID]) +REFERENCES [dbo].[ResourceGroups] ([GroupID]) +GO +ALTER TABLE [dbo].[ServiceItemTypes] CHECK CONSTRAINT [FK_ServiceItemTypes_ResourceGroups] +GO +ALTER TABLE [dbo].[ServiceProperties] WITH CHECK ADD CONSTRAINT [FK_ServiceProperties_Services] FOREIGN KEY([ServiceID]) +REFERENCES [dbo].[Services] ([ServiceID]) +ON DELETE CASCADE +GO +ALTER TABLE [dbo].[ServiceProperties] CHECK CONSTRAINT [FK_ServiceProperties_Services] +GO +ALTER TABLE [dbo].[Services] WITH CHECK ADD CONSTRAINT [FK_Services_Clusters] FOREIGN KEY([ClusterID]) +REFERENCES [dbo].[Clusters] ([ClusterID]) +GO +ALTER TABLE [dbo].[Services] CHECK CONSTRAINT [FK_Services_Clusters] +GO +ALTER TABLE [dbo].[Services] WITH CHECK ADD CONSTRAINT [FK_Services_Providers] FOREIGN KEY([ProviderID]) +REFERENCES [dbo].[Providers] ([ProviderID]) +GO +ALTER TABLE [dbo].[Services] CHECK CONSTRAINT [FK_Services_Providers] +GO +ALTER TABLE [dbo].[Services] WITH CHECK ADD CONSTRAINT [FK_Services_Servers] FOREIGN KEY([ServerID]) +REFERENCES [dbo].[Servers] ([ServerID]) +GO +ALTER TABLE [dbo].[Services] CHECK CONSTRAINT [FK_Services_Servers] +GO +ALTER TABLE [dbo].[Users] WITH CHECK ADD CONSTRAINT [FK_Users_Users] FOREIGN KEY([OwnerID]) +REFERENCES [dbo].[Users] ([UserID]) +GO +ALTER TABLE [dbo].[Users] CHECK CONSTRAINT [FK_Users_Users] +GO +ALTER TABLE [dbo].[UserSettings] WITH CHECK ADD CONSTRAINT [FK_UserSettings_Users] FOREIGN KEY([UserID]) +REFERENCES [dbo].[Users] ([UserID]) +ON DELETE CASCADE +GO +ALTER TABLE [dbo].[UserSettings] CHECK CONSTRAINT [FK_UserSettings_Users] +GO +ALTER TABLE [dbo].[VirtualGroups] WITH CHECK ADD CONSTRAINT [FK_VirtualGroups_ResourceGroups] FOREIGN KEY([GroupID]) +REFERENCES [dbo].[ResourceGroups] ([GroupID]) +GO +ALTER TABLE [dbo].[VirtualGroups] CHECK CONSTRAINT [FK_VirtualGroups_ResourceGroups] +GO +ALTER TABLE [dbo].[VirtualGroups] WITH CHECK ADD CONSTRAINT [FK_VirtualGroups_Servers] FOREIGN KEY([ServerID]) +REFERENCES [dbo].[Servers] ([ServerID]) +ON DELETE CASCADE +GO +ALTER TABLE [dbo].[VirtualGroups] CHECK CONSTRAINT [FK_VirtualGroups_Servers] +GO +ALTER TABLE [dbo].[VirtualServices] WITH CHECK ADD CONSTRAINT [FK_VirtualServices_Servers] FOREIGN KEY([ServerID]) +REFERENCES [dbo].[Servers] ([ServerID]) +ON DELETE CASCADE +GO +ALTER TABLE [dbo].[VirtualServices] CHECK CONSTRAINT [FK_VirtualServices_Servers] +GO +ALTER TABLE [dbo].[VirtualServices] WITH CHECK ADD CONSTRAINT [FK_VirtualServices_Services] FOREIGN KEY([ServiceID]) +REFERENCES [dbo].[Services] ([ServiceID]) +GO +ALTER TABLE [dbo].[VirtualServices] CHECK CONSTRAINT [FK_VirtualServices_Services] +GO + diff --git a/WebsitePanel/Database/wix_update_db.sql b/WebsitePanel/Database/wix_update_db.sql new file mode 100644 index 00000000..4f342f1d --- /dev/null +++ b/WebsitePanel/Database/wix_update_db.sql @@ -0,0 +1,10676 @@ +GO + + +--- Fix on version 2.0 +DELETE FROM HostingPlanQuotas WHERE QuotaID = 340 +GO +DELETE FROM HostingPlanQuotas WHERE QuotaID = 341 +GO +DELETE FROM HostingPlanQuotas WHERE QuotaID = 342 +GO +DELETE FROM HostingPlanQuotas WHERE QuotaID = 343 +GO +IF NOT EXISTS (SELECT * FROM [dbo].[ResourceGroups] WHERE GroupID = 33 AND [GroupName] = 'VPS2012') +BEGIN +DELETE FROM HostingPlanResources WHERE GroupID = 33 +END +GO + + +-- Version 2.1 section +IF NOT EXISTS (SELECT * FROM [dbo].[Providers] WHERE [DisplayName] = 'Hosted Microsoft Exchange Server 2013') +BEGIN +INSERT [dbo].[Providers] ([ProviderId], [GroupId], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery]) VALUES(91, 12, N'Exchange2013', N'Hosted Microsoft Exchange Server 2013', N'WebsitePanel.Providers.HostedSolution.Exchange2013, WebsitePanel.Providers.HostedSolution.Exchange2013', N'Exchange', 1) +END +ELSE +BEGIN +UPDATE [dbo].[Providers] SET [DisableAutoDiscovery] = NULL WHERE [DisplayName] = 'Hosted Microsoft Exchange Server 2013' +END +GO + + +IF NOT EXISTS (SELECT * FROM [dbo].[Quotas] WHERE [QuotaName] = 'Exchange2007.AllowLitigationHold') +BEGIN +INSERT [dbo].[Quotas] ([QuotaID], [GroupID],[QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID]) VALUES (420, 12, 24,N'Exchange2007.AllowLitigationHold',N'Allow Litigation Hold',1, 0 , NULL) +END +GO + +IF NOT EXISTS (SELECT * FROM [dbo].[Quotas] WHERE [QuotaName] = 'Exchange2007.RecoverableItemsSpace') +BEGIN +INSERT [dbo].[Quotas] ([QuotaID], [GroupID],[QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID]) VALUES (421, 12, 25,N'Exchange2007.RecoverableItemsSpace',N'Recoverable Items Space',2, 0 , NULL) +END +GO + +IF NOT EXISTS (SELECT * FROM [dbo].[ResourceGroups] WHERE [GroupName] = 'HeliconZoo') +BEGIN +INSERT [dbo].[ResourceGroups] ([GroupID], [GroupName], [GroupOrder], [GroupController], [ShowGroup]) VALUES (42, N'HeliconZoo', 2, N'WebsitePanel.EnterpriseServer.HeliconZooController', 1) +END +GO + +IF NOT EXISTS (SELECT * FROM [dbo].[Providers] WHERE [ProviderName] = 'HeliconZoo') +BEGIN +INSERT [dbo].[Providers] ([ProviderID], [GroupID], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery]) VALUES (135, 42, N'HeliconZoo', N'Web Application Engines', N'WebsitePanel.Providers.Web.HeliconZoo.HeliconZoo, WebsitePanel.Providers.Web.HeliconZoo', N'HeliconZoo', NULL) +END +GO + +IF NOT EXISTS(select 1 from sys.columns COLS INNER JOIN sys.objects OBJS ON OBJS.object_id=COLS.object_id and OBJS.type='U' AND OBJS.name='ExchangeMailboxPlans' AND COLS.name='AllowLitigationHold') +BEGIN +ALTER TABLE [dbo].[ExchangeMailboxPlans] ADD + [AllowLitigationHold] [bit] NULL, + [RecoverableItemsWarningPct] [int] NULL, + [RecoverableItemsSpace] [int] NULL +END +GO + +IF NOT EXISTS(select 1 from sys.columns COLS INNER JOIN sys.objects OBJS ON OBJS.object_id=COLS.object_id and OBJS.type='U' AND OBJS.name='ExchangeMailboxPlans' AND COLS.name='LitigationHoldUrl') +BEGIN +ALTER TABLE [dbo].[ExchangeMailboxPlans] ADD + [LitigationHoldUrl] [nvarchar] (256) COLLATE Latin1_General_CI_AS NULL, + [LitigationHoldMsg] [nvarchar] (512) COLLATE Latin1_General_CI_AS NULL +END +GO + + + + +ALTER PROCEDURE [dbo].[AddExchangeMailboxPlan] +( + @MailboxPlanId int OUTPUT, + @ItemID int, + @MailboxPlan nvarchar(300), + @EnableActiveSync bit, + @EnableIMAP bit, + @EnableMAPI bit, + @EnableOWA bit, + @EnablePOP bit, + @IsDefault bit, + @IssueWarningPct int, + @KeepDeletedItemsDays int, + @MailboxSizeMB int, + @MaxReceiveMessageSizeKB int, + @MaxRecipients int, + @MaxSendMessageSizeKB int, + @ProhibitSendPct int, + @ProhibitSendReceivePct int , + @HideFromAddressBook bit, + @MailboxPlanType int, + @AllowLitigationHold bit, + @RecoverableItemsWarningPct int, + @RecoverableItemsSpace int, + @LitigationHoldUrl nvarchar(256), + @LitigationHoldMsg nvarchar(512) +) +AS + +IF (((SELECT Count(*) FROM ExchangeMailboxPlans WHERE ItemId = @ItemID) = 0) AND (@MailboxPlanType=0)) +BEGIN + SET @IsDefault = 1 +END +ELSE +BEGIN + IF ((@IsDefault = 1) AND (@MailboxPlanType=0)) + BEGIN + UPDATE ExchangeMailboxPlans SET IsDefault = 0 WHERE ItemID = @ItemID + END +END + +INSERT INTO ExchangeMailboxPlans +( + ItemID, + MailboxPlan, + EnableActiveSync, + EnableIMAP, + EnableMAPI, + EnableOWA, + EnablePOP, + IsDefault, + IssueWarningPct, + KeepDeletedItemsDays, + MailboxSizeMB, + MaxReceiveMessageSizeKB, + MaxRecipients, + MaxSendMessageSizeKB, + ProhibitSendPct, + ProhibitSendReceivePct, + HideFromAddressBook, + MailboxPlanType, + AllowLitigationHold, + RecoverableItemsWarningPct, + RecoverableItemsSpace, + LitigationHoldUrl, + LitigationHoldMsg + +) +VALUES +( + @ItemID, + @MailboxPlan, + @EnableActiveSync, + @EnableIMAP, + @EnableMAPI, + @EnableOWA, + @EnablePOP, + @IsDefault, + @IssueWarningPct, + @KeepDeletedItemsDays, + @MailboxSizeMB, + @MaxReceiveMessageSizeKB, + @MaxRecipients, + @MaxSendMessageSizeKB, + @ProhibitSendPct, + @ProhibitSendReceivePct, + @HideFromAddressBook, + @MailboxPlanType, + @AllowLitigationHold, + @RecoverableItemsWarningPct, + @RecoverableItemsSpace, + @LitigationHoldUrl, + @LitigationHoldMsg +) + +SET @MailboxPlanId = SCOPE_IDENTITY() + +RETURN + +GO + + + + + + + + +ALTER PROCEDURE [dbo].[UpdateExchangeMailboxPlan] +( + @MailboxPlanId int, + @MailboxPlan nvarchar(300), + @EnableActiveSync bit, + @EnableIMAP bit, + @EnableMAPI bit, + @EnableOWA bit, + @EnablePOP bit, + @IsDefault bit, + @IssueWarningPct int, + @KeepDeletedItemsDays int, + @MailboxSizeMB int, + @MaxReceiveMessageSizeKB int, + @MaxRecipients int, + @MaxSendMessageSizeKB int, + @ProhibitSendPct int, + @ProhibitSendReceivePct int , + @HideFromAddressBook bit, + @MailboxPlanType int, + @AllowLitigationHold bit, + @RecoverableItemsWarningPct int, + @RecoverableItemsSpace int, + @LitigationHoldUrl nvarchar(256), + @LitigationHoldMsg nvarchar(512) +) +AS + +UPDATE ExchangeMailboxPlans SET + MailboxPlan = @MailboxPlan, + EnableActiveSync = @EnableActiveSync, + EnableIMAP = @EnableIMAP, + EnableMAPI = @EnableMAPI, + EnableOWA = @EnableOWA, + EnablePOP = @EnablePOP, + IsDefault = @IsDefault, + IssueWarningPct= @IssueWarningPct, + KeepDeletedItemsDays = @KeepDeletedItemsDays, + MailboxSizeMB= @MailboxSizeMB, + MaxReceiveMessageSizeKB= @MaxReceiveMessageSizeKB, + MaxRecipients= @MaxRecipients, + MaxSendMessageSizeKB= @MaxSendMessageSizeKB, + ProhibitSendPct= @ProhibitSendPct, + ProhibitSendReceivePct = @ProhibitSendReceivePct, + HideFromAddressBook = @HideFromAddressBook, + MailboxPlanType = @MailboxPlanType, + AllowLitigationHold = @AllowLitigationHold, + RecoverableItemsWarningPct = @RecoverableItemsWarningPct, + RecoverableItemsSpace = @RecoverableItemsSpace, + LitigationHoldUrl = @LitigationHoldUrl, + LitigationHoldMsg = @LitigationHoldMsg + +WHERE MailboxPlanId = @MailboxPlanId + +RETURN + +GO + + + +ALTER PROCEDURE [dbo].[GetExchangeMailboxPlan] +( + @MailboxPlanId int +) +AS +SELECT + MailboxPlanId, + ItemID, + MailboxPlan, + EnableActiveSync, + EnableIMAP, + EnableMAPI, + EnableOWA, + EnablePOP, + IsDefault, + IssueWarningPct, + KeepDeletedItemsDays, + MailboxSizeMB, + MaxReceiveMessageSizeKB, + MaxRecipients, + MaxSendMessageSizeKB, + ProhibitSendPct, + ProhibitSendReceivePct, + HideFromAddressBook, + MailboxPlanType, + AllowLitigationHold, + RecoverableItemsWarningPct, + RecoverableItemsSpace, + LitigationHoldUrl, + LitigationHoldMsg +FROM + ExchangeMailboxPlans +WHERE + MailboxPlanId = @MailboxPlanId +RETURN + +GO + + + +ALTER PROCEDURE [dbo].[GetExchangeOrganizationStatistics] +( + @ItemID int +) +AS + +IF -1 IN (SELECT B.MailboxSizeMB FROM ExchangeAccounts AS A INNER JOIN ExchangeMailboxPlans AS B ON A.MailboxPlanId = B.MailboxPlanId WHERE A.ItemID=@ItemID) +BEGIN +SELECT + (SELECT COUNT(*) FROM ExchangeAccounts WHERE (AccountType = 1 OR AccountType = 5 OR AccountType = 6) AND ItemID = @ItemID) AS CreatedMailboxes, + (SELECT COUNT(*) FROM ExchangeAccounts WHERE AccountType = 2 AND ItemID = @ItemID) AS CreatedContacts, + (SELECT COUNT(*) FROM ExchangeAccounts WHERE AccountType = 3 AND ItemID = @ItemID) AS CreatedDistributionLists, + (SELECT COUNT(*) FROM ExchangeAccounts WHERE AccountType = 4 AND ItemID = @ItemID) AS CreatedPublicFolders, + (SELECT COUNT(*) FROM ExchangeOrganizationDomains WHERE ItemID = @ItemID) AS CreatedDomains, + (SELECT MIN(B.MailboxSizeMB) FROM ExchangeAccounts AS A INNER JOIN ExchangeMailboxPlans AS B ON A.MailboxPlanId = B.MailboxPlanId WHERE A.ItemID=@ItemID) AS UsedDiskSpace, + (SELECT MIN(B.RecoverableItemsSpace) FROM ExchangeAccounts AS A INNER JOIN ExchangeMailboxPlans AS B ON A.MailboxPlanId = B.MailboxPlanId WHERE A.ItemID=@ItemID) AS UsedLitigationHoldSpace +END +ELSE +BEGIN +SELECT + (SELECT COUNT(*) FROM ExchangeAccounts WHERE (AccountType = 1 OR AccountType = 5 OR AccountType = 6) AND ItemID = @ItemID) AS CreatedMailboxes, + (SELECT COUNT(*) FROM ExchangeAccounts WHERE AccountType = 2 AND ItemID = @ItemID) AS CreatedContacts, + (SELECT COUNT(*) FROM ExchangeAccounts WHERE AccountType = 3 AND ItemID = @ItemID) AS CreatedDistributionLists, + (SELECT COUNT(*) FROM ExchangeAccounts WHERE AccountType = 4 AND ItemID = @ItemID) AS CreatedPublicFolders, + (SELECT COUNT(*) FROM ExchangeOrganizationDomains WHERE ItemID = @ItemID) AS CreatedDomains, + (SELECT SUM(B.MailboxSizeMB) FROM ExchangeAccounts AS A INNER JOIN ExchangeMailboxPlans AS B ON A.MailboxPlanId = B.MailboxPlanId WHERE A.ItemID=@ItemID) AS UsedDiskSpace, + (SELECT SUM(B.RecoverableItemsSpace) FROM ExchangeAccounts AS A INNER JOIN ExchangeMailboxPlans AS B ON A.MailboxPlanId = B.MailboxPlanId WHERE A.ItemID=@ItemID) AS UsedLitigationHoldSpace +END + + +RETURN +GO + + +-- UPDATE Domains SET IsDomainPointer=0, DomainItemID=NULL WHERE MailDomainID IS NOT NULL AND isDomainPointer=1 + + +ALTER PROCEDURE [dbo].[GetPackageQuotas] +( + @ActorID int, + @PackageID int +) +AS + +-- check rights +IF dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 +RAISERROR('You are not allowed to access this package', 16, 1) + +DECLARE @PlanID int, @ParentPackageID int +SELECT @PlanID = PlanID, @ParentPackageID = ParentPackageID FROM Packages +WHERE PackageID = @PackageID + +-- get resource groups +SELECT + RG.GroupID, + RG.GroupName, + ISNULL(HPR.CalculateDiskSpace, 0) AS CalculateDiskSpace, + ISNULL(HPR.CalculateBandwidth, 0) AS CalculateBandwidth, + dbo.GetPackageAllocatedResource(@ParentPackageID, RG.GroupID, 0) AS ParentEnabled +FROM ResourceGroups AS RG +LEFT OUTER JOIN HostingPlanResources AS HPR ON RG.GroupID = HPR.GroupID AND HPR.PlanID = @PlanID +WHERE dbo.GetPackageAllocatedResource(@PackageID, RG.GroupID, 0) = 1 +ORDER BY RG.GroupOrder + + +-- return quotas +SELECT + Q.QuotaID, + Q.GroupID, + Q.QuotaName, + Q.QuotaDescription, + Q.QuotaTypeID, + dbo.GetPackageAllocatedQuota(@PackageID, Q.QuotaID) AS QuotaValue, + dbo.GetPackageAllocatedQuota(@ParentPackageID, Q.QuotaID) AS ParentQuotaValue, + ISNULL(dbo.CalculateQuotaUsage(@PackageID, Q.QuotaID), 0) AS QuotaUsedValue +FROM Quotas AS Q +WHERE Q.HideQuota IS NULL OR Q.HideQuota = 0 +ORDER BY Q.QuotaOrder +RETURN + +GO + + + + + + + +ALTER PROCEDURE [dbo].[UpdateServiceProperties] +( + @ServiceID int, + @Xml ntext +) +AS + +-- delete old properties +BEGIN TRAN +DECLARE @idoc int +--Create an internal representation of the XML document. +EXEC sp_xml_preparedocument @idoc OUTPUT, @xml + +-- Execute a SELECT statement that uses the OPENXML rowset provider. +DELETE FROM ServiceProperties +WHERE ServiceID = @ServiceID +AND PropertyName COLLATE Latin1_General_CI_AS IN +( + SELECT PropertyName + FROM OPENXML(@idoc, '/properties/property', 1) + WITH (PropertyName nvarchar(50) '@name') +) + +INSERT INTO ServiceProperties +( + ServiceID, + PropertyName, + PropertyValue +) +SELECT + @ServiceID, + PropertyName, + PropertyValue +FROM OPENXML(@idoc, '/properties/property',1) WITH +( + PropertyName nvarchar(50) '@name', + PropertyValue nvarchar(1000) '@value' +) as PV + +-- remove document +exec sp_xml_removedocument @idoc + +COMMIT TRAN +RETURN +GO + +IF NOT EXISTS (SELECT * FROM [dbo].[Providers] WHERE [DisplayName] = 'Hosted MS CRM 2011') +BEGIN +INSERT [dbo].[Providers] ([ProviderID], [GroupID], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery]) VALUES (1201, 21, N'CRM', N'Hosted MS CRM 2011', N'WebsitePanel.Providers.HostedSolution.CRMProvider2011, WebsitePanel.Providers.HostedSolution.CRM2011', N'CRM', NULL) +END +GO + + +UPDATE Providers SET ProviderType = N'WebsitePanel.Providers.HostedSolution.CRMProvider2011, WebsitePanel.Providers.HostedSolution.CRM2011' WHERE ProviderID = 1201 +GO + +IF NOT EXISTS (SELECT * FROM [dbo].[Providers] WHERE [DisplayName] = 'Hosted SharePoint Foundation 2013') +BEGIN +INSERT [dbo].[Providers] ([ProviderID], [GroupID], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery]) +VALUES (1301, 20, N'HostedSharePoint2013', N'Hosted SharePoint Foundation 2013', N'WebsitePanel.Providers.HostedSolution.HostedSharePointServer2013, WebsitePanel.Providers.HostedSolution.SharePoint2013', N'HostedSharePoint30', NULL) +END +GO + +UPDATE Providers SET ProviderType = N'WebsitePanel.Providers.HostedSolution.HostedSharePointServer2013, WebsitePanel.Providers.HostedSolution.SharePoint2013' WHERE ProviderID = 1301 +GO + +IF NOT EXISTS (SELECT * FROM [dbo].[Providers] WHERE [ProviderName] = 'Lync2013') +BEGIN +INSERT [dbo].[Providers] ([ProviderID], [GroupID], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery]) +VALUES (1401, 41, N'Lync2013', N'Microsoft Lync Server 2013 Multitenant Hosting Pack', N'WebsitePanel.Providers.HostedSolution.Lync2013, WebsitePanel.Providers.HostedSolution.Lync2013', N'Lync', NULL) +END +GO + +UPDATE Providers SET DisplayName = N'Microsoft Lync Server 2013 Enterprise Edition' WHERE ProviderID = 1401 +GO + +IF NOT EXISTS (SELECT * FROM [dbo].[Providers] WHERE [ProviderName] = 'Lync2013HP') +BEGIN +INSERT [dbo].[Providers] ([ProviderID], [GroupID], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery]) +VALUES (1402, 41, N'Lync2013HP', N'Microsoft Lync Server 2013 Multitenant Hosting Pack', N'WebsitePanel.Providers.HostedSolution.Lync2013HP, WebsitePanel.Providers.HostedSolution.Lync2013HP', N'Lync', NULL) +END +GO + + +-- add Application Pools Restart Quota + +IF NOT EXISTS (SELECT * FROM [dbo].[Quotas] WHERE ([QuotaName] = N'Web.AppPoolsRestart')) +BEGIN + INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (411, 2, 13, N'Web.AppPoolsRestart', N'Application Pools Restart', 1, 0, NULL, NULL) +END +GO +-------------------------------- Scheduler Service------------------------------------------------------ + +IF EXISTS( SELECT * FROM INFORMATION_SCHEMA.COLUMNS + WHERE TABLE_NAME = 'Schedule' + AND COLUMN_NAME = 'LastFinish') +ALTER TABLE Schedule +DROP COLUMN LastFinish +GO + +ALTER PROCEDURE [dbo].[GetSchedule] +( + @ActorID int, + @ScheduleID int +) +AS + +-- select schedule +SELECT TOP 1 + S.ScheduleID, + S.TaskID, + S.PackageID, + S.ScheduleName, + S.ScheduleTypeID, + S.Interval, + S.FromTime, + S.ToTime, + S.StartTime, + S.LastRun, + S.NextRun, + S.Enabled, + S.HistoriesNumber, + S.PriorityID, + S.MaxExecutionTime, + S.WeekMonthDay, + 1 AS StatusID +FROM Schedule AS S +WHERE + S.ScheduleID = @ScheduleID + AND dbo.CheckActorPackageRights(@ActorID, S.PackageID) = 1 + +-- select task +SELECT + ST.TaskID, + ST.TaskType, + ST.RoleID +FROM Schedule AS S +INNER JOIN ScheduleTasks AS ST ON S.TaskID = ST.TaskID +WHERE + S.ScheduleID = @ScheduleID + AND dbo.CheckActorPackageRights(@ActorID, S.PackageID) = 1 + +-- select schedule parameters +SELECT + S.ScheduleID, + STP.ParameterID, + STP.DataTypeID, + ISNULL(SP.ParameterValue, STP.DefaultValue) AS ParameterValue +FROM Schedule AS S +INNER JOIN ScheduleTaskParameters AS STP ON S.TaskID = STP.TaskID +LEFT OUTER JOIN ScheduleParameters AS SP ON STP.ParameterID = SP.ParameterID AND SP.ScheduleID = S.ScheduleID +WHERE + S.ScheduleID = @ScheduleID + AND dbo.CheckActorPackageRights(@ActorID, S.PackageID) = 1 + +RETURN +GO + +ALTER PROCEDURE [dbo].[GetScheduleInternal] +( + @ScheduleID int +) +AS + +-- select schedule +SELECT + S.ScheduleID, + S.TaskID, + ST.TaskType, + ST.RoleID, + S.PackageID, + S.ScheduleName, + S.ScheduleTypeID, + S.Interval, + S.FromTime, + S.ToTime, + S.StartTime, + S.LastRun, + S.NextRun, + S.Enabled, + 1 AS StatusID, + S.PriorityID, + S.HistoriesNumber, + S.MaxExecutionTime, + S.WeekMonthDay +FROM Schedule AS S +INNER JOIN ScheduleTasks AS ST ON S.TaskID = ST.TaskID +WHERE ScheduleID = @ScheduleID +RETURN +GO + +ALTER PROCEDURE [dbo].[GetSchedules] +( + @ActorID int, + @PackageID int, + @Recursive bit +) +AS + +-- check rights +IF dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 +RAISERROR('You are not allowed to access this package', 16, 1) + +DECLARE @Schedules TABLE +( + ScheduleID int +) + +INSERT INTO @Schedules (ScheduleID) +SELECT + S.ScheduleID +FROM Schedule AS S +INNER JOIN PackagesTree(@PackageID, @Recursive) AS PT ON S.PackageID = PT.PackageID +ORDER BY S.Enabled DESC, S.NextRun + + +-- select schedules +SELECT + S.ScheduleID, + S.TaskID, + ST.TaskType, + ST.RoleID, + S.PackageID, + S.ScheduleName, + S.ScheduleTypeID, + S.Interval, + S.FromTime, + S.ToTime, + S.StartTime, + S.LastRun, + S.NextRun, + S.Enabled, + 1 AS StatusID, + S.PriorityID, + S.MaxExecutionTime, + S.WeekMonthDay, + ISNULL(0, (SELECT TOP 1 SeverityID FROM AuditLog WHERE ItemID = S.ScheduleID AND SourceName = 'SCHEDULER' ORDER BY StartDate DESC)) AS LastResult, + + U.Username, + U.FirstName, + U.LastName, + U.FullName, + U.RoleID, + U.Email +FROM @Schedules AS STEMP +INNER JOIN Schedule AS S ON STEMP.ScheduleID = S.ScheduleID +INNER JOIN Packages AS P ON S.PackageID = P.PackageID +INNER JOIN ScheduleTasks AS ST ON S.TaskID = ST.TaskID +INNER JOIN UsersDetailed AS U ON P.UserID = U.UserID + +-- select schedule parameters +SELECT + S.ScheduleID, + STP.ParameterID, + STP.DataTypeID, + ISNULL(SP.ParameterValue, STP.DefaultValue) AS ParameterValue +FROM @Schedules AS STEMP +INNER JOIN Schedule AS S ON STEMP.ScheduleID = S.ScheduleID +INNER JOIN ScheduleTaskParameters AS STP ON S.TaskID = STP.TaskID +LEFT OUTER JOIN ScheduleParameters AS SP ON STP.ParameterID = SP.ParameterID AND SP.ScheduleID = S.ScheduleID +RETURN +GO + +ALTER PROCEDURE [dbo].[GetSchedulesPaged] +( + @ActorID int, + @PackageID int, + @Recursive bit, + @FilterColumn nvarchar(50) = '', + @FilterValue nvarchar(50) = '', + @SortColumn nvarchar(50), + @StartRow int, + @MaximumRows int +) +AS +BEGIN + +-- check rights +IF dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 +RAISERROR('You are not allowed to access this package', 16, 1) + +DECLARE @condition nvarchar(400) +SET @condition = ' 1 = 1 ' + +IF @FilterColumn <> '' AND @FilterColumn IS NOT NULL +AND @FilterValue <> '' AND @FilterValue IS NOT NULL +SET @condition = @condition + ' AND ' + @FilterColumn + ' LIKE ''' + @FilterValue + '''' + +IF @SortColumn IS NULL OR @SortColumn = '' +SET @SortColumn = 'S.ScheduleName ASC' + +DECLARE @sql nvarchar(3500) + +set @sql = ' +SELECT COUNT(S.ScheduleID) FROM Schedule AS S +INNER JOIN PackagesTree(@PackageID, @Recursive) AS PT ON S.PackageID = PT.PackageID +INNER JOIN Packages AS P ON S.PackageID = P.PackageID +INNER JOIN UsersDetailed AS U ON P.UserID = U.UserID +WHERE ' + @condition + ' + +DECLARE @Schedules AS TABLE +( + ScheduleID int +); + +WITH TempSchedules AS ( + SELECT ROW_NUMBER() OVER (ORDER BY ' + @SortColumn + ') as Row, + S.ScheduleID + FROM Schedule AS S + INNER JOIN Packages AS P ON S.PackageID = P.PackageID + INNER JOIN PackagesTree(@PackageID, @Recursive) AS PT ON S.PackageID = PT.PackageID + INNER JOIN UsersDetailed AS U ON P.UserID = U.UserID + WHERE ' + @condition + ' +) + +INSERT INTO @Schedules +SELECT ScheduleID FROM TempSchedules +WHERE TempSchedules.Row BETWEEN @StartRow and @StartRow + @MaximumRows - 1 + +SELECT + S.ScheduleID, + S.TaskID, + ST.TaskType, + ST.RoleID, + S.ScheduleName, + S.ScheduleTypeID, + S.Interval, + S.FromTime, + S.ToTime, + S.StartTime, + S.LastRun, + S.NextRun, + S.Enabled, + 1 AS StatusID, + S.PriorityID, + S.MaxExecutionTime, + S.WeekMonthDay, + ISNULL(0, (SELECT TOP 1 SeverityID FROM AuditLog WHERE ItemID = S.ScheduleID AND SourceName = ''SCHEDULER'' ORDER BY StartDate DESC)) AS LastResult, + + -- packages + P.PackageID, + P.PackageName, + + -- user + P.UserID, + U.Username, + U.FirstName, + U.LastName, + U.FullName, + U.RoleID, + U.Email +FROM @Schedules AS STEMP +INNER JOIN Schedule AS S ON STEMP.ScheduleID = S.ScheduleID +INNER JOIN ScheduleTasks AS ST ON S.TaskID = ST.TaskID +INNER JOIN Packages AS P ON S.PackageID = P.PackageID +INNER JOIN UsersDetailed AS U ON P.UserID = U.UserID' + +exec sp_executesql @sql, N'@PackageID int, @StartRow int, @MaximumRows int, @Recursive bit', +@PackageID, @StartRow, @MaximumRows, @Recursive + +END +RETURN +GO + +ALTER PROCEDURE [dbo].[UpdateSchedule] +( + @ActorID int, + @ScheduleID int, + @TaskID nvarchar(100), + @ScheduleName nvarchar(100), + @ScheduleTypeID nvarchar(50), + @Interval int, + @FromTime datetime, + @ToTime datetime, + @StartTime datetime, + @LastRun datetime, + @NextRun datetime, + @Enabled bit, + @PriorityID nvarchar(50), + @HistoriesNumber int, + @MaxExecutionTime int, + @WeekMonthDay int, + @XmlParameters ntext +) +AS + +-- check rights +DECLARE @PackageID int +SELECT @PackageID = PackageID FROM Schedule +WHERE ScheduleID = @ScheduleID + +IF dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 +RAISERROR('You are not allowed to access this package', 16, 1) + +BEGIN TRAN + +UPDATE Schedule +SET + TaskID = @TaskID, + ScheduleName = @ScheduleName, + ScheduleTypeID = @ScheduleTypeID, + Interval = @Interval, + FromTime = @FromTime, + ToTime = @ToTime, + StartTime = @StartTime, + LastRun = @LastRun, + NextRun = @NextRun, + Enabled = @Enabled, + PriorityID = @PriorityID, + HistoriesNumber = @HistoriesNumber, + MaxExecutionTime = @MaxExecutionTime, + WeekMonthDay = @WeekMonthDay +WHERE + ScheduleID = @ScheduleID + +DECLARE @idoc int +--Create an internal representation of the XML document. +EXEC sp_xml_preparedocument @idoc OUTPUT, @XmlParameters + +-- Execute a SELECT statement that uses the OPENXML rowset provider. +DELETE FROM ScheduleParameters +WHERE ScheduleID = @ScheduleID + +INSERT INTO ScheduleParameters +( + ScheduleID, + ParameterID, + ParameterValue +) +SELECT + @ScheduleID, + ParameterID, + ParameterValue +FROM OPENXML(@idoc, '/parameters/parameter',1) WITH +( + ParameterID nvarchar(50) '@id', + ParameterValue nvarchar(3000) '@value' +) as PV + +-- remove document +exec sp_xml_removedocument @idoc + +COMMIT TRAN +RETURN +GO + +UPDATE ScheduleTasks SET TaskType = RTRIM(TaskType) + '.Code' +WHERE SUBSTRING(RTRIM(TaskType), LEN(RTRIM(TaskType)) - 3, 4) <> 'Code' +GO + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'GetRunningSchedules') +DROP PROCEDURE GetRunningSchedules +GO + +IF EXISTS (SELECT * FROM SYS.TABLES WHERE name = 'BackgroundTaskStack') +DROP TABLE BackgroundTaskStack +GO + +IF EXISTS (SELECT * FROM SYS.TABLES WHERE name = 'BackgroundTaskLogs') +DROP TABLE BackgroundTaskLogs +GO + +IF EXISTS (SELECT * FROM SYS.TABLES WHERE name = 'BackgroundTaskParameters') +DROP TABLE BackgroundTaskParameters +GO + +IF EXISTS (SELECT * FROM SYS.TABLES WHERE name = 'BackgroundTasks') +DROP TABLE BackgroundTasks +GO + +CREATE TABLE BackgroundTasks +( + ID INT IDENTITY(1,1) NOT NULL PRIMARY KEY, + Guid UNIQUEIDENTIFIER NOT NULL, + TaskID NVARCHAR(255), + ScheduleID INT NOT NULL, + PackageID INT NOT NULL, + UserID INT NOT NULL, + EffectiveUserID INT NOT NULL, + TaskName NVARCHAR(255), + ItemID INT, + ItemName NVARCHAR(255), + StartDate DATETIME NOT NULL, + FinishDate DATETIME, + IndicatorCurrent INT NOT NULL, + IndicatorMaximum INT NOT NULL, + MaximumExecutionTime INT NOT NULL, + Source NVARCHAR(MAX), + Severity INT NOT NULL, + Completed BIT, + NotifyOnComplete BIT, + Status INT NOT NULL +) +GO + +CREATE TABLE BackgroundTaskParameters +( + ParameterID INT IDENTITY(1,1) NOT NULL PRIMARY KEY, + TaskID INT NOT NULL, + Name NVARCHAR(255), + SerializerValue NTEXT, + TypeName NVARCHAR(255), + FOREIGN KEY (TaskID) REFERENCES BackgroundTasks (ID) +) +GO + +CREATE TABLE BackgroundTaskLogs +( + LogID INT IDENTITY(1,1) NOT NULL PRIMARY KEY, + TaskID INT NOT NULL, + Date DATETIME, + ExceptionStackTrace NTEXT, + InnerTaskStart INT, + Severity INT, + Text NTEXT, + TextIdent INT, + XmlParameters NTEXT, + FOREIGN KEY (TaskID) REFERENCES BackgroundTasks (ID) +) +GO + +CREATE TABLE BackgroundTaskStack +( + TaskStackID INT IDENTITY(1,1) NOT NULL PRIMARY KEY, + TaskID INT NOT NULL, + FOREIGN KEY (TaskID) REFERENCES BackgroundTasks (ID) +) +GO + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'AddBackgroundTask') +DROP PROCEDURE AddBackgroundTask +GO + +CREATE PROCEDURE [dbo].[AddBackgroundTask] +( + @BackgroundTaskID INT OUTPUT, + @Guid UNIQUEIDENTIFIER, + @TaskID NVARCHAR(255), + @ScheduleID INT, + @PackageID INT, + @UserID INT, + @EffectiveUserID INT, + @TaskName NVARCHAR(255), + @ItemID INT, + @ItemName NVARCHAR(255), + @StartDate DATETIME, + @IndicatorCurrent INT, + @IndicatorMaximum INT, + @MaximumExecutionTime INT, + @Source NVARCHAR(MAX), + @Severity INT, + @Completed BIT, + @NotifyOnComplete BIT, + @Status INT +) +AS + +INSERT INTO BackgroundTasks +( + Guid, + TaskID, + ScheduleID, + PackageID, + UserID, + EffectiveUserID, + TaskName, + ItemID, + ItemName, + StartDate, + IndicatorCurrent, + IndicatorMaximum, + MaximumExecutionTime, + Source, + Severity, + Completed, + NotifyOnComplete, + Status +) +VALUES +( + @Guid, + @TaskID, + @ScheduleID, + @PackageID, + @UserID, + @EffectiveUserID, + @TaskName, + @ItemID, + @ItemName, + @StartDate, + @IndicatorCurrent, + @IndicatorMaximum, + @MaximumExecutionTime, + @Source, + @Severity, + @Completed, + @NotifyOnComplete, + @Status +) + +SET @BackgroundTaskID = SCOPE_IDENTITY() + +RETURN +GO + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'GetBackgroundTask') +DROP PROCEDURE GetBackgroundTask +GO + +CREATE PROCEDURE [dbo].[GetBackgroundTask] +( + @TaskID NVARCHAR(255) +) +AS + +SELECT TOP 1 + T.ID, + T.Guid, + T.TaskID, + T.ScheduleID, + T.PackageID, + T.UserID, + T.EffectiveUserID, + T.TaskName, + T.ItemID, + T.ItemName, + T.StartDate, + T.FinishDate, + T.IndicatorCurrent, + T.IndicatorMaximum, + T.MaximumExecutionTime, + T.Source, + T.Severity, + T.Completed, + T.NotifyOnComplete, + T.Status +FROM BackgroundTasks AS T +INNER JOIN BackgroundTaskStack AS TS + ON TS.TaskId = T.ID +WHERE T.TaskID = @TaskID +GO + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'GetBackgroundTasks') +DROP PROCEDURE GetBackgroundTasks +GO + +CREATE PROCEDURE [dbo].[GetBackgroundTasks] +( + @ActorID INT +) +AS + + with GetChildUsersId(id) as ( + select UserID + from Users + where UserID = @ActorID + union all + select C.UserId + from GetChildUsersId P + inner join Users C on P.id = C.OwnerID +) + +SELECT + T.ID, + T.Guid, + T.TaskID, + T.ScheduleId, + T.PackageId, + T.UserId, + T.EffectiveUserId, + T.TaskName, + T.ItemId, + T.ItemName, + T.StartDate, + T.FinishDate, + T.IndicatorCurrent, + T.IndicatorMaximum, + T.MaximumExecutionTime, + T.Source, + T.Severity, + T.Completed, + T.NotifyOnComplete, + T.Status +FROM BackgroundTasks AS T +INNER JOIN (SELECT T.Guid, MIN(T.StartDate) AS Date + FROM BackgroundTasks AS T + INNER JOIN BackgroundTaskStack AS TS + ON TS.TaskId = T.ID + WHERE T.UserID in (select id from GetChildUsersId) + GROUP BY T.Guid) AS TT ON TT.Guid = T.Guid AND TT.Date = T.StartDate +GO + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'GetThreadBackgroundTasks') +DROP PROCEDURE GetThreadBackgroundTasks +GO + +CREATE PROCEDURE [dbo].GetThreadBackgroundTasks +( + @Guid UNIQUEIDENTIFIER +) +AS + +SELECT + T.ID, + T.Guid, + T.TaskID, + T.ScheduleId, + T.PackageId, + T.UserId, + T.EffectiveUserId, + T.TaskName, + T.ItemId, + T.ItemName, + T.StartDate, + T.FinishDate, + T.IndicatorCurrent, + T.IndicatorMaximum, + T.MaximumExecutionTime, + T.Source, + T.Severity, + T.Completed, + T.NotifyOnComplete, + T.Status +FROM BackgroundTasks AS T +INNER JOIN BackgroundTaskStack AS TS + ON TS.TaskId = T.ID +WHERE T.Guid = @Guid +GO + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'GetBackgroundTopTask') +DROP PROCEDURE GetBackgroundTopTask +GO + +CREATE PROCEDURE [dbo].[GetBackgroundTopTask] +( + @Guid UNIQUEIDENTIFIER +) +AS + +SELECT TOP 1 + T.ID, + T.Guid, + T.TaskID, + T.ScheduleId, + T.PackageId, + T.UserId, + T.EffectiveUserId, + T.TaskName, + T.ItemId, + T.ItemName, + T.StartDate, + T.FinishDate, + T.IndicatorCurrent, + T.IndicatorMaximum, + T.MaximumExecutionTime, + T.Source, + T.Severity, + T.Completed, + T.NotifyOnComplete, + T.Status +FROM BackgroundTasks AS T +INNER JOIN BackgroundTaskStack AS TS + ON TS.TaskId = T.ID +WHERE T.Guid = @Guid +ORDER BY T.StartDate ASC +GO + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'AddBackgroundTaskLog') +DROP PROCEDURE AddBackgroundTaskLog +GO + +CREATE PROCEDURE [dbo].[AddBackgroundTaskLog] +( + @TaskID INT, + @Date DATETIME, + @ExceptionStackTrace NTEXT, + @InnerTaskStart INT, + @Severity INT, + @Text NTEXT, + @TextIdent INT, + @XmlParameters NTEXT +) +AS + +INSERT INTO BackgroundTaskLogs +( + TaskID, + Date, + ExceptionStackTrace, + InnerTaskStart, + Severity, + Text, + TextIdent, + XmlParameters +) +VALUES +( + @TaskID, + @Date, + @ExceptionStackTrace, + @InnerTaskStart, + @Severity, + @Text, + @TextIdent, + @XmlParameters +) +GO + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'GetBackgroundTaskLogs') +DROP PROCEDURE GetBackgroundTaskLogs +GO + +CREATE PROCEDURE [dbo].[GetBackgroundTaskLogs] +( + @TaskID INT, + @StartLogTime DATETIME +) +AS + +SELECT + L.LogID, + L.TaskID, + L.Date, + L.ExceptionStackTrace, + L.InnerTaskStart, + L.Severity, + L.Text, + L.XmlParameters +FROM BackgroundTaskLogs AS L +WHERE L.TaskID = @TaskID AND L.Date >= @StartLogTime +ORDER BY L.Date +GO + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'UpdateBackgroundTask') +DROP PROCEDURE UpdateBackgroundTask +GO + +CREATE PROCEDURE [dbo].[UpdateBackgroundTask] +( + @Guid UNIQUEIDENTIFIER, + @TaskID INT, + @ScheduleID INT, + @PackageID INT, + @TaskName NVARCHAR(255), + @ItemID INT, + @ItemName NVARCHAR(255), + @FinishDate DATETIME, + @IndicatorCurrent INT, + @IndicatorMaximum INT, + @MaximumExecutionTime INT, + @Source NVARCHAR(MAX), + @Severity INT, + @Completed BIT, + @NotifyOnComplete BIT, + @Status INT +) +AS + +UPDATE BackgroundTasks +SET + Guid = @Guid, + ScheduleID = @ScheduleID, + PackageID = @PackageID, + TaskName = @TaskName, + ItemID = @ItemID, + ItemName = @ItemName, + FinishDate = @FinishDate, + IndicatorCurrent = @IndicatorCurrent, + IndicatorMaximum = @IndicatorMaximum, + MaximumExecutionTime = @MaximumExecutionTime, + Source = @Source, + Severity = @Severity, + Completed = @Completed, + NotifyOnComplete = @NotifyOnComplete, + Status = @Status +WHERE ID = @TaskID +GO + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'GetBackgroundTaskParams') +DROP PROCEDURE GetBackgroundTaskParams +GO + +CREATE PROCEDURE [dbo].[GetBackgroundTaskParams] +( + @TaskID INT +) +AS + +SELECT + P.ParameterID, + P.TaskID, + P.Name, + P.SerializerValue, + P.TypeName +FROM BackgroundTaskParameters AS P +WHERE P.TaskID = @TaskID +GO + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'AddBackgroundTaskParam') +DROP PROCEDURE AddBackgroundTaskParam +GO + +CREATE PROCEDURE [dbo].[AddBackgroundTaskParam] +( + @TaskID INT, + @Name NVARCHAR(255), + @Value NTEXT, + @TypeName NVARCHAR(255) +) +AS + +INSERT INTO BackgroundTaskParameters +( + TaskID, + Name, + SerializerValue, + TypeName +) +VALUES +( + @TaskID, + @Name, + @Value, + @TypeName +) +GO + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'DeleteBackgroundTaskParams') +DROP PROCEDURE DeleteBackgroundTaskParams +GO + +CREATE PROCEDURE [dbo].[DeleteBackgroundTaskParams] +( + @TaskID INT +) +AS + +DELETE FROM BackgroundTaskParameters +WHERE TaskID = @TaskID +GO + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'AddBackgroundTaskStack') +DROP PROCEDURE AddBackgroundTaskStack +GO + +CREATE PROCEDURE [dbo].[AddBackgroundTaskStack] +( + @TaskID INT +) +AS + +INSERT INTO BackgroundTaskStack +( + TaskID +) +VALUES +( + @TaskID +) +GO + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'DeleteBackgroundTasks') +DROP PROCEDURE DeleteBackgroundTasks +GO + +CREATE PROCEDURE [dbo].[DeleteBackgroundTasks] +( + @Guid UNIQUEIDENTIFIER +) +AS + +DELETE FROM BackgroundTaskStack +WHERE TaskID IN (SELECT ID FROM BackgroundTasks WHERE Guid = @Guid) + +DELETE FROM BackgroundTaskLogs +WHERE TaskID IN (SELECT ID FROM BackgroundTasks WHERE Guid = @Guid) + +DELETE FROM BackgroundTaskParameters +WHERE TaskID IN (SELECT ID FROM BackgroundTasks WHERE Guid = @Guid) + +DELETE FROM BackgroundTasks +WHERE ID IN (SELECT ID FROM BackgroundTasks WHERE Guid = @Guid) +GO + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'DeleteBackgroundTask') +DROP PROCEDURE DeleteBackgroundTask +GO + +CREATE PROCEDURE [dbo].[DeleteBackgroundTask] +( + @ID INT +) +AS + +DELETE FROM BackgroundTaskStack +WHERE TaskID = @ID + +DELETE FROM BackgroundTaskLogs +WHERE TaskID = @ID + +DELETE FROM BackgroundTaskParameters +WHERE TaskID = @ID + +DELETE FROM BackgroundTasks +WHERE ID = @ID +GO + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'GetProcessBackgroundTasks') +DROP PROCEDURE GetProcessBackgroundTasks +GO + +CREATE PROCEDURE [dbo].[GetProcessBackgroundTasks] +( + @Status INT +) +AS + +SELECT + T.ID, + T.TaskID, + T.ScheduleId, + T.PackageId, + T.UserId, + T.EffectiveUserId, + T.TaskName, + T.ItemId, + T.ItemName, + T.StartDate, + T.FinishDate, + T.IndicatorCurrent, + T.IndicatorMaximum, + T.MaximumExecutionTime, + T.Source, + T.Severity, + T.Completed, + T.NotifyOnComplete, + T.Status +FROM BackgroundTasks AS T +WHERE T.Completed = 0 AND T.Status = @Status +GO + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'GetScheduleBackgroundTasks') +DROP PROCEDURE GetScheduleBackgroundTasks +GO + +CREATE PROCEDURE [dbo].[GetScheduleBackgroundTasks] +( + @ScheduleID INT +) +AS + +SELECT + T.ID, + T.Guid, + T.TaskID, + T.ScheduleId, + T.PackageId, + T.UserId, + T.EffectiveUserId, + T.TaskName, + T.ItemId, + T.ItemName, + T.StartDate, + T.FinishDate, + T.IndicatorCurrent, + T.IndicatorMaximum, + T.MaximumExecutionTime, + T.Source, + T.Severity, + T.Completed, + T.NotifyOnComplete, + T.Status +FROM BackgroundTasks AS T +WHERE T.Guid = ( + SELECT Guid FROM BackgroundTasks + WHERE ScheduleID = @ScheduleID + AND Completed = 0 AND Status IN (1, 3)) +GO + +-- Disclaimers + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + +IF NOT EXISTS (SELECT * FROM SYS.TABLES WHERE name = 'ExchangeDisclaimers') + +CREATE TABLE [dbo].[ExchangeDisclaimers]( + [ExchangeDisclaimerId] [int] IDENTITY(1,1) NOT NULL, + [ItemID] [int] NOT NULL, + [DisclaimerName] [nvarchar](300) NOT NULL, + [DisclaimerText] [nvarchar](1024), + CONSTRAINT [PK_ExchangeDisclaimers] PRIMARY KEY CLUSTERED +( + [ExchangeDisclaimerId] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO + +IF NOT EXISTS (SELECT * FROM sys.objects WHERE type_desc = N'SQL_STORED_PROCEDURE' AND name = N'GetResourceGroupByName') +BEGIN +EXEC sp_executesql N'CREATE PROCEDURE [dbo].[GetResourceGroupByName] +( + @GroupName nvarchar(100) +) +AS +SELECT + RG.GroupID, + RG.GroupOrder, + RG.GroupName, + RG.GroupController +FROM ResourceGroups AS RG +WHERE RG.GroupName = @GroupName + +RETURN' +END + +GO + +IF NOT EXISTS (SELECT * FROM sys.objects WHERE type_desc = N'SQL_STORED_PROCEDURE' AND name = N'GetExchangeDisclaimers') +BEGIN +EXEC sp_executesql N'CREATE PROCEDURE [dbo].[GetExchangeDisclaimers] +( + @ItemID int +) +AS +SELECT + ExchangeDisclaimerId, + ItemID, + DisclaimerName, + DisclaimerText +FROM + ExchangeDisclaimers +WHERE + ItemID = @ItemID +ORDER BY DisclaimerName +RETURN' +END +GO + + +IF NOT EXISTS (SELECT * FROM sys.objects WHERE type_desc = N'SQL_STORED_PROCEDURE' AND name = N'DeleteExchangeDisclaimer') +BEGIN +EXEC sp_executesql N'CREATE PROCEDURE [dbo].[DeleteExchangeDisclaimer] +( + @ExchangeDisclaimerId int +) +AS + +DELETE FROM ExchangeDisclaimers +WHERE ExchangeDisclaimerId = @ExchangeDisclaimerId + +RETURN' +END +GO + +-- + +IF NOT EXISTS (SELECT * FROM sys.objects WHERE type_desc = N'SQL_STORED_PROCEDURE' AND name = N'UpdateExchangeDisclaimer') +BEGIN +EXEC sp_executesql N' CREATE PROCEDURE [dbo].[UpdateExchangeDisclaimer] +( + @ExchangeDisclaimerId int, + @DisclaimerName nvarchar(300), + @DisclaimerText nvarchar(1024) +) +AS + +UPDATE ExchangeDisclaimers SET + DisclaimerName = @DisclaimerName, + DisclaimerText = @DisclaimerText + +WHERE ExchangeDisclaimerId = @ExchangeDisclaimerId + +RETURN' +END +GO + +-- + +IF NOT EXISTS (SELECT * FROM sys.objects WHERE type_desc = N'SQL_STORED_PROCEDURE' AND name = N'AddExchangeDisclaimer') +BEGIN +EXEC sp_executesql N'CREATE PROCEDURE [dbo].[AddExchangeDisclaimer] +( + @ExchangeDisclaimerId int OUTPUT, + @ItemID int, + @DisclaimerName nvarchar(300), + @DisclaimerText nvarchar(1024) +) +AS + +INSERT INTO ExchangeDisclaimers +( + ItemID, + DisclaimerName, + DisclaimerText +) +VALUES +( + @ItemID, + @DisclaimerName, + @DisclaimerText +) + +SET @ExchangeDisclaimerId = SCOPE_IDENTITY() + +RETURN' +END +GO + +-- + + +IF NOT EXISTS (SELECT * FROM sys.objects WHERE type_desc = N'SQL_STORED_PROCEDURE' AND name = N'GetExchangeDisclaimer') +BEGIN +EXEC sp_executesql N'CREATE PROCEDURE [dbo].[GetExchangeDisclaimer] +( + @ExchangeDisclaimerId int +) +AS +SELECT + ExchangeDisclaimerId, + ItemID, + DisclaimerName, + DisclaimerText +FROM + ExchangeDisclaimers +WHERE + ExchangeDisclaimerId = @ExchangeDisclaimerId +RETURN' +END +GO + + + +IF NOT EXISTS(select 1 from sys.columns COLS INNER JOIN sys.objects OBJS ON OBJS.object_id=COLS.object_id and OBJS.type='U' AND OBJS.name='ExchangeAccounts' AND COLS.name='ExchangeDisclaimerId') +BEGIN + +ALTER TABLE [dbo].[ExchangeAccounts] ADD + +[ExchangeDisclaimerId] [int] NULL + +END +Go + + +IF NOT EXISTS (SELECT * FROM sys.objects WHERE type_desc = N'SQL_STORED_PROCEDURE' AND name = N'SetExchangeAccountDisclaimerId') +BEGIN +EXEC sp_executesql N' CREATE PROCEDURE [dbo].[SetExchangeAccountDisclaimerId] +( + @AccountID int, + @ExchangeDisclaimerId int +) +AS +UPDATE ExchangeAccounts SET + ExchangeDisclaimerId = @ExchangeDisclaimerId +WHERE AccountID = @AccountID + +RETURN' +END +GO + +IF NOT EXISTS (SELECT * FROM sys.objects WHERE type_desc = N'SQL_STORED_PROCEDURE' AND name = N'GetExchangeAccountDisclaimerId') +BEGIN +EXEC sp_executesql N'CREATE PROCEDURE [dbo].[GetExchangeAccountDisclaimerId] +( + @AccountID int +) +AS +SELECT + ExchangeDisclaimerId +FROM + ExchangeAccounts +WHERE + AccountID= @AccountID +RETURN' +END +GO + + +-- add Disclaimers Quota +IF NOT EXISTS (SELECT * FROM [dbo].[Quotas] WHERE ([QuotaName] = N'Exchange2007.DisclaimersAllowed')) +BEGIN +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (422, 12, 26, N'Exchange2007.DisclaimersAllowed', N'Disclaimers Allowed', 1, 0, NULL, NULL) +END +GO + +--add SecurityGroupManagement Quota +--IF NOT EXISTS (SELECT * FROM [dbo].[Quotas] WHERE [QuotaName] = 'HostedSolution.SecurityGroupManagement') +--BEGIN +--INSERT [dbo].[Quotas] ([QuotaID], [GroupID],[QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (423, 13, 5, N'HostedSolution.SecurityGroupManagement', N'Allow Security Group Management', 1, 0, NULL, NULL) +--END +--GO + +-- Lync Enterprise Voice + +IF NOT EXISTS(select 1 from sys.columns COLS INNER JOIN sys.objects OBJS ON OBJS.object_id=COLS.object_id and OBJS.type='U' AND OBJS.name='LyncUserPlans' AND COLS.name='TelephonyVoicePolicy') +BEGIN +ALTER TABLE [dbo].[LyncUserPlans] ADD + +[RemoteUserAccess] [bit] NOT NULL DEFAULT 0, +[PublicIMConnectivity] [bit] NOT NULL DEFAULT 0, + +[AllowOrganizeMeetingsWithExternalAnonymous] [bit] NOT NULL DEFAULT 0, + +[Telephony] [int] NULL, + +[ServerURI] [nvarchar](300) NULL, + +[ArchivePolicy] [nvarchar](300) NULL, +[TelephonyDialPlanPolicy] [nvarchar](300) NULL, +[TelephonyVoicePolicy] [nvarchar](300) NULL + + +END +Go + +-- + +DROP PROCEDURE GetLyncUserPlan; + +DROP PROCEDURE AddLyncUserPlan; + +DROP PROCEDURE UpdateLyncUserPlan; + +DROP PROCEDURE DeleteLyncUserPlan; + +-- + +IF NOT EXISTS (SELECT * FROM sys.objects WHERE type_desc = N'SQL_STORED_PROCEDURE' AND name = N'DeleteLyncUserPlan') +BEGIN +EXEC sp_executesql N'CREATE PROCEDURE [dbo].[DeleteLyncUserPlan] +( + @LyncUserPlanId int +) +AS + +-- delete lyncuserplan +DELETE FROM LyncUserPlans +WHERE LyncUserPlanId = @LyncUserPlanId + +RETURN' +END +GO + +-- + +IF NOT EXISTS (SELECT * FROM sys.objects WHERE type_desc = N'SQL_STORED_PROCEDURE' AND name = N'UpdateLyncUserPlan') +BEGIN +EXEC sp_executesql N' CREATE PROCEDURE [dbo].[UpdateLyncUserPlan] +( + @LyncUserPlanId int, + @LyncUserPlanName nvarchar(300), + @LyncUserPlanType int, + @IM bit, + @Mobility bit, + @MobilityEnableOutsideVoice bit, + @Federation bit, + @Conferencing bit, + @EnterpriseVoice bit, + @VoicePolicy int, + @IsDefault bit, + + @RemoteUserAccess bit, + @PublicIMConnectivity bit, + + @AllowOrganizeMeetingsWithExternalAnonymous bit, + + @Telephony int, + + @ServerURI nvarchar(300), + + @ArchivePolicy nvarchar(300), + + @TelephonyDialPlanPolicy nvarchar(300), + @TelephonyVoicePolicy nvarchar(300) +) +AS + +UPDATE LyncUserPlans SET + LyncUserPlanName = @LyncUserPlanName, + LyncUserPlanType = @LyncUserPlanType, + IM = @IM, + Mobility = @Mobility, + MobilityEnableOutsideVoice = @MobilityEnableOutsideVoice, + Federation = @Federation, + Conferencing =@Conferencing, + EnterpriseVoice = @EnterpriseVoice, + VoicePolicy = @VoicePolicy, + IsDefault = @IsDefault, + + RemoteUserAccess = @RemoteUserAccess, + PublicIMConnectivity = @PublicIMConnectivity, + + AllowOrganizeMeetingsWithExternalAnonymous = @AllowOrganizeMeetingsWithExternalAnonymous, + + Telephony = @Telephony, + + ServerURI = @ServerURI, + + ArchivePolicy = @ArchivePolicy, + TelephonyDialPlanPolicy = @TelephonyDialPlanPolicy, + TelephonyVoicePolicy = @TelephonyVoicePolicy + +WHERE LyncUserPlanId = @LyncUserPlanId + + +RETURN' +END +GO + +-- + +IF NOT EXISTS (SELECT * FROM sys.objects WHERE type_desc = N'SQL_STORED_PROCEDURE' AND name = N'AddLyncUserPlan') +BEGIN +EXEC sp_executesql N'CREATE PROCEDURE [dbo].[AddLyncUserPlan] +( + @LyncUserPlanId int OUTPUT, + @ItemID int, + @LyncUserPlanName nvarchar(300), + @LyncUserPlanType int, + @IM bit, + @Mobility bit, + @MobilityEnableOutsideVoice bit, + @Federation bit, + @Conferencing bit, + @EnterpriseVoice bit, + @VoicePolicy int, + @IsDefault bit, + + @RemoteUserAccess bit, + @PublicIMConnectivity bit, + + @AllowOrganizeMeetingsWithExternalAnonymous bit, + + @Telephony int, + + @ServerURI nvarchar(300), + + @ArchivePolicy nvarchar(300), + @TelephonyDialPlanPolicy nvarchar(300), + @TelephonyVoicePolicy nvarchar(300) + +) +AS + + + +IF (((SELECT Count(*) FROM LyncUserPlans WHERE ItemId = @ItemID) = 0) AND (@LyncUserPlanType=0)) +BEGIN + SET @IsDefault = 1 +END +ELSE +BEGIN + IF ((@IsDefault = 1) AND (@LyncUserPlanType=0)) + BEGIN + UPDATE LyncUserPlans SET IsDefault = 0 WHERE ItemID = @ItemID + END +END + + +INSERT INTO LyncUserPlans +( + ItemID, + LyncUserPlanName, + LyncUserPlanType, + IM, + Mobility, + MobilityEnableOutsideVoice, + Federation, + Conferencing, + EnterpriseVoice, + VoicePolicy, + IsDefault, + + RemoteUserAccess, + PublicIMConnectivity, + + AllowOrganizeMeetingsWithExternalAnonymous, + + Telephony, + + ServerURI, + + ArchivePolicy, + TelephonyDialPlanPolicy, + TelephonyVoicePolicy + +) +VALUES +( + @ItemID, + @LyncUserPlanName, + @LyncUserPlanType, + @IM, + @Mobility, + @MobilityEnableOutsideVoice, + @Federation, + @Conferencing, + @EnterpriseVoice, + @VoicePolicy, + @IsDefault, + + @RemoteUserAccess, + @PublicIMConnectivity, + + @AllowOrganizeMeetingsWithExternalAnonymous, + + @Telephony, + + @ServerURI, + + @ArchivePolicy, + @TelephonyDialPlanPolicy, + @TelephonyVoicePolicy + +) + +SET @LyncUserPlanId = SCOPE_IDENTITY() + +RETURN' +END +GO + +-- + + +IF NOT EXISTS (SELECT * FROM sys.objects WHERE type_desc = N'SQL_STORED_PROCEDURE' AND name = N'GetLyncUserPlan') +BEGIN +EXEC sp_executesql N'CREATE PROCEDURE [dbo].[GetLyncUserPlan] +( + @LyncUserPlanId int +) +AS +SELECT + LyncUserPlanId, + ItemID, + LyncUserPlanName, + LyncUserPlanType, + IM, + Mobility, + MobilityEnableOutsideVoice, + Federation, + Conferencing, + EnterpriseVoice, + VoicePolicy, + IsDefault, + + RemoteUserAccess, + PublicIMConnectivity, + + AllowOrganizeMeetingsWithExternalAnonymous, + + Telephony, + + ServerURI, + + ArchivePolicy, + TelephonyDialPlanPolicy, + TelephonyVoicePolicy + +FROM + LyncUserPlans +WHERE + LyncUserPlanId = @LyncUserPlanId +RETURN' +END +GO + + + + + +ALTER PROCEDURE [dbo].[GetLyncUserPlan] +( + @LyncUserPlanId int +) +AS +SELECT + LyncUserPlanId, + ItemID, + LyncUserPlanName, + LyncUserPlanType, + IM, + Mobility, + MobilityEnableOutsideVoice, + Federation, + Conferencing, + EnterpriseVoice, + VoicePolicy, + IsDefault, + + RemoteUserAccess, + PublicIMConnectivity, + + AllowOrganizeMeetingsWithExternalAnonymous, + + Telephony, + + ServerURI, + + ArchivePolicy, + TelephonyDialPlanPolicy, + TelephonyVoicePolicy + +FROM + LyncUserPlans +WHERE + LyncUserPlanId = @LyncUserPlanId +RETURN +GO + +-- Lync Phone Numbers Quota + +IF NOT EXISTS (SELECT * FROM [dbo].[Quotas] WHERE ([QuotaName] = N'Lync.PhoneNumbers')) +BEGIN + INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (381, 41, 12, N'Lync.PhoneNumbers', N'Phone Numbers', 2, 0, NULL, NULL) +END +GO + + +ALTER FUNCTION [dbo].[CalculateQuotaUsage] +( + @PackageID int, + @QuotaID int +) +RETURNS int +AS + BEGIN + + DECLARE @QuotaTypeID int + SELECT @QuotaTypeID = QuotaTypeID FROM Quotas + WHERE QuotaID = @QuotaID + + IF @QuotaTypeID <> 2 + RETURN 0 + + DECLARE @Result int + + IF @QuotaID = 52 -- diskspace + SET @Result = dbo.CalculatePackageDiskspace(@PackageID) + ELSE IF @QuotaID = 51 -- bandwidth + SET @Result = dbo.CalculatePackageBandwidth(@PackageID) + ELSE IF @QuotaID = 53 -- domains + SET @Result = (SELECT COUNT(D.DomainID) FROM PackagesTreeCache AS PT + INNER JOIN Domains AS D ON D.PackageID = PT.PackageID + WHERE IsSubDomain = 0 AND IsInstantAlias = 0 AND IsDomainPointer = 0 AND PT.ParentPackageID = @PackageID) + ELSE IF @QuotaID = 54 -- sub-domains + SET @Result = (SELECT COUNT(D.DomainID) FROM PackagesTreeCache AS PT + INNER JOIN Domains AS D ON D.PackageID = PT.PackageID + WHERE IsSubDomain = 1 AND IsInstantAlias = 0 AND IsDomainPointer = 0 AND PT.ParentPackageID = @PackageID) + ELSE IF @QuotaID = 220 -- domain pointers + SET @Result = (SELECT COUNT(D.DomainID) FROM PackagesTreeCache AS PT + INNER JOIN Domains AS D ON D.PackageID = PT.PackageID + WHERE IsDomainPointer = 1 AND PT.ParentPackageID = @PackageID) + ELSE IF @QuotaID = 71 -- scheduled tasks + SET @Result = (SELECT COUNT(S.ScheduleID) FROM PackagesTreeCache AS PT + INNER JOIN Schedule AS S ON S.PackageID = PT.PackageID + WHERE PT.ParentPackageID = @PackageID) + ELSE IF @QuotaID = 305 -- RAM of VPS + SET @Result = (SELECT SUM(CAST(SIP.PropertyValue AS int)) FROM ServiceItemProperties AS SIP + INNER JOIN ServiceItems AS SI ON SIP.ItemID = SI.ItemID + INNER JOIN PackagesTreeCache AS PT ON SI.PackageID = PT.PackageID + WHERE SIP.PropertyName = 'RamSize' AND PT.ParentPackageID = @PackageID) + ELSE IF @QuotaID = 306 -- HDD of VPS + SET @Result = (SELECT SUM(CAST(SIP.PropertyValue AS int)) FROM ServiceItemProperties AS SIP + INNER JOIN ServiceItems AS SI ON SIP.ItemID = SI.ItemID + INNER JOIN PackagesTreeCache AS PT ON SI.PackageID = PT.PackageID + WHERE SIP.PropertyName = 'HddSize' AND PT.ParentPackageID = @PackageID) + ELSE IF @QuotaID = 309 -- External IP addresses of VPS + SET @Result = (SELECT COUNT(PIP.PackageAddressID) FROM PackageIPAddresses AS PIP + INNER JOIN IPAddresses AS IP ON PIP.AddressID = IP.AddressID + INNER JOIN PackagesTreeCache AS PT ON PIP.PackageID = PT.PackageID + WHERE PT.ParentPackageID = @PackageID AND IP.PoolID = 3) + ELSE IF @QuotaID = 100 -- Dedicated Web IP addresses + SET @Result = (SELECT COUNT(PIP.PackageAddressID) FROM PackageIPAddresses AS PIP + INNER JOIN IPAddresses AS IP ON PIP.AddressID = IP.AddressID + INNER JOIN PackagesTreeCache AS PT ON PIP.PackageID = PT.PackageID + WHERE PT.ParentPackageID = @PackageID AND IP.PoolID = 2) + ELSE IF @QuotaID = 350 -- RAM of VPSforPc + SET @Result = (SELECT SUM(CAST(SIP.PropertyValue AS int)) FROM ServiceItemProperties AS SIP + INNER JOIN ServiceItems AS SI ON SIP.ItemID = SI.ItemID + INNER JOIN PackagesTreeCache AS PT ON SI.PackageID = PT.PackageID + WHERE SIP.PropertyName = 'Memory' AND PT.ParentPackageID = @PackageID) + ELSE IF @QuotaID = 351 -- HDD of VPSforPc + SET @Result = (SELECT SUM(CAST(SIP.PropertyValue AS int)) FROM ServiceItemProperties AS SIP + INNER JOIN ServiceItems AS SI ON SIP.ItemID = SI.ItemID + INNER JOIN PackagesTreeCache AS PT ON SI.PackageID = PT.PackageID + WHERE SIP.PropertyName = 'HddSize' AND PT.ParentPackageID = @PackageID) + ELSE IF @QuotaID = 354 -- External IP addresses of VPSforPc + SET @Result = (SELECT COUNT(PIP.PackageAddressID) FROM PackageIPAddresses AS PIP + INNER JOIN IPAddresses AS IP ON PIP.AddressID = IP.AddressID + INNER JOIN PackagesTreeCache AS PT ON PIP.PackageID = PT.PackageID + WHERE PT.ParentPackageID = @PackageID AND IP.PoolID = 3) + ELSE IF @QuotaID = 319 -- BB Users + SET @Result = (SELECT COUNT(ea.AccountID) FROM ExchangeAccounts ea + INNER JOIN BlackBerryUsers bu ON ea.AccountID = bu.AccountID + INNER JOIN ServiceItems si ON ea.ItemID = si.ItemID + INNER JOIN PackagesTreeCache pt ON si.PackageID = pt.PackageID + WHERE pt.ParentPackageID = @PackageID) + ELSE IF @QuotaID = 320 -- OCS Users + SET @Result = (SELECT COUNT(ea.AccountID) FROM ExchangeAccounts ea + INNER JOIN OCSUsers ocs ON ea.AccountID = ocs.AccountID + INNER JOIN ServiceItems si ON ea.ItemID = si.ItemID + INNER JOIN PackagesTreeCache pt ON si.PackageID = pt.PackageID + WHERE pt.ParentPackageID = @PackageID) + ELSE IF @QuotaID = 206 -- HostedSolution.Users + SET @Result = (SELECT COUNT(ea.AccountID) FROM ExchangeAccounts AS ea + INNER JOIN ServiceItems si ON ea.ItemID = si.ItemID + INNER JOIN PackagesTreeCache pt ON si.PackageID = pt.PackageID + WHERE pt.ParentPackageID = @PackageID AND ea.AccountType IN (1,5,6,7)) + ELSE IF @QuotaID = 78 -- Exchange2007.Mailboxes + SET @Result = (SELECT COUNT(ea.AccountID) FROM ExchangeAccounts AS ea + INNER JOIN ServiceItems si ON ea.ItemID = si.ItemID + INNER JOIN PackagesTreeCache pt ON si.PackageID = pt.PackageID + WHERE pt.ParentPackageID = @PackageID + AND ea.AccountType IN (1) + AND ea.MailboxPlanId IS NOT NULL) + ELSE IF @QuotaID = 77 -- Exchange2007.DiskSpace + SET @Result = (SELECT SUM(B.MailboxSizeMB) FROM ExchangeAccounts AS ea + INNER JOIN ExchangeMailboxPlans AS B ON ea.MailboxPlanId = B.MailboxPlanId + INNER JOIN ServiceItems si ON ea.ItemID = si.ItemID + INNER JOIN PackagesTreeCache pt ON si.PackageID = pt.PackageID + WHERE pt.ParentPackageID = @PackageID) + ELSE IF @QuotaID = 370 -- Lync.Users + SET @Result = (SELECT COUNT(ea.AccountID) FROM ExchangeAccounts AS ea + INNER JOIN LyncUsers lu ON ea.AccountID = lu.AccountID + INNER JOIN ServiceItems si ON ea.ItemID = si.ItemID + INNER JOIN PackagesTreeCache pt ON si.PackageID = pt.PackageID + WHERE pt.ParentPackageID = @PackageID) + ELSE IF @QuotaID = 376 -- Lync.EVUsers + SET @Result = (SELECT COUNT(ea.AccountID) FROM ExchangeAccounts AS ea + INNER JOIN LyncUsers lu ON ea.AccountID = lu.AccountID + INNER JOIN LyncUserPlans lp ON lu.LyncUserPlanId = lp.LyncUserPlanId + INNER JOIN ServiceItems si ON ea.ItemID = si.ItemID + INNER JOIN PackagesTreeCache pt ON si.PackageID = pt.PackageID + WHERE pt.ParentPackageID = @PackageID AND lp.EnterpriseVoice = 1) + ELSE IF @QuotaID = 381 -- Dedicated Lync Phone Numbers + SET @Result = (SELECT COUNT(PIP.PackageAddressID) FROM PackageIPAddresses AS PIP + INNER JOIN IPAddresses AS IP ON PIP.AddressID = IP.AddressID + INNER JOIN PackagesTreeCache AS PT ON PIP.PackageID = PT.PackageID + WHERE PT.ParentPackageID = @PackageID AND IP.PoolID = 5) + ELSE + SET @Result = (SELECT COUNT(SI.ItemID) FROM Quotas AS Q + INNER JOIN ServiceItems AS SI ON SI.ItemTypeID = Q.ItemTypeID + INNER JOIN PackagesTreeCache AS PT ON SI.PackageID = PT.PackageID AND PT.ParentPackageID = @PackageID + WHERE Q.QuotaID = @QuotaID) + + RETURN @Result + END +GO + +-- Enterprise Storage Provider +IF NOT EXISTS (SELECT * FROM [dbo].[ResourceGroups] WHERE [GroupName] = 'EnterpriseStorage') +BEGIN +INSERT [dbo].[ResourceGroups] ([GroupID], [GroupName], [GroupOrder], [GroupController], [ShowGroup]) VALUES (44, N'EnterpriseStorage', 25, N'WebsitePanel.EnterpriseServer.EnterpriseStorageController', 1) +END +GO + +IF NOT EXISTS (SELECT * FROM [dbo].[Providers] WHERE [DisplayName] = 'Enterprise Storage Windows 2012') +BEGIN +INSERT [dbo].[Providers] ([ProviderId], [GroupId], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery]) VALUES(600, 44, N'EnterpriseStorage2012', N'Enterprise Storage Windows 2012', N'WebsitePanel.Providers.EnterpriseStorage.Windows2012, WebsitePanel.Providers.EnterpriseStorage.Windows2012', N'EnterpriseStorage', 1) +END +ELSE +BEGIN +UPDATE [dbo].[Providers] SET [DisableAutoDiscovery] = NULL WHERE [DisplayName] = 'Enterprise Storage Windows 2012' +END +GO + +-- Enterprise Storage Quotas +IF NOT EXISTS (SELECT * FROM [dbo].[Quotas] WHERE [QuotaName] = 'EnterpriseStorage.DiskStorageSpace') +BEGIN +INSERT [dbo].[Quotas] ([QuotaID], [GroupID],[QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID]) VALUES (430, 44, 1,N'EnterpriseStorage.DiskStorageSpace',N'Disk Storage Space (Mb)',2, 0 , NULL) +END +GO + +IF NOT EXISTS (SELECT * FROM [dbo].[Quotas] WHERE [QuotaName] = 'EnterpriseStorage.Folders') +BEGIN +INSERT [dbo].[Quotas] ([QuotaID], [GroupID],[QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID]) VALUES (431, 44, 1,N'EnterpriseStorage.Folders',N'Number of Root Folders',2, 0 , NULL) +END +GO + + +ALTER PROCEDURE [dbo].[SearchExchangeAccounts] +( + @ActorID int, + @ItemID int, + @IncludeMailboxes bit, + @IncludeContacts bit, + @IncludeDistributionLists bit, + @IncludeRooms bit, + @IncludeEquipment bit, + @IncludeSecurityGroups bit, + @FilterColumn nvarchar(50) = '', + @FilterValue nvarchar(50) = '', + @SortColumn nvarchar(50) +) +AS +DECLARE @PackageID int +SELECT @PackageID = PackageID FROM ServiceItems +WHERE ItemID = @ItemID + +-- check rights +IF dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 +RAISERROR('You are not allowed to access this package', 16, 1) + +-- start +DECLARE @condition nvarchar(700) +SET @condition = ' +((@IncludeMailboxes = 1 AND EA.AccountType = 1) +OR (@IncludeContacts = 1 AND EA.AccountType = 2) +OR (@IncludeDistributionLists = 1 AND EA.AccountType = 3) +OR (@IncludeRooms = 1 AND EA.AccountType = 5) +OR (@IncludeEquipment = 1 AND EA.AccountType = 6) +OR (@IncludeSecurityGroups = 1 AND EA.AccountType = 8)) +AND EA.ItemID = @ItemID +' + +IF @FilterColumn <> '' AND @FilterColumn IS NOT NULL +AND @FilterValue <> '' AND @FilterValue IS NOT NULL +SET @condition = @condition + ' AND ' + @FilterColumn + ' LIKE ''' + @FilterValue + '''' + +IF @SortColumn IS NULL OR @SortColumn = '' +SET @SortColumn = 'EA.DisplayName ASC' + +DECLARE @sql nvarchar(3500) + +set @sql = ' +SELECT + EA.AccountID, + EA.ItemID, + EA.AccountType, + EA.AccountName, + EA.DisplayName, + EA.PrimaryEmailAddress, + EA.MailEnabledPublicFolder, + EA.SubscriberNumber, + EA.UserPrincipalName +FROM ExchangeAccounts AS EA +WHERE ' + @condition + +print @sql + +exec sp_executesql @sql, N'@ItemID int, @IncludeMailboxes int, @IncludeContacts int, + @IncludeDistributionLists int, @IncludeRooms bit, @IncludeEquipment bit, @IncludeSecurityGroups bit', +@ItemID, @IncludeMailboxes, @IncludeContacts, @IncludeDistributionLists, @IncludeRooms, @IncludeEquipment, @IncludeSecurityGroups + +RETURN +GO + + +IF EXISTS (SELECT * FROM sys.objects WHERE type_desc = N'SQL_STORED_PROCEDURE' AND name = N'SearchExchangeAccountsByTypes') +DROP PROCEDURE [dbo].[SearchExchangeAccountsByTypes] +GO + + +CREATE PROCEDURE [dbo].[SearchExchangeAccountsByTypes] +( + @ActorID int, + @ItemID int, + @AccountTypes nvarchar(30), + @FilterColumn nvarchar(50) = '', + @FilterValue nvarchar(50) = '', + @SortColumn nvarchar(50) +) +AS + +DECLARE @PackageID int +SELECT @PackageID = PackageID FROM ServiceItems +WHERE ItemID = @ItemID + +-- check rights +IF dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 +RAISERROR('You are not allowed to access this package', 16, 1) + +DECLARE @condition nvarchar(700) +SET @condition = 'EA.ItemID = @ItemID AND EA.AccountType IN (' + @AccountTypes + ')' + +IF @FilterColumn <> '' AND @FilterColumn IS NOT NULL +AND @FilterValue <> '' AND @FilterValue IS NOT NULL +BEGIN + IF @FilterColumn = 'PrimaryEmailAddress' AND @AccountTypes <> '2' + BEGIN + SET @condition = @condition + ' AND EA.AccountID IN (SELECT EAEA.AccountID FROM ExchangeAccountEmailAddresses EAEA WHERE EAEA.EmailAddress LIKE ''' + @FilterValue + ''')' + END + ELSE + BEGIN + SET @condition = @condition + ' AND ' + @FilterColumn + ' LIKE ''' + @FilterValue + '''' + END +END + +IF @SortColumn IS NULL OR @SortColumn = '' +SET @SortColumn = 'EA.DisplayName ASC' + +DECLARE @sql nvarchar(3500) +SET @sql = ' +SELECT + EA.AccountID, + EA.ItemID, + EA.AccountType, + EA.AccountName, + EA.DisplayName, + EA.PrimaryEmailAddress, + EA.MailEnabledPublicFolder, + EA.MailboxPlanId, + P.MailboxPlan, + EA.SubscriberNumber, + EA.UserPrincipalName +FROM + ExchangeAccounts AS EA +LEFT OUTER JOIN ExchangeMailboxPlans AS P ON EA.MailboxPlanId = P.MailboxPlanId + WHERE ' + @condition + + ' ORDER BY ' + @SortColumn + +EXEC sp_executesql @sql, N'@ItemID int', @ItemID + +RETURN +GO + +---- Additional Default Groups------------- + +IF EXISTS (SELECT * FROM SYS.TABLES WHERE name = 'AdditionalGroups') +DROP TABLE AdditionalGroups +GO + +CREATE TABLE AdditionalGroups +( + ID INT IDENTITY(1,1) NOT NULL PRIMARY KEY, + UserID INT NOT NULL, + GroupName NVARCHAR(255) +) +GO + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'GetAdditionalGroups') +DROP PROCEDURE GetAdditionalGroups +GO + +CREATE PROCEDURE [dbo].[GetAdditionalGroups] +( + @UserID INT +) +AS + +SELECT + AG.ID, + AG.UserID, + AG.GroupName +FROM AdditionalGroups AS AG +WHERE AG.UserID = @UserID +GO + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'AddAdditionalGroup') +DROP PROCEDURE AddAdditionalGroup +GO + +CREATE PROCEDURE [dbo].[AddAdditionalGroup] +( + @GroupID INT OUTPUT, + @UserID INT, + @GroupName NVARCHAR(255) +) +AS + +INSERT INTO AdditionalGroups +( + UserID, + GroupName +) +VALUES +( + @UserID, + @GroupName +) + +SET @GroupID = SCOPE_IDENTITY() + +RETURN +GO + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'DeleteAdditionalGroup') +DROP PROCEDURE DeleteAdditionalGroup +GO + +CREATE PROCEDURE [dbo].[DeleteAdditionalGroup] +( + @GroupID INT +) +AS + +DELETE FROM AdditionalGroups +WHERE ID = @GroupID +GO + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'UpdateAdditionalGroup') +DROP PROCEDURE UpdateAdditionalGroup +GO + +CREATE PROCEDURE [dbo].[UpdateAdditionalGroup] +( + @GroupID INT, + @GroupName NVARCHAR(255) +) +AS + +UPDATE AdditionalGroups SET + GroupName = @GroupName +WHERE ID = @GroupID +GO + + + +-- Remote Desktop Services + +-- RDS ResourceGroup + +IF NOT EXISTS (SELECT * FROM [dbo].[ResourceGroups] WHERE [GroupName] = 'RDS') +BEGIN +INSERT [dbo].[ResourceGroups] ([GroupID], [GroupName], [GroupOrder], [GroupController], [ShowGroup]) VALUES (45, N'RDS', 26, NULL, 1) +END +GO + +-- RDS Quotas + +IF NOT EXISTS (SELECT * FROM [dbo].[Quotas] WHERE [QuotaName] = 'RDS.Users') +BEGIN +INSERT [dbo].[Quotas] ([QuotaID], [GroupID],[QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID]) VALUES (450, 45, 1, N'RDS.Users',N'Remote Desktop Users',2, 0 , NULL) +END +GO + +IF NOT EXISTS (SELECT * FROM [dbo].[Quotas] WHERE [QuotaName] = 'RDS.Servers') +BEGIN +INSERT [dbo].[Quotas] ([QuotaID], [GroupID],[QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID]) VALUES (451, 45, 2, N'RDS.Servers',N'Remote Desktop Servers',2, 0 , NULL) +END +GO + +IF NOT EXISTS (SELECT * FROM [dbo].[Quotas] WHERE [QuotaName] = 'RDS.Collections') +BEGIN +INSERT [dbo].[Quotas] ([QuotaID], [GroupID],[QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID]) VALUES (491, 45, 2, N'RDS.Collections',N'Remote Desktop Servers',2, 0 , NULL) +END +GO + +-- RDS Provider + +IF NOT EXISTS (SELECT * FROM [dbo].[Providers] WHERE [DisplayName] = 'Remote Desktop Services Windows 2012') +BEGIN +INSERT [dbo].[Providers] ([ProviderId], [GroupId], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery]) +VALUES(1501, 45, N'RemoteDesktopServices2012', N'Remote Desktop Services Windows 2012', N'WebsitePanel.Providers.RemoteDesktopServices.Windows2012,WebsitePanel.Providers.RemoteDesktopServices.Windows2012', N'RDS', 1) +END +GO + +-- Added phone numbers in the hosted organization. + +IF NOT EXISTS(select 1 from sys.columns COLS INNER JOIN sys.objects OBJS ON OBJS.object_id=COLS.object_id and OBJS.type='U' AND OBJS.name='PackageIPAddresses' AND COLS.name='OrgID') +BEGIN +ALTER TABLE [dbo].[PackageIPAddresses] ADD + [OrgID] [int] NULL +END +GO + +ALTER PROCEDURE [dbo].[AllocatePackageIPAddresses] +( + @PackageID int, + @OrgID int, + @xml ntext +) +AS +BEGIN + + SET NOCOUNT ON; + + DECLARE @idoc int + --Create an internal representation of the XML document. + EXEC sp_xml_preparedocument @idoc OUTPUT, @xml + + -- delete + DELETE FROM PackageIPAddresses + FROM PackageIPAddresses AS PIP + INNER JOIN OPENXML(@idoc, '/items/item', 1) WITH + ( + AddressID int '@id' + ) as PV ON PIP.AddressID = PV.AddressID + + + -- insert + INSERT INTO dbo.PackageIPAddresses + ( + PackageID, + OrgID, + AddressID + ) + SELECT + @PackageID, + @OrgID, + AddressID + + FROM OPENXML(@idoc, '/items/item', 1) WITH + ( + AddressID int '@id' + ) as PV + + -- remove document + exec sp_xml_removedocument @idoc + +END +GO + +ALTER PROCEDURE [dbo].[GetPackageIPAddresses] +( + @PackageID int, + @OrgID int, + @FilterColumn nvarchar(50) = '', + @FilterValue nvarchar(50) = '', + @SortColumn nvarchar(50), + @StartRow int, + @MaximumRows int, + @PoolID int = 0, + @Recursive bit = 0 +) +AS +BEGIN + + +-- start +DECLARE @condition nvarchar(700) +SET @condition = ' +((@Recursive = 0 AND PA.PackageID = @PackageID) +OR (@Recursive = 1 AND dbo.CheckPackageParent(@PackageID, PA.PackageID) = 1)) +AND (@PoolID = 0 OR @PoolID <> 0 AND IP.PoolID = @PoolID) +AND (@OrgID = 0 OR @OrgID <> 0 AND PA.OrgID = @OrgID) +' + +IF @FilterColumn <> '' AND @FilterColumn IS NOT NULL +AND @FilterValue <> '' AND @FilterValue IS NOT NULL +SET @condition = @condition + ' AND ' + @FilterColumn + ' LIKE ''' + @FilterValue + '''' + +IF @SortColumn IS NULL OR @SortColumn = '' +SET @SortColumn = 'IP.ExternalIP ASC' + +DECLARE @sql nvarchar(3500) + +set @sql = ' +SELECT COUNT(PA.PackageAddressID) +FROM dbo.PackageIPAddresses PA +INNER JOIN dbo.IPAddresses AS IP ON PA.AddressID = IP.AddressID +INNER JOIN dbo.Packages P ON PA.PackageID = P.PackageID +INNER JOIN dbo.Users U ON U.UserID = P.UserID +LEFT JOIN ServiceItems SI ON PA.ItemId = SI.ItemID +WHERE ' + @condition + ' + +DECLARE @Addresses AS TABLE +( + PackageAddressID int +); + +WITH TempItems AS ( + SELECT ROW_NUMBER() OVER (ORDER BY ' + @SortColumn + ') as Row, + PA.PackageAddressID + FROM dbo.PackageIPAddresses PA + INNER JOIN dbo.IPAddresses AS IP ON PA.AddressID = IP.AddressID + INNER JOIN dbo.Packages P ON PA.PackageID = P.PackageID + INNER JOIN dbo.Users U ON U.UserID = P.UserID + LEFT JOIN ServiceItems SI ON PA.ItemId = SI.ItemID + WHERE ' + @condition + ' +) + +INSERT INTO @Addresses +SELECT PackageAddressID FROM TempItems +WHERE TempItems.Row BETWEEN @StartRow + 1 and @StartRow + @MaximumRows + +SELECT + PA.PackageAddressID, + PA.AddressID, + IP.ExternalIP, + IP.InternalIP, + IP.SubnetMask, + IP.DefaultGateway, + PA.ItemID, + SI.ItemName, + PA.PackageID, + P.PackageName, + P.UserID, + U.UserName, + PA.IsPrimary +FROM @Addresses AS TA +INNER JOIN dbo.PackageIPAddresses AS PA ON TA.PackageAddressID = PA.PackageAddressID +INNER JOIN dbo.IPAddresses AS IP ON PA.AddressID = IP.AddressID +INNER JOIN dbo.Packages P ON PA.PackageID = P.PackageID +INNER JOIN dbo.Users U ON U.UserID = P.UserID +LEFT JOIN ServiceItems SI ON PA.ItemId = SI.ItemID +' + +print @sql + +exec sp_executesql @sql, N'@PackageID int, @OrgID int, @StartRow int, @MaximumRows int, @Recursive bit, @PoolID int', +@PackageID, @OrgID, @StartRow, @MaximumRows, @Recursive, @PoolID + +END +GO + + + + + +ALTER PROCEDURE [dbo].[GetPackageUnassignedIPAddresses] +( + @ActorID int, + @PackageID int, + @OrgID int, + @PoolID int = 0 +) +AS +BEGIN + SELECT + PIP.PackageAddressID, + IP.AddressID, + IP.ExternalIP, + IP.InternalIP, + IP.ServerID, + IP.PoolID, + PIP.IsPrimary, + IP.SubnetMask, + IP.DefaultGateway + FROM PackageIPAddresses AS PIP + INNER JOIN IPAddresses AS IP ON PIP.AddressID = IP.AddressID + WHERE + PIP.ItemID IS NULL + AND PIP.PackageID = @PackageID + AND (@PoolID = 0 OR @PoolID <> 0 AND IP.PoolID = @PoolID) + AND (@OrgID = 0 OR @OrgID <> 0 AND PIP.OrgID = @OrgID) + AND dbo.CheckActorPackageRights(@ActorID, PIP.PackageID) = 1 + ORDER BY IP.DefaultGateway, IP.ExternalIP +END +GO + +-- DNS.2013 + +IF NOT EXISTS ( SELECT * FROM [dbo].[Providers] WHERE [ProviderID] = 410 ) +BEGIN + INSERT [dbo].[Providers] ([ProviderID], [GroupID], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery]) VALUES + (410, 7, N'MSDNS.2012', N'Microsoft DNS Server 2012+', N'WebsitePanel.Providers.DNS.MsDNS2012, WebsitePanel.Providers.DNS.MsDNS2012', N'MSDNS', NULL) +END +GO + +-- CRM Provider fix + +UPDATE Providers SET EditorControl = 'CRM2011' Where ProviderID = 1201; + +-- CRM Quota + +IF NOT EXISTS (SELECT * FROM [dbo].[Quotas] WHERE [QuotaName] = 'HostedCRM.MaxDatabaseSize') +BEGIN +INSERT [dbo].[Quotas] ([QuotaID], [GroupID],[QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID]) VALUES (460, 21, 4, N'HostedCRM.MaxDatabaseSize', N'Max Database Size, MB',3, 0 , NULL) +END +GO + +BEGIN +UPDATE [dbo].[Quotas] SET QuotaDescription = 'Full licenses per organization' WHERE [QuotaName] = 'HostedCRM.Users' +END +GO + +IF NOT EXISTS (SELECT * FROM [dbo].[Quotas] WHERE [QuotaName] = 'HostedCRM.LimitedUsers') +BEGIN +INSERT [dbo].[Quotas] ([QuotaID], [GroupID],[QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID]) VALUES (461, 21, 3, N'HostedCRM.LimitedUsers', N'Limited licenses per organization',3, 0 , NULL) +END +GO + +-- CRM Users + +IF NOT EXISTS(select 1 from sys.columns COLS INNER JOIN sys.objects OBJS ON OBJS.object_id=COLS.object_id and OBJS.type='U' AND OBJS.name='CRMUsers' AND COLS.name='CALType') +BEGIN +ALTER TABLE [dbo].[CRMUsers] ADD + [CALType] [int] NULL +END +GO + +BEGIN +UPDATE [dbo].[CRMUsers] + SET + CALType = 0 WHERE CALType IS NULL +END +GO + + +ALTER PROCEDURE [dbo].[InsertCRMUser] +( + @ItemID int, + @CrmUserID uniqueidentifier, + @BusinessUnitID uniqueidentifier, + @CALType int +) +AS +BEGIN + SET NOCOUNT ON; + +INSERT INTO + CRMUsers +( + AccountID, + CRMUserGuid, + BusinessUnitID, + CALType +) +VALUES +( + @ItemID, + @CrmUserID, + @BusinessUnitID, + @CALType +) + +END +GO + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'UpdateCRMUser') +DROP PROCEDURE UpdateCRMUser +GO + +CREATE PROCEDURE [dbo].[UpdateCRMUser] +( + @ItemID int, + @CALType int +) +AS +BEGIN + SET NOCOUNT ON; + + +UPDATE [dbo].[CRMUsers] + SET + CALType = @CALType + WHERE AccountID = @ItemID + + +END +GO + +ALTER PROCEDURE [dbo].[GetCRMUsersCount] +( + @ItemID int, + @Name nvarchar(400), + @Email nvarchar(400), + @CALType int +) +AS +BEGIN + +IF (@Name IS NULL) +BEGIN + SET @Name = '%' +END + +IF (@Email IS NULL) +BEGIN + SET @Email = '%' +END + +SELECT + COUNT(ea.AccountID) +FROM + ExchangeAccounts ea +INNER JOIN + CRMUsers cu +ON + ea.AccountID = cu.AccountID +WHERE + ea.ItemID = @ItemID AND ea.DisplayName LIKE @Name AND ea.PrimaryEmailAddress LIKE @Email + AND ((cu.CALType = @CALType) OR (@CALType = -1)) +END +GO + +IF NOT EXISTS (SELECT * FROM [dbo].[Providers] WHERE [DisplayName] = 'MySQL Server 5.6') +BEGIN +INSERT [dbo].[Providers] ([ProviderId], [GroupId], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery]) VALUES(302, 11, N'MySQL', N'MySQL Server 5.6', N'WebsitePanel.Providers.Database.MySqlServer56, WebsitePanel.Providers.Database.MySQL', N'MySQL', NULL) +END +ELSE +BEGIN +UPDATE [dbo].[Providers] SET [DisableAutoDiscovery] = NULL WHERE [DisplayName] = 'MySQL Server 5.6' +END +GO + + +-- CRM Quota + +BEGIN +UPDATE [dbo].[Quotas] SET QuotaOrder = 5 WHERE [QuotaName] = 'HostedCRM.MaxDatabaseSize' +END +GO + +IF NOT EXISTS (SELECT * FROM [dbo].[Quotas] WHERE [QuotaName] = 'HostedCRM.ESSUsers') +BEGIN +INSERT [dbo].[Quotas] ([QuotaID], [GroupID],[QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID]) VALUES (462, 21, 4, N'HostedCRM.ESSUsers', N'ESS licenses per organization',3, 0 , NULL) +END +GO + + +-- Lync + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'GetPackageIPAddressesCount') +DROP PROCEDURE GetPackageIPAddressesCount +GO + +CREATE PROCEDURE [dbo].[GetPackageIPAddressesCount] +( + @PackageID int, + @OrgID int, + @PoolID int = 0 +) +AS +BEGIN + +SELECT + COUNT(PA.PackageAddressID) +FROM + dbo.PackageIPAddresses PA +INNER JOIN + dbo.IPAddresses AS IP ON PA.AddressID = IP.AddressID +INNER JOIN + dbo.Packages P ON PA.PackageID = P.PackageID +INNER JOIN + dbo.Users U ON U.UserID = P.UserID +LEFT JOIN + ServiceItems SI ON PA.ItemId = SI.ItemID +WHERE + (@PoolID = 0 OR @PoolID <> 0 AND IP.PoolID = @PoolID) +AND (@OrgID = 0 OR @OrgID <> 0 AND PA.OrgID = @OrgID) + +END +GO + +-- Enterprise Storage Quotas +IF NOT EXISTS (SELECT * FROM [dbo].[Quotas] WHERE [QuotaName] = 'EnterpriseStorage.DiskStorageSpace') +BEGIN +INSERT [dbo].[Quotas] ([QuotaID], [GroupID],[QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID]) VALUES (430, 44, 1,N'EnterpriseStorage.DiskStorageSpace',N'Disk Storage Space (Gb)',2, 0 , NULL) +END +GO + +UPDATE [dbo].[Quotas] SET [QuotaDescription] = N'Disk Storage Space (Gb)' WHERE [QuotaName] = 'EnterpriseStorage.DiskStorageSpace' +GO + +IF NOT EXISTS (SELECT * FROM SYS.TABLES WHERE name = 'EnterpriseFolders') + +CREATE TABLE [dbo].[EnterpriseFolders]( + [EnterpriseFolderID] [int] IDENTITY(1,1) NOT NULL, + [ItemID] [int] NOT NULL, + [FolderName] [nvarchar](255) NOT NULL, + [FolderQuota] [int] NOT NULL DEFAULT 0, + CONSTRAINT [PK_EnterpriseFolders] PRIMARY KEY CLUSTERED +( + [EnterpriseFolderId] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO + +ALTER FUNCTION [dbo].[CalculateQuotaUsage] +( + @PackageID int, + @QuotaID int +) +RETURNS int +AS + BEGIN + + DECLARE @QuotaTypeID int + SELECT @QuotaTypeID = QuotaTypeID FROM Quotas + WHERE QuotaID = @QuotaID + + IF @QuotaTypeID <> 2 + RETURN 0 + + DECLARE @Result int + + IF @QuotaID = 52 -- diskspace + SET @Result = dbo.CalculatePackageDiskspace(@PackageID) + ELSE IF @QuotaID = 51 -- bandwidth + SET @Result = dbo.CalculatePackageBandwidth(@PackageID) + ELSE IF @QuotaID = 53 -- domains + SET @Result = (SELECT COUNT(D.DomainID) FROM PackagesTreeCache AS PT + INNER JOIN Domains AS D ON D.PackageID = PT.PackageID + WHERE IsSubDomain = 0 AND IsInstantAlias = 0 AND IsDomainPointer = 0 AND PT.ParentPackageID = @PackageID) + ELSE IF @QuotaID = 54 -- sub-domains + SET @Result = (SELECT COUNT(D.DomainID) FROM PackagesTreeCache AS PT + INNER JOIN Domains AS D ON D.PackageID = PT.PackageID + WHERE IsSubDomain = 1 AND IsInstantAlias = 0 AND IsDomainPointer = 0 AND PT.ParentPackageID = @PackageID) + ELSE IF @QuotaID = 220 -- domain pointers + SET @Result = (SELECT COUNT(D.DomainID) FROM PackagesTreeCache AS PT + INNER JOIN Domains AS D ON D.PackageID = PT.PackageID + WHERE IsDomainPointer = 1 AND PT.ParentPackageID = @PackageID) + ELSE IF @QuotaID = 71 -- scheduled tasks + SET @Result = (SELECT COUNT(S.ScheduleID) FROM PackagesTreeCache AS PT + INNER JOIN Schedule AS S ON S.PackageID = PT.PackageID + WHERE PT.ParentPackageID = @PackageID) + ELSE IF @QuotaID = 305 -- RAM of VPS + SET @Result = (SELECT SUM(CAST(SIP.PropertyValue AS int)) FROM ServiceItemProperties AS SIP + INNER JOIN ServiceItems AS SI ON SIP.ItemID = SI.ItemID + INNER JOIN PackagesTreeCache AS PT ON SI.PackageID = PT.PackageID + WHERE SIP.PropertyName = 'RamSize' AND PT.ParentPackageID = @PackageID) + ELSE IF @QuotaID = 306 -- HDD of VPS + SET @Result = (SELECT SUM(CAST(SIP.PropertyValue AS int)) FROM ServiceItemProperties AS SIP + INNER JOIN ServiceItems AS SI ON SIP.ItemID = SI.ItemID + INNER JOIN PackagesTreeCache AS PT ON SI.PackageID = PT.PackageID + WHERE SIP.PropertyName = 'HddSize' AND PT.ParentPackageID = @PackageID) + ELSE IF @QuotaID = 309 -- External IP addresses of VPS + SET @Result = (SELECT COUNT(PIP.PackageAddressID) FROM PackageIPAddresses AS PIP + INNER JOIN IPAddresses AS IP ON PIP.AddressID = IP.AddressID + INNER JOIN PackagesTreeCache AS PT ON PIP.PackageID = PT.PackageID + WHERE PT.ParentPackageID = @PackageID AND IP.PoolID = 3) + ELSE IF @QuotaID = 100 -- Dedicated Web IP addresses + SET @Result = (SELECT COUNT(PIP.PackageAddressID) FROM PackageIPAddresses AS PIP + INNER JOIN IPAddresses AS IP ON PIP.AddressID = IP.AddressID + INNER JOIN PackagesTreeCache AS PT ON PIP.PackageID = PT.PackageID + WHERE PT.ParentPackageID = @PackageID AND IP.PoolID = 2) + ELSE IF @QuotaID = 350 -- RAM of VPSforPc + SET @Result = (SELECT SUM(CAST(SIP.PropertyValue AS int)) FROM ServiceItemProperties AS SIP + INNER JOIN ServiceItems AS SI ON SIP.ItemID = SI.ItemID + INNER JOIN PackagesTreeCache AS PT ON SI.PackageID = PT.PackageID + WHERE SIP.PropertyName = 'Memory' AND PT.ParentPackageID = @PackageID) + ELSE IF @QuotaID = 351 -- HDD of VPSforPc + SET @Result = (SELECT SUM(CAST(SIP.PropertyValue AS int)) FROM ServiceItemProperties AS SIP + INNER JOIN ServiceItems AS SI ON SIP.ItemID = SI.ItemID + INNER JOIN PackagesTreeCache AS PT ON SI.PackageID = PT.PackageID + WHERE SIP.PropertyName = 'HddSize' AND PT.ParentPackageID = @PackageID) + ELSE IF @QuotaID = 354 -- External IP addresses of VPSforPc + SET @Result = (SELECT COUNT(PIP.PackageAddressID) FROM PackageIPAddresses AS PIP + INNER JOIN IPAddresses AS IP ON PIP.AddressID = IP.AddressID + INNER JOIN PackagesTreeCache AS PT ON PIP.PackageID = PT.PackageID + WHERE PT.ParentPackageID = @PackageID AND IP.PoolID = 3) + ELSE IF @QuotaID = 319 -- BB Users + SET @Result = (SELECT COUNT(ea.AccountID) FROM ExchangeAccounts ea + INNER JOIN BlackBerryUsers bu ON ea.AccountID = bu.AccountID + INNER JOIN ServiceItems si ON ea.ItemID = si.ItemID + INNER JOIN PackagesTreeCache pt ON si.PackageID = pt.PackageID + WHERE pt.ParentPackageID = @PackageID) + ELSE IF @QuotaID = 320 -- OCS Users + SET @Result = (SELECT COUNT(ea.AccountID) FROM ExchangeAccounts ea + INNER JOIN OCSUsers ocs ON ea.AccountID = ocs.AccountID + INNER JOIN ServiceItems si ON ea.ItemID = si.ItemID + INNER JOIN PackagesTreeCache pt ON si.PackageID = pt.PackageID + WHERE pt.ParentPackageID = @PackageID) + ELSE IF @QuotaID = 206 -- HostedSolution.Users + SET @Result = (SELECT COUNT(ea.AccountID) FROM ExchangeAccounts AS ea + INNER JOIN ServiceItems si ON ea.ItemID = si.ItemID + INNER JOIN PackagesTreeCache pt ON si.PackageID = pt.PackageID + WHERE pt.ParentPackageID = @PackageID AND ea.AccountType IN (1,5,6,7)) + ELSE IF @QuotaID = 78 -- Exchange2007.Mailboxes + SET @Result = (SELECT COUNT(ea.AccountID) FROM ExchangeAccounts AS ea + INNER JOIN ServiceItems si ON ea.ItemID = si.ItemID + INNER JOIN PackagesTreeCache pt ON si.PackageID = pt.PackageID + WHERE pt.ParentPackageID = @PackageID + AND ea.AccountType IN (1) + AND ea.MailboxPlanId IS NOT NULL) + ELSE IF @QuotaID = 77 -- Exchange2007.DiskSpace + SET @Result = (SELECT SUM(B.MailboxSizeMB) FROM ExchangeAccounts AS ea + INNER JOIN ExchangeMailboxPlans AS B ON ea.MailboxPlanId = B.MailboxPlanId + INNER JOIN ServiceItems si ON ea.ItemID = si.ItemID + INNER JOIN PackagesTreeCache pt ON si.PackageID = pt.PackageID + WHERE pt.ParentPackageID = @PackageID) + ELSE IF @QuotaID = 370 -- Lync.Users + SET @Result = (SELECT COUNT(ea.AccountID) FROM ExchangeAccounts AS ea + INNER JOIN LyncUsers lu ON ea.AccountID = lu.AccountID + INNER JOIN ServiceItems si ON ea.ItemID = si.ItemID + INNER JOIN PackagesTreeCache pt ON si.PackageID = pt.PackageID + WHERE pt.ParentPackageID = @PackageID) + ELSE IF @QuotaID = 376 -- Lync.EVUsers + SET @Result = (SELECT COUNT(ea.AccountID) FROM ExchangeAccounts AS ea + INNER JOIN LyncUsers lu ON ea.AccountID = lu.AccountID + INNER JOIN LyncUserPlans lp ON lu.LyncUserPlanId = lp.LyncUserPlanId + INNER JOIN ServiceItems si ON ea.ItemID = si.ItemID + INNER JOIN PackagesTreeCache pt ON si.PackageID = pt.PackageID + WHERE pt.ParentPackageID = @PackageID AND lp.EnterpriseVoice = 1) + ELSE IF @QuotaID = 381 -- Dedicated Lync Phone Numbers + SET @Result = (SELECT COUNT(PIP.PackageAddressID) FROM PackageIPAddresses AS PIP + INNER JOIN IPAddresses AS IP ON PIP.AddressID = IP.AddressID + INNER JOIN PackagesTreeCache AS PT ON PIP.PackageID = PT.PackageID + WHERE PT.ParentPackageID = @PackageID AND IP.PoolID = 5) + ELSE IF @QuotaID = 430 -- Enterprise Storage + SET @Result = (SELECT SUM(ESF.FolderQuota) FROM EnterpriseFolders AS ESF + INNER JOIN ServiceItems SI ON ESF.ItemID = SI.ItemID + INNER JOIN PackagesTreeCache PT ON SI.PackageID = PT.PackageID + WHERE PT.ParentPackageID = @PackageID) + ELSE IF @QuotaID = 431 -- Enterprise Storage Folders + SET @Result = (SELECT COUNT(ESF.EnterpriseFolderID) FROM EnterpriseFolders AS ESF + INNER JOIN ServiceItems SI ON ESF.ItemID = SI.ItemID + INNER JOIN PackagesTreeCache PT ON SI.PackageID = PT.PackageID + WHERE PT.ParentPackageID = @PackageID) + ELSE + SET @Result = (SELECT COUNT(SI.ItemID) FROM Quotas AS Q + INNER JOIN ServiceItems AS SI ON SI.ItemTypeID = Q.ItemTypeID + INNER JOIN PackagesTreeCache AS PT ON SI.PackageID = PT.PackageID AND PT.ParentPackageID = @PackageID + WHERE Q.QuotaID = @QuotaID) + + RETURN @Result + END +GO + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'AddEnterpriseFolder') +DROP PROCEDURE [dbo].[AddEnterpriseFolder] +GO + +CREATE PROCEDURE [dbo].[AddEnterpriseFolder] +( + @FolderID INT OUTPUT, + @ItemID INT, + @FolderName NVARCHAR(255) +) +AS + +INSERT INTO EnterpriseFolders +( + ItemID, + FolderName +) +VALUES +( + @ItemID, + @FolderName +) + +SET @FolderID = SCOPE_IDENTITY() + +RETURN +GO + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'DeleteEnterpriseFolder') +DROP PROCEDURE DeleteEnterpriseFolder +GO + +CREATE PROCEDURE [dbo].[DeleteEnterpriseFolder] +( + @ItemID INT, + @FolderName NVARCHAR(255) +) +AS + +DELETE FROM EnterpriseFolders +WHERE ItemID = @ItemID AND FolderName = @FolderName +GO + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'UpdateEnterpriseFolder') +DROP PROCEDURE UpdateEnterpriseFolder +GO + +CREATE PROCEDURE [dbo].[UpdateEnterpriseFolder] +( + @ItemID INT, + @FolderID NVARCHAR(255), + @FolderName NVARCHAR(255), + @FolderQuota INT +) +AS + +UPDATE EnterpriseFolders SET + FolderName = @FolderName, + FolderQuota = @FolderQuota +WHERE ItemID = @ItemID AND FolderName = @FolderID +GO + +-- Enterprise Storage Quotas +IF NOT EXISTS (SELECT * FROM [dbo].[Quotas] WHERE [QuotaName] = 'EnterpriseStorage.DiskStorageSpace') +BEGIN +INSERT [dbo].[Quotas] ([QuotaID], [GroupID],[QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID]) VALUES (430, 44, 1,N'EnterpriseStorage.DiskStorageSpace',N'Disk Storage Space (Mb)',2, 0 , NULL) +END +GO + +UPDATE [dbo].[Quotas] SET [QuotaDescription] = N'Disk Storage Space (Mb)' WHERE [QuotaName] = 'EnterpriseStorage.DiskStorageSpace' +GO + +--Enterprise Storage +IF NOT EXISTS(select 1 from sys.columns COLS INNER JOIN sys.objects OBJS ON OBJS.object_id=COLS.object_id and OBJS.type='U' AND OBJS.name='EnterpriseFolders' AND COLS.name='LocationDrive') +BEGIN +ALTER TABLE [dbo].[EnterpriseFolders] ADD + [LocationDrive] NVARCHAR(255) NULL +END +GO + +IF NOT EXISTS(select 1 from sys.columns COLS INNER JOIN sys.objects OBJS ON OBJS.object_id=COLS.object_id and OBJS.type='U' AND OBJS.name='EnterpriseFolders' AND COLS.name='HomeFolder') +BEGIN +ALTER TABLE [dbo].[EnterpriseFolders] ADD + [HomeFolder] NVARCHAR(255) NULL +END +GO + +IF NOT EXISTS(select 1 from sys.columns COLS INNER JOIN sys.objects OBJS ON OBJS.object_id=COLS.object_id and OBJS.type='U' AND OBJS.name='EnterpriseFolders' AND COLS.name='Domain') +BEGIN +ALTER TABLE [dbo].[EnterpriseFolders] ADD + [Domain] NVARCHAR(255) NULL +END +GO + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'GetEnterpriseFolders') +DROP PROCEDURE GetEnterpriseFolders +GO + +CREATE PROCEDURE [dbo].[GetEnterpriseFolders] +( + @ItemID INT +) +AS + +SELECT DISTINCT LocationDrive, HomeFolder, Domain FROM EnterpriseFolders +WHERE ItemID = @ItemID +GO + + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'GetEnterpriseFolder') +DROP PROCEDURE GetEnterpriseFolder +GO + +CREATE PROCEDURE [dbo].[GetEnterpriseFolder] +( + @ItemID INT, + @FolderName NVARCHAR(255) +) +AS + +SELECT LocationDrive, HomeFolder, Domain FROM EnterpriseFolders +WHERE ItemID = @ItemID AND FolderName = @FolderName +GO + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'AddEnterpriseFolder') +DROP PROCEDURE [dbo].[AddEnterpriseFolder] +GO + +CREATE PROCEDURE [dbo].[AddEnterpriseFolder] +( + @FolderID INT OUTPUT, + @ItemID INT, + @FolderName NVARCHAR(255), + @LocationDrive NVARCHAR(255), + @HomeFolder NVARCHAR(255), + @Domain NVARCHAR(255) +) +AS + +INSERT INTO EnterpriseFolders +( + ItemID, + FolderName, + LocationDrive, + HomeFolder, + Domain +) +VALUES +( + @ItemID, + @FolderName, + @LocationDrive, + @HomeFolder, + @Domain +) + +SET @FolderID = SCOPE_IDENTITY() + +RETURN +GO + +DECLARE @serviceId int +SET @serviceId = (SELECT TOP(1) ServiceId FROM Services WHERE ProviderID = 600) + +DECLARE @locationDrive nvarchar(255) +SET @locationDrive = (SELECT TOP(1) PropertyValue FROM ServiceProperties WHERE PropertyName = 'locationdrive' AND ServiceID = @serviceId) +DECLARE @homeFolder nvarchar(255) +SET @homeFolder = (SELECT TOP(1) PropertyValue FROM ServiceProperties WHERE PropertyName = 'usershome' AND ServiceID = @serviceId) +DECLARE @domain nvarchar(255) +SET @domain = (SELECT TOP(1) PropertyValue FROM ServiceProperties WHERE PropertyName = 'usersdomain' AND ServiceID = @serviceId) + +UPDATE EnterpriseFolders SET + LocationDrive = @locationDrive, + HomeFolder = @homeFolder, + Domain = @domain +GO + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'GetOrganizationGroupsByDisplayName') +DROP PROCEDURE [dbo].[GetOrganizationGroupsByDisplayName] +GO + +CREATE PROCEDURE [dbo].[GetOrganizationGroupsByDisplayName] +( + @ItemID int, + @DisplayName NVARCHAR(255) +) +AS +SELECT + AccountID, + ItemID, + AccountType, + AccountName, + DisplayName, + UserPrincipalName +FROM + ExchangeAccounts +WHERE + ItemID = @ItemID AND DisplayName = @DisplayName AND (AccountType IN (8, 9)) +RETURN +GO + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'AddEnterpriseFolder') +DROP PROCEDURE [dbo].[AddEnterpriseFolder] +GO + +CREATE PROCEDURE [dbo].[AddEnterpriseFolder] +( + @FolderID INT OUTPUT, + @ItemID INT, + @FolderName NVARCHAR(255), + @FolderQuota INT, + @LocationDrive NVARCHAR(255), + @HomeFolder NVARCHAR(255), + @Domain NVARCHAR(255) +) +AS + +INSERT INTO EnterpriseFolders +( + ItemID, + FolderName, + FolderQuota, + LocationDrive, + HomeFolder, + Domain +) +VALUES +( + @ItemID, + @FolderName, + @FolderQuota, + @LocationDrive, + @HomeFolder, + @Domain +) + +SET @FolderID = SCOPE_IDENTITY() + +RETURN +GO + +-- Security Groups Quota update + +IF EXISTS (SELECT * FROM [dbo].[Quotas] WHERE [QuotaName] = 'HostedSolution.SecurityGroupManagement' AND [QuotaID] = 423) +BEGIN + UPDATE [dbo].[Quotas] + SET [QuotaDescription] = N'Security Groups', + [QuotaName] = N'HostedSolution.SecurityGroups', + [QuotaTypeID] = 2 + WHERE [QuotaID] = 423 + + UPDATE [dbo].[HostingPlanQuotas] + SET [QuotaValue] = -1 + WHERE [QuotaID] = 423 + + UPDATE [dbo].[PackageQuotas] + SET [QuotaValue] = -1 + WHERE [QuotaID] = 423 +END +ELSE + BEGIN + --add Security Groups Quota + IF NOT EXISTS (SELECT * FROM [dbo].[Quotas] WHERE [QuotaName] = 'HostedSolution.SecurityGroups') + INSERT [dbo].[Quotas] ([QuotaID], [GroupID],[QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (423, 13, 5, N'HostedSolution.SecurityGroups', N'Security Groups', 2, 0, NULL, NULL) + END +GO + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'GetOrganizationStatistics') +DROP PROCEDURE [dbo].[GetOrganizationStatistics] +GO + +CREATE PROCEDURE [dbo].[GetOrganizationStatistics] +( + @ItemID int +) +AS +SELECT + (SELECT COUNT(*) FROM ExchangeAccounts WHERE (AccountType = 7 OR AccountType = 1 OR AccountType = 6 OR AccountType = 5) AND ItemID = @ItemID) AS CreatedUsers, + (SELECT COUNT(*) FROM ExchangeOrganizationDomains WHERE ItemID = @ItemID) AS CreatedDomains, + (SELECT COUNT(*) FROM ExchangeAccounts WHERE (AccountType = 8 OR AccountType = 9) AND ItemID = @ItemID) AS CreatedGroups +RETURN +GO + + +ALTER FUNCTION [dbo].[CalculateQuotaUsage] +( + @PackageID int, + @QuotaID int +) +RETURNS int +AS + BEGIN + + DECLARE @QuotaTypeID int + SELECT @QuotaTypeID = QuotaTypeID FROM Quotas + WHERE QuotaID = @QuotaID + + IF @QuotaTypeID <> 2 + RETURN 0 + + DECLARE @Result int + + IF @QuotaID = 52 -- diskspace + SET @Result = dbo.CalculatePackageDiskspace(@PackageID) + ELSE IF @QuotaID = 51 -- bandwidth + SET @Result = dbo.CalculatePackageBandwidth(@PackageID) + ELSE IF @QuotaID = 53 -- domains + SET @Result = (SELECT COUNT(D.DomainID) FROM PackagesTreeCache AS PT + INNER JOIN Domains AS D ON D.PackageID = PT.PackageID + WHERE IsSubDomain = 0 AND IsInstantAlias = 0 AND IsDomainPointer = 0 AND PT.ParentPackageID = @PackageID) + ELSE IF @QuotaID = 54 -- sub-domains + SET @Result = (SELECT COUNT(D.DomainID) FROM PackagesTreeCache AS PT + INNER JOIN Domains AS D ON D.PackageID = PT.PackageID + WHERE IsSubDomain = 1 AND IsInstantAlias = 0 AND IsDomainPointer = 0 AND PT.ParentPackageID = @PackageID) + ELSE IF @QuotaID = 220 -- domain pointers + SET @Result = (SELECT COUNT(D.DomainID) FROM PackagesTreeCache AS PT + INNER JOIN Domains AS D ON D.PackageID = PT.PackageID + WHERE IsDomainPointer = 1 AND PT.ParentPackageID = @PackageID) + ELSE IF @QuotaID = 71 -- scheduled tasks + SET @Result = (SELECT COUNT(S.ScheduleID) FROM PackagesTreeCache AS PT + INNER JOIN Schedule AS S ON S.PackageID = PT.PackageID + WHERE PT.ParentPackageID = @PackageID) + ELSE IF @QuotaID = 305 -- RAM of VPS + SET @Result = (SELECT SUM(CAST(SIP.PropertyValue AS int)) FROM ServiceItemProperties AS SIP + INNER JOIN ServiceItems AS SI ON SIP.ItemID = SI.ItemID + INNER JOIN PackagesTreeCache AS PT ON SI.PackageID = PT.PackageID + WHERE SIP.PropertyName = 'RamSize' AND PT.ParentPackageID = @PackageID) + ELSE IF @QuotaID = 306 -- HDD of VPS + SET @Result = (SELECT SUM(CAST(SIP.PropertyValue AS int)) FROM ServiceItemProperties AS SIP + INNER JOIN ServiceItems AS SI ON SIP.ItemID = SI.ItemID + INNER JOIN PackagesTreeCache AS PT ON SI.PackageID = PT.PackageID + WHERE SIP.PropertyName = 'HddSize' AND PT.ParentPackageID = @PackageID) + ELSE IF @QuotaID = 309 -- External IP addresses of VPS + SET @Result = (SELECT COUNT(PIP.PackageAddressID) FROM PackageIPAddresses AS PIP + INNER JOIN IPAddresses AS IP ON PIP.AddressID = IP.AddressID + INNER JOIN PackagesTreeCache AS PT ON PIP.PackageID = PT.PackageID + WHERE PT.ParentPackageID = @PackageID AND IP.PoolID = 3) + ELSE IF @QuotaID = 100 -- Dedicated Web IP addresses + SET @Result = (SELECT COUNT(PIP.PackageAddressID) FROM PackageIPAddresses AS PIP + INNER JOIN IPAddresses AS IP ON PIP.AddressID = IP.AddressID + INNER JOIN PackagesTreeCache AS PT ON PIP.PackageID = PT.PackageID + WHERE PT.ParentPackageID = @PackageID AND IP.PoolID = 2) + ELSE IF @QuotaID = 350 -- RAM of VPSforPc + SET @Result = (SELECT SUM(CAST(SIP.PropertyValue AS int)) FROM ServiceItemProperties AS SIP + INNER JOIN ServiceItems AS SI ON SIP.ItemID = SI.ItemID + INNER JOIN PackagesTreeCache AS PT ON SI.PackageID = PT.PackageID + WHERE SIP.PropertyName = 'Memory' AND PT.ParentPackageID = @PackageID) + ELSE IF @QuotaID = 351 -- HDD of VPSforPc + SET @Result = (SELECT SUM(CAST(SIP.PropertyValue AS int)) FROM ServiceItemProperties AS SIP + INNER JOIN ServiceItems AS SI ON SIP.ItemID = SI.ItemID + INNER JOIN PackagesTreeCache AS PT ON SI.PackageID = PT.PackageID + WHERE SIP.PropertyName = 'HddSize' AND PT.ParentPackageID = @PackageID) + ELSE IF @QuotaID = 354 -- External IP addresses of VPSforPc + SET @Result = (SELECT COUNT(PIP.PackageAddressID) FROM PackageIPAddresses AS PIP + INNER JOIN IPAddresses AS IP ON PIP.AddressID = IP.AddressID + INNER JOIN PackagesTreeCache AS PT ON PIP.PackageID = PT.PackageID + WHERE PT.ParentPackageID = @PackageID AND IP.PoolID = 3) + ELSE IF @QuotaID = 319 -- BB Users + SET @Result = (SELECT COUNT(ea.AccountID) FROM ExchangeAccounts ea + INNER JOIN BlackBerryUsers bu ON ea.AccountID = bu.AccountID + INNER JOIN ServiceItems si ON ea.ItemID = si.ItemID + INNER JOIN PackagesTreeCache pt ON si.PackageID = pt.PackageID + WHERE pt.ParentPackageID = @PackageID) + ELSE IF @QuotaID = 320 -- OCS Users + SET @Result = (SELECT COUNT(ea.AccountID) FROM ExchangeAccounts ea + INNER JOIN OCSUsers ocs ON ea.AccountID = ocs.AccountID + INNER JOIN ServiceItems si ON ea.ItemID = si.ItemID + INNER JOIN PackagesTreeCache pt ON si.PackageID = pt.PackageID + WHERE pt.ParentPackageID = @PackageID) + ELSE IF @QuotaID = 206 -- HostedSolution.Users + SET @Result = (SELECT COUNT(ea.AccountID) FROM ExchangeAccounts AS ea + INNER JOIN ServiceItems si ON ea.ItemID = si.ItemID + INNER JOIN PackagesTreeCache pt ON si.PackageID = pt.PackageID + WHERE pt.ParentPackageID = @PackageID AND ea.AccountType IN (1,5,6,7)) + ELSE IF @QuotaID = 78 -- Exchange2007.Mailboxes + SET @Result = (SELECT COUNT(ea.AccountID) FROM ExchangeAccounts AS ea + INNER JOIN ServiceItems si ON ea.ItemID = si.ItemID + INNER JOIN PackagesTreeCache pt ON si.PackageID = pt.PackageID + WHERE pt.ParentPackageID = @PackageID + AND ea.AccountType IN (1) + AND ea.MailboxPlanId IS NOT NULL) + ELSE IF @QuotaID = 77 -- Exchange2007.DiskSpace + SET @Result = (SELECT SUM(B.MailboxSizeMB) FROM ExchangeAccounts AS ea + INNER JOIN ExchangeMailboxPlans AS B ON ea.MailboxPlanId = B.MailboxPlanId + INNER JOIN ServiceItems si ON ea.ItemID = si.ItemID + INNER JOIN PackagesTreeCache pt ON si.PackageID = pt.PackageID + WHERE pt.ParentPackageID = @PackageID) + ELSE IF @QuotaID = 370 -- Lync.Users + SET @Result = (SELECT COUNT(ea.AccountID) FROM ExchangeAccounts AS ea + INNER JOIN LyncUsers lu ON ea.AccountID = lu.AccountID + INNER JOIN ServiceItems si ON ea.ItemID = si.ItemID + INNER JOIN PackagesTreeCache pt ON si.PackageID = pt.PackageID + WHERE pt.ParentPackageID = @PackageID) + ELSE IF @QuotaID = 376 -- Lync.EVUsers + SET @Result = (SELECT COUNT(ea.AccountID) FROM ExchangeAccounts AS ea + INNER JOIN LyncUsers lu ON ea.AccountID = lu.AccountID + INNER JOIN LyncUserPlans lp ON lu.LyncUserPlanId = lp.LyncUserPlanId + INNER JOIN ServiceItems si ON ea.ItemID = si.ItemID + INNER JOIN PackagesTreeCache pt ON si.PackageID = pt.PackageID + WHERE pt.ParentPackageID = @PackageID AND lp.EnterpriseVoice = 1) + ELSE IF @QuotaID = 381 -- Dedicated Lync Phone Numbers + SET @Result = (SELECT COUNT(PIP.PackageAddressID) FROM PackageIPAddresses AS PIP + INNER JOIN IPAddresses AS IP ON PIP.AddressID = IP.AddressID + INNER JOIN PackagesTreeCache AS PT ON PIP.PackageID = PT.PackageID + WHERE PT.ParentPackageID = @PackageID AND IP.PoolID = 5) + ELSE IF @QuotaID = 430 -- Enterprise Storage + SET @Result = (SELECT SUM(ESF.FolderQuota) FROM EnterpriseFolders AS ESF + INNER JOIN ServiceItems SI ON ESF.ItemID = SI.ItemID + INNER JOIN PackagesTreeCache PT ON SI.PackageID = PT.PackageID + WHERE PT.ParentPackageID = @PackageID) + ELSE IF @QuotaID = 431 -- Enterprise Storage Folders + SET @Result = (SELECT COUNT(ESF.EnterpriseFolderID) FROM EnterpriseFolders AS ESF + INNER JOIN ServiceItems SI ON ESF.ItemID = SI.ItemID + INNER JOIN PackagesTreeCache PT ON SI.PackageID = PT.PackageID + WHERE PT.ParentPackageID = @PackageID) + ELSE IF @QuotaID = 423 -- HostedSolution.SecurityGroups + SET @Result = (SELECT COUNT(ea.AccountID) FROM ExchangeAccounts AS ea + INNER JOIN ServiceItems si ON ea.ItemID = si.ItemID + INNER JOIN PackagesTreeCache pt ON si.PackageID = pt.PackageID + WHERE pt.ParentPackageID = @PackageID AND ea.AccountType IN (8,9)) + ELSE + SET @Result = (SELECT COUNT(SI.ItemID) FROM Quotas AS Q + INNER JOIN ServiceItems AS SI ON SI.ItemTypeID = Q.ItemTypeID + INNER JOIN PackagesTreeCache AS PT ON SI.PackageID = PT.PackageID AND PT.ParentPackageID = @PackageID + WHERE Q.QuotaID = @QuotaID) + + RETURN @Result + END +GO + + + +-- CRM2013 + +-- CRM2013 ResourceGroup + +IF NOT EXISTS (SELECT * FROM [dbo].[ResourceGroups] WHERE [GroupName] = 'Hosted CRM2013') +BEGIN +INSERT [dbo].[ResourceGroups] ([GroupID], [GroupName], [GroupOrder], [GroupController], [ShowGroup]) VALUES (24, N'Hosted CRM2013', 15, NULL, 1) +END +GO + +-- CRM2013 Provider + +IF NOT EXISTS (SELECT * FROM [dbo].[Providers] WHERE [DisplayName] = 'Hosted MS CRM 2013') +BEGIN +INSERT [dbo].[Providers] ([ProviderId], [GroupId], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery]) +VALUES(1202, 24, N'CRM', N'Hosted MS CRM 2013', N'WebsitePanel.Providers.HostedSolution.CRMProvider2013, WebsitePanel.Providers.HostedSolution.Crm2013', N'CRM2011', NULL) +END +GO + +-- CRM2013 Quotas + +IF NOT EXISTS (SELECT * FROM [dbo].[Quotas] WHERE [QuotaName] = 'HostedCRM2013.Organization') +BEGIN +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) +VALUES (463, 24, 1, N'HostedCRM2013.Organization', N'CRM Organization', 1, 0, NULL, NULL) +END +GO + +IF NOT EXISTS (SELECT * FROM [dbo].[Quotas] WHERE [QuotaName] = 'HostedCRM2013.MaxDatabaseSize') +BEGIN +INSERT [dbo].[Quotas] ([QuotaID], [GroupID],[QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID]) +VALUES (464, 24, 5, N'HostedCRM2013.MaxDatabaseSize', N'Max Database Size, MB',3, 0 , NULL) +END +GO + +IF NOT EXISTS (SELECT * FROM [dbo].[Quotas] WHERE [QuotaName] = 'HostedCRM2013.EssentialUsers') +BEGIN +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) +VALUES (465, 24, 2, N'HostedCRM2013.EssentialUsers', N'Essential licenses per organization', 3, 0, NULL, NULL) +END +GO + +IF NOT EXISTS (SELECT * FROM [dbo].[Quotas] WHERE [QuotaName] = 'HostedCRM2013.BasicUsers') +BEGIN +INSERT [dbo].[Quotas] ([QuotaID], [GroupID],[QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID]) +VALUES (466, 24, 3, N'HostedCRM2013.BasicUsers', N'Basic licenses per organization',3, 0 , NULL) +END +GO + +IF NOT EXISTS (SELECT * FROM [dbo].[Quotas] WHERE [QuotaName] = 'HostedCRM2013.ProfessionalUsers') +BEGIN +INSERT [dbo].[Quotas] ([QuotaID], [GroupID],[QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID]) +VALUES (467, 24, 4, N'HostedCRM2013.ProfessionalUsers', N'Professional licenses per organization',3, 0 , NULL) +END +GO + + + + +-- Exchange2013 Archiving + +-- Exchange2013 Archiving Quotas + +IF EXISTS (SELECT * FROM [dbo].[Quotas] WHERE [QuotaID] = 424) +BEGIN +UPDATE [dbo].[Quotas] SET [QuotaName]=N'Exchange2013.AllowRetentionPolicy', [QuotaDescription]=N'Allow Retention Policy' +WHERE [QuotaID] = 424 +END +GO + +IF NOT EXISTS (SELECT * FROM [dbo].[Quotas] WHERE [QuotaName] = 'Exchange2013.AllowRetentionPolicy') +BEGIN +INSERT [dbo].[Quotas] ([QuotaID], [GroupID],[QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) +VALUES (424, 12, 27,N'Exchange2013.AllowRetentionPolicy',N'Allow Retention Policy',1, 0 , NULL, NULL) +END +GO + +IF NOT EXISTS (SELECT * FROM [dbo].[Quotas] WHERE [QuotaName] = 'Exchange2013.ArchivingStorage') +BEGIN +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) +VALUES (425, 12, 29, N'Exchange2013.ArchivingStorage', N'Archiving storage, MB', 2, 0, NULL, NULL) +END +GO + +IF NOT EXISTS (SELECT * FROM [dbo].[Quotas] WHERE [QuotaName] = 'Exchange2013.ArchivingMailboxes') +BEGIN +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) +VALUES (426, 12, 28, N'Exchange2013.ArchivingMailboxes', N'Archiving Mailboxes per Organization', 2, 0, NULL, NULL) +END +GO + +IF NOT EXISTS (SELECT * FROM [dbo].[Quotas] WHERE [QuotaName] = 'Exchange2013.AllowArchiving') +BEGIN +INSERT [dbo].[Quotas] ([QuotaID], [GroupID],[QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) +VALUES (427, 12, 27,N'Exchange2013.AllowArchiving',N'Allow Archiving',1, 0 , NULL, NULL) +END +GO + + +-- Exchange2013 Archiving Plans +IF NOT EXISTS(select 1 from sys.columns COLS INNER JOIN sys.objects OBJS ON OBJS.object_id=COLS.object_id and OBJS.type='U' AND OBJS.name='ExchangeMailboxPlans' AND COLS.name='Archiving') +BEGIN +ALTER TABLE [dbo].[ExchangeMailboxPlans] ADD +[Archiving] [bit] NULL +END +GO + +IF NOT EXISTS(select 1 from sys.columns COLS INNER JOIN sys.objects OBJS ON OBJS.object_id=COLS.object_id and OBJS.type='U' AND OBJS.name='ExchangeMailboxPlans' AND COLS.name='EnableArchiving') +BEGIN +ALTER TABLE [dbo].[ExchangeMailboxPlans] ADD +[EnableArchiving] [bit] NULL +END +GO + +IF NOT EXISTS(select 1 from sys.columns COLS INNER JOIN sys.objects OBJS ON OBJS.object_id=COLS.object_id and OBJS.type='U' AND OBJS.name='ExchangeMailboxPlans' AND COLS.name='ArchiveSizeMB') +BEGIN +ALTER TABLE [dbo].[ExchangeMailboxPlans] ADD +[ArchiveSizeMB] [int] NULL, +[ArchiveWarningPct] [int] NULL +END +GO + + +ALTER PROCEDURE [dbo].[AddExchangeMailboxPlan] +( + @MailboxPlanId int OUTPUT, + @ItemID int, + @MailboxPlan nvarchar(300), + @EnableActiveSync bit, + @EnableIMAP bit, + @EnableMAPI bit, + @EnableOWA bit, + @EnablePOP bit, + @IsDefault bit, + @IssueWarningPct int, + @KeepDeletedItemsDays int, + @MailboxSizeMB int, + @MaxReceiveMessageSizeKB int, + @MaxRecipients int, + @MaxSendMessageSizeKB int, + @ProhibitSendPct int, + @ProhibitSendReceivePct int , + @HideFromAddressBook bit, + @MailboxPlanType int, + @AllowLitigationHold bit, + @RecoverableItemsWarningPct int, + @RecoverableItemsSpace int, + @LitigationHoldUrl nvarchar(256), + @LitigationHoldMsg nvarchar(512), + @Archiving bit, + @EnableArchiving bit, + @ArchiveSizeMB int, + @ArchiveWarningPct int +) +AS + +IF (((SELECT Count(*) FROM ExchangeMailboxPlans WHERE ItemId = @ItemID) = 0) AND (@MailboxPlanType=0)) +BEGIN + SET @IsDefault = 1 +END +ELSE +BEGIN + IF ((@IsDefault = 1) AND (@MailboxPlanType=0)) + BEGIN + UPDATE ExchangeMailboxPlans SET IsDefault = 0 WHERE ItemID = @ItemID + END +END + +INSERT INTO ExchangeMailboxPlans +( + ItemID, + MailboxPlan, + EnableActiveSync, + EnableIMAP, + EnableMAPI, + EnableOWA, + EnablePOP, + IsDefault, + IssueWarningPct, + KeepDeletedItemsDays, + MailboxSizeMB, + MaxReceiveMessageSizeKB, + MaxRecipients, + MaxSendMessageSizeKB, + ProhibitSendPct, + ProhibitSendReceivePct, + HideFromAddressBook, + MailboxPlanType, + AllowLitigationHold, + RecoverableItemsWarningPct, + RecoverableItemsSpace, + LitigationHoldUrl, + LitigationHoldMsg, + Archiving, + EnableArchiving, + ArchiveSizeMB, + ArchiveWarningPct +) +VALUES +( + @ItemID, + @MailboxPlan, + @EnableActiveSync, + @EnableIMAP, + @EnableMAPI, + @EnableOWA, + @EnablePOP, + @IsDefault, + @IssueWarningPct, + @KeepDeletedItemsDays, + @MailboxSizeMB, + @MaxReceiveMessageSizeKB, + @MaxRecipients, + @MaxSendMessageSizeKB, + @ProhibitSendPct, + @ProhibitSendReceivePct, + @HideFromAddressBook, + @MailboxPlanType, + @AllowLitigationHold, + @RecoverableItemsWarningPct, + @RecoverableItemsSpace, + @LitigationHoldUrl, + @LitigationHoldMsg, + @Archiving, + @EnableArchiving, + @ArchiveSizeMB, + @ArchiveWarningPct +) + +SET @MailboxPlanId = SCOPE_IDENTITY() + +RETURN + +GO + +ALTER PROCEDURE [dbo].[UpdateExchangeMailboxPlan] +( + @MailboxPlanId int, + @MailboxPlan nvarchar(300), + @EnableActiveSync bit, + @EnableIMAP bit, + @EnableMAPI bit, + @EnableOWA bit, + @EnablePOP bit, + @IsDefault bit, + @IssueWarningPct int, + @KeepDeletedItemsDays int, + @MailboxSizeMB int, + @MaxReceiveMessageSizeKB int, + @MaxRecipients int, + @MaxSendMessageSizeKB int, + @ProhibitSendPct int, + @ProhibitSendReceivePct int , + @HideFromAddressBook bit, + @MailboxPlanType int, + @AllowLitigationHold bit, + @RecoverableItemsWarningPct int, + @RecoverableItemsSpace int, + @LitigationHoldUrl nvarchar(256), + @LitigationHoldMsg nvarchar(512), + @Archiving bit, + @EnableArchiving bit, + @ArchiveSizeMB int, + @ArchiveWarningPct int +) +AS + +UPDATE ExchangeMailboxPlans SET + MailboxPlan = @MailboxPlan, + EnableActiveSync = @EnableActiveSync, + EnableIMAP = @EnableIMAP, + EnableMAPI = @EnableMAPI, + EnableOWA = @EnableOWA, + EnablePOP = @EnablePOP, + IsDefault = @IsDefault, + IssueWarningPct= @IssueWarningPct, + KeepDeletedItemsDays = @KeepDeletedItemsDays, + MailboxSizeMB= @MailboxSizeMB, + MaxReceiveMessageSizeKB= @MaxReceiveMessageSizeKB, + MaxRecipients= @MaxRecipients, + MaxSendMessageSizeKB= @MaxSendMessageSizeKB, + ProhibitSendPct= @ProhibitSendPct, + ProhibitSendReceivePct = @ProhibitSendReceivePct, + HideFromAddressBook = @HideFromAddressBook, + MailboxPlanType = @MailboxPlanType, + AllowLitigationHold = @AllowLitigationHold, + RecoverableItemsWarningPct = @RecoverableItemsWarningPct, + RecoverableItemsSpace = @RecoverableItemsSpace, + LitigationHoldUrl = @LitigationHoldUrl, + LitigationHoldMsg = @LitigationHoldMsg, + Archiving = @Archiving, + EnableArchiving = @EnableArchiving, + ArchiveSizeMB = @ArchiveSizeMB, + ArchiveWarningPct = @ArchiveWarningPct +WHERE MailboxPlanId = @MailboxPlanId + +RETURN + +GO + + + +ALTER PROCEDURE [dbo].[GetExchangeMailboxPlans] +( + @ItemID int, + @Archiving bit +) +AS +SELECT + MailboxPlanId, + ItemID, + MailboxPlan, + EnableActiveSync, + EnableIMAP, + EnableMAPI, + EnableOWA, + EnablePOP, + IsDefault, + IssueWarningPct, + KeepDeletedItemsDays, + MailboxSizeMB, + MaxReceiveMessageSizeKB, + MaxRecipients, + MaxSendMessageSizeKB, + ProhibitSendPct, + ProhibitSendReceivePct, + HideFromAddressBook, + MailboxPlanType, + Archiving, + EnableArchiving, + ArchiveSizeMB, + ArchiveWarningPct +FROM + ExchangeMailboxPlans +WHERE + ItemID = @ItemID +AND ((Archiving=@Archiving) OR ((@Archiving=0) AND (Archiving IS NULL))) +ORDER BY MailboxPlan +RETURN + +GO + + +ALTER PROCEDURE [dbo].[GetExchangeMailboxPlan] +( + @MailboxPlanId int +) +AS +SELECT + MailboxPlanId, + ItemID, + MailboxPlan, + EnableActiveSync, + EnableIMAP, + EnableMAPI, + EnableOWA, + EnablePOP, + IsDefault, + IssueWarningPct, + KeepDeletedItemsDays, + MailboxSizeMB, + MaxReceiveMessageSizeKB, + MaxRecipients, + MaxSendMessageSizeKB, + ProhibitSendPct, + ProhibitSendReceivePct, + HideFromAddressBook, + MailboxPlanType, + AllowLitigationHold, + RecoverableItemsWarningPct, + RecoverableItemsSpace, + LitigationHoldUrl, + LitigationHoldMsg, + Archiving, + EnableArchiving, + ArchiveSizeMB, + ArchiveWarningPct +FROM + ExchangeMailboxPlans +WHERE + MailboxPlanId = @MailboxPlanId +RETURN + +GO + +-- Exchange2013 ExchangeAccount + +IF NOT EXISTS(select 1 from sys.columns COLS INNER JOIN sys.objects OBJS ON OBJS.object_id=COLS.object_id and OBJS.type='U' AND OBJS.name='ExchangeAccounts' AND COLS.name='ArchivingMailboxPlanId') +BEGIN +ALTER TABLE [dbo].[ExchangeAccounts] ADD +[ArchivingMailboxPlanId] [int] NULL +END +GO + +IF NOT EXISTS(select 1 from sys.columns COLS INNER JOIN sys.objects OBJS ON OBJS.object_id=COLS.object_id and OBJS.type='U' AND OBJS.name='ExchangeAccounts' AND COLS.name='EnableArchiving') +BEGIN +ALTER TABLE [dbo].[ExchangeAccounts] ADD +[EnableArchiving] [bit] NULL +END +GO + +-- Password column removed +ALTER PROCEDURE [dbo].[GetExchangeAccount] +( + @ItemID int, + @AccountID int +) +AS +SELECT + E.AccountID, + E.ItemID, + E.AccountType, + E.AccountName, + E.DisplayName, + E.PrimaryEmailAddress, + E.MailEnabledPublicFolder, + E.MailboxManagerActions, + E.SamAccountName, + E.MailboxPlanId, + P.MailboxPlan, + E.SubscriberNumber, + E.UserPrincipalName, + E.ArchivingMailboxPlanId, + AP.MailboxPlan as 'ArchivingMailboxPlan', + E.EnableArchiving +FROM + ExchangeAccounts AS E +LEFT OUTER JOIN ExchangeMailboxPlans AS P ON E.MailboxPlanId = P.MailboxPlanId +LEFT OUTER JOIN ExchangeMailboxPlans AS AP ON E.ArchivingMailboxPlanId = AP.MailboxPlanId +WHERE + E.ItemID = @ItemID AND + E.AccountID = @AccountID +RETURN +GO + + +-- Password column removed +ALTER PROCEDURE [dbo].[GetExchangeAccountByAccountName] +( + @ItemID int, + @AccountName nvarchar(300) +) +AS +SELECT + E.AccountID, + E.ItemID, + E.AccountType, + E.AccountName, + E.DisplayName, + E.PrimaryEmailAddress, + E.MailEnabledPublicFolder, + E.MailboxManagerActions, + E.SamAccountName, + E.MailboxPlanId, + P.MailboxPlan, + E.SubscriberNumber, + E.UserPrincipalName, + E.ArchivingMailboxPlanId, + AP.MailboxPlan as 'ArchivingMailboxPlan', + E.EnableArchiving +FROM + ExchangeAccounts AS E +LEFT OUTER JOIN ExchangeMailboxPlans AS P ON E.MailboxPlanId = P.MailboxPlanId +LEFT OUTER JOIN ExchangeMailboxPlans AS AP ON E.ArchivingMailboxPlanId = AP.MailboxPlanId +WHERE + E.ItemID = @ItemID AND + E.AccountName = @AccountName +RETURN +GO + + + + + +-- Password column removed +ALTER PROCEDURE [dbo].[GetExchangeAccountByMailboxPlanId] +( + @ItemID int, + @MailboxPlanId int +) +AS + +IF (@MailboxPlanId < 0) +BEGIN +SELECT + E.AccountID, + E.ItemID, + E.AccountType, + E.AccountName, + E.DisplayName, + E.PrimaryEmailAddress, + E.MailEnabledPublicFolder, + E.MailboxManagerActions, + E.SamAccountName, + E.MailboxPlanId, + P.MailboxPlan, + E.SubscriberNumber, + E.UserPrincipalName, + E.ArchivingMailboxPlanId, + AP.MailboxPlan as 'ArchivingMailboxPlan', + E.EnableArchiving +FROM + ExchangeAccounts AS E +LEFT OUTER JOIN ExchangeMailboxPlans AS P ON E.MailboxPlanId = P.MailboxPlanId +LEFT OUTER JOIN ExchangeMailboxPlans AS AP ON E.ArchivingMailboxPlanId = AP.MailboxPlanId +WHERE + E.ItemID = @ItemID AND + E.MailboxPlanId IS NULL AND + E.AccountType IN (1,5) +RETURN + +END +ELSE +IF (@ItemId = 0) +BEGIN +SELECT + E.AccountID, + E.ItemID, + E.AccountType, + E.AccountName, + E.DisplayName, + E.PrimaryEmailAddress, + E.MailEnabledPublicFolder, + E.MailboxManagerActions, + E.SamAccountName, + E.MailboxPlanId, + P.MailboxPlan, + E.SubscriberNumber, + E.UserPrincipalName, + E.ArchivingMailboxPlanId, + AP.MailboxPlan as 'ArchivingMailboxPlan', + E.EnableArchiving +FROM + ExchangeAccounts AS E +LEFT OUTER JOIN ExchangeMailboxPlans AS P ON E.MailboxPlanId = P.MailboxPlanId +LEFT OUTER JOIN ExchangeMailboxPlans AS AP ON E.ArchivingMailboxPlanId = AP.MailboxPlanId +WHERE + E.MailboxPlanId = @MailboxPlanId AND + E.AccountType IN (1,5) +END +ELSE +BEGIN +SELECT + E.AccountID, + E.ItemID, + E.AccountType, + E.AccountName, + E.DisplayName, + E.PrimaryEmailAddress, + E.MailEnabledPublicFolder, + E.MailboxManagerActions, + E.SamAccountName, + E.MailboxPlanId, + P.MailboxPlan, + E.SubscriberNumber, + E.UserPrincipalName, + E.ArchivingMailboxPlanId, + AP.MailboxPlan as 'ArchivingMailboxPlan', + E.EnableArchiving +FROM + ExchangeAccounts AS E +LEFT OUTER JOIN ExchangeMailboxPlans AS P ON E.MailboxPlanId = P.MailboxPlanId +LEFT OUTER JOIN ExchangeMailboxPlans AS AP ON E.ArchivingMailboxPlanId = AP.MailboxPlanId +WHERE + E.ItemID = @ItemID AND + E.MailboxPlanId = @MailboxPlanId AND + E.AccountType IN (1,5) +RETURN +END +GO + + + + +ALTER PROCEDURE [dbo].[GetExchangeAccountsPaged] +( + @ActorID int, + @ItemID int, + @AccountTypes nvarchar(30), + @FilterColumn nvarchar(50) = '', + @FilterValue nvarchar(50) = '', + @SortColumn nvarchar(50), + @StartRow int, + @MaximumRows int, + @Archiving bit +) +AS + +DECLARE @PackageID int +SELECT @PackageID = PackageID FROM ServiceItems +WHERE ItemID = @ItemID + +-- check rights +IF dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 +RAISERROR('You are not allowed to access this package', 16, 1) + +-- start +DECLARE @condition nvarchar(700) +SET @condition = ' +EA.AccountType IN (' + @AccountTypes + ') +AND EA.ItemID = @ItemID +' + +IF @FilterColumn <> '' AND @FilterColumn IS NOT NULL +AND @FilterValue <> '' AND @FilterValue IS NOT NULL +BEGIN + IF @FilterColumn = 'PrimaryEmailAddress' AND @AccountTypes <> '2' + BEGIN + SET @condition = @condition + ' AND EA.AccountID IN (SELECT EAEA.AccountID FROM ExchangeAccountEmailAddresses EAEA WHERE EAEA.EmailAddress LIKE ''' + @FilterValue + ''')' + END + ELSE + BEGIN + SET @condition = @condition + ' AND ' + @FilterColumn + ' LIKE ''' + @FilterValue + '''' + END +END + +if @Archiving = 1 +BEGIN + SET @condition = @condition + ' AND (EA.ArchivingMailboxPlanId > 0) ' +END + +IF @SortColumn IS NULL OR @SortColumn = '' +SET @SortColumn = 'EA.DisplayName ASC' + +DECLARE @joincondition nvarchar(700) + SET @joincondition = ',P.MailboxPlan FROM ExchangeAccounts AS EA + LEFT OUTER JOIN ExchangeMailboxPlans AS P ON EA.MailboxPlanId = P.MailboxPlanId' + +DECLARE @sql nvarchar(3500) + +set @sql = ' +SELECT COUNT(EA.AccountID) FROM ExchangeAccounts AS EA +WHERE ' + @condition + '; + +WITH Accounts AS ( + SELECT ROW_NUMBER() OVER (ORDER BY ' + @SortColumn + ') as Row, + EA.AccountID, + EA.ItemID, + EA.AccountType, + EA.AccountName, + EA.DisplayName, + EA.PrimaryEmailAddress, + EA.MailEnabledPublicFolder, + EA.MailboxPlanId, + EA.SubscriberNumber, + EA.UserPrincipalName ' + @joincondition + + ' WHERE ' + @condition + ' +) + +SELECT * FROM Accounts +WHERE Row BETWEEN @StartRow + 1 and @StartRow + @MaximumRows +' + +print @sql + +exec sp_executesql @sql, N'@ItemID int, @StartRow int, @MaximumRows int', +@ItemID, @StartRow, @MaximumRows + +RETURN + +GO + + +ALTER PROCEDURE [dbo].[SetExchangeAccountMailboxplan] +( + @AccountID int, + @MailboxPlanId int, + @ArchivingMailboxPlanId int, + @EnableArchiving bit +) +AS + +UPDATE ExchangeAccounts SET + MailboxPlanId = @MailboxPlanId, + ArchivingMailboxPlanId = @ArchivingMailboxPlanId, + EnableArchiving = @EnableArchiving +WHERE + AccountID = @AccountID + +RETURN + +GO + +-- Password column removed +ALTER PROCEDURE [dbo].[UpdateExchangeAccount] +( + @AccountID int, + @AccountName nvarchar(300), + @DisplayName nvarchar(300), + @PrimaryEmailAddress nvarchar(300), + @AccountType int, + @SamAccountName nvarchar(100), + @MailEnabledPublicFolder bit, + @MailboxManagerActions varchar(200), + @MailboxPlanId int, + @ArchivingMailboxPlanId int, + @SubscriberNumber varchar(32), + @EnableArchiving bit +) +AS + +BEGIN TRAN + +IF (@MailboxPlanId = -1) +BEGIN + SET @MailboxPlanId = NULL +END + +UPDATE ExchangeAccounts SET + AccountName = @AccountName, + DisplayName = @DisplayName, + PrimaryEmailAddress = @PrimaryEmailAddress, + MailEnabledPublicFolder = @MailEnabledPublicFolder, + MailboxManagerActions = @MailboxManagerActions, + AccountType =@AccountType, + SamAccountName = @SamAccountName, + MailboxPlanId = @MailboxPlanId, + SubscriberNumber = @SubscriberNumber, + ArchivingMailboxPlanId = @ArchivingMailboxPlanId, + EnableArchiving = @EnableArchiving + +WHERE + AccountID = @AccountID + +IF (@@ERROR <> 0 ) + BEGIN + ROLLBACK TRANSACTION + RETURN -1 + END + +COMMIT TRAN +RETURN + +GO + +-- Exchange2013 Archiving ExchangeRetentionPolicyTags + +IF NOT EXISTS (SELECT * FROM SYS.TABLES WHERE name = 'ExchangeRetentionPolicyTags') +CREATE TABLE ExchangeRetentionPolicyTags +( +[TagID] [int] IDENTITY(1,1) NOT NULL PRIMARY KEY, +[ItemID] [int] NOT NULL, +[TagName] NVARCHAR(255), +[TagType] [int] NOT NULL, +[AgeLimitForRetention] [int] NOT NULL, +[RetentionAction] [int] NOT NULL +) +GO + + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'AddExchangeRetentionPolicyTag') +DROP PROCEDURE [dbo].[AddExchangeRetentionPolicyTag] +GO + +CREATE PROCEDURE [dbo].[AddExchangeRetentionPolicyTag] +( + @TagID int OUTPUT, + @ItemID int, + @TagName nvarchar(255), + @TagType int, + @AgeLimitForRetention int, + @RetentionAction int +) +AS +BEGIN + +INSERT INTO ExchangeRetentionPolicyTags +( + ItemID, + TagName, + TagType, + AgeLimitForRetention, + RetentionAction +) +VALUES +( + @ItemID, + @TagName, + @TagType, + @AgeLimitForRetention, + @RetentionAction +) + +SET @TagID = SCOPE_IDENTITY() + +RETURN + +END +GO + + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'UpdateExchangeRetentionPolicyTag') +DROP PROCEDURE [dbo].[UpdateExchangeRetentionPolicyTag] +GO + +CREATE PROCEDURE [dbo].[UpdateExchangeRetentionPolicyTag] +( + @TagID int, + @ItemID int, + @TagName nvarchar(255), + @TagType int, + @AgeLimitForRetention int, + @RetentionAction int +) +AS + +UPDATE ExchangeRetentionPolicyTags SET + ItemID = @ItemID, + TagName = @TagName, + TagType = @TagType, + AgeLimitForRetention = @AgeLimitForRetention, + RetentionAction = @RetentionAction +WHERE TagID = @TagID + +RETURN + +GO + + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'GetExchangeRetentionPolicyTags') +DROP PROCEDURE [dbo].[GetExchangeRetentionPolicyTags] +GO + +CREATE PROCEDURE [dbo].[GetExchangeRetentionPolicyTags] +( + @ItemID int +) +AS +SELECT + TagID, + ItemID, + TagName, + TagType, + AgeLimitForRetention, + RetentionAction +FROM + ExchangeRetentionPolicyTags +WHERE + ItemID = @ItemID +ORDER BY TagName +RETURN + +GO + + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'GetExchangeRetentionPolicyTag') +DROP PROCEDURE [dbo].[GetExchangeRetentionPolicyTag] +GO + +CREATE PROCEDURE [dbo].[GetExchangeRetentionPolicyTag] +( + @TagID int +) +AS +SELECT + TagID, + ItemID, + TagName, + TagType, + AgeLimitForRetention, + RetentionAction +FROM + ExchangeRetentionPolicyTags +WHERE + TagID = @TagID +RETURN + +GO + + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'DeleteExchangeRetentionPolicyTag') +DROP PROCEDURE [dbo].[DeleteExchangeRetentionPolicyTag] +GO + + +CREATE PROCEDURE [dbo].[DeleteExchangeRetentionPolicyTag] +( + @TagID int +) +AS +DELETE FROM ExchangeRetentionPolicyTags +WHERE + TagID = @TagID +RETURN + +GO + + +-- Exchange2013 Archiving ExchangeMailboxPlanRetentionPolicyTags + +IF NOT EXISTS (SELECT * FROM SYS.TABLES WHERE name = 'ExchangeMailboxPlanRetentionPolicyTags') +CREATE TABLE ExchangeMailboxPlanRetentionPolicyTags +( +[PlanTagID] [int] IDENTITY(1,1) NOT NULL PRIMARY KEY, +[TagID] [int] NOT NULL, +[MailboxPlanId] [int] NOT NULL +) +GO + + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'GetExchangeMailboxPlanRetentionPolicyTags') +DROP PROCEDURE [dbo].[GetExchangeMailboxPlanRetentionPolicyTags] +GO + +CREATE PROCEDURE [dbo].[GetExchangeMailboxPlanRetentionPolicyTags] +( + @MailboxPlanId int +) +AS +SELECT +D.PlanTagID, +D.TagID, +D.MailboxPlanId, +P.MailboxPlan, +T.TagName +FROM + ExchangeMailboxPlanRetentionPolicyTags AS D +LEFT OUTER JOIN ExchangeMailboxPlans AS P ON P.MailboxPlanId = D.MailboxPlanId +LEFT OUTER JOIN ExchangeRetentionPolicyTags AS T ON T.TagID = D.TagID +WHERE + D.MailboxPlanId = @MailboxPlanId +RETURN + +GO + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'AddExchangeMailboxPlanRetentionPolicyTag') +DROP PROCEDURE [dbo].[AddExchangeMailboxPlanRetentionPolicyTag] +GO + +CREATE PROCEDURE [dbo].[AddExchangeMailboxPlanRetentionPolicyTag] +( + @PlanTagID int OUTPUT, + @TagID int, + @MailboxPlanId int +) +AS +BEGIN + +INSERT INTO ExchangeMailboxPlanRetentionPolicyTags +( + TagID, + MailboxPlanId +) +VALUES +( + @TagID, + @MailboxPlanId +) + +SET @PlanTagID = SCOPE_IDENTITY() + +RETURN + +END +GO + + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'DeleteExchangeMailboxPlanRetentionPolicyTag') +DROP PROCEDURE [dbo].[DeleteExchangeMailboxPlanRetentionPolicyTag] +GO + +CREATE PROCEDURE [dbo].[DeleteExchangeMailboxPlanRetentionPolicyTag] +( + @PlanTagID int +) +AS +DELETE FROM ExchangeMailboxPlanRetentionPolicyTags +WHERE + PlanTagID = @PlanTagID +RETURN + +GO + +IF NOT EXISTS (SELECT * FROM [dbo].[Quotas] WHERE [QuotaName] = 'EnterpriseStorage.DriveMaps') +BEGIN +INSERT [dbo].[Quotas] ([QuotaID], [GroupID],[QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID]) VALUES (468, 44, 2, N'EnterpriseStorage.DriveMaps', N'Use Drive Maps', 1, 0, NULL) +END +GO + +-- Exchange2013 Archiving + +ALTER PROCEDURE [dbo].[GetExchangeOrganizationStatistics] +( + @ItemID int +) +AS + +DECLARE @ARCHIVESIZE INT +IF -1 in (SELECT B.ArchiveSizeMB FROM ExchangeAccounts AS A INNER JOIN ExchangeMailboxPlans AS B ON A.MailboxPlanId = B.MailboxPlanId WHERE A.ItemID=@ItemID) +BEGIN + SET @ARCHIVESIZE = -1 +END +ELSE +BEGIN + SET @ARCHIVESIZE = (SELECT SUM(B.ArchiveSizeMB) FROM ExchangeAccounts AS A INNER JOIN ExchangeMailboxPlans AS B ON A.MailboxPlanId = B.MailboxPlanId WHERE A.ItemID=@ItemID) +END + +IF -1 IN (SELECT B.MailboxSizeMB FROM ExchangeAccounts AS A INNER JOIN ExchangeMailboxPlans AS B ON A.MailboxPlanId = B.MailboxPlanId WHERE A.ItemID=@ItemID) +BEGIN +SELECT + (SELECT COUNT(*) FROM ExchangeAccounts WHERE (AccountType = 1 OR AccountType = 5 OR AccountType = 6) AND ItemID = @ItemID) AS CreatedMailboxes, + (SELECT COUNT(*) FROM ExchangeAccounts WHERE AccountType = 2 AND ItemID = @ItemID) AS CreatedContacts, + (SELECT COUNT(*) FROM ExchangeAccounts WHERE AccountType = 3 AND ItemID = @ItemID) AS CreatedDistributionLists, + (SELECT COUNT(*) FROM ExchangeAccounts WHERE AccountType = 4 AND ItemID = @ItemID) AS CreatedPublicFolders, + (SELECT COUNT(*) FROM ExchangeOrganizationDomains WHERE ItemID = @ItemID) AS CreatedDomains, + (SELECT MIN(B.MailboxSizeMB) FROM ExchangeAccounts AS A INNER JOIN ExchangeMailboxPlans AS B ON A.MailboxPlanId = B.MailboxPlanId WHERE A.ItemID=@ItemID) AS UsedDiskSpace, + (SELECT MIN(B.RecoverableItemsSpace) FROM ExchangeAccounts AS A INNER JOIN ExchangeMailboxPlans AS B ON A.MailboxPlanId = B.MailboxPlanId WHERE A.ItemID=@ItemID) AS UsedLitigationHoldSpace, + @ARCHIVESIZE AS UsedArchingStorage +END +ELSE +BEGIN +SELECT + (SELECT COUNT(*) FROM ExchangeAccounts WHERE (AccountType = 1 OR AccountType = 5 OR AccountType = 6) AND ItemID = @ItemID) AS CreatedMailboxes, + (SELECT COUNT(*) FROM ExchangeAccounts WHERE AccountType = 2 AND ItemID = @ItemID) AS CreatedContacts, + (SELECT COUNT(*) FROM ExchangeAccounts WHERE AccountType = 3 AND ItemID = @ItemID) AS CreatedDistributionLists, + (SELECT COUNT(*) FROM ExchangeAccounts WHERE AccountType = 4 AND ItemID = @ItemID) AS CreatedPublicFolders, + (SELECT COUNT(*) FROM ExchangeOrganizationDomains WHERE ItemID = @ItemID) AS CreatedDomains, + (SELECT SUM(B.MailboxSizeMB) FROM ExchangeAccounts AS A INNER JOIN ExchangeMailboxPlans AS B ON A.MailboxPlanId = B.MailboxPlanId WHERE A.ItemID=@ItemID) AS UsedDiskSpace, + (SELECT SUM(B.RecoverableItemsSpace) FROM ExchangeAccounts AS A INNER JOIN ExchangeMailboxPlans AS B ON A.MailboxPlanId = B.MailboxPlanId WHERE A.ItemID=@ItemID) AS UsedLitigationHoldSpace, + @ARCHIVESIZE AS UsedArchingStorage +END + + +RETURN +GO + + +BEGIN +DELETE FROM [dbo].[HostingPlanQuotas] WHERE QuotaID = 427 +END +GO + +BEGIN +DELETE FROM [dbo].[PackageQuotas] WHERE QuotaID = 427 +END +GO + + +BEGIN +DELETE FROM [dbo].[Quotas] WHERE QuotaID = 427 +END +GO + +-- Set SQL 2008 and SQL 2012 Users on suspendable +BEGIN +UPDATE [dbo].[ServiceItemTypes] SET [Suspendable] = 1 WHERE [ItemTypeID] = 32 AND [GroupID] = 22 +END +GO + +BEGIN +UPDATE [dbo].[ServiceItemTypes] SET [Suspendable] = 1 WHERE [ItemTypeID] = 38 AND [GroupID] = 23 +END +GO + +/* ICE Warp */ +IF NOT EXISTS (SELECT * FROM [dbo].[Providers] WHERE [ProviderName] = 'IceWarp') +BEGIN +INSERT [dbo].[Providers] ([ProviderID], [GroupID], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery]) VALUES (160, 4, N'IceWarp', N'IceWarp Mail Server', N'WebsitePanel.Providers.Mail.IceWarp, WebsitePanel.Providers.Mail.IceWarp', N'IceWarp', NULL) +END +GO + +/* SQL 2014 Provider */ +IF NOT EXISTS (SELECT * FROM [dbo].[ResourceGroups] WHERE [GroupName] = 'MsSQL2014') +BEGIN +INSERT [dbo].[ResourceGroups] ([GroupID], [GroupName], [GroupOrder], [GroupController], [ShowGroup]) VALUES (46, N'MsSQL2014', 11, N'WebsitePanel.EnterpriseServer.DatabaseServerController', 1) +END +ELSE +BEGIN +UPDATE [dbo].[ResourceGroups] SET [ShowGroup] = 1 WHERE [GroupName] = 'MsSQL2014' +END +GO +IF NOT EXISTS (SELECT * FROM [dbo].[Providers] WHERE [DisplayName] = 'Microsoft SQL Server 2014') +BEGIN +INSERT [dbo].[Providers] ([ProviderID], [GroupID], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery]) VALUES (1203, 46, N'MsSQL', N'Microsoft SQL Server 2014', N'WebsitePanel.Providers.Database.MsSqlServer2014, WebsitePanel.Providers.Database.SqlServer', N'MSSQL', NULL) +INSERT [dbo].[ServiceItemTypes] ([ItemTypeID], [GroupID], [DisplayName], [TypeName], [TypeOrder], [CalculateDiskspace], [CalculateBandwidth], [Suspendable], [Disposable], [Searchable], [Importable], [Backupable]) VALUES (39, 46, N'MsSQL2014Database', N'WebsitePanel.Providers.Database.SqlDatabase, WebsitePanel.Providers.Base', 1, 1, 0, 0, 1, 1, 1, 1) +INSERT [dbo].[ServiceItemTypes] ([ItemTypeID], [GroupID], [DisplayName], [TypeName], [TypeOrder], [CalculateDiskspace], [CalculateBandwidth], [Suspendable], [Disposable], [Searchable], [Importable], [Backupable]) VALUES (40, 46, N'MsSQL2014User', N'WebsitePanel.Providers.Database.SqlUser, WebsitePanel.Providers.Base', 1, 0, 0, 0, 1, 1, 1, 1) +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (470, 46, 1, N'MsSQL2014.Databases', N'Databases', 2, 0, 39, NULL) +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (471, 46, 2, N'MsSQL2014.Users', N'Users', 2, 0, 40, NULL) +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (472, 46, 3, N'MsSQL2014.MaxDatabaseSize', N'Max Database Size', 3, 0, NULL, NULL) +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (473, 46, 5, N'MsSQL2014.Backup', N'Database Backups', 1, 0, NULL, NULL) +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (474, 46, 6, N'MsSQL2014.Restore', N'Database Restores', 1, 0, NULL, NULL) +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (475, 46, 7, N'MsSQL2014.Truncate', N'Database Truncate', 1, 0, NULL, NULL) +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (476, 46, 4, N'MsSQL2014.MaxLogSize', N'Max Log Size', 3, 0, NULL, NULL) +END +ELSE +BEGIN +UPDATE [dbo].[Providers] SET [DisableAutoDiscovery] = NULL, GroupID = 46 WHERE [DisplayName] = 'Microsoft SQL Server 2014' +END +GO + + + +/*This should be [DefaultValue]= N'MsSQL2000=SQL Server 2000;MsSQL2005=SQL Server 2005;MsSQL2008=SQL Server 2008;MsSQL2012=SQL Server 2012;MsSQL2014=SQL Server 2014;MySQL4=MySQL 4.0;MySQL5=MySQL 5.0' but the field is not large enough!! */ +UPDATE [dbo].[ScheduleTaskParameters] SET [DefaultValue]= N'MsSQL2005=SQL Server 2005;MsSQL2008=SQL Server 2008;MsSQL2012=SQL Server 2012;MsSQL2014=SQL Server 2014;MySQL4=MySQL 4.0;MySQL5=MySQL 5.0' WHERE [TaskID]= 'SCHEDULE_TASK_BACKUP_DATABASE' AND [ParameterID]='DATABASE_GROUP' +GO + +/*SUPPORT SERVICE LEVELS*/ + +IF NOT EXISTS (SELECT * FROM [dbo].[ResourceGroups] WHERE [GroupName] = 'Service Levels') +BEGIN +INSERT [dbo].[ResourceGroups] ([GroupID], [GroupName], [GroupOrder], [GroupController], [ShowGroup]) VALUES (47, N'Service Levels', 2, NULL, 1) +END +GO + +IF NOT EXISTS (SELECT * FROM SYS.TABLES WHERE name = 'SupportServiceLevels') +CREATE TABLE SupportServiceLevels +( +[LevelID] [int] IDENTITY(1,1) NOT NULL PRIMARY KEY, +[LevelName] NVARCHAR(100) NOT NULL, +[LevelDescription] NVARCHAR(1000) NULL +) +GO + +IF NOT EXISTS(select 1 from sys.columns COLS INNER JOIN sys.objects OBJS ON OBJS.object_id=COLS.object_id and OBJS.type='U' AND OBJS.name='ExchangeAccounts' AND COLS.name='LevelID') +ALTER TABLE [dbo].[ExchangeAccounts] ADD + [LevelID] [int] NULL, + [IsVIP] [bit] NOT NULL DEFAULT 0 +GO + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'GetSupportServiceLevels') +DROP PROCEDURE GetSupportServiceLevels +GO + +CREATE PROCEDURE [dbo].[GetSupportServiceLevels] +AS +SELECT * +FROM SupportServiceLevels +RETURN +GO + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'GetSupportServiceLevel') +DROP PROCEDURE GetSupportServiceLevel +GO + +CREATE PROCEDURE [dbo].[GetSupportServiceLevel] +( + @LevelID int +) +AS +SELECT * +FROM SupportServiceLevels +WHERE LevelID = @LevelID +RETURN +GO + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'AddSupportServiceLevel') +DROP PROCEDURE AddSupportServiceLevel +GO + +CREATE PROCEDURE [dbo].[AddSupportServiceLevel] +( + @LevelID int OUTPUT, + @LevelName nvarchar(100), + @LevelDescription nvarchar(1000) +) +AS +BEGIN + + IF EXISTS (SELECT * FROM SupportServiceLevels WHERE LevelName = @LevelName) + BEGIN + SET @LevelID = -1 + + RETURN + END + + INSERT INTO SupportServiceLevels + ( + LevelName, + LevelDescription + ) + VALUES + ( + @LevelName, + @LevelDescription + ) + + SET @LevelID = SCOPE_IDENTITY() + + DECLARE @ResourseGroupID int + + IF EXISTS (SELECT * FROM ResourceGroups WHERE GroupName = 'Service Levels') + BEGIN + DECLARE @QuotaLastID int, @CurQuotaName nvarchar(100), + @CurQuotaDescription nvarchar(1000), @QuotaOrderInGroup int + + SET @CurQuotaName = N'ServiceLevel.' + @LevelName + SET @CurQuotaDescription = @LevelName + N', users' + + SELECT @ResourseGroupID = GroupID FROM ResourceGroups WHERE GroupName = 'Service Levels' + + SELECT @QuotaLastID = MAX(QuotaID) FROM Quotas + + SELECT @QuotaOrderInGroup = MAX(QuotaOrder) FROM Quotas WHERE GroupID = @ResourseGroupID + + IF @QuotaOrderInGroup IS NULL SET @QuotaOrderInGroup = 0 + + IF NOT EXISTS (SELECT * FROM Quotas WHERE QuotaName = @CurQuotaName) + BEGIN + INSERT Quotas + (QuotaID, + GroupID, + QuotaOrder, + QuotaName, + QuotaDescription, + QuotaTypeID, + ServiceQuota, + ItemTypeID) + VALUES + (@QuotaLastID + 1, + @ResourseGroupID, + @QuotaOrderInGroup + 1, + @CurQuotaName, + @CurQuotaDescription, + 2, + 0, + NULL) + END + END + +END + +RETURN +GO + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'DeleteSupportServiceLevel') +DROP PROCEDURE DeleteSupportServiceLevel +GO + +CREATE PROCEDURE [dbo].[DeleteSupportServiceLevel] +( + @LevelID int +) +AS +BEGIN + + DECLARE @LevelName nvarchar(100), @QuotaName nvarchar(100), @QuotaID int + + SELECT @LevelName = LevelName FROM SupportServiceLevels WHERE LevelID = @LevelID + + SET @QuotaName = N'ServiceLevel.' + @LevelName + + SELECT @QuotaID = QuotaID FROM Quotas WHERE QuotaName = @QuotaName + + IF @QuotaID IS NOT NULL + BEGIN + DELETE FROM HostingPlanQuotas WHERE QuotaID = @QuotaID + DELETE FROM PackageQuotas WHERE QuotaID = @QuotaID + DELETE FROM Quotas WHERE QuotaID = @QuotaID + END + + IF EXISTS (SELECT * FROM ExchangeAccounts WHERE LevelID = @LevelID) + UPDATE ExchangeAccounts + SET LevelID = NULL + WHERE LevelID = @LevelID + + DELETE FROM SupportServiceLevels WHERE LevelID = @LevelID + +END + +RETURN +GO + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'UpdateSupportServiceLevel') +DROP PROCEDURE UpdateSupportServiceLevel +GO + +CREATE PROCEDURE [dbo].[UpdateSupportServiceLevel] +( + @LevelID int, + @LevelName nvarchar(100), + @LevelDescription nvarchar(1000) +) +AS +BEGIN + + DECLARE @PrevQuotaName nvarchar(100), @PrevLevelName nvarchar(100) + + SELECT @PrevLevelName = LevelName FROM SupportServiceLevels WHERE LevelID = @LevelID + + SET @PrevQuotaName = N'ServiceLevel.' + @PrevLevelName + + UPDATE SupportServiceLevels + SET LevelName = @LevelName, + LevelDescription = @LevelDescription + WHERE LevelID = @LevelID + + IF EXISTS (SELECT * FROM Quotas WHERE QuotaName = @PrevQuotaName) + BEGIN + DECLARE @QuotaID INT + + SELECT @QuotaID = QuotaID FROM Quotas WHERE QuotaName = @PrevQuotaName + + UPDATE Quotas + SET QuotaName = N'ServiceLevel.' + @LevelName, + QuotaDescription = @LevelName + ', users' + WHERE QuotaID = @QuotaID + END + +END + +RETURN +GO + + + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type IN ('FN', 'IF', 'TF') AND name = 'GetPackageServiceLevelResource') +DROP FUNCTION GetPackageServiceLevelResource +GO + +CREATE FUNCTION dbo.GetPackageServiceLevelResource +( + @PackageID int, + @GroupID int, + @ServerID int +) +RETURNS bit +AS +BEGIN + +IF NOT EXISTS (SELECT * FROM dbo.ResourceGroups WHERE GroupID = @GroupID AND GroupName = 'Service Levels') +RETURN 0 + +IF @PackageID IS NULL +RETURN 1 + +DECLARE @Result bit +SET @Result = 1 -- enabled + +DECLARE @PID int, @ParentPackageID int +SET @PID = @PackageID + +DECLARE @OverrideQuotas bit + +IF @ServerID IS NULL OR @ServerID = 0 +SELECT @ServerID = ServerID FROM Packages +WHERE PackageID = @PackageID + +WHILE 1 = 1 +BEGIN + + DECLARE @GroupEnabled int + + -- get package info + SELECT + @ParentPackageID = ParentPackageID, + @OverrideQuotas = OverrideQuotas + FROM Packages WHERE PackageID = @PID + + -- check if this is a root 'System' package + SET @GroupEnabled = 1 -- enabled + IF @ParentPackageID IS NULL + BEGIN + + IF @ServerID = 0 + RETURN 0 + ELSE IF @PID = -1 + RETURN 1 + ELSE IF @ServerID IS NULL + RETURN 1 + ELSE IF @ServerID > 0 + RETURN 1 + ELSE RETURN 0 + END + ELSE -- parentpackage is not null + BEGIN + -- check the current package + IF @OverrideQuotas = 1 + BEGIN + IF NOT EXISTS( + SELECT GroupID FROM PackageResources WHERE GroupID = @GroupID AND PackageID = @PID + ) + SET @GroupEnabled = 0 + END + ELSE + BEGIN + IF NOT EXISTS( + SELECT HPR.GroupID FROM Packages AS P + INNER JOIN HostingPlanResources AS HPR ON P.PlanID = HPR.PlanID + WHERE HPR.GroupID = @GroupID AND P.PackageID = @PID + ) + SET @GroupEnabled = 0 + END + + -- check addons + IF EXISTS( + SELECT HPR.GroupID FROM PackageAddons AS PA + INNER JOIN HostingPlanResources AS HPR ON PA.PlanID = HPR.PlanID + WHERE HPR.GroupID = @GroupID AND PA.PackageID = @PID + AND PA.StatusID = 1 -- active add-on + ) + SET @GroupEnabled = 1 + END + + IF @GroupEnabled = 0 + RETURN 0 + + SET @PID = @ParentPackageID + +END -- end while + +RETURN @Result +END +GO + +ALTER PROCEDURE [dbo].[GetPackageQuotasForEdit] +( + @ActorID int, + @PackageID int +) +AS + +-- check rights +IF dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 +RAISERROR('You are not allowed to access this package', 16, 1) + +DECLARE @ServerID int, @ParentPackageID int, @PlanID int +SELECT @ServerID = ServerID, @ParentPackageID = ParentPackageID, @PlanID = PlanID FROM Packages +WHERE PackageID = @PackageID + +-- get resource groups +SELECT + RG.GroupID, + RG.GroupName, + ISNULL(PR.CalculateDiskSpace, ISNULL(HPR.CalculateDiskSpace, 0)) AS CalculateDiskSpace, + ISNULL(PR.CalculateBandwidth, ISNULL(HPR.CalculateBandwidth, 0)) AS CalculateBandwidth, + --dbo.GetPackageAllocatedResource(@PackageID, RG.GroupID, @ServerID) AS Enabled, + CASE + WHEN RG.GroupName = 'Service Levels' THEN dbo.GetPackageServiceLevelResource(PackageID, RG.GroupID, @ServerID) + ELSE dbo.GetPackageAllocatedResource(PackageID, RG.GroupID, @ServerID) + END AS Enabled, + --dbo.GetPackageAllocatedResource(@ParentPackageID, RG.GroupID, @ServerID) AS ParentEnabled + CASE + WHEN RG.GroupName = 'Service Levels' THEN dbo.GetPackageServiceLevelResource(@ParentPackageID, RG.GroupID, @ServerID) + ELSE dbo.GetPackageAllocatedResource(@ParentPackageID, RG.GroupID, @ServerID) + END AS ParentEnabled +FROM ResourceGroups AS RG +LEFT OUTER JOIN PackageResources AS PR ON RG.GroupID = PR.GroupID AND PR.PackageID = @PackageID +LEFT OUTER JOIN HostingPlanResources AS HPR ON RG.GroupID = HPR.GroupID AND HPR.PlanID = @PlanID +ORDER BY RG.GroupOrder + + +-- return quotas +SELECT + Q.QuotaID, + Q.GroupID, + Q.QuotaName, + Q.QuotaDescription, + Q.QuotaTypeID, + CASE + WHEN PQ.QuotaValue IS NULL THEN dbo.GetPackageAllocatedQuota(@PackageID, Q.QuotaID) + ELSE PQ.QuotaValue + END QuotaValue, + dbo.GetPackageAllocatedQuota(@ParentPackageID, Q.QuotaID) AS ParentQuotaValue +FROM Quotas AS Q +LEFT OUTER JOIN PackageQuotas AS PQ ON PQ.QuotaID = Q.QuotaID AND PQ.PackageID = @PackageID +ORDER BY Q.QuotaOrder + +RETURN +GO + +ALTER PROCEDURE [dbo].[GetPackageQuotas] +( + @ActorID int, + @PackageID int +) +AS + +-- check rights +IF dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 +RAISERROR('You are not allowed to access this package', 16, 1) + +DECLARE @PlanID int, @ParentPackageID int +SELECT @PlanID = PlanID, @ParentPackageID = ParentPackageID FROM Packages +WHERE PackageID = @PackageID + +-- get resource groups +SELECT + RG.GroupID, + RG.GroupName, + ISNULL(HPR.CalculateDiskSpace, 0) AS CalculateDiskSpace, + ISNULL(HPR.CalculateBandwidth, 0) AS CalculateBandwidth, + --dbo.GetPackageAllocatedResource(@ParentPackageID, RG.GroupID, 0) AS ParentEnabled + CASE + WHEN RG.GroupName = 'Service Levels' THEN dbo.GetPackageServiceLevelResource(@ParentPackageID, RG.GroupID, 0) + ELSE dbo.GetPackageAllocatedResource(@ParentPackageID, RG.GroupID, 0) + END AS ParentEnabled +FROM ResourceGroups AS RG +LEFT OUTER JOIN HostingPlanResources AS HPR ON RG.GroupID = HPR.GroupID AND HPR.PlanID = @PlanID +--WHERE dbo.GetPackageAllocatedResource(@PackageID, RG.GroupID, 0) = 1 +WHERE (dbo.GetPackageAllocatedResource(@PackageID, RG.GroupID, 0) = 1 AND RG.GroupName <> 'Service Levels') OR + (dbo.GetPackageServiceLevelResource(@PackageID, RG.GroupID, 0) = 1 AND RG.GroupName = 'Service Levels') +ORDER BY RG.GroupOrder + + +-- return quotas +SELECT + Q.QuotaID, + Q.GroupID, + Q.QuotaName, + Q.QuotaDescription, + Q.QuotaTypeID, + dbo.GetPackageAllocatedQuota(@PackageID, Q.QuotaID) AS QuotaValue, + dbo.GetPackageAllocatedQuota(@ParentPackageID, Q.QuotaID) AS ParentQuotaValue, + ISNULL(dbo.CalculateQuotaUsage(@PackageID, Q.QuotaID), 0) AS QuotaUsedValue +FROM Quotas AS Q +WHERE Q.HideQuota IS NULL OR Q.HideQuota = 0 +ORDER BY Q.QuotaOrder +RETURN +GO + +ALTER PROCEDURE [dbo].[GetHostingPlanQuotas] +( + @ActorID int, + @PlanID int, + @PackageID int, + @ServerID int +) +AS + +-- check rights +IF dbo.CheckActorParentPackageRights(@ActorID, @PackageID) = 0 +RAISERROR('You are not allowed to access this package', 16, 1) + +DECLARE @IsAddon bit + +IF @ServerID = 0 +SELECT @ServerID = ServerID FROM Packages +WHERE PackageID = @PackageID + +-- get resource groups +SELECT + RG.GroupID, + RG.GroupName, + CASE + WHEN HPR.CalculateDiskSpace IS NULL THEN CAST(0 as bit) + ELSE CAST(1 as bit) + END AS Enabled, + --dbo.GetPackageAllocatedResource(@PackageID, RG.GroupID, @ServerID) AS ParentEnabled, + CASE + WHEN RG.GroupName = 'Service Levels' THEN dbo.GetPackageServiceLevelResource(@PackageID, RG.GroupID, @ServerID) + ELSE dbo.GetPackageAllocatedResource(@PackageID, RG.GroupID, @ServerID) + END AS ParentEnabled, + ISNULL(HPR.CalculateDiskSpace, 1) AS CalculateDiskSpace, + ISNULL(HPR.CalculateBandwidth, 1) AS CalculateBandwidth +FROM ResourceGroups AS RG +LEFT OUTER JOIN HostingPlanResources AS HPR ON RG.GroupID = HPR.GroupID AND HPR.PlanID = @PlanID +WHERE (RG.ShowGroup = 1) +ORDER BY RG.GroupOrder + +-- get quotas by groups +SELECT + Q.QuotaID, + Q.GroupID, + Q.QuotaName, + Q.QuotaDescription, + Q.QuotaTypeID, + ISNULL(HPQ.QuotaValue, 0) AS QuotaValue, + dbo.GetPackageAllocatedQuota(@PackageID, Q.QuotaID) AS ParentQuotaValue +FROM Quotas AS Q +LEFT OUTER JOIN HostingPlanQuotas AS HPQ ON Q.QuotaID = HPQ.QuotaID AND HPQ.PlanID = @PlanID +WHERE Q.HideQuota IS NULL OR Q.HideQuota = 0 +ORDER BY Q.QuotaOrder +RETURN +GO + +ALTER PROCEDURE [dbo].[SearchOrganizationAccounts] +( + @ActorID int, + @ItemID int, + @FilterColumn nvarchar(50) = '', + @FilterValue nvarchar(50) = '', + @SortColumn nvarchar(50), + @IncludeMailboxes bit +) +AS +DECLARE @PackageID int +SELECT @PackageID = PackageID FROM ServiceItems +WHERE ItemID = @ItemID + +-- check rights +IF dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 +RAISERROR('You are not allowed to access this package', 16, 1) + +-- start +DECLARE @condition nvarchar(700) +SET @condition = ' +(EA.AccountType = 7 OR (EA.AccountType = 1 AND @IncludeMailboxes = 1) ) +AND EA.ItemID = @ItemID +' + +IF @FilterColumn <> '' AND @FilterColumn IS NOT NULL +AND @FilterValue <> '' AND @FilterValue IS NOT NULL +SET @condition = @condition + ' AND ' + @FilterColumn + ' LIKE ''' + @FilterValue + '''' + +IF @SortColumn IS NULL OR @SortColumn = '' +SET @SortColumn = 'EA.DisplayName ASC' + +DECLARE @sql nvarchar(3500) + +set @sql = ' +SELECT + EA.AccountID, + EA.ItemID, + EA.AccountType, + EA.AccountName, + EA.DisplayName, + EA.PrimaryEmailAddress, + EA.SubscriberNumber, + EA.UserPrincipalName, + EA.LevelID, + EA.IsVIP +FROM ExchangeAccounts AS EA +WHERE ' + @condition + +print @sql + +exec sp_executesql @sql, N'@ItemID int, @IncludeMailboxes bit', +@ItemID, @IncludeMailboxes + +RETURN +GO + +-- Password column removed +ALTER PROCEDURE [dbo].[GetExchangeAccount] +( + @ItemID int, + @AccountID int +) +AS +SELECT + E.AccountID, + E.ItemID, + E.AccountType, + E.AccountName, + E.DisplayName, + E.PrimaryEmailAddress, + E.MailEnabledPublicFolder, + E.MailboxManagerActions, + E.SamAccountName, + E.MailboxPlanId, + P.MailboxPlan, + E.SubscriberNumber, + E.UserPrincipalName, + E.ArchivingMailboxPlanId, + AP.MailboxPlan as 'ArchivingMailboxPlan', + E.EnableArchiving, + E.LevelID, + E.IsVIP +FROM + ExchangeAccounts AS E +LEFT OUTER JOIN ExchangeMailboxPlans AS P ON E.MailboxPlanId = P.MailboxPlanId +LEFT OUTER JOIN ExchangeMailboxPlans AS AP ON E.ArchivingMailboxPlanId = AP.MailboxPlanId +WHERE + E.ItemID = @ItemID AND + E.AccountID = @AccountID +RETURN +GO + +ALTER PROCEDURE [dbo].[GetExchangeAccountsPaged] +( + @ActorID int, + @ItemID int, + @AccountTypes nvarchar(30), + @FilterColumn nvarchar(50) = '', + @FilterValue nvarchar(50) = '', + @SortColumn nvarchar(50), + @StartRow int, + @MaximumRows int, + @Archiving bit +) +AS + +DECLARE @PackageID int +SELECT @PackageID = PackageID FROM ServiceItems +WHERE ItemID = @ItemID + +-- check rights +IF dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 +RAISERROR('You are not allowed to access this package', 16, 1) + +-- start +DECLARE @condition nvarchar(700) +SET @condition = ' +EA.AccountType IN (' + @AccountTypes + ') +AND EA.ItemID = @ItemID +' + +IF @FilterColumn <> '' AND @FilterColumn IS NOT NULL +AND @FilterValue <> '' AND @FilterValue IS NOT NULL +BEGIN + IF @FilterColumn = 'PrimaryEmailAddress' AND @AccountTypes <> '2' + BEGIN + SET @condition = @condition + ' AND EA.AccountID IN (SELECT EAEA.AccountID FROM ExchangeAccountEmailAddresses EAEA WHERE EAEA.EmailAddress LIKE ''' + @FilterValue + ''')' + END + ELSE + BEGIN + SET @condition = @condition + ' AND ' + @FilterColumn + ' LIKE ''' + @FilterValue + '''' + END +END + +if @Archiving = 1 +BEGIN + SET @condition = @condition + ' AND (EA.ArchivingMailboxPlanId > 0) ' +END + +IF @SortColumn IS NULL OR @SortColumn = '' +SET @SortColumn = 'EA.DisplayName ASC' + +DECLARE @joincondition nvarchar(700) + SET @joincondition = ',P.MailboxPlan FROM ExchangeAccounts AS EA + LEFT OUTER JOIN ExchangeMailboxPlans AS P ON EA.MailboxPlanId = P.MailboxPlanId' + +DECLARE @sql nvarchar(3500) + +set @sql = ' +SELECT COUNT(EA.AccountID) FROM ExchangeAccounts AS EA +WHERE ' + @condition + '; + +WITH Accounts AS ( + SELECT ROW_NUMBER() OVER (ORDER BY ' + @SortColumn + ') as Row, + EA.AccountID, + EA.ItemID, + EA.AccountType, + EA.AccountName, + EA.DisplayName, + EA.PrimaryEmailAddress, + EA.MailEnabledPublicFolder, + EA.MailboxPlanId, + EA.SubscriberNumber, + EA.UserPrincipalName, + EA.LevelID, + EA.IsVIP ' + @joincondition + + ' WHERE ' + @condition + ' +) + +SELECT * FROM Accounts +WHERE Row BETWEEN @StartRow + 1 and @StartRow + @MaximumRows +' + +print @sql + +exec sp_executesql @sql, N'@ItemID int, @StartRow int, @MaximumRows int', +@ItemID, @StartRow, @MaximumRows + +RETURN +GO + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'UpdateExchangeAccountSLSettings') +DROP PROCEDURE UpdateExchangeAccountSLSettings +GO + +CREATE PROCEDURE [dbo].[UpdateExchangeAccountSLSettings] +( + @AccountID int, + @LevelID int, + @IsVIP bit +) +AS + +BEGIN TRAN + + IF (@LevelID = -1) + BEGIN + SET @LevelID = NULL + END + + UPDATE ExchangeAccounts SET + LevelID = @LevelID, + IsVIP = @IsVIP + WHERE + AccountID = @AccountID + + IF (@@ERROR <> 0 ) + BEGIN + ROLLBACK TRANSACTION + RETURN -1 + END +COMMIT TRAN +RETURN +GO + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'CheckServiceLevelUsage') +DROP PROCEDURE CheckServiceLevelUsage +GO + +CREATE PROCEDURE [dbo].[CheckServiceLevelUsage] +( + @LevelID int +) +AS +SELECT COUNT(EA.AccountID) +FROM SupportServiceLevels AS SL +INNER JOIN ExchangeAccounts AS EA ON SL.LevelID = EA.LevelID +WHERE EA.LevelID = @LevelID +RETURN +GO + +-- Service Level Quotas, change type +UPDATE Quotas +SET QuotaTypeID = 2 +WHERE QuotaName like 'ServiceLevel.%' +GO + +ALTER FUNCTION [dbo].[CalculateQuotaUsage] +( + @PackageID int, + @QuotaID int +) +RETURNS int +AS + BEGIN + + DECLARE @QuotaTypeID int + DECLARE @QuotaName nvarchar(50) + SELECT @QuotaTypeID = QuotaTypeID, @QuotaName = QuotaName FROM Quotas + WHERE QuotaID = @QuotaID + + IF @QuotaTypeID <> 2 + RETURN 0 + + DECLARE @Result int + + IF @QuotaID = 52 -- diskspace + SET @Result = dbo.CalculatePackageDiskspace(@PackageID) + ELSE IF @QuotaID = 51 -- bandwidth + SET @Result = dbo.CalculatePackageBandwidth(@PackageID) + ELSE IF @QuotaID = 53 -- domains + SET @Result = (SELECT COUNT(D.DomainID) FROM PackagesTreeCache AS PT + INNER JOIN Domains AS D ON D.PackageID = PT.PackageID + WHERE IsSubDomain = 0 AND IsInstantAlias = 0 AND IsDomainPointer = 0 AND PT.ParentPackageID = @PackageID) + ELSE IF @QuotaID = 54 -- sub-domains + SET @Result = (SELECT COUNT(D.DomainID) FROM PackagesTreeCache AS PT + INNER JOIN Domains AS D ON D.PackageID = PT.PackageID + WHERE IsSubDomain = 1 AND IsInstantAlias = 0 AND IsDomainPointer = 0 AND PT.ParentPackageID = @PackageID) + ELSE IF @QuotaID = 220 -- domain pointers + SET @Result = (SELECT COUNT(D.DomainID) FROM PackagesTreeCache AS PT + INNER JOIN Domains AS D ON D.PackageID = PT.PackageID + WHERE IsDomainPointer = 1 AND PT.ParentPackageID = @PackageID) + ELSE IF @QuotaID = 71 -- scheduled tasks + SET @Result = (SELECT COUNT(S.ScheduleID) FROM PackagesTreeCache AS PT + INNER JOIN Schedule AS S ON S.PackageID = PT.PackageID + WHERE PT.ParentPackageID = @PackageID) + ELSE IF @QuotaID = 305 -- RAM of VPS + SET @Result = (SELECT SUM(CAST(SIP.PropertyValue AS int)) FROM ServiceItemProperties AS SIP + INNER JOIN ServiceItems AS SI ON SIP.ItemID = SI.ItemID + INNER JOIN PackagesTreeCache AS PT ON SI.PackageID = PT.PackageID + WHERE SIP.PropertyName = 'RamSize' AND PT.ParentPackageID = @PackageID) + ELSE IF @QuotaID = 306 -- HDD of VPS + SET @Result = (SELECT SUM(CAST(SIP.PropertyValue AS int)) FROM ServiceItemProperties AS SIP + INNER JOIN ServiceItems AS SI ON SIP.ItemID = SI.ItemID + INNER JOIN PackagesTreeCache AS PT ON SI.PackageID = PT.PackageID + WHERE SIP.PropertyName = 'HddSize' AND PT.ParentPackageID = @PackageID) + ELSE IF @QuotaID = 309 -- External IP addresses of VPS + SET @Result = (SELECT COUNT(PIP.PackageAddressID) FROM PackageIPAddresses AS PIP + INNER JOIN IPAddresses AS IP ON PIP.AddressID = IP.AddressID + INNER JOIN PackagesTreeCache AS PT ON PIP.PackageID = PT.PackageID + WHERE PT.ParentPackageID = @PackageID AND IP.PoolID = 3) + ELSE IF @QuotaID = 100 -- Dedicated Web IP addresses + SET @Result = (SELECT COUNT(PIP.PackageAddressID) FROM PackageIPAddresses AS PIP + INNER JOIN IPAddresses AS IP ON PIP.AddressID = IP.AddressID + INNER JOIN PackagesTreeCache AS PT ON PIP.PackageID = PT.PackageID + WHERE PT.ParentPackageID = @PackageID AND IP.PoolID = 2) + ELSE IF @QuotaID = 350 -- RAM of VPSforPc + SET @Result = (SELECT SUM(CAST(SIP.PropertyValue AS int)) FROM ServiceItemProperties AS SIP + INNER JOIN ServiceItems AS SI ON SIP.ItemID = SI.ItemID + INNER JOIN PackagesTreeCache AS PT ON SI.PackageID = PT.PackageID + WHERE SIP.PropertyName = 'Memory' AND PT.ParentPackageID = @PackageID) + ELSE IF @QuotaID = 351 -- HDD of VPSforPc + SET @Result = (SELECT SUM(CAST(SIP.PropertyValue AS int)) FROM ServiceItemProperties AS SIP + INNER JOIN ServiceItems AS SI ON SIP.ItemID = SI.ItemID + INNER JOIN PackagesTreeCache AS PT ON SI.PackageID = PT.PackageID + WHERE SIP.PropertyName = 'HddSize' AND PT.ParentPackageID = @PackageID) + ELSE IF @QuotaID = 354 -- External IP addresses of VPSforPc + SET @Result = (SELECT COUNT(PIP.PackageAddressID) FROM PackageIPAddresses AS PIP + INNER JOIN IPAddresses AS IP ON PIP.AddressID = IP.AddressID + INNER JOIN PackagesTreeCache AS PT ON PIP.PackageID = PT.PackageID + WHERE PT.ParentPackageID = @PackageID AND IP.PoolID = 3) + ELSE IF @QuotaID = 319 -- BB Users + SET @Result = (SELECT COUNT(ea.AccountID) FROM ExchangeAccounts ea + INNER JOIN BlackBerryUsers bu ON ea.AccountID = bu.AccountID + INNER JOIN ServiceItems si ON ea.ItemID = si.ItemID + INNER JOIN PackagesTreeCache pt ON si.PackageID = pt.PackageID + WHERE pt.ParentPackageID = @PackageID) + ELSE IF @QuotaID = 320 -- OCS Users + SET @Result = (SELECT COUNT(ea.AccountID) FROM ExchangeAccounts ea + INNER JOIN OCSUsers ocs ON ea.AccountID = ocs.AccountID + INNER JOIN ServiceItems si ON ea.ItemID = si.ItemID + INNER JOIN PackagesTreeCache pt ON si.PackageID = pt.PackageID + WHERE pt.ParentPackageID = @PackageID) + ELSE IF @QuotaID = 206 -- HostedSolution.Users + SET @Result = (SELECT COUNT(ea.AccountID) FROM ExchangeAccounts AS ea + INNER JOIN ServiceItems si ON ea.ItemID = si.ItemID + INNER JOIN PackagesTreeCache pt ON si.PackageID = pt.PackageID + WHERE pt.ParentPackageID = @PackageID AND ea.AccountType IN (1,5,6,7)) + ELSE IF @QuotaID = 78 -- Exchange2007.Mailboxes + SET @Result = (SELECT COUNT(ea.AccountID) FROM ExchangeAccounts AS ea + INNER JOIN ServiceItems si ON ea.ItemID = si.ItemID + INNER JOIN PackagesTreeCache pt ON si.PackageID = pt.PackageID + WHERE pt.ParentPackageID = @PackageID + AND ea.AccountType IN (1) + AND ea.MailboxPlanId IS NOT NULL) + ELSE IF @QuotaID = 77 -- Exchange2007.DiskSpace + SET @Result = (SELECT SUM(B.MailboxSizeMB) FROM ExchangeAccounts AS ea + INNER JOIN ExchangeMailboxPlans AS B ON ea.MailboxPlanId = B.MailboxPlanId + INNER JOIN ServiceItems si ON ea.ItemID = si.ItemID + INNER JOIN PackagesTreeCache pt ON si.PackageID = pt.PackageID + WHERE pt.ParentPackageID = @PackageID) + ELSE IF @QuotaID = 370 -- Lync.Users + SET @Result = (SELECT COUNT(ea.AccountID) FROM ExchangeAccounts AS ea + INNER JOIN LyncUsers lu ON ea.AccountID = lu.AccountID + INNER JOIN ServiceItems si ON ea.ItemID = si.ItemID + INNER JOIN PackagesTreeCache pt ON si.PackageID = pt.PackageID + WHERE pt.ParentPackageID = @PackageID) + ELSE IF @QuotaID = 376 -- Lync.EVUsers + SET @Result = (SELECT COUNT(ea.AccountID) FROM ExchangeAccounts AS ea + INNER JOIN LyncUsers lu ON ea.AccountID = lu.AccountID + INNER JOIN LyncUserPlans lp ON lu.LyncUserPlanId = lp.LyncUserPlanId + INNER JOIN ServiceItems si ON ea.ItemID = si.ItemID + INNER JOIN PackagesTreeCache pt ON si.PackageID = pt.PackageID + WHERE pt.ParentPackageID = @PackageID AND lp.EnterpriseVoice = 1) + ELSE IF @QuotaID = 381 -- Dedicated Lync Phone Numbers + SET @Result = (SELECT COUNT(PIP.PackageAddressID) FROM PackageIPAddresses AS PIP + INNER JOIN IPAddresses AS IP ON PIP.AddressID = IP.AddressID + INNER JOIN PackagesTreeCache AS PT ON PIP.PackageID = PT.PackageID + WHERE PT.ParentPackageID = @PackageID AND IP.PoolID = 5) + ELSE IF @QuotaID = 430 -- Enterprise Storage + SET @Result = (SELECT SUM(ESF.FolderQuota) FROM EnterpriseFolders AS ESF + INNER JOIN ServiceItems SI ON ESF.ItemID = SI.ItemID + INNER JOIN PackagesTreeCache PT ON SI.PackageID = PT.PackageID + WHERE PT.ParentPackageID = @PackageID) + ELSE IF @QuotaID = 431 -- Enterprise Storage Folders + SET @Result = (SELECT COUNT(ESF.EnterpriseFolderID) FROM EnterpriseFolders AS ESF + INNER JOIN ServiceItems SI ON ESF.ItemID = SI.ItemID + INNER JOIN PackagesTreeCache PT ON SI.PackageID = PT.PackageID + WHERE PT.ParentPackageID = @PackageID) + ELSE IF @QuotaID = 423 -- HostedSolution.SecurityGroups + SET @Result = (SELECT COUNT(ea.AccountID) FROM ExchangeAccounts AS ea + INNER JOIN ServiceItems si ON ea.ItemID = si.ItemID + INNER JOIN PackagesTreeCache pt ON si.PackageID = pt.PackageID + WHERE pt.ParentPackageID = @PackageID AND ea.AccountType IN (8,9)) + ELSE IF @QuotaName like 'ServiceLevel.%' -- Support Service Level Quota + BEGIN + DECLARE @LevelID int + + SELECT @LevelID = LevelID FROM SupportServiceLevels + WHERE LevelName = REPLACE(@QuotaName,'ServiceLevel.','') + + IF (@LevelID IS NOT NULL) + SET @Result = (SELECT COUNT(EA.AccountID) + FROM SupportServiceLevels AS SL + INNER JOIN ExchangeAccounts AS EA ON SL.LevelID = EA.LevelID + INNER JOIN ServiceItems SI ON EA.ItemID = SI.ItemID + INNER JOIN PackagesTreeCache PT ON SI.PackageID = PT.PackageID + WHERE EA.LevelID = @LevelID AND PT.ParentPackageID = @PackageID) + ELSE SET @Result = 0 + END + ELSE + SET @Result = (SELECT COUNT(SI.ItemID) FROM Quotas AS Q + INNER JOIN ServiceItems AS SI ON SI.ItemTypeID = Q.ItemTypeID + INNER JOIN PackagesTreeCache AS PT ON SI.PackageID = PT.PackageID AND PT.ParentPackageID = @PackageID + WHERE Q.QuotaID = @QuotaID) + + RETURN @Result + END +GO + + + +-- IIS80 Provider update for SNI and CCS support +-- Add default serviceproperties for all existing IIS80 Services (if any). These properties are used as markers in the IIS70 Controls in WebPortal to know the version of the IIS Provider +declare c cursor read_only for +select ServiceID from Services where ProviderID in(select ProviderID from Providers where ProviderName='IIS80') + +declare @ServiceID int + +open c + +fetch next from c +into @ServiceID + +while @@FETCH_STATUS = 0 +begin + if not exists(select null from ServiceProperties where ServiceID = @ServiceID and PropertyName = 'sslccscommonpassword') + insert into ServiceProperties(ServiceID, PropertyName, PropertyValue) + values(@ServiceID, 'sslccscommonpassword', '') + + if not exists(select null from ServiceProperties where ServiceID = @ServiceID and PropertyName = 'sslccsuncpath') + insert into ServiceProperties(ServiceID, PropertyName, PropertyValue) + values(@ServiceID, 'sslccsuncpath', '') + + if not exists(select null from ServiceProperties where ServiceID = @ServiceID and PropertyName = 'ssluseccs') + insert into ServiceProperties(ServiceID, PropertyName, PropertyValue) + values(@ServiceID, 'ssluseccs', 'False') + + if not exists(select null from ServiceProperties where ServiceID = @ServiceID and PropertyName = 'ssluseccs') + insert into ServiceProperties(ServiceID, PropertyName, PropertyValue) + values(@ServiceID, 'sslusesni', 'False') + + fetch next from c + into @ServiceID +end + +close c + +deallocate c + +GO + + + +/*Remote Desktop Services*/ + +/*Remote Desktop Services Tables*/ +IF NOT EXISTS (SELECT * FROM SYS.TABLES WHERE name = 'RDSCollectionUsers') +CREATE TABLE RDSCollectionUsers +( + ID INT IDENTITY(1,1) NOT NULL PRIMARY KEY, + RDSCollectionId INT NOT NULL, + AccountID INT NOT NULL +) +GO + + +IF NOT EXISTS (SELECT * FROM SYS.TABLES WHERE name = 'RDSServers') +CREATE TABLE RDSServers +( + ID INT IDENTITY(1,1) NOT NULL PRIMARY KEY, + ItemID INT, + Name NVARCHAR(255), + FqdName NVARCHAR(255), + Description NVARCHAR(255), + RDSCollectionId INT, + ConnectionEnabled BIT NOT NULL DEFAULT(1) +) +GO + +IF NOT EXISTS(SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'RDSServers' AND COLUMN_NAME = 'ConnectionEnabled') +BEGIN + ALTER TABLE [dbo].[RDSServers] + ADD ConnectionEnabled BIT NOT NULL DEFAULT(1) +END +GO + + +IF NOT EXISTS (SELECT * FROM SYS.TABLES WHERE name = 'RDSCollections') +CREATE TABLE RDSCollections +( + ID INT IDENTITY(1,1) NOT NULL PRIMARY KEY, + ItemID INT NOT NULL, + Name NVARCHAR(255), + Description NVARCHAR(255) +) +GO + +IF NOT EXISTS(SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'RDSCollections' AND COLUMN_NAME = 'DisplayName') +BEGIN + ALTER TABLE [dbo].[RDSCollections] + ADD DisplayName NVARCHAR(255) +END +GO + +UPDATE [dbo].[RDSCollections] SET DisplayName = [Name] WHERE DisplayName IS NULL + +IF NOT EXISTS(SELECT * FROM SYS.TABLES WHERE name = 'RDSCollectionSettings') +CREATE TABLE [dbo].[RDSCollectionSettings]( + [ID] [int] IDENTITY(1,1) NOT NULL, + [RDSCollectionId] [int] NOT NULL, + [DisconnectedSessionLimitMin] [int] NULL, + [ActiveSessionLimitMin] [int] NULL, + [IdleSessionLimitMin] [int] NULL, + [BrokenConnectionAction] [nvarchar](20) NULL, + [AutomaticReconnectionEnabled] [bit] NULL, + [TemporaryFoldersDeletedOnExit] [bit] NULL, + [TemporaryFoldersPerSession] [bit] NULL, + [ClientDeviceRedirectionOptions] [nvarchar](250) NULL, + [ClientPrinterRedirected] [bit] NULL, + [ClientPrinterAsDefault] [bit] NULL, + [RDEasyPrintDriverEnabled] [bit] NULL, + [MaxRedirectedMonitors] [int] NULL, + CONSTRAINT [PK_RDSCollectionSettings] PRIMARY KEY CLUSTERED +( + [ID] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] +) ON [PRIMARY] + +GO + +IF NOT EXISTS(SELECT * FROM sys.columns + WHERE [name] = N'SecurityLayer' AND [object_id] = OBJECT_ID(N'RDSCollectionSettings')) +BEGIN + ALTER TABLE [dbo].[RDSCollectionSettings] ADD SecurityLayer NVARCHAR(20) null; +END +GO + +IF NOT EXISTS(SELECT * FROM sys.columns + WHERE [name] = N'EncryptionLevel' AND [object_id] = OBJECT_ID(N'RDSCollectionSettings')) +BEGIN + ALTER TABLE [dbo].[RDSCollectionSettings] ADD EncryptionLevel NVARCHAR(20) null; +END +GO + +IF NOT EXISTS(SELECT * FROM sys.columns + WHERE [name] = N'AuthenticateUsingNLA' AND [object_id] = OBJECT_ID(N'RDSCollectionSettings')) +BEGIN + ALTER TABLE [dbo].[RDSCollectionSettings] ADD AuthenticateUsingNLA BIT null; +END +GO + + + +IF NOT EXISTS(SELECT * FROM SYS.TABLES WHERE name = 'RDSCertificates') +CREATE TABLE [dbo].[RDSCertificates]( + [ID] [int] IDENTITY(1,1) NOT NULL, + [ServiceId] [int] NOT NULL, + [Content] [ntext] NOT NULL, + [Hash] [nvarchar](255) NOT NULL, + [FileName] [nvarchar](255) NOT NULL, + [ValidFrom] [datetime] NULL, + [ExpiryDate] [datetime] NULL + CONSTRAINT [PK_RDSCertificates] PRIMARY KEY CLUSTERED +( + [ID] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] +) ON [PRIMARY] + +GO + +IF EXISTS (SELECT * FROM sys.objects WHERE type = 'F' AND name = 'FK_RDSCollectionUsers_RDSCollectionId') +BEGIN + ALTER TABLE [dbo].[RDSCollectionUsers] + DROP CONSTRAINT [FK_RDSCollectionUsers_RDSCollectionId] +END +ELSE + PRINT 'FK_RDSCollectionUsers_RDSCollectionId not EXISTS' +GO + +IF EXISTS (SELECT * FROM sys.objects WHERE type = 'F' AND name = 'FK_RDSCollectionUsers_UserId') +BEGIN + ALTER TABLE [dbo].[RDSCollectionUsers] + DROP CONSTRAINT [FK_RDSCollectionUsers_UserId] +END +ELSE + PRINT 'FK_RDSCollectionUsers_UserId not EXISTS' +GO + + +IF EXISTS (SELECT * FROM sys.objects WHERE type = 'F' AND name = 'FK_RDSServers_RDSCollectionId') +BEGIN + ALTER TABLE [dbo].[RDSServers] + DROP CONSTRAINT [FK_RDSServers_RDSCollectionId] +END +ELSE + PRINT 'FK_RDSServers_RDSCollectionId not EXISTS' +GO + +ALTER TABLE [dbo].[RDSCollectionUsers] WITH CHECK ADD CONSTRAINT [FK_RDSCollectionUsers_RDSCollectionId] FOREIGN KEY([RDSCollectionId]) +REFERENCES [dbo].[RDSCollections] ([ID]) +ON DELETE CASCADE +GO + + +ALTER TABLE [dbo].[RDSCollectionUsers] WITH CHECK ADD CONSTRAINT [FK_RDSCollectionUsers_UserId] FOREIGN KEY([AccountID]) +REFERENCES [dbo].[ExchangeAccounts] ([AccountID]) +ON DELETE CASCADE +GO + +ALTER TABLE [dbo].[RDSServers] WITH CHECK ADD CONSTRAINT [FK_RDSServers_RDSCollectionId] FOREIGN KEY([RDSCollectionId]) +REFERENCES [dbo].[RDSCollections] ([ID]) +GO + +IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS WHERE CONSTRAINT_NAME ='FK_RDSCollectionSettings_RDSCollections') +ALTER TABLE [dbo].[RDSCollectionSettings] WITH CHECK ADD CONSTRAINT [FK_RDSCollectionSettings_RDSCollections] FOREIGN KEY([RDSCollectionId]) +REFERENCES [dbo].[RDSCollections] ([ID]) +ON DELETE CASCADE +GO + +ALTER TABLE [dbo].[RDSCollectionSettings] CHECK CONSTRAINT [FK_RDSCollectionSettings_RDSCollections] +GO + +/*Remote Desktop Services Procedures*/ + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'AddRDSCertificate') +DROP PROCEDURE AddRDSCertificate +GO +CREATE PROCEDURE [dbo].[AddRDSCertificate] +( + @RDSCertificateId INT OUTPUT, + @ServiceId INT, + @Content NTEXT, + @Hash NVARCHAR(255), + @FileName NVARCHAR(255), + @ValidFrom DATETIME, + @ExpiryDate DATETIME +) +AS +INSERT INTO RDSCertificates +( + ServiceId, + Content, + Hash, + FileName, + ValidFrom, + ExpiryDate +) +VALUES +( + @ServiceId, + @Content, + @Hash, + @FileName, + @ValidFrom, + @ExpiryDate +) + +SET @RDSCertificateId = SCOPE_IDENTITY() + +RETURN +GO + + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'GetRDSCertificateByServiceId') +DROP PROCEDURE GetRDSCertificateByServiceId +GO +CREATE PROCEDURE [dbo].[GetRDSCertificateByServiceId] +( + @ServiceId INT +) +AS +SELECT TOP 1 + Id, + ServiceId, + Content, + Hash, + FileName, + ValidFrom, + ExpiryDate + FROM RDSCertificates + WHERE ServiceId = @ServiceId + ORDER BY Id DESC +GO + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'AddRDSServer') +DROP PROCEDURE AddRDSServer +GO +CREATE PROCEDURE [dbo].[AddRDSServer] +( + @RDSServerID INT OUTPUT, + @Name NVARCHAR(255), + @FqdName NVARCHAR(255), + @Description NVARCHAR(255) +) +AS +INSERT INTO RDSServers +( + Name, + FqdName, + Description +) +VALUES +( + @Name, + @FqdName, + @Description +) + +SET @RDSServerID = SCOPE_IDENTITY() + +RETURN +GO + + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'DeleteRDSServer') +DROP PROCEDURE DeleteRDSServer +GO +CREATE PROCEDURE [dbo].[DeleteRDSServer] +( + @Id int +) +AS +DELETE FROM RDSServers +WHERE Id = @Id +GO + + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'AddRDSServerToOrganization') +DROP PROCEDURE AddRDSServerToOrganization +GO +CREATE PROCEDURE [dbo].[AddRDSServerToOrganization] +( + @Id INT, + @ItemID INT +) +AS + +UPDATE RDSServers +SET + ItemID = @ItemID +WHERE ID = @Id +GO + + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'RemoveRDSServerFromOrganization') +DROP PROCEDURE RemoveRDSServerFromOrganization +GO +CREATE PROCEDURE [dbo].[RemoveRDSServerFromOrganization] +( + @Id INT +) +AS + +UPDATE RDSServers +SET + ItemID = NULL +WHERE ID = @Id +GO + + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'AddRDSServerToCollection') +DROP PROCEDURE AddRDSServerToCollection +GO +CREATE PROCEDURE [dbo].[AddRDSServerToCollection] +( + @Id INT, + @RDSCollectionId INT +) +AS + +UPDATE RDSServers +SET + RDSCollectionId = @RDSCollectionId +WHERE ID = @Id +GO + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'RemoveRDSServerFromCollection') +DROP PROCEDURE RemoveRDSServerFromCollection +GO +CREATE PROCEDURE [dbo].[RemoveRDSServerFromCollection] +( + @Id INT +) +AS + +UPDATE RDSServers +SET + RDSCollectionId = NULL +WHERE ID = @Id +GO + + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'GetRDSServersByItemId') +DROP PROCEDURE GetRDSServersByItemId +GO +CREATE PROCEDURE [dbo].[GetRDSServersByItemId] +( + @ItemID INT +) +AS +SELECT + RS.Id, + RS.ItemID, + RS.Name, + RS.FqdName, + RS.Description, + RS.RdsCollectionId, + SI.ItemName + FROM RDSServers AS RS + LEFT OUTER JOIN ServiceItems AS SI ON SI.ItemId = RS.ItemId + WHERE RS.ItemID = @ItemID +GO + + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'GetRDSServers') +DROP PROCEDURE GetRDSServers +GO +CREATE PROCEDURE [dbo].[GetRDSServers] +AS +SELECT + RS.Id, + RS.ItemID, + RS.Name, + RS.FqdName, + RS.Description, + RS.RdsCollectionId, + SI.ItemName + FROM RDSServers AS RS + LEFT OUTER JOIN ServiceItems AS SI ON SI.ItemId = RS.ItemId +GO + + + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'GetRDSServerById') +DROP PROCEDURE GetRDSServerById +GO +CREATE PROCEDURE [dbo].[GetRDSServerById] +( + @ID INT +) +AS +SELECT TOP 1 + RS.Id, + RS.ItemID, + RS.Name, + RS.FqdName, + RS.Description, + RS.RdsCollectionId, + SI.ItemName + FROM RDSServers AS RS + LEFT OUTER JOIN ServiceItems AS SI ON SI.ItemId = RS.ItemId + WHERE Id = @Id +GO + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'GetRDSServersByCollectionId') +DROP PROCEDURE GetRDSServersByCollectionId +GO +CREATE PROCEDURE [dbo].[GetRDSServersByCollectionId] +( + @RdsCollectionId INT +) +AS +SELECT + RS.Id, + RS.ItemID, + RS.Name, + RS.FqdName, + RS.Description, + RS.RdsCollectionId, + SI.ItemName + FROM RDSServers AS RS + LEFT OUTER JOIN ServiceItems AS SI ON SI.ItemId = RS.ItemId + WHERE RdsCollectionId = @RdsCollectionId +GO + + + + +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + + + + + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'GetRDSCollectionsPaged') +DROP PROCEDURE GetRDSCollectionsPaged +GO +CREATE PROCEDURE [dbo].[GetRDSCollectionsPaged] +( + @FilterColumn nvarchar(50) = '', + @FilterValue nvarchar(50) = '', + @ItemID int, + @SortColumn nvarchar(50), + @StartRow int, + @MaximumRows int +) +AS +-- build query and run it to the temporary table +DECLARE @sql nvarchar(2000) + +SET @sql = ' + +DECLARE @EndRow int +SET @EndRow = @StartRow + @MaximumRows +DECLARE @RDSCollections TABLE +( + ItemPosition int IDENTITY(0,1), + RDSCollectionId int +) +INSERT INTO @RDSCollections (RDSCollectionId) +SELECT + S.ID +FROM RDSCollections AS S +WHERE + ((@ItemID is Null AND S.ItemID is null) + or (@ItemID is not Null AND S.ItemID = @ItemID))' + +IF @FilterColumn <> '' AND @FilterValue <> '' +SET @sql = @sql + ' AND ' + @FilterColumn + ' LIKE @FilterValue ' + +IF @SortColumn <> '' AND @SortColumn IS NOT NULL +SET @sql = @sql + ' ORDER BY ' + @SortColumn + ' ' + +SET @sql = @sql + ' SELECT COUNT(RDSCollectionId) FROM @RDSCollections; +SELECT + CR.ID, + CR.ItemID, + CR.Name, + CR.Description, + CR.DisplayName +FROM @RDSCollections AS C +INNER JOIN RDSCollections AS CR ON C.RDSCollectionId = CR.ID +WHERE C.ItemPosition BETWEEN @StartRow AND @EndRow' + +exec sp_executesql @sql, N'@StartRow int, @MaximumRows int, @FilterValue nvarchar(50), @ItemID int', +@StartRow, @MaximumRows, @FilterValue, @ItemID + + +RETURN + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + + + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'GetRDSCollectionsByItemId') +DROP PROCEDURE GetRDSCollectionsByItemId +GO +CREATE PROCEDURE [dbo].[GetRDSCollectionsByItemId] +( + @ItemID INT +) +AS +SELECT + Id, + ItemId, + Name, + Description, + DisplayName + FROM RDSCollections + WHERE ItemID = @ItemID +GO + + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'GetRDSCollectionByName') +DROP PROCEDURE GetRDSCollectionByName +GO +CREATE PROCEDURE [dbo].[GetRDSCollectionByName] +( + @Name NVARCHAR(255) +) +AS + +SELECT TOP 1 + Id, + Name, + ItemId, + Description, + DisplayName + FROM RDSCollections + WHERE DisplayName = @Name +GO + + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'GetRDSCollectionById') +DROP PROCEDURE GetRDSCollectionById +GO +CREATE PROCEDURE [dbo].[GetRDSCollectionById] +( + @ID INT +) +AS + +SELECT TOP 1 + Id, + ItemId, + Name, + Description, + DisplayName + FROM RDSCollections + WHERE ID = @ID +GO + + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'AddRDSCollection') +DROP PROCEDURE AddRDSCollection +GO +CREATE PROCEDURE [dbo].[AddRDSCollection] +( + @RDSCollectionID INT OUTPUT, + @ItemID INT, + @Name NVARCHAR(255), + @Description NVARCHAR(255), + @DisplayName NVARCHAR(255) +) +AS + +INSERT INTO RDSCollections +( + ItemID, + Name, + Description, + DisplayName +) +VALUES +( + @ItemID, + @Name, + @Description, + @DisplayName +) + +SET @RDSCollectionID = SCOPE_IDENTITY() + +RETURN +GO + + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'UpdateRDSCollection') +DROP PROCEDURE UpdateRDSCollection +GO +CREATE PROCEDURE [dbo].[UpdateRDSCollection] +( + @ID INT, + @ItemID INT, + @Name NVARCHAR(255), + @Description NVARCHAR(255), + @DisplayName NVARCHAR(255) +) +AS + +UPDATE RDSCollections +SET + ItemID = @ItemID, + Name = @Name, + Description = @Description, + DisplayName = @DisplayName +WHERE ID = @Id +GO + + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'DeleteRDSCollection') +DROP PROCEDURE DeleteRDSCollection +GO +CREATE PROCEDURE [dbo].[DeleteRDSCollection] +( + @Id int +) +AS + +UPDATE RDSServers +SET + RDSCollectionId = Null +WHERE RDSCollectionId = @Id + +DELETE FROM RDSCollections +WHERE Id = @Id +GO + + +-- Password column removed +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'GetRDSCollectionUsersByRDSCollectionId') +DROP PROCEDURE GetRDSCollectionUsersByRDSCollectionId +GO +CREATE PROCEDURE [dbo].[GetRDSCollectionUsersByRDSCollectionId] +( + @ID INT +) +AS +SELECT + [AccountID], + [ItemID], + [AccountType], + [AccountName], + [DisplayName], + [PrimaryEmailAddress], + [MailEnabledPublicFolder], + [MailboxManagerActions], + [SamAccountName], + [CreatedDate], + [MailboxPlanId], + [SubscriberNumber], + [UserPrincipalName], + [ExchangeDisclaimerId], + [ArchivingMailboxPlanId], + [EnableArchiving], + [LevelID], + [IsVIP] + FROM ExchangeAccounts + WHERE AccountID IN (Select AccountId from RDSCollectionUsers where RDSCollectionId = @Id) +GO + + + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'AddUserToRDSCollection') +DROP PROCEDURE AddUserToRDSCollection +GO +CREATE PROCEDURE [dbo].[AddUserToRDSCollection] +( + @RDSCollectionID INT, + @AccountId INT +) +AS + +INSERT INTO RDSCollectionUsers +( + RDSCollectionId, + AccountID +) +VALUES +( + @RDSCollectionID, + @AccountId +) +GO + + + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'RemoveRDSUserFromRDSCollection') +DROP PROCEDURE RemoveRDSUserFromRDSCollection +GO +CREATE PROCEDURE [dbo].[RemoveRDSUserFromRDSCollection] +( + @AccountId INT, + @RDSCollectionId INT +) +AS + + +DELETE FROM RDSCollectionUsers +WHERE AccountId = @AccountId AND RDSCollectionId = @RDSCollectionId +GO + + + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'GetOrganizationRdsUsersCount') +DROP PROCEDURE GetOrganizationRdsUsersCount +GO +CREATE PROCEDURE [dbo].GetOrganizationRdsUsersCount +( + @ItemID INT, + @TotalNumber int OUTPUT +) +AS +SELECT + @TotalNumber = Count(DISTINCT([AccountId])) + FROM [dbo].[RDSCollectionUsers] + WHERE [RDSCollectionId] in (SELECT [ID] FROM [RDSCollections] where [ItemId] = @ItemId ) +RETURN +GO + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'GetOrganizationRdsCollectionsCount') +DROP PROCEDURE GetOrganizationRdsCollectionsCount +GO +CREATE PROCEDURE [dbo].GetOrganizationRdsCollectionsCount +( + @ItemID INT, + @TotalNumber int OUTPUT +) +AS +SELECT + @TotalNumber = Count([Id]) + FROM [dbo].[RDSCollections] WHERE [ItemId] = @ItemId +RETURN +GO + + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'GetOrganizationRdsServersCount') +DROP PROCEDURE GetOrganizationRdsServersCount +GO +CREATE PROCEDURE [dbo].GetOrganizationRdsServersCount +( + @ItemID INT, + @TotalNumber int OUTPUT +) +AS +SELECT + @TotalNumber = Count([Id]) + FROM [dbo].[RDSServers] WHERE [ItemId] = @ItemId +RETURN +GO + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'GetRDSCollectionSettingsByCollectionId') +DROP PROCEDURE GetRDSCollectionSettingsByCollectionId +GO +CREATE PROCEDURE [dbo].[GetRDSCollectionSettingsByCollectionId] +( + @RDSCollectionID INT +) +AS + +SELECT TOP 1 + Id, + RDSCollectionId, + DisconnectedSessionLimitMin, + ActiveSessionLimitMin, + IdleSessionLimitMin, + BrokenConnectionAction, + AutomaticReconnectionEnabled, + TemporaryFoldersDeletedOnExit, + TemporaryFoldersPerSession, + ClientDeviceRedirectionOptions, + ClientPrinterRedirected, + ClientPrinterAsDefault, + RDEasyPrintDriverEnabled, + MaxRedirectedMonitors + FROM RDSCollectionSettings + WHERE RDSCollectionID = @RDSCollectionID +GO + + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'AddRDSCollectionSettings') +DROP PROCEDURE AddRDSCollectionSettings +GO +CREATE PROCEDURE [dbo].[AddRDSCollectionSettings] +( + @RDSCollectionSettingsID INT OUTPUT, + @RDSCollectionId INT, + @DisconnectedSessionLimitMin INT, + @ActiveSessionLimitMin INT, + @IdleSessionLimitMin INT, + @BrokenConnectionAction NVARCHAR(20), + @AutomaticReconnectionEnabled BIT, + @TemporaryFoldersDeletedOnExit BIT, + @TemporaryFoldersPerSession BIT, + @ClientDeviceRedirectionOptions NVARCHAR(250), + @ClientPrinterRedirected BIT, + @ClientPrinterAsDefault BIT, + @RDEasyPrintDriverEnabled BIT, + @MaxRedirectedMonitors INT +) +AS + +INSERT INTO RDSCollectionSettings +( + RDSCollectionId, + DisconnectedSessionLimitMin, + ActiveSessionLimitMin, + IdleSessionLimitMin, + BrokenConnectionAction, + AutomaticReconnectionEnabled, + TemporaryFoldersDeletedOnExit, + TemporaryFoldersPerSession, + ClientDeviceRedirectionOptions, + ClientPrinterRedirected, + ClientPrinterAsDefault, + RDEasyPrintDriverEnabled, + MaxRedirectedMonitors +) +VALUES +( + @RDSCollectionId, + @DisconnectedSessionLimitMin, + @ActiveSessionLimitMin, + @IdleSessionLimitMin, + @BrokenConnectionAction, + @AutomaticReconnectionEnabled, + @TemporaryFoldersDeletedOnExit, + @TemporaryFoldersPerSession, + @ClientDeviceRedirectionOptions, + @ClientPrinterRedirected, + @ClientPrinterAsDefault, + @RDEasyPrintDriverEnabled, + @MaxRedirectedMonitors +) + +SET @RDSCollectionSettingsID = SCOPE_IDENTITY() + +RETURN +GO + + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'UpdateRDSCollectionSettings') +DROP PROCEDURE UpdateRDSCollectionSettings +GO +CREATE PROCEDURE [dbo].[UpdateRDSCollectionSettings] +( + @ID INT, + @RDSCollectionId INT, + @DisconnectedSessionLimitMin INT, + @ActiveSessionLimitMin INT, + @IdleSessionLimitMin INT, + @BrokenConnectionAction NVARCHAR(20), + @AutomaticReconnectionEnabled BIT, + @TemporaryFoldersDeletedOnExit BIT, + @TemporaryFoldersPerSession BIT, + @ClientDeviceRedirectionOptions NVARCHAR(250), + @ClientPrinterRedirected BIT, + @ClientPrinterAsDefault BIT, + @RDEasyPrintDriverEnabled BIT, + @MaxRedirectedMonitors INT +) +AS + +UPDATE RDSCollectionSettings +SET + RDSCollectionId = @RDSCollectionId, + DisconnectedSessionLimitMin = @DisconnectedSessionLimitMin, + ActiveSessionLimitMin = @ActiveSessionLimitMin, + IdleSessionLimitMin = @IdleSessionLimitMin, + BrokenConnectionAction = @BrokenConnectionAction, + AutomaticReconnectionEnabled = @AutomaticReconnectionEnabled, + TemporaryFoldersDeletedOnExit = @TemporaryFoldersDeletedOnExit, + TemporaryFoldersPerSession = @TemporaryFoldersPerSession, + ClientDeviceRedirectionOptions = @ClientDeviceRedirectionOptions, + ClientPrinterRedirected = @ClientPrinterRedirected, + ClientPrinterAsDefault = @ClientPrinterAsDefault, + RDEasyPrintDriverEnabled = @RDEasyPrintDriverEnabled, + MaxRedirectedMonitors = @MaxRedirectedMonitors +WHERE ID = @Id +GO + + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'DeleteRDSCollectionSettings') +DROP PROCEDURE DeleteRDSCollectionSettings +GO +CREATE PROCEDURE [dbo].[DeleteRDSCollectionSettings] +( + @Id int +) +AS + +DELETE FROM DeleteRDSCollectionSettings +WHERE Id = @Id +GO + +-- wsp-10269: Changed php extension path in default properties for IIS70 and IIS80 provider +update ServiceDefaultProperties +set PropertyValue='%PROGRAMFILES(x86)%\PHP\php-cgi.exe' +where PropertyName='PhpPath' and ProviderId in(101, 105) + +update ServiceDefaultProperties +set PropertyValue='%PROGRAMFILES(x86)%\PHP\php.exe' +where PropertyName='Php4Path' and ProviderId in(101, 105) + +GO + +-- Exchange2013 Shared and resource mailboxes + +-- Exchange2013 Shared and resource mailboxes Quotas + +IF NOT EXISTS (SELECT * FROM [dbo].[Quotas] WHERE [QuotaName] = 'Exchange2013.SharedMailboxes') +BEGIN +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) +VALUES (429, 12, 30, N'Exchange2013.SharedMailboxes', N'Shared Mailboxes per Organization', 2, 0, NULL, NULL) +END +GO + +IF NOT EXISTS (SELECT * FROM [dbo].[Quotas] WHERE [QuotaName] = 'Exchange2013.ResourceMailboxes') +BEGIN +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) +VALUES (428, 12, 31, N'Exchange2013.ResourceMailboxes', N'Resource Mailboxes per Organization', 2, 0, NULL, NULL) +END +GO + +-- Exchange2013 Shared and resource mailboxes Organization statistics + +ALTER PROCEDURE [dbo].[GetExchangeOrganizationStatistics] +( + @ItemID int +) +AS + +DECLARE @ARCHIVESIZE INT +IF -1 in (SELECT B.ArchiveSizeMB FROM ExchangeAccounts AS A INNER JOIN ExchangeMailboxPlans AS B ON A.MailboxPlanId = B.MailboxPlanId WHERE A.ItemID=@ItemID) +BEGIN + SET @ARCHIVESIZE = -1 +END +ELSE +BEGIN + SET @ARCHIVESIZE = (SELECT SUM(B.ArchiveSizeMB) FROM ExchangeAccounts AS A INNER JOIN ExchangeMailboxPlans AS B ON A.MailboxPlanId = B.MailboxPlanId WHERE A.ItemID=@ItemID) +END + +IF -1 IN (SELECT B.MailboxSizeMB FROM ExchangeAccounts AS A INNER JOIN ExchangeMailboxPlans AS B ON A.MailboxPlanId = B.MailboxPlanId WHERE A.ItemID=@ItemID) +BEGIN +SELECT + (SELECT COUNT(*) FROM ExchangeAccounts WHERE (AccountType = 1) AND ItemID = @ItemID) AS CreatedMailboxes, + (SELECT COUNT(*) FROM ExchangeAccounts WHERE (AccountType = 10) AND ItemID = @ItemID) AS CreatedSharedMailboxes, + (SELECT COUNT(*) FROM ExchangeAccounts WHERE (AccountType = 5 OR AccountType = 6) AND ItemID = @ItemID) AS CreatedResourceMailboxes, + (SELECT COUNT(*) FROM ExchangeAccounts WHERE AccountType = 2 AND ItemID = @ItemID) AS CreatedContacts, + (SELECT COUNT(*) FROM ExchangeAccounts WHERE AccountType = 3 AND ItemID = @ItemID) AS CreatedDistributionLists, + (SELECT COUNT(*) FROM ExchangeAccounts WHERE AccountType = 4 AND ItemID = @ItemID) AS CreatedPublicFolders, + (SELECT COUNT(*) FROM ExchangeOrganizationDomains WHERE ItemID = @ItemID) AS CreatedDomains, + (SELECT MIN(B.MailboxSizeMB) FROM ExchangeAccounts AS A INNER JOIN ExchangeMailboxPlans AS B ON A.MailboxPlanId = B.MailboxPlanId WHERE A.ItemID=@ItemID) AS UsedDiskSpace, + (SELECT MIN(B.RecoverableItemsSpace) FROM ExchangeAccounts AS A INNER JOIN ExchangeMailboxPlans AS B ON A.MailboxPlanId = B.MailboxPlanId WHERE A.ItemID=@ItemID) AS UsedLitigationHoldSpace, + @ARCHIVESIZE AS UsedArchingStorage +END +ELSE +BEGIN +SELECT + (SELECT COUNT(*) FROM ExchangeAccounts WHERE (AccountType = 1) AND ItemID = @ItemID) AS CreatedMailboxes, + (SELECT COUNT(*) FROM ExchangeAccounts WHERE (AccountType = 10) AND ItemID = @ItemID) AS CreatedSharedMailboxes, + (SELECT COUNT(*) FROM ExchangeAccounts WHERE (AccountType = 5 OR AccountType = 6) AND ItemID = @ItemID) AS CreatedResourceMailboxes, + (SELECT COUNT(*) FROM ExchangeAccounts WHERE AccountType = 2 AND ItemID = @ItemID) AS CreatedContacts, + (SELECT COUNT(*) FROM ExchangeAccounts WHERE AccountType = 3 AND ItemID = @ItemID) AS CreatedDistributionLists, + (SELECT COUNT(*) FROM ExchangeAccounts WHERE AccountType = 4 AND ItemID = @ItemID) AS CreatedPublicFolders, + (SELECT COUNT(*) FROM ExchangeOrganizationDomains WHERE ItemID = @ItemID) AS CreatedDomains, + (SELECT SUM(B.MailboxSizeMB) FROM ExchangeAccounts AS A INNER JOIN ExchangeMailboxPlans AS B ON A.MailboxPlanId = B.MailboxPlanId WHERE A.ItemID=@ItemID) AS UsedDiskSpace, + (SELECT SUM(B.RecoverableItemsSpace) FROM ExchangeAccounts AS A INNER JOIN ExchangeMailboxPlans AS B ON A.MailboxPlanId = B.MailboxPlanId WHERE A.ItemID=@ItemID) AS UsedLitigationHoldSpace, + @ARCHIVESIZE AS UsedArchingStorage +END + + +RETURN +GO + +-- wsp-10053: IDN, return ZoneName also from GetDomainsPaged (already exists in other GetDomain-sps) +ALTER PROCEDURE [dbo].[GetDomainsPaged] +( + @ActorID int, + @PackageID int, + @ServerID int, + @Recursive bit, + @FilterColumn nvarchar(50) = '', + @FilterValue nvarchar(50) = '', + @SortColumn nvarchar(50), + @StartRow int, + @MaximumRows int +) +AS +SET NOCOUNT ON + +-- check rights +IF dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 +RAISERROR('You are not allowed to access this package', 16, 1) + +-- build query and run it to the temporary table +DECLARE @sql nvarchar(4000) + +IF @SortColumn = '' OR @SortColumn IS NULL +SET @SortColumn = 'DomainName' + +SET @sql = ' +DECLARE @Domains TABLE +( + ItemPosition int IDENTITY(1,1), + DomainID int +) +INSERT INTO @Domains (DomainID) +SELECT + D.DomainID +FROM Domains AS D +INNER JOIN Packages AS P ON D.PackageID = P.PackageID +INNER JOIN UsersDetailed AS U ON P.UserID = U.UserID +LEFT OUTER JOIN ServiceItems AS Z ON D.ZoneItemID = Z.ItemID +LEFT OUTER JOIN Services AS S ON Z.ServiceID = S.ServiceID +LEFT OUTER JOIN Servers AS SRV ON S.ServerID = SRV.ServerID +WHERE (D.IsInstantAlias = 0 AND D.IsDomainPointer = 0) AND + ((@Recursive = 0 AND D.PackageID = @PackageID) + OR (@Recursive = 1 AND dbo.CheckPackageParent(@PackageID, D.PackageID) = 1)) +AND (@ServerID = 0 OR (@ServerID > 0 AND S.ServerID = @ServerID)) +' + +IF @FilterColumn <> '' AND @FilterValue <> '' +SET @sql = @sql + ' AND ' + @FilterColumn + ' LIKE @FilterValue ' + +IF @SortColumn <> '' AND @SortColumn IS NOT NULL +SET @sql = @sql + ' ORDER BY ' + @SortColumn + ' ' + +SET @sql = @sql + ' SELECT COUNT(DomainID) FROM @Domains;SELECT + D.DomainID, + D.PackageID, + D.ZoneItemID, + D.DomainItemID, + D.DomainName, + D.HostingAllowed, + ISNULL(WS.ItemID, 0) AS WebSiteID, + WS.ItemName AS WebSiteName, + ISNULL(MD.ItemID, 0) AS MailDomainID, + MD.ItemName AS MailDomainName, + Z.ItemName AS ZoneName, + D.IsSubDomain, + D.IsInstantAlias, + D.IsDomainPointer, + + -- packages + P.PackageName, + + -- server + ISNULL(SRV.ServerID, 0) AS ServerID, + ISNULL(SRV.ServerName, '''') AS ServerName, + ISNULL(SRV.Comments, '''') AS ServerComments, + ISNULL(SRV.VirtualServer, 0) AS VirtualServer, + + -- user + P.UserID, + U.Username, + U.FirstName, + U.LastName, + U.FullName, + U.RoleID, + U.Email +FROM @Domains AS SD +INNER JOIN Domains AS D ON SD.DomainID = D.DomainID +INNER JOIN Packages AS P ON D.PackageID = P.PackageID +INNER JOIN UsersDetailed AS U ON P.UserID = U.UserID +LEFT OUTER JOIN ServiceItems AS WS ON D.WebSiteID = WS.ItemID +LEFT OUTER JOIN ServiceItems AS MD ON D.MailDomainID = MD.ItemID +LEFT OUTER JOIN ServiceItems AS Z ON D.ZoneItemID = Z.ItemID +LEFT OUTER JOIN Services AS S ON Z.ServiceID = S.ServiceID +LEFT OUTER JOIN Servers AS SRV ON S.ServerID = SRV.ServerID +WHERE SD.ItemPosition BETWEEN @StartRow + 1 AND @StartRow + @MaximumRows' + +exec sp_executesql @sql, N'@StartRow int, @MaximumRows int, @PackageID int, @FilterValue nvarchar(50), @ServerID int, @Recursive bit', +@StartRow, @MaximumRows, @PackageID, @FilterValue, @ServerID, @Recursive + + +RETURN + +GO + + +-- Domain lookup tasks + +IF NOT EXISTS (SELECT * FROM [dbo].[ScheduleTasks] WHERE [TaskID] = N'SCHEDULE_TASK_DOMAIN_LOOKUP') +BEGIN +INSERT [dbo].[ScheduleTasks] ([TaskID], [TaskType], [RoleID]) VALUES (N'SCHEDULE_TASK_DOMAIN_LOOKUP', N'WebsitePanel.EnterpriseServer.DomainLookupViewTask, WebsitePanel.EnterpriseServer.Code', 1) +END +GO + +IF NOT EXISTS (SELECT * FROM [dbo].[ScheduleTaskViewConfiguration] WHERE [TaskID] = N'SCHEDULE_TASK_DOMAIN_LOOKUP') +BEGIN +INSERT [dbo].[ScheduleTaskViewConfiguration] ([TaskID], [ConfigurationID], [Environment], [Description]) VALUES (N'SCHEDULE_TASK_DOMAIN_LOOKUP', N'ASP_NET', N'ASP.NET', N'~/DesktopModules/WebsitePanel/ScheduleTaskControls/DomainLookupView.ascx') +END +GO + +IF NOT EXISTS (SELECT * FROM [dbo].[ScheduleTaskParameters] WHERE [TaskID] = N'SCHEDULE_TASK_DOMAIN_LOOKUP' AND [ParameterID]= N'DNS_SERVERS' ) +BEGIN +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_DOMAIN_LOOKUP', N'DNS_SERVERS', N'String', NULL, 1) +END +GO + +IF NOT EXISTS (SELECT * FROM [dbo].[ScheduleTaskParameters] WHERE [TaskID] = N'SCHEDULE_TASK_DOMAIN_LOOKUP' AND [ParameterID]= N'MAIL_TO' ) +BEGIN +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_DOMAIN_LOOKUP', N'MAIL_TO', N'String', NULL, 2) +END +GO + +IF NOT EXISTS (SELECT * FROM [dbo].[ScheduleTaskParameters] WHERE [TaskID] = N'SCHEDULE_TASK_DOMAIN_LOOKUP' AND [ParameterID]= N'SERVER_NAME' ) +BEGIN +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_DOMAIN_LOOKUP', N'SERVER_NAME', N'String', N'', 3) +END +GO + +IF NOT EXISTS (SELECT * FROM [dbo].[ScheduleTaskParameters] WHERE [TaskID] = N'SCHEDULE_TASK_DOMAIN_LOOKUP' AND [ParameterID]= N'PAUSE_BETWEEN_QUERIES' ) +BEGIN +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_DOMAIN_LOOKUP', N'PAUSE_BETWEEN_QUERIES', N'String', N'100', 4) +END +GO + +IF EXISTS (SELECT * FROM [dbo].[ScheduleTaskParameters] WHERE [TaskID] = N'SCHEDULE_TASK_DOMAIN_LOOKUP' AND [ParameterID]= N'SERVER_NAME' ) +BEGIN +UPDATE [dbo].[ScheduleTaskParameters] SET [DefaultValue] = N'' WHERE [TaskID] = N'SCHEDULE_TASK_DOMAIN_LOOKUP' AND [ParameterID]= N'SERVER_NAME' +END +GO + +-- Domain Expiration Task + + +IF NOT EXISTS (SELECT * FROM [dbo].[ScheduleTasks] WHERE [TaskID] = N'SCHEDULE_TASK_DOMAIN_EXPIRATION') +BEGIN +INSERT [dbo].[ScheduleTasks] ([TaskID], [TaskType], [RoleID]) VALUES (N'SCHEDULE_TASK_DOMAIN_EXPIRATION', N'WebsitePanel.EnterpriseServer.DomainExpirationTask, WebsitePanel.EnterpriseServer.Code', 3) +END +GO + +IF EXISTS (SELECT * FROM [dbo].[ScheduleTasks] WHERE [TaskID] = N'SCHEDULE_TASK_DOMAIN_EXPIRATION' AND [RoleID] = 1) +BEGIN +UPDATE [dbo].[ScheduleTasks] SET [RoleID] = 3 WHERE [TaskID] = N'SCHEDULE_TASK_DOMAIN_EXPIRATION' +END +GO + + +IF NOT EXISTS (SELECT * FROM [dbo].[ScheduleTaskViewConfiguration] WHERE [TaskID] = N'SCHEDULE_TASK_DOMAIN_EXPIRATION') +BEGIN +INSERT [dbo].[ScheduleTaskViewConfiguration] ([TaskID], [ConfigurationID], [Environment], [Description]) VALUES (N'SCHEDULE_TASK_DOMAIN_EXPIRATION', N'ASP_NET', N'ASP.NET', N'~/DesktopModules/WebsitePanel/ScheduleTaskControls/DomainExpirationView.ascx') +END +GO + +IF NOT EXISTS (SELECT * FROM [dbo].[ScheduleTaskParameters] WHERE [TaskID] = N'SCHEDULE_TASK_DOMAIN_EXPIRATION' AND [ParameterID]= N'DAYS_BEFORE' ) +BEGIN +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_DOMAIN_EXPIRATION', N'DAYS_BEFORE', N'String', NULL, 1) +END +GO + +IF NOT EXISTS (SELECT * FROM [dbo].[ScheduleTaskParameters] WHERE [TaskID] = N'SCHEDULE_TASK_DOMAIN_EXPIRATION' AND [ParameterID]= N'MAIL_TO' ) +BEGIN +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_DOMAIN_EXPIRATION', N'MAIL_TO', N'String', NULL, 2) +END +GO + +IF NOT EXISTS (SELECT * FROM [dbo].[ScheduleTaskParameters] WHERE [TaskID] = N'SCHEDULE_TASK_DOMAIN_EXPIRATION' AND [ParameterID]= N'ENABLE_NOTIFICATION' ) +BEGIN +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_DOMAIN_EXPIRATION', N'ENABLE_NOTIFICATION', N'Boolean', N'false', 3) +END +GO + +IF NOT EXISTS (SELECT * FROM [dbo].[ScheduleTaskParameters] WHERE [TaskID] = N'SCHEDULE_TASK_DOMAIN_EXPIRATION' AND [ParameterID]= N'INCLUDE_NONEXISTEN_DOMAINS' ) +BEGIN +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_DOMAIN_EXPIRATION', N'INCLUDE_NONEXISTEN_DOMAINS', N'Boolean', N'false', 4) +END +GO + + +-- Domain lookup tables + +IF EXISTS (SELECT * FROM SYS.TABLES WHERE name = 'DomainDnsRecords') +DROP TABLE DomainDnsRecords +GO +CREATE TABLE DomainDnsRecords +( + ID INT IDENTITY(1,1) NOT NULL PRIMARY KEY, + DomainId INT NOT NULL, + RecordType INT NOT NULL, + DnsServer NVARCHAR(255), + Value NVARCHAR(255), + Date DATETIME +) +GO + +ALTER TABLE [dbo].[DomainDnsRecords] WITH CHECK ADD CONSTRAINT [FK_DomainDnsRecords_DomainId] FOREIGN KEY([DomainId]) +REFERENCES [dbo].[Domains] ([DomainID]) +ON DELETE CASCADE +GO + +IF NOT EXISTS(SELECT * FROM sys.columns + WHERE [name] = N'CreationDate' AND [object_id] = OBJECT_ID(N'Domains')) +BEGIN + ALTER TABLE [dbo].[Domains] ADD CreationDate DateTime null; +END +GO + +IF NOT EXISTS(SELECT * FROM sys.columns + WHERE [name] = N'ExpirationDate' AND [object_id] = OBJECT_ID(N'Domains')) +BEGIN + ALTER TABLE [dbo].[Domains] ADD ExpirationDate DateTime null; +END +GO + +IF NOT EXISTS(SELECT * FROM sys.columns + WHERE [name] = N'LastUpdateDate' AND [object_id] = OBJECT_ID(N'Domains')) +BEGIN + ALTER TABLE [dbo].[Domains] ADD LastUpdateDate DateTime null; +END +GO + +IF EXISTS (SELECT * FROM SYS.TABLES WHERE name = 'ScheduleTasksEmailTemplates') +DROP TABLE ScheduleTasksEmailTemplates +GO + +IF NOT EXISTS (SELECT * FROM [dbo].[UserSettings] WHERE [UserID] = 1 AND [SettingsName]= N'DomainExpirationLetter' AND [PropertyName]= N'CC' ) +BEGIN +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'DomainExpirationLetter', N'CC', N'support@HostingCompany.com') +END +GO +IF NOT EXISTS (SELECT * FROM [dbo].[UserSettings] WHERE [UserID] = 1 AND [SettingsName]= N'DomainExpirationLetter' AND [PropertyName]= N'From' ) +BEGIN +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'DomainExpirationLetter', N'From', N'support@HostingCompany.com') +END +GO + +DECLARE @DomainExpirationLetterHtmlBody nvarchar(2500) + +Set @DomainExpirationLetterHtmlBody = N' + + Domain Expiration Information + + + +
+ + +
+ Domain Expiration Information +
+ + +

+Hello #user.FirstName#, +

+
+ +

+Please, find below details of your domain expiration information. +

+ + + + + + + + + + + + + + + + + + + + +
DomainRegistrarCustomerExpiration Date
#Domain.DomainName##iif(isnull(Domain.Registrar), "", Domain.Registrar)##Domain.Customer##iif(isnull(Domain.ExpirationDate), "", Domain.ExpirationDate)#
+ + +

+ Please, find below details of your non-existen domains. +

+ + + + + + + + + + + + + + + + +
DomainCustomer
#Domain.DomainName##Domain.Customer#
+
+ + +

+If you have any questions regarding your hosting account, feel free to contact our support department at any time. +

+ +

+Best regards +

'; + +IF NOT EXISTS (SELECT * FROM [dbo].[UserSettings] WHERE [UserID] = 1 AND [SettingsName]= N'DomainExpirationLetter' AND [PropertyName]= N'HtmlBody' ) +BEGIN +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'DomainExpirationLetter', N'HtmlBody', @DomainExpirationLetterHtmlBody) +END +ELSE +UPDATE [dbo].[UserSettings] SET [PropertyValue] = @DomainExpirationLetterHtmlBody WHERE [UserID] = 1 AND [SettingsName]= N'DomainExpirationLetter' AND [PropertyName]= N'HtmlBody' +GO + + +IF NOT EXISTS (SELECT * FROM [dbo].[UserSettings] WHERE [UserID] = 1 AND [SettingsName]= N'DomainExpirationLetter' AND [PropertyName]= N'Priority' ) +BEGIN +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'DomainExpirationLetter', N'Priority', N'Normal') +END +GO +IF NOT EXISTS (SELECT * FROM [dbo].[UserSettings] WHERE [UserID] = 1 AND [SettingsName]= N'DomainExpirationLetter' AND [PropertyName]= N'Subject' ) +BEGIN +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'DomainExpirationLetter', N'Subject', N'Domain expiration notification') +END +GO + +DECLARE @DomainExpirationLetterTextBody nvarchar(2500) + +Set @DomainExpirationLetterTextBody = N'================================= + Domain Expiration Information +================================= + +Hello #user.FirstName#, + + +Please, find below details of your domain expiration information. + + + + Domain: #Domain.DomainName# + Registrar: #iif(isnull(Domain.Registrar), "", Domain.Registrar)# + Customer: #Domain.Customer# + Expiration Date: #iif(isnull(Domain.ExpirationDate), "", Domain.ExpirationDate)# + + + + +Please, find below details of your non-existen domains. + + + Domain: #Domain.DomainName# + Customer: #Domain.Customer# + + + + +If you have any questions regarding your hosting account, feel free to contact our support department at any time. + +Best regards' + +IF NOT EXISTS (SELECT * FROM [dbo].[UserSettings] WHERE [UserID] = 1 AND [SettingsName]= N'DomainExpirationLetter' AND [PropertyName]= N'TextBody' ) +BEGIN +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'DomainExpirationLetter', N'TextBody', @DomainExpirationLetterTextBody) +END +ELSE +UPDATE [dbo].[UserSettings] SET [PropertyValue] = @DomainExpirationLetterTextBody WHERE [UserID] = 1 AND [SettingsName]= N'DomainExpirationLetter' AND [PropertyName]= N'TextBody' +GO + + + + +IF NOT EXISTS (SELECT * FROM [dbo].[UserSettings] WHERE [UserID] = 1 AND [SettingsName]= N'DomainLookupLetter' AND [PropertyName]= N'CC' ) +BEGIN +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'DomainLookupLetter', N'CC', N'support@HostingCompany.com') +END +GO +IF NOT EXISTS (SELECT * FROM [dbo].[UserSettings] WHERE [UserID] = 1 AND [SettingsName]= N'DomainLookupLetter' AND [PropertyName]= N'From' ) +BEGIN +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'DomainLookupLetter', N'From', N'support@HostingCompany.com') +END +GO + +DECLARE @DomainLookupLetterHtmlBody nvarchar(2500) + +Set @DomainLookupLetterHtmlBody = N' + + MX and NS Changes Information + + + +
+ + +
+ MX and NS Changes Information +
+ + +

+Hello #user.FirstName#, +

+
+ +

+Please, find below details of MX and NS changes. +

+ + +

#Domain.DomainName# - #DomainUsers[Domain.PackageId].FirstName# #DomainUsers[Domain.PackageId].LastName#

+

#iif(isnull(Domain.Registrar), "", Domain.Registrar)# #iif(isnull(Domain.ExpirationDate), "", Domain.ExpirationDate)#

+ + + + + + + + + + + + + + + + + + + + + + +
DNSTypeStatusOld ValueNew Value
#DnsChange.DnsServer##DnsChange.Type##DnsChange.Status##DnsChange.OldRecord.Value##DnsChange.NewRecord.Value#
+ +
+ +

+If you have any questions regarding your hosting account, feel free to contact our support department at any time. +

+ +

+Best regards +

' + +IF NOT EXISTS (SELECT * FROM [dbo].[UserSettings] WHERE [UserID] = 1 AND [SettingsName]= N'DomainLookupLetter' AND [PropertyName]= N'HtmlBody' ) +BEGIN +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'DomainLookupLetter', N'HtmlBody', @DomainLookupLetterHtmlBody) +END +ELSE +UPDATE [dbo].[UserSettings] SET [PropertyValue] = @DomainLookupLetterHtmlBody WHERE [UserID] = 1 AND [SettingsName]= N'DomainLookupLetter' AND [PropertyName]= N'HtmlBody' +GO + + +IF NOT EXISTS (SELECT * FROM [dbo].[UserSettings] WHERE [UserID] = 1 AND [SettingsName]= N'DomainLookupLetter' AND [PropertyName]= N'Priority' ) +BEGIN +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'DomainLookupLetter', N'Priority', N'Normal') +END +GO +IF NOT EXISTS (SELECT * FROM [dbo].[UserSettings] WHERE [UserID] = 1 AND [SettingsName]= N'DomainLookupLetter' AND [PropertyName]= N'Subject' ) +BEGIN +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'DomainLookupLetter', N'Subject', N'MX and NS changes notification') +END +GO + +DECLARE @DomainLookupLetterTextBody nvarchar(2500) + +Set @DomainLookupLetterTextBody = N'================================= + MX and NS Changes Information +================================= + +Hello #user.FirstName#, + + +Please, find below details of MX and NS changes. + + + + + #Domain.DomainName# - #DomainUsers[Domain.PackageId].FirstName# #DomainUsers[Domain.PackageId].LastName# + Registrar: #iif(isnull(Domain.Registrar), "", Domain.Registrar)# + ExpirationDate: #iif(isnull(Domain.ExpirationDate), "", Domain.ExpirationDate)# + + + DNS: #DnsChange.DnsServer# + Type: #DnsChange.Type# + Status: #DnsChange.Status# + Old Value: #DnsChange.OldRecord.Value# + New Value: #DnsChange.NewRecord.Value# + + + + + + +If you have any questions regarding your hosting account, feel free to contact our support department at any time. + +Best regards +' + +IF NOT EXISTS (SELECT * FROM [dbo].[UserSettings] WHERE [UserID] = 1 AND [SettingsName]= N'DomainLookupLetter' AND [PropertyName]= N'TextBody' ) +BEGIN +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'DomainLookupLetter', N'TextBody',@DomainLookupLetterTextBody ) +END +ELSE +UPDATE [dbo].[UserSettings] SET [PropertyValue] = @DomainLookupLetterTextBody WHERE [UserID] = 1 AND [SettingsName]= N'DomainLookupLetter' AND [PropertyName]= N'TextBody' +GO + + + +IF NOT EXISTS (SELECT * FROM [dbo].[UserSettings] WHERE [UserID] = 1 AND [SettingsName]= N'DomainLookupLetter' AND [PropertyName]= N'NoChangesHtmlBody' ) +BEGIN +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'DomainLookupLetter', N'NoChangesHtmlBody', N' + + MX and NS Changes Information + + + +
+ + +
+ MX and NS Changes Information +
+ + +

+Hello #user.FirstName#, +

+
+ +

+No MX and NS changes have been found. +

+ +

+If you have any questions regarding your hosting account, feel free to contact our support department at any time. +

+ +

+Best regards +

') +END +GO +IF NOT EXISTS (SELECT * FROM [dbo].[UserSettings] WHERE [UserID] = 1 AND [SettingsName]= N'DomainLookupLetter' AND [PropertyName]= N'NoChangesTextBody' ) +BEGIN +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'DomainLookupLetter', N'NoChangesTextBody', N'================================= + MX and NS Changes Information +================================= + +Hello #user.FirstName#, + + +No MX and NS changes have been founded. + +If you have any questions regarding your hosting account, feel free to contact our support department at any time. + +Best regards +') +END +GO + + +-- Procedures for Domain lookup service + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'GetAllPackages') +DROP PROCEDURE GetAllPackages +GO +CREATE PROCEDURE [dbo].[GetAllPackages] +AS +SELECT + [PackageID] + ,[ParentPackageID] + ,[UserID] + ,[PackageName] + ,[PackageComments] + ,[ServerID] + ,[StatusID] + ,[PlanID] + ,[PurchaseDate] + ,[OverrideQuotas] + ,[BandwidthUpdated] + FROM [dbo].[Packages] +GO + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'GetScheduleTaskEmailTemplate') +DROP PROCEDURE GetScheduleTaskEmailTemplate +GO +CREATE PROCEDURE [dbo].GetScheduleTaskEmailTemplate +( + @TaskID [nvarchar](100) +) +AS +SELECT + [TaskID], + [From] , + [Subject] , + [Template] + FROM [dbo].[ScheduleTasksEmailTemplates] where [TaskID] = @TaskID +GO + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'GetDomainDnsRecords') +DROP PROCEDURE GetDomainDnsRecords +GO +CREATE PROCEDURE [dbo].GetDomainDnsRecords +( + @DomainId INT, + @RecordType INT +) +AS +SELECT + ID, + DomainId, + DnsServer, + RecordType, + Value, + Date + FROM [dbo].[DomainDnsRecords] + WHERE [DomainId] = @DomainId AND [RecordType] = @RecordType +GO + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'GetDomainAllDnsRecords') +DROP PROCEDURE GetDomainAllDnsRecords +GO +CREATE PROCEDURE [dbo].GetDomainAllDnsRecords +( + @DomainId INT +) +AS +SELECT + ID, + DomainId, + DnsServer, + RecordType, + Value, + Date + FROM [dbo].[DomainDnsRecords] + WHERE [DomainId] = @DomainId +GO + + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'AddDomainDnsRecord') +DROP PROCEDURE AddDomainDnsRecord +GO +CREATE PROCEDURE [dbo].[AddDomainDnsRecord] +( + @DomainId INT, + @RecordType INT, + @DnsServer NVARCHAR(255), + @Value NVARCHAR(255), + @Date DATETIME +) +AS + +INSERT INTO DomainDnsRecords +( + DomainId, + DnsServer, + RecordType, + Value, + Date +) +VALUES +( + @DomainId, + @DnsServer, + @RecordType, + @Value, + @Date +) +GO + + + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'DeleteDomainDnsRecord') +DROP PROCEDURE DeleteDomainDnsRecord +GO +CREATE PROCEDURE [dbo].[DeleteDomainDnsRecord] +( + @Id INT +) +AS +DELETE FROM DomainDnsRecords +WHERE Id = @Id +GO + +--Domain Expiration Stored Procedures + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'UpdateDomainCreationDate') +DROP PROCEDURE UpdateDomainCreationDate +GO +CREATE PROCEDURE [dbo].UpdateDomainCreationDate +( + @DomainId INT, + @Date DateTime +) +AS +UPDATE [dbo].[Domains] SET [CreationDate] = @Date WHERE [DomainID] = @DomainId +GO + + + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'UpdateDomainExpirationDate') +DROP PROCEDURE UpdateDomainExpirationDate +GO +CREATE PROCEDURE [dbo].UpdateDomainExpirationDate +( + @DomainId INT, + @Date DateTime +) +AS +UPDATE [dbo].[Domains] SET [ExpirationDate] = @Date WHERE [DomainID] = @DomainId +GO + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'UpdateDomainLastUpdateDate') +DROP PROCEDURE UpdateDomainLastUpdateDate +GO +CREATE PROCEDURE [dbo].UpdateDomainLastUpdateDate +( + @DomainId INT, + @Date DateTime +) +AS +UPDATE [dbo].[Domains] SET [LastUpdateDate] = @Date WHERE [DomainID] = @DomainId +GO + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'UpdateDomainDates') +DROP PROCEDURE UpdateDomainDates +GO +CREATE PROCEDURE [dbo].UpdateDomainDates +( + @DomainId INT, + @DomainCreationDate DateTime, + @DomainExpirationDate DateTime, + @DomainLastUpdateDate DateTime +) +AS +UPDATE [dbo].[Domains] SET [CreationDate] = @DomainCreationDate, [ExpirationDate] = @DomainExpirationDate, [LastUpdateDate] = @DomainLastUpdateDate WHERE [DomainID] = @DomainId +GO + + +--Updating Domain procedures + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'GetDomains') +DROP PROCEDURE GetDomains +GO +CREATE PROCEDURE [dbo].[GetDomains] +( + @ActorID int, + @PackageID int, + @Recursive bit = 1 +) +AS + +-- check rights +IF dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 +RAISERROR('You are not allowed to access this package', 16, 1) + +SELECT + D.DomainID, + D.PackageID, + D.ZoneItemID, + D.DomainItemID, + D.DomainName, + D.HostingAllowed, + ISNULL(WS.ItemID, 0) AS WebSiteID, + WS.ItemName AS WebSiteName, + ISNULL(MD.ItemID, 0) AS MailDomainID, + MD.ItemName AS MailDomainName, + Z.ItemName AS ZoneName, + D.IsSubDomain, + D.IsInstantAlias, + D.CreationDate, + D.ExpirationDate, + D.LastUpdateDate, + D.IsDomainPointer +FROM Domains AS D +INNER JOIN PackagesTree(@PackageID, @Recursive) AS PT ON D.PackageID = PT.PackageID +LEFT OUTER JOIN ServiceItems AS WS ON D.WebSiteID = WS.ItemID +LEFT OUTER JOIN ServiceItems AS MD ON D.MailDomainID = MD.ItemID +LEFT OUTER JOIN ServiceItems AS Z ON D.ZoneItemID = Z.ItemID +RETURN + +GO + + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'GetDomainsPaged') +DROP PROCEDURE GetDomainsPaged +GO +CREATE PROCEDURE [dbo].[GetDomainsPaged] +( + @ActorID int, + @PackageID int, + @ServerID int, + @Recursive bit, + @FilterColumn nvarchar(50) = '', + @FilterValue nvarchar(50) = '', + @SortColumn nvarchar(50), + @StartRow int, + @MaximumRows int +) +AS +SET NOCOUNT ON + +-- check rights +IF dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 +RAISERROR('You are not allowed to access this package', 16, 1) + +-- build query and run it to the temporary table +DECLARE @sql nvarchar(2000) + +IF @SortColumn = '' OR @SortColumn IS NULL +SET @SortColumn = 'DomainName' + +SET @sql = ' +DECLARE @Domains TABLE +( + ItemPosition int IDENTITY(1,1), + DomainID int +) +INSERT INTO @Domains (DomainID) +SELECT + D.DomainID +FROM Domains AS D +INNER JOIN Packages AS P ON D.PackageID = P.PackageID +INNER JOIN UsersDetailed AS U ON P.UserID = U.UserID +LEFT OUTER JOIN ServiceItems AS Z ON D.ZoneItemID = Z.ItemID +LEFT OUTER JOIN Services AS S ON Z.ServiceID = S.ServiceID +LEFT OUTER JOIN Servers AS SRV ON S.ServerID = SRV.ServerID +WHERE (D.IsInstantAlias = 0 AND D.IsDomainPointer = 0) AND + ((@Recursive = 0 AND D.PackageID = @PackageID) + OR (@Recursive = 1 AND dbo.CheckPackageParent(@PackageID, D.PackageID) = 1)) +AND (@ServerID = 0 OR (@ServerID > 0 AND S.ServerID = @ServerID)) +' + +IF @FilterColumn <> '' AND @FilterValue <> '' +SET @sql = @sql + ' AND ' + @FilterColumn + ' LIKE @FilterValue ' + +IF @SortColumn <> '' AND @SortColumn IS NOT NULL +SET @sql = @sql + ' ORDER BY ' + @SortColumn + ' ' + +SET @sql = @sql + ' SELECT COUNT(DomainID) FROM @Domains;SELECT + D.DomainID, + D.PackageID, + D.ZoneItemID, + D.DomainItemID, + D.DomainName, + D.HostingAllowed, + ISNULL(WS.ItemID, 0) AS WebSiteID, + WS.ItemName AS WebSiteName, + ISNULL(MD.ItemID, 0) AS MailDomainID, + MD.ItemName AS MailDomainName, + D.IsSubDomain, + D.IsInstantAlias, + D.IsDomainPointer, + D.ExpirationDate, + D.LastUpdateDate, + P.PackageName, + ISNULL(SRV.ServerID, 0) AS ServerID, + ISNULL(SRV.ServerName, '''') AS ServerName, + ISNULL(SRV.Comments, '''') AS ServerComments, + ISNULL(SRV.VirtualServer, 0) AS VirtualServer, + P.UserID, + U.Username, + U.FirstName, + U.LastName, + U.FullName, + U.RoleID, + U.Email +FROM @Domains AS SD +INNER JOIN Domains AS D ON SD.DomainID = D.DomainID +INNER JOIN Packages AS P ON D.PackageID = P.PackageID +INNER JOIN UsersDetailed AS U ON P.UserID = U.UserID +LEFT OUTER JOIN ServiceItems AS WS ON D.WebSiteID = WS.ItemID +LEFT OUTER JOIN ServiceItems AS MD ON D.MailDomainID = MD.ItemID +LEFT OUTER JOIN ServiceItems AS Z ON D.ZoneItemID = Z.ItemID +LEFT OUTER JOIN Services AS S ON Z.ServiceID = S.ServiceID +LEFT OUTER JOIN Servers AS SRV ON S.ServerID = SRV.ServerID +WHERE SD.ItemPosition BETWEEN @StartRow + 1 AND @StartRow + @MaximumRows' + +exec sp_executesql @sql, N'@StartRow int, @MaximumRows int, @PackageID int, @FilterValue nvarchar(50), @ServerID int, @Recursive bit', +@StartRow, @MaximumRows, @PackageID, @FilterValue, @ServerID, @Recursive + + +RETURN +GO + + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'GetRDSServersPaged') +DROP PROCEDURE GetRDSServersPaged +GO +CREATE PROCEDURE [dbo].[GetRDSServersPaged] +( + @FilterColumn nvarchar(50) = '', + @FilterValue nvarchar(50) = '', + @ItemID int, + @IgnoreItemId bit, + @RdsCollectionId int, + @IgnoreRdsCollectionId bit, + @SortColumn nvarchar(50), + @StartRow int, + @MaximumRows int +) +AS +-- build query and run it to the temporary table +DECLARE @sql nvarchar(2000) + +SET @sql = ' + +DECLARE @EndRow int +SET @EndRow = @StartRow + @MaximumRows + +DECLARE @RDSServer TABLE +( + ItemPosition int IDENTITY(0,1), + RDSServerId int +) +INSERT INTO @RDSServer (RDSServerId) +SELECT + S.ID +FROM RDSServers AS S +WHERE + ((((@ItemID is Null AND S.ItemID is null) or @IgnoreItemId = 1) + or (@ItemID is not Null AND S.ItemID = @ItemID)) + and + (((@RdsCollectionId is Null AND S.RDSCollectionId is null) or @IgnoreRdsCollectionId = 1) + or (@RdsCollectionId is not Null AND S.RDSCollectionId = @RdsCollectionId)))' + +IF @FilterColumn <> '' AND @FilterValue <> '' +SET @sql = @sql + ' AND ' + @FilterColumn + ' LIKE @FilterValue ' + +IF @SortColumn <> '' AND @SortColumn IS NOT NULL +SET @sql = @sql + ' ORDER BY ' + @SortColumn + ' ' + +SET @sql = @sql + ' SELECT COUNT(RDSServerId) FROM @RDSServer; +SELECT + ST.ID, + ST.ItemID, + ST.Name, + ST.FqdName, + ST.Description, + ST.RdsCollectionId, + SI.ItemName, + ST.ConnectionEnabled +FROM @RDSServer AS S +INNER JOIN RDSServers AS ST ON S.RDSServerId = ST.ID +LEFT OUTER JOIN ServiceItems AS SI ON SI.ItemId = ST.ItemId +WHERE S.ItemPosition BETWEEN @StartRow AND @EndRow' + +exec sp_executesql @sql, N'@StartRow int, @MaximumRows int, @FilterValue nvarchar(50), @ItemID int, @RdsCollectionId int, @IgnoreItemId bit, @IgnoreRdsCollectionId bit', +@StartRow, @MaximumRows, @FilterValue, @ItemID, @RdsCollectionId, @IgnoreItemId , @IgnoreRdsCollectionId + + +RETURN + +GO + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'UpdateRDSServer') +DROP PROCEDURE UpdateRDSServer +GO +CREATE PROCEDURE [dbo].[UpdateRDSServer] +( + @Id INT, + @ItemID INT, + @Name NVARCHAR(255), + @FqdName NVARCHAR(255), + @Description NVARCHAR(255), + @RDSCollectionId INT, + @ConnectionEnabled BIT +) +AS + +UPDATE RDSServers +SET + ItemID = @ItemID, + Name = @Name, + FqdName = @FqdName, + Description = @Description, + RDSCollectionId = @RDSCollectionId, + ConnectionEnabled = @ConnectionEnabled +WHERE ID = @Id +GO + + +-- fix Windows 2012 Provider +BEGIN +UPDATE [dbo].[Providers] SET [EditorControl] = 'Windows2012' WHERE [ProviderName] = 'Windows2012' +END +GO + +-- fix check domain used by HostedOrganization + +ALTER PROCEDURE [dbo].[CheckDomainUsedByHostedOrganization] + @DomainName nvarchar(100), + @Result int OUTPUT +AS + SET @Result = 0 + IF EXISTS(SELECT 1 FROM ExchangeAccounts WHERE UserPrincipalName LIKE '%@'+ @DomainName AND AccountType!=2) + BEGIN + SET @Result = 1 + END + ELSE + IF EXISTS(SELECT 1 FROM ExchangeAccountEmailAddresses WHERE EmailAddress LIKE '%@'+ @DomainName) + BEGIN + SET @Result = 1 + END + ELSE + IF EXISTS(SELECT 1 FROM LyncUsers WHERE SipAddress LIKE '%@'+ @DomainName) + BEGIN + SET @Result = 1 + END + + RETURN @Result +GO + + +-- check domain used by hosted organization + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'GetOrganizationObjectsByDomain') +DROP PROCEDURE GetOrganizationObjectsByDomain +GO + +CREATE PROCEDURE [dbo].[GetOrganizationObjectsByDomain] +( + @ItemID int, + @DomainName nvarchar(100) +) +AS +SELECT + 'ExchangeAccounts' as ObjectName, + AccountID as ObjectID, + AccountType as ObjectType, + DisplayName as DisplayName, + 0 as OwnerID +FROM + ExchangeAccounts +WHERE + UserPrincipalName LIKE '%@'+ @DomainName AND AccountType!=2 +UNION +SELECT + 'ExchangeAccountEmailAddresses' as ObjectName, + eam.AddressID as ObjectID, + ea.AccountType as ObjectType, + eam.EmailAddress as DisplayName, + eam.AccountID as OwnerID +FROM + ExchangeAccountEmailAddresses as eam +INNER JOIN + ExchangeAccounts ea +ON + ea.AccountID = eam.AccountID +WHERE + (ea.PrimaryEmailAddress != eam.EmailAddress) + AND (ea.UserPrincipalName != eam.EmailAddress) + AND (eam.EmailAddress LIKE '%@'+ @DomainName) +UNION +SELECT + 'LyncUsers' as ObjectName, + ea.AccountID as ObjectID, + ea.AccountType as ObjectType, + ea.DisplayName as DisplayName, + 0 as OwnerID +FROM + ExchangeAccounts ea +INNER JOIN + LyncUsers ou +ON + ea.AccountID = ou.AccountID +WHERE + ou.SipAddress LIKE '%@'+ @DomainName +ORDER BY + DisplayName +RETURN +GO +IF NOT EXISTS(SELECT * FROM sys.columns + WHERE [name] = N'RegistrarName' AND [object_id] = OBJECT_ID(N'Domains')) +BEGIN + ALTER TABLE [dbo].[Domains] ADD RegistrarName nvarchar(max); +END +GO + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'UpdateWhoisDomainInfo') +DROP PROCEDURE UpdateWhoisDomainInfo +GO +CREATE PROCEDURE [dbo].UpdateWhoisDomainInfo +( + @DomainId INT, + @DomainCreationDate DateTime, + @DomainExpirationDate DateTime, + @DomainLastUpdateDate DateTime, + @DomainRegistrarName nvarchar(max) +) +AS +UPDATE [dbo].[Domains] SET [CreationDate] = @DomainCreationDate, [ExpirationDate] = @DomainExpirationDate, [LastUpdateDate] = @DomainLastUpdateDate, [RegistrarName] = @DomainRegistrarName WHERE [DomainID] = @DomainId +GO + + + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'GetDomainsPaged') +DROP PROCEDURE GetDomainsPaged +GO +CREATE PROCEDURE [dbo].[GetDomainsPaged] +( + @ActorID int, + @PackageID int, + @ServerID int, + @Recursive bit, + @FilterColumn nvarchar(50) = '', + @FilterValue nvarchar(50) = '', + @SortColumn nvarchar(50), + @StartRow int, + @MaximumRows int +) +AS +SET NOCOUNT ON + +-- check rights +IF dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 +RAISERROR('You are not allowed to access this package', 16, 1) + +-- build query and run it to the temporary table +DECLARE @sql nvarchar(2500) + +IF @SortColumn = '' OR @SortColumn IS NULL +SET @SortColumn = 'DomainName' + +SET @sql = ' +DECLARE @Domains TABLE +( + ItemPosition int IDENTITY(1,1), + DomainID int +) +INSERT INTO @Domains (DomainID) +SELECT + D.DomainID +FROM Domains AS D +INNER JOIN Packages AS P ON D.PackageID = P.PackageID +INNER JOIN UsersDetailed AS U ON P.UserID = U.UserID +LEFT OUTER JOIN ServiceItems AS Z ON D.ZoneItemID = Z.ItemID +LEFT OUTER JOIN Services AS S ON Z.ServiceID = S.ServiceID +LEFT OUTER JOIN Servers AS SRV ON S.ServerID = SRV.ServerID +WHERE (D.IsInstantAlias = 0 AND D.IsDomainPointer = 0) AND + ((@Recursive = 0 AND D.PackageID = @PackageID) + OR (@Recursive = 1 AND dbo.CheckPackageParent(@PackageID, D.PackageID) = 1)) +AND (@ServerID = 0 OR (@ServerID > 0 AND S.ServerID = @ServerID)) +' + +IF @FilterColumn <> '' AND @FilterValue <> '' +SET @sql = @sql + ' AND ' + @FilterColumn + ' LIKE @FilterValue ' + +IF @SortColumn <> '' AND @SortColumn IS NOT NULL +SET @sql = @sql + ' ORDER BY ' + @SortColumn + ' ' + +SET @sql = @sql + ' SELECT COUNT(DomainID) FROM @Domains;SELECT + D.DomainID, + D.PackageID, + D.ZoneItemID, + D.DomainItemID, + D.DomainName, + D.HostingAllowed, + ISNULL(WS.ItemID, 0) AS WebSiteID, + WS.ItemName AS WebSiteName, + ISNULL(MD.ItemID, 0) AS MailDomainID, + MD.ItemName AS MailDomainName, + D.IsSubDomain, + D.IsInstantAlias, + D.IsDomainPointer, + D.ExpirationDate, + D.LastUpdateDate, + D.RegistrarName, + P.PackageName, + ISNULL(SRV.ServerID, 0) AS ServerID, + ISNULL(SRV.ServerName, '''') AS ServerName, + ISNULL(SRV.Comments, '''') AS ServerComments, + ISNULL(SRV.VirtualServer, 0) AS VirtualServer, + P.UserID, + U.Username, + U.FirstName, + U.LastName, + U.FullName, + U.RoleID, + U.Email +FROM @Domains AS SD +INNER JOIN Domains AS D ON SD.DomainID = D.DomainID +INNER JOIN Packages AS P ON D.PackageID = P.PackageID +INNER JOIN UsersDetailed AS U ON P.UserID = U.UserID +LEFT OUTER JOIN ServiceItems AS WS ON D.WebSiteID = WS.ItemID +LEFT OUTER JOIN ServiceItems AS MD ON D.MailDomainID = MD.ItemID +LEFT OUTER JOIN ServiceItems AS Z ON D.ZoneItemID = Z.ItemID +LEFT OUTER JOIN Services AS S ON Z.ServiceID = S.ServiceID +LEFT OUTER JOIN Servers AS SRV ON S.ServerID = SRV.ServerID +WHERE SD.ItemPosition BETWEEN @StartRow + 1 AND @StartRow + @MaximumRows' + +exec sp_executesql @sql, N'@StartRow int, @MaximumRows int, @PackageID int, @FilterValue nvarchar(50), @ServerID int, @Recursive bit', +@StartRow, @MaximumRows, @PackageID, @FilterValue, @ServerID, @Recursive + + +RETURN +GO + + + + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'GetDomains') +DROP PROCEDURE GetDomains +GO +CREATE PROCEDURE [dbo].[GetDomains] +( + @ActorID int, + @PackageID int, + @Recursive bit = 1 +) +AS + +-- check rights +IF dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 +RAISERROR('You are not allowed to access this package', 16, 1) + +SELECT + D.DomainID, + D.PackageID, + D.ZoneItemID, + D.DomainItemID, + D.DomainName, + D.HostingAllowed, + ISNULL(WS.ItemID, 0) AS WebSiteID, + WS.ItemName AS WebSiteName, + ISNULL(MD.ItemID, 0) AS MailDomainID, + MD.ItemName AS MailDomainName, + Z.ItemName AS ZoneName, + D.IsSubDomain, + D.IsInstantAlias, + D.CreationDate, + D.ExpirationDate, + D.LastUpdateDate, + D.IsDomainPointer, + D.RegistrarName +FROM Domains AS D +INNER JOIN PackagesTree(@PackageID, @Recursive) AS PT ON D.PackageID = PT.PackageID +LEFT OUTER JOIN ServiceItems AS WS ON D.WebSiteID = WS.ItemID +LEFT OUTER JOIN ServiceItems AS MD ON D.MailDomainID = MD.ItemID +LEFT OUTER JOIN ServiceItems AS Z ON D.ZoneItemID = Z.ItemID +RETURN + +GO + +IF NOT EXISTS(select 1 from sys.columns COLS INNER JOIN sys.objects OBJS ON OBJS.object_id=COLS.object_id and OBJS.type='U' AND OBJS.name='Packages' AND COLS.name='DefaultTopPackage') +BEGIN +ALTER TABLE [dbo].[Packages] ADD + [DefaultTopPackage] [bit] DEFAULT 0 NOT NULL +END +GO + + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'GetMyPackages') +DROP PROCEDURE GetMyPackages +GO +CREATE PROCEDURE [dbo].[GetMyPackages] +( + @ActorID int, + @UserID int +) +AS + +-- check rights +IF dbo.CheckActorUserRights(@ActorID, @UserID) = 0 +RAISERROR('You are not allowed to access this account', 16, 1) + +SELECT + P.PackageID, + P.ParentPackageID, + P.PackageName, + P.StatusID, + P.PlanID, + P.PurchaseDate, + + dbo.GetItemComments(P.PackageID, 'PACKAGE', @ActorID) AS Comments, + + -- server + ISNULL(P.ServerID, 0) AS ServerID, + ISNULL(S.ServerName, 'None') AS ServerName, + ISNULL(S.Comments, '') AS ServerComments, + ISNULL(S.VirtualServer, 1) AS VirtualServer, + + -- hosting plan + HP.PlanName, + + -- user + P.UserID, + U.Username, + U.FirstName, + U.LastName, + U.FullName, + U.RoleID, + U.Email, + + P.DefaultTopPackage +FROM Packages AS P +INNER JOIN UsersDetailed AS U ON P.UserID = U.UserID +LEFT OUTER JOIN Servers AS S ON P.ServerID = S.ServerID +LEFT OUTER JOIN HostingPlans AS HP ON P.PlanID = HP.PlanID +WHERE P.UserID = @UserID +RETURN +GO + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'GetPackages') +DROP PROCEDURE GetPackages +GO +CREATE PROCEDURE [dbo].[GetPackages] +( + @ActorID int, + @UserID int +) +AS + +SELECT + P.PackageID, + P.ParentPackageID, + P.PackageName, + P.StatusID, + P.PurchaseDate, + + -- server + ISNULL(P.ServerID, 0) AS ServerID, + ISNULL(S.ServerName, 'None') AS ServerName, + ISNULL(S.Comments, '') AS ServerComments, + ISNULL(S.VirtualServer, 1) AS VirtualServer, + + -- hosting plan + P.PlanID, + HP.PlanName, + + -- user + P.UserID, + U.Username, + U.FirstName, + U.LastName, + U.RoleID, + U.Email, + + P.DefaultTopPackage +FROM Packages AS P +INNER JOIN Users AS U ON P.UserID = U.UserID +INNER JOIN Servers AS S ON P.ServerID = S.ServerID +INNER JOIN HostingPlans AS HP ON P.PlanID = HP.PlanID +WHERE + P.UserID = @UserID +RETURN + +GO + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'GetPackage') +DROP PROCEDURE GetPackage +GO +CREATE PROCEDURE [dbo].[GetPackage] +( + @PackageID int, + @ActorID int +) +AS + +-- Note: ActorID is not verified +-- check both requested and parent package + +SELECT + P.PackageID, + P.ParentPackageID, + P.UserID, + P.PackageName, + P.PackageComments, + P.ServerID, + P.StatusID, + P.PlanID, + P.PurchaseDate, + P.OverrideQuotas, + P.DefaultTopPackage +FROM Packages AS P +WHERE P.PackageID = @PackageID +RETURN + +GO + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'UpdatePackage') +DROP PROCEDURE UpdatePackage +GO +CREATE PROCEDURE [dbo].[UpdatePackage] +( + @ActorID int, + @PackageID int, + @PackageName nvarchar(300), + @PackageComments ntext, + @StatusID int, + @PlanID int, + @PurchaseDate datetime, + @OverrideQuotas bit, + @QuotasXml ntext, + @DefaultTopPackage bit +) +AS + +-- check rights +IF dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 +RAISERROR('You are not allowed to access this package', 16, 1) + +BEGIN TRAN + +DECLARE @ParentPackageID int +DECLARE @OldPlanID int + +SELECT @ParentPackageID = ParentPackageID, @OldPlanID = PlanID FROM Packages +WHERE PackageID = @PackageID + +-- update package +UPDATE Packages SET + PackageName = @PackageName, + PackageComments = @PackageComments, + StatusID = @StatusID, + PlanID = @PlanID, + PurchaseDate = @PurchaseDate, + OverrideQuotas = @OverrideQuotas, + DefaultTopPackage = @DefaultTopPackage +WHERE + PackageID = @PackageID + +-- update quotas (if required) +EXEC UpdatePackageQuotas @ActorID, @PackageID, @QuotasXml + +-- check resulting quotas +DECLARE @ExceedingQuotas AS TABLE (QuotaID int, QuotaName nvarchar(50), QuotaValue int) + +-- check exceeding quotas if plan has been changed +IF (@OldPlanID <> @PlanID) OR (@OverrideQuotas = 1) +BEGIN + INSERT INTO @ExceedingQuotas + SELECT * FROM dbo.GetPackageExceedingQuotas(@ParentPackageID) WHERE QuotaValue > 0 +END + +SELECT * FROM @ExceedingQuotas + +IF EXISTS(SELECT * FROM @ExceedingQuotas) +BEGIN + ROLLBACK TRAN + RETURN +END + + +COMMIT TRAN +RETURN + +GO + + +-- WebDAv portal + +IF EXISTS (SELECT * FROM SYS.TABLES WHERE name = 'WebDavAccessTokens') +DROP TABLE WebDavAccessTokens +GO +CREATE TABLE WebDavAccessTokens +( + ID INT IDENTITY(1,1) NOT NULL PRIMARY KEY, + FilePath NVARCHAR(MAX) NOT NULL, + AuthData NVARCHAR(MAX) NOT NULL, + AccessToken UNIQUEIDENTIFIER NOT NULL, + ExpirationDate DATETIME NOT NULL, + AccountID INT NOT NULL , + ItemId INT NOT NULL +) +GO + +ALTER TABLE [dbo].[WebDavAccessTokens] WITH CHECK ADD CONSTRAINT [FK_WebDavAccessTokens_UserId] FOREIGN KEY([AccountID]) +REFERENCES [dbo].[ExchangeAccounts] ([AccountID]) +ON DELETE CASCADE +GO + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'AddWebDavAccessToken') +DROP PROCEDURE AddWebDavAccessToken +GO +CREATE PROCEDURE [dbo].[AddWebDavAccessToken] +( + @TokenID INT OUTPUT, + @FilePath NVARCHAR(MAX), + @AccessToken UNIQUEIDENTIFIER, + @AuthData NVARCHAR(MAX), + @ExpirationDate DATETIME, + @AccountID INT, + @ItemId INT +) +AS +INSERT INTO WebDavAccessTokens +( + FilePath, + AccessToken, + AuthData, + ExpirationDate, + AccountID , + ItemId +) +VALUES +( + @FilePath , + @AccessToken , + @AuthData, + @ExpirationDate , + @AccountID, + @ItemId +) + +SET @TokenID = SCOPE_IDENTITY() + +RETURN +GO + + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'DeleteExpiredWebDavAccessTokens') +DROP PROCEDURE DeleteExpiredWebDavAccessTokens +GO +CREATE PROCEDURE [dbo].[DeleteExpiredWebDavAccessTokens] +AS +DELETE FROM WebDavAccessTokens +WHERE ExpirationDate < getdate() +GO + + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'GetWebDavAccessTokenById') +DROP PROCEDURE GetWebDavAccessTokenById +GO +CREATE PROCEDURE [dbo].[GetWebDavAccessTokenById] +( + @Id int +) +AS +SELECT + ID , + FilePath , + AuthData , + AccessToken, + ExpirationDate, + AccountID, + ItemId + FROM WebDavAccessTokens + Where ID = @Id AND ExpirationDate > getdate() +GO + + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'GetWebDavAccessTokenByAccessToken') +DROP PROCEDURE GetWebDavAccessTokenByAccessToken +GO +CREATE PROCEDURE [dbo].[GetWebDavAccessTokenByAccessToken] +( + @AccessToken UNIQUEIDENTIFIER +) +AS +SELECT + ID , + FilePath , + AuthData , + AccessToken, + ExpirationDate, + AccountID, + ItemId + FROM WebDavAccessTokens + Where AccessToken = @AccessToken AND ExpirationDate > getdate() +GO + +--add Deleted Users Quota +IF NOT EXISTS (SELECT * FROM [dbo].[Quotas] WHERE [QuotaName] = 'HostedSolution.DeletedUsers') +BEGIN + INSERT [dbo].[Quotas] ([QuotaID], [GroupID],[QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (495, 13, 6, N'HostedSolution.DeletedUsers', N'Deleted Users', 2, 0, NULL, NULL) +END + +IF NOT EXISTS (SELECT * FROM [dbo].[Quotas] WHERE [QuotaName] = 'HostedSolution.DeletedUsersBackupStorageSpace') +BEGIN + INSERT [dbo].[Quotas] ([QuotaID], [GroupID],[QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (496, 13, 6, N'HostedSolution.DeletedUsersBackupStorageSpace', N'Deleted Users Backup Storage Space, Mb', 2, 0, NULL, NULL) +END +GO + +IF NOT EXISTS (SELECT * FROM SYS.TABLES WHERE name = 'ExchangeDeletedAccounts') +CREATE TABLE ExchangeDeletedAccounts +( + ID INT IDENTITY(1,1) NOT NULL PRIMARY KEY, + AccountID INT NOT NULL, + OriginAT INT NOT NULL, + StoragePath NVARCHAR(255) NULL, + FolderName NVARCHAR(128) NULL, + FileName NVARCHAR(128) NULL, + ExpirationDate DATETIME NOT NULL +) +GO + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'GetOrganizationStatistics') +DROP PROCEDURE [dbo].[GetOrganizationStatistics] +GO + +CREATE PROCEDURE [dbo].[GetOrganizationStatistics] +( + @ItemID int +) +AS +SELECT + (SELECT COUNT(*) FROM ExchangeAccounts WHERE (AccountType = 7 OR AccountType = 1 OR AccountType = 6 OR AccountType = 5) AND ItemID = @ItemID) AS CreatedUsers, + (SELECT COUNT(*) FROM ExchangeOrganizationDomains WHERE ItemID = @ItemID) AS CreatedDomains, + (SELECT COUNT(*) FROM ExchangeAccounts WHERE (AccountType = 8 OR AccountType = 9) AND ItemID = @ItemID) AS CreatedGroups, + (SELECT COUNT(*) FROM ExchangeAccounts WHERE AccountType = 11 AND ItemID = @ItemID) AS DeletedUsers +RETURN +GO + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'DeleteOrganizationDeletedUser') +DROP PROCEDURE [dbo].[DeleteOrganizationDeletedUser] +GO + +CREATE PROCEDURE [dbo].[DeleteOrganizationDeletedUser] +( + @ID int +) +AS +DELETE FROM ExchangeDeletedAccounts WHERE AccountID = @ID +RETURN +GO + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'GetOrganizationDeletedUser') +DROP PROCEDURE [dbo].[GetOrganizationDeletedUser] +GO + +CREATE PROCEDURE [dbo].[GetOrganizationDeletedUser] +( + @AccountID int +) +AS +SELECT + EDA.AccountID, + EDA.OriginAT, + EDA.StoragePath, + EDA.FolderName, + EDA.FileName, + EDA.ExpirationDate +FROM + ExchangeDeletedAccounts AS EDA +WHERE + EDA.AccountID = @AccountID +RETURN +GO + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'AddOrganizationDeletedUser') +DROP PROCEDURE [dbo].[AddOrganizationDeletedUser] +GO + +CREATE PROCEDURE [dbo].[AddOrganizationDeletedUser] +( + @ID int OUTPUT, + @AccountID int, + @OriginAT int, + @StoragePath nvarchar(255), + @FolderName nvarchar(128), + @FileName nvarchar(128), + @ExpirationDate datetime +) +AS + +INSERT INTO ExchangeDeletedAccounts +( + AccountID, + OriginAT, + StoragePath, + FolderName, + FileName, + ExpirationDate +) +VALUES +( + @AccountID, + @OriginAT, + @StoragePath, + @FolderName, + @FileName, + @ExpirationDate +) + +SET @ID = SCOPE_IDENTITY() + +RETURN +GO + +ALTER FUNCTION [dbo].[CalculateQuotaUsage] +( + @PackageID int, + @QuotaID int +) +RETURNS int +AS + BEGIN + + DECLARE @QuotaTypeID int + DECLARE @QuotaName nvarchar(50) + SELECT @QuotaTypeID = QuotaTypeID, @QuotaName = QuotaName FROM Quotas + WHERE QuotaID = @QuotaID + + IF @QuotaTypeID <> 2 + RETURN 0 + + DECLARE @Result int + + IF @QuotaID = 52 -- diskspace + SET @Result = dbo.CalculatePackageDiskspace(@PackageID) + ELSE IF @QuotaID = 51 -- bandwidth + SET @Result = dbo.CalculatePackageBandwidth(@PackageID) + ELSE IF @QuotaID = 53 -- domains + SET @Result = (SELECT COUNT(D.DomainID) FROM PackagesTreeCache AS PT + INNER JOIN Domains AS D ON D.PackageID = PT.PackageID + WHERE IsSubDomain = 0 AND IsInstantAlias = 0 AND IsDomainPointer = 0 AND PT.ParentPackageID = @PackageID) + ELSE IF @QuotaID = 54 -- sub-domains + SET @Result = (SELECT COUNT(D.DomainID) FROM PackagesTreeCache AS PT + INNER JOIN Domains AS D ON D.PackageID = PT.PackageID + WHERE IsSubDomain = 1 AND IsInstantAlias = 0 AND IsDomainPointer = 0 AND PT.ParentPackageID = @PackageID) + ELSE IF @QuotaID = 220 -- domain pointers + SET @Result = (SELECT COUNT(D.DomainID) FROM PackagesTreeCache AS PT + INNER JOIN Domains AS D ON D.PackageID = PT.PackageID + WHERE IsDomainPointer = 1 AND PT.ParentPackageID = @PackageID) + ELSE IF @QuotaID = 71 -- scheduled tasks + SET @Result = (SELECT COUNT(S.ScheduleID) FROM PackagesTreeCache AS PT + INNER JOIN Schedule AS S ON S.PackageID = PT.PackageID + WHERE PT.ParentPackageID = @PackageID) + ELSE IF @QuotaID = 305 -- RAM of VPS + SET @Result = (SELECT SUM(CAST(SIP.PropertyValue AS int)) FROM ServiceItemProperties AS SIP + INNER JOIN ServiceItems AS SI ON SIP.ItemID = SI.ItemID + INNER JOIN PackagesTreeCache AS PT ON SI.PackageID = PT.PackageID + WHERE SIP.PropertyName = 'RamSize' AND PT.ParentPackageID = @PackageID) + ELSE IF @QuotaID = 306 -- HDD of VPS + SET @Result = (SELECT SUM(CAST(SIP.PropertyValue AS int)) FROM ServiceItemProperties AS SIP + INNER JOIN ServiceItems AS SI ON SIP.ItemID = SI.ItemID + INNER JOIN PackagesTreeCache AS PT ON SI.PackageID = PT.PackageID + WHERE SIP.PropertyName = 'HddSize' AND PT.ParentPackageID = @PackageID) + ELSE IF @QuotaID = 309 -- External IP addresses of VPS + SET @Result = (SELECT COUNT(PIP.PackageAddressID) FROM PackageIPAddresses AS PIP + INNER JOIN IPAddresses AS IP ON PIP.AddressID = IP.AddressID + INNER JOIN PackagesTreeCache AS PT ON PIP.PackageID = PT.PackageID + WHERE PT.ParentPackageID = @PackageID AND IP.PoolID = 3) + ELSE IF @QuotaID = 558 BEGIN -- RAM of VPS2012 + DECLARE @Result1 int = (SELECT SUM(CAST(SIP.PropertyValue AS int)) FROM ServiceItemProperties AS SIP + INNER JOIN ServiceItems AS SI ON SIP.ItemID = SI.ItemID + INNER JOIN PackagesTreeCache AS PT ON SI.PackageID = PT.PackageID + WHERE SIP.PropertyName = 'RamSize' AND PT.ParentPackageID = @PackageID) + DECLARE @Result2 int = (SELECT SUM(CAST(SIP.PropertyValue AS int)) FROM ServiceItemProperties AS SIP + INNER JOIN ServiceItems AS SI ON SIP.ItemID = SI.ItemID + INNER JOIN ServiceItemProperties AS SIP2 ON + SIP2.ItemID = SI.ItemID AND SIP2.PropertyName = 'DynamicMemory.Enabled' AND SIP2.PropertyValue = 'True' + INNER JOIN PackagesTreeCache AS PT ON SI.PackageID = PT.PackageID + WHERE SIP.PropertyName = 'DynamicMemory.Maximum' AND PT.ParentPackageID = @PackageID) + SET @Result = CASE WHEN isnull(@Result1,0) > isnull(@Result2,0) THEN @Result1 ELSE @Result2 END + END + ELSE IF @QuotaID = 559 -- HDD of VPS2012 + SET @Result = (SELECT SUM(CAST(SIP.PropertyValue AS int)) FROM ServiceItemProperties AS SIP + INNER JOIN ServiceItems AS SI ON SIP.ItemID = SI.ItemID + INNER JOIN PackagesTreeCache AS PT ON SI.PackageID = PT.PackageID + WHERE SIP.PropertyName = 'HddSize' AND PT.ParentPackageID = @PackageID) + ELSE IF @QuotaID = 562 -- External IP addresses of VPS2012 + SET @Result = (SELECT COUNT(PIP.PackageAddressID) FROM PackageIPAddresses AS PIP + INNER JOIN IPAddresses AS IP ON PIP.AddressID = IP.AddressID + INNER JOIN PackagesTreeCache AS PT ON PIP.PackageID = PT.PackageID + WHERE PT.ParentPackageID = @PackageID AND IP.PoolID = 3) + ELSE IF @QuotaID = 100 -- Dedicated Web IP addresses + SET @Result = (SELECT COUNT(PIP.PackageAddressID) FROM PackageIPAddresses AS PIP + INNER JOIN IPAddresses AS IP ON PIP.AddressID = IP.AddressID + INNER JOIN PackagesTreeCache AS PT ON PIP.PackageID = PT.PackageID + WHERE PT.ParentPackageID = @PackageID AND IP.PoolID = 2) + ELSE IF @QuotaID = 350 -- RAM of VPSforPc + SET @Result = (SELECT SUM(CAST(SIP.PropertyValue AS int)) FROM ServiceItemProperties AS SIP + INNER JOIN ServiceItems AS SI ON SIP.ItemID = SI.ItemID + INNER JOIN PackagesTreeCache AS PT ON SI.PackageID = PT.PackageID + WHERE SIP.PropertyName = 'Memory' AND PT.ParentPackageID = @PackageID) + ELSE IF @QuotaID = 351 -- HDD of VPSforPc + SET @Result = (SELECT SUM(CAST(SIP.PropertyValue AS int)) FROM ServiceItemProperties AS SIP + INNER JOIN ServiceItems AS SI ON SIP.ItemID = SI.ItemID + INNER JOIN PackagesTreeCache AS PT ON SI.PackageID = PT.PackageID + WHERE SIP.PropertyName = 'HddSize' AND PT.ParentPackageID = @PackageID) + ELSE IF @QuotaID = 354 -- External IP addresses of VPSforPc + SET @Result = (SELECT COUNT(PIP.PackageAddressID) FROM PackageIPAddresses AS PIP + INNER JOIN IPAddresses AS IP ON PIP.AddressID = IP.AddressID + INNER JOIN PackagesTreeCache AS PT ON PIP.PackageID = PT.PackageID + WHERE PT.ParentPackageID = @PackageID AND IP.PoolID = 3) + ELSE IF @QuotaID = 319 -- BB Users + SET @Result = (SELECT COUNT(ea.AccountID) FROM ExchangeAccounts ea + INNER JOIN BlackBerryUsers bu ON ea.AccountID = bu.AccountID + INNER JOIN ServiceItems si ON ea.ItemID = si.ItemID + INNER JOIN PackagesTreeCache pt ON si.PackageID = pt.PackageID + WHERE pt.ParentPackageID = @PackageID) + ELSE IF @QuotaID = 320 -- OCS Users + SET @Result = (SELECT COUNT(ea.AccountID) FROM ExchangeAccounts ea + INNER JOIN OCSUsers ocs ON ea.AccountID = ocs.AccountID + INNER JOIN ServiceItems si ON ea.ItemID = si.ItemID + INNER JOIN PackagesTreeCache pt ON si.PackageID = pt.PackageID + WHERE pt.ParentPackageID = @PackageID) + ELSE IF @QuotaID = 206 -- HostedSolution.Users + SET @Result = (SELECT COUNT(ea.AccountID) FROM ExchangeAccounts AS ea + INNER JOIN ServiceItems si ON ea.ItemID = si.ItemID + INNER JOIN PackagesTreeCache pt ON si.PackageID = pt.PackageID + WHERE pt.ParentPackageID = @PackageID AND ea.AccountType IN (1,5,6,7)) + ELSE IF @QuotaID = 78 -- Exchange2007.Mailboxes + SET @Result = (SELECT COUNT(ea.AccountID) FROM ExchangeAccounts AS ea + INNER JOIN ServiceItems si ON ea.ItemID = si.ItemID + INNER JOIN PackagesTreeCache pt ON si.PackageID = pt.PackageID + WHERE pt.ParentPackageID = @PackageID + AND ea.AccountType IN (1) + AND ea.MailboxPlanId IS NOT NULL) + ELSE IF @QuotaID = 77 -- Exchange2007.DiskSpace + SET @Result = (SELECT SUM(B.MailboxSizeMB) FROM ExchangeAccounts AS ea + INNER JOIN ExchangeMailboxPlans AS B ON ea.MailboxPlanId = B.MailboxPlanId + INNER JOIN ServiceItems si ON ea.ItemID = si.ItemID + INNER JOIN PackagesTreeCache pt ON si.PackageID = pt.PackageID + WHERE pt.ParentPackageID = @PackageID) + ELSE IF @QuotaID = 370 -- Lync.Users + SET @Result = (SELECT COUNT(ea.AccountID) FROM ExchangeAccounts AS ea + INNER JOIN LyncUsers lu ON ea.AccountID = lu.AccountID + INNER JOIN ServiceItems si ON ea.ItemID = si.ItemID + INNER JOIN PackagesTreeCache pt ON si.PackageID = pt.PackageID + WHERE pt.ParentPackageID = @PackageID) + ELSE IF @QuotaID = 376 -- Lync.EVUsers + SET @Result = (SELECT COUNT(ea.AccountID) FROM ExchangeAccounts AS ea + INNER JOIN LyncUsers lu ON ea.AccountID = lu.AccountID + INNER JOIN LyncUserPlans lp ON lu.LyncUserPlanId = lp.LyncUserPlanId + INNER JOIN ServiceItems si ON ea.ItemID = si.ItemID + INNER JOIN PackagesTreeCache pt ON si.PackageID = pt.PackageID + WHERE pt.ParentPackageID = @PackageID AND lp.EnterpriseVoice = 1) + ELSE IF @QuotaID = 381 -- Dedicated Lync Phone Numbers + SET @Result = (SELECT COUNT(PIP.PackageAddressID) FROM PackageIPAddresses AS PIP + INNER JOIN IPAddresses AS IP ON PIP.AddressID = IP.AddressID + INNER JOIN PackagesTreeCache AS PT ON PIP.PackageID = PT.PackageID + WHERE PT.ParentPackageID = @PackageID AND IP.PoolID = 5) + ELSE IF @QuotaID = 430 -- Enterprise Storage + SET @Result = (SELECT SUM(ESF.FolderQuota) FROM EnterpriseFolders AS ESF + INNER JOIN ServiceItems SI ON ESF.ItemID = SI.ItemID + INNER JOIN PackagesTreeCache PT ON SI.PackageID = PT.PackageID + WHERE PT.ParentPackageID = @PackageID) + ELSE IF @QuotaID = 431 -- Enterprise Storage Folders + SET @Result = (SELECT COUNT(ESF.EnterpriseFolderID) FROM EnterpriseFolders AS ESF + INNER JOIN ServiceItems SI ON ESF.ItemID = SI.ItemID + INNER JOIN PackagesTreeCache PT ON SI.PackageID = PT.PackageID + WHERE PT.ParentPackageID = @PackageID) + ELSE IF @QuotaID = 423 -- HostedSolution.SecurityGroups + SET @Result = (SELECT COUNT(ea.AccountID) FROM ExchangeAccounts AS ea + INNER JOIN ServiceItems si ON ea.ItemID = si.ItemID + INNER JOIN PackagesTreeCache pt ON si.PackageID = pt.PackageID + WHERE pt.ParentPackageID = @PackageID AND ea.AccountType IN (8,9)) + ELSE IF @QuotaID = 495 -- HostedSolution.DeletedUsers + SET @Result = (SELECT COUNT(ea.AccountID) FROM ExchangeAccounts AS ea + INNER JOIN ServiceItems si ON ea.ItemID = si.ItemID + INNER JOIN PackagesTreeCache pt ON si.PackageID = pt.PackageID + WHERE pt.ParentPackageID = @PackageID AND ea.AccountType = 11) + ELSE IF @QuotaID = 450 + SET @Result = (SELECT COUNT(DISTINCT(RCU.[AccountId])) FROM [dbo].[RDSCollectionUsers] RCU + INNER JOIN ExchangeAccounts EA ON EA.AccountId = RCU.AccountId + INNER JOIN ServiceItems si ON ea.ItemID = si.ItemID + INNER JOIN PackagesTreeCache pt ON si.PackageID = pt.PackageID + WHERE PT.ParentPackageID = @PackageID) + ELSE IF @QuotaID = 451 + SET @Result = (SELECT COUNT(RS.[ID]) FROM [dbo].[RDSServers] RS + INNER JOIN ServiceItems si ON RS.ItemID = si.ItemID + INNER JOIN PackagesTreeCache pt ON si.PackageID = pt.PackageID + WHERE PT.ParentPackageID = @PackageID) + ELSE IF @QuotaID = 491 + SET @Result = (SELECT COUNT(RC.[ID]) FROM [dbo].[RDSCollections] RC + INNER JOIN ServiceItems si ON RC.ItemID = si.ItemID + INNER JOIN PackagesTreeCache pt ON si.PackageID = pt.PackageID + WHERE PT.ParentPackageID = @PackageID) + ELSE IF @QuotaName like 'ServiceLevel.%' -- Support Service Level Quota + BEGIN + DECLARE @LevelID int + + SELECT @LevelID = LevelID FROM SupportServiceLevels + WHERE LevelName = REPLACE(@QuotaName,'ServiceLevel.','') + + IF (@LevelID IS NOT NULL) + SET @Result = (SELECT COUNT(EA.AccountID) + FROM SupportServiceLevels AS SL + INNER JOIN ExchangeAccounts AS EA ON SL.LevelID = EA.LevelID + INNER JOIN ServiceItems SI ON EA.ItemID = SI.ItemID + INNER JOIN PackagesTreeCache PT ON SI.PackageID = PT.PackageID + WHERE EA.LevelID = @LevelID AND PT.ParentPackageID = @PackageID) + ELSE SET @Result = 0 + END + ELSE + SET @Result = (SELECT COUNT(SI.ItemID) FROM Quotas AS Q + INNER JOIN ServiceItems AS SI ON SI.ItemTypeID = Q.ItemTypeID + INNER JOIN PackagesTreeCache AS PT ON SI.PackageID = PT.PackageID AND PT.ParentPackageID = @PackageID + WHERE Q.QuotaID = @QuotaID) + + RETURN @Result + END +GO + +IF NOT EXISTS(select 1 from sys.columns COLS INNER JOIN sys.objects OBJS ON OBJS.object_id=COLS.object_id and OBJS.type='U' AND OBJS.name='ExchangeMailboxPlans' AND COLS.name='EnableForceArchiveDeletion') +BEGIN + ALTER TABLE [dbo].[ExchangeMailboxPlans] ADD [EnableForceArchiveDeletion] [bit] NULL +END +GO + +ALTER PROCEDURE [dbo].[AddExchangeMailboxPlan] +( + @MailboxPlanId int OUTPUT, + @ItemID int, + @MailboxPlan nvarchar(300), + @EnableActiveSync bit, + @EnableIMAP bit, + @EnableMAPI bit, + @EnableOWA bit, + @EnablePOP bit, + @IsDefault bit, + @IssueWarningPct int, + @KeepDeletedItemsDays int, + @MailboxSizeMB int, + @MaxReceiveMessageSizeKB int, + @MaxRecipients int, + @MaxSendMessageSizeKB int, + @ProhibitSendPct int, + @ProhibitSendReceivePct int , + @HideFromAddressBook bit, + @MailboxPlanType int, + @AllowLitigationHold bit, + @RecoverableItemsWarningPct int, + @RecoverableItemsSpace int, + @LitigationHoldUrl nvarchar(256), + @LitigationHoldMsg nvarchar(512), + @Archiving bit, + @EnableArchiving bit, + @ArchiveSizeMB int, + @ArchiveWarningPct int, + @EnableForceArchiveDeletion bit +) +AS + +IF (((SELECT Count(*) FROM ExchangeMailboxPlans WHERE ItemId = @ItemID) = 0) AND (@MailboxPlanType=0)) +BEGIN + SET @IsDefault = 1 +END +ELSE +BEGIN + IF ((@IsDefault = 1) AND (@MailboxPlanType=0)) + BEGIN + UPDATE ExchangeMailboxPlans SET IsDefault = 0 WHERE ItemID = @ItemID + END +END + +INSERT INTO ExchangeMailboxPlans +( + ItemID, + MailboxPlan, + EnableActiveSync, + EnableIMAP, + EnableMAPI, + EnableOWA, + EnablePOP, + IsDefault, + IssueWarningPct, + KeepDeletedItemsDays, + MailboxSizeMB, + MaxReceiveMessageSizeKB, + MaxRecipients, + MaxSendMessageSizeKB, + ProhibitSendPct, + ProhibitSendReceivePct, + HideFromAddressBook, + MailboxPlanType, + AllowLitigationHold, + RecoverableItemsWarningPct, + RecoverableItemsSpace, + LitigationHoldUrl, + LitigationHoldMsg, + Archiving, + EnableArchiving, + ArchiveSizeMB, + ArchiveWarningPct, + EnableForceArchiveDeletion +) +VALUES +( + @ItemID, + @MailboxPlan, + @EnableActiveSync, + @EnableIMAP, + @EnableMAPI, + @EnableOWA, + @EnablePOP, + @IsDefault, + @IssueWarningPct, + @KeepDeletedItemsDays, + @MailboxSizeMB, + @MaxReceiveMessageSizeKB, + @MaxRecipients, + @MaxSendMessageSizeKB, + @ProhibitSendPct, + @ProhibitSendReceivePct, + @HideFromAddressBook, + @MailboxPlanType, + @AllowLitigationHold, + @RecoverableItemsWarningPct, + @RecoverableItemsSpace, + @LitigationHoldUrl, + @LitigationHoldMsg, + @Archiving, + @EnableArchiving, + @ArchiveSizeMB, + @ArchiveWarningPct, + @EnableForceArchiveDeletion +) + +SET @MailboxPlanId = SCOPE_IDENTITY() + +RETURN +GO + +ALTER PROCEDURE [dbo].[UpdateExchangeMailboxPlan] +( + @MailboxPlanId int, + @MailboxPlan nvarchar(300), + @EnableActiveSync bit, + @EnableIMAP bit, + @EnableMAPI bit, + @EnableOWA bit, + @EnablePOP bit, + @IsDefault bit, + @IssueWarningPct int, + @KeepDeletedItemsDays int, + @MailboxSizeMB int, + @MaxReceiveMessageSizeKB int, + @MaxRecipients int, + @MaxSendMessageSizeKB int, + @ProhibitSendPct int, + @ProhibitSendReceivePct int , + @HideFromAddressBook bit, + @MailboxPlanType int, + @AllowLitigationHold bit, + @RecoverableItemsWarningPct int, + @RecoverableItemsSpace int, + @LitigationHoldUrl nvarchar(256), + @LitigationHoldMsg nvarchar(512), + @Archiving bit, + @EnableArchiving bit, + @ArchiveSizeMB int, + @ArchiveWarningPct int, + @EnableForceArchiveDeletion bit +) +AS + +UPDATE ExchangeMailboxPlans SET + MailboxPlan = @MailboxPlan, + EnableActiveSync = @EnableActiveSync, + EnableIMAP = @EnableIMAP, + EnableMAPI = @EnableMAPI, + EnableOWA = @EnableOWA, + EnablePOP = @EnablePOP, + IsDefault = @IsDefault, + IssueWarningPct= @IssueWarningPct, + KeepDeletedItemsDays = @KeepDeletedItemsDays, + MailboxSizeMB= @MailboxSizeMB, + MaxReceiveMessageSizeKB= @MaxReceiveMessageSizeKB, + MaxRecipients= @MaxRecipients, + MaxSendMessageSizeKB= @MaxSendMessageSizeKB, + ProhibitSendPct= @ProhibitSendPct, + ProhibitSendReceivePct = @ProhibitSendReceivePct, + HideFromAddressBook = @HideFromAddressBook, + MailboxPlanType = @MailboxPlanType, + AllowLitigationHold = @AllowLitigationHold, + RecoverableItemsWarningPct = @RecoverableItemsWarningPct, + RecoverableItemsSpace = @RecoverableItemsSpace, + LitigationHoldUrl = @LitigationHoldUrl, + LitigationHoldMsg = @LitigationHoldMsg, + Archiving = @Archiving, + EnableArchiving = @EnableArchiving, + ArchiveSizeMB = @ArchiveSizeMB, + ArchiveWarningPct = @ArchiveWarningPct, + EnableForceArchiveDeletion = @EnableForceArchiveDeletion +WHERE MailboxPlanId = @MailboxPlanId + +RETURN +GO + +ALTER PROCEDURE [dbo].[GetExchangeMailboxPlan] +( + @MailboxPlanId int +) +AS +SELECT + MailboxPlanId, + ItemID, + MailboxPlan, + EnableActiveSync, + EnableIMAP, + EnableMAPI, + EnableOWA, + EnablePOP, + IsDefault, + IssueWarningPct, + KeepDeletedItemsDays, + MailboxSizeMB, + MaxReceiveMessageSizeKB, + MaxRecipients, + MaxSendMessageSizeKB, + ProhibitSendPct, + ProhibitSendReceivePct, + HideFromAddressBook, + MailboxPlanType, + AllowLitigationHold, + RecoverableItemsWarningPct, + RecoverableItemsSpace, + LitigationHoldUrl, + LitigationHoldMsg, + Archiving, + EnableArchiving, + ArchiveSizeMB, + ArchiveWarningPct, + EnableForceArchiveDeletion +FROM + ExchangeMailboxPlans +WHERE + MailboxPlanId = @MailboxPlanId +RETURN +GO + +ALTER PROCEDURE [dbo].[GetExchangeMailboxPlans] +( + @ItemID int, + @Archiving bit +) +AS +SELECT + MailboxPlanId, + ItemID, + MailboxPlan, + EnableActiveSync, + EnableIMAP, + EnableMAPI, + EnableOWA, + EnablePOP, + IsDefault, + IssueWarningPct, + KeepDeletedItemsDays, + MailboxSizeMB, + MaxReceiveMessageSizeKB, + MaxRecipients, + MaxSendMessageSizeKB, + ProhibitSendPct, + ProhibitSendReceivePct, + HideFromAddressBook, + MailboxPlanType, + Archiving, + EnableArchiving, + ArchiveSizeMB, + ArchiveWarningPct, + EnableForceArchiveDeletion +FROM + ExchangeMailboxPlans +WHERE + ItemID = @ItemID +AND ((Archiving=@Archiving) OR ((@Archiving=0) AND (Archiving IS NULL))) +ORDER BY MailboxPlan +RETURN +GO + +IF NOT EXISTS (SELECT * FROM [dbo].[ScheduleTasks] WHERE [TaskID] = 'SCHEDULE_TASK_DELETE_EXCHANGE_ACCOUNTS') +BEGIN +INSERT INTO [dbo].[ScheduleTasks] ([TaskID], [TaskType], [RoleID]) VALUES (N'SCHEDULE_TASK_DELETE_EXCHANGE_ACCOUNTS', N'WebsitePanel.EnterpriseServer.DeleteExchangeAccountsTask, WebsitePanel.EnterpriseServer.Code', 3) +END +GO + + + + + +ALTER PROCEDURE [dbo].[UpdateServiceItem] +( + @ActorID int, + @ItemID int, + @ItemName nvarchar(500), + @XmlProperties ntext +) +AS +BEGIN TRAN + +-- check rights +DECLARE @PackageID int +SELECT PackageID = @PackageID FROM ServiceItems +WHERE ItemID = @ItemID + +IF dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 +RAISERROR('You are not allowed to access this package', 16, 1) + +-- update item +UPDATE ServiceItems SET ItemName = @ItemName +WHERE ItemID=@ItemID + +DECLARE @idoc int +--Create an internal representation of the XML document. +EXEC sp_xml_preparedocument @idoc OUTPUT, @XmlProperties + +-- Execute a SELECT statement that uses the OPENXML rowset provider. +DELETE FROM ServiceItemProperties +WHERE ItemID = @ItemID + +-- Add the xml data into a temp table for the capability and robust +IF OBJECT_ID('tempdb..#TempTable') IS NOT NULL DROP TABLE #TempTable + +CREATE TABLE #TempTable( + ItemID int, + PropertyName nvarchar(50), + PropertyValue nvarchar(3000)) + +INSERT INTO #TempTable (ItemID, PropertyName, PropertyValue) +SELECT + @ItemID, + PropertyName, + PropertyValue +FROM OPENXML(@idoc, '/properties/property',1) WITH +( + PropertyName nvarchar(50) '@name', + PropertyValue nvarchar(3000) '@value' +) as PV + +-- Move data from temp table to real table +INSERT INTO ServiceItemProperties +( + ItemID, + PropertyName, + PropertyValue +) +SELECT + ItemID, + PropertyName, + PropertyValue +FROM #TempTable + +DROP TABLE #TempTable + +-- remove document +exec sp_xml_removedocument @idoc + +COMMIT TRAN + +RETURN +GO + + +-- Password column removed +IF OBJECTPROPERTY(object_id('dbo.GetExchangeAccountByAccountNameWithoutItemId'), N'IsProcedure') = 1 +DROP PROCEDURE [dbo].[GetExchangeAccountByAccountNameWithoutItemId] +GO +CREATE PROCEDURE [dbo].[GetExchangeAccountByAccountNameWithoutItemId] +( + @UserPrincipalName nvarchar(300) +) +AS +SELECT + E.AccountID, + E.ItemID, + E.AccountType, + E.AccountName, + E.DisplayName, + E.PrimaryEmailAddress, + E.MailEnabledPublicFolder, + E.MailboxManagerActions, + E.SamAccountName, + E.MailboxPlanId, + P.MailboxPlan, + E.SubscriberNumber, + E.UserPrincipalName, + E.ArchivingMailboxPlanId, + AP.MailboxPlan as 'ArchivingMailboxPlan', + E.EnableArchiving +FROM + ExchangeAccounts AS E +LEFT OUTER JOIN ExchangeMailboxPlans AS P ON E.MailboxPlanId = P.MailboxPlanId +LEFT OUTER JOIN ExchangeMailboxPlans AS AP ON E.ArchivingMailboxPlanId = AP.MailboxPlanId +WHERE + E.UserPrincipalName = @UserPrincipalName +RETURN +GO + + + +--Webdav portal users settings + +IF NOT EXISTS (SELECT * FROM SYS.TABLES WHERE name = 'WebDavPortalUsersSettings') +CREATE TABLE WebDavPortalUsersSettings +( + ID INT IDENTITY(1,1) NOT NULL PRIMARY KEY, + AccountId INT NOT NULL, + Settings NVARCHAR(max) +) +GO + +IF EXISTS (SELECT * FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS WHERE CONSTRAINT_NAME ='FK_WebDavPortalUsersSettings_UserId') +ALTER TABLE [dbo].[WebDavPortalUsersSettings] +DROP CONSTRAINT [FK_WebDavPortalUsersSettings_UserId] +GO + +ALTER TABLE [dbo].[WebDavPortalUsersSettings] WITH CHECK ADD CONSTRAINT [FK_WebDavPortalUsersSettings_UserId] FOREIGN KEY([AccountID]) +REFERENCES [dbo].[ExchangeAccounts] ([AccountID]) +ON DELETE CASCADE +GO + + + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'GetWebDavPortalUsersSettingsByAccountId') +DROP PROCEDURE GetWebDavPortalUsersSettingsByAccountId +GO +CREATE PROCEDURE [dbo].[GetWebDavPortalUsersSettingsByAccountId] +( + @AccountId INT +) +AS +SELECT TOP 1 + US.Id, + US.AccountId, + US.Settings + FROM WebDavPortalUsersSettings AS US + WHERE AccountId = @AccountId +GO + + + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'AddWebDavPortalUsersSettings') +DROP PROCEDURE AddWebDavPortalUsersSettings +GO +CREATE PROCEDURE [dbo].[AddWebDavPortalUsersSettings] +( + @WebDavPortalUsersSettingsId INT OUTPUT, + @AccountId INT, + @Settings NVARCHAR(max) +) +AS + +INSERT INTO WebDavPortalUsersSettings +( + AccountId, + Settings +) +VALUES +( + @AccountId, + @Settings +) + +SET @WebDavPortalUsersSettingsId = SCOPE_IDENTITY() + +RETURN +GO + + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'UpdateWebDavPortalUsersSettings') +DROP PROCEDURE UpdateWebDavPortalUsersSettings +GO +CREATE PROCEDURE [dbo].[UpdateWebDavPortalUsersSettings] +( + @AccountId INT, + @Settings NVARCHAR(max) +) +AS + +UPDATE WebDavPortalUsersSettings +SET + Settings = @Settings +WHERE AccountId = @AccountId +GO + +IF NOT EXISTS (SELECT * FROM [dbo].[Providers] WHERE [DisplayName] = 'SmarterMail 10.x +') +BEGIN +INSERT [dbo].[Providers] ([ProviderId], [GroupId], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery]) VALUES(66, 4, N'SmarterMail', N'SmarterMail 10.x +', N'WebsitePanel.Providers.Mail.SmarterMail10, WebsitePanel.Providers.Mail.SmarterMail10', N'SmarterMail100', NULL) +END +ELSE +BEGIN +UPDATE [dbo].[Providers] SET [EditorControl] = 'SmarterMail100' WHERE [DisplayName] = 'SmarterMail 10.x +' +END +GO + + +-- Service items count by name and serviceid + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'GetServiceItemsCountByNameAndServiceId') +DROP PROCEDURE GetServiceItemsCountByNameAndServiceId +GO + +CREATE PROCEDURE [dbo].[GetServiceItemsCountByNameAndServiceId] +( + @ActorID int, + @ServiceId int, + @ItemName nvarchar(500), + @GroupName nvarchar(100) = NULL, + @ItemTypeName nvarchar(200) +) +AS +SELECT Count(*) +FROM ServiceItems AS SI +INNER JOIN ServiceItemTypes AS SIT ON SI.ItemTypeID = SIT.ItemTypeID +INNER JOIN ResourceGroups AS RG ON SIT.GroupID = RG.GroupID +INNER JOIN Services AS S ON SI.ServiceID = S.ServiceID +WHERE S.ServiceID = @ServiceId +AND SIT.TypeName = @ItemTypeName +AND SI.ItemName = @ItemName +AND ((@GroupName IS NULL) OR (@GroupName IS NOT NULL AND RG.GroupName = @GroupName)) +RETURN +GO + +-- Hyper-V 2012 R2 Provider +IF NOT EXISTS (SELECT * FROM [dbo].[ResourceGroups] WHERE [GroupName] = 'VPS2012') +BEGIN +INSERT [dbo].[ResourceGroups] ([GroupID], [GroupName], [GroupOrder], [GroupController], [ShowGroup]) VALUES (33, N'VPS2012', 19, NULL, 1) + +INSERT [dbo].[ServiceItemTypes] ([ItemTypeID], [GroupID], [DisplayName], [TypeName], [TypeOrder], [CalculateDiskspace], [CalculateBandwidth], [Suspendable], [Disposable], [Searchable], [Importable], [Backupable]) VALUES (41, 33, N'VirtualMachine', N'WebsitePanel.Providers.Virtualization.VirtualMachine, WebsitePanel.Providers.Base', 1, 0, 0, 1, 1, 1, 0, 0) + +INSERT [dbo].[ServiceItemTypes] ([ItemTypeID], [GroupID], [DisplayName], [TypeName], [TypeOrder], [CalculateDiskspace], [CalculateBandwidth], [Suspendable], [Disposable], [Searchable], [Importable], [Backupable]) VALUES (42, 33, N'VirtualSwitch', N'WebsitePanel.Providers.Virtualization.VirtualSwitch, WebsitePanel.Providers.Base', 2, 0, 0, 1, 1, 1, 0, 0) + +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (553, 33, 1, N'VPS2012.ServersNumber', N'Number of VPS', 2, 0, 41, NULL) + +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (554, 33, 2, N'VPS2012.ManagingAllowed', N'Allow user to create VPS', 1, 0, NULL, NULL) + +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (555, 33, 3, N'VPS2012.CpuNumber', N'Number of CPU cores', 3, 0, NULL, NULL) + +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (556, 33, 7, N'VPS2012.BootCdAllowed', N'Boot from CD allowed', 1, 0, NULL, NULL) + +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (557, 33, 8, N'VPS2012.BootCdEnabled', N'Boot from CD', 1, 0, NULL, NULL) + +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (558, 33, 4, N'VPS2012.Ram', N'RAM size, MB', 2, 0, NULL, NULL) + +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (559, 33, 5, N'VPS2012.Hdd', N'Hard Drive size, GB', 2, 0, NULL, NULL) + +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (560, 33, 6, N'VPS2012.DvdEnabled', N'DVD drive', 1, 0, NULL, NULL) + +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (561, 33, 10, N'VPS2012.ExternalNetworkEnabled', N'External Network', 1, 0, NULL, NULL) + +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (562, 33, 11, N'VPS2012.ExternalIPAddressesNumber', N'Number of External IP addresses', 2, 0, NULL, NULL) + +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (563, 33, 13, N'VPS2012.PrivateNetworkEnabled', N'Private Network', 1, 0, NULL, NULL) + +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (564, 33, 14, N'VPS2012.PrivateIPAddressesNumber', N'Number of Private IP addresses per VPS', 3, 0, NULL, NULL) + +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (565, 33, 9, N'VPS2012.SnapshotsNumber', N'Number of Snaphots', 3, 0, NULL, NULL) + +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (566, 33, 15, N'VPS2012.StartShutdownAllowed', N'Allow user to Start, Turn off and Shutdown VPS', 1, 0, NULL, NULL) + +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (567, 33, 16, N'VPS2012.PauseResumeAllowed', N'Allow user to Pause, Resume VPS', 1, 0, NULL, NULL) + +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (568, 33, 17, N'VPS2012.RebootAllowed', N'Allow user to Reboot VPS', 1, 0, NULL, NULL) + +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (569, 33, 18, N'VPS2012.ResetAlowed', N'Allow user to Reset VPS', 1, 0, NULL, NULL) + +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (570, 33, 19, N'VPS2012.ReinstallAllowed', N'Allow user to Re-install VPS', 1, 0, NULL, NULL) + +INSERT [dbo].[Quotas] ([QuotaID], [GroupID], [QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID], [HideQuota]) VALUES (571, 33, 12, N'VPS2012.Bandwidth', N'Monthly bandwidth, GB', 2, 0, NULL, NULL) + +END +GO + +IF NOT EXISTS (SELECT * FROM [dbo].[Providers] WHERE [ProviderName] = 'HyperV2012R2') +BEGIN +INSERT [dbo].[Providers] ([ProviderID], [GroupID], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery]) VALUES (350, 33, N'HyperV2012R2', N'Microsoft Hyper-V 2012 R2', N'WebsitePanel.Providers.Virtualization.HyperV2012R2, WebsitePanel.Providers.Virtualization.HyperV2012R2', N'HyperV2012R2', 1) +END +ELSE +BEGIN +UPDATE [dbo].[Providers] SET [EditorControl] = N'HyperV2012R2', [GroupID] = 33 WHERE [ProviderName] = 'HyperV2012R2' +END +GO + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'GetVirtualMachinesPaged2012') +DROP PROCEDURE GetVirtualMachinesPaged2012 +GO +CREATE PROCEDURE [dbo].[GetVirtualMachinesPaged2012] +( + @ActorID int, + @PackageID int, + @FilterColumn nvarchar(50) = '', + @FilterValue nvarchar(50) = '', + @SortColumn nvarchar(50), + @StartRow int, + @MaximumRows int, + @Recursive bit +) +AS +-- check rights +IF dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 +RAISERROR('You are not allowed to access this package', 16, 1) + +-- start +DECLARE @condition nvarchar(700) +SET @condition = ' +SI.ItemTypeID = 41 -- VPS2012 +AND ((@Recursive = 0 AND P.PackageID = @PackageID) +OR (@Recursive = 1 AND dbo.CheckPackageParent(@PackageID, P.PackageID) = 1)) +' + +IF @FilterColumn <> '' AND @FilterColumn IS NOT NULL +AND @FilterValue <> '' AND @FilterValue IS NOT NULL +SET @condition = @condition + ' AND ' + @FilterColumn + ' LIKE ''' + @FilterValue + '''' + +IF @SortColumn IS NULL OR @SortColumn = '' +SET @SortColumn = 'SI.ItemName ASC' + +DECLARE @sql nvarchar(3500) + +set @sql = ' +SELECT COUNT(SI.ItemID) FROM Packages AS P +INNER JOIN ServiceItems AS SI ON P.PackageID = SI.PackageID +INNER JOIN Users AS U ON P.UserID = U.UserID +LEFT OUTER JOIN ( + SELECT PIP.ItemID, IP.ExternalIP FROM PackageIPAddresses AS PIP + INNER JOIN IPAddresses AS IP ON PIP.AddressID = IP.AddressID + WHERE PIP.IsPrimary = 1 AND IP.PoolID = 3 -- external IP addresses +) AS EIP ON SI.ItemID = EIP.ItemID +LEFT OUTER JOIN PrivateIPAddresses AS PIP ON PIP.ItemID = SI.ItemID AND PIP.IsPrimary = 1 +WHERE ' + @condition + ' + +DECLARE @Items AS TABLE +( + ItemID int +); + +WITH TempItems AS ( + SELECT ROW_NUMBER() OVER (ORDER BY ' + @SortColumn + ') as Row, + SI.ItemID + FROM Packages AS P + INNER JOIN ServiceItems AS SI ON P.PackageID = SI.PackageID + INNER JOIN Users AS U ON P.UserID = U.UserID + LEFT OUTER JOIN ( + SELECT PIP.ItemID, IP.ExternalIP FROM PackageIPAddresses AS PIP + INNER JOIN IPAddresses AS IP ON PIP.AddressID = IP.AddressID + WHERE PIP.IsPrimary = 1 AND IP.PoolID = 3 -- external IP addresses + ) AS EIP ON SI.ItemID = EIP.ItemID + LEFT OUTER JOIN PrivateIPAddresses AS PIP ON PIP.ItemID = SI.ItemID AND PIP.IsPrimary = 1 + WHERE ' + @condition + ' +) + +INSERT INTO @Items +SELECT ItemID FROM TempItems +WHERE TempItems.Row BETWEEN @StartRow + 1 and @StartRow + @MaximumRows + +SELECT + SI.ItemID, + SI.ItemName, + SI.PackageID, + P.PackageName, + P.UserID, + U.Username, + + EIP.ExternalIP, + PIP.IPAddress +FROM @Items AS TSI +INNER JOIN ServiceItems AS SI ON TSI.ItemID = SI.ItemID +INNER JOIN Packages AS P ON SI.PackageID = P.PackageID +INNER JOIN Users AS U ON P.UserID = U.UserID +LEFT OUTER JOIN ( + SELECT PIP.ItemID, IP.ExternalIP FROM PackageIPAddresses AS PIP + INNER JOIN IPAddresses AS IP ON PIP.AddressID = IP.AddressID + WHERE PIP.IsPrimary = 1 AND IP.PoolID = 3 -- external IP addresses +) AS EIP ON SI.ItemID = EIP.ItemID +LEFT OUTER JOIN PrivateIPAddresses AS PIP ON PIP.ItemID = SI.ItemID AND PIP.IsPrimary = 1 +' + +--print @sql + +exec sp_executesql @sql, N'@PackageID int, @StartRow int, @MaximumRows int, @Recursive bit', +@PackageID, @StartRow, @MaximumRows, @Recursive + +RETURN +GO + + +--ES OWA Editing +IF NOT EXISTS (SELECT * FROM SYS.TABLES WHERE name = 'EnterpriseFoldersOwaPermissions') +CREATE TABLE EnterpriseFoldersOwaPermissions +( + ID INT IDENTITY(1,1) NOT NULL PRIMARY KEY, + ItemID INT NOT NULL, + FolderID INT NOT NULL, + AccountID INT NOT NULL +) +GO + +IF EXISTS (SELECT * FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS WHERE CONSTRAINT_NAME ='FK_EnterpriseFoldersOwaPermissions_AccountId') +ALTER TABLE [dbo].[EnterpriseFoldersOwaPermissions] +DROP CONSTRAINT [FK_EnterpriseFoldersOwaPermissions_AccountId] +GO + +ALTER TABLE [dbo].[EnterpriseFoldersOwaPermissions] WITH CHECK ADD CONSTRAINT [FK_EnterpriseFoldersOwaPermissions_AccountId] FOREIGN KEY([AccountID]) +REFERENCES [dbo].[ExchangeAccounts] ([AccountID]) +ON DELETE CASCADE +GO + +IF EXISTS (SELECT * FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS WHERE CONSTRAINT_NAME ='FK_EnterpriseFoldersOwaPermissions_FolderId') +ALTER TABLE [dbo].[EnterpriseFoldersOwaPermissions] +DROP CONSTRAINT [FK_EnterpriseFoldersOwaPermissions_FolderId] +GO + +ALTER TABLE [dbo].[EnterpriseFoldersOwaPermissions] WITH CHECK ADD CONSTRAINT [FK_EnterpriseFoldersOwaPermissions_FolderId] FOREIGN KEY([FolderID]) +REFERENCES [dbo].[EnterpriseFolders] ([EnterpriseFolderID]) +ON DELETE CASCADE +GO + + + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'DeleteAllEnterpriseFolderOwaUsers') +DROP PROCEDURE DeleteAllEnterpriseFolderOwaUsers +GO +CREATE PROCEDURE [dbo].[DeleteAllEnterpriseFolderOwaUsers] +( + @ItemID int, + @FolderID int +) +AS +DELETE FROM EnterpriseFoldersOwaPermissions +WHERE ItemId = @ItemID AND FolderID = @FolderID +GO + + + + + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'AddEnterpriseFolderOwaUser') +DROP PROCEDURE AddEnterpriseFolderOwaUser +GO +CREATE PROCEDURE [dbo].[AddEnterpriseFolderOwaUser] +( + @ESOwsaUserId INT OUTPUT, + @ItemID INT, + @FolderID INT, + @AccountID INT +) +AS +INSERT INTO EnterpriseFoldersOwaPermissions +( + ItemID , + FolderID, + AccountID +) +VALUES +( + @ItemID, + @FolderID, + @AccountID +) + +SET @ESOwsaUserId = SCOPE_IDENTITY() + +RETURN +GO + + + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'GetEnterpriseFolderOwaUsers') +DROP PROCEDURE GetEnterpriseFolderOwaUsers +GO +CREATE PROCEDURE [dbo].[GetEnterpriseFolderOwaUsers] +( + @ItemID INT, + @FolderID INT +) +AS +SELECT + EA.AccountID, + EA.ItemID, + EA.AccountType, + EA.AccountName, + EA.DisplayName, + EA.PrimaryEmailAddress, + EA.MailEnabledPublicFolder, + EA.MailboxPlanId, + EA.SubscriberNumber, + EA.UserPrincipalName + FROM EnterpriseFoldersOwaPermissions AS EFOP + LEFT JOIN ExchangeAccounts AS EA ON EA.AccountID = EFOP.AccountID + WHERE EFOP.ItemID = @ItemID AND EFOP.FolderID = @FolderID +GO + + + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'GetEnterpriseFolderId') +DROP PROCEDURE GetEnterpriseFolderId +GO +CREATE PROCEDURE [dbo].[GetEnterpriseFolderId] +( + @ItemID INT, + @FolderName varchar(max) +) +AS +SELECT TOP 1 + EnterpriseFolderID + FROM EnterpriseFolders + WHERE ItemId = @ItemID AND FolderName = @FolderName +GO + + + + + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'GetUserEnterpriseFolderWithOwaEditPermission') +DROP PROCEDURE GetUserEnterpriseFolderWithOwaEditPermission +GO +CREATE PROCEDURE [dbo].[GetUserEnterpriseFolderWithOwaEditPermission] +( + @ItemID INT, + @AccountID INT +) +AS +SELECT + EF.FolderName + FROM EnterpriseFoldersOwaPermissions AS EFOP + LEFT JOIN [dbo].[EnterpriseFolders] AS EF ON EF.EnterpriseFolderID = EFOP.FolderID + WHERE EFOP.ItemID = @ItemID AND EFOP.AccountID = @AccountID +GO + + +-- CRM2015 Provider + +IF NOT EXISTS (SELECT * FROM [dbo].[Providers] WHERE [DisplayName] = 'Hosted MS CRM 2015') +BEGIN +INSERT [dbo].[Providers] ([ProviderId], [GroupId], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery]) +VALUES(1205, 24, N'CRM', N'Hosted MS CRM 2015', N'WebsitePanel.Providers.HostedSolution.CRMProvider2015, WebsitePanel.Providers.HostedSolution.Crm2015', N'CRM2011', NULL) +END +GO + +-- RDS Setup Instructions + +IF NOT EXISTS (SELECT * FROM [dbo].[UserSettings] WHERE [UserID] = 1 AND [SettingsName]= N'RDSSetupLetter' AND [PropertyName]= N'CC' ) +BEGIN +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'RDSSetupLetter', N'CC', N'support@HostingCompany.com') +END +GO +IF NOT EXISTS (SELECT * FROM [dbo].[UserSettings] WHERE [UserID] = 1 AND [SettingsName]= N'RDSSetupLetter' AND [PropertyName]= N'From' ) +BEGIN +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'RDSSetupLetter', N'From', N'support@HostingCompany.com') +END +GO + +DECLARE @RDSSetupLetterHtmlBody nvarchar(2500) + +Set @RDSSetupLetterHtmlBody = N' + + RDS Setup Information + + + +
+ + +
+ RDS Setup Information +
+
+'; + +IF NOT EXISTS (SELECT * FROM [dbo].[UserSettings] WHERE [UserID] = 1 AND [SettingsName]= N'RDSSetupLetter' AND [PropertyName]= N'HtmlBody' ) +BEGIN +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'RDSSetupLetter', N'HtmlBody', @RDSSetupLetterHtmlBody) +END +ELSE +UPDATE [dbo].[UserSettings] SET [PropertyValue] = @RDSSetupLetterHtmlBody WHERE [UserID] = 1 AND [SettingsName]= N'RDSSetupLetter' AND [PropertyName]= N'HtmlBody' +GO + + +IF NOT EXISTS (SELECT * FROM [dbo].[UserSettings] WHERE [UserID] = 1 AND [SettingsName]= N'RDSSetupLetter' AND [PropertyName]= N'Priority' ) +BEGIN +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'RDSSetupLetter', N'Priority', N'Normal') +END +GO +IF NOT EXISTS (SELECT * FROM [dbo].[UserSettings] WHERE [UserID] = 1 AND [SettingsName]= N'RDSSetupLetter' AND [PropertyName]= N'Subject' ) +BEGIN +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'RDSSetupLetter', N'Subject', N'RDS setup') +END +GO + +DECLARE @RDSSetupLetterTextBody nvarchar(2500) + +Set @RDSSetupLetterTextBody = N'================================= + RDS Setup Information +================================= + +Hello #user.FirstName#, + + +Please, find below RDS setup instructions. + +If you have any questions, feel free to contact our support department at any time. + +Best regards' + +IF NOT EXISTS (SELECT * FROM [dbo].[UserSettings] WHERE [UserID] = 1 AND [SettingsName]= N'RDSSetupLetter' AND [PropertyName]= N'TextBody' ) +BEGIN +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'RDSSetupLetter', N'TextBody', @RDSSetupLetterTextBody) +END +ELSE +UPDATE [dbo].[UserSettings] SET [PropertyValue] = @RDSSetupLetterTextBody WHERE [UserID] = 1 AND [SettingsName]= N'RDSSetupLetter' AND [PropertyName]= N'TextBody' +GO + +IF NOT EXISTS (SELECT * FROM [dbo].[ResourceGroups] WHERE GroupName = 'Sharepoint Foundation Server') +BEGIN + DECLARE @group_order AS INT + DECLARE @group_controller AS NVARCHAR(1000) + DECLARE @group_id AS INT + DECLARE @provider_id AS INT + + UPDATE [dbo].[ResourceGroups] SET GroupName = 'Sharepoint Foundation Server' WHERE GroupName = 'Hosted Sharepoint' + SELECT @group_order = GroupOrder, @group_controller = GroupController FROM [dbo].[ResourceGroups] WHERE GroupName = 'Sharepoint Foundation Server' + SELECT TOP 1 @group_id = GroupId + 1 From [dbo].[ResourceGroups] ORDER BY GroupID DESC + SELECT TOP 1 @provider_id = ProviderId + 1 From [dbo].[Providers] ORDER BY ProviderID DESC + UPDATE [dbo].[ResourceGroups] SET GroupOrder = GroupOrder + 1 WHERE GroupOrder > @group_order + INSERT INTO [dbo].[ResourceGroups] (GroupID, GroupName, GroupOrder, GroupController, ShowGroup) VALUES (@group_id, 'Sharepoint Server', @group_order + 1, @group_controller, 1) + INSERT INTO [dbo].[Providers] (ProviderID, GroupID, ProviderName, DisplayName, ProviderType, EditorControl, DisableAutoDiscovery) + (SELECT @provider_id, @group_id, ProviderName, DisplayName, ProviderType, EditorControl, DisableAutoDiscovery FROM [dbo].[Providers] WHERE ProviderName = 'HostedSharePoint2013') + + INSERT INTO [dbo].[Quotas] (QuotaID, GroupID, QuotaOrder, QuotaName, QuotaDescription, QuotaTypeID, ServiceQuota) + VALUES (550, @group_id, 1, 'HostedSharePointServer.Sites', 'SharePoint Site Collections', 2, 0) + INSERT INTO [dbo].[Quotas] (QuotaID, GroupID, QuotaOrder, QuotaName, QuotaDescription, QuotaTypeID, ServiceQuota) + VALUES (551, @group_id, 2, 'HostedSharePointServer.MaxStorage', 'Max site storage, MB', 3, 0) + INSERT INTO [dbo].[Quotas] (QuotaID, GroupID, QuotaOrder, QuotaName, QuotaDescription, QuotaTypeID, ServiceQuota) + VALUES (552, @group_id, 3, 'HostedSharePointServer.UseSharedSSL', 'Use shared SSL Root', 1, 0) +END + +GO + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'GetLyncUsers') +DROP PROCEDURE GetLyncUsers +GO + +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + +CREATE PROCEDURE [dbo].[GetLyncUsers] +( + @ItemID int, + @SortColumn nvarchar(40), + @SortDirection nvarchar(20), + @StartRow int, + @Count int +) +AS + +CREATE TABLE #TempLyncUsers +( + [ID] [int] IDENTITY(1,1) NOT NULL, + [AccountID] [int], + [ItemID] [int] NOT NULL, + [AccountName] [nvarchar](300) NOT NULL, + [DisplayName] [nvarchar](300) NOT NULL, + [UserPrincipalName] [nvarchar](300) NULL, + [SipAddress] [nvarchar](300) NULL, + [SamAccountName] [nvarchar](100) NULL, + [LyncUserPlanId] [int] NOT NULL, + [LyncUserPlanName] [nvarchar] (300) NOT NULL, +) + +DECLARE @condition nvarchar(700) +SET @condition = '' + +IF (@SortColumn = 'DisplayName') +BEGIN + SET @condition = 'ORDER BY ea.DisplayName' +END + +IF (@SortColumn = 'UserPrincipalName') +BEGIN + SET @condition = 'ORDER BY ea.UserPrincipalName' +END + +IF (@SortColumn = 'SipAddress') +BEGIN + SET @condition = 'ORDER BY ou.SipAddress' +END + +IF (@SortColumn = 'LyncUserPlanName') +BEGIN + SET @condition = 'ORDER BY lp.LyncUserPlanName' +END + +DECLARE @sql nvarchar(3500) + +set @sql = ' + INSERT INTO + #TempLyncUsers + SELECT + ea.AccountID, + ea.ItemID, + ea.AccountName, + ea.DisplayName, + ea.UserPrincipalName, + ou.SipAddress, + ea.SamAccountName, + ou.LyncUserPlanId, + lp.LyncUserPlanName + FROM + ExchangeAccounts ea + INNER JOIN + LyncUsers ou + INNER JOIN + LyncUserPlans lp + ON + ou.LyncUserPlanId = lp.LyncUserPlanId + ON + ea.AccountID = ou.AccountID + WHERE + ea.ItemID = @ItemID ' + @condition + +exec sp_executesql @sql, N'@ItemID int',@ItemID + +DECLARE @RetCount int +SELECT @RetCount = COUNT(ID) FROM #TempLyncUsers + +IF (@SortDirection = 'ASC') +BEGIN + SELECT * FROM #TempLyncUsers + WHERE ID > @StartRow AND ID <= (@StartRow + @Count) +END +ELSE +BEGIN + IF @SortColumn <> '' AND @SortColumn IS NOT NULL + BEGIN + IF (@SortColumn = 'DisplayName') + BEGIN + SELECT * FROM #TempLyncUsers + WHERE ID >@RetCount - @Count - @StartRow AND ID <= @RetCount- @StartRow ORDER BY DisplayName DESC + END + IF (@SortColumn = 'UserPrincipalName') + BEGIN + SELECT * FROM #TempLyncUsers + WHERE ID >@RetCount - @Count - @StartRow AND ID <= @RetCount- @StartRow ORDER BY UserPrincipalName DESC + END + + IF (@SortColumn = 'SipAddress') + BEGIN + SELECT * FROM #TempLyncUsers + WHERE ID >@RetCount - @Count - @StartRow AND ID <= @RetCount- @StartRow ORDER BY SipAddress DESC + END + + IF (@SortColumn = 'LyncUserPlanName') + BEGIN + SELECT * FROM #TempLyncUsers + WHERE ID >@RetCount - @Count - @StartRow AND ID <= @RetCount- @StartRow ORDER BY LyncUserPlanName DESC + END + END + ELSE + BEGIN + SELECT * FROM #TempLyncUsers + WHERE ID >@RetCount - @Count - @StartRow AND ID <= @RetCount- @StartRow ORDER BY UserPrincipalName DESC + END +END + +DROP TABLE #TempLyncUsers + +GO + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'SearchOrganizationAccounts') +DROP PROCEDURE SearchOrganizationAccounts +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO + +CREATE PROCEDURE [dbo].[SearchOrganizationAccounts] +( + @ActorID int, + @ItemID int, + @FilterColumn nvarchar(50) = '', + @FilterValue nvarchar(50) = '', + @SortColumn nvarchar(50), + @IncludeMailboxes bit +) +AS +DECLARE @PackageID int +SELECT @PackageID = PackageID FROM ServiceItems +WHERE ItemID = @ItemID + +-- check rights +IF dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 +RAISERROR('You are not allowed to access this package', 16, 1) + +-- start +DECLARE @condition nvarchar(700) +SET @condition = ' +(EA.AccountType = 7 OR (EA.AccountType = 1 AND @IncludeMailboxes = 1) ) +AND EA.ItemID = @ItemID +' + +IF @FilterColumn <> '' AND @FilterColumn IS NOT NULL +AND @FilterValue <> '' AND @FilterValue IS NOT NULL +SET @condition = @condition + ' AND ' + @FilterColumn + ' LIKE ''' + @FilterValue + '''' + +IF @SortColumn IS NULL OR @SortColumn = '' +SET @SortColumn = 'EA.DisplayName ASC' + +DECLARE @sql nvarchar(3500) + +set @sql = ' +SELECT + EA.AccountID, + EA.ItemID, + EA.AccountType, + EA.AccountName, + EA.DisplayName, + EA.PrimaryEmailAddress, + EA.SubscriberNumber, + EA.UserPrincipalName, + (CASE WHEN LU.AccountID IS NULL THEN ''false'' ELSE ''true'' END) as IsLyncUser +FROM ExchangeAccounts AS EA +LEFT JOIN LyncUsers AS LU +ON LU.AccountID = EA.AccountID +WHERE ' + @condition + +print @sql + +exec sp_executesql @sql, N'@ItemID int, @IncludeMailboxes bit', +@ItemID, @IncludeMailboxes + +RETURN + +GO + + +-- RDS GPO + +IF NOT EXISTS(SELECT * FROM SYS.TABLES WHERE name = 'RDSServerSettings') +CREATE TABLE [dbo].[RDSServerSettings]( + [RdsServerId] [int] NOT NULL, + [SettingsName] [nvarchar](50) COLLATE Latin1_General_CI_AS NOT NULL, + [PropertyName] [nvarchar](50) COLLATE Latin1_General_CI_AS NOT NULL, + [PropertyValue] [ntext] COLLATE Latin1_General_CI_AS NULL, + [ApplyUsers] [BIT] NOT NULL, + [ApplyAdministrators] [BIT] NOT NULL + CONSTRAINT [PK_RDSServerSettings] PRIMARY KEY CLUSTERED +( + [RdsServerId] ASC, + [SettingsName] ASC, + [PropertyName] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +) + +GO + + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'GetRDSServerSettings') +DROP PROCEDURE GetRDSServerSettings +GO +CREATE PROCEDURE GetRDSServerSettings +( + @ServerId int, + @SettingsName nvarchar(50) +) +AS + SELECT RDSServerId, PropertyName, PropertyValue, ApplyUsers, ApplyAdministrators + FROM RDSServerSettings + WHERE RDSServerId = @ServerId AND SettingsName = @SettingsName +GO + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'DeleteRDSServerSettings') +DROP PROCEDURE DeleteRDSServerSettings +GO +CREATE PROCEDURE DeleteRDSServerSettings +( + @ServerId int +) +AS + DELETE FROM RDSServerSettings WHERE RDSServerId = @ServerId +GO + + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'UpdateRDSServerSettings') +DROP PROCEDURE UpdateRDSServerSettings +GO +CREATE PROCEDURE UpdateRDSServerSettings +( + @ServerId int, + @SettingsName nvarchar(50), + @Xml ntext +) +AS + +BEGIN TRAN +DECLARE @idoc int +EXEC sp_xml_preparedocument @idoc OUTPUT, @xml + +DELETE FROM RDSServerSettings +WHERE RDSServerId = @ServerId AND SettingsName = @SettingsName + +INSERT INTO RDSServerSettings +( + RDSServerId, + SettingsName, + ApplyUsers, + ApplyAdministrators, + PropertyName, + PropertyValue +) +SELECT + @ServerId, + @SettingsName, + ApplyUsers, + ApplyAdministrators, + PropertyName, + PropertyValue +FROM OPENXML(@idoc, '/properties/property',1) WITH +( + PropertyName nvarchar(50) '@name', + PropertyValue ntext '@value', + ApplyUsers BIT '@applyUsers', + ApplyAdministrators BIT '@applyAdministrators' +) as PV + +exec sp_xml_removedocument @idoc + +COMMIT TRAN + +RETURN + +GO + + +IF EXISTS (SELECT * FROM ResourceGroups WHERE GroupName = 'SharePoint') +BEGIN + DECLARE @group_id INT + SELECT @group_id = GroupId FROM ResourceGroups WHERE GroupName = 'SharePoint' + DELETE FROM Providers WHERE GroupID = @group_id + DELETE FROM Quotas WHERE GroupID = @group_id + DELETE FROM VirtualGroups WHERE GroupID = @group_id + DELETE FROM ServiceItemTypes WHERE GroupID = @group_id + DELETE FROM ResourceGroups WHERE GroupID = @group_id +END + +GO + +IF NOT EXISTS (SELECT * FROM [dbo].[ServiceItemTypes] WHERE DisplayName = 'SharePointFoundationSiteCollection') +BEGIN + DECLARE @group_id AS INT + DECLARE @item_type_id INT + SELECT TOP 1 @item_type_id = ItemTypeId + 1 FROM [dbo].[ServiceItemTypes] ORDER BY ItemTypeId DESC + UPDATE [dbo].[ServiceItemTypes] SET DisplayName = 'SharePointFoundationSiteCollection' WHERE DisplayName = 'SharePointSiteCollection' + SELECT @group_id = GroupId FROM [dbo].[ResourceGroups] WHERE GroupName = 'Sharepoint Server' + + INSERT INTO [dbo].[ServiceItemTypes] (ItemTypeId, GroupId, DisplayName, TypeName, TypeOrder, CalculateDiskSpace, CalculateBandwidth, Suspendable, Disposable, Searchable, Importable, Backupable) + (SELECT TOP 1 @item_type_id, @group_id, 'SharePointSiteCollection', TypeName, 100, CalculateDiskSpace, CalculateBandwidth, Suspendable, Disposable, Searchable, Importable, Backupable FROM [dbo].[ServiceItemTypes] WHERE DisplayName = 'SharePointFoundationSiteCollection') +END + +GO + +UPDATE [dbo].[Quotas] SET GroupID = 45 WHERE QuotaName = 'EnterpriseStorage.DriveMaps' +GO + + +UPDATE [dbo].[ResourceGroups] SET GroupName = 'Sharepoint Enterprise Server' WHERE GroupName = 'Sharepoint Server' +GO + +UPDATE [dbo].[ResourceGroups] SET GroupController = 'WebsitePanel.EnterpriseServer.HostedSharePointServerEntController' WHERE GroupName = 'Sharepoint Enterprise Server' +GO + +IF NOT EXISTS (SELECT * FROM [dbo].[Providers] WHERE [DisplayName] = 'Hosted SharePoint Enterprise 2013') +BEGIN +DECLARE @provider_id AS INT +DECLARE @group_id AS INT +SELECT @group_id = GroupId FROM [dbo].[ResourceGroups] WHERE GroupName = 'Sharepoint Enterprise Server' +SELECT TOP 1 @provider_id = ProviderId + 1 From [dbo].[Providers] ORDER BY ProviderID DESC +INSERT [dbo].[Providers] ([ProviderID], [GroupID], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery]) +VALUES (@provider_id, @group_id, N'HostedSharePoint2013Ent', N'Hosted SharePoint Enterprise 2013', N'WebsitePanel.Providers.HostedSolution.HostedSharePointServer2013Ent, WebsitePanel.Providers.HostedSolution.SharePoint2013Ent', N'HostedSharePoint30', NULL) +END +GO + +UPDATE [dbo].[Quotas] SET QuotaName = 'HostedSharePointEnterprise.Sites' WHERE QuotaId = 550 +GO + +UPDATE [dbo].[Quotas] SET QuotaName = 'HostedSharePointEnterprise.MaxStorage' WHERE QuotaId = 551 +GO + +UPDATE [dbo].[Quotas] SET QuotaName = 'HostedSharePointEnterprise.UseSharedSSL' WHERE QuotaId = 552 +GO + +UPDATE [dbo].[ServiceItemTypes] SET DisplayName = 'SharePointEnterpriseSiteCollection' WHERE DisplayName = 'SharePointSiteCollection' +GO + + +IF EXISTS (SELECT * FROM Providers WHERE ProviderName = 'HostedSharePoint2013' AND GroupID IN (Select GroupID FROM ResourceGroups WHERE GroupName = 'Sharepoint Enterprise Server')) +BEGIN + DECLARE @group_id INT + SELECT @group_id = GroupId FROM ResourceGroups WHERE GroupName = 'Sharepoint Enterprise Server' + DELETE FROM Providers WHERE ProviderName = 'HostedSharePoint2013' AND GroupID = @group_id +END + +GO + + +ALTER PROCEDURE [dbo].[AddServiceItem] +( + @ActorID int, + @PackageID int, + @ServiceID int, + @ItemName nvarchar(500), + @ItemTypeName nvarchar(200), + @ItemID int OUTPUT, + @XmlProperties ntext, + @CreatedDate datetime +) +AS +BEGIN TRAN + +-- check rights +IF dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 +RAISERROR('You are not allowed to access this package', 16, 1) + +-- get GroupID +DECLARE @GroupID int +SELECT + @GroupID = PROV.GroupID +FROM Services AS S +INNER JOIN Providers AS PROV ON S.ProviderID = PROV.ProviderID +WHERE S.ServiceID = @ServiceID + +DECLARE @ItemTypeID int +SELECT @ItemTypeID = ItemTypeID FROM ServiceItemTypes +WHERE TypeName = @ItemTypeName +AND ((@GroupID IS NULL) OR (@GroupID IS NOT NULL AND GroupID = @GroupID)) + +-- Fix to allow plans assigned to serveradmin +IF (@ItemTypeName = 'WebsitePanel.Providers.HostedSolution.Organization, WebsitePanel.Providers.Base') +BEGIN + IF NOT EXISTS (SELECT * FROM ServiceItems WHERE PackageID = 1) + BEGIN + INSERT INTO ServiceItems (PackageID, ItemTypeID,ServiceID,ItemName,CreatedDate) + VALUES(1, @ItemTypeID, @ServiceID, 'System', @CreatedDate) + + DECLARE @TempItemID int + + SET @TempItemID = SCOPE_IDENTITY() + INSERT INTO ExchangeOrganizations (ItemID, OrganizationID) + VALUES(@TempItemID, 'System') + END +END + + + +-- add item +INSERT INTO ServiceItems +( + PackageID, + ServiceID, + ItemName, + ItemTypeID, + CreatedDate +) +VALUES +( + @PackageID, + @ServiceID, + @ItemName, + @ItemTypeID, + @CreatedDate +) + +SET @ItemID = SCOPE_IDENTITY() + +DECLARE @idoc int +--Create an internal representation of the XML document. +EXEC sp_xml_preparedocument @idoc OUTPUT, @XmlProperties + +-- Execute a SELECT statement that uses the OPENXML rowset provider. +DELETE FROM ServiceItemProperties +WHERE ItemID = @ItemID + +CREATE TABLE #TempTable( + ItemID int, + PropertyName nvarchar(50), + PropertyValue nvarchar(3000)) + +INSERT INTO #TempTable (ItemID, PropertyName, PropertyValue) +SELECT + @ItemID, + PropertyName, + PropertyValue +FROM OPENXML(@idoc, '/properties/property',1) WITH +( + PropertyName nvarchar(50) '@name', + PropertyValue nvarchar(3000) '@value' +) as PV + +-- Move data from temp table to real table +INSERT INTO ServiceItemProperties +( + ItemID, + PropertyName, + PropertyValue +) +SELECT + ItemID, + PropertyName, + PropertyValue +FROM #TempTable + +DROP TABLE #TempTable + +-- remove document +exec sp_xml_removedocument @idoc + +COMMIT TRAN +RETURN +GO + +UPDATE [dbo].[ServiceItemTypes] SET TypeName ='WebsitePanel.Providers.SharePoint.SharePointEnterpriseSiteCollection, WebsitePanel.Providers.Base' WHERE DisplayName = 'SharePointEnterpriseSiteCollection' +GO + +-- USER PASSWORD EXPIRATION NOTIFICATION tasks + +IF NOT EXISTS (SELECT * FROM [dbo].[ScheduleTasks] WHERE [TaskID] = N'SCHEDULE_TASK_USER_PASSWORD_EXPIRATION_NOTIFICATION') +BEGIN +INSERT [dbo].[ScheduleTasks] ([TaskID], [TaskType], [RoleID]) VALUES (N'SCHEDULE_TASK_USER_PASSWORD_EXPIRATION_NOTIFICATION', N'WebsitePanel.EnterpriseServer.UserPasswordExpirationNotificationTask, WebsitePanel.EnterpriseServer.Code', 1) +END +GO + +IF NOT EXISTS (SELECT * FROM [dbo].[ScheduleTaskViewConfiguration] WHERE [TaskID] = N'SCHEDULE_TASK_USER_PASSWORD_EXPIRATION_NOTIFICATION') +BEGIN +INSERT [dbo].[ScheduleTaskViewConfiguration] ([TaskID], [ConfigurationID], [Environment], [Description]) VALUES (N'SCHEDULE_TASK_USER_PASSWORD_EXPIRATION_NOTIFICATION', N'ASP_NET', N'ASP.NET', N'~/DesktopModules/WebsitePanel/ScheduleTaskControls/UserPasswordExpirationNotificationView.ascx') +END +GO + +IF NOT EXISTS (SELECT * FROM [dbo].[ScheduleTaskParameters] WHERE [TaskID] = N'SCHEDULE_TASK_USER_PASSWORD_EXPIRATION_NOTIFICATION' AND [ParameterID]= N'DAYS_BEFORE_EXPIRATION' ) +BEGIN +INSERT [dbo].[ScheduleTaskParameters] ([TaskID], [ParameterID], [DataTypeID], [DefaultValue], [ParameterOrder]) VALUES (N'SCHEDULE_TASK_USER_PASSWORD_EXPIRATION_NOTIFICATION', N'DAYS_BEFORE_EXPIRATION', N'String', NULL, 1) +END +GO + + +-- USER PASSWORD EXPIRATION EMAIL TEMPLATE + +IF NOT EXISTS (SELECT * FROM [dbo].[UserSettings] WHERE [UserID] = 1 AND [SettingsName]= N'UserPasswordExpirationLetter' AND [PropertyName]= N'From' ) +BEGIN +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'UserPasswordExpirationLetter', N'From', N'support@HostingCompany.com') +END +GO + +DECLARE @UserPasswordExpirationLetterHtmlBody nvarchar(2500) + +Set @UserPasswordExpirationLetterHtmlBody = N' + + Password expiration notification + + + +
+
+ +
+

Password expiration notification

+ + +

+Hello #user.FirstName#, +

+
+ +

+Your password expiration date is #user.PasswordExpirationDateTime#. You can reset your own password by visiting the following page: +

+ +#passwordResetLink# + + +

+If you have any questions regarding your hosting account, feel free to contact our support department at any time. +

+ +

+Best regards +

+
+'; + +IF NOT EXISTS (SELECT * FROM [dbo].[UserSettings] WHERE [UserID] = 1 AND [SettingsName]= N'UserPasswordExpirationLetter' AND [PropertyName]= N'HtmlBody' ) +BEGIN +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'UserPasswordExpirationLetter', N'HtmlBody', @UserPasswordExpirationLetterHtmlBody) +END +ELSE +UPDATE [dbo].[UserSettings] SET [PropertyValue] = @UserPasswordExpirationLetterHtmlBody WHERE [UserID] = 1 AND [SettingsName]= N'UserPasswordExpirationLetter' AND [PropertyName]= N'HtmlBody' +GO + + +IF NOT EXISTS (SELECT * FROM [dbo].[UserSettings] WHERE [UserID] = 1 AND [SettingsName]= N'UserPasswordExpirationLetter' AND [PropertyName]= N'Priority' ) +BEGIN +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'UserPasswordExpirationLetter', N'Priority', N'Normal') +END +GO +IF NOT EXISTS (SELECT * FROM [dbo].[UserSettings] WHERE [UserID] = 1 AND [SettingsName]= N'UserPasswordExpirationLetter' AND [PropertyName]= N'Subject' ) +BEGIN +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'UserPasswordExpirationLetter', N'Subject', N'Password expiration notification') +END +GO +IF NOT EXISTS (SELECT * FROM [dbo].[UserSettings] WHERE [UserID] = 1 AND [SettingsName]= N'UserPasswordExpirationLetter' AND [PropertyName]= N'LogoUrl' ) +BEGIN +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'UserPasswordExpirationLetter', N'LogoUrl', N'https://controlpanel.virtuworks.net/App_Themes/Default/Images/logo.png') +END +GO + + +DECLARE @UserPasswordExpirationLetterTextBody nvarchar(2500) + +Set @UserPasswordExpirationLetterTextBody = N'========================================= + Password expiration notification +========================================= + + +Hello #user.FirstName#, + + +Your password expiration date is #user.PasswordExpirationDateTime#. You can reset your own password by visiting the following page: + +#passwordResetLink# + +If you have any questions regarding your hosting account, feel free to contact our support department at any time. + +Best regards' + +IF NOT EXISTS (SELECT * FROM [dbo].[UserSettings] WHERE [UserID] = 1 AND [SettingsName]= N'UserPasswordExpirationLetter' AND [PropertyName]= N'TextBody' ) +BEGIN +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'UserPasswordExpirationLetter', N'TextBody', @UserPasswordExpirationLetterTextBody) +END +ELSE +UPDATE [dbo].[UserSettings] SET [PropertyValue] = @UserPasswordExpirationLetterTextBody WHERE [UserID] = 1 AND [SettingsName]= N'UserPasswordExpirationLetter' AND [PropertyName]= N'TextBody' +GO + + +-- USER PASSWORD RESET EMAIL TEMPLATE + + + +IF NOT EXISTS (SELECT * FROM [dbo].[UserSettings] WHERE [UserID] = 1 AND [SettingsName]= N'UserPasswordResetLetter' AND [PropertyName]= N'From' ) +BEGIN +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'UserPasswordResetLetter', N'From', N'support@HostingCompany.com') +END +GO + +DECLARE @UserPasswordResetLetterHtmlBody nvarchar(2500) + +Set @UserPasswordResetLetterHtmlBody = N' + + Password reset notification + + + +
+
+ +
+

Password reset notification

+ + +

+Hello #user.FirstName#, +

+
+ +

+We received a request to reset the password for your account. If you made this request, click the link below. If you did not make this request, you can ignore this email. +

+ +#passwordResetLink# + + +

+If you have any questions regarding your hosting account, feel free to contact our support department at any time. +

+ +

+Best regards +

+
+'; + +IF NOT EXISTS (SELECT * FROM [dbo].[UserSettings] WHERE [UserID] = 1 AND [SettingsName]= N'UserPasswordResetLetter' AND [PropertyName]= N'HtmlBody' ) +BEGIN +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'UserPasswordResetLetter', N'HtmlBody', @UserPasswordResetLetterHtmlBody) +END +ELSE +UPDATE [dbo].[UserSettings] SET [PropertyValue] = @UserPasswordResetLetterHtmlBody WHERE [UserID] = 1 AND [SettingsName]= N'UserPasswordResetLetter' AND [PropertyName]= N'HtmlBody' +GO + + +IF NOT EXISTS (SELECT * FROM [dbo].[UserSettings] WHERE [UserID] = 1 AND [SettingsName]= N'UserPasswordResetLetter' AND [PropertyName]= N'Priority' ) +BEGIN +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'UserPasswordResetLetter', N'Priority', N'Normal') +END +GO +IF NOT EXISTS (SELECT * FROM [dbo].[UserSettings] WHERE [UserID] = 1 AND [SettingsName]= N'UserPasswordResetLetter' AND [PropertyName]= N'Subject' ) +BEGIN +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'UserPasswordResetLetter', N'Subject', N'Password reset notification') +END +GO +IF NOT EXISTS (SELECT * FROM [dbo].[UserSettings] WHERE [UserID] = 1 AND [SettingsName]= N'UserPasswordResetLetter' AND [PropertyName]= N'LogoUrl' ) +BEGIN +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'UserPasswordResetLetter', N'LogoUrl', N'https://controlpanel.virtuworks.net/App_Themes/Default/Images/logo.png') +END +GO + + +DECLARE @UserPasswordResetLetterTextBody nvarchar(2500) + +Set @UserPasswordResetLetterTextBody = N'========================================= + Password reset notification +========================================= + + +Hello #user.FirstName#, + + +We received a request to reset the password for your account. If you made this request, click the link below. If you did not make this request, you can ignore this email. + +#passwordResetLink# + +If you have any questions regarding your hosting account, feel free to contact our support department at any time. + +Best regards' + +IF NOT EXISTS (SELECT * FROM [dbo].[UserSettings] WHERE [UserID] = 1 AND [SettingsName]= N'UserPasswordResetLetter' AND [PropertyName]= N'TextBody' ) +BEGIN +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'UserPasswordResetLetter', N'TextBody', @UserPasswordResetLetterTextBody) +END +ELSE +UPDATE [dbo].[UserSettings] SET [PropertyValue] = @UserPasswordResetLetterTextBody WHERE [UserID] = 1 AND [SettingsName]= N'UserPasswordResetLetter' AND [PropertyName]= N'TextBody' +GO + + +-- Exchange setup EMAIL TEMPLATE + + + +IF NOT EXISTS (SELECT * FROM [dbo].[UserSettings] WHERE [UserID] = 1 AND [SettingsName]= N'ExchangeMailboxSetupLetter' AND [PropertyName]= N'From' ) +BEGIN +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'ExchangeMailboxSetupLetter', N'From', N'orders@virtuworks.com') +END +GO + +DECLARE @ExchangeMailboxSetupLetterHtmlBody nvarchar(max) + +Set @ExchangeMailboxSetupLetterHtmlBody = N' + + Account Summary Information + + + + + + + + + +
+ + + + + + +
VirtuWorks: Run Your Business In The Cloud
+ + + + + + +
+ + + + + + +
+ + + + + + + + + + + +
+
+ + + + + + + + + +
+ + + + + + + +
+ + + + + + +
+ + +
+ +

+ Hello #Account.DisplayName#, +

+

+ Thanks for choosing VirtuWorks as your Exchange hosting provider. +

+
+ +

User Accounts

+

+ The following user accounts have been created for you. +

+ + + + + + + + + + + + + + + +
Username:#Account.UserPrincipalName#
E-mail:#Account.PrimaryEmailAddress#
Password Reset Url:Click here
+
+

DNS

+

+ In order for us to accept mail for your domain, you will need to point your MX records to: +

+ + + + + + +
#SmtpServer#
+

+ Webmail (OWA, Outlook Web Access)

+

+ https://mail.virtuworks.net/owa +

+

+ Outlook (Windows Clients)

+

+ To configure Outlook 2013 to work with the VirtuWorks servers, please reference: +

+

+ http://www.virtuworks.com/how-to-configure-my-outlook-2010-client-to-work-with-my-velum-hosted-exchange-account/ +

+

+ If you need to download and install the Outlook client:

+ + + + + + + + + + + + + + + + +
Outlook 2013 Client
+ Download URL:Outlook 2013 - 32bit
Outlook 2013 - 64bit
+ KEY:HPN4P-JKC89-VCCWD-24CD2-9P8H7
+ +

+ ActiveSync, iPhone, iPad

+ + + + + + + + + + + + + + + + + +
Server:#ActiveSyncServer#
Domain:#SamDomain#
SSL:must be checked
Your username:#SamUsername#
+ +

Password Changes

+

+ Passwords can be changed at any time using Webmail or the Control Panel.

+

Control Panel

+

+ If you need to change the details of your account, you can easily do this using Control Panel.

+

Support

+

+ You have 2 options, email help@virtuworks.com or use the web interface at http://www.virtuworks.com/support

+ +
+ +
+
+
+ + + + + + +
+ + + + + + +
+ + + + + + + + +
Visit VirtuWorks.com
Learn more about the services VirtuWorks can provide to improve your business.
Privacy Policy
VirtuWorks follows strict guidelines in protecting your privacy. Learn about our Privacy Policy.
Contact Us
Questions? For more information, contact us.
+
+
+
+
+ +'; + +IF NOT EXISTS (SELECT * FROM [dbo].[UserSettings] WHERE [UserID] = 1 AND [SettingsName]= N'ExchangeMailboxSetupLetter' AND [PropertyName]= N'HtmlBody' ) +BEGIN +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'ExchangeMailboxSetupLetter', N'HtmlBody', @ExchangeMailboxSetupLetterHtmlBody) +END +ELSE +UPDATE [dbo].[UserSettings] SET [PropertyValue] = @ExchangeMailboxSetupLetterHtmlBody WHERE [UserID] = 1 AND [SettingsName]= N'ExchangeMailboxSetupLetter' AND [PropertyName]= N'HtmlBody' +GO + + +IF NOT EXISTS (SELECT * FROM [dbo].[UserSettings] WHERE [UserID] = 1 AND [SettingsName]= N'ExchangeMailboxSetupLetter' AND [PropertyName]= N'Priority' ) +BEGIN +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'ExchangeMailboxSetupLetter', N'Priority', N'Normal') +END +GO +IF NOT EXISTS (SELECT * FROM [dbo].[UserSettings] WHERE [UserID] = 1 AND [SettingsName]= N'ExchangeMailboxSetupLetter' AND [PropertyName]= N'Subject' ) +BEGIN +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'ExchangeMailboxSetupLetter', N'Subject', N'Virtuworks Hosted Exchange Mailbox Setup') +END +GO + + +DECLARE @ExchangeMailboxSetupLetterTextBody nvarchar(2500) + +Set @ExchangeMailboxSetupLetterTextBody = N' +Hello #Account.DisplayName#, + +Thanks for choosing VirtuWorks as your Exchange hosting provider. + + +User Accounts + +The following user accounts have been created for you. + +Username: #Account.UserPrincipalName# +E-mail: #Account.PrimaryEmailAddress# + +Password Reset Url: #PswResetUrl# + + + +================================= +DNS +================================= + +In order for us to accept mail for your domain, you will need to point your MX records to: + +#SmtpServer# + +================================= +Webmail (OWA, Outlook Web Access) +================================= + +https://mail.virtuworks.net/owa + +================================= +Outlook (Windows Clients) +================================= + +To configure Outlook 2010 to work with VirtuWorks servers, please reference: + +https://portal.virtuworks.net/whmcs/knowledgebase.php?action=displayarticle&id=2 + +If you need to download and install the Outlook 2010 client: + +Outlook 2010 Download URL: +32 Bit - http://www.virtuworks.net/downloads/Outlook2010-32bit.zip +64 Bit - http://www.virtuworks.net/downloads/Outlook2010-64bit.zip +KEY: HXGFV-DY3HM-4W2BQ-3R7KQ-K8P49 + +================================= +ActiveSync, iPhone, iPad +================================= + +Server: #ActiveSyncServer# +Domain: #SamDomain# +SSL: must be checked +Your username: #SamUsername# + +================================= +Password Changes +================================= + +Passwords can be changed at any time using Webmail or the Control Panel (https://controlpanel.virtuworks.net). + + +================================= +Control Panel +================================= + +If you need to change the details of your account, you can easily do this using the Control Panel (https://controlpanel.virtuworks.net). + + +================================= +Support +================================= + +You have 2 options, email help@virtuworks.com or use the web interface at http://www.virtuworks.com/contact/' + +IF NOT EXISTS (SELECT * FROM [dbo].[UserSettings] WHERE [UserID] = 1 AND [SettingsName]= N'ExchangeMailboxSetupLetter' AND [PropertyName]= N'TextBody' ) +BEGIN +INSERT [dbo].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'ExchangeMailboxSetupLetter', N'TextBody', @ExchangeMailboxSetupLetterTextBody) +END +ELSE +UPDATE [dbo].[UserSettings] SET [PropertyValue] = @ExchangeMailboxSetupLetterTextBody WHERE [UserID] = 1 AND [SettingsName]= N'ExchangeMailboxSetupLetter' AND [PropertyName]= N'TextBody' +GO + + + +-- ORGANIZATION USER PASSWORD RESET TOKENS + + +IF EXISTS (SELECT * FROM SYS.TABLES WHERE name = 'AccessTokens') +DROP TABLE AccessTokens +GO +CREATE TABLE AccessTokens +( + ID INT IDENTITY(1,1) NOT NULL PRIMARY KEY, + AccessTokenGuid UNIQUEIDENTIFIER NOT NULL, + ExpirationDate DATETIME NOT NULL, + AccountID INT NOT NULL , + ItemId INT NOT NULL, + TokenType INT NOT NULL, + SmsResponse varchar(100) +) +GO + +ALTER TABLE [dbo].[AccessTokens] WITH CHECK ADD CONSTRAINT [FK_AccessTokens_UserId] FOREIGN KEY([AccountID]) +REFERENCES [dbo].[ExchangeAccounts] ([AccountID]) +ON DELETE CASCADE +GO + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'AddAccessToken') +DROP PROCEDURE AddAccessToken +GO +CREATE PROCEDURE [dbo].[AddAccessToken] +( + @TokenID INT OUTPUT, + @AccessToken UNIQUEIDENTIFIER, + @ExpirationDate DATETIME, + @AccountID INT, + @ItemId INT, + @TokenType INT +) +AS +INSERT INTO AccessTokens +( + AccessTokenGuid, + ExpirationDate, + AccountID , + ItemId, + TokenType +) +VALUES +( + @AccessToken , + @ExpirationDate , + @AccountID, + @ItemId, + @TokenType +) + +SET @TokenID = SCOPE_IDENTITY() + +RETURN +GO + + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'SetAccessTokenSmsResponse') +DROP PROCEDURE SetAccessTokenSmsResponse +GO +CREATE PROCEDURE [dbo].[SetAccessTokenSmsResponse] +( + @AccessToken UNIQUEIDENTIFIER, + @SmsResponse varchar(100) +) +AS +UPDATE [dbo].[AccessTokens] SET [SmsResponse] = @SmsResponse WHERE [AccessTokenGuid] = @AccessToken +RETURN +GO + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'DeleteAccessToken') +DROP PROCEDURE DeleteAccessToken +GO +CREATE PROCEDURE [dbo].[DeleteAccessToken] +( + @AccessToken UNIQUEIDENTIFIER, + @TokenType INT +) +AS +DELETE FROM AccessTokens +WHERE AccessTokenGuid = @AccessToken AND TokenType = @TokenType +GO + + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'DeleteExpiredAccessTokenTokens') +DROP PROCEDURE DeleteExpiredAccessTokenTokens +GO +CREATE PROCEDURE [dbo].[DeleteExpiredAccessTokenTokens] +AS +DELETE FROM AccessTokens +WHERE ExpirationDate < getdate() +GO + + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'GetAccessTokenByAccessToken') +DROP PROCEDURE GetAccessTokenByAccessToken +GO +CREATE PROCEDURE [dbo].[GetAccessTokenByAccessToken] +( + @AccessToken UNIQUEIDENTIFIER, + @TokenType INT +) +AS +SELECT + ID , + AccessTokenGuid, + ExpirationDate, + AccountID, + ItemId, + TokenType, + SmsResponse + FROM AccessTokens + Where AccessTokenGuid = @AccessToken AND ExpirationDate > getdate() AND TokenType = @TokenType +GO + + +-- ORGANIZATION SETTINGS + + +IF NOT EXISTS (SELECT * FROM SYS.TABLES WHERE name = 'ExchangeOrganizationSettings') +BEGIN + CREATE TABLE ExchangeOrganizationSettings + ( + ItemId INT NOT NULL, + SettingsName nvarchar(100) NOT NULL, + Xml nvarchar(max) NOT NULL + ); + + ALTER TABLE [dbo].[ExchangeOrganizationSettings] WITH CHECK ADD CONSTRAINT [FK_ExchangeOrganizationSettings_ExchangeOrganizations_ItemId] FOREIGN KEY([ItemId]) + REFERENCES [dbo].[ExchangeOrganizations] ([ItemId]) + ON DELETE CASCADE; +END + + + + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'UpdateExchangeOrganizationSettings') +DROP PROCEDURE UpdateExchangeOrganizationSettings +GO +CREATE PROCEDURE [dbo].[UpdateExchangeOrganizationSettings] +( + @ItemId INT , + @SettingsName nvarchar(100) , + @Xml nvarchar(max) +) +AS +IF NOT EXISTS (SELECT * FROM [dbo].[ExchangeOrganizationSettings] WHERE [ItemId] = @ItemId AND [SettingsName]= @SettingsName ) +BEGIN +INSERT [dbo].[ExchangeOrganizationSettings] ([ItemId], [SettingsName], [Xml]) VALUES (@ItemId, @SettingsName, @Xml) +END +ELSE +UPDATE [dbo].[ExchangeOrganizationSettings] SET [Xml] = @Xml WHERE [ItemId] = @ItemId AND [SettingsName]= @SettingsName +GO + + + + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'GetExchangeOrganizationSettings') +DROP PROCEDURE GetExchangeOrganizationSettings +GO +CREATE PROCEDURE [dbo].[GetExchangeOrganizationSettings] +( + @ItemId INT , + @SettingsName nvarchar(100) +) +AS +SELECT + ItemId, + SettingsName, + Xml + +FROM ExchangeOrganizationSettings +Where ItemId = @ItemId AND SettingsName = @SettingsName +GO + + +-- Exchange Account password column removed + +if exists(select * from sys.columns + where Name = N'AccountPassword' and Object_ID = Object_ID(N'ExchangeAccounts')) +begin + ALTER TABLE [ExchangeAccounts] DROP COLUMN [AccountPassword] +end + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'AddExchangeAccount') +DROP PROCEDURE AddExchangeAccount +GO +CREATE PROCEDURE [dbo].[AddExchangeAccount] +( + @AccountID int OUTPUT, + @ItemID int, + @AccountType int, + @AccountName nvarchar(300), + @DisplayName nvarchar(300), + @PrimaryEmailAddress nvarchar(300), + @MailEnabledPublicFolder bit, + @MailboxManagerActions varchar(200), + @SamAccountName nvarchar(100), + @MailboxPlanId int, + @SubscriberNumber nvarchar(32) +) +AS + +INSERT INTO ExchangeAccounts +( + ItemID, + AccountType, + AccountName, + DisplayName, + PrimaryEmailAddress, + MailEnabledPublicFolder, + MailboxManagerActions, + SamAccountName, + MailboxPlanId, + SubscriberNumber, + UserPrincipalName +) +VALUES +( + @ItemID, + @AccountType, + @AccountName, + @DisplayName, + @PrimaryEmailAddress, + @MailEnabledPublicFolder, + @MailboxManagerActions, + @SamAccountName, + @MailboxPlanId, + @SubscriberNumber, + @PrimaryEmailAddress +) + +SET @AccountID = SCOPE_IDENTITY() + +RETURN + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + + + +IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'SearchExchangeAccount') +DROP PROCEDURE SearchExchangeAccount +GO +CREATE PROCEDURE [dbo].[SearchExchangeAccount] +( + @ActorID int, + @AccountType int, + @PrimaryEmailAddress nvarchar(300) +) +AS + +DECLARE @PackageID int +DECLARE @ItemID int +DECLARE @AccountID int + +SELECT + @AccountID = AccountID, + @ItemID = ItemID +FROM ExchangeAccounts +WHERE PrimaryEmailAddress = @PrimaryEmailAddress +AND AccountType = @AccountType + + +-- check space rights +SELECT @PackageID = PackageID FROM ServiceItems +WHERE ItemID = @ItemID + +IF dbo.CheckActorPackageRights(@ActorID, @PackageID) = 0 +RAISERROR('You are not allowed to access this package', 16, 1) + +SELECT + AccountID, + ItemID, + @PackageID AS PackageID, + AccountType, + AccountName, + DisplayName, + PrimaryEmailAddress, + MailEnabledPublicFolder, + MailboxManagerActions, + SamAccountName, + SubscriberNumber, + UserPrincipalName +FROM ExchangeAccounts +WHERE AccountID = @AccountID + +RETURN + + +GO +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER OFF +GO diff --git a/WebsitePanel/Sources/Tools/WebsitePanel.LocalizationToolkit.Wix/WebsitePanel.LocalizationToolkit.Wix.wixproj b/WebsitePanel/Sources/Tools/WebsitePanel.LocalizationToolkit.Wix/WebsitePanel.LocalizationToolkit.Wix.wixproj index 67638bd4..aa98b7c6 100644 --- a/WebsitePanel/Sources/Tools/WebsitePanel.LocalizationToolkit.Wix/WebsitePanel.LocalizationToolkit.Wix.wixproj +++ b/WebsitePanel/Sources/Tools/WebsitePanel.LocalizationToolkit.Wix/WebsitePanel.LocalizationToolkit.Wix.wixproj @@ -3,7 +3,7 @@ Debug x86 - 3.7 + 3.9 3f3f1c39-6719-4862-bb45-4c227f13b821 2.0 WebsitePanel.LocalizationToolkit @@ -63,4 +63,4 @@ --> - \ No newline at end of file + diff --git a/WebsitePanel/Sources/VersionInfo.cs b/WebsitePanel/Sources/VersionInfo.cs index df25dde8..9df3788e 100644 --- a/WebsitePanel/Sources/VersionInfo.cs +++ b/WebsitePanel/Sources/VersionInfo.cs @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.34014 +// Runtime Version:4.0.30319.34209 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/WebsitePanel/Sources/VersionInfo.vb b/WebsitePanel/Sources/VersionInfo.vb index d14bcc16..c5fcfea3 100644 --- a/WebsitePanel/Sources/VersionInfo.vb +++ b/WebsitePanel/Sources/VersionInfo.vb @@ -1,7 +1,7 @@ '------------------------------------------------------------------------------ ' ' This code was generated by a tool. -' Runtime Version:4.0.30319.34014 +' Runtime Version:4.0.30319.34209 ' ' Changes to this file may cause incorrect behavior and will be lost if ' the code is regenerated. diff --git a/WebsitePanel/build-release.bat b/WebsitePanel/build-release.bat index 2ad25172..315aa852 100644 --- a/WebsitePanel/build-release.bat +++ b/WebsitePanel/build-release.bat @@ -1 +1 @@ -%windir%\Microsoft.NET\Framework\v4.0.30319\msbuild.exe build.xml /target:Build /p:BuildConfiguration=Release /p:Version="2.1.0" /p:FileVersion="2.1.0.1" /p:VersionLabel="2.1.0.1" /v:n /fileLogger /m \ No newline at end of file +%windir%\Microsoft.NET\Framework\v4.0.30319\msbuild.exe build.xml /target:Build /p:BuildConfiguration=Release /p:Version="2.1.0" /p:FileVersion="2.1.0.1" /p:VersionLabel="2.1.0.1" /v:n /fileLogger /m diff --git a/WebsitePanel/build.xml b/WebsitePanel/build.xml index 886973e5..1e123f4a 100644 --- a/WebsitePanel/build.xml +++ b/WebsitePanel/build.xml @@ -53,6 +53,7 @@ $(BuildFolder)\LocalizationToolkit $(BuildFolder)\Installer $(BuildFolder)\FixDefaultPublicFolderMailbox + $(BuildFolder)\WiXInstaller @@ -360,11 +361,20 @@ + + + + + + + + + - + - + $(DeployFolder)\Install @@ -384,7 +394,6 @@ $(ToolsFolder)\AWStats.Viewer $(ToolsFolder)\WSPTransportAgent $(ToolsFolder)\FixDefaultPublicFolderMailbox - @@ -640,8 +649,15 @@ + + + + + + + - + @@ -814,10 +830,11 @@ - + + diff --git a/tools/WIX/LuxTasks.dll b/tools/WIX/LuxTasks.dll new file mode 100644 index 00000000..e56f896a Binary files /dev/null and b/tools/WIX/LuxTasks.dll differ diff --git a/tools/WIX/Microsoft.Deployment.Compression.Cab.dll b/tools/WIX/Microsoft.Deployment.Compression.Cab.dll index f5de31ad..9cba0fe6 100644 Binary files a/tools/WIX/Microsoft.Deployment.Compression.Cab.dll and b/tools/WIX/Microsoft.Deployment.Compression.Cab.dll differ diff --git a/tools/WIX/Microsoft.Deployment.Compression.dll b/tools/WIX/Microsoft.Deployment.Compression.dll index 24445732..e7d2f79a 100644 Binary files a/tools/WIX/Microsoft.Deployment.Compression.dll and b/tools/WIX/Microsoft.Deployment.Compression.dll differ diff --git a/tools/WIX/Microsoft.Deployment.Resources.dll b/tools/WIX/Microsoft.Deployment.Resources.dll index 17a9d340..4fe3340f 100644 Binary files a/tools/WIX/Microsoft.Deployment.Resources.dll and b/tools/WIX/Microsoft.Deployment.Resources.dll differ diff --git a/tools/WIX/Microsoft.Deployment.WindowsInstaller.Package.dll b/tools/WIX/Microsoft.Deployment.WindowsInstaller.Package.dll index d509c647..ac8e1bd1 100644 Binary files a/tools/WIX/Microsoft.Deployment.WindowsInstaller.Package.dll and b/tools/WIX/Microsoft.Deployment.WindowsInstaller.Package.dll differ diff --git a/tools/WIX/Microsoft.Deployment.WindowsInstaller.dll b/tools/WIX/Microsoft.Deployment.WindowsInstaller.dll index 0a7d1e99..ebf46ae9 100644 Binary files a/tools/WIX/Microsoft.Deployment.WindowsInstaller.dll and b/tools/WIX/Microsoft.Deployment.WindowsInstaller.dll differ diff --git a/tools/WIX/SetupBuilder.dll b/tools/WIX/SetupBuilder.dll deleted file mode 100644 index 87c02c7d..00000000 Binary files a/tools/WIX/SetupBuilder.dll and /dev/null differ diff --git a/tools/WIX/ThmViewer.exe b/tools/WIX/ThmViewer.exe new file mode 100644 index 00000000..a20d6852 Binary files /dev/null and b/tools/WIX/ThmViewer.exe differ diff --git a/tools/WIX/WixBalExtension.dll b/tools/WIX/WixBalExtension.dll index 6de1915d..c356a711 100644 Binary files a/tools/WIX/WixBalExtension.dll and b/tools/WIX/WixBalExtension.dll differ diff --git a/tools/WIX/WixComPlusExtension.dll b/tools/WIX/WixComPlusExtension.dll new file mode 100644 index 00000000..aaa03d35 Binary files /dev/null and b/tools/WIX/WixComPlusExtension.dll differ diff --git a/tools/WIX/WixCop.exe b/tools/WIX/WixCop.exe index a7015b51..e7f37352 100644 Binary files a/tools/WIX/WixCop.exe and b/tools/WIX/WixCop.exe differ diff --git a/tools/WIX/WixDependencyExtension.dll b/tools/WIX/WixDependencyExtension.dll index 7c1c8af5..68600888 100644 Binary files a/tools/WIX/WixDependencyExtension.dll and b/tools/WIX/WixDependencyExtension.dll differ diff --git a/tools/WIX/WixDifxAppExtension.dll b/tools/WIX/WixDifxAppExtension.dll index 04d337f0..43a9ad2c 100644 Binary files a/tools/WIX/WixDifxAppExtension.dll and b/tools/WIX/WixDifxAppExtension.dll differ diff --git a/tools/WIX/WixDirectXExtension.dll b/tools/WIX/WixDirectXExtension.dll index 26bbc865..7df2235e 100644 Binary files a/tools/WIX/WixDirectXExtension.dll and b/tools/WIX/WixDirectXExtension.dll differ diff --git a/tools/WIX/WixFirewallExtension.dll b/tools/WIX/WixFirewallExtension.dll index 407e050a..b41b515b 100644 Binary files a/tools/WIX/WixFirewallExtension.dll and b/tools/WIX/WixFirewallExtension.dll differ diff --git a/tools/WIX/WixGamingExtension.dll b/tools/WIX/WixGamingExtension.dll index d85afcd9..cd171b0f 100644 Binary files a/tools/WIX/WixGamingExtension.dll and b/tools/WIX/WixGamingExtension.dll differ diff --git a/tools/WIX/WixIIsExtension.dll b/tools/WIX/WixIIsExtension.dll index ec566a27..05488a94 100644 Binary files a/tools/WIX/WixIIsExtension.dll and b/tools/WIX/WixIIsExtension.dll differ diff --git a/tools/WIX/WixLuxExtension.dll b/tools/WIX/WixLuxExtension.dll new file mode 100644 index 00000000..3fc6f19d Binary files /dev/null and b/tools/WIX/WixLuxExtension.dll differ diff --git a/tools/WIX/WixMsmqExtension.dll b/tools/WIX/WixMsmqExtension.dll new file mode 100644 index 00000000..4800f4a3 Binary files /dev/null and b/tools/WIX/WixMsmqExtension.dll differ diff --git a/tools/WIX/WixNetFxExtension.dll b/tools/WIX/WixNetFxExtension.dll index 71f6d98f..4bd7ed5e 100644 Binary files a/tools/WIX/WixNetFxExtension.dll and b/tools/WIX/WixNetFxExtension.dll differ diff --git a/tools/WIX/WixPSExtension.dll b/tools/WIX/WixPSExtension.dll index af23fccb..10aee90b 100644 Binary files a/tools/WIX/WixPSExtension.dll and b/tools/WIX/WixPSExtension.dll differ diff --git a/tools/WIX/WixSqlExtension.dll b/tools/WIX/WixSqlExtension.dll index 7da1c76f..ef135bfa 100644 Binary files a/tools/WIX/WixSqlExtension.dll and b/tools/WIX/WixSqlExtension.dll differ diff --git a/tools/WIX/WixTagExtension.dll b/tools/WIX/WixTagExtension.dll index 21c8451c..aac8c11c 100644 Binary files a/tools/WIX/WixTagExtension.dll and b/tools/WIX/WixTagExtension.dll differ diff --git a/tools/WIX/WixTasks.dll b/tools/WIX/WixTasks.dll index 5c617f5f..bd4c0424 100644 Binary files a/tools/WIX/WixTasks.dll and b/tools/WIX/WixTasks.dll differ diff --git a/tools/WIX/WixUIExtension.dll b/tools/WIX/WixUIExtension.dll index e8404e2b..81affd8c 100644 Binary files a/tools/WIX/WixUIExtension.dll and b/tools/WIX/WixUIExtension.dll differ diff --git a/tools/WIX/WixUtilExtension.dll b/tools/WIX/WixUtilExtension.dll index c81c4c72..f1a6c221 100644 Binary files a/tools/WIX/WixUtilExtension.dll and b/tools/WIX/WixUtilExtension.dll differ diff --git a/tools/WIX/WixVSExtension.dll b/tools/WIX/WixVSExtension.dll index 7e3fc469..900d3561 100644 Binary files a/tools/WIX/WixVSExtension.dll and b/tools/WIX/WixVSExtension.dll differ diff --git a/tools/WIX/candle.exe b/tools/WIX/candle.exe index 279e85cb..99913683 100644 Binary files a/tools/WIX/candle.exe and b/tools/WIX/candle.exe differ diff --git a/tools/WIX/candle.exe.config b/tools/WIX/candle.exe.config index 02c468a7..fd001e77 100644 --- a/tools/WIX/candle.exe.config +++ b/tools/WIX/candle.exe.config @@ -12,4 +12,7 @@ + + + diff --git a/tools/WIX/dark.exe b/tools/WIX/dark.exe index 6cedfcbc..52c04456 100644 Binary files a/tools/WIX/dark.exe and b/tools/WIX/dark.exe differ diff --git a/tools/WIX/dark.exe.config b/tools/WIX/dark.exe.config index 786f4763..af8ac295 100644 --- a/tools/WIX/dark.exe.config +++ b/tools/WIX/dark.exe.config @@ -15,4 +15,7 @@ + + + diff --git a/tools/WIX/difxapp_x64.wixlib b/tools/WIX/difxapp_x64.wixlib index 840f7449..3d7cbe25 100644 Binary files a/tools/WIX/difxapp_x64.wixlib and b/tools/WIX/difxapp_x64.wixlib differ diff --git a/tools/WIX/difxapp_x86.wixlib b/tools/WIX/difxapp_x86.wixlib index c7caf413..872cf367 100644 Binary files a/tools/WIX/difxapp_x86.wixlib and b/tools/WIX/difxapp_x86.wixlib differ diff --git a/tools/WIX/doc/DTF.chm b/tools/WIX/doc/DTF.chm new file mode 100644 index 00000000..e1d62403 Binary files /dev/null and b/tools/WIX/doc/DTF.chm differ diff --git a/tools/WIX/doc/DTFAPI.chm b/tools/WIX/doc/DTFAPI.chm new file mode 100644 index 00000000..dad6bbb1 Binary files /dev/null and b/tools/WIX/doc/DTFAPI.chm differ diff --git a/tools/WIX/doc/Dependency.xsd b/tools/WIX/doc/Dependency.xsd index 08f490e2..3c8d2433 100644 --- a/tools/WIX/doc/Dependency.xsd +++ b/tools/WIX/doc/Dependency.xsd @@ -41,7 +41,7 @@ By default this uses the Product/@Id attribute value, which may be automatically generated. - How To: Author product dependencies + How To: Author product dependencies @@ -103,7 +103,7 @@ - How To: Author product dependencies + How To: Author product dependencies @@ -166,7 +166,7 @@ - How To: Author product dependencies + How To: Author product dependencies diff --git a/tools/WIX/doc/IsolatedApp.xsd b/tools/WIX/doc/IsolatedApp.xsd deleted file mode 100644 index 5bfa958a..00000000 --- a/tools/WIX/doc/IsolatedApp.xsd +++ /dev/null @@ -1,242 +0,0 @@ - - - - - - Schema for describing Isolated Applications. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Values of this type will look like: "01234567-89AB-CDEF-0123-456789ABCDEF" or "{01234567-89AB-CDEF-0123-456789ABCDEF}". - - - - - - - Values of this type will look like: "x.x.x.x" where x is an integer from 0 to 65534. - - - - - diff --git a/tools/WIX/doc/OfficeAddin.xsd b/tools/WIX/doc/OfficeAddin.xsd deleted file mode 100644 index e01d648d..00000000 --- a/tools/WIX/doc/OfficeAddin.xsd +++ /dev/null @@ -1,262 +0,0 @@ - - - - - - Schema for describing Office Addins. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Values of this type will look like: "01234567-89AB-CDEF-0123-456789ABCDEF" or "{01234567-89AB-CDEF-0123-456789ABCDEF}". - - - - - - - Values of this type will look like: "x.x.x.x" where x is an integer from 0 to 65534. - - - - - diff --git a/tools/WIX/doc/WiX.chm b/tools/WIX/doc/WiX.chm new file mode 100644 index 00000000..9f284642 Binary files /dev/null and b/tools/WIX/doc/WiX.chm differ diff --git a/tools/WIX/doc/bal.xsd b/tools/WIX/doc/bal.xsd index 94d5f3dc..f72ba72c 100644 --- a/tools/WIX/doc/bal.xsd +++ b/tools/WIX/doc/bal.xsd @@ -60,6 +60,40 @@ + + + + If set, the success page will show a Launch button the user can use to launch the application being installed. + The string value can be formatted using Burn variables enclosed in brackets, + to refer to installation directories and so forth. + + + + + + + Id of the target ApprovedExeForElevation element. + If set with LaunchTarget, WixStdBA will launch the application through the Engine's LaunchApprovedExe method instead of through ShellExecute. + + + + + + + If set, WixStdBA will supply these arguments when launching the application specified by the LaunchTarget attribute. + The string value can be formatted using Burn variables enclosed in brackets, + to refer to installation directories and so forth. + + + + + + + If set to "yes", WixStdBA will launch the application specified by the LaunchTarget attribute with the SW_HIDE flag. + This attribute is ignored when the LaunchTargetElevatedId attribute is specified. + + + Source file of the RTF license file. Cannot be used simultaneously with LicenseUrl. @@ -75,6 +109,11 @@ Source file of the logo graphic. + + + Source file of the side logo graphic. + + Source file of the theme XML. @@ -96,10 +135,34 @@ The default behavior (or when explicitly set to "no") is to treat downgrade attempts as failures. + + + If set to "yes", the Repair button will not be shown in the maintenance-mode UI. + + + + + If set to "yes", the application version will be displayed on the UI. + + + + + + + When set to "yes", the Prereq BA will plan the package to be installed if its InstallCondition is "true" or empty. + + + + + + + + + - + When set to "yes", lets the user override the variable's default value by specifying another value on the command line, diff --git a/tools/WIX/doc/difxapp.xsd b/tools/WIX/doc/difxapp.xsd index 22c6ed2d..e072ddae 100644 --- a/tools/WIX/doc/difxapp.xsd +++ b/tools/WIX/doc/difxapp.xsd @@ -28,7 +28,7 @@ Installs a driver. To use this element, you need to reference the WixDifxAppExtension extension and add the - .wixlib appropriate for the target platform (difxapp_x86.wixlib, difxapp_x64.wixlib, or difxapp_ia64.wixlib) + .wixlib appropriate for the target platform (difxapp_x86.wixlib or difxapp_x64.wixlib) to your project. diff --git a/tools/WIX/doc/firewall.xsd b/tools/WIX/doc/firewall.xsd index 2a226094..3a3e2f54 100644 --- a/tools/WIX/doc/firewall.xsd +++ b/tools/WIX/doc/firewall.xsd @@ -25,7 +25,7 @@ Registers an exception for a program or a specific port and protocol in the Windows Firewall on Windows XP SP2, Windows Server 2003 SP1, and later. For more information about the Windows - Firewall, see + Firewall, see About Windows Firewall API. @@ -184,10 +184,10 @@ A remote address to which the port or program can listen. Address formats vary based on the version of Windows and Windows Firewall the program is being installed on. For Windows XP SP2 and Windows Server 2003 SP1, see - + RemoteAddresses Property. For Windows Vista and Windows Server 2008, see - + RemoteAddresses Property. diff --git a/tools/WIX/doc/iis.xsd b/tools/WIX/doc/iis.xsd index 0491540e..c4dc39fa 100644 --- a/tools/WIX/doc/iis.xsd +++ b/tools/WIX/doc/iis.xsd @@ -198,7 +198,7 @@ - Value for the custom HTTP Header. This attribute can contain a formatted string that is processed at install time to insert the values of properties using [PropertyName] syntax. Also supported are environment variables, file installation paths, and component installation directories; see Formatted for details. + Value for the custom HTTP Header. This attribute can contain a formatted string that is processed at install time to insert the values of properties using [PropertyName] syntax. Also supported are environment variables, file installation paths, and component installation directories; see Formatted for details. @@ -394,7 +394,7 @@ - Identity you want the AppPool to run under. Use the 'other' value in conjunction with the User attribute to specify non-standard user. + Identity you want the AppPool to run under (applicationPoolIdentity is only available on IIS7). Use the 'other' value in conjunction with the User attribute to specify non-standard user. @@ -402,6 +402,7 @@ + @@ -409,7 +410,7 @@ Specifies the request-processing mode that is used to process requests for managed content. Only available on IIS7, ignored on IIS6. - See http://www.iis.net/ConfigReference/system.applicationHost/applicationPools/applicationPoolDefaults for valid values. + See http://www.iis.net/ConfigReference/system.applicationHost/applicationPools/applicationPoolDefaults for valid values. This attribute may be set via a formatted Property (e.g. [MyProperty]). @@ -418,7 +419,7 @@ Specifies the .NET Framework version to be used by the application pool. Only available on IIS7, ignored on IIS6. - See http://www.iis.net/ConfigReference/system.applicationHost/applicationPools/applicationPoolDefaults for valid values. + See http://www.iis.net/ConfigReference/system.applicationHost/applicationPools/applicationPoolDefaults for valid values. This attribute may be set via a formatted Property (e.g. [MyProperty]). @@ -504,7 +505,7 @@ Contains the certificates of those that the user normally sends enveloped messages to or receives signed messages from. - See MSDN documentation for more information. + See MSDN documentation for more information. @@ -512,7 +513,7 @@ Contains the certificates of those directly trusted people and resources. - See MSDN documentation for more information. + See MSDN documentation for more information. @@ -520,7 +521,7 @@ Contains the certificates of those publishers who are trusted. - See MSDN documentation for more information. + See MSDN documentation for more information. @@ -841,8 +842,9 @@ Defines a subdirectory within an IIS web site. When this element is a child of WebSite, the web directory is defined within that web site. Otherwise the web directory must reference a WebSite element via the WebSite attribute. - - + + + diff --git a/tools/WIX/doc/netfx.xsd b/tools/WIX/doc/netfx.xsd index 64b4e1fb..ec1a809a 100644 --- a/tools/WIX/doc/netfx.xsd +++ b/tools/WIX/doc/netfx.xsd @@ -23,7 +23,7 @@ Improves the performance of managed applications by creating native images. Requires the .NET Framework 2.0 or newer to be installed on the target machine since - it runs NGen. + it runs NGen. diff --git a/tools/WIX/doc/sql.xsd b/tools/WIX/doc/sql.xsd index 8765e261..fd7f9042 100644 --- a/tools/WIX/doc/sql.xsd +++ b/tools/WIX/doc/sql.xsd @@ -49,7 +49,7 @@ - + SQL Database diff --git a/tools/WIX/doc/util.xsd b/tools/WIX/doc/util.xsd index ec7690a4..53424cf9 100644 --- a/tools/WIX/doc/util.xsd +++ b/tools/WIX/doc/util.xsd @@ -28,18 +28,18 @@ - Condition that determines if the application should be closed. Must be blank or evaluate to true - for the application to be scheduled for closing. - + Condition that determines if the application should be closed. Must be blank or evaluate to true + for the application to be scheduled for closing. + - + - Identifier for the close application (primary key). + Identifier for the close application (primary key). If the Id is not specified, one will be generated. - Name of the exectuable to be closed. This should only be file name. + Name of the exectuable to be closed. This should only be the file name. @@ -57,14 +57,34 @@ Optionally sends a close message to the application. Default is no. + + + Sends WM_QUERYENDSESSION then WM_ENDSESSION messages to the application. Default is "no". + + Optionally sends a close message to the application from deffered action without impersonation. Default is no. + + + Sends WM_QUERYENDSESSION then WM_ENDSESSION messages to the application from a deffered action without impersonation. Default is "no". + + - Optionally prompts for reboot if application is still running. Default is yes. + Optionally prompts for reboot if application is still running. The default is "yes". The TerminateProcess attribute must be "no" or not specified if this attribute is "yes". + + + + + + When this attribute is set to "yes", the user will be prompted when the application is still running. The Description attribute must contain the message to + display in the prompt. The prompt occurs before executing any of the other options and gives the options to "Abort", "Retry", or "Ignore". Abort will cancel + the install. Retry will attempt the check again and if the application is still running, prompt again. "Ignore" will continue and execute any other options + set on the CloseApplication element. The default is "no". + @@ -72,6 +92,22 @@ Property to be set if application is still running. Useful for launch conditions or to conditionalize custom UI to ask user to shut down apps. + + + + Attempts to terminates process and return the specified exit code if application is still running after sending any requested close and/or end session messages. + If this attribute is specified, the RebootPrompt attribute must be "no". The default is "no". + + + + + + + Optional time in seconds to wait for the application to exit after the close and/or end session messages. If the application is still running after the timeout then + the RebootPrompt or TerminateProcess attributes will be considered. The default value is "5" seconds. + + + @@ -463,7 +499,7 @@ - How To: Create a shortcut to a webpage + How To: Create a shortcut to a webpage Creates a shortcut to a URL. @@ -620,7 +656,12 @@ - Used to install Perfmon Counter Manifests. + + Used to install Perfmon Counter Manifests. + Note that this functionality cannot be used with major upgrades that are scheduled after the InstallExecute, + InstallExecuteAgain, or InstallFinalize actions. For more information on major upgrade scheduling, see + RemoveExistingProducts Action. + @@ -658,12 +699,10 @@ - Sets ACLs on File, Registry, CreateFolder, or ServiceInstall. When under a Registry element, this cannot be used - if the Action attribute's value is remove or removeKeyOnInstall. This element has no Id attribute. - The table and key are taken from the parent element. To use PermissionEx with an IA-64 MSI, you must - compile all of your source files with the "-arch ia64" switch, to ensure the IA-64 custom action is used, and not - the x64 custom action. - + Sets ACLs on File, Registry, CreateFolder, or ServiceInstall. When under a Registry element, this cannot be used + if the Action attribute's value is remove or removeKeyOnInstall. This element has no Id attribute. + The table and key are taken from the parent element. + @@ -785,9 +824,19 @@ - + - ProductCode to search for. + The Guid attribute has been deprecated; use the ProductCode or UpgradeCode attribute instead. If this attribute is used, it is assumed to be a ProductCode. + + + + + The ProductCode to use for the search. This attribute must be omitted if UpgradeCode is specified. + + + + + The UpgradeCode to use for the search. This attribute must be omitted if ProductCode is specified. Note that if multiple products are found, the highest versioned product will be used for the result. @@ -810,7 +859,7 @@ - Saves the state of the product: advertised (1), absent (2), or locally installed (3). + Saves the state of the product: advertised (1), absent (2), or locally installed (5). @@ -848,7 +897,7 @@ create properties for the Directory hierarchy in your package until later, in the CostFinalize action. An easy workaround for a typical use case of removing a folder during uninstall is to write the directory path to the registry and to load it during uninstall. See - The WiX toolset's "Remember Property" pattern + The WiX toolset's "Remember Property" pattern for an example. If you use custom actions to set properties, ensure that they are scheduled before the WixRemoveFoldersEx custom action. @@ -1162,12 +1211,12 @@ - A Formatted string that contains the name of the user account. + A Formatted string that contains the name of the user account. - A Formatted string that contains the local machine or Active Directory domain for the user. + A Formatted string that contains the local machine or Active Directory domain for the user. @@ -1200,6 +1249,11 @@ Indicates whether or not the user can logon as a serivce. User creation can be skipped if all that is desired is to set this access right on the user. + + + Indicates whether or not the user can logon as a batch job. User creation can be skipped if all that is desired is to set this access right on the user. + + Indicates if the user account properties should be updated if the user already exists. @@ -1220,6 +1274,11 @@ Indicates whether or not to create the user. User creation can be skipped if all that is desired is to join a user to groups. + + + Indicates whether failure to create the user or add the user to a group fails the installation. The default value is "yes". + + @@ -1553,4 +1612,4 @@ - \ No newline at end of file + diff --git a/tools/WIX/doc/wix.chm b/tools/WIX/doc/wix.chm deleted file mode 100644 index 7edfaacf..00000000 Binary files a/tools/WIX/doc/wix.chm and /dev/null differ diff --git a/tools/WIX/doc/wix.xsd b/tools/WIX/doc/wix.xsd index e16d0d40..cc097b7f 100644 --- a/tools/WIX/doc/wix.xsd +++ b/tools/WIX/doc/wix.xsd @@ -11,7 +11,10 @@ Schema for describing Windows Installer database files (.msi/.msm/.pcp). - + + + + @@ -70,6 +73,7 @@ + @@ -251,6 +255,46 @@ + + + Provides information about an .exe so that the BA can request the engine to run it elevated from any secure location. + + + + + + + + The identifier of the ApprovedExeForElevation element. + + + + + + The key path. + For security purposes, the root key will be HKLM and Variables are not supported. + + + + + + + The value name. + For security purposes, Variables are not supported. + + + + + + + Instructs the search to look in the 64-bit registry when the value is 'yes'. + When the value is 'no', the search looks in the 32-bit registry. + The default value is 'no'. + + + + + Overrides the default log settings for a bundle. @@ -542,7 +586,6 @@ - @@ -617,7 +660,6 @@ - @@ -874,9 +916,9 @@ A condition to evaluate before installing the package. The package will only be installed if the condition evaluates to true. If the condition evaluates to false and the bundle is being installed, repaired, or modified, the package will be uninstalled. - + - Whether to cache the package. + Whether to cache the package. The default is "yes". @@ -899,7 +941,7 @@ Specifies the description to place in the bootstrapper application data manifest for the package. By default, ExePackages use the FileName field from the version information, MsiPackages use the ARPCOMMENTS property, and MspPackages use - the Description patch metadata property. Other package types must use this attribute to define a desciption in the + the Description patch metadata property. Other package types must use this attribute to define a description in the bootstrapper application data manifest. @@ -932,7 +974,7 @@ Specifies whether the package must succeed for the chain to continue. The default "yes" - inidicates that if the package fails then the chain will fail and rollback or stop. If + indicates that if the package fails then the chain will fail and rollback or stop. If "no" is specified then the chain will continue even if the package reports failure. @@ -945,10 +987,12 @@ - By default, a Bundle will use a package's Authenticode signature to verify the contents. If the package does not - have an Authenticode signature then the Bundle will use a hash of the package instead. Set this attribute to "yes" - to suppress the default behavior and force the Bundle to always use the hash of the package even when the package - is signed. + By default, a Bundle will use the hash of a package to verify its contents. If this attribute is explicitly set to "no" + and the package is signed with an Authenticode signature the Bundle will verify the contents of the package using the + signature instead. Therefore, the default for this attribute could be considered to be "yes". It is unusual for "yes" to + be the default of an attribute. In this case, the default was changed in WiX v3.9 after experiencing real world issues + with Windows verifying Authenticode signatures. Since the Authenticode signatures are no more secure than hashing the + packages directly, the default was changed. @@ -1201,9 +1245,6 @@ - - - The identifier of Payload element. @@ -1289,16 +1330,11 @@ - Describes a information about a remote file payload that is not available at the time of building the bundle. + Describes information about a remote file payload that is not available at the time of building the bundle. The parent must specify DownloadUrl and must not specify SourceFile when using this element. - - - - - @@ -1314,7 +1350,7 @@ - Description of the file from version resouces. + Description of the file from version resources. @@ -1397,7 +1433,7 @@ - You can specify any valid Windows code page by integer like 1252, or by web name like Windows-1252. See Code Pages for more information. + You can specify any valid Windows code page by integer like 1252, or by web name like Windows-1252. See Code Pages for more information. @@ -1510,7 +1546,7 @@ - You can specify any valid Windows code by by integer like 1252, or by web name like Windows-1252. See Code Pages for more information. + You can specify any valid Windows code by by integer like 1252, or by web name like Windows-1252. See Code Pages for more information. @@ -1850,7 +1886,7 @@ - You can specify any valid Windows code by by integer like 1252, or by web name like Windows-1252. See Code Pages for more information. + You can specify any valid Windows code by by integer like 1252, or by web name like Windows-1252. See Code Pages for more information. The ClientPatchId attribute allows you to specify an easily referenced identity that you can use in product authoring. This identity prefixes properties added by WiX to a patch transform, such as ClientPatchId.PatchCode and ClientPatchId.AllowRemoval. If the patch code GUID is auto-generated you could not reference any properties using this auto-generated prefix. For example, if you were planning to ship a patch referred to as "QFE1" and needed to write your own registry values for Add/Remove Programs in product authoring such as the UninstallString for this patch, you could author a RegistryValue with the name UninstallString and the value [SystemFolder]msiexec.exe /package [ProductCode] /uninstall [QFE1.PatchCode]. In your patch authoring you would then set ClientPatchId to "QFE1" and WiX will add the QFE1.PatchCode property to the patch transform when the patch is created. If the Id attribute specified the patch code to be generated automatically, you could not reference the prefix.PatchCode property as shown above. The summary information is automatically populated from attribute values of the Patch element including the code page. If you want to override some of these summary information properties or use a different code page for the summary information itself, author the PatchInformation element. @@ -2153,6 +2189,7 @@ + @@ -2268,7 +2305,7 @@ - You can specify any valid Windows code by by integer like 1252, or by web name like Windows-1252. See Code Pages for more information. + You can specify any valid Windows code by by integer like 1252, or by web name like Windows-1252. See Code Pages for more information. @@ -2291,17 +2328,17 @@ - Use this to set whether the major versions between the upgrade and target images match. See AllowProductVersionMajorMismatches for more information. + Use this to set whether the major versions between the upgrade and target images match. See AllowProductVersionMajorMismatches for more information. - Use this to set whether the product code between the upgrade and target images match. See AllowProductCodeMismatches for more information. + Use this to set whether the product code between the upgrade and target images match. See AllowProductCodeMismatches for more information. - Use this to set whether Patchwiz should clean the temp folder when finished. See DontRemoveTempFolderWhenFinished for more information. + Use this to set whether Patchwiz should clean the temp folder when finished. See DontRemoveTempFolderWhenFinished for more information. @@ -2311,22 +2348,22 @@ - The full path, including file name, of the patch package file that is to be generated. See PatchOutputPath for more information. + The full path, including file name, of the patch package file that is to be generated. See PatchOutputPath for more information. - Used to locate the .msp file for the patch if the cached copy is unavailable. See PatchSourceList for more information. + Used to locate the .msp file for the patch if the cached copy is unavailable. See PatchSourceList for more information. - An 8-digit hex integer representing the combination of patch symbol usage flags to use when creating a binary file patch. See ApiPatchingSymbolFlags for more information. + An 8-digit hex integer representing the combination of patch symbol usage flags to use when creating a binary file patch. See ApiPatchingSymbolFlags for more information. - Use this to set whether changing files should be included in their entirety. See IncludeWholeFilesOnly for more information. + Use this to set whether changing files should be included in their entirety. See IncludeWholeFilesOnly for more information. @@ -2336,7 +2373,7 @@ Properties about the patch to be placed in the Summary Information Stream. These are visible from COM through the IStream interface, and these properties can be seen on the package in Explorer. - You can specify any valid Windows code by by integer like 1252, or by web name like Windows-1252. See Code Pages for more information. + You can specify any valid Windows code by by integer like 1252, or by web name like Windows-1252. See Code Pages for more information. @@ -2931,7 +2968,7 @@ - You can specify any valid Windows code by by integer like 1252, or by web name like Windows-1252. See Code Pages for more information. + You can specify any valid Windows code by by integer like 1252, or by web name like Windows-1252. See Code Pages for more information. @@ -3065,38 +3102,46 @@ - Set this value to declare that the package is an x86 package. - + Set this value to declare that the package is an x86 package. + - Set this value to declare that the package is an ia64 package. - This value requires that the InstallerVersion property be set to 200 or greater. - + Set this value to declare that the package is an ia64 package. + This value requires that the InstallerVersion property be set to 200 or greater. + - Set this value to declare that the package is an x64 package. - This value requires that the InstallerVersion property be set to 200 or greater. - + Set this value to declare that the package is an x64 package. + This value requires that the InstallerVersion property be set to 200 or greater. + + + + + + + Set this value to declare that the package is an arm package. + This value requires that the InstallerVersion property be set to 500 or greater. + - This value has been deprecated. Use "x86" instead. - + This value has been deprecated. Use "x86" instead. + - This value has been deprecated. Use "ia64" instead. - + This value has been deprecated. Use "ia64" instead. + @@ -3105,10 +3150,10 @@ - The value of this attribute conveys whether the package should be opened as read-only. - A database editing tool should not modify a read-only enforced database and should - issue a warning at attempts to modify a read-only recommended database. - + The value of this attribute conveys whether the package should be opened as read-only. + A database editing tool should not modify a read-only enforced database and should + issue a warning at attempts to modify a read-only recommended database. + @@ -3539,7 +3584,7 @@ - How To: Check the version number of a file during installation + How To: Check the version number of a file during installation When the parent DirectorySearch/@Depth attribute is greater than 0, the FileSearch/@Id attribute must be absent or the same as the parent DirectorySearch/@Id attribute value, unless the parent DirectorySearch/@AssignToProperty attribute value is 'yes'. @@ -3645,9 +3690,9 @@ - How To: Check the version number of a file during installation - How To: Reference another DirectorySearch element - How To: Get the parent directory of a file search + How To: Check the version number of a file during installation + How To: Reference another DirectorySearch element + How To: Get the parent directory of a file search Use the AssignToProperty attribute to search for a file but set the outer property to the directory containing the file. When this attribute is set to 'yes', you may only nest a FileSearch element with a unique Id or define no child element. When the parent DirectorySearch/@Depth attribute is greater than 0, the FileSearch/@Id attribute must be absent or the same as the parent DirectorySearch/@Id attribute value, unless the parent DirectorySearch/@AssignToProperty attribute value is 'yes'. @@ -3692,7 +3737,7 @@ - How To: Reference another DirectorySearch element + How To: Reference another DirectorySearch element A reference to another DirectorySearch element must reference the same Id, the same Parent Id, and the same Path. If any of these attribute values are different you must instead use a DirectorySearch element. @@ -3870,7 +3915,7 @@ - How To: Read a registry entry during installation + How To: Read a registry entry during installation When the Type attribute value is 'directory' the registry value must specify the path to a directory excluding the file name. @@ -3975,7 +4020,12 @@ - Instructs the search to look in the 64-bit registry when the value is 'yes'. When the value is 'no', the search looks in the 32-bit registry. The default value depends on the value of the Package/@Platform attribute: if the @Platform attribute value is 'x86', the default @Win64 attribute value is 'no'; otherwise, the default value is 'yes'. + Instructs the search to look in the 64-bit registry when the value is 'yes'. When the value is 'no', the search looks in the 32-bit registry. + The default value is based on the platform set by the -arch switch to candle.exe + or the InstallerPlatform property in a .wixproj MSBuild project: + For x86 and ARM, the default value is 'no'. + For x64 and IA64, the default value is 'yes'. + @@ -4052,7 +4102,7 @@ - How To: Check the version number of a file during installation + How To: Check the version number of a file during installation Property value for a Product or Module. @@ -4134,7 +4184,7 @@ - How To: Check for .NET Framework versions + How To: Check for .NET Framework versions Reference to a Property value. @@ -4161,7 +4211,7 @@ - How To: Create a shortcut on the Start Menu + How To: Create a shortcut on the Start Menu @@ -4625,7 +4675,7 @@ - How To: Add a file to your installer + How To: Add a file to your installer @@ -4892,7 +4942,7 @@ - Specifies the path to the File in the build process. Overrides default source path set by parent directories and Name attribute. This attribute must be set if no source information can be gathered from parent directories. For more information, see Specifying source files. + Specifies the path to the File in the build process. Overrides default source path set by parent directories and Name attribute. This attribute must be set if no source information can be gathered from parent directories. For more information, see Specifying source files. @@ -4956,8 +5006,8 @@ - How To: Read a registry entry during installation - How To: Write a registry entry during installation + How To: Read a registry entry during installation + How To: Write a registry entry during installation @@ -5075,7 +5125,7 @@ - How To: Write a registry entry during installation + How To: Write a registry entry during installation @@ -6594,7 +6644,7 @@ - Adds and removes services for parent Component. + Adds services for parent Component. Use the ServiceControl element to remove services. @@ -6615,7 +6665,7 @@ - ordered list of dependencies when installing services + Ordered list of dependencies when installing services. @@ -6649,7 +6699,7 @@ - The Windows Installer does not currently support kernelDriver or systemDriver + The Windows Installer does not currently support kernelDriver or systemDriver. @@ -7196,8 +7246,8 @@ - How To: Block installation based on OS version - How To: Check the version number of a file during installation + How To: Block installation based on OS version + How To: Check the version number of a file during installation @@ -7338,7 +7388,7 @@ - How To: Add a file to your installer + How To: Add a file to your installer @@ -7579,10 +7629,13 @@ Set this attribute to 'yes' to mark this as a 64-bit component. This attribute facilitates - the installation of packages that include both 32-bit and 64-bit components. If this bit - is not set, the component is registered as a 32-bit component. If this is a 64-bit - component replacing a 32-bit component, set this bit and assign a new GUID in the Guid attribute. - + the installation of packages that include both 32-bit and 64-bit components. If this is a 64-bit + component replacing a 32-bit component, set this attribute to 'yes' and assign a new GUID in the Guid attribute. + The default value is based on the platform set by the -arch switch to candle.exe + or the InstallerPlatform property in a .wixproj MSBuild project: + For x86 and ARM, the default value is 'no'. + For x64 and IA64, the default value is 'yes'. + @@ -7634,7 +7687,7 @@ Used to set the default file system source for child Component elements. For more information, see - Specifying source files. + Specifying source files. @@ -7685,6 +7738,17 @@ + + + Used only for PatchFamilies to include all changes between the baseline and upgraded packages in a patch. + + + Warning: this is intended for testing purposes only. Shipping a patch with all changes negates the benefits of using patch families for including only specific changes. + Because changing the ProductCode is not supported in a patch, the ProductCode property is automatically removed from the transform. + + + + Used only for PatchFamilies to include only a binary table entry in a patch. @@ -7730,7 +7794,7 @@ Create a reference to a Feature element in another Fragment. - How To: Add a file to your installer + How To: Add a file to your installer @@ -7767,7 +7831,7 @@ - How To: Install the Visual C++ Redistributable with your installer + How To: Install the Visual C++ Redistributable with your installer Merge directive to bring in a merge module that will be redirected to the parent directory. @@ -7820,7 +7884,7 @@ - How To: Install the Visual C++ Redistributable with your installer + How To: Install the Visual C++ Redistributable with your installer Merge reference to connect a Merge Module to parent Feature @@ -7868,7 +7932,7 @@ - How To: Add a file to your installer + How To: Add a file to your installer @@ -7895,11 +7959,11 @@ The Component Guid Generation Seed is a guid that must be used when a Component with the generate guid directive ("*") - is not rooted in a standard Windows Installer directory (for example, ProgramFilesFolder or CommonFilesFolder, etc). + is not rooted in a standard Windows Installer directory (for example, ProgramFilesFolder or CommonFilesFolder). It is recommended that this attribute be avoided and that developers install their Components under standard directories with unique names instead (for example, "ProgramFilesFolder\Company Name Product Name Version"). It is important to note that once a directory is assigned a Component Guid Generation Seed the value must not change until - the directory name changes. + (and must be changed when) the path to that directory, including itself and all parent directories, changes. @@ -7915,7 +7979,7 @@ - Used to set the file system source for this directory's child elements. For more information, see Specifying source files. + Used to set the file system source for this directory's child elements. For more information, see Specifying source files. @@ -7939,7 +8003,7 @@ Do not specify this attribute (or the LongName attribute) if this directory represents the same directory as the parent (see the Windows Installer SDK's - Directory table + Directory table topic for more information about the "." operator). In prior versions of the WiX toolset, this attribute specified the short directory name. @@ -8010,7 +8074,7 @@ Create a reference to a Directory element in another Fragment. - How To: Add a file to your installer + How To: Add a file to your installer @@ -8044,7 +8108,7 @@ - Used to set the file system source for this DirectoryRef's child elements. For more information, see Specifying source files. + Used to set the file system source for this DirectoryRef's child elements. For more information, see Specifying source files. @@ -8095,7 +8159,7 @@ - When the FindRelatedProducts action detects a related product installed on the system, it appends the product code to the property specified in this field. Windows Installer documentation for the Upgrade table states that the property specified in this field must be a public property and must be added to the SecureCustomProperties property. WiX automatically appends the property specified in this field to the SecureCustomProperties property when creating an MSI. Each UpgradeVersion must have a unique Property value. After the FindRelatedProducts action is run, the value of this property is a list of product codes, separated by semicolons (;), detected on the system. + When the FindRelatedProducts action detects a related product installed on the system, it appends the product code to the property specified in this field. Windows Installer documentation for the Upgrade table states that the property specified in this field must be a public property and must be added to the SecureCustomProperties property. WiX automatically appends the property specified in this field to the SecureCustomProperties property when creating an MSI. Each UpgradeVersion must have a unique Property value. After the FindRelatedProducts action is run, the value of this property is a list of product codes, separated by semicolons (;), detected on the system. @@ -8177,7 +8241,7 @@ - How To: Add a file to your installer + How To: Add a file to your installer @@ -8679,6 +8743,20 @@ + + + + Maximum size of cabinet files in megabytes for large files. This attribute is used for packaging + files that are larger than MaximumUncompressedMediaSize into smaller cabinets. If cabinet size + exceed this value, then setting this attribute will cause the file to be split into multiple + cabinets of this maximum size. For simply controlling cabinet size without file splitting use + MaximumUncompressedMediaSize attribute. Setting this attribute will disable smart cabbing feature + for this Fragment / Product. Setting WIX_MCSLFS environment variable can be used to override this + value. Minimum allowed value of this attribute is 20 MB. Maximum allowed value and the Default + value of this attribute is 2048 MB (2 GB). + + + @@ -8998,7 +9076,11 @@ Specifies that a script custom action targets a 64-bit platform. Valid only when used with the Script, VBScriptCall, and JScriptCall attributes. - + The default value is based on the platform set by the -arch switch to candle.exe + or the InstallerPlatform property in a .wixproj MSBuild project: + For x86 and ARM, the default value is 'no'. + For x64 and IA64, the default value is 'yes'. + @@ -10681,8 +10763,8 @@ - How To: Set your installer's icon in Add/Remove Programs - How To: Create a shortcut on the Start Menu + How To: Set your installer's icon in Add/Remove Programs + How To: Create a shortcut on the Start Menu @@ -11193,7 +11275,7 @@ - A localizable string used to set the initial text contained in a control. This attribute can contain a formatted string that is processed at install time to insert the values of properties using [PropertyName] syntax. Also supported are environment variables, file installation paths, and component installation directories; see Formatted for details. + A localizable string used to set the initial text contained in a control. This attribute can contain a formatted string that is processed at install time to insert the values of properties using [PropertyName] syntax. Also supported are environment variables, file installation paths, and component installation directories; see Formatted for details. @@ -12306,7 +12388,7 @@ - + The ProductCode for this instance. @@ -12316,6 +12398,11 @@ The ProductName for this instance. + + + The UpgradeCode for this instance. + + @@ -12780,6 +12867,22 @@ + + + Values of this type will either be "always", "yes", or "no". + + + + + + Values of this type will either be "always", "yes", or "no". + + + + + + + Values of this type represent possible registry roots. diff --git a/tools/WIX/doc/wixloc.xsd b/tools/WIX/doc/wixloc.xsd index 63c08485..35b26533 100644 --- a/tools/WIX/doc/wixloc.xsd +++ b/tools/WIX/doc/wixloc.xsd @@ -22,10 +22,10 @@ - You can specify any valid Windows code page by integer like 1252, or by web name like Windows-1252 or iso-8859-1. See Code Pages for more information. + You can specify any valid Windows code page by integer like 1252, or by web name like Windows-1252 or iso-8859-1. See Code Pages for more information. - How To: Build a localized version of your installer - How To: Make your installer localizable + How To: Build a localized version of your installer + How To: Make your installer localizable @@ -54,8 +54,8 @@ - How To: Build a localized version of your installer - How To: Make your installer localizable + How To: Build a localized version of your installer + How To: Make your installer localizable diff --git a/tools/WIX/heat.exe b/tools/WIX/heat.exe index 43198075..00b1c538 100644 Binary files a/tools/WIX/heat.exe and b/tools/WIX/heat.exe differ diff --git a/tools/WIX/heat.exe.config b/tools/WIX/heat.exe.config index 1c6e8ada..48d7d696 100644 --- a/tools/WIX/heat.exe.config +++ b/tools/WIX/heat.exe.config @@ -15,4 +15,7 @@ + + + diff --git a/tools/WIX/insignia.exe b/tools/WIX/insignia.exe index 37deb2b2..92db18de 100644 Binary files a/tools/WIX/insignia.exe and b/tools/WIX/insignia.exe differ diff --git a/tools/WIX/light.exe b/tools/WIX/light.exe index 9f5602d6..96cf4567 100644 Binary files a/tools/WIX/light.exe and b/tools/WIX/light.exe differ diff --git a/tools/WIX/light.exe.config b/tools/WIX/light.exe.config index 02c468a7..fd001e77 100644 --- a/tools/WIX/light.exe.config +++ b/tools/WIX/light.exe.config @@ -12,4 +12,7 @@ + + + diff --git a/tools/WIX/lit.exe b/tools/WIX/lit.exe index c8c7219a..1fdb5744 100644 Binary files a/tools/WIX/lit.exe and b/tools/WIX/lit.exe differ diff --git a/tools/WIX/lit.exe.config b/tools/WIX/lit.exe.config index 02c468a7..fd001e77 100644 --- a/tools/WIX/lit.exe.config +++ b/tools/WIX/lit.exe.config @@ -12,4 +12,7 @@ + + + diff --git a/tools/WIX/lux.exe b/tools/WIX/lux.exe new file mode 100644 index 00000000..397922f5 Binary files /dev/null and b/tools/WIX/lux.exe differ diff --git a/tools/WIX/lux.exe.config b/tools/WIX/lux.exe.config new file mode 100644 index 00000000..d9c1f59b --- /dev/null +++ b/tools/WIX/lux.exe.config @@ -0,0 +1,17 @@ + + + + + + + + + + diff --git a/tools/WIX/lux.targets b/tools/WIX/lux.targets new file mode 100644 index 00000000..c276e0d7 --- /dev/null +++ b/tools/WIX/lux.targets @@ -0,0 +1,117 @@ + + + + + + + + + Compile;_ScanForUnitTests;_GenerateTestConsumer;Link + $(BuildTestPackageDependsOn) + + + + + + + + + + + + + + + + + + + + + $(OutputName)_test + ICE71;$(SuppressIces) + true + + + + + + + + + + + + + + + + + + + + diff --git a/tools/WIX/melt.exe b/tools/WIX/melt.exe index 8019cb60..607f6db7 100644 Binary files a/tools/WIX/melt.exe and b/tools/WIX/melt.exe differ diff --git a/tools/WIX/melt.exe.config b/tools/WIX/melt.exe.config index 943586e4..fd001e77 100644 --- a/tools/WIX/melt.exe.config +++ b/tools/WIX/melt.exe.config @@ -8,10 +8,11 @@ --> - - + + + diff --git a/tools/WIX/nit.exe b/tools/WIX/nit.exe new file mode 100644 index 00000000..c52fcf1d Binary files /dev/null and b/tools/WIX/nit.exe differ diff --git a/tools/WIX/nit.exe.config b/tools/WIX/nit.exe.config new file mode 100644 index 00000000..8012dcd3 --- /dev/null +++ b/tools/WIX/nit.exe.config @@ -0,0 +1,14 @@ + + + + + + + diff --git a/tools/WIX/pyro.exe b/tools/WIX/pyro.exe index 603240dd..122dcae3 100644 Binary files a/tools/WIX/pyro.exe and b/tools/WIX/pyro.exe differ diff --git a/tools/WIX/pyro.exe.config b/tools/WIX/pyro.exe.config index 02c468a7..fd001e77 100644 --- a/tools/WIX/pyro.exe.config +++ b/tools/WIX/pyro.exe.config @@ -12,4 +12,7 @@ + + + diff --git a/tools/WIX/retina.exe b/tools/WIX/retina.exe index 59602298..84ebb5ea 100644 Binary files a/tools/WIX/retina.exe and b/tools/WIX/retina.exe differ diff --git a/tools/WIX/sdk/BootstrapperCore.dll b/tools/WIX/sdk/BootstrapperCore.dll index ebe3de46..80b5e4cb 100644 Binary files a/tools/WIX/sdk/BootstrapperCore.dll and b/tools/WIX/sdk/BootstrapperCore.dll differ diff --git a/tools/WIX/sdk/BootstrapperCore.xml b/tools/WIX/sdk/BootstrapperCore.xml new file mode 100644 index 00000000..17bdb365 --- /dev/null +++ b/tools/WIX/sdk/BootstrapperCore.xml @@ -0,0 +1,2807 @@ + + + + BootstrapperCore + + + + + The default bootstrapper application. + + + + + Allows customization of the bootstrapper application. + + + + + Creates a new instance of the class. + + + + + Entry point that is called when the bootstrapper application is ready to run. + + + + + Called by the engine on startup of the bootstrapper application. + + Additional arguments for this event. + + + + Called by the engine to uninitialize the user experience. + + Additional arguments for this event. + + + + Called when the system is shutting down or the user is logging off. + + Additional arguments for this event. + + To prevent shutting down or logging off, set to + ; otherwise, set it to . + By default setup will prevent shutting down or logging off between + and . + Derivatives can change this behavior by overriding + or handling . + If contains + the bootstrapper cannot prevent the shutdown and only has a few seconds to save state or perform any other + critical operations before being closed by the operating system. + This method may be called on a different thread. + + + + + Called when the overall detection phase has begun. + + Additional arguments for this event. + + + + Called when the update detection phase has begun. + + Additional arguments for this event. + + + + Called when the update detection phase has begun. + + Additional arguments for this event. + + + + Fired when the update detection has found a potential update candidate. + + Additional arguments for this event. + + + + Called when the update detection phase has completed. + + Additional arguments for this event. + + + + Called when the detection for a prior bundle has begun. + + Additional arguments for this event. + + + + Called when a related bundle has been detected for a bundle. + + Additional arguments for this event. + + + + Called when the detection for a specific package has begun. + + Additional arguments for this event. + + + + Called when a package was not detected but a package using the same provider key was. + + Additional arguments for this event. + + + + Called when a related MSI package has been detected for a package. + + Additional arguments for this event. + + + + Called when an MSP package detects a target MSI has been detected. + + Additional arguments for this event. + + + + Called when an MSI feature has been detected for a package. + + Additional arguments for this event. + + + + Called when the detection for a specific package has completed. + + Additional arguments for this event. + + + + Called when the detection phase has completed. + + Additional arguments for this event. + + + + Called when the engine has begun planning the installation. + + Additional arguments for this event. + + + + Called when the engine has begun planning for a prior bundle. + + Additional arguments for this event. + + + + Called when the engine has begun planning the installation of a specific package. + + Additional arguments for this event. + + + + Called when the engine plans a new, compatible package using the same provider key. + + Additional arguments for this event. + + + + Called when the engine is about to plan the target MSI of a MSP package. + + Additional arguments for this event. + + + + Called when the engine is about to plan an MSI feature of a specific package. + + Additional arguments for this event. + + + + Called when then engine has completed planning the installation of a specific package. + + Additional arguments for this event. + + + + Called when the engine has completed planning the installation. + + Additional arguments for this event. + + + + Called when the engine has begun installing the bundle. + + Additional arguments for this event. + + + + Called right after OnApplyBegin. + + Additional arguments for this event. + + + + Called when the engine is about to start the elevated process. + + Additional arguments for this event. + + + + Called when the engine has begun registering the location and visibility of the bundle. + + Additional arguments for this event. + + + + Called when the engine has completed registering the location and visilibity of the bundle. + + Additional arguments for this event. + + + + Called when the engine has begun removing the registration for the location and visibility of the bundle. + + Additional arguments for this event. + + + + Called when the engine has completed removing the registration for the location and visibility of the bundle. + + Additional arguments for this event. + + + + Called when the engine begins to cache the installation sources. + + + + + + Called by the engine when it begins to cache a specific package. + + + + + + Called when the engine begins to cache the container or payload. + + + + + + Called when the engine has progressed on caching the container or payload. + + + + + + Called by the engine to allow the user experience to change the source + using or . + + Additional arguments for this event. + + + + Called when the engine complets caching of the container or payload. + + + + + + Called when the engine has started verify the payload. + + + + + + Called when the engine completes verification of the payload. + + + + + + Called when the engine completes caching a specific package. + + + + + + Called after the engine has cached the installation sources. + + Additional arguments for this event. + + + + Called when the engine has begun installing packages. + + Additional arguments for this event. + + + + Called when the engine has begun installing a specific package. + + Additional arguments for this event. + + + + Called when the engine executes one or more patches targeting a product. + + Additional arguments for this event. + + + + Called when the engine has encountered an error. + + Additional arguments for this event. + + + + Called when the engine has changed progress for the bundle installation. + + Additional arguments for this event. + + + + Called when Windows Installer sends an installation message. + + Additional arguments for this event. + + + + Called when Windows Installer sends a file in use installation message. + + Additional arguments for this event. + + + + Called when the engine has completed installing a specific package. + + Additional arguments for this event. + + + + Called when the engine has completed installing packages. + + Additional arguments for this event. + + + + Called by the engine to request a restart now or inform the user a manual restart is required later. + + Additional arguments for this event. + + + + Called when the engine has completed installing the bundle. + + Additional arguments for this event. + + + + Called by the engine while executing on payload. + + Additional arguments for this event. + + + + Called by the engine before trying to launch the preapproved executable. + + Additional arguments for this event. + + + + Called by the engine after trying to launch the preapproved executable. + + Additional arguments for this event. + + + + Fired when the engine is starting up the bootstrapper application. + + + + + Fired when the engine is shutting down the bootstrapper application. + + + + + Fired when the system is shutting down or user is logging off. + + + To prevent shutting down or logging off, set to + ; otherwise, set it to . + By default setup will prevent shutting down or logging off between + and . + Derivatives can change this behavior by overriding + or handling . + If contains + the bootstrapper cannot prevent the shutdown and only has a few seconds to save state or perform any other + critical operations before being closed by the operating system. + This event may be fired on a different thread. + + + + + Fired when the overall detection phase has begun. + + + + + Fired when a forward compatible bundle is detected. + + + + + Fired when the update detection phase has begun. + + + + + Fired when the update detection has found a potential update candidate. + + + + + Fired when the update detection phase has completed. + + + + + Fired when the detection for a prior bundle has begun. + + + + + Fired when a related bundle has been detected for a bundle. + + + + + Fired when the detection for a specific package has begun. + + + + + Fired when a package was not detected but a package using the same provider key was. + + + + + Fired when a related MSI package has been detected for a package. + + + + + Fired when an MSP package detects a target MSI has been detected. + + + + + Fired when a feature in an MSI package has been detected. + + + + + Fired when the detection for a specific package has completed. + + + + + Fired when the detection phase has completed. + + + + + Fired when the engine has begun planning the installation. + + + + + Fired when the engine has begun planning for a related bundle. + + + + + Fired when the engine has begun planning the installation of a specific package. + + + + + Fired when the engine plans a new, compatible package using the same provider key. + + + + + Fired when the engine is about to plan the target MSI of a MSP package. + + + + + Fired when the engine is about to plan a feature in an MSI package. + + + + + Fired when the engine has completed planning the installation of a specific package. + + + + + Fired when the engine has completed planning the installation. + + + + + Fired when the engine has begun installing the bundle. + + + + + DEPRECATED: This event will be merged with ApplyBegin in wix4. + Fired right after ApplyBegin, providing the number of phases that the engine will go through in apply. + + + + + Fired when the engine is about to start the elevated process. + + + + + Fired when the engine has begun registering the location and visibility of the bundle. + + + + + Fired when the engine has completed registering the location and visibility of the bundle. + + + + + Fired when the engine has begun removing the registration for the location and visibility of the bundle. + + + + + Fired when the engine has completed removing the registration for the location and visibility of the bundle. + + + + + Fired when the engine has begun caching the installation sources. + + + + + Fired when the engine has begun caching a specific package. + + + + + Fired when the engine has begun acquiring the installation sources. + + + + + Fired when the engine has progress acquiring the installation sources. + + + + + Fired by the engine to allow the user experience to change the source + using or . + + + + + Fired when the engine has completed the acquisition of the installation sources. + + + + + Fired when the engine begins the verification of the acquired installation sources. + + + + + Fired when the engine complete the verification of the acquired installation sources. + + + + + Fired when the engine has completed caching a specific package. + + + + + Fired after the engine has cached the installation sources. + + + + + Fired when the engine has begun installing packages. + + + + + Fired when the engine has begun installing a specific package. + + + + + Fired when the engine executes one or more patches targeting a product. + + + + + Fired when the engine has encountered an error. + + + + + Fired when the engine has changed progress for the bundle installation. + + + + + Fired when Windows Installer sends an installation message. + + + + + Fired when Windows Installer sends a files in use installation message. + + + + + Fired when the engine has completed installing a specific package. + + + + + Fired when the engine has completed installing packages. + + + + + Fired by the engine to request a restart now or inform the user a manual restart is required later. + + + + + Fired when the engine has completed installing the bundle. + + + + + Fired by the engine while executing on payload. + + + + + Fired when the engine is about to launch the preapproved executable. + + + + + Fired when the engine has completed launching the preapproved executable. + + + + + Specifies whether this bootstrapper should run asynchronously. The default is true. + + + + + Gets the information for how the UX should be started. + + + + + Gets the for interaction with the Engine. + + + + + Identifies the bootstrapper application class. + + + This required assembly attribute identifies the bootstrapper application class. + + + + + Creates a new instance of the class. + + The of the user experience, or null for the default user experience. + + + + Gets the type of the bootstrapper application class to create. + + + + + Class used by the MUX host to create and return the IBootstrapperApplication implementation to the engine. + + + + + Creates a new instance of the class. + + + + + Loads the bootstrapper application assembly and creates an instance of the IBootstrapperApplication. + + IBootstrapperEngine provided for the bootstrapper application. + Command line for the bootstrapper application. + Bootstrapper application via interface. + The bootstrapper application assembly + does not define the . + + + + Locates the and returns the specified type. + + The assembly that defines the user experience class. + The bootstrapper application . + + + + Handler for the wix.bootstrapper configuration section group. + + + + + Creates a new instance of the class. + + + + + Gets the handler for the mux configuration section. + + + + + Handler for the supportedFramework collection. + + + + + Handler for the supportedFramework configuration section. + + + + + Creates a new instance of the class. + + + + + Gets the version of the supported framework. + + + The assembly specified by this name must contain a value matching the NETFX version registry key under + "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP". + + + + + Gets the runtime version required by this supported framework. + + + + + Container class for the interface. + + + + + Creates a new instance of the container class. + + The to contain. + + + + Install the packages. + + The parent window for the installation user interface. + + + + Close the splash screen if it is still open. Does nothing if the splash screen is not or + never was opened. + + + + + Determine if all installation conditions are fulfilled. + + + + + Determine if all installation conditions are fulfilled. + + The parent window for the installation user interface. + + + + Elevate the install. + + The parent window of the elevation dialog. + true if elevation succeeded; otherwise, false if the user cancelled. + A Win32 error occurred. + + + + Escapes the input string. + + The string to escape. + The escaped string. + A Win32 error occurred. + + + + Evaluates the string. + + The string representing the condition to evaluate. + Whether the condition evaluated to true or false. + + + + Formats the input string. + + The string to format. + The formatted string. + A Win32 error occurred. + + + + Launches a preapproved executable elevated. As long as the engine already elevated, there will be no UAC prompt. + + The parent window of the elevation dialog (if the engine hasn't elevated yet). + Id of the ApprovedExeForElevation element specified when the bundle was authored. + Optional arguments. + + + + Launches a preapproved executable elevated. As long as the engine already elevated, there will be no UAC prompt. + + The parent window of the elevation dialog (if the engine hasn't elevated yet). + Id of the ApprovedExeForElevation element specified when the bundle was authored. + Optional arguments. + Timeout in milliseconds. When set to something other than zero, the engine will call WaitForInputIdle for the new process with this timeout before calling OnLaunchApprovedExeComplete. + + + + Logs the . + + The logging level. + The message to log. + + + + Determine the installation sequencing and costing. + + The action to perform when planning. + + + + Set the update information for a bundle. + + Optional local source path for the update. Default is "update\[OriginalNameOfBundle].exe". + Optional download source for the update. + Size of the expected update. + Type of the hash expected on the update. + Optional hash expected for the update. + + + + Set the local source for a package or container. + + The id that uniquely identifies the package or container. + The id that uniquely identifies the payload. + The new source path. + + + + Set the new download URL for a package or container. + + The id that uniquely identifies the package or container. + The id that uniquely identifies the payload. + The new url. + The user name for proxy authentication. + The password for proxy authentication. + + + + Sends error message when embedded. + + Error code. + Error message. + UI buttons to show on error dialog. + + + + Sends progress percentages when embedded. + + Percentage completed thus far. + Overall percentage completed. + + + + Shuts down the engine. + + Exit code indicating reason for shut down. + + + + Gets whether the variable given by exists. + + The name of the variable to check. + True if the variable given by exists; otherwise, false. + + + + Gets the variable given by as a string. + + The name of the variable to get. + The length of the Unicode string. + The value by a pointer to a Unicode string. Must be freed by Marshal.FreeCoTaskMem. + An error occurred getting the variable. + + + + Initialize a SecureString with the given Unicode string. + + Pointer to Unicode string. + The string's length. + + + + Verifies that VersionVariables can pass on the given Version to the engine. + If the Build or Revision fields are undefined, they are set to zero. + + + + + Gets or sets numeric variables for the engine. + + + + + Gets the number of packages in the bundle. + + + + + Gets or sets string variables for the engine using SecureStrings. + + + + + Gets or sets string variables for the engine. + + + + + Gets or sets variables for the engine. + + The class can keep track of when the build and revision fields are undefined, but the engine can't. + Therefore, the build and revision fields must be defined when setting a variable. + Use the NormalizeVersion method to make sure the engine can accept the Version. + + To keep track of versions without build or revision fields, use StringVariables instead. + + The given was invalid. + + + + An accessor for numeric, string, and version variables for the engine. + + + + + Gets whether the variable given by exists. + + The name of the variable to check. + True if the variable given by exists; otherwise, false. + + + + Gets or sets the variable given by . + + The name of the variable to get/set. + The value of the given variable. + An error occurred getting the variable. + + + + Base class for classes that must return a value. + + + + + Creates a new instance of the class. + + + + + Creates a new instance of the class. + + Recommended result from engine. + + + + Gets or sets the of the operation. This is passed back to the engine. + + + + + Base class for classes that receive status from the engine. + + + + + Creates a new instance of the class. + + The return code of the operation. + + + + Gets the return code of the operation. + + + + + Base class for classes that receive status from the engine and return a result. + + + + + Creates a new instance of the class. + + The return code of the operation. + + + + Creates a new instance of the class. + + The return code of the operation. + The recommended result from the engine. + + + + Gets the return code of the operation. + + + + + Additional arguments used when startup has begun. + + + + + Creates a new instance of the class. + + + + + Additional arguments used when shutdown has begun. + + + + + Creates a new instance of the class. + + + + + Additional arguments used when the system is shutting down or the user is logging off. + + + To prevent shutting down or logging off, set to + ; otherwise, set it to . + By default setup will prevent shutting down or logging off between + and . + Derivatives can change this behavior by overriding + or handling . + If contains + the bootstrapper cannot prevent the shutdown and only has a few seconds to save state or perform any other + critical operations before being closed by the operating system. + + + + + + + Creates a new instance of the class. + + The reason the application is requested to close or being closed. + The recommendation from the engine. + + + + Gets the reason the application is requested to close or being closed. + + + To prevent shutting down or logging off, set to + ; otherwise, set it to . + If contains + the bootstrapper cannot prevent the shutdown and only has a few seconds to save state or perform any other + critical operations before being closed by the operating system. + + + + + Additional arguments used when the overall detection phase has begun. + + + + + Creates a new instance of the class. + + Specifies whether the bundle is installed. + The number of packages to detect. + + + + Gets whether the bundle is installed. + + + + + Gets the number of packages to detect. + + + + + Additional arguments used when detected a forward compatible bundle. + + + + + Creates a new instance of the class. + + The identity of the forward compatible bundle. + Relationship type for this forward compatible bundle. + The tag of the forward compatible bundle. + Whether the detected forward compatible bundle is per machine. + The version of the forward compatible bundle detected. + The recommendation from the engine. + + + + Gets the identity of the forward compatible bundle detected. + + + + + Gets the relationship type of the forward compatible bundle. + + + + + Gets the tag of the forward compatible bundle. + + + + + Gets whether the detected forward compatible bundle is per machine. + + + + + Gets the version of the forward compatible bundle detected. + + + + + Additional arguments used when the detection for an update has begun. + + + + + Creates a new instance of the class. + + The location to check for an updated bundle. + The recommendation from the engine. + + + + Gets the identity of the bundle to detect. + + + + + Additional arguments used when the detection for an update has begun. + + + + + Creates a new instance of the class. + + The location to check for an updated bundle. + The expected size of the updated bundle. + The expected version of the updated bundle. + The title of the updated bundle. + The summary of the updated bundle. + The content type of the content of the updated bundle. + The content of the updated bundle. + The recommendation from the engine. + + + + Gets the size of the updated bundle. + + + + + Gets the version of the updated bundle. + + + + + Gets the title of the the updated bundle. + + + + + Gets the summary of the updated bundle. + + + + + Gets the content type of the content of the updated bundle. + + + + + Gets the content of the updated bundle. + + + + + Additional arguments used when the detection for an update has completed. + + + + + Creates a new instance of the class. + + The return code of the operation. + The location of the updated bundle. + + + + Gets the location of the updated bundle if one was detected. + + + + + Additional arguments used when the detection for a prior bundle has begun. + + + + + Creates a new instance of the class. + + The identity of the bundle to detect. + + + + Gets the identity of the bundle to detect. + + + + + Additional arguments used when a related bundle has been detected for a bundle. + + + + + Creates a new instance of the class. + + The identity of the related package bundle. + Relationship type for this related bundle. + The tag of the related package bundle. + Whether the detected bundle is per machine. + The version of the related bundle detected. + The operation that will be taken on the detected bundle. + + + + Gets the identity of the related bundle detected. + + + + + Gets the relationship type of the related bundle. + + + + + Gets the tag of the related package bundle. + + + + + Gets whether the detected bundle is per machine. + + + + + Gets the version of the related bundle detected. + + + + + Gets the operation that will be taken on the detected bundle. + + + + + Additional arguments used when the detection for a specific package has begun. + + + + + Creates a new instance of the class. + + The identity of the package to detect. + + + + Gets the identity of the package to detect. + + + + + Additional arguments used when a package was not found but a newer package using the same provider key was. + + + + + Creates a new instance of the class. + + The identity of the package that was not detected. + The identity of the compatible package that was detected. + + + + Gets the identity of the package that was not detected. + + + + + Gets the identity of the compatible package that was detected. + + + + + Additional arguments used when a related MSI package has been detected for a package. + + + + + Creates a new instance of the class. + + The identity of the package detecting. + The identity of the related package detected. + Whether the detected package is per machine. + The version of the related package detected. + The operation that will be taken on the detected package. + + + + Gets the identity of the product's package detected. + + + + + Gets the identity of the related package detected. + + + + + Gets whether the detected package is per machine. + + + + + Gets the version of the related package detected. + + + + + Gets the operation that will be taken on the detected package. + + + + + Additional arguments used when a target MSI package has been detected. + + + + + Creates a new instance of the class. + + Detected package identifier. + Detected product code. + Package state detected. + + + + Gets the identity of the target's package detected. + + + + + Gets the product code of the target MSI detected. + + + + + Gets the detected patch package state. + + + + + Additional arguments used when a feature in an MSI package has been detected. + + + + + Creates a new instance of the class. + + Detected package identifier. + Detected feature identifier. + Feature state detected. + + + + Gets the identity of the feature's package detected. + + + + + Gets the identity of the feature detected. + + + + + Gets the detected feature state. + + + + + Additional arguments used when the detection for a specific package has completed. + + + + + Creates a new instance of the class. + + The identity of the package detected. + The return code of the operation. + The state of the specified package. + + + + Gets the identity of the package detected. + + + + + Gets the state of the specified package. + + + + + Additional arguments used when the detection phase has completed. + + + + + Creates a new instance of the class. + + The return code of the operation. + + + + Additional arguments used when the engine has begun planning the installation. + + + + + Creates a new instance of the class. + + The number of packages to plan for. + + + + Gets the number of packages to plan for. + + + + + Additional arguments used when the engine has begun planning for a related bundle. + + + + + Creates a new instance of the class. + + The identity of the bundle to plan for. + The requested state for the bundle. + + + + Gets the identity of the bundle to plan for. + + + + + Gets or sets the requested state for the bundle. + + + + + Additional arguments used when the engine has begun planning the installation of a specific package. + + + + + Creates a new instance of the class. + + The identity of the package to plan for. + The requested state for the package. + + + + Gets the identity of the package to plan for. + + + + + Gets or sets the requested state for the package. + + + + + Additional arguments used when the engine is about to plan a newer package using the same provider key. + + + + + Creates a new instance of the class. + + The identity of the package that was not detected. + The requested state for the compatible package. + + + + Gets the identity of the package that was not detected. + + + + + Gets or sets the state to use for the compatible package for planning. + + + + + Additional arguments used when engine is about to plan a MSP applied to a target MSI package. + + + + + Creates a new instance of the class. + + Package identifier of the patch being planned. + Product code identifier being planned. + Package state of the patch being planned. + + + + Gets the identity of the feature's package to plan. + + + + + Gets the identity of the feature to plan. + + + + + Gets or sets the state of the patch to use by planning. + + + + + Additional arguments used when engine is about to plan a feature in an MSI package. + + + + + Creates a new instance of the class. + + Package identifier being planned. + Feature identifier being planned. + Feature state being planned. + + + + Gets the identity of the feature's package to plan. + + + + + Gets the identity of the feature to plan. + + + + + Gets or sets the feature state to use by planning. + + + + + Additional arguments used when then engine has completed planning the installation of a specific package. + + + + + Creates a new instance of the class. + + The identity of the package planned for. + The return code of the operation. + The current state of the package. + The requested state for the package + The execution action to take. + The rollback action to take. + + + + Gets the identity of the package planned for. + + + + + Gets the current state of the package. + + + + + Gets the requested state for the package. + + + + + Gets the execution action to take. + + + + + Gets the rollback action to take. + + + + + Additional arguments used when the engine has completed planning the installation. + + + + + Creates a new instance of the class. + + The return code of the operation. + + + + Additional arguments used when the engine has begun installing the bundle. + + + + + DEPRECATED: this information will be provided in ApplyBeginEventArgs in wix4. + Additional arguments used when the engine has determined the number of phases in apply. + + + + + DEPRECATED: this information will be provided in ApplyBeginEventArgs in wix4. + Gets the number of phases that the engine will go through in apply. + There are currently two possible phases: cache and execute. + + + + + Additional arguments used when the engine is about to start the elevated process. + + + + + Additional arguments used when the engine has begun registering the location and visibility of the bundle. + + + + + Additional arguments used when the engine has completed registering the location and visilibity of the bundle. + + + + + Creates a new instance of the class. + + The return code of the operation. + + + + Additional arguments used when the engine has begun removing the registration for the location and visibility of the bundle. + + + + + Additional arguments used when the engine has completed removing the registration for the location and visibility of the bundle. + + + + + Creates a new instance of the class. + + The return code of the operation. + + + + Additional arguments used when the engine has begun caching the installation sources. + + + + + Additional arguments used when the engine begins to acquire containers or payloads. + + + + + Creates a new instance of the class. + + + + + Gets the identifier of the container or package. + + + + + Gets the identifier of the payload (if acquiring a payload). + + + + + Gets the cache acquire operation. + + + + + Gets the source of the container or payload. + + + + + Additional arguments used when the engine acquires some part of a container or payload. + + + + + Creates a new instance of the class. + + + + + Gets the identifier of the container or package. + + + + + Gets the identifier of the payload (if acquiring a payload). + + + + + Gets the number of bytes cached thus far. + + + + + Gets the total bytes to cache. + + + + + Gets the overall percentage of progress of caching. + + + + + Additional arguments used when the engine completes the acquisition of a container or payload. + + + + + Creates a new instance of the class. + + + + + Gets the identifier of the container or package. + + + + + Gets the identifier of the payload (if acquiring a payload). + + + + + Additional arguments used when the engine starts the verification of a payload. + + + + + Creates a new instance of the class. + + + + + Gets the identifier of the package. + + + + + Gets the identifier of the payload. + + + + + Additional arguments used when the engine completes the verification of a payload. + + + + + Creates a new instance of the class. + + + + + Gets the identifier of the package. + + + + + Gets the identifier of the payload. + + + + + Additional arguments used after the engine has cached the installation sources. + + + + + Creates a new instance of the class. + + The return code of the operation. + + + + Additional arguments used when the engine has begun installing packages. + + + + + Creates a new instance of the class. + + The number of packages to act on. + + + + Gets the number of packages to act on. + + + + + Additional arguments used when the engine has begun installing a specific package. + + + + + Creates a new instance of the class. + + The identity of the package to act on. + Whether the package should really be acted on. + + + + Gets the identity of the package to act on. + + + + + Gets whether the package should really be acted on. + + + + + Additional arguments used when the engine executes one or more patches targeting a product. + + + + + Creates a new instance of the class. + + The identity of the package to act on. + The product code of the target of the patch. + + + + Gets the identity of the package to act on. + + + + + Gets the product code being targeted. + + + + + Additional arguments used when the engine has encountered an error. + + + + + Creates a new instance of the class. + + The error type. + The identity of the package that yielded the error. + The error code. + The error message. + Recommended display flags for an error dialog. + The exteded data for the error. + Recommended result from engine. + + + + Gets the type of error that occurred. + + + + + Gets the identity of the package that yielded the error. + + + + + Gets the error code. + + + + + Gets the error message. + + + + + Gets the recommended display flags for an error dialog. + + + + + Gets the extended data for the error. + + + + + Additional arguments used when the engine has changed progress for the bundle installation. + + + + + Creates an new instance of the class. + + The percentage from 0 to 100 completed for a package. + The percentage from 0 to 100 completed for the bundle. + + + + Gets the percentage from 0 to 100 completed for a package. + + + + + Gets the percentage from 0 to 100 completed for the bundle. + + + + + Additional arguments used when Windows Installer sends an installation message. + + + + + Creates a new instance of the class. + + The identity of the package that yielded this message. + The type of this message. + Recommended display flags for this message. + The message. + The extended data for the message. + Recommended result from engine. + + + + Gets the identity of the package that yielded this message. + + + + + Gets the type of this message. + + + + + Gets the recommended display flags for this message. + + + + + Gets the message. + + + + + Gets the extended data for the message. + + + + + Additional arugments used for file in use installation messages. + + + + + Creates a new instance of the class. + + The identity of the package that yielded the files in use message. + The list of files in use. + + + + Gets the identity of the package that yielded the files in use message. + + + + + Gets the list of files in use. + + + + + Additional arguments used when the engine has completed installing a specific package. + + + + + Creates a new instance of the class. + + The identity of the packaged that was acted on. + The return code of the operation. + Whether a restart is required. + Recommended result from engine. + + + + Gets the identity of the package that was acted on. + + + + + Gets the package restart state after being applied. + + + + + Additional arguments used when the engine has completed installing packages. + + + + + Creates a new instance of the class. + + The return code of the operation. + + + + Additional arguments used by the engine to request a restart now or inform the user a manual restart is required later. + + + + + Creates a new instance of the class. + + + + + Gets or sets whether the engine should restart now. The default is false. + + + + + Additional arguments used when the engine has completed installing the bundle. + + + + + Creates a new instance of the clas. + + The return code of the operation. + Whether a restart is required. + + + + Gets the apply restart state when complete. + + + + + Additional arguments used by the engine to allow the user experience to change the source + using or . + + + + + Creates a new instance of the class. + + The identity of the package or container that requires source. + The identity of the payload that requires source. + The current path used for source resolution. + Optional URL to download container or payload. + + + + Gets the identity of the package or container that requires source. + + + + + Gets the identity of the payload that requires source. + + + + + Gets the current path used for source resolution. + + + + + Gets the optional URL to download container or payload. + + + + + Additional arguments used by the engine when it has begun caching a specific package. + + + + + Creates a new instance of the class. + + The identity of the package that is being cached. + Number of payloads to be cached. + The size on disk required by the specific package. + + + + Gets the identity of the package that is being cached. + + + + + Gets number of payloads to be cached. + + + + + Gets the size on disk required by the specific package. + + + + + Additional arguments passed by the engine when it has completed caching a specific package. + + + + + Creates a new instance of the class. + + The identity of the package that was cached. + The return code of the operation. + Recommended result from engine. + + + + Gets the identity of the package that was cached. + + + + + Additional arguments passed by the engine when it has begun downloading a specific payload. + + + + + Creates a new instance of the class. + + The identifier of the payload being downloaded. + The file name of the payload being downloaded. + + + + Gets the identifier of the payload being downloaded. + + + + + Gets the file name of the payload being downloaded. + + + + + Additional arguments passed by the engine when it has completed downloading a specific payload. + + + + + Creates a new instance of the class. + + The identifier of the payload that was downloaded. + The file name of the payload that was downloaded. + The return code of the operation. + + + + Gets the identifier of the payload that was downloaded. + + + + + Gets the file name of the payload that was downloaded. + + + + + Additional arguments passed by the engine while downloading payload. + + + + + Creates a new instance of the class. + + The percentage from 0 to 100 of the download progress for a single payload. + The percentage from 0 to 100 of the download progress for all payload. + + + + Gets the percentage from 0 to 100 of the download progress for a single payload. + + + + + Gets the percentage from 0 to 100 of the download progress for all payload. + + + + + Additional arguments passed by the engine while executing on payload. + + + + + Creates a new instance of the class. + + The identifier of the package being executed. + The percentage from 0 to 100 of the execution progress for a single payload. + The percentage from 0 to 100 of the execution progress for all payload. + + + + Gets the identity of the package that was executed. + + + + + Gets the percentage from 0 to 100 of the execution progress for a single payload. + + + + + Gets the percentage from 0 to 100 of the execution progress for all payload. + + + + + Additional arguments passed by the engine before it tries to launch the preapproved executable. + + + + + Additional arguments passed by the engine after it finished trying to launch the preapproved executable. + + + + + Gets the ProcessId of the process that was launched. + This is only valid if the status reports success. + + + + + Base class for exception returned to the bootstrapper application host. + + + + + Creates an instance of the base class with the given HRESULT. + + The HRESULT for the exception that is used by the bootstrapper application host. + + + + Initializes a new instance of the class. + + Exception message. + + + + Initializes a new instance of the class. + + Exception message + Inner exception associated with this one + + + + Initializes a new instance of the class. + + Serialization information for this exception + Streaming context to serialize to + + + + The bootstrapper application loaded by the host does not contain exactly one instance of the + class. + + + + + + Creates a new instance of the class. + + + + + Initializes a new instance of the class. + + Exception message. + + + + Initializes a new instance of the class. + + Exception message + Inner exception associated with this one + + + + Initializes a new instance of the class. + + Serialization information for this exception + Streaming context to serialize to + + + + The bootstrapper application specified by the + does not extend the base class. + + + + + + + Creates a new instance of the class. + + + + + Initializes a new instance of the class. + + Exception message. + + + + Initializes a new instance of the class. + + Exception message + Inner exception associated with this one + + + + Initializes a new instance of the class. + + Serialization information for this exception + Streaming context to serialize to + + + + Handler for the Host configuration section. + + + + + Creates a new instance of the class. + + + + + Gets the name of the assembly that contians the child class. + + + The assembly specified by this name must contain the to identify + the type of the child class. + + + + + Gets the of supported frameworks for the host configuration. + + + + + The display level for the UX. + + + + + Messages from Windows Installer. + + + + + The action to perform when a reboot is necessary. + + + + + Result codes. + + + + + Describes why a bundle or packaged is being resumed. + + + + + Resume information exists but is invalid. + + + + + The bundle was re-launched after an unexpected interruption. + + + + + A reboot is pending. + + + + + The bundle was re-launched after a reboot. + + + + + The bundle was re-launched after being suspended. + + + + + The bundle was launched from Add/Remove Programs. + + + + + Indicates what caused the error. + + + + + The error occurred trying to elevate. + + + + + The error came from the Windows Installer. + + + + + The error came from an EXE Package. + + + + + The error came while trying to authenticate with an HTTP server. + + + + + The error came while trying to authenticate with an HTTP proxy. + + + + + The related bundle or package will be downgraded. + + + + + The related package will be upgraded as a minor revision. + + + + + The related bundle or package will be upgraded as a major revision. + + + + + The related bundle will be removed. + + + + + The related bundle will be installed. + + + + + The related bundle will be repaired. + + + + + The cache operation used to acquire a container or payload. + + + + + Container or payload is being copied. + + + + + Container or payload is being downloaded. + + + + + Container or payload is being extracted. + + + + + The restart state after a package or all packages were applied. + + + + + Package or chain does not require a restart. + + + + + Package or chain requires a restart but it has not been initiated yet. + + + + + Package or chain has already initiated the restart. + + + + + The relation type for related bundles. + + + + + One or more reasons why the application is requested to be closed or is being closed. + + + + + The system is shutting down or restarting (it is not possible to determine which event is occurring). + + + + + The application is using a file that must be replaced, the system is being serviced, or system resources are exhausted. + + + + + The application is forced to shut down. + + + + + The user is logging off. + + + + + Command information passed from the engine for the user experience to perform. + + + + + Gets the command line arguments as a string array. + + + Array of command line arguments not handled by the engine. + + The command line could not be parsed into an array. + + This method uses the same parsing as the operating system which handles quotes and spaces correctly. + + + + + Gets the action for the user experience to perform. + + + + + Gets the display level for the user experience. + + + + + Gets the action to perform if a reboot is required. + + + + + Gets command line arguments that weren't processed by the engine. Can be null. + + + + + Gets layout directory. + + + + + Gets the method of how the engine was resumed from a previous installation step. + + + + + Gets the handle to the splash screen window. If no splash screen was displayed this value will be IntPtr.Zero. + + + + + If this was run from a related bundle, specifies the relation type. + + + + + If this was run from a backward compatible bundle. + + + + + Allows calls into the bootstrapper engine. + + + + + The installation action for the bundle or current package. + + + + + The action for the BA to perform. + + + + + The message log level. + + + + + No logging level (generic). + + + + + User messages. + + + + + Verbose messages. + + + + + Messages for debugging. + + + + + Error messages. + + + + + Type of hash used for update bundle. + + + + + No hash provided. + + + + + SHA-1 based hash provided. + + + + + Describes the state of an installation package. + + + + + Indicates the state desired for an installation package. + + + + + Indicates the state of a feature. + + + + + Indicates the action for a feature. + + + + + Contains native constants, functions, and structures for this assembly. + + + + + Distribution specific strings. + + + + + News URL for the distribution. + + + + + Short product name for the distribution. + + + + + Support URL for the distribution. + + + + + Telemetry URL format for the distribution. + + + + diff --git a/tools/WIX/sdk/DocCompiler.exe b/tools/WIX/sdk/DocCompiler.exe index 43779fe6..c600f862 100644 Binary files a/tools/WIX/sdk/DocCompiler.exe and b/tools/WIX/sdk/DocCompiler.exe differ diff --git a/tools/WIX/sdk/MakeSfxCA.exe b/tools/WIX/sdk/MakeSfxCA.exe index edc5fc2b..04cf2105 100644 Binary files a/tools/WIX/sdk/MakeSfxCA.exe and b/tools/WIX/sdk/MakeSfxCA.exe differ diff --git a/tools/WIX/sdk/Microsoft.Deployment.Compression.Cab.dll b/tools/WIX/sdk/Microsoft.Deployment.Compression.Cab.dll index f5de31ad..9cba0fe6 100644 Binary files a/tools/WIX/sdk/Microsoft.Deployment.Compression.Cab.dll and b/tools/WIX/sdk/Microsoft.Deployment.Compression.Cab.dll differ diff --git a/tools/WIX/sdk/Microsoft.Deployment.Compression.Cab.xml b/tools/WIX/sdk/Microsoft.Deployment.Compression.Cab.xml index 54bd28f5..91f7088c 100644 --- a/tools/WIX/sdk/Microsoft.Deployment.Compression.Cab.xml +++ b/tools/WIX/sdk/Microsoft.Deployment.Compression.Cab.xml @@ -461,5 +461,30 @@ GCHandle doesn't like the bool type, so use an int underneath.
+ + + Distribution specific strings. + + + + + News URL for the distribution. + + + + + Short product name for the distribution. + + + + + Support URL for the distribution. + + + + + Telemetry URL format for the distribution. + + diff --git a/tools/WIX/sdk/Microsoft.Deployment.Compression.Zip.dll b/tools/WIX/sdk/Microsoft.Deployment.Compression.Zip.dll index 6de59f49..2d945b87 100644 Binary files a/tools/WIX/sdk/Microsoft.Deployment.Compression.Zip.dll and b/tools/WIX/sdk/Microsoft.Deployment.Compression.Zip.dll differ diff --git a/tools/WIX/sdk/Microsoft.Deployment.Compression.Zip.xml b/tools/WIX/sdk/Microsoft.Deployment.Compression.Zip.xml index 75780575..305c9aa9 100644 --- a/tools/WIX/sdk/Microsoft.Deployment.Compression.Zip.xml +++ b/tools/WIX/sdk/Microsoft.Deployment.Compression.Zip.xml @@ -518,5 +518,30 @@ A list of objects, each containing information about a file in the archive. + + + Distribution specific strings. + + + + + News URL for the distribution. + + + + + Short product name for the distribution. + + + + + Support URL for the distribution. + + + + + Telemetry URL format for the distribution. + + diff --git a/tools/WIX/sdk/Microsoft.Deployment.Compression.dll b/tools/WIX/sdk/Microsoft.Deployment.Compression.dll index 24445732..e7d2f79a 100644 Binary files a/tools/WIX/sdk/Microsoft.Deployment.Compression.dll and b/tools/WIX/sdk/Microsoft.Deployment.Compression.dll differ diff --git a/tools/WIX/sdk/Microsoft.Deployment.Compression.xml b/tools/WIX/sdk/Microsoft.Deployment.Compression.xml index 18eb1be6..28cddeac 100644 --- a/tools/WIX/sdk/Microsoft.Deployment.Compression.xml +++ b/tools/WIX/sdk/Microsoft.Deployment.Compression.xml @@ -1931,5 +1931,30 @@ is equal to the position of the source stream minus the offset. + + + Distribution specific strings. + + + + + News URL for the distribution. + + + + + Short product name for the distribution. + + + + + Support URL for the distribution. + + + + + Telemetry URL format for the distribution. + + diff --git a/tools/WIX/sdk/Microsoft.Deployment.Resources.dll b/tools/WIX/sdk/Microsoft.Deployment.Resources.dll index 17a9d340..4fe3340f 100644 Binary files a/tools/WIX/sdk/Microsoft.Deployment.Resources.dll and b/tools/WIX/sdk/Microsoft.Deployment.Resources.dll differ diff --git a/tools/WIX/sdk/Microsoft.Deployment.Resources.xml b/tools/WIX/sdk/Microsoft.Deployment.Resources.xml index a5fe1001..58b0205d 100644 --- a/tools/WIX/sdk/Microsoft.Deployment.Resources.xml +++ b/tools/WIX/sdk/Microsoft.Deployment.Resources.xml @@ -507,5 +507,30 @@ Gets the number of strings in the table. + + + Distribution specific strings. + + + + + News URL for the distribution. + + + + + Short product name for the distribution. + + + + + Support URL for the distribution. + + + + + Telemetry URL format for the distribution. + + diff --git a/tools/WIX/sdk/Microsoft.Deployment.WindowsInstaller.Linq.dll b/tools/WIX/sdk/Microsoft.Deployment.WindowsInstaller.Linq.dll index 231d8589..d9d732ee 100644 Binary files a/tools/WIX/sdk/Microsoft.Deployment.WindowsInstaller.Linq.dll and b/tools/WIX/sdk/Microsoft.Deployment.WindowsInstaller.Linq.dll differ diff --git a/tools/WIX/sdk/Microsoft.Deployment.WindowsInstaller.Linq.xml b/tools/WIX/sdk/Microsoft.Deployment.WindowsInstaller.Linq.xml index c297f892..1c142242 100644 --- a/tools/WIX/sdk/Microsoft.Deployment.WindowsInstaller.Linq.xml +++ b/tools/WIX/sdk/Microsoft.Deployment.WindowsInstaller.Linq.xml @@ -430,5 +430,30 @@ the result type of the current query -- either some kind of QRecord, or some projection of record data + + + Distribution specific strings. + + + + + News URL for the distribution. + + + + + Short product name for the distribution. + + + + + Support URL for the distribution. + + + + + Telemetry URL format for the distribution. + + diff --git a/tools/WIX/sdk/Microsoft.Deployment.WindowsInstaller.Package.dll b/tools/WIX/sdk/Microsoft.Deployment.WindowsInstaller.Package.dll index d509c647..ac8e1bd1 100644 Binary files a/tools/WIX/sdk/Microsoft.Deployment.WindowsInstaller.Package.dll and b/tools/WIX/sdk/Microsoft.Deployment.WindowsInstaller.Package.dll differ diff --git a/tools/WIX/sdk/Microsoft.Deployment.WindowsInstaller.Package.xml b/tools/WIX/sdk/Microsoft.Deployment.WindowsInstaller.Package.xml index 1450ade6..15d1102e 100644 --- a/tools/WIX/sdk/Microsoft.Deployment.WindowsInstaller.Package.xml +++ b/tools/WIX/sdk/Microsoft.Deployment.WindowsInstaller.Package.xml @@ -675,5 +675,30 @@ Gets the validation flags specified when the transform was generated. + + + Distribution specific strings. + + + + + News URL for the distribution. + + + + + Short product name for the distribution. + + + + + Support URL for the distribution. + + + + + Telemetry URL format for the distribution. + + diff --git a/tools/WIX/sdk/Microsoft.Deployment.WindowsInstaller.dll b/tools/WIX/sdk/Microsoft.Deployment.WindowsInstaller.dll index 0a7d1e99..ebf46ae9 100644 Binary files a/tools/WIX/sdk/Microsoft.Deployment.WindowsInstaller.dll and b/tools/WIX/sdk/Microsoft.Deployment.WindowsInstaller.dll differ diff --git a/tools/WIX/sdk/Microsoft.Deployment.WindowsInstaller.xml b/tools/WIX/sdk/Microsoft.Deployment.WindowsInstaller.xml index ca8df3c2..b9521e96 100644 --- a/tools/WIX/sdk/Microsoft.Deployment.WindowsInstaller.xml +++ b/tools/WIX/sdk/Microsoft.Deployment.WindowsInstaller.xml @@ -907,6 +907,7 @@ v0 - Binary Stream g? - Temporary string (?=0-255) j? - Temporary integer (?=0,1,2,4) + O0 - Temporary object (stream) l? - Localizable string, variable length (?=1-255) l0 - Localizable string, variable length @@ -7379,5 +7380,30 @@ MsiViewGetColumnInfo

+ + + Distribution specific strings. + + + + + News URL for the distribution. + + + + + Short product name for the distribution. + + + + + Support URL for the distribution. + + + + + Telemetry URL format for the distribution. + + diff --git a/tools/WIX/sdk/MsgGen.exe b/tools/WIX/sdk/MsgGen.exe index e5092560..8c806749 100644 Binary files a/tools/WIX/sdk/MsgGen.exe and b/tools/WIX/sdk/MsgGen.exe differ diff --git a/tools/WIX/sdk/XsdGen.exe b/tools/WIX/sdk/XsdGen.exe index 525f4318..429f1d32 100644 Binary files a/tools/WIX/sdk/XsdGen.exe and b/tools/WIX/sdk/XsdGen.exe differ diff --git a/tools/WIX/sdk/XsdStitch.exe b/tools/WIX/sdk/XsdStitch.exe index 363058aa..c0230efb 100644 Binary files a/tools/WIX/sdk/XsdStitch.exe and b/tools/WIX/sdk/XsdStitch.exe differ diff --git a/tools/WIX/sdk/inc/BalBaseBootstrapperApplication.h b/tools/WIX/sdk/inc/BalBaseBootstrapperApplication.h index 48304984..c5738e80 100644 --- a/tools/WIX/sdk/inc/BalBaseBootstrapperApplication.h +++ b/tools/WIX/sdk/inc/BalBaseBootstrapperApplication.h @@ -65,7 +65,7 @@ public: // IUnknown return 0; } -public: // IBurnUserExperience +public: // IBootstrapperApplication virtual STDMETHODIMP OnStartup() { return S_OK; @@ -118,6 +118,20 @@ public: // IBurnUserExperience return CheckCanceled() ? IDCANCEL : nRecommendation; } + virtual STDMETHODIMP_(int) OnDetectUpdate( + __in_z LPCWSTR /*wzUpdateLocation*/, + __in DWORD64 /*dw64Size*/, + __in DWORD64 /*dw64Version*/, + __in_z LPCWSTR /*wzTitle*/, + __in_z LPCWSTR /*wzSummary*/, + __in_z LPCWSTR /*wzContentType*/, + __in_z LPCWSTR /*wzContent*/, + __in int nRecommendation + ) + { + return CheckCanceled() ? IDCANCEL : nRecommendation; + } + virtual STDMETHODIMP_(void) OnDetectUpdateComplete( __in HRESULT /*hrStatus*/, __in_z_opt LPCWSTR /*wzUpdateLocation*/ @@ -125,6 +139,14 @@ public: // IBurnUserExperience { } + virtual STDMETHODIMP_(int) OnDetectCompatiblePackage( + __in_z LPCWSTR /*wzPackageId*/, + __in_z LPCWSTR /*wzCompatiblePackageId*/ + ) + { + return CheckCanceled() ? IDCANCEL : IDNOACTION; + } + virtual STDMETHODIMP_(int) OnDetectPriorBundle( __in_z LPCWSTR /*wzBundleId*/ ) @@ -217,6 +239,14 @@ public: // IBurnUserExperience return CheckCanceled() ? IDCANCEL : IDNOACTION; } + virtual STDMETHODIMP_(int) OnPlanCompatiblePackage( + __in_z LPCWSTR /*wzPackageId*/, + __inout BOOTSTRAPPER_REQUEST_STATE* /*pRequestedState*/ + ) + { + return CheckCanceled() ? IDCANCEL : IDNOACTION; + } + virtual STDMETHODIMP_(int) OnPlanTargetMsiPackage( __in_z LPCWSTR /*wzPackageId*/, __in_z LPCWSTR /*wzProductCode*/, @@ -255,9 +285,20 @@ public: // IBurnUserExperience virtual STDMETHODIMP_(int) OnApplyBegin() { m_fApplying = TRUE; + + m_dwProgressPercentage = 0; + m_dwOverallProgressPercentage = 0; + return CheckCanceled() ? IDCANCEL : IDNOACTION; } + // DEPRECATED: this will be merged with OnApplyBegin in wix4. + virtual STDMETHODIMP_(void) OnApplyPhaseCount( + __in DWORD /*dwPhaseCount*/ + ) + { + } + virtual STDMETHODIMP_(int) OnElevate() { return CheckCanceled() ? IDCANCEL : IDNOACTION; @@ -329,7 +370,19 @@ public: // IBurnUserExperience __in DWORD /*dwOverallPercentage*/ ) { - return CheckCanceled() ? IDCANCEL : IDNOACTION; + HRESULT hr = S_OK; + int nResult = IDNOACTION; + + // Send progress even though we don't update the numbers to at least give the caller an opportunity + // to cancel. + if (BOOTSTRAPPER_DISPLAY_EMBEDDED == m_display) + { + hr = m_pEngine->SendEmbeddedProgress(m_dwProgressPercentage, m_dwOverallProgressPercentage, &nResult); + BalExitOnFailure(hr, "Failed to send embedded cache progress."); + } + + LExit: + return FAILED(hr) ? IDERROR : CheckCanceled() ? IDCANCEL : nResult; } virtual STDMETHODIMP_(int) OnCacheAcquireComplete( @@ -431,11 +484,24 @@ public: // IBurnUserExperience } virtual STDMETHODIMP_(int) OnProgress( - __in DWORD /*dwProgressPercentage*/, - __in DWORD /*dwOverallProgressPercentage*/ + __in DWORD dwProgressPercentage, + __in DWORD dwOverallProgressPercentage ) { - return CheckCanceled() ? IDCANCEL : IDNOACTION; + HRESULT hr = S_OK; + int nResult = IDNOACTION; + + m_dwProgressPercentage = dwProgressPercentage; + m_dwOverallProgressPercentage = dwOverallProgressPercentage; + + if (BOOTSTRAPPER_DISPLAY_EMBEDDED == m_display) + { + hr = m_pEngine->SendEmbeddedProgress(m_dwProgressPercentage, m_dwOverallProgressPercentage, &nResult); + BalExitOnFailure(hr, "Failed to send embedded overall progress."); + } + + LExit: + return FAILED(hr) ? IDERROR : CheckCanceled() ? IDCANCEL : nResult; } virtual STDMETHODIMP_(int) OnDownloadPayloadBegin( @@ -455,13 +521,25 @@ public: // IBurnUserExperience return CheckCanceled() ? IDCANCEL : IDNOACTION; } - virtual STDMETHODIMP_(int) OnExecuteProgress( + virtual STDMETHODIMP_(int) OnExecuteProgress( __in_z LPCWSTR /*wzPackageId*/, __in DWORD /*dwProgressPercentage*/, __in DWORD /*dwOverallProgressPercentage*/ ) { - return CheckCanceled() ? IDCANCEL : IDNOACTION; + HRESULT hr = S_OK; + int nResult = IDNOACTION; + + // Send progress even though we don't update the numbers to at least give the caller an opportunity + // to cancel. + if (BOOTSTRAPPER_DISPLAY_EMBEDDED == m_display) + { + hr = m_pEngine->SendEmbeddedProgress(m_dwProgressPercentage, m_dwOverallProgressPercentage, &nResult); + BalExitOnFailure(hr, "Failed to send embedded execute progress."); + } + + LExit: + return FAILED(hr) ? IDERROR : CheckCanceled() ? IDCANCEL : nResult; } virtual STDMETHODIMP_(int) OnExecuteMsiMessage( @@ -513,6 +591,18 @@ public: // IBurnUserExperience return CheckCanceled() ? IDCANCEL : IDNOACTION; } + virtual STDMETHODIMP_(int) OnLaunchApprovedExeBegin() + { + return CheckCanceled() ? IDCANCEL : IDNOACTION; + } + + virtual STDMETHODIMP_(void) OnLaunchApprovedExeComplete( + __in HRESULT /*hrStatus*/, + __in DWORD /*dwProcessId*/ + ) + { + } + protected: // // PromptCancel - prompts the user to close (if not forced). @@ -565,7 +655,7 @@ protected: } CBalBaseBootstrapperApplication( - __in IBootstrapperEngine* /*pEngine*/, + __in IBootstrapperEngine* pEngine, __in const BOOTSTRAPPER_COMMAND* pCommand, __in DWORD dwRetryCount = 0, __in DWORD dwRetryTimeout = 1000 @@ -575,6 +665,9 @@ protected: m_display = pCommand->display; m_restart = pCommand->restart; + pEngine->AddRef(); + m_pEngine = pEngine; + ::InitializeCriticalSection(&m_csCanceled); m_fCanceled = FALSE; m_fApplying = FALSE; @@ -587,15 +680,21 @@ protected: { BalRetryUninitialize(); ::DeleteCriticalSection(&m_csCanceled); + + ReleaseNullObject(m_pEngine); } private: long m_cReferences; BOOTSTRAPPER_DISPLAY m_display; BOOTSTRAPPER_RESTART m_restart; + IBootstrapperEngine* m_pEngine; CRITICAL_SECTION m_csCanceled; BOOL m_fCanceled; BOOL m_fApplying; BOOL m_fRollingBack; + + DWORD m_dwProgressPercentage; + DWORD m_dwOverallProgressPercentage; }; diff --git a/tools/WIX/sdk/inc/IBootstrapperApplication.h b/tools/WIX/sdk/inc/IBootstrapperApplication.h index 55ab50ab..2a9a460d 100644 --- a/tools/WIX/sdk/inc/IBootstrapperApplication.h +++ b/tools/WIX/sdk/inc/IBootstrapperApplication.h @@ -188,6 +188,25 @@ DECLARE_INTERFACE_IID_(IBootstrapperApplication, IUnknown, "53C31D56-49C0-426B-A __in int nRecommendation ) = 0; + // OnDetectUpdate - called when the engine has an update candidate for bundle update. + // + // Return: + // IDOK instructs the engine to stop further update detection. + // + // IDCANCEL instructs the engine to stop detection. + // + // IDNOACTION instructs the engine to process further update candidates. + STDMETHOD_(int, OnDetectUpdate)( + __in_z_opt LPCWSTR wzUpdateLocation, + __in DWORD64 dw64Size, + __in DWORD64 dw64Version, + __in_z_opt LPCWSTR wzTitle, + __in_z_opt LPCWSTR wzSummary, + __in_z_opt LPCWSTR wzContentType, + __in_z_opt LPCWSTR wzContent, + __in int nRecommendation + ) = 0; + // OnDetectUpdateComplete - called when the engine completes detection for bundle update. // // Remarks: @@ -222,6 +241,17 @@ DECLARE_INTERFACE_IID_(IBootstrapperApplication, IUnknown, "53C31D56-49C0-426B-A __in_z LPCWSTR wzPackageId ) = 0; + // OnDetectCompatiblePackage - called when the engine detects that a package is not installed but a newer package using the same provider key is. + // + // Return: + // IDCANCEL instructs the engine to stop detection. + // + // IDNOACTION instructs the engine to continue. + STDMETHOD_(int, OnDetectCompatiblePackage)( + __in_z LPCWSTR wzPackageId, + __in_z LPCWSTR wzCompatiblePackageId + ) = 0; + // OnDetectRelatedMsiPackage - called when the engine begins detects a related package. // // Return: @@ -307,6 +337,17 @@ DECLARE_INTERFACE_IID_(IBootstrapperApplication, IUnknown, "53C31D56-49C0-426B-A __inout BOOTSTRAPPER_REQUEST_STATE* pRequestedState ) = 0; + // OnPlanCompatiblePackage - called when the engine plans a newer, compatible package using the same provider key. + // + // Return: + // IDCANCEL instructs the engine to stop planning. + // + // IDNOACTION instructs the engine to continue. + STDMETHOD_(int, OnPlanCompatiblePackage)( + __in_z LPCWSTR wzPackageId, + __inout BOOTSTRAPPER_REQUEST_STATE* pRequestedState + ) = 0; + // OnPlanTargetMsiPackage - called when the engine plans an MSP package // to apply to an MSI package. // @@ -358,6 +399,13 @@ DECLARE_INTERFACE_IID_(IBootstrapperApplication, IUnknown, "53C31D56-49C0-426B-A // IDNOACTION instructs the engine to continue. STDMETHOD_(int, OnApplyBegin)() = 0; + // DEPRECATED: In wix4, this will be merged with OnApplyBegin. + // OnApplyPhaseCount - called right after OnApplyBegin. + // + STDMETHOD_(void, OnApplyPhaseCount)( + __in DWORD dwPhaseCount + ) = 0; + // OnElevate - called before the engine displays an elevation prompt. // Will only happen once per execution of the engine. // @@ -619,8 +667,18 @@ DECLARE_INTERFACE_IID_(IBootstrapperApplication, IUnknown, "53C31D56-49C0-426B-A // executing a package. // // Return: - // IDNOACTION instructs the engine to pass the message through to default - // handling which usually results in the execution continuing. + // IDOK instructs the engine to let the Restart Manager attempt to close the + // applications to avoid a restart. + // + // IDCANCEL instructs the engine to abort the execution and start rollback. + // + // IDIGNORE instructs the engine to ignore the running applications. A restart will be + // required. + // + // IDRETRY instructs the engine to check if the applications are still running again. + // + // IDNOACTION is equivalent to ignoring the running applications. A restart will be + // required. STDMETHOD_(int, OnExecuteFilesInUse)( __in_z LPCWSTR wzPackageId, __in DWORD cFiles, @@ -682,6 +740,21 @@ DECLARE_INTERFACE_IID_(IBootstrapperApplication, IUnknown, "53C31D56-49C0-426B-A __in HRESULT hrStatus, __in BOOTSTRAPPER_APPLY_RESTART restart ) = 0; + + // OnLaunchApprovedExeBegin - called before trying to launch the preapproved executable. + // + STDMETHOD_(int, OnLaunchApprovedExeBegin)() = 0; + + + // OnLaunchApprovedExeComplete - called after trying to launch the preapproved executable. + // + // Parameters: + // dwProcessId is only valid if the operation succeeded. + // + STDMETHOD_(void, OnLaunchApprovedExeComplete)( + __in HRESULT hrStatus, + __in DWORD dwProcessId + ) = 0; }; diff --git a/tools/WIX/sdk/inc/IBootstrapperBAFunction.h b/tools/WIX/sdk/inc/IBootstrapperBAFunction.h new file mode 100644 index 00000000..5f688bb5 --- /dev/null +++ b/tools/WIX/sdk/inc/IBootstrapperBAFunction.h @@ -0,0 +1,36 @@ +//------------------------------------------------------------------------------------------------- +// +// Copyright (c) 2004, Outercurve Foundation. +// This software is released under Microsoft Reciprocal License (MS-RL). +// The license and further copyright text can be found in the file +// LICENSE.TXT at the root directory of the distribution. +// +//------------------------------------------------------------------------------------------------- + +#pragma once + +#include + +#include "IBootstrapperEngine.h" + +interface IBootstrapperBAFunction +{ + STDMETHOD(OnDetect)() = 0; + STDMETHOD(OnDetectComplete)() = 0; + STDMETHOD(OnPlan)() = 0; + STDMETHOD(OnPlanComplete)() = 0; +}; + +#ifdef __cplusplus +extern "C" { +#endif + +typedef HRESULT (WINAPI *PFN_BOOTSTRAPPER_BA_FUNCTION_CREATE)( + __in IBootstrapperEngine* pEngine, + __in HMODULE hModule, + __out IBootstrapperBAFunction** ppBAFunction + ); + +#ifdef __cplusplus +} +#endif diff --git a/tools/WIX/sdk/inc/IBootstrapperEngine.h b/tools/WIX/sdk/inc/IBootstrapperEngine.h index 4c2a4191..bfb6d126 100644 --- a/tools/WIX/sdk/inc/IBootstrapperEngine.h +++ b/tools/WIX/sdk/inc/IBootstrapperEngine.h @@ -200,7 +200,9 @@ DECLARE_INTERFACE_IID_(IBootstrapperEngine, IUnknown, "6480D616-27A0-44D7-905B-8 STDMETHOD(CloseSplashScreen)() = 0; - STDMETHOD(Detect)() = 0; + STDMETHOD(Detect)( + __in_opt HWND hwndParent = NULL + ) = 0; STDMETHOD(Plan)( __in BOOTSTRAPPER_ACTION action @@ -217,4 +219,11 @@ DECLARE_INTERFACE_IID_(IBootstrapperEngine, IUnknown, "6480D616-27A0-44D7-905B-8 STDMETHOD(Quit)( __in DWORD dwExitCode ) = 0; + + STDMETHOD(LaunchApprovedExe)( + __in_opt HWND hwndParent, + __in_z LPCWSTR wzApprovedExeForElevationId, + __in_z_opt LPCWSTR wzArguments, + __in DWORD dwWaitForInputIdleTimeout + ) = 0; }; diff --git a/tools/WIX/sdk/inc/apuputil.h b/tools/WIX/sdk/inc/apuputil.h index 966e7fae..324640a2 100644 --- a/tools/WIX/sdk/inc/apuputil.h +++ b/tools/WIX/sdk/inc/apuputil.h @@ -22,13 +22,13 @@ extern "C" { const LPCWSTR APPLICATION_SYNDICATION_NAMESPACE = L"http://appsyndication.org/2006/appsyn"; -enum APUP_HASH_ALGORITHM +typedef enum APUP_HASH_ALGORITHM { APUP_HASH_ALGORITHM_UNKNOWN, APUP_HASH_ALGORITHM_MD5, APUP_HASH_ALGORITHM_SHA1, APUP_HASH_ALGORITHM_SHA256, -}; +} APUP_HASH_ALGORITHM; struct APPLICATION_UPDATE_ENCLOSURE @@ -49,6 +49,10 @@ struct APPLICATION_UPDATE_ENTRY { LPWSTR wzApplicationId; LPWSTR wzApplicationType; + LPWSTR wzTitle; + LPWSTR wzSummary; + LPWSTR wzContentType; + LPWSTR wzContent; LPWSTR wzUpgradeId; BOOL fUpgradeExclusive; diff --git a/tools/WIX/sdk/inc/balinfo.h b/tools/WIX/sdk/inc/balinfo.h index 337b2287..464feb22 100644 --- a/tools/WIX/sdk/inc/balinfo.h +++ b/tools/WIX/sdk/inc/balinfo.h @@ -6,7 +6,7 @@ // The license and further copyright text can be found in the file // LICENSE.TXT at the root directory of the distribution. // -// +// // // Bootstrapper Application Layer package utility. // @@ -17,13 +17,24 @@ extern "C" { #endif -enum BAL_INFO_PACKAGE_TYPE +typedef enum BAL_INFO_PACKAGE_TYPE { + BAL_INFO_PACKAGE_TYPE_UNKNOWN, BAL_INFO_PACKAGE_TYPE_EXE, BAL_INFO_PACKAGE_TYPE_MSI, BAL_INFO_PACKAGE_TYPE_MSP, BAL_INFO_PACKAGE_TYPE_MSU, -}; + BAL_INFO_PACKAGE_TYPE_BUNDLE_UPGRADE, + BAL_INFO_PACKAGE_TYPE_BUNDLE_ADDON, + BAL_INFO_PACKAGE_TYPE_BUNDLE_PATCH, +} BAL_INFO_PACKAGE_TYPE; + +typedef enum BAL_INFO_CACHE_TYPE +{ + BAL_INFO_CACHE_TYPE_NO, + BAL_INFO_CACHE_TYPE_YES, + BAL_INFO_CACHE_TYPE_ALWAYS, +} BAL_INFO_CACHE_TYPE; typedef struct _BAL_INFO_PACKAGE @@ -35,6 +46,11 @@ typedef struct _BAL_INFO_PACKAGE BOOL fPermanent; BOOL fVital; BOOL fDisplayInternalUI; + LPWSTR sczProductCode; + LPWSTR sczUpgradeCode; + LPWSTR sczVersion; + LPWSTR sczInstallCondition; + BAL_INFO_CACHE_TYPE cacheType; } BAL_INFO_PACKAGE; @@ -65,6 +81,18 @@ DAPI_(HRESULT) BalInfoParseFromXml( ); +/******************************************************************* + BalInfoAddRelatedBundleAsPackage - adds a related bundle as a package. + + ********************************************************************/ +DAPI_(HRESULT) BalInfoAddRelatedBundleAsPackage( + __in BAL_INFO_PACKAGES* pPackages, + __in LPCWSTR wzId, + __in BOOTSTRAPPER_RELATION_TYPE relationType, + __in BOOL fPerMachine + ); + + /******************************************************************* BalInfoFindPackageById - finds a package by its id. diff --git a/tools/WIX/sdk/inc/balretry.h b/tools/WIX/sdk/inc/balretry.h index c6452caf..086fb4b9 100644 --- a/tools/WIX/sdk/inc/balretry.h +++ b/tools/WIX/sdk/inc/balretry.h @@ -6,7 +6,7 @@ // The license and further copyright text can be found in the file // LICENSE.TXT at the root directory of the distribution. // -// +// // // Bootstrapper Application Layer retry utility. // @@ -17,11 +17,11 @@ extern "C" { #endif -enum BALRETRY_TYPE +typedef enum BALRETRY_TYPE { BALRETRY_TYPE_CACHE, BALRETRY_TYPE_EXECUTE, -}; +} BALRETRY_TYPE; /******************************************************************* BalRetryInitialize - initialize the retry count and timeout between diff --git a/tools/WIX/sdk/inc/balutil.h b/tools/WIX/sdk/inc/balutil.h index 6412ff1d..6668ea96 100644 --- a/tools/WIX/sdk/inc/balutil.h +++ b/tools/WIX/sdk/inc/balutil.h @@ -32,6 +32,12 @@ extern "C" { #define BalExitOnNullWithLastError(p, x, f) if (NULL == p) { DWORD Dutil_er = ::GetLastError(); x = HRESULT_FROM_WIN32(Dutil_er); if (!FAILED(x)) { x = E_FAIL; } BalLogError(x, f); ExitTrace(x, f); goto LExit; } #define BalExitOnNullWithLastError1(p, x, f, s) if (NULL == p) { DWORD Dutil_er = ::GetLastError(); x = HRESULT_FROM_WIN32(Dutil_er); if (!FAILED(x)) { x = E_FAIL; } BalLogError(x, f, s); ExitTrace1(x, f, s); goto LExit; } +#define FACILITY_WIX 500 + +static const HRESULT E_WIXSTDBA_CONDITION_FAILED = MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIX, 1); + +static const HRESULT E_MBAHOST_NET452_ON_WIN7RTM = MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIX, 1000); + /******************************************************************* BalInitialize - remembers the engine interface to enable logging and diff --git a/tools/WIX/sdk/inc/butil.h b/tools/WIX/sdk/inc/butil.h new file mode 100644 index 00000000..e70f76ed --- /dev/null +++ b/tools/WIX/sdk/inc/butil.h @@ -0,0 +1,41 @@ +//------------------------------------------------------------------------------------------------- +// +// Copyright (c) 2004, Outercurve Foundation. +// This software is released under Microsoft Reciprocal License (MS-RL). +// The license and further copyright text can be found in the file +// LICENSE.TXT at the root directory of the distribution. +// +// +// +// Header for bundle helper functions. +// +//------------------------------------------------------------------------------------------------- +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +enum BUNDLE_INSTALL_CONTEXT +{ + BUNDLE_INSTALL_CONTEXT_MACHINE, + BUNDLE_INSTALL_CONTEXT_USER, +}; + +HRESULT DAPI BundleGetBundleInfo( + __in LPCWSTR szBundleId, // Bundle code + __in LPCWSTR szAttribute, // attribute name + __out_ecount_opt(*pcchValueBuf) LPWSTR lpValueBuf, // returned value, NULL if not desired + __inout_opt LPDWORD pcchValueBuf // in/out buffer character count + ); + +HRESULT DAPI BundleEnumRelatedBundle( + __in LPCWSTR lpUpgradeCode, + __in BUNDLE_INSTALL_CONTEXT context, + __inout PDWORD pdwStartIndex, + __out_ecount(MAX_GUID_CHARS+1) LPWSTR lpBundleIdBuf + ); + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/tools/WIX/sdk/inc/cabcutil.h b/tools/WIX/sdk/inc/cabcutil.h index aaa08a2c..9186d321 100644 --- a/tools/WIX/sdk/inc/cabcutil.h +++ b/tools/WIX/sdk/inc/cabcutil.h @@ -6,7 +6,7 @@ // The license and further copyright text can be found in the file // LICENSE.TXT at the root directory of the distribution. // -// +// // // Header for cabinet creation helper functions. // @@ -16,6 +16,12 @@ #include #include +// Callback from PFNFCIGETNEXTCABINET CabCGetNextCabinet method +// First argument is the name of splitting cabinet without extension e.g. "cab1" +// Second argument is name of the new cabinet that would be formed by splitting e.g. "cab1b.cab" +// Third argument is the file token of the first file present in the splitting cabinet +typedef void (__stdcall * FileSplitCabNamesCallback)(LPWSTR, LPWSTR, LPWSTR); + #define CAB_MAX_SIZE 0x7FFFFFFF // (see KB: Q174866) #ifdef __cplusplus @@ -25,14 +31,14 @@ extern "C" { extern const int CABC_HANDLE_BYTES; // time vs. space trade-off -enum COMPRESSION_TYPE -{ +typedef enum COMPRESSION_TYPE +{ COMPRESSION_TYPE_NONE, // fastest - COMPRESSION_TYPE_LOW, + COMPRESSION_TYPE_LOW, COMPRESSION_TYPE_MEDIUM, COMPRESSION_TYPE_HIGH, // smallest COMPRESSION_TYPE_MSZIP -}; +} COMPRESSION_TYPE; // functions HRESULT DAPI CabCBegin( @@ -54,7 +60,8 @@ HRESULT DAPI CabCAddFile( __in_bcount(CABC_HANDLE_BYTES) HANDLE hContext ); HRESULT DAPI CabCFinish( - __in_bcount(CABC_HANDLE_BYTES) HANDLE hContext + __in_bcount(CABC_HANDLE_BYTES) HANDLE hContext, + __in_opt FileSplitCabNamesCallback fileSplitCabNamesCallback ); void DAPI CabCCancel( __in_bcount(CABC_HANDLE_BYTES) HANDLE hContext diff --git a/tools/WIX/sdk/inc/conutil.h b/tools/WIX/sdk/inc/conutil.h index 955a1f1e..b26c20ca 100644 --- a/tools/WIX/sdk/inc/conutil.h +++ b/tools/WIX/sdk/inc/conutil.h @@ -50,7 +50,7 @@ extern "C" { // enums -enum CONSOLE_COLOR { CONSOLE_COLOR_NORMAL, CONSOLE_COLOR_RED, CONSOLE_COLOR_YELLOW, CONSOLE_COLOR_GREEN }; +typedef enum CONSOLE_COLOR { CONSOLE_COLOR_NORMAL, CONSOLE_COLOR_RED, CONSOLE_COLOR_YELLOW, CONSOLE_COLOR_GREEN } CONSOLE_COLOR; // structs diff --git a/tools/WIX/sdk/inc/cryputil.h b/tools/WIX/sdk/inc/cryputil.h index 38d3d3f1..90ee3462 100644 --- a/tools/WIX/sdk/inc/cryputil.h +++ b/tools/WIX/sdk/inc/cryputil.h @@ -19,10 +19,39 @@ extern "C" { #endif +// Use CRYPTPROTECTMEMORY_BLOCK_SIZE, because it's larger and thus more restrictive than RTL_ENCRYPT_MEMORY_SIZE. +#define CRYP_ENCRYPT_MEMORY_SIZE CRYPTPROTECTMEMORY_BLOCK_SIZE #define SHA1_HASH_LEN 20 +typedef NTSTATUS (APIENTRY *PFN_RTLENCRYPTMEMORY)( + __inout PVOID Memory, + __in ULONG MemoryLength, + __in ULONG OptionFlags + ); + +typedef NTSTATUS (APIENTRY *PFN_RTLDECRYPTMEMORY)( + __inout PVOID Memory, + __in ULONG MemoryLength, + __in ULONG OptionFlags + ); + +typedef BOOL (APIENTRY *PFN_CRYPTPROTECTMEMORY)( + __inout LPVOID pData, + __in DWORD cbData, + __in DWORD dwFlags + ); + +typedef BOOL (APIENTRY *PFN_CRYPTUNPROTECTMEMORY)( + __inout LPVOID pData, + __in DWORD cbData, + __in DWORD dwFlags + ); + // function declarations +HRESULT DAPI CrypInitialize(); +void DAPI CrypUninitialize(); + HRESULT DAPI CrypDecodeObject( __in_z LPCSTR szStructType, __in_ecount(cbData) const BYTE* pbData, @@ -67,6 +96,18 @@ HRESULT DAPI CrypHashBuffer( __in DWORD cbHash ); +HRESULT DAPI CrypEncryptMemory( + __inout LPVOID pData, + __in DWORD cbData, + __in DWORD dwFlags + ); + +HRESULT DAPI CrypDecryptMemory( + __inout LPVOID pData, + __in DWORD cbData, + __in DWORD dwFlags + ); + #ifdef __cplusplus } #endif diff --git a/tools/WIX/sdk/inc/dictutil.h b/tools/WIX/sdk/inc/dictutil.h index 3b954214..47fadf1c 100644 --- a/tools/WIX/sdk/inc/dictutil.h +++ b/tools/WIX/sdk/inc/dictutil.h @@ -24,11 +24,11 @@ typedef const void* C_STRINGDICT_HANDLE; extern const int STRINGDICT_HANDLE_BYTES; -enum DICT_FLAG +typedef enum DICT_FLAG { DICT_FLAG_NONE = 0, DICT_FLAG_CASEINSENSITIVE = 1 -}; +} DICT_FLAG; HRESULT DAPI DictCreateWithEmbeddedKey( __out_bcount(STRINGDICT_HANDLE_BYTES) STRINGDICT_HANDLE* psdHandle, diff --git a/tools/WIX/sdk/inc/dirutil.h b/tools/WIX/sdk/inc/dirutil.h index 1d4e8653..f5017060 100644 --- a/tools/WIX/sdk/inc/dirutil.h +++ b/tools/WIX/sdk/inc/dirutil.h @@ -13,12 +13,12 @@ #pragma once -enum DIR_DELETE +typedef enum DIR_DELETE { DIR_DELETE_FILES = 1, DIR_DELETE_RECURSE = 2, DIR_DELETE_SCHEDULE = 4, -}; +} DIR_DELETE; #ifdef __cplusplus extern "C" { diff --git a/tools/WIX/sdk/inc/dlutil.h b/tools/WIX/sdk/inc/dlutil.h new file mode 100644 index 00000000..9366beab --- /dev/null +++ b/tools/WIX/sdk/inc/dlutil.h @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------------------------- +// +// Copyright (c) 2004, Outercurve Foundation. +// This software is released under Microsoft Reciprocal License (MS-RL). +// The license and further copyright text can be found in the file +// LICENSE.TXT at the root directory of the distribution. +// +// +// +// Setup chainer/bootstrapper download engine for WiX toolset. +// +//------------------------------------------------------------------------------------------------- + +#pragma once + + +#ifdef __cplusplus +extern "C" { +#endif + +typedef HRESULT (WINAPI *LPAUTHENTICATION_ROUTINE)( + __in LPVOID pVoid, + __in HINTERNET hUrl, + __in long lHttpCode, + __out BOOL* pfRetrySend, + __out BOOL* pfRetry + ); + +typedef int (WINAPI *LPCANCEL_ROUTINE)( + __in HRESULT hrError, + __in_z_opt LPCWSTR wzError, + __in BOOL fAllowRetry, + __in_opt LPVOID pvContext + ); + +// structs +typedef struct _DOWNLOAD_SOURCE +{ + LPWSTR sczUrl; + LPWSTR sczUser; + LPWSTR sczPassword; +} DOWNLOAD_SOURCE; + +typedef struct _DOWNLOAD_CACHE_CALLBACK +{ + LPPROGRESS_ROUTINE pfnProgress; + LPCANCEL_ROUTINE pfnCancel; + LPVOID pv; +} DOWNLOAD_CACHE_CALLBACK; + +typedef struct _DOWNLOAD_AUTHENTICATION_CALLBACK +{ + LPAUTHENTICATION_ROUTINE pfnAuthenticate; + LPVOID pv; +} DOWNLOAD_AUTHENTICATION_CALLBACK; + + +// functions + +HRESULT DAPI DownloadUrl( + __in DOWNLOAD_SOURCE* pDownloadSource, + __in DWORD64 dw64AuthoredDownloadSize, + __in LPCWSTR wzDestinationPath, + __in_opt DOWNLOAD_CACHE_CALLBACK* pCache, + __in_opt DOWNLOAD_AUTHENTICATION_CALLBACK* pAuthenticate + ); + + +#ifdef __cplusplus +} +#endif diff --git a/tools/WIX/sdk/inc/dutil.h b/tools/WIX/sdk/inc/dutil.h index 2c7b33a9..0cf45190 100644 --- a/tools/WIX/sdk/inc/dutil.h +++ b/tools/WIX/sdk/inc/dutil.h @@ -20,7 +20,7 @@ // enums -enum REPORT_LEVEL +typedef enum REPORT_LEVEL { REPORT_NONE, // turns off report (only valid for XXXSetLevel()) REPORT_WARNING, // written if want only warnings or reporting is on in general @@ -28,21 +28,30 @@ enum REPORT_LEVEL REPORT_VERBOSE, // written only if verbose reporting is on REPORT_DEBUG, // reporting useful when debugging code REPORT_ERROR, // always gets reported, but can never be specified -}; +} REPORT_LEVEL; // asserts and traces typedef BOOL (DAPI *DUTIL_ASSERTDISPLAYFUNCTION)(__in_z LPCSTR sz); -extern "C" void DAPI Dutil_SetAssertModule(__in HMODULE hAssertModule); -extern "C" void DAPI Dutil_SetAssertDisplayFunction(__in DUTIL_ASSERTDISPLAYFUNCTION pfn); -extern "C" void DAPI Dutil_Assert(__in_z LPCSTR szFile, __in int iLine); -extern "C" void DAPI Dutil_AssertSz(__in_z LPCSTR szFile, __in int iLine, __in_z LPCSTR szMsg); +#ifdef __cplusplus +extern "C" { +#endif + +void DAPI Dutil_SetAssertModule(__in HMODULE hAssertModule); +void DAPI Dutil_SetAssertDisplayFunction(__in DUTIL_ASSERTDISPLAYFUNCTION pfn); +void DAPI Dutil_Assert(__in_z LPCSTR szFile, __in int iLine); +void DAPI Dutil_AssertSz(__in_z LPCSTR szFile, __in int iLine, __in_z LPCSTR szMsg); + +void DAPI Dutil_TraceSetLevel(__in REPORT_LEVEL ll, __in BOOL fTraceFilenames); +REPORT_LEVEL DAPI Dutil_TraceGetLevel(); +void __cdecl Dutil_Trace(__in_z LPCSTR szFile, __in int iLine, __in REPORT_LEVEL rl, __in_z __format_string LPCSTR szMessage, ...); +void __cdecl Dutil_TraceError(__in_z LPCSTR szFile, __in int iLine, __in REPORT_LEVEL rl, __in HRESULT hr, __in_z __format_string LPCSTR szMessage, ...); +void DAPI Dutil_RootFailure(__in_z LPCSTR szFile, __in int iLine, __in HRESULT hrError); + +#ifdef __cplusplus +} +#endif -extern "C" void DAPI Dutil_TraceSetLevel(__in REPORT_LEVEL ll, __in BOOL fTraceFilenames); -extern "C" REPORT_LEVEL DAPI Dutil_TraceGetLevel(); -extern "C" void __cdecl Dutil_Trace(__in_z LPCSTR szFile, __in int iLine, __in REPORT_LEVEL rl, __in_z __format_string LPCSTR szMessage, ...); -extern "C" void __cdecl Dutil_TraceError(__in_z LPCSTR szFile, __in int iLine, __in REPORT_LEVEL rl, __in HRESULT hr, __in_z __format_string LPCSTR szMessage, ...); -extern "C" void DAPI Dutil_RootFailure(__in_z LPCSTR szFile, __in int iLine, __in HRESULT hrError); #ifdef DEBUG @@ -112,6 +121,8 @@ extern "C" void DAPI Dutil_RootFailure(__in_z LPCSTR szFile, __in int iLine, __i #define ExitFunction() { goto LExit; } #define ExitFunction1(x) { x; goto LExit; } +#define ExitFunctionWithLastError(x) { x = HRESULT_FROM_WIN32(::GetLastError()); goto LExit; } + #define ExitOnLastError(x, s) { DWORD Dutil_er = ::GetLastError(); x = HRESULT_FROM_WIN32(Dutil_er); if (FAILED(x)) { Dutil_RootFailure(__FILE__, __LINE__, x); ExitTrace(x, s); goto LExit; } } #define ExitOnLastError1(x, f, s) { DWORD Dutil_er = ::GetLastError(); x = HRESULT_FROM_WIN32(Dutil_er); if (FAILED(x)) { Dutil_RootFailure(__FILE__, __LINE__, x); ExitTrace1(x, f, s); goto LExit; } } #define ExitOnLastError2(x, f, s, t) { DWORD Dutil_er = ::GetLastError(); x = HRESULT_FROM_WIN32(Dutil_er); if (FAILED(x)) { Dutil_RootFailure(__FILE__, __LINE__, x); ExitTrace2(x, f, s, t); goto LExit; } } @@ -210,5 +221,15 @@ typedef const BYTE* LPCBYTE; #define MAKEDWORD(lo, hi) ((DWORD)MAKELONG(lo, hi)) #define MAKEQWORDVERSION(mj, mi, b, r) (((DWORD64)MAKELONG(r, b)) | (((DWORD64)MAKELONG(mi, mj)) << 32)) + +#ifdef __cplusplus +extern "C" { +#endif + // other functions -extern "C" HRESULT DAPI LoadSystemLibrary(__in_z LPCWSTR wzModuleName, __out HMODULE *phModule); +HRESULT DAPI LoadSystemLibrary(__in_z LPCWSTR wzModuleName, __out HMODULE *phModule); +HRESULT DAPI LoadSystemLibraryWithPath(__in_z LPCWSTR wzModuleName, __out HMODULE *phModule, __deref_out_z_opt LPWSTR* psczPath); + +#ifdef __cplusplus +} +#endif diff --git a/tools/WIX/sdk/inc/eseutil.h b/tools/WIX/sdk/inc/eseutil.h index a17eeb98..614871f7 100644 --- a/tools/WIX/sdk/inc/eseutil.h +++ b/tools/WIX/sdk/inc/eseutil.h @@ -44,12 +44,12 @@ struct ESE_DATABASE_SCHEMA ESE_TABLE_SCHEMA *ptsTables; }; -enum ESE_QUERY_TYPE +typedef enum ESE_QUERY_TYPE { ESE_QUERY_EXACT, ESE_QUERY_FROM_TOP, ESE_QUERY_FROM_BOTTOM -}; +} ESE_QUERY_TYPE; typedef void* ESE_QUERY_HANDLE; diff --git a/tools/WIX/sdk/inc/fileutil.h b/tools/WIX/sdk/inc/fileutil.h index 4e9b0845..1d80770a 100644 --- a/tools/WIX/sdk/inc/fileutil.h +++ b/tools/WIX/sdk/inc/fileutil.h @@ -25,15 +25,15 @@ extern "C" { | (static_cast(build & 0xFFFF) << 16) \ | (static_cast(revision & 0xFFFF))) -enum FILE_ARCHITECTURE +typedef enum FILE_ARCHITECTURE { FILE_ARCHITECTURE_UNKNOWN, FILE_ARCHITECTURE_X86, FILE_ARCHITECTURE_X64, FILE_ARCHITECTURE_IA64, -}; +} FILE_ARCHITECTURE; -enum FILE_ENCODING +typedef enum FILE_ENCODING { FILE_ENCODING_UNSPECIFIED = 0, // TODO: distinguish between non-BOM utf-8 and ANSI in the future? @@ -41,7 +41,7 @@ enum FILE_ENCODING FILE_ENCODING_UTF8_WITH_BOM, FILE_ENCODING_UTF16, FILE_ENCODING_UTF16_WITH_BOM, -}; +} FILE_ENCODING; LPWSTR DAPI FileFromPath( @@ -97,6 +97,13 @@ BOOL DAPI FileExistsEx( __in_z LPCWSTR wzPath, __out_opt DWORD *pdwAttributes ); +BOOL DAPI FileExistsAfterRestart( + __in_z LPCWSTR wzPath, + __out_opt DWORD *pdwAttributes + ); +HRESULT DAPI FileRemoveFromPendingRename( + __in_z LPCWSTR wzPath + ); HRESULT DAPI FileRead( __deref_out_bcount_full(*pcbDest) LPBYTE* ppbDest, __out DWORD* pcbDest, diff --git a/tools/WIX/sdk/inc/iis7util.h b/tools/WIX/sdk/inc/iis7util.h index b3915ba4..d5883db8 100644 --- a/tools/WIX/sdk/inc/iis7util.h +++ b/tools/WIX/sdk/inc/iis7util.h @@ -88,6 +88,7 @@ extern "C" { #define IIS_CONFIG_LOCALSERVICE L"LocalService" #define IIS_CONFIG_NETWORKSERVICE L"NetworkService" #define IIS_CONFIG_SPECIFICUSER L"SpecificUser" +#define IIS_CONFIG_APPLICATIONPOOLIDENTITY L"ApplicationPoolIdentity" #define IIS_CONFIG_USERNAME L"userName" #define IIS_CONFIG_PASSWORD L"password" #define IIS_CONFIG_CPU L"cpu" diff --git a/tools/WIX/sdk/inc/jsonutil.h b/tools/WIX/sdk/inc/jsonutil.h index b88c6910..213825b6 100644 --- a/tools/WIX/sdk/inc/jsonutil.h +++ b/tools/WIX/sdk/inc/jsonutil.h @@ -16,7 +16,7 @@ extern "C" { #endif -enum JSON_TOKEN +typedef enum JSON_TOKEN { JSON_TOKEN_NONE, JSON_TOKEN_ARRAY_START, @@ -27,7 +27,7 @@ enum JSON_TOKEN JSON_TOKEN_OBJECT_VALUE, JSON_TOKEN_OBJECT_END, JSON_TOKEN_VALUE, -}; +} JSON_TOKEN; typedef struct _JSON_VALUE { diff --git a/tools/WIX/sdk/inc/locutil.h b/tools/WIX/sdk/inc/locutil.h index 0b0c6ced..6e409501 100644 --- a/tools/WIX/sdk/inc/locutil.h +++ b/tools/WIX/sdk/inc/locutil.h @@ -106,6 +106,15 @@ HRESULT DAPI LocGetControl( __out LOC_CONTROL** ppLocControl ); +/******************************************************************** + LocGetString - returns a string's localization information +*******************************************************************/ +extern "C" HRESULT DAPI LocGetString( + __in const WIX_LOCALIZATION* pWixLoc, + __in_z LPCWSTR wzId, + __out LOC_STRING** ppLocString + ); + #ifdef __cplusplus } #endif diff --git a/tools/WIX/sdk/inc/memutil.h b/tools/WIX/sdk/inc/memutil.h index 254eb6c8..650bdafb 100644 --- a/tools/WIX/sdk/inc/memutil.h +++ b/tools/WIX/sdk/inc/memutil.h @@ -31,6 +31,12 @@ LPVOID DAPI MemReAlloc( __in SIZE_T cbSize, __in BOOL fZero ); +HRESULT DAPI MemReAllocSecure( + __in LPVOID pv, + __in SIZE_T cbSize, + __in BOOL fZero, + __deref_out LPVOID* ppvNew + ); HRESULT DAPI MemEnsureArraySize( __deref_out_bcount(cArray * cbArrayType) LPVOID* ppvArray, __in DWORD cArray, diff --git a/tools/WIX/sdk/inc/osutil.h b/tools/WIX/sdk/inc/osutil.h index 12ce45d2..4bf5ed92 100644 --- a/tools/WIX/sdk/inc/osutil.h +++ b/tools/WIX/sdk/inc/osutil.h @@ -16,7 +16,7 @@ extern "C" { #endif -enum OS_VERSION +typedef enum OS_VERSION { OS_VERSION_UNKNOWN, OS_VERSION_WINNT, @@ -28,7 +28,7 @@ enum OS_VERSION OS_VERSION_WIN7, OS_VERSION_WIN2008_R2, OS_VERSION_FUTURE -}; +} OS_VERSION; void DAPI OsGetVersion( __out OS_VERSION* pVersion, diff --git a/tools/WIX/sdk/inc/pathutil.h b/tools/WIX/sdk/inc/pathutil.h index faff2eeb..e89dde6e 100644 --- a/tools/WIX/sdk/inc/pathutil.h +++ b/tools/WIX/sdk/inc/pathutil.h @@ -16,11 +16,11 @@ extern "C" { #endif -enum PATH_EXPAND +typedef enum PATH_EXPAND { PATH_EXPAND_ENVIRONMENT = 0x0001, PATH_EXPAND_FULLPATH = 0x0002, -}; +} PATH_EXPAND; /******************************************************************* @@ -208,6 +208,23 @@ DAPI_(HRESULT) PathCompress( __in_z LPCWSTR wzPath ); +/******************************************************************* +PathCanonicalizePath - wrapper around PathCanonicalizeW. +*******************************************************************/ +DAPI_(HRESULT) PathCanonicalizePath( + __in_z LPCWSTR wzPath, + __deref_out_z LPWSTR* psczCanonicalized + ); + +/******************************************************************* +PathDirectoryContainsPath - checks if wzPath is located inside + wzDirectory. +*******************************************************************/ +DAPI_(HRESULT) PathDirectoryContainsPath( + __in_z LPCWSTR wzDirectory, + __in_z LPCWSTR wzPath + ); + #ifdef __cplusplus } #endif diff --git a/tools/WIX/sdk/inc/polcutil.h b/tools/WIX/sdk/inc/polcutil.h index 1f6bb412..ba94a681 100644 --- a/tools/WIX/sdk/inc/polcutil.h +++ b/tools/WIX/sdk/inc/polcutil.h @@ -16,6 +16,8 @@ extern "C" { #endif +const LPCWSTR POLICY_BURN_REGISTRY_PATH = L"WiX\\Burn"; + /******************************************************************** PolcReadNumber - reads a number from policy. diff --git a/tools/WIX/sdk/inc/regutil.h b/tools/WIX/sdk/inc/regutil.h index 42e27ccf..7a41775e 100644 --- a/tools/WIX/sdk/inc/regutil.h +++ b/tools/WIX/sdk/inc/regutil.h @@ -21,12 +21,12 @@ extern "C" { #define ReleaseRegKey(h) if (h) { ::RegCloseKey(h); h = NULL; } -enum REG_KEY_BITNESS +typedef enum REG_KEY_BITNESS { REG_KEY_DEFAULT = 0, REG_KEY_32BIT = 1, REG_KEY_64BIT = 2 -}; +} REG_KEY_BITNESS; typedef LSTATUS (APIENTRY *PFN_REGCREATEKEYEXW)( __in HKEY hKey, @@ -163,6 +163,11 @@ HRESULT DAPI RegValueEnum( __deref_out_z LPWSTR* psczName, __out_opt DWORD *pdwType ); +HRESULT DAPI RegGetType( + __in HKEY hk, + __in_z_opt LPCWSTR wzName, + __out DWORD *pdwType + ); HRESULT DAPI RegReadBinary( __in HKEY hk, __in_z_opt LPCWSTR wzName, diff --git a/tools/WIX/sdk/inc/rexutil.h b/tools/WIX/sdk/inc/rexutil.h index ee57089f..8c8f6c0a 100644 --- a/tools/WIX/sdk/inc/rexutil.h +++ b/tools/WIX/sdk/inc/rexutil.h @@ -30,7 +30,7 @@ struct MEM_FILE UINT uiLength; }; -enum FAKE_FILE_TYPE { NORMAL_FILE, MEMORY_FILE }; +typedef enum FAKE_FILE_TYPE { NORMAL_FILE, MEMORY_FILE } FAKE_FILE_TYPE; typedef HRESULT (*REX_CALLBACK_PROGRESS)(BOOL fBeginFile, LPCWSTR wzFileId, LPVOID pvContext); typedef VOID (*REX_CALLBACK_WRITE)(UINT cb); diff --git a/tools/WIX/sdk/inc/srputil.h b/tools/WIX/sdk/inc/srputil.h index 27c4694a..16699b79 100644 --- a/tools/WIX/sdk/inc/srputil.h +++ b/tools/WIX/sdk/inc/srputil.h @@ -19,13 +19,13 @@ extern "C" { #endif -enum SRP_ACTION +typedef enum SRP_ACTION { SRP_ACTION_UNKNOWN, SRP_ACTION_UNINSTALL, SRP_ACTION_INSTALL, SRP_ACTION_MODIFY, -}; +} SRP_ACTION; /******************************************************************** diff --git a/tools/WIX/sdk/inc/strutil.h b/tools/WIX/sdk/inc/strutil.h index 3e297ff2..fa4667ad 100644 --- a/tools/WIX/sdk/inc/strutil.h +++ b/tools/WIX/sdk/inc/strutil.h @@ -22,6 +22,7 @@ extern "C" { #define ReleaseNullBSTR(bstr) if (bstr) { ::SysFreeString(bstr); bstr = NULL; } #define ReleaseStrArray(rg, c) { if (rg) { StrArrayFree(rg, c); } } #define ReleaseNullStrArray(rg, c) { if (rg) { StrArrayFree(rg, c); c = 0; rg = NULL; } } +#define ReleaseNullStrSecure(pwz) if (pwz) { StrSecureZeroFreeString(pwz); pwz = NULL; } #define DeclareConstBSTR(bstr_const, wz) const WCHAR bstr_const[] = { 0x00, 0x00, sizeof(wz)-sizeof(WCHAR), 0x00, wz } #define UseConstBSTR(bstr_const) const_cast(bstr_const + 4) @@ -30,6 +31,10 @@ HRESULT DAPI StrAlloc( __deref_out_ecount_part(cch, 0) LPWSTR* ppwz, __in DWORD_PTR cch ); +HRESULT DAPI StrAllocSecure( + __deref_out_ecount_part(cch, 0) LPWSTR* ppwz, + __in DWORD_PTR cch + ); HRESULT DAPI StrTrimCapacity( __deref_out_z LPWSTR* ppwz ); @@ -53,6 +58,11 @@ HRESULT DAPI StrAllocString( __in_z LPCWSTR wzSource, __in DWORD_PTR cchSource ); +HRESULT DAPI StrAllocStringSecure( + __deref_out_ecount_z(cchSource + 1) LPWSTR* ppwz, + __in_z LPCWSTR wzSource, + __in DWORD_PTR cchSource + ); HRESULT DAPI StrAnsiAllocString( __deref_out_ecount_z(cchSource+1) LPSTR* ppsz, __in_z LPCWSTR wzSource, @@ -80,6 +90,11 @@ HRESULT DAPI StrAllocConcat( __in_z LPCWSTR wzSource, __in DWORD_PTR cchSource ); +HRESULT DAPI StrAllocConcatSecure( + __deref_out_z LPWSTR* ppwz, + __in_z LPCWSTR wzSource, + __in DWORD_PTR cchSource + ); HRESULT DAPI StrAnsiAllocConcat( __deref_out_z LPSTR* ppz, __in_z LPCSTR pzSource, @@ -90,6 +105,11 @@ HRESULT __cdecl StrAllocFormatted( __in __format_string LPCWSTR wzFormat, ... ); +HRESULT __cdecl StrAllocFormattedSecure( + __deref_out_z LPWSTR* ppwz, + __in __format_string LPCWSTR wzFormat, + ... + ); HRESULT __cdecl StrAnsiAllocFormatted( __deref_out_z LPSTR* ppsz, __in __format_string LPCSTR szFormat, @@ -100,6 +120,11 @@ HRESULT DAPI StrAllocFormattedArgs( __in __format_string LPCWSTR wzFormat, __in va_list args ); +HRESULT DAPI StrAllocFormattedArgsSecure( + __deref_out_z LPWSTR* ppwz, + __in __format_string LPCWSTR wzFormat, + __in va_list args + ); HRESULT DAPI StrAnsiAllocFormattedArgs( __deref_out_z LPSTR* ppsz, __in __format_string LPCSTR szFormat, @@ -274,6 +299,13 @@ HRESULT DAPI StrSplitAllocArray( __in_z LPCWSTR wzDelim ); +HRESULT DAPI StrSecureZeroString( + __in LPWSTR pwz + ); +HRESULT DAPI StrSecureZeroFreeString( + __in LPWSTR pwz + ); + #ifdef __cplusplus } #endif diff --git a/tools/WIX/sdk/inc/thmutil.h b/tools/WIX/sdk/inc/thmutil.h index 85c08c64..e394d087 100644 --- a/tools/WIX/sdk/inc/thmutil.h +++ b/tools/WIX/sdk/inc/thmutil.h @@ -18,12 +18,12 @@ extern "C" { #define ReleaseTheme(p) if (p) { ThemeFree(p); p = NULL; } -enum THEME_CONTROL_DATA +typedef enum THEME_CONTROL_DATA { THEME_CONTROL_DATA_HOVER = 1, -}; +} THEME_CONTROL_DATA; -enum THEME_CONTROL_TYPE +typedef enum THEME_CONTROL_TYPE { THEME_CONTROL_TYPE_UNKNOWN, THEME_CONTROL_TYPE_BILLBOARD, @@ -40,7 +40,7 @@ enum THEME_CONTROL_TYPE THEME_CONTROL_TYPE_LISTVIEW, THEME_CONTROL_TYPE_TREEVIEW, THEME_CONTROL_TYPE_TAB, -}; +} THEME_CONTROL_TYPE; struct THEME_BILLBOARD @@ -543,6 +543,16 @@ DAPI_(HRESULT) ThemeUpdateCaption( __in_z LPCWSTR wzCaption ); +/******************************************************************** + ThemeSetFocus - set the focus to the control supplied or the next + enabled control if it is disabled. + +*******************************************************************/ +DAPI_(void) ThemeSetFocus( + __in THEME* pTheme, + __in DWORD dwControl + ); + #ifdef __cplusplus } #endif diff --git a/tools/WIX/sdk/inc/timeutil.h b/tools/WIX/sdk/inc/timeutil.h index 8d5f1728..3cabdf1a 100644 --- a/tools/WIX/sdk/inc/timeutil.h +++ b/tools/WIX/sdk/inc/timeutil.h @@ -21,6 +21,10 @@ HRESULT DAPI TimeFromString( __in_z LPCWSTR wzTime, __out FILETIME* pFileTime ); +HRESULT DAPI TimeFromString3339( + __in_z LPCWSTR wzTime, + __out FILETIME* pFileTime + ); HRESULT DAPI TimeCurrentTime( __deref_out_z LPWSTR* ppwz, __in BOOL fGMT diff --git a/tools/WIX/sdk/inc/uriutil.h b/tools/WIX/sdk/inc/uriutil.h index 96950978..492d2cfd 100644 --- a/tools/WIX/sdk/inc/uriutil.h +++ b/tools/WIX/sdk/inc/uriutil.h @@ -20,7 +20,7 @@ extern "C" { #endif -enum URI_PROTOCOL +typedef enum URI_PROTOCOL { URI_PROTOCOL_UNKNOWN, URI_PROTOCOL_FILE, @@ -29,7 +29,7 @@ enum URI_PROTOCOL URI_PROTOCOL_HTTPS, URI_PROTOCOL_LOCAL, URI_PROTOCOL_UNC -}; +} URI_PROTOCOL; typedef struct _URI_INFO { diff --git a/tools/WIX/sdk/inc/wcautil.h b/tools/WIX/sdk/inc/wcautil.h index 487690d8..02949310 100644 --- a/tools/WIX/sdk/inc/wcautil.h +++ b/tools/WIX/sdk/inc/wcautil.h @@ -37,32 +37,32 @@ extern "C" { #define MessageExitOnNullWithLastError2(p, x, e, f, s, t) if (NULL == p) { x = ::GetLastError(); x = HRESULT_FROM_WIN32(x); if (!FAILED(x)) { x = E_FAIL; } ExitTrace(x, f, s, t); WcaErrorMessage(e, x, MB_OK, 2, s, t); goto LExit; } // Generic action enum. -enum WCA_ACTION +typedef enum WCA_ACTION { WCA_ACTION_NONE, WCA_ACTION_INSTALL, WCA_ACTION_UNINSTALL, -}; +} WCA_ACTION; -enum WCA_CASCRIPT +typedef enum WCA_CASCRIPT { WCA_CASCRIPT_SCHEDULED, WCA_CASCRIPT_ROLLBACK, -}; +} WCA_CASCRIPT; -enum WCA_CASCRIPT_CLOSE +typedef enum WCA_CASCRIPT_CLOSE { WCA_CASCRIPT_CLOSE_PRESERVE, WCA_CASCRIPT_CLOSE_DELETE, -}; +} WCA_CASCRIPT_CLOSE; -enum WCA_TODO +typedef enum WCA_TODO { WCA_TODO_UNKNOWN, WCA_TODO_INSTALL, WCA_TODO_UNINSTALL, WCA_TODO_REINSTALL, -}; +} WCA_TODO; typedef struct WCA_CASCRIPT_STRUCT { @@ -94,13 +94,13 @@ void WIXAPI WcaSetReturnValue( ); BOOL WIXAPI WcaCancelDetected(); -const int LOG_BUFFER = 2048; -enum LOGLEVEL +#define LOG_BUFFER 2048 +typedef enum LOGLEVEL { LOGMSG_TRACEONLY, // Never written to the log file (except in DEBUG builds) LOGMSG_VERBOSE, // Written to log when LOGVERBOSE LOGMSG_STANDARD // Written to log whenever informational logging is enabled -}; +} LOGLEVEL; void __cdecl WcaLog( __in LOGLEVEL llv, diff --git a/tools/WIX/sdk/inc/wcawrapquery.h b/tools/WIX/sdk/inc/wcawrapquery.h index baaa4853..34dabcfd 100644 --- a/tools/WIX/sdk/inc/wcawrapquery.h +++ b/tools/WIX/sdk/inc/wcawrapquery.h @@ -16,23 +16,23 @@ #include "wcautil.h" // Enumerations -enum eWrapQueryAction +typedef enum eWrapQueryAction { wqaTableBegin = 1, wqaTableFinish, wqaRowBegin, wqaRowFinish -}; +} eWrapQueryAction; -enum eColumnDataType +typedef enum eColumnDataType { cdtString = 1, cdtInt, cdtStream, cdtUnknown -}; +} eColumnDataType; -enum eFormatMaskColumn +typedef enum eFormatMaskColumn { efmcColumn1 = 1, efmcColumn2 = 1 << 1, @@ -66,7 +66,7 @@ enum eFormatMaskColumn efmcColumn30 = 1 << 29, efmcColumn31 = 1 << 30, efmcColumn32 = 1 << 31, -}; +} eFormatMaskColumn; // Keeps track of the query instance for the reading CA (deferred CA) typedef struct WCA_WRAPQUERY_STRUCT diff --git a/tools/WIX/sdk/inc/wiutil.h b/tools/WIX/sdk/inc/wiutil.h index 17a34875..1aeb827f 100644 --- a/tools/WIX/sdk/inc/wiutil.h +++ b/tools/WIX/sdk/inc/wiutil.h @@ -19,6 +19,8 @@ extern "C" { // constants #define IDNOACTION 0 +#define WIU_MB_OKIGNORECANCELRETRY 0xE + #define MAX_DARWIN_KEY 73 #define MAX_DARWIN_COLUMN 255 @@ -31,21 +33,21 @@ extern "C" { #define ReleaseNullMsi(h) if (h) { ::MsiCloseHandle(h); h = NULL; } -enum WIU_RESTART +typedef enum WIU_RESTART { WIU_RESTART_NONE, WIU_RESTART_REQUIRED, WIU_RESTART_INITIATED, -}; +} WIU_RESTART; -enum WIU_MSI_EXECUTE_MESSAGE_TYPE +typedef enum WIU_MSI_EXECUTE_MESSAGE_TYPE { WIU_MSI_EXECUTE_MESSAGE_NONE, WIU_MSI_EXECUTE_MESSAGE_PROGRESS, WIU_MSI_EXECUTE_MESSAGE_ERROR, WIU_MSI_EXECUTE_MESSAGE_MSI_MESSAGE, WIU_MSI_EXECUTE_MESSAGE_MSI_FILES_IN_USE, -}; +} WIU_MSI_EXECUTE_MESSAGE_TYPE; // structures @@ -169,6 +171,11 @@ typedef UINT (WINAPI *PFN_MSIDETERMINEPATCHSEQUENCEW)( __in DWORD cPatchInfo, __in PMSIPATCHSEQUENCEINFOW pPatchInfo ); +typedef UINT (WINAPI *PFN_MSIDETERMINEAPPLICABLEPATCHESW)( + __in_z LPCWSTR wzProductPackagePath, + __in DWORD cPatchInfo, + __in PMSIPATCHSEQUENCEINFOW pPatchInfo + ); typedef UINT (WINAPI *PFN_MSIINSTALLPRODUCTW)( __in LPCWSTR szPackagePath, __in_opt LPCWSTR szCommandLine @@ -298,6 +305,11 @@ HRESULT DAPI WiuDeterminePatchSequence( __in PMSIPATCHSEQUENCEINFOW pPatchInfo, __in DWORD cPatchInfo ); +HRESULT DAPI WiuDetermineApplicablePatches( + __in_z LPCWSTR wzProductPackagePath, + __in PMSIPATCHSEQUENCEINFOW pPatchInfo, + __in DWORD cPatchInfo + ); HRESULT DAPI WiuEnumProducts( __in DWORD iProductIndex, __out_ecount(MAX_GUID_CHARS + 1) LPWSTR wzProductCode @@ -317,6 +329,12 @@ HRESULT DAPI WiuEnumRelatedProducts( __in DWORD iProductIndex, __out_ecount(MAX_GUID_CHARS + 1) LPWSTR wzProductCode ); +HRESULT DAPI WiuEnumRelatedProductCodes( + __in_z LPCWSTR wzUpgradeCode, + __deref_out_ecount_opt(pcRelatedProducts) LPWSTR** prgsczProductCodes, + __out DWORD* pcRelatedProducts, + __in BOOL fReturnHighestVersionOnly + ); HRESULT DAPI WiuEnableLog( __in DWORD dwLogMode, __in_z LPCWSTR wzLogFile, diff --git a/tools/WIX/sdk/inc/xmlutil.h b/tools/WIX/sdk/inc/xmlutil.h index 37f2146f..86c630f7 100644 --- a/tools/WIX/sdk/inc/xmlutil.h +++ b/tools/WIX/sdk/inc/xmlutil.h @@ -26,10 +26,10 @@ extern __declspec(selectany) const IID XmlUtil_IID_IXMLDOMDocument = {0x2933BF8 extern __declspec(selectany) const IID XmlUtil_IID_IXMLDOMDocument2 = {0x2933BF95, 0x7B36, 0x11D2, {0xB2, 0x0E, 0x00, 0xC0, 0x4F, 0x98, 0x3E, 0x60}}; extern __declspec(selectany) const IID XmlUtil_IID_IXMLDOMSchemaCollection = {0x373984C8, 0xB845, 0x449B, {0x91, 0xE7, 0x45, 0xAC, 0x83, 0x03, 0x6A, 0xDE}}; -enum XML_LOAD_ATTRIBUTE +typedef enum XML_LOAD_ATTRIBUTE { XML_LOAD_PRESERVE_WHITESPACE = 1, -}; +} XML_LOAD_ATTRIBUTE; #ifdef __cplusplus diff --git a/tools/WIX/sdk/vs2008/lib/x64/deputil.lib b/tools/WIX/sdk/vs2008/lib/x64/deputil.lib deleted file mode 100644 index d4402e03..00000000 Binary files a/tools/WIX/sdk/vs2008/lib/x64/deputil.lib and /dev/null differ diff --git a/tools/WIX/sdk/vs2008/lib/x64/dutil.lib b/tools/WIX/sdk/vs2008/lib/x64/dutil.lib deleted file mode 100644 index 5ff038dd..00000000 Binary files a/tools/WIX/sdk/vs2008/lib/x64/dutil.lib and /dev/null differ diff --git a/tools/WIX/sdk/vs2008/lib/x64/wcautil.lib b/tools/WIX/sdk/vs2008/lib/x64/wcautil.lib deleted file mode 100644 index 7dc79292..00000000 Binary files a/tools/WIX/sdk/vs2008/lib/x64/wcautil.lib and /dev/null differ diff --git a/tools/WIX/sdk/vs2008/lib/x86/balutil.lib b/tools/WIX/sdk/vs2008/lib/x86/balutil.lib deleted file mode 100644 index ebfbe74c..00000000 Binary files a/tools/WIX/sdk/vs2008/lib/x86/balutil.lib and /dev/null differ diff --git a/tools/WIX/sdk/vs2008/lib/x86/deputil.lib b/tools/WIX/sdk/vs2008/lib/x86/deputil.lib deleted file mode 100644 index 97d1ceea..00000000 Binary files a/tools/WIX/sdk/vs2008/lib/x86/deputil.lib and /dev/null differ diff --git a/tools/WIX/sdk/vs2008/lib/x86/dutil.lib b/tools/WIX/sdk/vs2008/lib/x86/dutil.lib deleted file mode 100644 index eb94c101..00000000 Binary files a/tools/WIX/sdk/vs2008/lib/x86/dutil.lib and /dev/null differ diff --git a/tools/WIX/sdk/vs2008/lib/x86/wcautil.lib b/tools/WIX/sdk/vs2008/lib/x86/wcautil.lib deleted file mode 100644 index 9c666732..00000000 Binary files a/tools/WIX/sdk/vs2008/lib/x86/wcautil.lib and /dev/null differ diff --git a/tools/WIX/sdk/vs2010/lib/x64/deputil.lib b/tools/WIX/sdk/vs2010/lib/x64/deputil.lib index 2b2a5e5e..eb9200da 100644 Binary files a/tools/WIX/sdk/vs2010/lib/x64/deputil.lib and b/tools/WIX/sdk/vs2010/lib/x64/deputil.lib differ diff --git a/tools/WIX/sdk/vs2010/lib/x64/dutil.lib b/tools/WIX/sdk/vs2010/lib/x64/dutil.lib index 16ee7c97..97f4ae0a 100644 Binary files a/tools/WIX/sdk/vs2010/lib/x64/dutil.lib and b/tools/WIX/sdk/vs2010/lib/x64/dutil.lib differ diff --git a/tools/WIX/sdk/vs2010/lib/x64/wcautil.lib b/tools/WIX/sdk/vs2010/lib/x64/wcautil.lib index ba9b15c5..de354276 100644 Binary files a/tools/WIX/sdk/vs2010/lib/x64/wcautil.lib and b/tools/WIX/sdk/vs2010/lib/x64/wcautil.lib differ diff --git a/tools/WIX/sdk/vs2010/lib/x86/balutil.lib b/tools/WIX/sdk/vs2010/lib/x86/balutil.lib index d1bd34f4..6f55edb7 100644 Binary files a/tools/WIX/sdk/vs2010/lib/x86/balutil.lib and b/tools/WIX/sdk/vs2010/lib/x86/balutil.lib differ diff --git a/tools/WIX/sdk/vs2010/lib/x86/deputil.lib b/tools/WIX/sdk/vs2010/lib/x86/deputil.lib index 2ad0ec73..c1915273 100644 Binary files a/tools/WIX/sdk/vs2010/lib/x86/deputil.lib and b/tools/WIX/sdk/vs2010/lib/x86/deputil.lib differ diff --git a/tools/WIX/sdk/vs2010/lib/x86/dutil.lib b/tools/WIX/sdk/vs2010/lib/x86/dutil.lib index c4bce3e2..cfc3423f 100644 Binary files a/tools/WIX/sdk/vs2010/lib/x86/dutil.lib and b/tools/WIX/sdk/vs2010/lib/x86/dutil.lib differ diff --git a/tools/WIX/sdk/vs2010/lib/x86/wcautil.lib b/tools/WIX/sdk/vs2010/lib/x86/wcautil.lib index a155c0a7..15aa2ea8 100644 Binary files a/tools/WIX/sdk/vs2010/lib/x86/wcautil.lib and b/tools/WIX/sdk/vs2010/lib/x86/wcautil.lib differ diff --git a/tools/WIX/sdk/vs2012/lib/x64/deputil.lib b/tools/WIX/sdk/vs2012/lib/x64/deputil.lib index 17a21493..a3d42432 100644 Binary files a/tools/WIX/sdk/vs2012/lib/x64/deputil.lib and b/tools/WIX/sdk/vs2012/lib/x64/deputil.lib differ diff --git a/tools/WIX/sdk/vs2012/lib/x64/dutil.lib b/tools/WIX/sdk/vs2012/lib/x64/dutil.lib index f41eec0e..e2e96473 100644 Binary files a/tools/WIX/sdk/vs2012/lib/x64/dutil.lib and b/tools/WIX/sdk/vs2012/lib/x64/dutil.lib differ diff --git a/tools/WIX/sdk/vs2012/lib/x64/wcautil.lib b/tools/WIX/sdk/vs2012/lib/x64/wcautil.lib index a44fe864..7edb4d05 100644 Binary files a/tools/WIX/sdk/vs2012/lib/x64/wcautil.lib and b/tools/WIX/sdk/vs2012/lib/x64/wcautil.lib differ diff --git a/tools/WIX/sdk/vs2012/lib/x86/balutil.lib b/tools/WIX/sdk/vs2012/lib/x86/balutil.lib index 7ec26c84..73862e5a 100644 Binary files a/tools/WIX/sdk/vs2012/lib/x86/balutil.lib and b/tools/WIX/sdk/vs2012/lib/x86/balutil.lib differ diff --git a/tools/WIX/sdk/vs2012/lib/x86/deputil.lib b/tools/WIX/sdk/vs2012/lib/x86/deputil.lib index 34f657b0..9f44fc3b 100644 Binary files a/tools/WIX/sdk/vs2012/lib/x86/deputil.lib and b/tools/WIX/sdk/vs2012/lib/x86/deputil.lib differ diff --git a/tools/WIX/sdk/vs2012/lib/x86/dutil.lib b/tools/WIX/sdk/vs2012/lib/x86/dutil.lib index 18e90eb3..a37f14c7 100644 Binary files a/tools/WIX/sdk/vs2012/lib/x86/dutil.lib and b/tools/WIX/sdk/vs2012/lib/x86/dutil.lib differ diff --git a/tools/WIX/sdk/vs2012/lib/x86/wcautil.lib b/tools/WIX/sdk/vs2012/lib/x86/wcautil.lib index 27c521a4..5a1aa321 100644 Binary files a/tools/WIX/sdk/vs2012/lib/x86/wcautil.lib and b/tools/WIX/sdk/vs2012/lib/x86/wcautil.lib differ diff --git a/tools/WIX/sdk/vs2013/lib/x64/deputil.lib b/tools/WIX/sdk/vs2013/lib/x64/deputil.lib new file mode 100644 index 00000000..83698b41 Binary files /dev/null and b/tools/WIX/sdk/vs2013/lib/x64/deputil.lib differ diff --git a/tools/WIX/sdk/vs2013/lib/x64/dutil.lib b/tools/WIX/sdk/vs2013/lib/x64/dutil.lib new file mode 100644 index 00000000..60d9d6b2 Binary files /dev/null and b/tools/WIX/sdk/vs2013/lib/x64/dutil.lib differ diff --git a/tools/WIX/sdk/vs2013/lib/x64/wcautil.lib b/tools/WIX/sdk/vs2013/lib/x64/wcautil.lib new file mode 100644 index 00000000..4194206c Binary files /dev/null and b/tools/WIX/sdk/vs2013/lib/x64/wcautil.lib differ diff --git a/tools/WIX/sdk/vs2013/lib/x86/balutil.lib b/tools/WIX/sdk/vs2013/lib/x86/balutil.lib new file mode 100644 index 00000000..80d6c878 Binary files /dev/null and b/tools/WIX/sdk/vs2013/lib/x86/balutil.lib differ diff --git a/tools/WIX/sdk/vs2013/lib/x86/deputil.lib b/tools/WIX/sdk/vs2013/lib/x86/deputil.lib new file mode 100644 index 00000000..1201bdb5 Binary files /dev/null and b/tools/WIX/sdk/vs2013/lib/x86/deputil.lib differ diff --git a/tools/WIX/sdk/vs2013/lib/x86/dutil.lib b/tools/WIX/sdk/vs2013/lib/x86/dutil.lib new file mode 100644 index 00000000..134f07c4 Binary files /dev/null and b/tools/WIX/sdk/vs2013/lib/x86/dutil.lib differ diff --git a/tools/WIX/sdk/vs2013/lib/x86/wcautil.lib b/tools/WIX/sdk/vs2013/lib/x86/wcautil.lib new file mode 100644 index 00000000..577a8911 Binary files /dev/null and b/tools/WIX/sdk/vs2013/lib/x86/wcautil.lib differ diff --git a/tools/WIX/sdk/wix.ca.targets b/tools/WIX/sdk/wix.ca.targets index c2a65ec3..4ce9e43e 100644 --- a/tools/WIX/sdk/wix.ca.targets +++ b/tools/WIX/sdk/wix.ca.targets @@ -23,9 +23,9 @@ $(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\wix.ca.targets - $(MSBuildExtensionsPath32)\..\WiX Toolset v3.7\bin\WixTasks.dll + $(MSBuildExtensionsPath32)\..\WiX Toolset v3.9\bin\WixTasks.dll $(MSBuildExtensionsPath)\Microsoft\WiX\v3.x\wix.ca.targets - $(MSBuildExtensionsPath)\..\WiX Toolset v3.7\bin\WixTasks.dll + $(MSBuildExtensionsPath)\..\WiX Toolset v3.9\bin\WixTasks.dll $(TargetName).CA$(TargetExt) @@ -43,8 +43,8 @@ ================================================================================================== --> - SOFTWARE\Microsoft\Windows Installer XML\3.7 - SOFTWARE\Wow6432Node\Microsoft\Windows Installer XML\3.7 + SOFTWARE\Microsoft\Windows Installer XML\3.9 + SOFTWARE\Wow6432Node\Microsoft\Windows Installer XML\3.9 @@ -119,6 +119,12 @@ + + + + $(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets - $(MSBuildExtensionsPath32)\..\WiX Toolset v3.7\bin\WixTasks.dll + $(MSBuildExtensionsPath32)\..\WiX Toolset v3.9\bin\WixTasks.dll $(MSBuildExtensionsPath)\Microsoft\WiX\v3.x\Wix.targets - $(MSBuildExtensionsPath)\..\WiX Toolset v3.7\bin\WixTasks.dll + $(MSBuildExtensionsPath)\..\WiX Toolset v3.9\bin\WixTasks.dll $(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Lux.targets - $(MSBuildExtensionsPath32)\..\WiX Toolset v3.7\bin\LuxTasks.dll + $(MSBuildExtensionsPath32)\..\WiX Toolset v3.9\bin\LuxTasks.dll $(MSBuildExtensionsPath)\Microsoft\WiX\v3.x\Lux.targets - $(MSBuildExtensionsPath)\..\WiX Toolset v3.7\bin\LuxTasks.dll + $(MSBuildExtensionsPath)\..\WiX Toolset v3.9\bin\LuxTasks.dll @@ -490,8 +490,8 @@ ================================================================================================== --> - SOFTWARE\Microsoft\Windows Installer XML\3.7 - SOFTWARE\Wow6432Node\Microsoft\Windows Installer XML\3.7 + SOFTWARE\Microsoft\Windows Installer XML\3.9 + SOFTWARE\Wow6432Node\Microsoft\Windows Installer XML\3.9 @@ -2520,6 +2520,7 @@ NoLogo="$(LinkerNoLogo)" OutputAsXml="$(OutputAsXml)" OutputFile="$(TargetDir)%(CultureGroup.OutputFolder)$(TargetName)$(TargetExt)" + SuppressPatchSequenceData="$(SuppressPatchSequenceData)" PdbOutputFile="$(PdbOutputFile)" Pedantic="$(LinkerPedantic)" ReferencePaths="$(ReferencePaths)" @@ -2529,7 +2530,6 @@ SuppressAclReset="$(SuppressAclReset)" SuppressAllWarnings="$(LinkerSuppressAllWarnings)" SuppressAssemblies="$(SuppressAssemblies)" - SuppressBuildInfo="$(SuppressBuildInfo)" SuppressDefaultAdminSequenceActions="$(SuppressDefaultAdminSequenceActions)" SuppressDefaultAdvSequenceActions="$(SuppressDefaultAdvSequenceActions)" SuppressDefaultUISequenceActions="$(SuppressDefaultUISequenceActions)" diff --git a/tools/WIX/wix2010.targets b/tools/WIX/wix2010.targets index 08527d0f..a62a4660 100644 --- a/tools/WIX/wix2010.targets +++ b/tools/WIX/wix2010.targets @@ -45,8 +45,8 @@ InitialTargets="_CheckForInvalidConfigurationAndPlatform; _CheckRequiredProperties"> - $(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Installer XML\3.7@InstallRoot) - $(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows Installer XML\3.7@InstallRoot) + $(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Installer XML\3.9@InstallRoot) + $(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows Installer XML\3.9@InstallRoot)