From 1602a3e3f9b8d35cdabd0d31d0a3692a8b95174f Mon Sep 17 00:00:00 2001 From: McMak Date: Mon, 27 Apr 2015 20:14:02 +0300 Subject: [PATCH] Upd sql scripts. --- WebsitePanel/Database/install_db.sql | 1756 +- WebsitePanel/Database/wix_install_db.sql | 45307 +++++++++++++++++++++ WebsitePanel/Database/wix_update_db.sql | 10676 +++++ 3 files changed, 56861 insertions(+), 878 deletions(-) create mode 100644 WebsitePanel/Database/wix_install_db.sql create mode 100644 WebsitePanel/Database/wix_update_db.sql 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