From c824d7c6654aa22dac085304e02a3ba7146cd9df Mon Sep 17 00:00:00 2001 From: dev_amdtel Date: Thu, 21 Nov 2013 17:26:18 +0400 Subject: [PATCH] CRM changes --- WebsitePanel/Database/update_db.sql | 3 + .../HostedSolution/CRMController.cs | 35 +++- .../Common/Constants.cs | 6 + .../CRMOrganizationStatistics.cs | 9 + .../HostedSolution/ICRM.cs | 4 + .../CRMProvider2011.cs | 187 ++++++++++++++++-- .../CRMProvider.cs | 7 +- .../WebsitePanel.Server.Client/CRMProxy.cs | 153 ++++++++------ .../Sources/WebsitePanel.Server/CRM.asmx.cs | 12 +- .../ProviderControls/CRM2011_Settings.ascx | 37 +++- .../ProviderControls/CRM2011_Settings.ascx.cs | 17 ++ .../CRM2011_Settings.ascx.designer.cs | 147 +++++++------- 12 files changed, 461 insertions(+), 156 deletions(-) diff --git a/WebsitePanel/Database/update_db.sql b/WebsitePanel/Database/update_db.sql index cc9675fd..ed2db875 100644 --- a/WebsitePanel/Database/update_db.sql +++ b/WebsitePanel/Database/update_db.sql @@ -2586,3 +2586,6 @@ BEGIN END GO +-- CRM + +UPDATE Providers SET EditorControl = 'CRM2011' Where ProviderID = 1201; diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/HostedSolution/CRMController.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/HostedSolution/CRMController.cs index ed6cb8d0..b0a415dd 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/HostedSolution/CRMController.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/HostedSolution/CRMController.cs @@ -200,6 +200,32 @@ namespace WebsitePanel.EnterpriseServer return res; } + private static string GetProviderProperty(int organizationServiceId, string property) + { + + Organizations orgProxy = new Organizations(); + + ServiceProviderProxy.Init(orgProxy, organizationServiceId); + + string[] organizationSettings = orgProxy.ServiceProviderSettingsSoapHeaderValue.Settings; + + string value = string.Empty; + foreach (string str in organizationSettings) + { + string[] props = str.Split('='); + if (props.Length == 2) + { + if (props[0].ToLower() == property) + { + value = props[1]; + break; + } + } + } + + return value; + } + public static OrganizationResult CreateOrganization(int organizationId, string baseCurrencyCode, string baseCurrencyName, string baseCurrencySymbol, string regionName, int userId, string collation) { OrganizationResult res = StartTask("CRM", "CREATE_ORGANIZATION"); @@ -239,6 +265,10 @@ namespace WebsitePanel.EnterpriseServer return res; } + + + int serviceid = PackageController.GetPackageServiceId(org.PackageId, ResourceGroups.HostedOrganizations); + string rootOU = GetProviderProperty(serviceid, "rootou"); org.CrmAdministratorId = user.AccountId; org.CrmCurrency = @@ -248,7 +278,10 @@ namespace WebsitePanel.EnterpriseServer org.CrmOrganizationId = orgId; OrganizationResult serverRes = - crm.CreateOrganization(orgId, org.OrganizationId, org.Name, baseCurrencyCode, baseCurrencyName, + crm.CreateOrganization(orgId, org.OrganizationId, org.Name, + org.DefaultDomain, + org.OrganizationId + "." + rootOU, + baseCurrencyCode, baseCurrencyName, baseCurrencySymbol, user.SamAccountName, user.FirstName, user.LastName, user.PrimaryEmailAddress, collation); diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Base/Common/Constants.cs b/WebsitePanel/Sources/WebsitePanel.Providers.Base/Common/Constants.cs index 9d5bfab4..d99847d0 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.Base/Common/Constants.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.Base/Common/Constants.cs @@ -58,6 +58,12 @@ namespace WebsitePanel.Providers.Common public const string AppRootDomain = "AppRootDomain"; + public const string OrganizationWebService = "OrganizationWebService"; + + public const string DiscoveryWebService = "DiscoveryWebService"; + + public const string DeploymentWebService = "DeploymentWebService"; + public const string UtilityPath = "UtilityPath"; public const string EnterpriseServer = "EnterpriseServer"; diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Base/HostedSolution/CRMOrganizationStatistics.cs b/WebsitePanel/Sources/WebsitePanel.Providers.Base/HostedSolution/CRMOrganizationStatistics.cs index cabe1bed..1ad2f6e3 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.Base/HostedSolution/CRMOrganizationStatistics.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.Base/HostedSolution/CRMOrganizationStatistics.cs @@ -36,5 +36,14 @@ namespace WebsitePanel.Providers.HostedSolution public string CRMUserName { get; set; } public CRMUserAccessMode ClientAccessMode { get; set; } public bool CRMDisabled { get; set; } + + public int CRMUsersCount { get; set; } + public string AccountNumber { get; set; } + public string СRMOrganizationName { get; set; } + public int CRMUsersFullLicenceCount { get; set; } + public int CRMUsersReadOnlyLicenceCount { get; set; } + public int UsedSpace { get; set; } + public string UsageMonth { get; set; } + } } diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Base/HostedSolution/ICRM.cs b/WebsitePanel/Sources/WebsitePanel.Providers.Base/HostedSolution/ICRM.cs index 4a02c4ca..930a8081 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.Base/HostedSolution/ICRM.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.Base/HostedSolution/ICRM.cs @@ -35,6 +35,7 @@ namespace WebsitePanel.Providers.HostedSolution public interface ICRM { OrganizationResult CreateOrganization(Guid organizationId, string organizationUniqueName, string organizationFriendlyName, + string organizationDomainName, string ou, string baseCurrencyCode, string baseCurrencyName, string baseCurrencySymbol, string initialUserDomainName, string initialUserFirstName, string initialUserLastName, string initialUserPrimaryEmail, string organizationCollation); @@ -60,5 +61,8 @@ namespace WebsitePanel.Providers.HostedSolution CrmUserResult GetCrmUserById(Guid crmUserId, string orgName); ResultObject ChangeUserState(bool disable, string orgName, Guid crmUserId); + + long GetUsedSpace(Guid organizationId); + } } diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution.Crm2011/CRMProvider2011.cs b/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution.Crm2011/CRMProvider2011.cs index 8da7c628..6855bfe2 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution.Crm2011/CRMProvider2011.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution.Crm2011/CRMProvider2011.cs @@ -11,6 +11,7 @@ using System.Security.Principal; using System.Security.Cryptography.X509Certificates; using System.Threading; using System.ServiceModel.Description; +using System.Text.RegularExpressions; using Microsoft.Win32; using WebsitePanel.Providers.Common; using WebsitePanel.Providers.ResultObjects; @@ -58,7 +59,9 @@ namespace WebsitePanel.Providers.HostedSolution { get { - string cRMServiceUrl = "https://" + ProviderSettings[Constants.AppRootDomain] + ":" + ProviderSettings[Constants.Port] + "/XRMDeployment/2011/Deployment.svc"; + string uri = ProviderSettings[Constants.DeploymentWebService]; + if (String.IsNullOrEmpty(uri)) uri = ProviderSettings[Constants.AppRootDomain]; + string cRMServiceUrl = "https://" + uri + ":" + ProviderSettings[Constants.Port] + "/XRMDeployment/2011/Deployment.svc"; return cRMServiceUrl; } } @@ -67,7 +70,9 @@ namespace WebsitePanel.Providers.HostedSolution { get { - string cRMDiscoveryUri = "https://" + ProviderSettings[Constants.AppRootDomain] + ":" + ProviderSettings[Constants.Port] + "/XRMServices/2011/Discovery.svc"; + string uri = ProviderSettings[Constants.DiscoveryWebService]; + if (String.IsNullOrEmpty(uri)) uri = ProviderSettings[Constants.AppRootDomain]; + string cRMDiscoveryUri = "https://" + uri + ":" + ProviderSettings[Constants.Port] + "/XRMServices/2011/Discovery.svc"; return cRMDiscoveryUri; } } @@ -174,6 +179,75 @@ namespace WebsitePanel.Providers.HostedSolution return res; } + public long GetUsedSpace(Guid organizationId) + { + Log.WriteStart("GetUsedSpace"); + long res = 0; + + string crmDatabaseName = "MSCRM_CONFIG"; + string databasename = ""; + + SqlConnection connection = null; + try + { + connection = new SqlConnection(); + connection.ConnectionString = + string.Format("Server={1};Initial Catalog={0};Integrated Security=SSPI", + crmDatabaseName, SqlServer); + + connection.Open(); + + string commandText = string.Format("SELECT DatabaseName FROM dbo.Organization where id = '{0}'", organizationId); + SqlCommand command = new SqlCommand(commandText, connection); + databasename = command.ExecuteScalar().ToString(); + + } + catch (Exception ex) + { + Log.WriteError(ex); + } + finally + { + if (connection != null) + connection.Dispose(); + } + + try + { + connection = new SqlConnection(); + connection.ConnectionString = + string.Format("Server={1};Initial Catalog={0};Integrated Security=SSPI", + databasename, SqlServer); + + connection.Open(); + + string commandText = "SELECT ((dbsize + logsize) * 8192 ) size FROM " + + "( " + + "SELECT SUM(CONVERT(BIGINT,CASE WHEN status & 64 = 0 THEN size ELSE 0 END)) dbsize " + + ", SUM(CONVERT(BIGINT,CASE WHEN status & 64 <> 0 THEN size ELSE 0 END)) logsize " + + "FROM dbo.sysfiles " + + ") big"; + + SqlCommand command = new SqlCommand(commandText, connection); + res = (long)command.ExecuteScalar(); + + } + catch (Exception ex) + { + Log.WriteError(ex); + } + finally + { + if (connection != null) + connection.Dispose(); + + } + + Log.WriteEnd("GetUsedSpace"); + return res; + + } + private bool CheckOrganizationUnique(string databaseName, string orgName) { Log.WriteStart("CheckOrganizationUnique"); @@ -319,17 +393,39 @@ namespace WebsitePanel.Providers.HostedSolution return retOrganization; } - public OrganizationResult CreateOrganization(Guid organizationId, string organizationUniqueName, string organizationFriendlyName, string baseCurrencyCode, string baseCurrencyName, string baseCurrencySymbol, string initialUserDomainName, string initialUserFirstName, string initialUserLastName, string initialUserPrimaryEmail, string organizationCollation) + public OrganizationResult CreateOrganization(Guid organizationId, string organizationUniqueName, string organizationFriendlyName, string organizationDomainName, string ou, string baseCurrencyCode, string baseCurrencyName, string baseCurrencySymbol, string initialUserDomainName, string initialUserFirstName, string initialUserLastName, string initialUserPrimaryEmail, string organizationCollation) { - return CreateOrganizationInternal(organizationId, organizationUniqueName, organizationFriendlyName, baseCurrencyCode, baseCurrencyName, baseCurrencySymbol, initialUserDomainName, initialUserFirstName, initialUserLastName, initialUserPrimaryEmail, organizationCollation); + return CreateOrganizationInternal(organizationId, organizationUniqueName, organizationFriendlyName, organizationDomainName, ou , baseCurrencyCode, baseCurrencyName, baseCurrencySymbol, initialUserDomainName, initialUserFirstName, initialUserLastName, initialUserPrimaryEmail, organizationCollation); } - const string CRMSysAdminRoleStr = "Ñèñòåìíûé àäìèíèñòðàòîð;System Administrator"; + const string CRMSysAdminRoleStr = "Системный администратор;System Administrator"; - internal OrganizationResult CreateOrganizationInternal(Guid organizationId, string organizationUniqueName, string organizationFriendlyName, string baseCurrencyCode, string baseCurrencyName, string baseCurrencySymbol, string initialUserDomainName, string initialUserFirstName, string initialUserLastName, string initialUserPrimaryEmail, string organizationCollation) + internal OrganizationResult CreateOrganizationInternal(Guid organizationId, string organizationUniqueName, string organizationFriendlyName, string organizationDomainName, string ou, string baseCurrencyCode, string baseCurrencyName, string baseCurrencySymbol, string initialUserDomainName, string initialUserFirstName, string initialUserLastName, string initialUserPrimaryEmail, string organizationCollation) { + OrganizationResult ret = StartLog("CreateOrganizationInternal"); + organizationUniqueName = Regex.Replace(organizationUniqueName, @"[^\dA-Za-z]", "-", RegexOptions.Compiled); + + // calculate UserRootPath + string ldapstr = ""; + + string[] ouItems = ou.Split('.'); + foreach (string ouItem in ouItems) + { + if (ldapstr.Length != 0) ldapstr += ","; + ldapstr += "OU=" + ouItem; + } + + string rootDomain = ServerSettings.ADRootDomain; + string[] domainItems = rootDomain.Split('.'); + foreach (string domainItem in domainItems) + ldapstr += ",DC=" + domainItem; + + ldapstr = @"LDAP://" + rootDomain + "/" + ldapstr; + + + if (organizationId == Guid.Empty) throw new ArgumentException("OrganizationId is Guid.Empty"); @@ -362,6 +458,8 @@ namespace WebsitePanel.Providers.HostedSolution Uri serviceUrl = new Uri(CRMServiceUrl); DeploymentServiceClient deploymentService = Microsoft.Xrm.Sdk.Deployment.Proxy.ProxyClientHelper.CreateClient(serviceUrl); + if (!String.IsNullOrEmpty(UserName)) + deploymentService.ClientCredentials.Windows.ClientCredential = new NetworkCredential(UserName, Password); Microsoft.Xrm.Sdk.Deployment.Organization org = new Microsoft.Xrm.Sdk.Deployment.Organization { @@ -397,9 +495,11 @@ namespace WebsitePanel.Providers.HostedSolution Microsoft.Xrm.Sdk.Deployment.OrganizationState OperationState = Microsoft.Xrm.Sdk.Deployment.OrganizationState.Pending; + int timeout = 30000; + do { - Thread.Sleep(30000); + Thread.Sleep(timeout); try { Microsoft.Xrm.Sdk.Deployment.Organization getorg @@ -413,16 +513,50 @@ namespace WebsitePanel.Providers.HostedSolution if (OperationState == Microsoft.Xrm.Sdk.Deployment.OrganizationState.Failed) throw new ArgumentException("Create organization failed."); - - try + // update UserRootPath setting + Microsoft.Xrm.Sdk.Deployment.ConfigurationEntity orgSettings = new Microsoft.Xrm.Sdk.Deployment.ConfigurationEntity { - OrganizationServiceProxy _serviceProxy = GetOrganizationProxy(organizationUniqueName); + Id = org.Id, + LogicalName = "Organization" + }; + orgSettings.Attributes = new Microsoft.Xrm.Sdk.Deployment.AttributeCollection(); + orgSettings.Attributes.Add(new KeyValuePair("UserRootPath", ldapstr)); + Microsoft.Xrm.Sdk.Deployment.UpdateAdvancedSettingsRequest reqUpdateSettings = new Microsoft.Xrm.Sdk.Deployment.UpdateAdvancedSettingsRequest + { + Entity = orgSettings + }; + Microsoft.Xrm.Sdk.Deployment.UpdateAdvancedSettingsResponse respUpdateSettings = (Microsoft.Xrm.Sdk.Deployment.UpdateAdvancedSettingsResponse) deploymentService.Execute(reqUpdateSettings); - string ldap = ""; + int tryTimeout = 30000; + int tryCount = 10; - Guid SysAdminGuid = RetrieveSystemUser(GetDomainName(initialUserDomainName), initialUserFirstName, initialUserLastName, CRMSysAdminRoleStr, _serviceProxy, ref ldap); + bool success = false; + int tryItem = 0; + + while (!success) + { + + try + { + Thread.Sleep(tryTimeout); + + OrganizationServiceProxy _serviceProxy = GetOrganizationProxy(organizationUniqueName, 0, 0); + + string ldap = ""; + + Guid SysAdminGuid = RetrieveSystemUser(GetDomainName(initialUserDomainName), initialUserFirstName, initialUserLastName, CRMSysAdminRoleStr, _serviceProxy, ref ldap); + + success = true; + + } + catch (Exception exc) + { + tryItem++; + if (tryItem >= tryCount) + success = true; + } } - catch { } + } catch (Exception ex) @@ -944,10 +1078,15 @@ namespace WebsitePanel.Providers.HostedSolution return false; } - int GetOrganizationProxyTryCount = 5; + int GetOrganizationProxyTryCount = 10; int GetOrganizationProxyTryTimeout = 30000; private OrganizationServiceProxy GetOrganizationProxy(string orgName) + { + return GetOrganizationProxy(orgName, GetOrganizationProxyTryCount, GetOrganizationProxyTryTimeout); + } + + private OrganizationServiceProxy GetOrganizationProxy(string orgName, int TryCount, int TryTimeout) { Uri OrganizationUri = GetOrganizationAddress(orgName); @@ -977,9 +1116,9 @@ namespace WebsitePanel.Providers.HostedSolution } catch (Exception exc) { - Thread.Sleep(GetOrganizationProxyTryTimeout); + Thread.Sleep(TryTimeout); tryItem++; - if (tryItem >= GetOrganizationProxyTryCount) + if (tryItem >= TryCount) { exception = exc; success = true; @@ -1013,7 +1152,6 @@ namespace WebsitePanel.Providers.HostedSolution return credentials; } - private DiscoveryServiceProxy GetDiscoveryProxy() { @@ -1041,7 +1179,20 @@ namespace WebsitePanel.Providers.HostedSolution protected virtual Uri GetOrganizationAddress(string orgName) { - string url = "https://" + ProviderSettings[Constants.AppRootDomain] + ":" + ProviderSettings[Constants.Port] + "/" + orgName + "/XRMServices/2011/Organization.svc"; + //string url = "https://" + ProviderSettings[Constants.AppRootDomain] + ":" + ProviderSettings[Constants.Port] + "/" + orgName + "/XRMServices/2011/Organization.svc"; + + string url; + + string organizationWebServiceUri = ProviderSettings[Constants.OrganizationWebService]; + + if (!String.IsNullOrEmpty(organizationWebServiceUri)) + { + url = "https://" + organizationWebServiceUri + ":" + ProviderSettings[Constants.Port] + "/" + orgName + "/XRMServices/2011/Organization.svc"; + } + else + { + url = "https://" + orgName + "." + ProviderSettings[Constants.IFDWebApplicationRootDomain] + ":" + ProviderSettings[Constants.Port] + "/XRMServices/2011/Organization.svc"; + } try { diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/CRMProvider.cs b/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/CRMProvider.cs index 9f00bc92..7a551525 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/CRMProvider.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/CRMProvider.cs @@ -328,7 +328,7 @@ namespace WebsitePanel.Providers.HostedSolution return retOrganization; } - public OrganizationResult CreateOrganization(Guid organizationId, string organizationUniqueName, string organizationFriendlyName, string baseCurrencyCode, string baseCurrencyName, string baseCurrencySymbol, string initialUserDomainName, string initialUserFirstName, string initialUserLastName, string initialUserPrimaryEmail, string organizationCollation) + public OrganizationResult CreateOrganization(Guid organizationId, string organizationUniqueName, string organizationFriendlyName, string organizationDomainName, string ou, string baseCurrencyCode, string baseCurrencyName, string baseCurrencySymbol, string initialUserDomainName, string initialUserFirstName, string initialUserLastName, string initialUserPrimaryEmail, string organizationCollation) { return CreateOrganizationInternal(organizationId, organizationUniqueName, organizationFriendlyName, baseCurrencyCode, baseCurrencyName, baseCurrencySymbol, initialUserDomainName, initialUserFirstName, initialUserLastName, initialUserPrimaryEmail, organizationCollation); } @@ -1545,6 +1545,11 @@ namespace WebsitePanel.Providers.HostedSolution return value.StartsWith("4."); } + public long GetUsedSpace(Guid organizationId) + { + return 0; + } + } } diff --git a/WebsitePanel/Sources/WebsitePanel.Server.Client/CRMProxy.cs b/WebsitePanel/Sources/WebsitePanel.Server.Client/CRMProxy.cs index 1d98cbc3..4939fae4 100644 --- a/WebsitePanel/Sources/WebsitePanel.Server.Client/CRMProxy.cs +++ b/WebsitePanel/Sources/WebsitePanel.Server.Client/CRMProxy.cs @@ -1,55 +1,26 @@ -// Copyright (c) 2012, Outercurve Foundation. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without modification, -// are permitted provided that the following conditions are met: -// -// - Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// -// - Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// - Neither the name of the Outercurve Foundation nor the names of its -// contributors may be used to endorse or promote products derived from this -// software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:2.0.50727.3053 +// Runtime Version:2.0.50727.5466 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // //------------------------------------------------------------------------------ -// -// This source code was auto-generated by wsdl, Version=2.0.50727.42. -// using WebsitePanel.Providers.Common; using WebsitePanel.Providers.HostedSolution; using WebsitePanel.Providers.ResultObjects; - +// +// This source code was auto-generated by wsdl, Version=2.0.50727.42. +// namespace WebsitePanel.Providers.CRM { - using System.Diagnostics; + using System.Xml.Serialization; using System.Web.Services; using System.ComponentModel; using System.Web.Services.Protocols; using System; - using System.Xml.Serialization; + using System.Diagnostics; /// @@ -86,9 +57,11 @@ namespace WebsitePanel.Providers.CRM { private System.Threading.SendOrPostCallback ChangeUserStateOperationCompleted; + private System.Threading.SendOrPostCallback GetUsedSpaceOperationCompleted; + /// public CRM() { - this.Url = "http://192.168.0.133:9003/CRM.asmx"; + this.Url = "http://localhost:9004/CRM.asmx"; } /// @@ -127,14 +100,19 @@ namespace WebsitePanel.Providers.CRM { /// public event ChangeUserStateCompletedEventHandler ChangeUserStateCompleted; + /// + public event GetUsedSpaceCompletedEventHandler GetUsedSpaceCompleted; + /// [System.Web.Services.Protocols.SoapHeaderAttribute("ServiceProviderSettingsSoapHeaderValue")] [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/server/CreateOrganization", RequestNamespace="http://smbsaas/websitepanel/server/", ResponseNamespace="http://smbsaas/websitepanel/server/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] - public OrganizationResult CreateOrganization(System.Guid organizationId, string organizationUniqueName, string organizationFriendlyName, string baseCurrencyCode, string baseCurrencyName, string baseCurrencySymbol, string initialUserDomainName, string initialUserFirstName, string initialUserLastName, string initialUserPrimaryEmail, string organizationCollation) { + public OrganizationResult CreateOrganization(System.Guid organizationId, string organizationUniqueName, string organizationFriendlyName, string organizationDomainName, string ou, string baseCurrencyCode, string baseCurrencyName, string baseCurrencySymbol, string initialUserDomainName, string initialUserFirstName, string initialUserLastName, string initialUserPrimaryEmail, string organizationCollation) { object[] results = this.Invoke("CreateOrganization", new object[] { organizationId, organizationUniqueName, organizationFriendlyName, + organizationDomainName, + ou, baseCurrencyCode, baseCurrencyName, baseCurrencySymbol, @@ -147,11 +125,13 @@ namespace WebsitePanel.Providers.CRM { } /// - public System.IAsyncResult BeginCreateOrganization(System.Guid organizationId, string organizationUniqueName, string organizationFriendlyName, string baseCurrencyCode, string baseCurrencyName, string baseCurrencySymbol, string initialUserDomainName, string initialUserFirstName, string initialUserLastName, string initialUserPrimaryEmail, string organizationCollation, System.AsyncCallback callback, object asyncState) { + public System.IAsyncResult BeginCreateOrganization(System.Guid organizationId, string organizationUniqueName, string organizationFriendlyName, string organizationDomainName, string ou, string baseCurrencyCode, string baseCurrencyName, string baseCurrencySymbol, string initialUserDomainName, string initialUserFirstName, string initialUserLastName, string initialUserPrimaryEmail, string organizationCollation, System.AsyncCallback callback, object asyncState) { return this.BeginInvoke("CreateOrganization", new object[] { organizationId, organizationUniqueName, organizationFriendlyName, + organizationDomainName, + ou, baseCurrencyCode, baseCurrencyName, baseCurrencySymbol, @@ -169,12 +149,12 @@ namespace WebsitePanel.Providers.CRM { } /// - public void CreateOrganizationAsync(System.Guid organizationId, string organizationUniqueName, string organizationFriendlyName, string baseCurrencyCode, string baseCurrencyName, string baseCurrencySymbol, string initialUserDomainName, string initialUserFirstName, string initialUserLastName, string initialUserPrimaryEmail, string organizationCollation) { - this.CreateOrganizationAsync(organizationId, organizationUniqueName, organizationFriendlyName, baseCurrencyCode, baseCurrencyName, baseCurrencySymbol, initialUserDomainName, initialUserFirstName, initialUserLastName, initialUserPrimaryEmail, organizationCollation, null); + public void CreateOrganizationAsync(System.Guid organizationId, string organizationUniqueName, string organizationFriendlyName, string organizationDomainName, string ou, string baseCurrencyCode, string baseCurrencyName, string baseCurrencySymbol, string initialUserDomainName, string initialUserFirstName, string initialUserLastName, string initialUserPrimaryEmail, string organizationCollation) { + this.CreateOrganizationAsync(organizationId, organizationUniqueName, organizationFriendlyName, organizationDomainName, ou, baseCurrencyCode, baseCurrencyName, baseCurrencySymbol, initialUserDomainName, initialUserFirstName, initialUserLastName, initialUserPrimaryEmail, organizationCollation, null); } /// - public void CreateOrganizationAsync(System.Guid organizationId, string organizationUniqueName, string organizationFriendlyName, string baseCurrencyCode, string baseCurrencyName, string baseCurrencySymbol, string initialUserDomainName, string initialUserFirstName, string initialUserLastName, string initialUserPrimaryEmail, string organizationCollation, object userState) { + public void CreateOrganizationAsync(System.Guid organizationId, string organizationUniqueName, string organizationFriendlyName, string organizationDomainName, string ou, string baseCurrencyCode, string baseCurrencyName, string baseCurrencySymbol, string initialUserDomainName, string initialUserFirstName, string initialUserLastName, string initialUserPrimaryEmail, string organizationCollation, object userState) { if ((this.CreateOrganizationOperationCompleted == null)) { this.CreateOrganizationOperationCompleted = new System.Threading.SendOrPostCallback(this.OnCreateOrganizationOperationCompleted); } @@ -182,6 +162,8 @@ namespace WebsitePanel.Providers.CRM { organizationId, organizationUniqueName, organizationFriendlyName, + organizationDomainName, + ou, baseCurrencyCode, baseCurrencyName, baseCurrencySymbol, @@ -691,33 +673,54 @@ namespace WebsitePanel.Providers.CRM { } } + /// + [System.Web.Services.Protocols.SoapHeaderAttribute("ServiceProviderSettingsSoapHeaderValue")] + [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/server/GetUsedSpace", RequestNamespace="http://smbsaas/websitepanel/server/", ResponseNamespace="http://smbsaas/websitepanel/server/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] + public long GetUsedSpace(System.Guid organizationId) { + object[] results = this.Invoke("GetUsedSpace", new object[] { + organizationId}); + return ((long)(results[0])); + } + + /// + public System.IAsyncResult BeginGetUsedSpace(System.Guid organizationId, System.AsyncCallback callback, object asyncState) { + return this.BeginInvoke("GetUsedSpace", new object[] { + organizationId}, callback, asyncState); + } + + /// + public long EndGetUsedSpace(System.IAsyncResult asyncResult) { + object[] results = this.EndInvoke(asyncResult); + return ((long)(results[0])); + } + + /// + public void GetUsedSpaceAsync(System.Guid organizationId) { + this.GetUsedSpaceAsync(organizationId, null); + } + + /// + public void GetUsedSpaceAsync(System.Guid organizationId, object userState) { + if ((this.GetUsedSpaceOperationCompleted == null)) { + this.GetUsedSpaceOperationCompleted = new System.Threading.SendOrPostCallback(this.OnGetUsedSpaceOperationCompleted); + } + this.InvokeAsync("GetUsedSpace", new object[] { + organizationId}, this.GetUsedSpaceOperationCompleted, userState); + } + + private void OnGetUsedSpaceOperationCompleted(object arg) { + if ((this.GetUsedSpaceCompleted != null)) { + System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); + this.GetUsedSpaceCompleted(this, new GetUsedSpaceCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); + } + } + /// public new void CancelAsync(object userState) { base.CancelAsync(userState); } } - - - - - - - - - - - - - - - - - - - - - /// [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")] public delegate void CreateOrganizationCompletedEventHandler(object sender, CreateOrganizationCompletedEventArgs e); @@ -1029,4 +1032,30 @@ namespace WebsitePanel.Providers.CRM { } } } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")] + public delegate void GetUsedSpaceCompletedEventHandler(object sender, GetUsedSpaceCompletedEventArgs e); + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + public partial class GetUsedSpaceCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs { + + private object[] results; + + internal GetUsedSpaceCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : + base(exception, cancelled, userState) { + this.results = results; + } + + /// + public long Result { + get { + this.RaiseExceptionIfNecessary(); + return ((long)(this.results[0])); + } + } + } } diff --git a/WebsitePanel/Sources/WebsitePanel.Server/CRM.asmx.cs b/WebsitePanel/Sources/WebsitePanel.Server/CRM.asmx.cs index 7c8ff121..eba10cc1 100644 --- a/WebsitePanel/Sources/WebsitePanel.Server/CRM.asmx.cs +++ b/WebsitePanel/Sources/WebsitePanel.Server/CRM.asmx.cs @@ -55,9 +55,9 @@ namespace WebsitePanel.Server [WebMethod, SoapHeader("settings")] - public OrganizationResult CreateOrganization(Guid organizationId, string organizationUniqueName, string organizationFriendlyName, string baseCurrencyCode, string baseCurrencyName, string baseCurrencySymbol, string initialUserDomainName, string initialUserFirstName, string initialUserLastName, string initialUserPrimaryEmail, string organizationCollation) + public OrganizationResult CreateOrganization(Guid organizationId, string organizationUniqueName, string organizationFriendlyName, string organizationDomainName, string ou, string baseCurrencyCode, string baseCurrencyName, string baseCurrencySymbol, string initialUserDomainName, string initialUserFirstName, string initialUserLastName, string initialUserPrimaryEmail, string organizationCollation) { - return CrmProvider.CreateOrganization(organizationId, organizationUniqueName, organizationFriendlyName, baseCurrencyCode, baseCurrencyName, baseCurrencySymbol, initialUserDomainName, initialUserFirstName, initialUserLastName, initialUserPrimaryEmail, organizationCollation); + return CrmProvider.CreateOrganization(organizationId, organizationUniqueName, organizationFriendlyName, organizationDomainName, ou, baseCurrencyCode, baseCurrencyName, baseCurrencySymbol, initialUserDomainName, initialUserFirstName, initialUserLastName, initialUserPrimaryEmail, organizationCollation); } [WebMethod, SoapHeader("settings")] @@ -126,5 +126,13 @@ namespace WebsitePanel.Server { return CrmProvider.ChangeUserState(disable, orgName, crmUserId); } + + [WebMethod, SoapHeader("settings")] + public long GetUsedSpace(Guid organizationId) + { + return CrmProvider.GetUsedSpace( organizationId); + } + + } } diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/CRM2011_Settings.ascx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/CRM2011_Settings.ascx index 5fc28f50..b9febeb0 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/CRM2011_Settings.ascx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/CRM2011_Settings.ascx @@ -51,14 +51,47 @@ - Deployment web service + Web Application Server + + Organization Web Service + + + + + + Discovery Web Service + + + + + + + + Deployment Web Service + + + + + - + + Service account + + + + + + Password + + + + + \ No newline at end of file diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/CRM2011_Settings.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/CRM2011_Settings.ascx.cs index 761a530b..ba38a58e 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/CRM2011_Settings.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/CRM2011_Settings.ascx.cs @@ -47,7 +47,16 @@ namespace WebsitePanel.Portal.ProviderControls txtSqlServer.Text = settings[Constants.SqlServer]; txtDomainName.Text = settings[Constants.IFDWebApplicationRootDomain]; txtPort.Text = settings[Constants.Port]; + txtAppRootDomain.Text = settings[Constants.AppRootDomain]; + txtOrganizationWebService.Text = settings[Constants.OrganizationWebService]; + txtDiscoveryWebService.Text = settings[Constants.DiscoveryWebService]; + txtDeploymentWebService.Text = settings[Constants.DeploymentWebService]; + + txtPassword.Text = settings[Constants.Password]; + ViewState["PWD"] = settings[Constants.Password]; + txtUserName.Text = settings[Constants.UserName]; + int selectedAddressid = FindAddressByText(settings[Constants.CRMWebsiteIP]); ddlCrmIpAddress.AddressId = (selectedAddressid > 0) ? selectedAddressid : 0; @@ -61,7 +70,15 @@ namespace WebsitePanel.Portal.ProviderControls settings[Constants.SqlServer] = txtSqlServer.Text; settings[Constants.IFDWebApplicationRootDomain] = txtDomainName.Text; settings[Constants.Port] = txtPort.Text; + settings[Constants.AppRootDomain] = txtAppRootDomain.Text; + settings[Constants.OrganizationWebService] = txtOrganizationWebService.Text; + settings[Constants.DiscoveryWebService] = txtDiscoveryWebService.Text; + settings[Constants.DeploymentWebService] = txtDeploymentWebService.Text; + + settings[Constants.Password] = (txtPassword.Text.Length > 0) ? txtPassword.Text : (string)ViewState["PWD"]; + settings[Constants.UserName] = txtUserName.Text; + if (ddlCrmIpAddress.AddressId > 0) { IPAddressInfo address = ES.Services.Servers.GetIPAddress(ddlCrmIpAddress.AddressId); diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/CRM2011_Settings.ascx.designer.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/CRM2011_Settings.ascx.designer.cs index 86ec4040..be9b87cf 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/CRM2011_Settings.ascx.designer.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/CRM2011_Settings.ascx.designer.cs @@ -1,39 +1,10 @@ -// Copyright (c) 2011, Outercurve Foundation. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without modification, -// are permitted provided that the following conditions are met: -// -// - Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// -// - Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// - Neither the name of the Outercurve Foundation nor the names of its -// contributors may be used to endorse or promote products derived from this -// software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - //------------------------------------------------------------------------------ -// -// This code was generated by a tool. +// < > +// . // -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// - +// +// . +// //------------------------------------------------------------------------------ namespace WebsitePanel.Portal.ProviderControls { @@ -42,93 +13,129 @@ namespace WebsitePanel.Portal.ProviderControls { public partial class CRM2011_Settings { /// - /// txtSqlServer control. + /// txtSqlServer . /// /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - + /// . + /// . /// protected global::System.Web.UI.WebControls.TextBox txtSqlServer; /// - /// RequiredFieldValidator1 control. + /// RequiredFieldValidator1 . /// /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - + /// . + /// . /// protected global::System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator1; /// - /// txtReportingService control. + /// txtReportingService . /// /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - + /// . + /// . /// protected global::System.Web.UI.WebControls.TextBox txtReportingService; /// - /// txtDomainName control. + /// txtDomainName . /// /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - + /// . + /// . /// protected global::System.Web.UI.WebControls.TextBox txtDomainName; /// - /// RequiredFieldValidator2 control. + /// RequiredFieldValidator2 . /// /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - + /// . + /// . /// protected global::System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator2; /// - /// ddlSchema control. + /// ddlSchema . /// /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - + /// . + /// . /// protected global::System.Web.UI.WebControls.DropDownList ddlSchema; /// - /// ddlCrmIpAddress control. + /// ddlCrmIpAddress . /// /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - + /// . + /// . /// protected global::WebsitePanel.Portal.SelectIPAddress ddlCrmIpAddress; /// - /// txtPort control. + /// txtPort . /// /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - + /// . + /// . /// protected global::System.Web.UI.WebControls.TextBox txtPort; /// - /// txtAppRootDomain control. + /// txtAppRootDomain . /// /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - + /// . + /// . /// protected global::System.Web.UI.WebControls.TextBox txtAppRootDomain; + + /// + /// txtOrganizationWebService . + /// + /// + /// . + /// . + /// + protected global::System.Web.UI.WebControls.TextBox txtOrganizationWebService; + + /// + /// txtDiscoveryWebService . + /// + /// + /// . + /// . + /// + protected global::System.Web.UI.WebControls.TextBox txtDiscoveryWebService; + + /// + /// txtDeploymentWebService . + /// + /// + /// . + /// . + /// + protected global::System.Web.UI.WebControls.TextBox txtDeploymentWebService; + + /// + /// txtUserName . + /// + /// + /// . + /// . + /// + protected global::System.Web.UI.WebControls.TextBox txtUserName; + + /// + /// txtPassword . + /// + /// + /// . + /// . + /// + protected global::System.Web.UI.WebControls.TextBox txtPassword; } }