diff --git a/WebsitePanel/Database/update_db.sql b/WebsitePanel/Database/update_db.sql
index 2a4e69e6..802718bc 100644
--- a/WebsitePanel/Database/update_db.sql
+++ b/WebsitePanel/Database/update_db.sql
@@ -1,4 +1,4 @@
-USE [${install.database}]
+USE [${install.database}]
GO
-- update database version
DECLARE @build_version nvarchar(10), @build_date datetime
@@ -8860,112 +8860,163 @@ AND ((@GroupName IS NULL) OR (@GroupName IS NOT NULL AND RG.GroupName = @GroupNa
RETURN
GO
-
-
-IF NOT EXISTS (SELECT * FROM [dbo].[UserSettings] WHERE [UserID] = 1 AND [SettingsName]= N'RDSSetupLetter' AND [PropertyName]= N'CC' )
+-- Hyper-V 2012 R2
+IF NOT EXISTS (SELECT * FROM [dbo].[Providers] WHERE [ProviderName] = 'HyperV2012R2')
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')
+INSERT [dbo].[Providers] ([ProviderID], [GroupID], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery]) VALUES (350, 30, N'HyperV2012R2', N'Microsoft Hyper-V 2012 R2', N'WebsitePanel.Providers.Virtualization.HyperV2012R2, WebsitePanel.Providers.Virtualization.HyperV2012R2', N'HyperV', 1)
END
GO
-DECLARE @RDSSetupLetterHtmlBody nvarchar(2500)
+--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
-Set @RDSSetupLetterHtmlBody = N'
-
- RDS Setup Information
-
-
-
-
+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 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'
+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 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
+
+IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE type = 'P' AND name = 'DeleteAllEnterpriseFolderOwaUsers')
+DROP PROCEDURE DeleteAllEnterpriseFolderOwaUsers
GO
-IF NOT EXISTS (SELECT * FROM [dbo].[UserSettings] WHERE [UserID] = 1 AND [SettingsName]= N'RDSSetupLetter' AND [PropertyName]= N'Subject' )
+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].[UserSettings] ([UserID], [SettingsName], [PropertyName], [PropertyValue]) VALUES (1, N'RDSSetupLetter', N'Subject', N'RDS setup')
+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
-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
\ No newline at end of file
diff --git a/WebsitePanel/Lib/References/Microsoft/CRM2015/Microsoft.Crm.Sdk.Proxy.dll b/WebsitePanel/Lib/References/Microsoft/CRM2015/Microsoft.Crm.Sdk.Proxy.dll
new file mode 100644
index 00000000..6d736097
Binary files /dev/null and b/WebsitePanel/Lib/References/Microsoft/CRM2015/Microsoft.Crm.Sdk.Proxy.dll differ
diff --git a/WebsitePanel/Lib/References/Microsoft/CRM2015/Microsoft.Xrm.Client.CodeGeneration.dll b/WebsitePanel/Lib/References/Microsoft/CRM2015/Microsoft.Xrm.Client.CodeGeneration.dll
new file mode 100644
index 00000000..fc20d921
Binary files /dev/null and b/WebsitePanel/Lib/References/Microsoft/CRM2015/Microsoft.Xrm.Client.CodeGeneration.dll differ
diff --git a/WebsitePanel/Lib/References/Microsoft/CRM2015/Microsoft.Xrm.Client.dll b/WebsitePanel/Lib/References/Microsoft/CRM2015/Microsoft.Xrm.Client.dll
new file mode 100644
index 00000000..94be8cd7
Binary files /dev/null and b/WebsitePanel/Lib/References/Microsoft/CRM2015/Microsoft.Xrm.Client.dll differ
diff --git a/WebsitePanel/Lib/References/Microsoft/CRM2015/Microsoft.Xrm.Portal.Files.dll b/WebsitePanel/Lib/References/Microsoft/CRM2015/Microsoft.Xrm.Portal.Files.dll
new file mode 100644
index 00000000..51ac3758
Binary files /dev/null and b/WebsitePanel/Lib/References/Microsoft/CRM2015/Microsoft.Xrm.Portal.Files.dll differ
diff --git a/WebsitePanel/Lib/References/Microsoft/CRM2015/Microsoft.Xrm.Portal.dll b/WebsitePanel/Lib/References/Microsoft/CRM2015/Microsoft.Xrm.Portal.dll
new file mode 100644
index 00000000..cad08f8b
Binary files /dev/null and b/WebsitePanel/Lib/References/Microsoft/CRM2015/Microsoft.Xrm.Portal.dll differ
diff --git a/WebsitePanel/Lib/References/Microsoft/CRM2015/Microsoft.Xrm.Sdk.Deployment.dll b/WebsitePanel/Lib/References/Microsoft/CRM2015/Microsoft.Xrm.Sdk.Deployment.dll
new file mode 100644
index 00000000..edd84245
Binary files /dev/null and b/WebsitePanel/Lib/References/Microsoft/CRM2015/Microsoft.Xrm.Sdk.Deployment.dll differ
diff --git a/WebsitePanel/Lib/References/Microsoft/CRM2015/Microsoft.Xrm.Sdk.Workflow.dll b/WebsitePanel/Lib/References/Microsoft/CRM2015/Microsoft.Xrm.Sdk.Workflow.dll
new file mode 100644
index 00000000..e584c526
Binary files /dev/null and b/WebsitePanel/Lib/References/Microsoft/CRM2015/Microsoft.Xrm.Sdk.Workflow.dll differ
diff --git a/WebsitePanel/Lib/References/Microsoft/CRM2015/Microsoft.Xrm.Sdk.dll b/WebsitePanel/Lib/References/Microsoft/CRM2015/Microsoft.Xrm.Sdk.dll
new file mode 100644
index 00000000..dc1e25da
Binary files /dev/null and b/WebsitePanel/Lib/References/Microsoft/CRM2015/Microsoft.Xrm.Sdk.dll differ
diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/HostedSolution/CRMLycenseTypes.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/HostedSolution/CRMLycenseTypes.cs
index 4e999f18..f8a1c58a 100644
--- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/HostedSolution/CRMLycenseTypes.cs
+++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/HostedSolution/CRMLycenseTypes.cs
@@ -41,7 +41,7 @@ namespace WebsitePanel.EnterpriseServer
public const int LIMITED = 2;
public const int ESS = 22;
- // CRM 2013
+ // CRM 2013/2015
public const int PROFESSIONAL = 0;
public const int BASIC = 2;
public const int ESSENTIAL = 5;
diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/Servers/ResourceGroups.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/Servers/ResourceGroups.cs
index e9c2b2a7..877cfc9f 100644
--- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/Servers/ResourceGroups.cs
+++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/Servers/ResourceGroups.cs
@@ -49,7 +49,7 @@ namespace WebsitePanel.EnterpriseServer
public const string Exchange = "Exchange";
public const string HostedOrganizations = "Hosted Organizations";
public const string HostedCRM = "Hosted CRM";
- public const string HostedCRM2013 = "Hosted CRM2013";
+ public const string HostedCRM2013 = "Hosted CRM2013"; // CRM 2013/2015
public const string VPS = "VPS";
public const string BlackBerry = "BlackBerry";
public const string OCS = "OCS";
diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Client/EnterpriseStorageProxy.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Client/EnterpriseStorageProxy.cs
index 87682b0f..ef29192f 100644
--- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Client/EnterpriseStorageProxy.cs
+++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Client/EnterpriseStorageProxy.cs
@@ -81,6 +81,16 @@ namespace WebsitePanel.EnterpriseServer {
private System.Threading.SendOrPostCallback SetEnterpriseFolderSettingsOperationCompleted;
+ private System.Threading.SendOrPostCallback SetEnterpriseFolderGeneralSettingsOperationCompleted;
+
+ private System.Threading.SendOrPostCallback SetEnterpriseFolderPermissionSettingsOperationCompleted;
+
+ private System.Threading.SendOrPostCallback GetFolderOwaAccountsOperationCompleted;
+
+ private System.Threading.SendOrPostCallback SetFolderOwaAccountsOperationCompleted;
+
+ private System.Threading.SendOrPostCallback GetUserEnterpriseFolderWithOwaEditPermissionOperationCompleted;
+
private System.Threading.SendOrPostCallback GetStatisticsOperationCompleted;
private System.Threading.SendOrPostCallback GetStatisticsByOrganizationOperationCompleted;
@@ -169,6 +179,21 @@ namespace WebsitePanel.EnterpriseServer {
///
public event SetEnterpriseFolderSettingsCompletedEventHandler SetEnterpriseFolderSettingsCompleted;
+ ///
+ public event SetEnterpriseFolderGeneralSettingsCompletedEventHandler SetEnterpriseFolderGeneralSettingsCompleted;
+
+ ///
+ public event SetEnterpriseFolderPermissionSettingsCompletedEventHandler SetEnterpriseFolderPermissionSettingsCompleted;
+
+ ///
+ public event GetFolderOwaAccountsCompletedEventHandler GetFolderOwaAccountsCompleted;
+
+ ///
+ public event SetFolderOwaAccountsCompletedEventHandler SetFolderOwaAccountsCompleted;
+
+ ///
+ public event GetUserEnterpriseFolderWithOwaEditPermissionCompletedEventHandler GetUserEnterpriseFolderWithOwaEditPermissionCompleted;
+
///
public event GetStatisticsCompletedEventHandler GetStatisticsCompleted;
@@ -1223,6 +1248,237 @@ namespace WebsitePanel.EnterpriseServer {
}
}
+ ///
+ [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/enterpriseserver/SetEnterpriseFolderGeneralSettings", RequestNamespace="http://smbsaas/websitepanel/enterpriseserver", ResponseNamespace="http://smbsaas/websitepanel/enterpriseserver", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
+ public void SetEnterpriseFolderGeneralSettings(int itemId, SystemFile folder, bool directoyBrowsingEnabled, int quota, QuotaType quotaType) {
+ this.Invoke("SetEnterpriseFolderGeneralSettings", new object[] {
+ itemId,
+ folder,
+ directoyBrowsingEnabled,
+ quota,
+ quotaType});
+ }
+
+ ///
+ public System.IAsyncResult BeginSetEnterpriseFolderGeneralSettings(int itemId, SystemFile folder, bool directoyBrowsingEnabled, int quota, QuotaType quotaType, System.AsyncCallback callback, object asyncState) {
+ return this.BeginInvoke("SetEnterpriseFolderGeneralSettings", new object[] {
+ itemId,
+ folder,
+ directoyBrowsingEnabled,
+ quota,
+ quotaType}, callback, asyncState);
+ }
+
+ ///
+ public void EndSetEnterpriseFolderGeneralSettings(System.IAsyncResult asyncResult) {
+ this.EndInvoke(asyncResult);
+ }
+
+ ///
+ public void SetEnterpriseFolderGeneralSettingsAsync(int itemId, SystemFile folder, bool directoyBrowsingEnabled, int quota, QuotaType quotaType) {
+ this.SetEnterpriseFolderGeneralSettingsAsync(itemId, folder, directoyBrowsingEnabled, quota, quotaType, null);
+ }
+
+ ///
+ public void SetEnterpriseFolderGeneralSettingsAsync(int itemId, SystemFile folder, bool directoyBrowsingEnabled, int quota, QuotaType quotaType, object userState) {
+ if ((this.SetEnterpriseFolderGeneralSettingsOperationCompleted == null)) {
+ this.SetEnterpriseFolderGeneralSettingsOperationCompleted = new System.Threading.SendOrPostCallback(this.OnSetEnterpriseFolderGeneralSettingsOperationCompleted);
+ }
+ this.InvokeAsync("SetEnterpriseFolderGeneralSettings", new object[] {
+ itemId,
+ folder,
+ directoyBrowsingEnabled,
+ quota,
+ quotaType}, this.SetEnterpriseFolderGeneralSettingsOperationCompleted, userState);
+ }
+
+ private void OnSetEnterpriseFolderGeneralSettingsOperationCompleted(object arg) {
+ if ((this.SetEnterpriseFolderGeneralSettingsCompleted != null)) {
+ System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
+ this.SetEnterpriseFolderGeneralSettingsCompleted(this, new System.ComponentModel.AsyncCompletedEventArgs(invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
+ }
+ }
+
+ ///
+ [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/enterpriseserver/SetEnterpriseFolderPermissionSetting" +
+ "s", RequestNamespace="http://smbsaas/websitepanel/enterpriseserver", ResponseNamespace="http://smbsaas/websitepanel/enterpriseserver", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
+ public void SetEnterpriseFolderPermissionSettings(int itemId, SystemFile folder, ESPermission[] permissions) {
+ this.Invoke("SetEnterpriseFolderPermissionSettings", new object[] {
+ itemId,
+ folder,
+ permissions});
+ }
+
+ ///
+ public System.IAsyncResult BeginSetEnterpriseFolderPermissionSettings(int itemId, SystemFile folder, ESPermission[] permissions, System.AsyncCallback callback, object asyncState) {
+ return this.BeginInvoke("SetEnterpriseFolderPermissionSettings", new object[] {
+ itemId,
+ folder,
+ permissions}, callback, asyncState);
+ }
+
+ ///
+ public void EndSetEnterpriseFolderPermissionSettings(System.IAsyncResult asyncResult) {
+ this.EndInvoke(asyncResult);
+ }
+
+ ///
+ public void SetEnterpriseFolderPermissionSettingsAsync(int itemId, SystemFile folder, ESPermission[] permissions) {
+ this.SetEnterpriseFolderPermissionSettingsAsync(itemId, folder, permissions, null);
+ }
+
+ ///
+ public void SetEnterpriseFolderPermissionSettingsAsync(int itemId, SystemFile folder, ESPermission[] permissions, object userState) {
+ if ((this.SetEnterpriseFolderPermissionSettingsOperationCompleted == null)) {
+ this.SetEnterpriseFolderPermissionSettingsOperationCompleted = new System.Threading.SendOrPostCallback(this.OnSetEnterpriseFolderPermissionSettingsOperationCompleted);
+ }
+ this.InvokeAsync("SetEnterpriseFolderPermissionSettings", new object[] {
+ itemId,
+ folder,
+ permissions}, this.SetEnterpriseFolderPermissionSettingsOperationCompleted, userState);
+ }
+
+ private void OnSetEnterpriseFolderPermissionSettingsOperationCompleted(object arg) {
+ if ((this.SetEnterpriseFolderPermissionSettingsCompleted != null)) {
+ System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
+ this.SetEnterpriseFolderPermissionSettingsCompleted(this, new System.ComponentModel.AsyncCompletedEventArgs(invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
+ }
+ }
+
+ ///
+ [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/enterpriseserver/GetFolderOwaAccounts", RequestNamespace="http://smbsaas/websitepanel/enterpriseserver", ResponseNamespace="http://smbsaas/websitepanel/enterpriseserver", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
+ public OrganizationUser[] GetFolderOwaAccounts(int itemId, SystemFile folder) {
+ object[] results = this.Invoke("GetFolderOwaAccounts", new object[] {
+ itemId,
+ folder});
+ return ((OrganizationUser[])(results[0]));
+ }
+
+ ///
+ public System.IAsyncResult BeginGetFolderOwaAccounts(int itemId, SystemFile folder, System.AsyncCallback callback, object asyncState) {
+ return this.BeginInvoke("GetFolderOwaAccounts", new object[] {
+ itemId,
+ folder}, callback, asyncState);
+ }
+
+ ///
+ public OrganizationUser[] EndGetFolderOwaAccounts(System.IAsyncResult asyncResult) {
+ object[] results = this.EndInvoke(asyncResult);
+ return ((OrganizationUser[])(results[0]));
+ }
+
+ ///
+ public void GetFolderOwaAccountsAsync(int itemId, SystemFile folder) {
+ this.GetFolderOwaAccountsAsync(itemId, folder, null);
+ }
+
+ ///
+ public void GetFolderOwaAccountsAsync(int itemId, SystemFile folder, object userState) {
+ if ((this.GetFolderOwaAccountsOperationCompleted == null)) {
+ this.GetFolderOwaAccountsOperationCompleted = new System.Threading.SendOrPostCallback(this.OnGetFolderOwaAccountsOperationCompleted);
+ }
+ this.InvokeAsync("GetFolderOwaAccounts", new object[] {
+ itemId,
+ folder}, this.GetFolderOwaAccountsOperationCompleted, userState);
+ }
+
+ private void OnGetFolderOwaAccountsOperationCompleted(object arg) {
+ if ((this.GetFolderOwaAccountsCompleted != null)) {
+ System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
+ this.GetFolderOwaAccountsCompleted(this, new GetFolderOwaAccountsCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
+ }
+ }
+
+ ///
+ [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/enterpriseserver/SetFolderOwaAccounts", RequestNamespace="http://smbsaas/websitepanel/enterpriseserver", ResponseNamespace="http://smbsaas/websitepanel/enterpriseserver", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
+ public void SetFolderOwaAccounts(int itemId, SystemFile folder, OrganizationUser[] users) {
+ this.Invoke("SetFolderOwaAccounts", new object[] {
+ itemId,
+ folder,
+ users});
+ }
+
+ ///
+ public System.IAsyncResult BeginSetFolderOwaAccounts(int itemId, SystemFile folder, OrganizationUser[] users, System.AsyncCallback callback, object asyncState) {
+ return this.BeginInvoke("SetFolderOwaAccounts", new object[] {
+ itemId,
+ folder,
+ users}, callback, asyncState);
+ }
+
+ ///
+ public void EndSetFolderOwaAccounts(System.IAsyncResult asyncResult) {
+ this.EndInvoke(asyncResult);
+ }
+
+ ///
+ public void SetFolderOwaAccountsAsync(int itemId, SystemFile folder, OrganizationUser[] users) {
+ this.SetFolderOwaAccountsAsync(itemId, folder, users, null);
+ }
+
+ ///
+ public void SetFolderOwaAccountsAsync(int itemId, SystemFile folder, OrganizationUser[] users, object userState) {
+ if ((this.SetFolderOwaAccountsOperationCompleted == null)) {
+ this.SetFolderOwaAccountsOperationCompleted = new System.Threading.SendOrPostCallback(this.OnSetFolderOwaAccountsOperationCompleted);
+ }
+ this.InvokeAsync("SetFolderOwaAccounts", new object[] {
+ itemId,
+ folder,
+ users}, this.SetFolderOwaAccountsOperationCompleted, userState);
+ }
+
+ private void OnSetFolderOwaAccountsOperationCompleted(object arg) {
+ if ((this.SetFolderOwaAccountsCompleted != null)) {
+ System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
+ this.SetFolderOwaAccountsCompleted(this, new System.ComponentModel.AsyncCompletedEventArgs(invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
+ }
+ }
+
+ ///
+ [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/enterpriseserver/GetUserEnterpriseFolderWithOwaEditPe" +
+ "rmission", RequestNamespace="http://smbsaas/websitepanel/enterpriseserver", ResponseNamespace="http://smbsaas/websitepanel/enterpriseserver", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
+ public string[] GetUserEnterpriseFolderWithOwaEditPermission(int itemId, int[] accountIds) {
+ object[] results = this.Invoke("GetUserEnterpriseFolderWithOwaEditPermission", new object[] {
+ itemId,
+ accountIds});
+ return ((string[])(results[0]));
+ }
+
+ ///
+ public System.IAsyncResult BeginGetUserEnterpriseFolderWithOwaEditPermission(int itemId, int[] accountIds, System.AsyncCallback callback, object asyncState) {
+ return this.BeginInvoke("GetUserEnterpriseFolderWithOwaEditPermission", new object[] {
+ itemId,
+ accountIds}, callback, asyncState);
+ }
+
+ ///
+ public string[] EndGetUserEnterpriseFolderWithOwaEditPermission(System.IAsyncResult asyncResult) {
+ object[] results = this.EndInvoke(asyncResult);
+ return ((string[])(results[0]));
+ }
+
+ ///
+ public void GetUserEnterpriseFolderWithOwaEditPermissionAsync(int itemId, int[] accountIds) {
+ this.GetUserEnterpriseFolderWithOwaEditPermissionAsync(itemId, accountIds, null);
+ }
+
+ ///
+ public void GetUserEnterpriseFolderWithOwaEditPermissionAsync(int itemId, int[] accountIds, object userState) {
+ if ((this.GetUserEnterpriseFolderWithOwaEditPermissionOperationCompleted == null)) {
+ this.GetUserEnterpriseFolderWithOwaEditPermissionOperationCompleted = new System.Threading.SendOrPostCallback(this.OnGetUserEnterpriseFolderWithOwaEditPermissionOperationCompleted);
+ }
+ this.InvokeAsync("GetUserEnterpriseFolderWithOwaEditPermission", new object[] {
+ itemId,
+ accountIds}, this.GetUserEnterpriseFolderWithOwaEditPermissionOperationCompleted, userState);
+ }
+
+ private void OnGetUserEnterpriseFolderWithOwaEditPermissionOperationCompleted(object arg) {
+ if ((this.GetUserEnterpriseFolderWithOwaEditPermissionCompleted != null)) {
+ System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
+ this.GetUserEnterpriseFolderWithOwaEditPermissionCompleted(this, new GetUserEnterpriseFolderWithOwaEditPermissionCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
+ }
+ }
+
///
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/enterpriseserver/GetStatistics", RequestNamespace="http://smbsaas/websitepanel/enterpriseserver", ResponseNamespace="http://smbsaas/websitepanel/enterpriseserver", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
public OrganizationStatistics GetStatistics(int itemId) {
@@ -2053,6 +2309,70 @@ namespace WebsitePanel.EnterpriseServer {
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")]
public delegate void SetEnterpriseFolderSettingsCompletedEventHandler(object sender, System.ComponentModel.AsyncCompletedEventArgs e);
+ ///
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")]
+ public delegate void SetEnterpriseFolderGeneralSettingsCompletedEventHandler(object sender, System.ComponentModel.AsyncCompletedEventArgs e);
+
+ ///
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")]
+ public delegate void SetEnterpriseFolderPermissionSettingsCompletedEventHandler(object sender, System.ComponentModel.AsyncCompletedEventArgs e);
+
+ ///
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")]
+ public delegate void GetFolderOwaAccountsCompletedEventHandler(object sender, GetFolderOwaAccountsCompletedEventArgs e);
+
+ ///
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")]
+ [System.Diagnostics.DebuggerStepThroughAttribute()]
+ [System.ComponentModel.DesignerCategoryAttribute("code")]
+ public partial class GetFolderOwaAccountsCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
+
+ private object[] results;
+
+ internal GetFolderOwaAccountsCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) :
+ base(exception, cancelled, userState) {
+ this.results = results;
+ }
+
+ ///
+ public OrganizationUser[] Result {
+ get {
+ this.RaiseExceptionIfNecessary();
+ return ((OrganizationUser[])(this.results[0]));
+ }
+ }
+ }
+
+ ///
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")]
+ public delegate void SetFolderOwaAccountsCompletedEventHandler(object sender, System.ComponentModel.AsyncCompletedEventArgs e);
+
+ ///
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")]
+ public delegate void GetUserEnterpriseFolderWithOwaEditPermissionCompletedEventHandler(object sender, GetUserEnterpriseFolderWithOwaEditPermissionCompletedEventArgs e);
+
+ ///
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")]
+ [System.Diagnostics.DebuggerStepThroughAttribute()]
+ [System.ComponentModel.DesignerCategoryAttribute("code")]
+ public partial class GetUserEnterpriseFolderWithOwaEditPermissionCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
+
+ private object[] results;
+
+ internal GetUserEnterpriseFolderWithOwaEditPermissionCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) :
+ base(exception, cancelled, userState) {
+ this.results = results;
+ }
+
+ ///
+ public string[] Result {
+ get {
+ this.RaiseExceptionIfNecessary();
+ return ((string[])(this.results[0]));
+ }
+ }
+ }
+
///
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")]
public delegate void GetStatisticsCompletedEventHandler(object sender, GetStatisticsCompletedEventArgs e);
diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Data/DataProvider.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Data/DataProvider.cs
index 0c75029f..d83c4684 100644
--- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Data/DataProvider.cs
+++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Data/DataProvider.cs
@@ -4543,6 +4543,69 @@ namespace WebsitePanel.EnterpriseServer
);
}
+ public static void DeleteAllEnterpriseFolderOwaUsers(int itemId, int folderId)
+ {
+ SqlHelper.ExecuteNonQuery(
+ ConnectionString,
+ CommandType.StoredProcedure,
+ "DeleteAllEnterpriseFolderOwaUsers",
+ new SqlParameter("@ItemID", itemId),
+ new SqlParameter("@FolderID", folderId)
+ );
+ }
+
+ public static int AddEnterpriseFolderOwaUser(int itemId, int folderId, int accountId)
+ {
+ SqlParameter id = new SqlParameter("@ESOwsaUserId", SqlDbType.Int);
+ id.Direction = ParameterDirection.Output;
+
+ SqlHelper.ExecuteNonQuery(
+ ConnectionString,
+ CommandType.StoredProcedure,
+ "AddEnterpriseFolderOwaUser",
+ id,
+ new SqlParameter("@ItemID", itemId),
+ new SqlParameter("@FolderID", folderId),
+ new SqlParameter("@AccountId", accountId)
+ );
+
+ // read identity
+ return Convert.ToInt32(id.Value);
+ }
+
+ public static IDataReader GetEnterpriseFolderOwaUsers(int itemId, int folderId)
+ {
+ return SqlHelper.ExecuteReader(
+ ConnectionString,
+ CommandType.StoredProcedure,
+ "GetEnterpriseFolderOwaUsers",
+ new SqlParameter("@ItemID", itemId),
+ new SqlParameter("@FolderID", folderId)
+ );
+ }
+
+ public static IDataReader GetEnterpriseFolderId(int itemId, string folderName)
+ {
+ return SqlHelper.ExecuteReader(
+ ConnectionString,
+ CommandType.StoredProcedure,
+ "GetEnterpriseFolderId",
+ new SqlParameter("@ItemID", itemId),
+ new SqlParameter("@FolderName", folderName)
+ );
+ }
+
+ public static IDataReader GetUserEnterpriseFolderWithOwaEditPermission(int itemId, int accountId)
+ {
+ return SqlHelper.ExecuteReader(
+ ConnectionString,
+ CommandType.StoredProcedure,
+ "GetUserEnterpriseFolderWithOwaEditPermission",
+ new SqlParameter("@ItemID", itemId),
+ new SqlParameter("@AccountID", accountId)
+ );
+ }
+
#endregion
#region Support Service Levels
diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/DnsServers/DnsServerController.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/DnsServers/DnsServerController.cs
index d659f9aa..bab622ac 100644
--- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/DnsServers/DnsServerController.cs
+++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/DnsServers/DnsServerController.cs
@@ -32,6 +32,7 @@ using System.Collections.Specialized;
using System.Globalization;
using System.Linq;
using System.Xml;
+using System.Text;
using System.Xml.Serialization;
using WebsitePanel.Providers;
using WebsitePanel.Providers.DNS;
@@ -385,7 +386,9 @@ namespace WebsitePanel.EnterpriseServer
var idn = new IdnMapping();
if (itemType == typeof(DnsZone))
- items.AddRange(dns.GetZones().Select(z => idn.GetUnicode(z)));
+ items.AddRange(dns.GetZones().Select(z =>
+ Encoding.UTF8.GetByteCount(z) == z.Length ? // IsASCII
+ idn.GetUnicode(z) : z ));
return items;
}
diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/EnterpriseStorage/EnterpriseStorageController.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/EnterpriseStorage/EnterpriseStorageController.cs
index d7fbc832..6402a7b0 100644
--- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/EnterpriseStorage/EnterpriseStorageController.cs
+++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/EnterpriseStorage/EnterpriseStorageController.cs
@@ -152,6 +152,16 @@ namespace WebsitePanel.EnterpriseServer
StartESBackgroundTaskInternal("SET_ENTERPRISE_FOLDER_SETTINGS", itemId, folder, permissions, directoyBrowsingEnabled, quota, quotaType);
}
+ public static void SetESGeneralSettings(int itemId, SystemFile folder, bool directoyBrowsingEnabled, int quota, QuotaType quotaType)
+ {
+ SetESGeneralSettingsInternal("SET_ENTERPRISE_FOLDER_GENERAL_SETTINGS", itemId, folder, directoyBrowsingEnabled, quota, quotaType);
+ }
+
+ public static void SetESFolderPermissionSettings(int itemId, SystemFile folder, ESPermission[] permissions)
+ {
+ SetESFolderPermissionSettingsInternal("SET_ENTERPRISE_FOLDER_GENERAL_SETTINGS", itemId, folder, permissions);
+ }
+
public static int AddWebDavAccessToken(WebDavAccessToken accessToken)
{
return DataProvider.AddWebDavAccessToken(accessToken);
@@ -257,6 +267,69 @@ namespace WebsitePanel.EnterpriseServer
return rootFolders;
}
+ protected static void SetESGeneralSettingsInternal(string taskName, int itemId, SystemFile folder, bool directoyBrowsingEnabled, int quota, QuotaType quotaType)
+ {
+ // load organization
+ var org = OrganizationController.GetOrganization(itemId);
+
+ try
+ {
+ TaskManager.StartTask("ENTERPRISE_STORAGE", taskName, org.PackageId);
+
+ EnterpriseStorageController.SetFRSMQuotaOnFolder(itemId, folder.Name, quota, quotaType);
+ EnterpriseStorageController.SetDirectoryBrowseEnabled(itemId, folder.Url, directoyBrowsingEnabled);
+ }
+ catch (Exception ex)
+ {
+ // log error
+ TaskManager.WriteError(ex, "Error executing enterprise storage background task");
+ }
+ finally
+ {
+ // complete task
+ try
+ {
+ TaskManager.CompleteTask();
+ }
+ catch (Exception)
+ {
+ }
+ }
+ }
+
+ protected static void SetESFolderPermissionSettingsInternal(string taskName, int itemId, SystemFile folder, ESPermission[] permissions)
+ {
+ // load organization
+ var org = OrganizationController.GetOrganization(itemId);
+
+ new Thread(() =>
+ {
+ try
+ {
+ TaskManager.StartTask("ENTERPRISE_STORAGE", taskName, org.PackageId);
+
+ EnterpriseStorageController.SetFolderPermission(itemId, folder.Name, permissions);
+ }
+ catch (Exception ex)
+ {
+ // log error
+ TaskManager.WriteError(ex, "Error executing enterprise storage background task");
+ }
+ finally
+ {
+ // complete task
+ try
+ {
+ TaskManager.CompleteTask();
+ }
+ catch (Exception)
+ {
+ }
+ }
+
+ }).Start();
+ }
+
protected static void StartESBackgroundTaskInternal(string taskName, int itemId, SystemFile folder, ESPermission[] permissions, bool directoyBrowsingEnabled, int quota, QuotaType quotaType)
{
// load organization
@@ -1265,6 +1338,87 @@ namespace WebsitePanel.EnterpriseServer
return null;
}
+ public static OrganizationUser[] GetFolderOwaAccounts(int itemId, string folderName)
+ {
+ try
+ {
+ var folderId = GetFolderId(itemId, folderName);
+
+ var users = ObjectUtils.CreateListFromDataReader(DataProvider.GetEnterpriseFolderOwaUsers(itemId, folderId));
+
+ return users.ToArray();
+ }
+ catch (Exception ex)
+ {
+ throw ex;
+ }
+ }
+
+ public static void SetFolderOwaAccounts(int itemId, string folderName, OrganizationUser[] users)
+ {
+ try
+ {
+ var folderId = GetFolderId(itemId, folderName);
+
+ DataProvider.DeleteAllEnterpriseFolderOwaUsers(itemId, folderId);
+
+ foreach (var user in users)
+ {
+ DataProvider.AddEnterpriseFolderOwaUser(itemId, folderId, user.AccountId);
+ }
+ }
+ catch (Exception ex)
+ {
+ throw ex;
+ }
+ }
+
+ protected static int GetFolderId(int itemId, string folderName)
+ {
+ try
+ {
+ GetFolder(itemId, folderName);
+
+ var dataReader = DataProvider.GetEnterpriseFolderId(itemId, folderName);
+
+ while (dataReader.Read())
+ {
+ return (int)dataReader[0];
+ }
+
+ return -1;
+ }
+ catch (Exception ex)
+ {
+ throw ex;
+ }
+ }
+
+ public static List GetUserEnterpriseFolderWithOwaEditPermission(int itemId, List accountIds)
+ {
+ try
+ {
+ var result = new List();
+
+
+ foreach (var accountId in accountIds)
+ {
+ var reader = DataProvider.GetUserEnterpriseFolderWithOwaEditPermission(itemId, accountId);
+
+ while (reader.Read())
+ {
+ result.Add(Convert.ToString(reader["FolderName"]));
+ }
+ }
+
+ return result.Distinct().ToList();
+ }
+ catch (Exception ex)
+ {
+ throw ex;
+ }
+ }
+
#region WebDav portal
public static string GetWebDavPortalUserSettingsByAccountId(int accountId)
diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Virtualization/VirtualizationServerController.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Virtualization/VirtualizationServerController.cs
index 75ea31ef..fb69ef50 100644
--- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Virtualization/VirtualizationServerController.cs
+++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/Virtualization/VirtualizationServerController.cs
@@ -1074,10 +1074,14 @@ namespace WebsitePanel.EnterpriseServer
}
}
- private static void CheckNumericQuota(PackageContext cntx, List errors, string quotaName, int currentVal, int val, string messageKey)
+ private static void CheckNumericQuota(PackageContext cntx, List errors, string quotaName, long currentVal, long val, string messageKey)
{
CheckQuotaValue(cntx, errors, quotaName, currentVal, val, messageKey);
}
+ private static void CheckNumericQuota(PackageContext cntx, List errors, string quotaName, int currentVal, int val, string messageKey)
+ {
+ CheckQuotaValue(cntx, errors, quotaName, Convert.ToInt64(currentVal), Convert.ToInt64(val), messageKey);
+ }
private static void CheckNumericQuota(PackageContext cntx, List errors, string quotaName, int val, string messageKey)
{
@@ -1094,7 +1098,7 @@ namespace WebsitePanel.EnterpriseServer
CheckQuotaValue(cntx, errors, quotaName, 0, -1, messageKey);
}
- private static void CheckQuotaValue(PackageContext cntx, List errors, string quotaName, int currentVal, int val, string messageKey)
+ private static void CheckQuotaValue(PackageContext cntx, List errors, string quotaName, long currentVal, long val, string messageKey)
{
if (!cntx.Quotas.ContainsKey(quotaName))
return;
@@ -1111,7 +1115,7 @@ namespace WebsitePanel.EnterpriseServer
errors.Add(messageKey);
else if (quota.QuotaTypeId == 2)
{
- int maxValue = quota.QuotaAllocatedValue - quota.QuotaUsedValue + currentVal;
+ long maxValue = quota.QuotaAllocatedValue - quota.QuotaUsedValue + currentVal;
if(val > maxValue)
errors.Add(messageKey + ":" + maxValue);
}
@@ -1795,8 +1799,9 @@ namespace WebsitePanel.EnterpriseServer
else if (state == VirtualMachineRequestedState.Reboot)
{
// shutdown first
- ResultObject shutdownResult = ChangeVirtualMachineState(itemId, VirtualMachineRequestedState.ShutDown);
- if(!shutdownResult.IsSuccess)
+ ResultObject shutdownResult = ChangeVirtualMachineState(itemId,
+ VirtualMachineRequestedState.ShutDown);
+ if (!shutdownResult.IsSuccess)
{
TaskManager.CompleteResultTask(res);
return shutdownResult;
@@ -1817,20 +1822,29 @@ namespace WebsitePanel.EnterpriseServer
JobResult result = vps.ChangeVirtualMachineState(machine.VirtualMachineId, state);
- // check return
- if (result.ReturnValue != ReturnCode.JobStarted)
+ if (result.Job.JobState == ConcreteJobState.Completed)
{
LogReturnValueResult(res, result);
- TaskManager.CompleteResultTask(res);
+ TaskManager.CompleteTask();
return res;
}
-
- // wait for completion
- if (!JobCompleted(vps, result.Job))
+ else
{
- LogJobResult(res, result.Job);
- TaskManager.CompleteResultTask(res);
- return res;
+ // check return
+ if (result.ReturnValue != ReturnCode.JobStarted)
+ {
+ LogReturnValueResult(res, result);
+ TaskManager.CompleteResultTask(res);
+ return res;
+ }
+
+ // wait for completion
+ if (!JobCompleted(vps, result.Job))
+ {
+ LogJobResult(res, result.Job);
+ TaskManager.CompleteResultTask(res);
+ return res;
+ }
}
}
}
diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/esEnterpriseStorage.asmx.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/esEnterpriseStorage.asmx.cs
index 6668b40b..f5ba338b 100644
--- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/esEnterpriseStorage.asmx.cs
+++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/esEnterpriseStorage.asmx.cs
@@ -196,6 +196,36 @@ namespace WebsitePanel.EnterpriseServer
EnterpriseStorageController.StartSetEnterpriseFolderSettingsBackgroundTask(itemId, folder, permissions, directoyBrowsingEnabled, quota, quotaType);
}
+ [WebMethod]
+ public void SetEnterpriseFolderGeneralSettings(int itemId, SystemFile folder, bool directoyBrowsingEnabled, int quota, QuotaType quotaType)
+ {
+ EnterpriseStorageController.SetESGeneralSettings(itemId, folder, directoyBrowsingEnabled, quota, quotaType);
+ }
+
+ [WebMethod]
+ public void SetEnterpriseFolderPermissionSettings(int itemId, SystemFile folder, ESPermission[] permissions)
+ {
+ EnterpriseStorageController.SetESFolderPermissionSettings(itemId, folder, permissions);
+ }
+
+ [WebMethod]
+ public OrganizationUser[] GetFolderOwaAccounts(int itemId, SystemFile folder)
+ {
+ return EnterpriseStorageController.GetFolderOwaAccounts(itemId, folder.Name);
+ }
+
+ [WebMethod]
+ public void SetFolderOwaAccounts(int itemId, SystemFile folder, OrganizationUser[] users)
+ {
+ EnterpriseStorageController.SetFolderOwaAccounts(itemId, folder.Name, users);
+ }
+
+ [WebMethod]
+ public List GetUserEnterpriseFolderWithOwaEditPermission(int itemId, List accountIds)
+ {
+ return EnterpriseStorageController.GetUserEnterpriseFolderWithOwaEditPermission(itemId, accountIds);
+ }
+
#endregion
#region Statistics
diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Base/OS/SystemFile.cs b/WebsitePanel/Sources/WebsitePanel.Providers.Base/OS/SystemFile.cs
index 830bccab..83d68d90 100644
--- a/WebsitePanel/Sources/WebsitePanel.Providers.Base/OS/SystemFile.cs
+++ b/WebsitePanel/Sources/WebsitePanel.Providers.Base/OS/SystemFile.cs
@@ -145,6 +145,7 @@ namespace WebsitePanel.Providers.OS
}
public string RelativeUrl { get; set; }
+ public string Summary { get; set; }
public string DriveLetter
{
diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Base/Virtualization/AutomaticStartAction.cs b/WebsitePanel/Sources/WebsitePanel.Providers.Base/Virtualization/AutomaticStartAction.cs
new file mode 100644
index 00000000..881a8a27
--- /dev/null
+++ b/WebsitePanel/Sources/WebsitePanel.Providers.Base/Virtualization/AutomaticStartAction.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace WebsitePanel.Providers.Virtualization
+{
+ public enum AutomaticStartAction
+ {
+ Undefined = 100,
+ Nothing = 0,
+ StartIfRunning = 1,
+ Start = 2,
+ }
+}
diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Base/Virtualization/AutomaticStopAction.cs b/WebsitePanel/Sources/WebsitePanel.Providers.Base/Virtualization/AutomaticStopAction.cs
new file mode 100644
index 00000000..3386e0d8
--- /dev/null
+++ b/WebsitePanel/Sources/WebsitePanel.Providers.Base/Virtualization/AutomaticStopAction.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace WebsitePanel.Providers.Virtualization
+{
+ public enum AutomaticStopAction
+ {
+ Undefined = 100,
+ TurnOff = 0,
+ Save = 1,
+ ShutDown = 2,
+ }
+}
diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Base/Virtualization/BiosInfo.cs b/WebsitePanel/Sources/WebsitePanel.Providers.Base/Virtualization/BiosInfo.cs
new file mode 100644
index 00000000..796876fc
--- /dev/null
+++ b/WebsitePanel/Sources/WebsitePanel.Providers.Base/Virtualization/BiosInfo.cs
@@ -0,0 +1,41 @@
+// Copyright (c) 2014, 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.
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace WebsitePanel.Providers.Virtualization
+{
+ public class BiosInfo
+ {
+ public bool NumLockEnabled { get; set; }
+ public string[] StartupOrder { get; set; }
+ public bool BootFromCD { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Base/Virtualization/ConcreteJobState.cs b/WebsitePanel/Sources/WebsitePanel.Providers.Base/Virtualization/ConcreteJobState.cs
index 468136e8..b316ef8f 100644
--- a/WebsitePanel/Sources/WebsitePanel.Providers.Base/Virtualization/ConcreteJobState.cs
+++ b/WebsitePanel/Sources/WebsitePanel.Providers.Base/Virtualization/ConcreteJobState.cs
@@ -42,6 +42,9 @@ namespace WebsitePanel.Providers.Virtualization
Completed = 7,
Terminated = 8,
Killed = 9,
- Exception = 10
+ Exception = 10,
+
+ NotStarted = 11,
+ Failed = 12,
}
}
diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Base/Virtualization/ControllerType.cs b/WebsitePanel/Sources/WebsitePanel.Providers.Base/Virtualization/ControllerType.cs
new file mode 100644
index 00000000..afe85d2a
--- /dev/null
+++ b/WebsitePanel/Sources/WebsitePanel.Providers.Base/Virtualization/ControllerType.cs
@@ -0,0 +1,40 @@
+// Copyright (c) 2014, 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.
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace WebsitePanel.Providers.Virtualization
+{
+ public enum ControllerType
+ {
+ IDE = 0,
+ SCSI = 1
+ }
+}
diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Base/Virtualization/DvdDriveInfo.cs b/WebsitePanel/Sources/WebsitePanel.Providers.Base/Virtualization/DvdDriveInfo.cs
new file mode 100644
index 00000000..34a1100d
--- /dev/null
+++ b/WebsitePanel/Sources/WebsitePanel.Providers.Base/Virtualization/DvdDriveInfo.cs
@@ -0,0 +1,44 @@
+// Copyright (c) 2014, 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.
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace WebsitePanel.Providers.Virtualization
+{
+ public class DvdDriveInfo
+ {
+ public ControllerType ControllerType { get; set; }
+ public int ControllerNumber { get; set; }
+ public int ControllerLocation { get; set; }
+ public string Name { get; set; }
+ public string Id { get; set; }
+ public string Path { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Base/Virtualization/MemoryInfo.cs b/WebsitePanel/Sources/WebsitePanel.Providers.Base/Virtualization/MemoryInfo.cs
new file mode 100644
index 00000000..7e79088a
--- /dev/null
+++ b/WebsitePanel/Sources/WebsitePanel.Providers.Base/Virtualization/MemoryInfo.cs
@@ -0,0 +1,44 @@
+// Copyright (c) 2014, 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.
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace WebsitePanel.Providers.Virtualization
+{
+ public class MemoryInfo
+ {
+ public bool DynamicMemoryEnabled { get; set; }
+ public Int64 Startup { get; set; }
+ public Int64 Minimum { get; set; }
+ public Int64 Maximum { get; set; }
+ public int Buffer { get; set; }
+ public int Priority { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Base/Virtualization/OperationalStatus.cs b/WebsitePanel/Sources/WebsitePanel.Providers.Base/Virtualization/OperationalStatus.cs
index 808ff0dc..c10ebc26 100644
--- a/WebsitePanel/Sources/WebsitePanel.Providers.Base/Virtualization/OperationalStatus.cs
+++ b/WebsitePanel/Sources/WebsitePanel.Providers.Base/Virtualization/OperationalStatus.cs
@@ -35,9 +35,10 @@ namespace WebsitePanel.Providers.Virtualization
public enum OperationalStatus
{
None = 0,
- OK = 2,
+ Ok = 2,
Error = 6,
NoContact = 12,
- LostCommunication = 13
+ LostCommunication = 13,
+ Paused = 15
}
}
diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Base/Virtualization/VirtualHardDiskFormat.cs b/WebsitePanel/Sources/WebsitePanel.Providers.Base/Virtualization/VirtualHardDiskFormat.cs
new file mode 100644
index 00000000..6d6a9fb0
--- /dev/null
+++ b/WebsitePanel/Sources/WebsitePanel.Providers.Base/Virtualization/VirtualHardDiskFormat.cs
@@ -0,0 +1,40 @@
+// Copyright (c) 2014, 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.
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace WebsitePanel.Providers.Virtualization
+{
+ public enum VirtualHardDiskFormat
+ {
+ VHD = 0,
+ VHDX = 1
+ }
+}
diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Base/Virtualization/VirtualHardDiskInfo.cs b/WebsitePanel/Sources/WebsitePanel.Providers.Base/Virtualization/VirtualHardDiskInfo.cs
index 75bd6f74..e327767f 100644
--- a/WebsitePanel/Sources/WebsitePanel.Providers.Base/Virtualization/VirtualHardDiskInfo.cs
+++ b/WebsitePanel/Sources/WebsitePanel.Providers.Base/Virtualization/VirtualHardDiskInfo.cs
@@ -40,5 +40,15 @@ namespace WebsitePanel.Providers.Virtualization
public long MaxInternalSize { get; set; }
public string ParentPath { get; set; }
public VirtualHardDiskType DiskType { get; set; }
+ public bool SupportPersistentReservations { get; set; }
+ public ulong MaximumIOPS { get; set; }
+ public ulong MinimumIOPS { get; set; }
+ public ControllerType VHDControllerType { get; set; }
+ public int ControllerNumber { get; set; }
+ public int ControllerLocation { get; set; }
+ public string Name { get; set; }
+ public string Path { get; set; }
+ public VirtualHardDiskFormat DiskFormat { get; set; }
+ public bool Attached { get; set; }
}
}
diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Base/Virtualization/VirtualMachine.cs b/WebsitePanel/Sources/WebsitePanel.Providers.Base/Virtualization/VirtualMachine.cs
index 22732d61..11da6676 100644
--- a/WebsitePanel/Sources/WebsitePanel.Providers.Base/Virtualization/VirtualMachine.cs
+++ b/WebsitePanel/Sources/WebsitePanel.Providers.Base/Virtualization/VirtualMachine.cs
@@ -69,8 +69,8 @@ namespace WebsitePanel.Providers.Virtualization
public int CpuUsage { get; set; }
[Persistent]
- public int RamSize { get; set; }
- public int RamUsage { get; set; }
+ public long RamSize { get; set; }
+ public long RamUsage { get; set; }
[Persistent]
public int HddSize { get; set; }
public LogicalDisk[] HddLogicalDisks { get; set; }
@@ -123,5 +123,24 @@ namespace WebsitePanel.Providers.Virtualization
// for GetVirtualMachineEx used in import method
public VirtualMachineNetworkAdapter[] Adapters { get; set; }
+
+ [Persistent]
+ public VirtualHardDiskInfo[] Disks { get; set; }
+
+ [Persistent]
+ public string Status { get; set; }
+
+ [Persistent]
+ public string ReplicationState { get; set; }
+
+ [Persistent]
+ public int Generation { get; set; }
+
+ [Persistent]
+ public int ProcessorCount { get; set; }
+
+ [Persistent]
+ public string ParentSnapshotId { get; set; }
+
}
}
diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Base/Virtualization/VirtualMachineNetworkAdapter.cs b/WebsitePanel/Sources/WebsitePanel.Providers.Base/Virtualization/VirtualMachineNetworkAdapter.cs
index fe2646d3..d1209d10 100644
--- a/WebsitePanel/Sources/WebsitePanel.Providers.Base/Virtualization/VirtualMachineNetworkAdapter.cs
+++ b/WebsitePanel/Sources/WebsitePanel.Providers.Base/Virtualization/VirtualMachineNetworkAdapter.cs
@@ -36,5 +36,6 @@ namespace WebsitePanel.Providers.Virtualization
{
public string Name { get; set; }
public string MacAddress { get; set; }
+ public string SwitchName { get; set; }
}
}
diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Base/Virtualization/VirtualMachineSnapshot.cs b/WebsitePanel/Sources/WebsitePanel.Providers.Base/Virtualization/VirtualMachineSnapshot.cs
index f8f496ce..a20ae5f0 100644
--- a/WebsitePanel/Sources/WebsitePanel.Providers.Base/Virtualization/VirtualMachineSnapshot.cs
+++ b/WebsitePanel/Sources/WebsitePanel.Providers.Base/Virtualization/VirtualMachineSnapshot.cs
@@ -37,6 +37,7 @@ namespace WebsitePanel.Providers.Virtualization
public string Id { get; set; }
public string CheckPointId { get; set; }
public string Name { get; set; }
+ public string VMName { get; set; }
public string ParentId { get; set; }
public DateTime Created { get; set; }
public bool IsCurrent { get; set; }
diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Base/Virtualization/VirtualMachineState.cs b/WebsitePanel/Sources/WebsitePanel.Providers.Base/Virtualization/VirtualMachineState.cs
index 86ba3354..c33396f7 100644
--- a/WebsitePanel/Sources/WebsitePanel.Providers.Base/Virtualization/VirtualMachineState.cs
+++ b/WebsitePanel/Sources/WebsitePanel.Providers.Base/Virtualization/VirtualMachineState.cs
@@ -34,8 +34,9 @@ namespace WebsitePanel.Providers.Virtualization
{
public enum VirtualMachineState
{
+ /*
Unknown = 0,
- Started = 2, // start
+ Running = 2, // start
Off = 3, // turn off
Reset = 10, // reset
Paused = 32768, // pause
@@ -47,5 +48,36 @@ namespace WebsitePanel.Providers.Virtualization
Stopping = 32774,
Deleted = 32775,
Pausing = 32776
+ */
+ Snapshotting = 32771,
+ Migrating = 32772,
+ Deleted = 32775,
+
+ Unknown = 0,
+ Other = 1,
+ Running = 2,
+ Off = 3,
+ Stopping = 32774, // new 4
+ Saved = 32769, // new 6
+ Paused = 32768, // new 9
+ Starting = 32770, // new 10
+ Reset = 10, // new 11
+ Saving = 32773, // new 32773
+ Pausing = 32776, // new 32776
+ Resuming = 32777,
+ FastSaved = 32779,
+ FastSaving = 32780,
+ RunningCritical = 32781,
+ OffCritical = 32782,
+ StoppingCritical = 32783,
+ SavedCritical = 32784,
+ PausedCritical = 32785,
+ StartingCritical = 32786,
+ ResetCritical = 32787,
+ SavingCritical = 32788,
+ PausingCritical = 32789,
+ ResumingCritical = 32790,
+ FastSavedCritical = 32791,
+ FastSavingCritical = 32792
}
}
diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Base/Virtualization/VirtualSwitch.cs b/WebsitePanel/Sources/WebsitePanel.Providers.Base/Virtualization/VirtualSwitch.cs
index 63bf3479..44c6906e 100644
--- a/WebsitePanel/Sources/WebsitePanel.Providers.Base/Virtualization/VirtualSwitch.cs
+++ b/WebsitePanel/Sources/WebsitePanel.Providers.Base/Virtualization/VirtualSwitch.cs
@@ -37,5 +37,6 @@ namespace WebsitePanel.Providers.Virtualization
{
[Persistent]
public string SwitchId { get; set; }
+ public string SwitchType { get; set; }
}
}
diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Base/WebsitePanel.Providers.Base.csproj b/WebsitePanel/Sources/WebsitePanel.Providers.Base/WebsitePanel.Providers.Base.csproj
index c0f01014..d0bf17c3 100644
--- a/WebsitePanel/Sources/WebsitePanel.Providers.Base/WebsitePanel.Providers.Base.csproj
+++ b/WebsitePanel/Sources/WebsitePanel.Providers.Base/WebsitePanel.Providers.Base.csproj
@@ -288,6 +288,9 @@
+
+
+
Code
@@ -298,6 +301,7 @@
Code
+
Code
@@ -308,6 +312,8 @@
+
+
@@ -322,6 +328,7 @@
Code
+
diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.EnterpriseStorage.Windows2012/Windows2012.cs b/WebsitePanel/Sources/WebsitePanel.Providers.EnterpriseStorage.Windows2012/Windows2012.cs
index e5ff425c..f0a8caf3 100644
--- a/WebsitePanel/Sources/WebsitePanel.Providers.EnterpriseStorage.Windows2012/Windows2012.cs
+++ b/WebsitePanel/Sources/WebsitePanel.Providers.EnterpriseStorage.Windows2012/Windows2012.cs
@@ -304,7 +304,7 @@ namespace WebsitePanel.Providers.EnterpriseStorage
var rootFolder = Path.Combine(settings.LocationDrive + ":\\", settings.HomeFolder);
rootFolder = Path.Combine(rootFolder, organizationId);
- var wsSql = string.Format(@"SELECT System.FileName, System.DateModified, System.Size, System.Kind, System.ItemPathDisplay, System.ItemType FROM SYSTEMINDEX WHERE System.FileName LIKE '%{0}%' AND ({1})",
+ var wsSql = string.Format(@"SELECT System.FileName, System.DateModified, System.Size, System.Kind, System.ItemPathDisplay, System.ItemType, System.Search.AutoSummary FROM SYSTEMINDEX WHERE System.FileName LIKE '%{0}%' AND ({1})",
searchText, string.Join(" OR ", searchPaths.Select(x => string.Format("{0} = '{1}'", recursive ? "SCOPE" : "DIRECTORY", Path.Combine(rootFolder, x))).ToArray()));
conn.Open();
@@ -318,7 +318,7 @@ namespace WebsitePanel.Providers.EnterpriseStorage
var file = new SystemFile {Name = reader[0] as string};
file.Changed = file.CreatedDate = reader[1] is DateTime ? (DateTime)reader[1] : new DateTime();
- file.Size = reader[2] is long ? (long) reader[2] : 0;
+ file.Size = reader[2] is Decimal ? Convert.ToInt64((Decimal) reader[2]) : 0;
var kind = reader[3] is IEnumerable ? ((IEnumerable)reader[3]).Cast().ToList() : null;
var itemType = reader[5] as string ?? string.Empty;
@@ -342,6 +342,8 @@ namespace WebsitePanel.Providers.EnterpriseStorage
}
}
+ file.Summary = SanitizeXmlString(reader[6] as string);
+
result.Add(file);
}
}
@@ -352,6 +354,36 @@ namespace WebsitePanel.Providers.EnterpriseStorage
}
+ public string SanitizeXmlString(string xml)
+ {
+ if (xml == null)
+ {
+ return null;
+ }
+
+ var buffer = new StringBuilder(xml.Length);
+
+ foreach (char c in xml.Where(c => IsLegalXmlChar(c)))
+ {
+ buffer.Append(c);
+ }
+
+ return buffer.ToString();
+ }
+
+ public bool IsLegalXmlChar(int character)
+ {
+ return
+ (
+ character == 0x9 /* == '\t' == 9 */ ||
+ character == 0xA /* == '\n' == 10 */ ||
+ character == 0xD /* == '\r' == 13 */ ||
+ (character >= 0x20 && character <= 0xD7FF) ||
+ (character >= 0xE000 && character <= 0xFFFD) ||
+ (character >= 0x10000 && character <= 0x10FFFF)
+ );
+ }
+
#region HostingServiceProvider methods
public override string[] Install()
diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution.Crm2015/CRMBase.cs b/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution.Crm2015/CRMBase.cs
new file mode 100644
index 00000000..bb48c462
--- /dev/null
+++ b/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution.Crm2015/CRMBase.cs
@@ -0,0 +1,2103 @@
+// Copyright (c) 2015, 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.
+
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Data.SqlClient;
+using System.Globalization;
+using System.IO;
+using System.Net;
+using System.Reflection;
+using System.Net.Security;
+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;
+using WebsitePanel.Server.Utils;
+using WebsitePanel.Providers.HostedSolution;
+using WebsitePanel.Providers;
+using WebsitePanel.Providers.Utils;
+using Microsoft.Xrm.Sdk;
+using Microsoft.Xrm.Sdk.Query;
+using Microsoft.Xrm.Sdk.Discovery;
+using Microsoft.Xrm.Sdk.Client;
+using Microsoft.Xrm.Sdk.Deployment;
+using Microsoft.Xrm.Sdk.Messages;
+
+namespace WebsitePanel.Providers.HostedSolution
+{
+ public class CRMBase : HostingServiceProviderBase, ICRM
+ {
+ #region Properties
+
+ protected virtual string UserName
+ {
+ get { return ProviderSettings[Constants.UserName]; }
+ }
+
+ protected virtual string Password
+ {
+ get { return ProviderSettings[Constants.Password]; }
+ }
+
+ protected virtual string SqlServer
+ {
+ get { return ProviderSettings[Constants.SqlServer]; }
+ }
+
+ protected virtual string ReportingServer
+ {
+ get { return ProviderSettings[Constants.ReportingServer]; }
+ }
+
+ protected virtual string UrlSchema
+ {
+ get { return ProviderSettings[Constants.UrlSchema] == "http" ? "http://" : "https://"; }
+ }
+
+ protected virtual string CRMDeploymentUrl
+ {
+ get
+ {
+ string uri = ProviderSettings[Constants.DeploymentWebService];
+ if (String.IsNullOrEmpty(uri)) uri = ProviderSettings[Constants.AppRootDomain];
+ string cRMServiceUrl = UrlSchema + uri + ":" + ProviderSettings[Constants.Port] + "/XRMDeployment/2011/Deployment.svc";
+ return cRMServiceUrl;
+ }
+ }
+
+ protected virtual string CRMDiscoveryUrl
+ {
+ get
+ {
+ string uri = ProviderSettings[Constants.DiscoveryWebService];
+ if (String.IsNullOrEmpty(uri)) uri = ProviderSettings[Constants.AppRootDomain];
+ string cRMDiscoveryUri = UrlSchema + uri + ":" + ProviderSettings[Constants.Port] + "/XRMServices/2011/Discovery.svc";
+ return cRMDiscoveryUri;
+ }
+ }
+
+ private static string crmPath = null;
+ protected static string CRMPath
+ {
+ get
+ {
+ if (string.IsNullOrEmpty(crmPath))
+ {
+ RegistryKey root = Registry.LocalMachine;
+ RegistryKey rk = root.OpenSubKey("SOFTWARE\\Microsoft\\MSCRM");
+ if (rk != null)
+ {
+ crmPath = (string)rk.GetValue("CRM_Server_InstallDir", string.Empty);
+ }
+ }
+ return crmPath;
+ }
+ }
+
+ protected static string CRMDatabaseName = "MSCRM_CONFIG";
+
+ #endregion
+
+ #region Service
+
+ protected virtual ClientCredentials GetUserLogonCredentials()
+ {
+ ClientCredentials credentials = new ClientCredentials();
+
+ if (String.IsNullOrEmpty(UserName))
+ {
+ credentials.Windows.ClientCredential = System.Net.CredentialCache.DefaultNetworkCredentials;
+ }
+ else
+ {
+ credentials.UserName.UserName = UserName;
+ credentials.UserName.Password = Password;
+ }
+
+ return credentials;
+ }
+
+ protected virtual DeploymentServiceClient GetDeploymentProxy()
+ {
+ Uri serviceUrl = new Uri(CRMDeploymentUrl);
+
+ DeploymentServiceClient deploymentService = Microsoft.Xrm.Sdk.Deployment.Proxy.ProxyClientHelper.CreateClient(serviceUrl);
+ if (!String.IsNullOrEmpty(UserName))
+ deploymentService.ClientCredentials.Windows.ClientCredential = new NetworkCredential(UserName, Password);
+
+ return deploymentService;
+ }
+
+ protected virtual DiscoveryServiceProxy GetDiscoveryProxy()
+ {
+
+ IServiceManagement serviceManagement =
+ ServiceConfigurationFactory.CreateManagement(
+ new Uri(CRMDiscoveryUrl));
+
+ ClientCredentials Credentials = GetUserLogonCredentials();
+
+ DiscoveryServiceProxy r = new DiscoveryServiceProxy(serviceManagement, Credentials);
+
+ return r;
+ }
+
+ private OrganizationDetailCollection DiscoverOrganizations(IDiscoveryService service)
+ {
+ if (service == null) throw new ArgumentNullException("service");
+ RetrieveOrganizationsRequest orgRequest = new RetrieveOrganizationsRequest();
+ RetrieveOrganizationsResponse orgResponse =
+ (RetrieveOrganizationsResponse)service.Execute(orgRequest);
+
+ return orgResponse.Details;
+ }
+
+ public virtual string GetOrganizationUniqueName(string orgName)
+ {
+ return Regex.Replace(orgName, @"[^\dA-Za-z]", "-", RegexOptions.Compiled);
+ }
+
+ protected virtual Uri GetCRMOrganizationUrl(string orgName)
+ {
+ //string url = "https://" + ProviderSettings[Constants.AppRootDomain] + ":" + ProviderSettings[Constants.Port] + "/" + orgName + "/XRMServices/2011/Organization.svc";
+
+ string url;
+
+ orgName = GetOrganizationUniqueName(orgName);
+
+ string organizationWebServiceUri = ProviderSettings[Constants.OrganizationWebService];
+
+ if (String.IsNullOrEmpty(orgName))
+ return null;
+
+ if (!String.IsNullOrEmpty(organizationWebServiceUri))
+ {
+ url = UrlSchema + organizationWebServiceUri + ":" + ProviderSettings[Constants.Port] + "/" + orgName + "/XRMServices/2011/Organization.svc";
+ }
+ else
+ {
+ url = UrlSchema + orgName + "." + ProviderSettings[Constants.IFDWebApplicationRootDomain] + ":" + ProviderSettings[Constants.Port] + "/XRMServices/2011/Organization.svc";
+ }
+
+ try
+ {
+
+ using (DiscoveryServiceProxy serviceProxy = GetDiscoveryProxy())
+ {
+ // Obtain organization information from the Discovery service.
+ if (serviceProxy != null)
+ {
+ // Obtain information about the organizations that the system user belongs to.
+ OrganizationDetailCollection orgs = DiscoverOrganizations(serviceProxy);
+
+ for (int n = 0; n < orgs.Count; n++)
+ {
+ if (orgs[n].UniqueName == orgName)
+ {
+ // Return the organization Uri.
+ return new System.Uri(orgs[n].Endpoints[EndpointType.OrganizationService]);
+ }
+ }
+
+ }
+ }
+ }
+ catch { }
+
+ return new Uri(url);
+ }
+
+ private int getOrganizationProxyTryCount = 10;
+ private int getOrganizationProxyTryTimeout = 30000;
+ protected virtual OrganizationServiceProxy GetOrganizationProxy(string orgName)
+ {
+ return GetOrganizationProxy(orgName, getOrganizationProxyTryCount, getOrganizationProxyTryTimeout);
+ }
+
+ protected virtual OrganizationServiceProxy GetOrganizationProxy(string orgName, int TryCount, int TryTimeout)
+ {
+
+ Uri OrganizationUri = GetCRMOrganizationUrl(orgName);
+
+ OrganizationServiceProxy r = null;
+
+ bool success = false;
+ int tryItem = 0;
+ Exception exception = null;
+
+ while (!success)
+ {
+
+ try
+ {
+ // Set IServiceManagement for the current organization.
+ IServiceManagement orgServiceManagement =
+ ServiceConfigurationFactory.CreateManagement(
+ OrganizationUri);
+
+ r = new OrganizationServiceProxy(
+ orgServiceManagement,
+ GetUserLogonCredentials());
+
+ success = true;
+
+ }
+ catch (Exception exc)
+ {
+ Thread.Sleep(TryTimeout);
+ tryItem++;
+ if (tryItem >= TryCount)
+ {
+ exception = exc;
+ success = true;
+ }
+ }
+
+ }
+
+ if (exception != null)
+ throw new ArgumentException(exception.ToString());
+
+ r.EnableProxyTypes();
+
+ return r;
+ }
+
+ #endregion
+
+ #region Static constructor
+
+ static CRMBase()
+ {
+ AppDomain.CurrentDomain.AssemblyResolve += ResolveCRMAssembly;
+ }
+
+ static Assembly ResolveCRMAssembly(object sender, ResolveEventArgs args)
+ {
+ // Ensure we load DLLs only.
+ if (args.Name.ToLower().Contains("microsoft.crm") || args.Name.ToLower().Contains("antixsslibrary") || args.Name.ToLower().Contains("microsoft.xrm"))
+ {
+ string dllName = args.Name.Split(',')[0] + ".dll";
+
+ List paths = new List();
+
+ // assembly location
+ paths.Add( Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().EscapedCodeBase).LocalPath) );
+ // crm tools path
+ paths.Add(CRMPath);
+
+ foreach(string path in paths)
+ {
+ string filename = Path.Combine(path, dllName);
+ if (File.Exists(filename))
+ return Assembly.LoadFrom(filename);
+ }
+ }
+
+ return default(Assembly);
+ }
+
+ #endregion
+
+ #region Check environment
+
+ protected virtual bool CheckCRMWebServicesAccess()
+ {
+ Log.WriteStart("CheckCRMWebServicesAccess");
+ bool ret = false;
+ HttpWebResponse response = null;
+ HttpWebRequest request;
+
+ try
+ {
+ WindowsIdentity.GetCurrent();
+
+ request = WebRequest.Create(CRMDeploymentUrl) as HttpWebRequest;
+
+ if (request != null)
+ {
+ request.UseDefaultCredentials = true;
+ request.Credentials = CredentialCache.DefaultCredentials;
+ response = request.GetResponse() as HttpWebResponse;
+
+ }
+ if (response != null)
+ ret = (response.StatusCode == HttpStatusCode.OK);
+ }
+ catch (Exception ex)
+ {
+ Log.WriteError(ex);
+ ret = false;
+ }
+
+ Log.WriteEnd("CheckCRMWebServicesAccess");
+ return ret;
+ }
+
+ protected virtual bool CheckPermissions()
+ {
+ Log.WriteStart("CheckPermissions");
+ bool res = false;
+ try
+ {
+ string group = "PrivUserGroup";
+ string user = WindowsIdentity.GetCurrent().Name.Split(new char[] { '\\' })[1];
+ res = ActiveDirectoryUtils.IsUserInGroup(user, group);
+ }
+ catch (Exception ex)
+ {
+ Log.WriteError(ex);
+ res = false;
+ }
+
+ Log.WriteEnd("CheckPermissions");
+ return res;
+ }
+
+ protected virtual bool CheckOrganizationUnique(string databaseName, string orgName)
+ {
+ Log.WriteStart("CheckOrganizationUnique");
+ bool res = false;
+
+ SqlConnection connection = null;
+ try
+ {
+ connection = new SqlConnection();
+ connection.ConnectionString =
+ string.Format("Server={1};Initial Catalog={0};Integrated Security=SSPI",
+ databaseName, SqlServer);
+
+ connection.Open();
+
+ string commandText = string.Format("SELECT COUNT(*) FROM dbo.Organization WHERE UniqueName = '{0}'", orgName);
+ SqlCommand command = new SqlCommand(commandText, connection);
+ int count = (int)command.ExecuteScalar();
+ res = count == 0;
+
+
+ }
+ catch (Exception ex)
+ {
+ res = false;
+ Log.WriteError(ex);
+ }
+ finally
+ {
+ if (connection != null)
+ connection.Close();
+
+ }
+
+ Log.WriteEnd("CheckOrganizationUnique");
+ return res;
+ }
+
+ protected virtual bool CheckSqlServerConnection()
+ {
+ Log.WriteStart("CheckSqlServerConnection");
+ bool res = false;
+ SqlConnection connection = null;
+ try
+ {
+ connection = new SqlConnection();
+ connection.ConnectionString =
+ string.Format("server={0}; Integrated Security=SSPI",
+ SqlServer);
+
+ connection.Open();
+ res = true;
+ }
+ catch (Exception ex)
+ {
+ Log.WriteError(ex);
+ res = false;
+ }
+ finally
+ {
+ if (connection != null)
+ connection.Close();
+ }
+
+ Log.WriteEnd("CheckSqlServerConnection");
+
+ return res;
+ }
+
+ protected virtual bool CheckReportServerConnection()
+ {
+ Log.WriteStart("CheckReportServerConnection");
+ bool ret = false;
+ HttpWebResponse response = null;
+ HttpWebRequest request;
+
+ try
+ {
+ WindowsIdentity.GetCurrent();
+
+ request = WebRequest.Create(ReportingServer) as HttpWebRequest;
+
+ if (request != null)
+ {
+ request.UseDefaultCredentials = true;
+ request.Credentials = CredentialCache.DefaultCredentials;
+ response = request.GetResponse() as HttpWebResponse;
+
+ }
+ if (response != null)
+ ret = (response.StatusCode == HttpStatusCode.OK);
+ }
+ catch (Exception ex)
+ {
+ Log.WriteError(ex);
+ ret = false;
+ }
+
+ Log.WriteEnd("CheckReportServerConnection");
+ return ret;
+ }
+
+ protected virtual OrganizationResult CheckCrmEnvironment(string strDataBaseName, string organizationUniqueName)
+ {
+ OrganizationResult retOrganization = StartLog("CheckCrmEnvironment");
+ bool res = CheckSqlServerConnection();
+
+ if (!res)
+ {
+ EndLog("CheckCrmEnvironment", retOrganization, CrmErrorCodes.CRM_SQL_SERVER_ERROR);
+ return retOrganization;
+ }
+
+ res = CheckOrganizationUnique(strDataBaseName, organizationUniqueName);
+ if (!res)
+ {
+ EndLog("CheckCrmEnvironment", retOrganization, CrmErrorCodes.CRM_ORGANIZATION_ALREADY_EXISTS);
+ return retOrganization;
+ }
+
+ res = CheckReportServerConnection();
+ if (!res)
+ {
+ EndLog("CheckCrmEnvironment", retOrganization, CrmErrorCodes.CRM_REPORT_SERVER_ERROR);
+ return retOrganization;
+ }
+
+ res = CheckPermissions();
+ if (!res)
+ {
+ EndLog("CheckCrmEnvironment", retOrganization, CrmErrorCodes.CRM_PERMISSIONS_ERROR);
+ return retOrganization;
+ }
+
+ res = CheckCRMWebServicesAccess();
+ if (!res)
+ {
+ EndLog("CheckCrmEnvironment", retOrganization, CrmErrorCodes.CRM_WEB_SERVICE_ERROR);
+ return retOrganization;
+ }
+
+ EndLog("CheckCrmEnvironment");
+ return retOrganization;
+ }
+
+ #endregion
+
+ #region DataBase
+
+ protected virtual string GetDataBaseName(Guid organizationId)
+ {
+ string databasename = null;
+
+ 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);
+ object result = command.ExecuteScalar();
+ if (result!=null)
+ databasename = String.Concat(result.ToString());
+
+ }
+ catch (Exception ex)
+ {
+ Log.WriteError(ex);
+ }
+ finally
+ {
+ if (connection != null)
+ connection.Close();
+ }
+
+ return databasename;
+ }
+
+ public virtual long GetDBSize(Guid organizationId)
+ {
+ StartLog("GetDBSize");
+ long res = 0;
+
+ string databasename = GetDataBaseName(organizationId);
+ if (databasename == null) return 0;
+
+ if (databasename == null) return 0;
+
+ SqlConnection connection = null;
+ try
+ {
+ connection = new SqlConnection();
+ connection.ConnectionString =
+ string.Format("Server={1};Initial Catalog={0};Integrated Security=SSPI",
+ databasename, SqlServer);
+
+ connection.Open();
+
+ string commandText = "SELECT ((dbsize ) * 8192 ) size FROM " + // + logsize
+ "( " +
+ "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)
+ {
+ EndLog("GetDBSize", null, null, ex);
+ }
+ finally
+ {
+ if (connection != null)
+ connection.Close();
+
+ }
+
+ EndLog("GetDBSize");
+ return res;
+
+ }
+
+ public virtual long GetMaxDBSize(Guid organizationId)
+ {
+ StartLog("GetMaxDBSize");
+ long res = 0;
+
+ string databasename = GetDataBaseName(organizationId);
+ if (databasename == null) return 0;
+
+ SqlConnection connection = null;
+ try
+ {
+ connection = new SqlConnection();
+ connection.ConnectionString =
+ string.Format("Server={1};Initial Catalog={0};Integrated Security=SSPI",
+ databasename, SqlServer);
+
+ connection.Open();
+
+ string commandText = "SELECT SUM(CONVERT(BIGINT,CASE WHEN status & 64 = 0 THEN maxsize ELSE 0 END)) dbsize FROM dbo.sysfiles";
+
+ SqlCommand command = new SqlCommand(commandText, connection);
+ res = (long)command.ExecuteScalar();
+ if (res > 0) res = res * 8192;
+
+ }
+ catch (Exception ex)
+ {
+ EndLog("GetMaxDBSize", null, null, ex);
+ }
+ finally
+ {
+ if (connection != null)
+ connection.Close();
+
+ }
+
+ EndLog("GetMaxDBSize");
+ return res;
+ }
+
+ public virtual ResultObject SetMaxDBSize(Guid organizationId, long maxSize)
+ {
+ ResultObject res = StartLog("SetMaxDBSize");
+
+ SqlConnection connection = null;
+ try
+ {
+ string databasename = GetDataBaseName(organizationId);
+ if (databasename == null) throw new Exception("Can not get database name");
+
+ connection = new SqlConnection();
+ connection.ConnectionString =
+ string.Format("Server={1};Initial Catalog={0};Integrated Security=SSPI",
+ databasename, SqlServer);
+
+ connection.Open();
+
+ string maxSizeStr = maxSize == -1 ? "UNLIMITED" : (maxSize / (1024 * 1024)).ToString() + " MB";
+
+ string commandText = "ALTER DATABASE [" + databasename + "] MODIFY FILE ( NAME = N'mscrm', MAXSIZE = " + maxSizeStr + " )";
+
+ SqlCommand command = new SqlCommand(commandText, connection);
+ command.ExecuteNonQuery();
+
+ res.IsSuccess = true;
+
+ }
+ catch (Exception ex)
+ {
+ EndLog("SetMaxDBSize", res, CrmErrorCodes.CANNOT_CHANGE_CRM_ORGANIZATION_STATE, ex);
+ }
+ finally
+ {
+ if (connection != null)
+ connection.Close();
+
+ }
+
+ EndLog("SetMaxDBSize");
+ return res;
+ }
+
+ #endregion
+
+ #region Organization
+
+ public virtual OrganizationResult CreateOrganization(Guid organizationId, string organizationUniqueName, string organizationFriendlyName,
+ int baseLanguageCode,
+ string ou,
+ string baseCurrencyCode, string baseCurrencyName, string baseCurrencySymbol,
+ string initialUserDomainName, string initialUserFirstName, string initialUserLastName, string initialUserPrimaryEmail,
+ string organizationCollation,
+ long maxSize)
+ {
+ return CreateOrganizationInternal(organizationId, organizationUniqueName, organizationFriendlyName,
+ baseLanguageCode,
+ ou , baseCurrencyCode, baseCurrencyName, baseCurrencySymbol,
+ initialUserDomainName, initialUserFirstName, initialUserLastName, initialUserPrimaryEmail,
+ organizationCollation,
+ maxSize);
+ }
+
+ protected const string CRMSysAdminRoleStr = "Системный администратор;System Administrator";
+
+ internal virtual OrganizationResult CreateOrganizationInternal(Guid organizationId, string organizationUniqueName, string organizationFriendlyName,
+ int baseLanguageCode,
+ string ou,
+ string baseCurrencyCode, string baseCurrencyName, string baseCurrencySymbol,
+ string initialUserDomainName, string initialUserFirstName, string initialUserLastName, string initialUserPrimaryEmail,
+ string organizationCollation,
+ long maxSize)
+ {
+
+ OrganizationResult ret = StartLog("CreateOrganizationInternal");
+
+ organizationUniqueName = GetOrganizationUniqueName(organizationUniqueName);
+
+ // 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");
+
+ if (string.IsNullOrEmpty(organizationFriendlyName))
+ throw new ArgumentNullException("organizationFriendlyName");
+
+ if (string.IsNullOrEmpty(baseCurrencyCode))
+ throw new ArgumentNullException("baseCurrencyCode");
+
+ if (string.IsNullOrEmpty(baseCurrencySymbol))
+ throw new ArgumentNullException("baseCurrencySymbol");
+
+ if (string.IsNullOrEmpty(initialUserDomainName))
+ throw new ArgumentNullException("initialUserDomainName");
+
+ OrganizationResult retCheckEn = CheckCrmEnvironment(CRMDatabaseName, organizationUniqueName);
+
+ if (!retCheckEn.IsSuccess)
+ {
+ ret.ErrorCodes.AddRange(retCheckEn.ErrorCodes);
+ EndLog("CreateOrganizationInternal", ret, null, null);
+ return ret;
+ }
+
+ try
+ {
+
+ DeploymentServiceClient deploymentService = GetDeploymentProxy();
+
+ Microsoft.Xrm.Sdk.Deployment.Organization org = new Microsoft.Xrm.Sdk.Deployment.Organization
+ {
+ Id = organizationId,
+ UniqueName = organizationUniqueName,
+ FriendlyName = organizationFriendlyName,
+ SqlServerName = SqlServer,
+ SrsUrl = ReportingServer,
+ BaseCurrencyCode = baseCurrencyCode,
+ BaseCurrencyName = baseCurrencyName,
+ BaseCurrencySymbol = baseCurrencySymbol,
+ SqlCollation = organizationCollation,
+ State = Microsoft.Xrm.Sdk.Deployment.OrganizationState.Enabled
+ };
+
+ if (baseLanguageCode > 0)
+ org.BaseLanguageCode = baseLanguageCode;
+
+ BeginCreateOrganizationRequest req = new BeginCreateOrganizationRequest
+ {
+ Organization = org
+ };
+
+ if (!String.IsNullOrEmpty(UserName))
+ {
+ req.SysAdminName = UserName;
+ }
+
+ BeginCreateOrganizationResponse resp = deploymentService.Execute(req) as BeginCreateOrganizationResponse;
+
+ if (resp == null)
+ throw new ArgumentException("BeginCreateOrganizationResponse is Null");
+
+ EntityInstanceId id = new EntityInstanceId();
+ id.Name = org.UniqueName;
+
+ Microsoft.Xrm.Sdk.Deployment.OrganizationState OperationState = Microsoft.Xrm.Sdk.Deployment.OrganizationState.Pending;
+
+ int timeout = 30000;
+
+ do
+ {
+ Thread.Sleep(timeout);
+ try
+ {
+ Microsoft.Xrm.Sdk.Deployment.Organization getorg
+ = (Microsoft.Xrm.Sdk.Deployment.Organization)deploymentService.Retrieve(DeploymentEntityType.Organization, id);
+ OperationState = getorg.State;
+ }
+ catch { }
+ } while ((OperationState != Microsoft.Xrm.Sdk.Deployment.OrganizationState.Enabled) &&
+ (OperationState != Microsoft.Xrm.Sdk.Deployment.OrganizationState.Failed));
+
+ if (OperationState == Microsoft.Xrm.Sdk.Deployment.OrganizationState.Failed)
+ throw new ArgumentException("Create organization failed.");
+
+ // update UserRootPath setting
+ Microsoft.Xrm.Sdk.Deployment.ConfigurationEntity orgSettings = new Microsoft.Xrm.Sdk.Deployment.ConfigurationEntity
+ {
+ 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);
+
+ // DB size limit
+ if (maxSize!=-1)
+ SetMaxDBSize(organizationId, maxSize);
+
+ int tryTimeout = 30000;
+ int tryCount = 10;
+
+ 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, 0);
+
+ success = true;
+
+ }
+ catch
+ {
+ tryItem++;
+ if (tryItem >= tryCount)
+ success = true;
+ }
+ }
+
+
+ }
+ catch (Exception ex)
+ {
+ EndLog("CheckCrmEnvironment", ret, CrmErrorCodes.CREATE_CRM_ORGANIZATION_GENERAL_ERROR, ex);
+ return ret;
+
+ }
+
+ EndLog("CheckCrmEnvironment");
+
+ return ret;
+ }
+
+ protected string GetDomainName(string username)
+ {
+ string domain = ActiveDirectoryUtils.GetNETBIOSDomainName(ServerSettings.ADRootDomain);
+ string ret = string.Format(@"{0}\{1}", domain, username);
+ return ret;
+ }
+
+ public virtual string[] GetSupportedCollationNames()
+ {
+ return GetSupportedCollationNamesInternal(SqlServer);
+ }
+
+ internal virtual string[] GetSupportedCollationNamesInternal(string SqlServer)
+ {
+ StartLog("GetSupportedCollationNamesInternal");
+
+ List ret = new List();
+
+ 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 = "select * from fn_helpcollations() where " +
+ "(name not like '%_WS') AND (name not like '%_KS') AND (name not like '%_100_%') " +
+ " AND (name not like 'SQL_%') " +
+ " order by name";
+ SqlCommand command = new SqlCommand(commandText, connection);
+ SqlDataReader reader = command.ExecuteReader();
+
+ while (reader.Read())
+ {
+ string name = reader["name"] as string;
+ ret.Add(name);
+ }
+
+ }
+ catch (Exception ex)
+ {
+ Log.WriteError(ex);
+ }
+ finally
+ {
+ if (connection != null)
+ connection.Close();
+
+ }
+
+ EndLog("GetSupportedCollationNamesInternal");
+ return ret.ToArray();
+ }
+
+ public virtual Currency[] GetCurrencyList()
+ {
+ return GetCurrencyListInternal();
+ }
+
+ internal virtual Currency[] GetCurrencyListInternal()
+ {
+ StartLog("GetCurrencyListInternal");
+ List retList = new List();
+
+ CultureInfo[] cultures = CultureInfo.GetCultures(CultureTypes.AllCultures & ~CultureTypes.NeutralCultures);
+
+ foreach (CultureInfo culture in cultures)
+ {
+ if (culture.IsNeutralCulture) continue;
+
+ try
+ {
+ RegionInfo Region = new RegionInfo(culture.LCID);
+
+ Currency currency = new Currency();
+ currency.RegionName = Region.NativeName;
+ currency.CurrencyName = Region.CurrencyNativeName;
+ currency.CurrencyCode = Region.ISOCurrencySymbol;
+ currency.CurrencySymbol = Region.CurrencySymbol;
+ retList.Add(currency);
+
+ }
+ catch
+ {
+ continue;
+ }
+ }
+
+ retList.Sort(delegate(Currency a, Currency b) { return a.RegionName.CompareTo(b.RegionName); });
+
+ EndLog("GetCurrencyListInternal");
+ return retList.ToArray();
+ }
+
+ public virtual int[] GetInstalledLanguagePacks()
+ {
+ return GetInstalledLanguagePacksInternal();
+ }
+
+ internal virtual int[] GetInstalledLanguagePacksInternal()
+ {
+ StartLog("GetInstalledLanguagePacks");
+ List res = new List();
+
+ try
+ {
+ RegistryKey root = Registry.LocalMachine;
+ RegistryKey rk = root.OpenSubKey("SOFTWARE\\Microsoft\\MSCRM");
+
+ if (rk == null)
+ rk = root.OpenSubKey("SOFTWARE\\Wow6432Node\\Microsoft\\MSCRM");
+
+ if (rk == null) throw new Exception("Can't open SOFTWARE\\Microsoft\\MSCRM");
+
+ RegistryKey langPacksKey = rk.OpenSubKey("LangPacks");
+ if (langPacksKey == null) throw new Exception("Can't open SOFTWARE\\Microsoft\\MSCRM\\LangPacks");
+
+ string[] langPacksId = langPacksKey.GetSubKeyNames();
+
+ foreach (string strLangId in langPacksId)
+ {
+ int langId = 0;
+ if (int.TryParse(strLangId, out langId))
+ res.Add(langId);
+ }
+
+ }
+ catch (Exception ex)
+ {
+ EndLog("GetInstalledLanguagePacks", null, null, ex);
+ return null;
+ }
+
+ EndLog("GetInstalledLanguagePacks");
+ return res.ToArray();
+ }
+
+ public virtual ResultObject DeleteOrganization(Guid orgId)
+ {
+ return DeleteOrganizationInternal(orgId);
+ }
+
+ internal virtual ResultObject DeleteOrganizationInternal(Guid orgId)
+ {
+ ResultObject res = StartLog("DeleteOrganizationInternal");
+
+
+ res.IsSuccess = true;
+ try
+ {
+ DeploymentServiceClient deploymentService = GetDeploymentProxy();
+
+ EntityInstanceId i = new EntityInstanceId();
+ i.Id = orgId; //Organisation Id
+
+ Microsoft.Xrm.Sdk.Deployment.Organization org = (Microsoft.Xrm.Sdk.Deployment.Organization)deploymentService.Retrieve(DeploymentEntityType.Organization, i);
+
+ org.State = Microsoft.Xrm.Sdk.Deployment.OrganizationState.Disabled;
+
+ Microsoft.Xrm.Sdk.Deployment.UpdateRequest updateRequest = new Microsoft.Xrm.Sdk.Deployment.UpdateRequest();
+ updateRequest.Entity = org;
+
+ deploymentService.Execute(updateRequest);
+
+ }
+ catch (Exception ex)
+ {
+ EndLog("DeleteOrganizationInternal", res, CrmErrorCodes.DELETE_CRM_ORGANIZATION_GENERAL_ERROR, ex);
+ return res;
+
+ }
+
+
+ EndLog("DeleteOrganizationInternal");
+ return res;
+ }
+
+ public override void DeleteServiceItems(ServiceProviderItem[] items)
+ {
+ foreach (ServiceProviderItem item in items)
+ {
+ try
+ {
+ if (item is Organization)
+ {
+ Organization org = item as Organization;
+ DeleteOrganization(org.CrmOrganizationId);
+ }
+
+ }
+ catch (Exception ex)
+ {
+ Log.WriteError(String.Format("Error deleting '{0}' {1}", item.Name, item.GetType().Name), ex);
+ }
+ }
+ base.DeleteServiceItems(items);
+
+ }
+
+ #endregion
+
+ #region Log
+
+ private static void EndLog(string message, ResultObject res, string errorCode, Exception ex)
+ {
+ if (res != null)
+ {
+ res.IsSuccess = false;
+
+ if (!string.IsNullOrEmpty(errorCode))
+ res.ErrorCodes.Add(errorCode);
+ }
+
+ if (ex != null)
+ HostedSolutionLog.LogError(ex);
+
+ HostedSolutionLog.LogEnd(message);
+ }
+
+ private static void EndLog(string message, ResultObject res, string errorCode)
+ {
+ EndLog(message, res, errorCode, null);
+ }
+
+ private static void EndLog(string message, ResultObject res)
+ {
+ EndLog(message, res, null);
+ }
+
+ private static void EndLog(string message)
+ {
+ EndLog(message, null);
+ }
+
+ private static T StartLog(string message) where T : ResultObject, new()
+ {
+ HostedSolutionLog.LogStart(message);
+ T res = new T();
+ res.IsSuccess = true;
+ return res;
+ }
+
+ private static void StartLog(string message)
+ {
+ HostedSolutionLog.LogStart(message);
+ }
+
+ #endregion
+
+ #region User
+
+ public virtual UserResult CreateCRMUser(OrganizationUser user, string orgName, Guid organizationId, Guid baseUnitId, int CALType)
+ {
+ return CreateCRMUserInternal(user, orgName, organizationId, baseUnitId, CALType);
+ }
+
+ internal virtual UserResult CreateCRMUserInternal(OrganizationUser user, string orgName, Guid organizationId, Guid businessUnitId, int CALType)
+ {
+ UserResult res = StartLog("CreateCRMUserInternal");
+
+ try
+ {
+ if (user == null)
+ throw new ArgumentNullException("user");
+
+ if (string.IsNullOrEmpty(orgName))
+ throw new ArgumentNullException("orgName");
+
+ if (organizationId == Guid.Empty)
+ throw new ArgumentException("organizationId");
+
+ if (businessUnitId == Guid.Empty)
+ throw new ArgumentException("businessUnitId");
+
+ try
+ {
+ OrganizationServiceProxy _serviceProxy = GetOrganizationProxy(orgName);
+
+
+ string ldap = "";
+ Guid guid = RetrieveSystemUser(user.DomainUserName, user.FirstName, user.LastName, CRMSysAdminRoleStr, _serviceProxy, ref ldap, CALType);
+
+ user.CrmUserId = guid;
+ res.Value = user;
+
+ }
+ catch (Exception ex)
+ {
+ EndLog("CreateCRMUserInternal", res, CrmErrorCodes.CANNOT_CREATE_CRM_USER, ex);
+ return res;
+ }
+ }
+ catch (Exception ex)
+ {
+ EndLog("CreateCRMUserInternal", res, CrmErrorCodes.CANNOT_CREATE_CRM_USER_GENERAL_ERROR, ex);
+ return res;
+
+ }
+
+ EndLog("CreateCRMUserInternal");
+ return res;
+ }
+
+ protected virtual Guid CreateSystemUser(String userName, String firstName,
+ String lastName, String domain, String roleStr,
+ OrganizationServiceProxy serviceProxy, ref String ldapPath, int CALType)
+ {
+
+ if (serviceProxy.ServiceConfiguration.AuthenticationType == AuthenticationProviderType.LiveId ||
+ serviceProxy.ServiceConfiguration.AuthenticationType == AuthenticationProviderType.OnlineFederation)
+ throw new Exception(String.Format("To run this sample, {0} {1} must be an active system user in your Microsoft Dynamics CRM Online organization.", firstName, lastName));
+
+ Guid userId = Guid.Empty;
+
+ Microsoft.Xrm.Sdk.Query.QueryExpression businessUnitQuery = new Microsoft.Xrm.Sdk.Query.QueryExpression
+ {
+ EntityName = BusinessUnit.EntityLogicalName,
+ ColumnSet = new Microsoft.Xrm.Sdk.Query.ColumnSet("businessunitid"),
+ Criteria =
+ {
+ Conditions =
+ {
+ new Microsoft.Xrm.Sdk.Query.ConditionExpression("parentbusinessunitid",
+ Microsoft.Xrm.Sdk.Query.ConditionOperator.Null)
+ }
+ }
+ };
+
+ BusinessUnit defaultBusinessUnit = serviceProxy.RetrieveMultiple(
+ businessUnitQuery).Entities[0].ToEntity();
+
+ // Retrieve the specified security role.
+ Role role = RetrieveRoleByName(serviceProxy, roleStr);
+
+ // CALType and AccessMode
+ int accessmode = CALType / 10;
+ int caltype = CALType % 10;
+
+ //Create a new system user.
+ SystemUser user = new SystemUser
+ {
+ DomainName = userName,
+ FirstName = firstName,
+ LastName = lastName,
+ BusinessUnitId = new EntityReference
+ {
+ LogicalName = BusinessUnit.EntityLogicalName,
+ Name = BusinessUnit.EntityLogicalName,
+ Id = defaultBusinessUnit.Id
+ },
+ CALType = new OptionSetValue(caltype),
+ AccessMode = new OptionSetValue(accessmode)
+ };
+ userId = serviceProxy.Create(user);
+
+ // Assign the security role to the newly created Microsoft Dynamics CRM user.
+ AssociateRequest associate = new AssociateRequest()
+ {
+ Target = new EntityReference(SystemUser.EntityLogicalName, userId),
+ RelatedEntities = new EntityReferenceCollection()
+ {
+ new EntityReference(Role.EntityLogicalName, role.Id),
+ },
+ Relationship = new Relationship("systemuserroles_association")
+ };
+ serviceProxy.Execute(associate);
+
+ return userId;
+ }
+
+
+ protected virtual Guid RetrieveSystemUser(String userName, String firstName,
+ String lastName, String roleStr, OrganizationServiceProxy serviceProxy,
+ ref String ldapPath,
+ int CALType)
+ {
+ String domain;
+ Guid userId = Guid.Empty;
+
+ if (serviceProxy == null)
+ throw new ArgumentNullException("serviceProxy");
+
+ if (String.IsNullOrWhiteSpace(userName))
+ throw new ArgumentNullException("UserName");
+
+ if (String.IsNullOrWhiteSpace(firstName))
+ throw new ArgumentNullException("FirstName");
+
+ if (String.IsNullOrWhiteSpace(lastName))
+ throw new ArgumentNullException("LastName");
+
+ if (String.IsNullOrWhiteSpace(roleStr))
+ throw new ArgumentNullException("Role");
+
+ // Obtain the current user's information.
+ Microsoft.Crm.Sdk.Messages.WhoAmIRequest who = new Microsoft.Crm.Sdk.Messages.WhoAmIRequest();
+ Microsoft.Crm.Sdk.Messages.WhoAmIResponse whoResp = (Microsoft.Crm.Sdk.Messages.WhoAmIResponse)serviceProxy.Execute(who);
+ Guid currentUserId = whoResp.UserId;
+
+ SystemUser currentUser =
+ serviceProxy.Retrieve(SystemUser.EntityLogicalName, currentUserId, new Microsoft.Xrm.Sdk.Query.ColumnSet("domainname")).ToEntity();
+
+ // Extract the domain and create the LDAP object.
+ String[] userPath = currentUser.DomainName.Split(new char[] { '\\' });
+ if (userPath.Length > 1)
+ domain = userPath[0] + "\\";
+ else
+ domain = String.Empty;
+
+ // Create the system user in Microsoft Dynamics CRM if the user doesn't
+ // already exist.
+ Microsoft.Xrm.Sdk.Query.QueryExpression userQuery = new Microsoft.Xrm.Sdk.Query.QueryExpression
+ {
+ EntityName = SystemUser.EntityLogicalName,
+ ColumnSet = new Microsoft.Xrm.Sdk.Query.ColumnSet("systemuserid"),
+ Criteria =
+ {
+ FilterOperator = Microsoft.Xrm.Sdk.Query.LogicalOperator.Or,
+ Filters =
+ {
+ new Microsoft.Xrm.Sdk.Query.FilterExpression
+ {
+ FilterOperator = Microsoft.Xrm.Sdk.Query.LogicalOperator.And,
+ Conditions =
+ {
+ new Microsoft.Xrm.Sdk.Query.ConditionExpression("domainname", Microsoft.Xrm.Sdk.Query.ConditionOperator.Equal, domain + userName)
+ }
+ },
+ new Microsoft.Xrm.Sdk.Query.FilterExpression
+ {
+ FilterOperator = Microsoft.Xrm.Sdk.Query.LogicalOperator.And,
+ Conditions =
+ {
+ new Microsoft.Xrm.Sdk.Query.ConditionExpression("firstname", Microsoft.Xrm.Sdk.Query.ConditionOperator.Equal, firstName),
+ new Microsoft.Xrm.Sdk.Query.ConditionExpression("lastname", Microsoft.Xrm.Sdk.Query.ConditionOperator.Equal, lastName)
+ }
+ }
+ }
+
+ }
+ };
+
+ DataCollection existingUsers = (DataCollection)serviceProxy.RetrieveMultiple(userQuery).Entities;
+
+ SystemUser existingUser = null;
+ if (existingUsers.Count > 0)
+ existingUser = existingUsers[0].ToEntity();
+
+ if (existingUser != null)
+ {
+ userId = existingUser.SystemUserId.Value;
+
+ // Check to make sure the user is assigned the correct role.
+ Role role = RetrieveRoleByName(serviceProxy, roleStr);
+
+ // Associate the user with the role when needed.
+ if (!UserInRole(serviceProxy, userId, role.Id))
+ {
+ AssociateRequest associate = new AssociateRequest()
+ {
+ Target = new EntityReference(SystemUser.EntityLogicalName, userId),
+ RelatedEntities = new EntityReferenceCollection()
+ {
+ new EntityReference(Role.EntityLogicalName, role.Id)
+ },
+ Relationship = new Relationship("systemuserroles_association")
+ };
+ serviceProxy.Execute(associate);
+ }
+
+ }
+ else
+ {
+ userId = CreateSystemUser(userName, firstName, lastName, domain,
+ roleStr, serviceProxy, ref ldapPath, CALType);
+ }
+
+ return userId;
+ }
+
+ public virtual CrmUserResult GetCrmUserById(Guid crmUserId, string orgName)
+ {
+ return GetCrmUserByIdInternal(crmUserId, orgName);
+ }
+
+ internal virtual CrmUserResult GetCrmUserByIdInternal(Guid crmUserId, string orgName)
+ {
+ CrmUserResult ret = StartLog("GetCrmUserByIdInternal");
+
+ try
+ {
+ if (crmUserId == Guid.Empty)
+ throw new ArgumentNullException("crmUserId");
+
+ if (string.IsNullOrEmpty(orgName))
+ throw new ArgumentNullException("orgName");
+
+ OrganizationServiceProxy serviceProxy = GetOrganizationProxy(orgName);
+
+ SystemUser retruveUser =
+ serviceProxy.Retrieve(SystemUser.EntityLogicalName, crmUserId, new Microsoft.Xrm.Sdk.Query.ColumnSet("domainname", "businessunitid", "accessmode", "isdisabled", "caltype")).ToEntity();
+
+ CrmUser user = null;
+
+ if (retruveUser != null)
+ {
+ user = new CrmUser();
+ user.BusinessUnitId = retruveUser.BusinessUnitId.Id;
+ user.CRMUserId = retruveUser.SystemUserId.Value;
+ user.ClientAccessMode = (CRMUserAccessMode)retruveUser.AccessMode.Value;
+ user.IsDisabled = (bool)retruveUser.IsDisabled;
+ user.CALType = retruveUser.CALType.Value;
+
+ ret.Value = user;
+ }
+ }
+ catch (Exception ex)
+ {
+ EndLog("GetCrmUserByIdInternal", ret, CrmErrorCodes.CANONT_GET_CRM_USER_BY_ID, ex);
+ return ret;
+ }
+
+ EndLog("GetCrmUserByIdInternal");
+ return ret;
+ }
+
+ internal virtual CrmUserResult GetCrmUserByDomainNameInternal(string domainName, string orgName)
+ {
+ CrmUserResult ret = StartLog("GetCrmUserByDomainNameInternal");
+
+ try
+ {
+ if (string.IsNullOrEmpty(domainName))
+ throw new ArgumentNullException("domainName");
+
+ if (string.IsNullOrEmpty(orgName))
+ throw new ArgumentNullException("orgName");
+
+
+ OrganizationServiceProxy serviceProxy = GetOrganizationProxy(orgName);
+
+ Microsoft.Xrm.Sdk.Query.QueryExpression usereQuery = new Microsoft.Xrm.Sdk.Query.QueryExpression
+ {
+ EntityName = SystemUser.EntityLogicalName,
+ ColumnSet = new Microsoft.Xrm.Sdk.Query.ColumnSet("domainname", "businessunitid", "accessmode", "isdisabled", "systemuserid", "caltype"),
+ };
+
+ EntityCollection users = serviceProxy.RetrieveMultiple(usereQuery);
+
+ foreach (Entity entityuser in users.Entities)
+ {
+ SystemUser sysuser = entityuser.ToEntity();
+
+ if (sysuser == null) continue;
+ if (sysuser.DomainName != domainName) continue;
+
+ CrmUser user = new CrmUser();
+ user.BusinessUnitId = sysuser.BusinessUnitId.Id;
+ user.CRMUserId = sysuser.SystemUserId.Value;
+ user.ClientAccessMode = (CRMUserAccessMode)sysuser.AccessMode.Value;
+ user.IsDisabled = sysuser.IsDisabled.Value;
+ user.CALType = sysuser.CALType.Value;
+ ret.Value = user;
+ }
+ }
+ catch (Exception ex)
+ {
+ EndLog("GetCrmUserByDomainNameInternal", ret, CrmErrorCodes.CANONT_GET_CRM_USER_BY_DOMAIN_NAME, ex);
+ return ret;
+ }
+
+ EndLog("GetCrmUserByDomainNameInternal");
+ return ret;
+ }
+
+ public virtual CrmUserResult GetCrmUserByDomainName(string domainName, string orgName)
+ {
+ return GetCrmUserByDomainNameInternal(domainName, orgName);
+ }
+
+ public virtual ResultObject ChangeUserState(bool disable, string orgName, Guid crmUserId)
+ {
+ return ChangeUserStateInternal(disable, orgName, crmUserId);
+ }
+
+ internal virtual ResultObject ChangeUserStateInternal(bool disable, string orgName, Guid crmUserId)
+ {
+ ResultObject res = StartLog("ChangeUserStateInternal");
+
+ res.IsSuccess = true;
+ try
+ {
+ if (crmUserId == Guid.Empty)
+ throw new ArgumentNullException("crmUserId");
+
+ if (string.IsNullOrEmpty(orgName))
+ throw new ArgumentNullException("orgName");
+
+ OrganizationServiceProxy serviceProxy = GetOrganizationProxy(orgName);
+
+ // Retrieve a user.
+ SystemUser user = serviceProxy.Retrieve(SystemUser.EntityLogicalName,
+ crmUserId, new Microsoft.Xrm.Sdk.Query.ColumnSet(new String[] { "systemuserid", "firstname", "lastname" })).ToEntity();
+
+ if (user != null)
+ {
+ Microsoft.Crm.Sdk.Messages.SetStateRequest request = new Microsoft.Crm.Sdk.Messages.SetStateRequest()
+ {
+ EntityMoniker = user.ToEntityReference(),
+
+ // Required by request but always valued at -1 in this context.
+ Status = new OptionSetValue(-1),
+
+ // Sets the user to disabled.
+ State = disable ? new OptionSetValue(-1) : new OptionSetValue(0)
+ };
+
+ serviceProxy.Execute(request);
+
+ }
+ }
+ catch (Exception ex)
+ {
+ EndLog("ChangeUserStateInternal", res, CrmErrorCodes.CANNOT_CHANGE_USER_STATE, ex);
+ return res;
+ }
+
+
+ EndLog("ChangeUserStateInternal");
+ return res;
+ }
+
+ public virtual ResultObject SetUserCALType(string orgName, Guid userId, int CALType)
+ {
+ return SetUserCALTypeInternal(orgName, userId, CALType);
+ }
+
+ internal virtual ResultObject SetUserCALTypeInternal(string orgName, Guid userId, int CALType)
+ {
+ ResultObject ret = StartLog("SetUserCALTypeInternal");
+
+ try
+ {
+ if (userId == Guid.Empty)
+ throw new ArgumentNullException("crmUserId");
+
+ if (string.IsNullOrEmpty(orgName))
+ throw new ArgumentNullException("orgName");
+
+ OrganizationServiceProxy serviceProxy = GetOrganizationProxy(orgName);
+
+ SystemUser user =
+ serviceProxy.Retrieve(SystemUser.EntityLogicalName, userId, new Microsoft.Xrm.Sdk.Query.ColumnSet("domainname", "businessunitid", "accessmode", "isdisabled", "caltype")).ToEntity();
+
+ // CALType and AccessMode
+ int accessmode = CALType / 10;
+ int caltype = CALType % 10;
+
+ user.CALType = new OptionSetValue(caltype);
+ user.AccessMode = new OptionSetValue(accessmode);
+
+ serviceProxy.Update(user);
+
+ }
+ catch (Exception ex)
+ {
+ EndLog("SetUserCALTypeInternal", ret, CrmErrorCodes.CANONT_GET_CRM_USER_BY_ID, ex);
+ return ret;
+ }
+
+ EndLog("SetUserCALTypeInternal");
+ return ret;
+ }
+
+ #endregion
+
+ #region Role
+
+ protected virtual Role RetrieveRoleByName(OrganizationServiceProxy serviceProxy,
+ String roleSplitStr)
+ {
+ string[] RolesStr = roleSplitStr.Split(';');
+
+ foreach (string roleStr in RolesStr)
+ {
+
+ Microsoft.Xrm.Sdk.Query.QueryExpression roleQuery = new Microsoft.Xrm.Sdk.Query.QueryExpression
+ {
+ EntityName = Role.EntityLogicalName,
+ ColumnSet = new Microsoft.Xrm.Sdk.Query.ColumnSet("roleid"),
+ Criteria =
+ {
+ Conditions =
+ {
+ new Microsoft.Xrm.Sdk.Query.ConditionExpression("name", Microsoft.Xrm.Sdk.Query.ConditionOperator.Equal, roleStr)
+ }
+ }
+ };
+
+ DataCollection roles = serviceProxy.RetrieveMultiple(roleQuery).Entities;
+
+ if (roles.Count > 0) return roles[0].ToEntity();
+ }
+
+ return null;
+ }
+
+ protected virtual bool UserInRole(OrganizationServiceProxy serviceProxy,
+ Guid userId, Guid roleId)
+ {
+ // Establish a SystemUser link for a query.
+ Microsoft.Xrm.Sdk.Query.LinkEntity systemUserLink = new Microsoft.Xrm.Sdk.Query.LinkEntity()
+ {
+ LinkFromEntityName = SystemUserRoles.EntityLogicalName,
+ LinkFromAttributeName = "systemuserid",
+ LinkToEntityName = SystemUser.EntityLogicalName,
+ LinkToAttributeName = "systemuserid",
+ LinkCriteria =
+ {
+ Conditions =
+ {
+ new Microsoft.Xrm.Sdk.Query.ConditionExpression(
+ "systemuserid", Microsoft.Xrm.Sdk.Query.ConditionOperator.Equal, userId)
+ }
+ }
+ };
+
+ // Build the query.
+ Microsoft.Xrm.Sdk.Query.QueryExpression query = new Microsoft.Xrm.Sdk.Query.QueryExpression()
+ {
+ EntityName = Role.EntityLogicalName,
+ ColumnSet = new Microsoft.Xrm.Sdk.Query.ColumnSet("roleid"),
+ LinkEntities =
+ {
+ new Microsoft.Xrm.Sdk.Query.LinkEntity()
+ {
+ LinkFromEntityName = Role.EntityLogicalName,
+ LinkFromAttributeName = "roleid",
+ LinkToEntityName = SystemUserRoles.EntityLogicalName,
+ LinkToAttributeName = "roleid",
+ LinkEntities = {systemUserLink}
+ }
+ },
+ Criteria =
+ {
+ Conditions =
+ {
+ new Microsoft.Xrm.Sdk.Query.ConditionExpression("roleid", Microsoft.Xrm.Sdk.Query.ConditionOperator.Equal, roleId)
+ }
+ }
+ };
+
+ // Retrieve matching roles.
+ EntityCollection ec = serviceProxy.RetrieveMultiple(query);
+
+ if (ec.Entities.Count > 0)
+ return true;
+
+ return false;
+ }
+
+ public virtual CrmRolesResult GetAllCrmRoles(string orgName, Guid businessUnitId)
+ {
+ return GetAllCrmRolesInternal(orgName, businessUnitId);
+ }
+
+ public virtual CrmRolesResult GetCrmUserRoles(string orgName, Guid userId)
+ {
+ return GetCrmUserRolesInternal(userId, orgName);
+ }
+
+ public virtual EntityCollection GetUserRoles(Guid userId, string orgName)
+ {
+ OrganizationServiceProxy serviceProxy = GetOrganizationProxy(orgName);
+
+ // Establish a SystemUser link for a query.
+ Microsoft.Xrm.Sdk.Query.LinkEntity systemUserLink = new Microsoft.Xrm.Sdk.Query.LinkEntity()
+ {
+ LinkFromEntityName = SystemUserRoles.EntityLogicalName,
+ LinkFromAttributeName = "systemuserid",
+ LinkToEntityName = SystemUser.EntityLogicalName,
+ LinkToAttributeName = "systemuserid",
+ LinkCriteria =
+ {
+ Conditions =
+ {
+ new Microsoft.Xrm.Sdk.Query.ConditionExpression(
+ "systemuserid", Microsoft.Xrm.Sdk.Query.ConditionOperator.Equal, userId)
+ }
+ }
+ };
+
+ // Build the query.
+ Microsoft.Xrm.Sdk.Query.QueryExpression query = new Microsoft.Xrm.Sdk.Query.QueryExpression()
+ {
+ EntityName = Role.EntityLogicalName,
+ ColumnSet = new Microsoft.Xrm.Sdk.Query.ColumnSet("roleid"),
+ LinkEntities =
+ {
+ new Microsoft.Xrm.Sdk.Query.LinkEntity()
+ {
+ LinkFromEntityName = Role.EntityLogicalName,
+ LinkFromAttributeName = "roleid",
+ LinkToEntityName = SystemUserRoles.EntityLogicalName,
+ LinkToAttributeName = "roleid",
+ LinkEntities = {systemUserLink}
+ }
+ }
+ };
+
+ // Retrieve matching roles.
+ EntityCollection relations = serviceProxy.RetrieveMultiple(query);
+
+ return relations;
+ }
+
+ internal virtual CrmRolesResult GetCrmUserRolesInternal(Guid userId, string orgName)
+ {
+ CrmRolesResult res = StartLog("GetCrmUserRolesInternal");
+
+ try
+ {
+ EntityCollection relations;
+
+ if (userId == Guid.Empty)
+ throw new ArgumentException("userId");
+
+ if (string.IsNullOrEmpty(orgName))
+ throw new ArgumentNullException("orgName");
+
+ try
+ {
+ relations = GetUserRoles(userId, orgName);
+ }
+ catch (Exception ex)
+ {
+ EndLog("GetCrmUserRolesInternal", res, CrmErrorCodes.CANNOT_GET_CRM_USER_ROLES, ex);
+ return res;
+ }
+
+ try
+ {
+ res.Value = FillCrmRoles(relations, true, Guid.Empty);
+ }
+ catch (Exception ex)
+ {
+ EndLog("GetCrmUserRolesInternal", res, CrmErrorCodes.CANNOT_FILL_ROLES_COLLECTION, ex);
+ return res;
+ }
+ }
+ catch (Exception ex)
+ {
+ EndLog("GetCrmUserRolesInternal", res, CrmErrorCodes.GET_CRM_USER_ROLE_GENERAL_ERROR, ex);
+ return res;
+ }
+
+ EndLog("GetCrmUserRolesInternal");
+ return res;
+ }
+
+ protected static string excludedRolesStr = ";пользователь поддержки;support user;";
+
+ protected virtual List FillCrmRoles(EntityCollection entities, bool isUserRole, Guid businessUnitId)
+ {
+ List res = new List();
+
+ foreach (Entity current in entities.Entities)
+ {
+ Role role = current.ToEntity();
+
+ if (role == null) continue;
+
+ if (businessUnitId != Guid.Empty)
+ {
+ if (businessUnitId != role.BusinessUnitId.Id)
+ continue;
+ }
+
+ string roleName = role.Name;
+
+ if (roleName != null)
+ if (excludedRolesStr.IndexOf(";" + roleName.ToLower() + ";") != -1)
+ continue;
+
+ CrmRole crmRole = new CrmRole();
+ crmRole.IsCurrentUserRole = isUserRole;
+ crmRole.RoleId = (Guid)role.RoleId;
+ crmRole.RoleName = roleName;
+
+ res.Add(crmRole);
+ }
+
+ return res;
+ }
+
+ protected virtual List FillCrmRoles(EntityCollection entities, Guid businessUnitId)
+ {
+ return FillCrmRoles(entities, false, businessUnitId);
+ }
+
+ internal virtual CrmRolesResult GetAllCrmRolesInternal(string orgName, Guid businessUnitId)
+ {
+ CrmRolesResult res = StartLog("GetAllCrmRoles");
+
+ try
+ {
+ if (string.IsNullOrEmpty(orgName))
+ throw new ArgumentNullException("orgName");
+
+ EntityCollection roles;
+ try
+ {
+ OrganizationServiceProxy serviceProxy = GetOrganizationProxy(orgName);
+
+ Microsoft.Xrm.Sdk.Query.QueryExpression roleQuery = new Microsoft.Xrm.Sdk.Query.QueryExpression
+ {
+ EntityName = Role.EntityLogicalName,
+ ColumnSet = new Microsoft.Xrm.Sdk.Query.ColumnSet(new string[] { "roleid", "name", "businessunitid" }),
+ };
+
+ roles = serviceProxy.RetrieveMultiple(roleQuery);
+
+
+ }
+ catch (Exception ex)
+ {
+ EndLog("GetAllCrmRoles", res, CrmErrorCodes.CANNOT_GET_ALL_CRM_ROLES, ex);
+ return res;
+ }
+
+ try
+ {
+ List crmRoles = FillCrmRoles(roles, businessUnitId);
+ res.Value = crmRoles;
+ }
+ catch (Exception ex)
+ {
+ EndLog("GetAllCrmRoles", res, CrmErrorCodes.CANNOT_FILL_ROLES_COLLECTION, ex);
+ return res;
+ }
+ }
+ catch (Exception ex)
+ {
+ EndLog("GetAllCrmRoles", res, CrmErrorCodes.GET_ALL_CRM_ROLES_GENERAL_ERROR, ex);
+ return res;
+ }
+
+ EndLog("GetAllCrmRoles");
+ return res;
+ }
+
+ public virtual ResultObject SetUserRoles(string orgName, Guid userId, Guid[] roles)
+ {
+ return SetUserRolesInternal(orgName, userId, roles);
+ }
+
+ internal virtual ResultObject SetUserRolesInternal(string orgName, Guid userId, Guid[] roles)
+ {
+ CrmRolesResult res = StartLog("SetUserRolesInternal");
+
+ try
+ {
+ if (string.IsNullOrEmpty(orgName))
+ throw new ArgumentNullException("orgName");
+
+ if (userId == Guid.Empty)
+ throw new ArgumentException("userId");
+
+ if (roles == null)
+ throw new ArgumentNullException("roles");
+
+ OrganizationServiceProxy serviceProxy = GetOrganizationProxy(orgName);
+
+
+ CrmRolesResult tmpRoles = GetCrmUserRoles(orgName, userId);
+ res.ErrorCodes.AddRange(tmpRoles.ErrorCodes);
+
+ if (!tmpRoles.IsSuccess)
+ return res;
+
+ List remRoles = new List();
+
+ for (int i = 0; i < tmpRoles.Value.Count; i++)
+ {
+ if (Array.Find(roles, delegate(Guid current) { return current == tmpRoles.Value[i].RoleId; }) == Guid.Empty)
+ {
+ remRoles.Add(tmpRoles.Value[i].RoleId);
+ }
+ }
+
+ try
+ {
+ DisassociateRequest removeRole = new DisassociateRequest()
+ {
+ Target = new EntityReference(SystemUser.EntityLogicalName, userId),
+ RelatedEntities = new EntityReferenceCollection(),
+ Relationship = new Relationship("systemuserroles_association")
+ };
+
+ for (int i = 0; i < remRoles.Count; i++)
+ removeRole.RelatedEntities.Add(new EntityReference(Role.EntityLogicalName, remRoles[i]));
+
+ serviceProxy.Execute(removeRole);
+
+ }
+ catch (Exception ex)
+ {
+ EndLog("SetUserRolesInternal", res, CrmErrorCodes.CANNOT_REMOVE_CRM_USER_ROLES, ex);
+ return res;
+ }
+
+
+ try
+ {
+ // Assign the security role to the newly created Microsoft Dynamics CRM user.
+ AssociateRequest associate = new AssociateRequest()
+ {
+ Target = new EntityReference(SystemUser.EntityLogicalName, userId),
+ RelatedEntities = new EntityReferenceCollection(),
+ Relationship = new Relationship("systemuserroles_association")
+ };
+
+ for (int i = 0; i < roles.Length; i++)
+ {
+ bool find = false;
+ foreach (CrmRole current in tmpRoles.Value)
+ {
+ if (current.RoleId == roles[i])
+ find = true;
+ }
+ if (find) continue;
+
+ associate.RelatedEntities.Add(new EntityReference(Role.EntityLogicalName, roles[i]));
+ }
+
+ serviceProxy.Execute(associate);
+ }
+ catch (Exception ex)
+ {
+ EndLog("SetUserRolesInternal", res, CrmErrorCodes.CANNOT_ASSIGN_CRM_USER_ROLES, ex);
+ return res;
+ }
+
+ }
+ catch (Exception ex)
+ {
+ EndLog("SetUserRolesInternal", res, CrmErrorCodes.CANNOT_SET_CRM_USER_ROLES_GENERAL_ERROR, ex);
+ return res;
+ }
+
+
+ EndLog("SetUserRolesInternal");
+ return res;
+
+ }
+
+ #endregion
+
+ #region Business Units
+
+ internal virtual CRMBusinessUnitsResult GetOrganizationBusinessUnitsInternal(Guid organizationId, string orgName)
+ {
+ CRMBusinessUnitsResult res = StartLog("GetOrganizationBusinessUnitsInternal");
+
+ try
+ {
+ if (organizationId == Guid.Empty)
+ throw new ArgumentException("organizationId");
+
+ if (string.IsNullOrEmpty(orgName))
+ throw new ArgumentNullException("orgName");
+
+ OrganizationServiceProxy serviceProxy;
+
+ try
+ {
+ serviceProxy = GetOrganizationProxy(orgName);
+ }
+ catch (Exception ex)
+ {
+ EndLog("GetOrganizationBusinessUnitsInternal", res, CrmErrorCodes.CANNOT_GET_CRM_SERVICE, ex);
+ return res;
+ }
+
+ DataCollection BusinessUnits;
+
+ try
+ {
+
+ Microsoft.Xrm.Sdk.Query.QueryExpression businessUnitQuery = new Microsoft.Xrm.Sdk.Query.QueryExpression
+ {
+ EntityName = BusinessUnit.EntityLogicalName,
+ ColumnSet = new Microsoft.Xrm.Sdk.Query.ColumnSet(new string[] { "businessunitid", "name" }),
+ Criteria =
+ {
+ Conditions =
+ {
+ new Microsoft.Xrm.Sdk.Query.ConditionExpression("parentbusinessunitid",
+ Microsoft.Xrm.Sdk.Query.ConditionOperator.Null)
+ }
+ }
+ };
+
+ BusinessUnits = serviceProxy.RetrieveMultiple(
+ businessUnitQuery).Entities;
+
+ }
+ catch (Exception ex)
+ {
+ EndLog("GetOrganizationBusinessUnitsInternal", res, CrmErrorCodes.CANNOT_GET_CRM_BUSINESS_UNITS, ex);
+ return res;
+ }
+
+ List businessUnits = new List();
+
+ try
+ {
+ for (int i = 0; i < BusinessUnits.Count; i++)
+ {
+ BusinessUnit bu = BusinessUnits[i].ToEntity();
+
+ CRMBusinessUnit unit = new CRMBusinessUnit();
+ unit.BusinessUnitId = (Guid)bu.BusinessUnitId;
+ unit.BusinessUnitName = bu.Name;
+
+ if (unit.BusinessUnitName == null)
+ unit.BusinessUnitName = "default";
+
+ businessUnits.Add(unit);
+
+ }
+
+ res.Value = businessUnits;
+ }
+ catch (Exception ex)
+ {
+ EndLog("GetOrganizationBusinessUnitsInternal", res, CrmErrorCodes.CANNOT_FILL_BASE_UNITS_COLLECTION,
+ ex);
+ return res;
+ }
+ }
+ catch (Exception ex)
+ {
+ EndLog("GetOrganizationBusinessUnitsInternal", res, CrmErrorCodes.GET_ORGANIZATION_BUSINESS_UNITS_GENERAL_ERROR,
+ ex);
+ return res;
+
+ }
+
+ EndLog("GetOrganizationBusinessUnitsInternal");
+ return res;
+
+ }
+
+ public virtual CRMBusinessUnitsResult GetOrganizationBusinessUnits(Guid organizationId, string orgName)
+ {
+ return GetOrganizationBusinessUnitsInternal(organizationId, orgName);
+ }
+
+ #endregion
+
+ #region Version
+
+ public virtual string CRMServerVersion
+ {
+ get
+ {
+ string value = "";
+ try
+ {
+ RegistryKey root = Registry.LocalMachine;
+ RegistryKey rk = root.OpenSubKey("SOFTWARE\\Microsoft\\MSCRM");
+
+ if (rk == null)
+ rk = root.OpenSubKey("SOFTWARE\\Wow6432Node\\Microsoft\\MSCRM");
+
+ if (rk != null)
+ {
+ value = (string)rk.GetValue("CRM_Server_Version", null);
+ rk.Close();
+ }
+ }
+ catch (Exception ex)
+ {
+ Log.WriteError(ex);
+ }
+
+ return value;
+ }
+
+ }
+
+ public override bool IsInstalled()
+ {
+ return false;
+ }
+
+ #endregion
+
+ }
+}
diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution.Crm2015/CRMProvider2015.cs b/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution.Crm2015/CRMProvider2015.cs
new file mode 100644
index 00000000..5fcf9a4e
--- /dev/null
+++ b/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution.Crm2015/CRMProvider2015.cs
@@ -0,0 +1,46 @@
+// Copyright (c) 2015, 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.
+
+using System;
+using WebsitePanel.Providers.HostedSolution;
+
+
+namespace WebsitePanel.Providers.HostedSolution
+{
+ public class CRMProvider2015 : CRMBase
+ {
+
+ public override bool IsInstalled()
+ {
+
+ return CRMServerVersion.StartsWith("7.");
+ }
+
+ }
+
+}
diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution.Crm2015/HostedSolutionLog.cs b/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution.Crm2015/HostedSolutionLog.cs
new file mode 100644
index 00000000..75f869e8
--- /dev/null
+++ b/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution.Crm2015/HostedSolutionLog.cs
@@ -0,0 +1,152 @@
+// Copyright (c) 2015, 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.
+
+using System;
+using WebsitePanel.Providers.Common;
+using WebsitePanel.Server.Utils;
+using System.Text;
+using System.Management.Automation.Runspaces;
+
+namespace WebsitePanel.Providers.HostedSolution
+{
+ public class HostedSolutionLog
+ {
+ public static string LogPrefix = "HostedSolution";
+
+ public static void LogStart(string message, params object[] args)
+ {
+ string text = String.Format(message, args);
+ Log.WriteStart("{0} {1}", LogPrefix, text);
+ }
+
+ public static void LogEnd(string message, params object[] args)
+ {
+ string text = String.Format(message, args);
+ Log.WriteEnd("{0} {1}", LogPrefix, text);
+ }
+
+ public static void LogInfo(string message)
+ {
+ Log.WriteInfo("{0} {1}", LogPrefix, message);
+ }
+
+ public static void LogInfo(string message, params object[] args)
+ {
+ string text = String.Format(message, args);
+ Log.WriteInfo("{0} {1}", LogPrefix, text);
+ }
+
+ public static void LogWarning(string message)
+ {
+ Log.WriteWarning("{0} {1}", LogPrefix, message);
+ }
+
+ public static void LogWarning(string message, params object[] args)
+ {
+ string text = String.Format(message, args);
+ Log.WriteWarning("{0} {1}", LogPrefix, text);
+ }
+
+ public static void LogError(Exception ex)
+ {
+ Log.WriteError(LogPrefix, ex);
+ }
+
+ public static void LogError(string message, Exception ex)
+ {
+ string text = String.Format("{0} {1}", LogPrefix, message);
+ Log.WriteError(text, ex);
+ }
+
+ public static void DebugInfo(string message, params object[] args)
+ {
+ string text = String.Format(message, args);
+ Log.WriteInfo("{0} {1}", LogPrefix, text);
+ }
+
+ public static void EndLog(string message, ResultObject res, string errorCode, Exception ex)
+ {
+ if (res != null)
+ {
+ res.IsSuccess = false;
+
+ if (!string.IsNullOrEmpty(errorCode))
+ res.ErrorCodes.Add(errorCode);
+ }
+
+ if (ex != null)
+ LogError(ex);
+
+
+ //LogRecord.
+ LogEnd(message);
+
+
+ }
+
+ public static void EndLog(string message, ResultObject res, string errorCode)
+ {
+ EndLog(message, res, errorCode, null);
+ }
+
+ public static void EndLog(string message, ResultObject res)
+ {
+ EndLog(message, res, null);
+ }
+
+ public static void EndLog(string message)
+ {
+ EndLog(message, null);
+ }
+
+ internal static T StartLog(string message) where T : ResultObject, new()
+ {
+ LogStart(message);
+ T res = new T();
+ res.IsSuccess = true;
+ return res;
+ }
+
+ public static void DebugCommand(Command cmd)
+ {
+ StringBuilder sb = new StringBuilder(cmd.CommandText);
+ foreach (CommandParameter parameter in cmd.Parameters)
+ {
+ string formatString = " -{0} {1}";
+ if (parameter.Value is string)
+ formatString = " -{0} '{1}'";
+ else if (parameter.Value is bool)
+ formatString = " -{0} ${1}";
+ sb.AppendFormat(formatString, parameter.Name, parameter.Value);
+ }
+ Log.WriteInfo("{0} {1}", LogPrefix, sb.ToString());
+ }
+
+
+ }
+}
diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution.Crm2015/MyOrganizationCrmSdkTypes.cs b/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution.Crm2015/MyOrganizationCrmSdkTypes.cs
new file mode 100644
index 00000000..abcd214f
--- /dev/null
+++ b/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution.Crm2015/MyOrganizationCrmSdkTypes.cs
@@ -0,0 +1,213367 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.34209
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+[assembly: Microsoft.Xrm.Sdk.Client.ProxyTypesAssemblyAttribute()]
+
+
+
+[System.Runtime.Serialization.DataContractAttribute()]
+[System.CodeDom.Compiler.GeneratedCodeAttribute("CrmSvcUtil", "7.0.0000.3048")]
+public enum AccountState
+{
+
+ [System.Runtime.Serialization.EnumMemberAttribute()]
+ Active = 0,
+
+ [System.Runtime.Serialization.EnumMemberAttribute()]
+ Inactive = 1,
+}
+
+///
+/// Business that represents a customer or potential customer. The company that is billed in business transactions.
+///
+[System.Runtime.Serialization.DataContractAttribute()]
+[Microsoft.Xrm.Sdk.Client.EntityLogicalNameAttribute("account")]
+[System.CodeDom.Compiler.GeneratedCodeAttribute("CrmSvcUtil", "7.0.0000.3048")]
+public partial class Account : Microsoft.Xrm.Sdk.Entity, System.ComponentModel.INotifyPropertyChanging, System.ComponentModel.INotifyPropertyChanged
+{
+
+ ///
+ /// Default Constructor.
+ ///
+ public Account() :
+ base(EntityLogicalName)
+ {
+ }
+
+ public const string EntityLogicalName = "account";
+
+ public const int EntityTypeCode = 1;
+
+ public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
+
+ public event System.ComponentModel.PropertyChangingEventHandler PropertyChanging;
+
+ private void OnPropertyChanged(string propertyName)
+ {
+ if ((this.PropertyChanged != null))
+ {
+ this.PropertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
+ }
+ }
+
+ private void OnPropertyChanging(string propertyName)
+ {
+ if ((this.PropertyChanging != null))
+ {
+ this.PropertyChanging(this, new System.ComponentModel.PropertyChangingEventArgs(propertyName));
+ }
+ }
+
+ ///
+ /// Select a category to indicate whether the customer account is standard or preferred.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("accountcategorycode")]
+ public Microsoft.Xrm.Sdk.OptionSetValue AccountCategoryCode
+ {
+ get
+ {
+ return this.GetAttributeValue("accountcategorycode");
+ }
+ set
+ {
+ this.OnPropertyChanging("AccountCategoryCode");
+ this.SetAttributeValue("accountcategorycode", value);
+ this.OnPropertyChanged("AccountCategoryCode");
+ }
+ }
+
+ ///
+ /// Select a classification code to indicate the potential value of the customer account based on the projected return on investment, cooperation level, sales cycle length or other criteria.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("accountclassificationcode")]
+ public Microsoft.Xrm.Sdk.OptionSetValue AccountClassificationCode
+ {
+ get
+ {
+ return this.GetAttributeValue("accountclassificationcode");
+ }
+ set
+ {
+ this.OnPropertyChanging("AccountClassificationCode");
+ this.SetAttributeValue("accountclassificationcode", value);
+ this.OnPropertyChanged("AccountClassificationCode");
+ }
+ }
+
+ ///
+ /// Unique identifier of the account.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("accountid")]
+ public System.Nullable AccountId
+ {
+ get
+ {
+ return this.GetAttributeValue>("accountid");
+ }
+ set
+ {
+ this.OnPropertyChanging("AccountId");
+ this.SetAttributeValue("accountid", value);
+ if (value.HasValue)
+ {
+ base.Id = value.Value;
+ }
+ else
+ {
+ base.Id = System.Guid.Empty;
+ }
+ this.OnPropertyChanged("AccountId");
+ }
+ }
+
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("accountid")]
+ public override System.Guid Id
+ {
+ get
+ {
+ return base.Id;
+ }
+ set
+ {
+ this.AccountId = value;
+ }
+ }
+
+ ///
+ /// Type an ID number or code for the account to quickly search and identify the account in system views.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("accountnumber")]
+ public string AccountNumber
+ {
+ get
+ {
+ return this.GetAttributeValue("accountnumber");
+ }
+ set
+ {
+ this.OnPropertyChanging("AccountNumber");
+ this.SetAttributeValue("accountnumber", value);
+ this.OnPropertyChanged("AccountNumber");
+ }
+ }
+
+ ///
+ /// Select a rating to indicate the value of the customer account.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("accountratingcode")]
+ public Microsoft.Xrm.Sdk.OptionSetValue AccountRatingCode
+ {
+ get
+ {
+ return this.GetAttributeValue("accountratingcode");
+ }
+ set
+ {
+ this.OnPropertyChanging("AccountRatingCode");
+ this.SetAttributeValue("accountratingcode", value);
+ this.OnPropertyChanged("AccountRatingCode");
+ }
+ }
+
+ ///
+ /// Unique identifier for address 1.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("address1_addressid")]
+ public System.Nullable Address1_AddressId
+ {
+ get
+ {
+ return this.GetAttributeValue>("address1_addressid");
+ }
+ set
+ {
+ this.OnPropertyChanging("Address1_AddressId");
+ this.SetAttributeValue("address1_addressid", value);
+ this.OnPropertyChanged("Address1_AddressId");
+ }
+ }
+
+ ///
+ /// Select the primary address type.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("address1_addresstypecode")]
+ public Microsoft.Xrm.Sdk.OptionSetValue Address1_AddressTypeCode
+ {
+ get
+ {
+ return this.GetAttributeValue("address1_addresstypecode");
+ }
+ set
+ {
+ this.OnPropertyChanging("Address1_AddressTypeCode");
+ this.SetAttributeValue("address1_addresstypecode", value);
+ this.OnPropertyChanged("Address1_AddressTypeCode");
+ }
+ }
+
+ ///
+ /// Type the city for the primary address.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("address1_city")]
+ public string Address1_City
+ {
+ get
+ {
+ return this.GetAttributeValue("address1_city");
+ }
+ set
+ {
+ this.OnPropertyChanging("Address1_City");
+ this.SetAttributeValue("address1_city", value);
+ this.OnPropertyChanged("Address1_City");
+ }
+ }
+
+ ///
+ /// Shows the complete primary address.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("address1_composite")]
+ public string Address1_Composite
+ {
+ get
+ {
+ return this.GetAttributeValue("address1_composite");
+ }
+ }
+
+ ///
+ /// Type the country or region for the primary address.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("address1_country")]
+ public string Address1_Country
+ {
+ get
+ {
+ return this.GetAttributeValue("address1_country");
+ }
+ set
+ {
+ this.OnPropertyChanging("Address1_Country");
+ this.SetAttributeValue("address1_country", value);
+ this.OnPropertyChanged("Address1_Country");
+ }
+ }
+
+ ///
+ /// Type the county for the primary address.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("address1_county")]
+ public string Address1_County
+ {
+ get
+ {
+ return this.GetAttributeValue("address1_county");
+ }
+ set
+ {
+ this.OnPropertyChanging("Address1_County");
+ this.SetAttributeValue("address1_county", value);
+ this.OnPropertyChanged("Address1_County");
+ }
+ }
+
+ ///
+ /// Type the fax number associated with the primary address.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("address1_fax")]
+ public string Address1_Fax
+ {
+ get
+ {
+ return this.GetAttributeValue("address1_fax");
+ }
+ set
+ {
+ this.OnPropertyChanging("Address1_Fax");
+ this.SetAttributeValue("address1_fax", value);
+ this.OnPropertyChanged("Address1_Fax");
+ }
+ }
+
+ ///
+ /// Select the freight terms for the primary address to make sure shipping orders are processed correctly.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("address1_freighttermscode")]
+ public Microsoft.Xrm.Sdk.OptionSetValue Address1_FreightTermsCode
+ {
+ get
+ {
+ return this.GetAttributeValue("address1_freighttermscode");
+ }
+ set
+ {
+ this.OnPropertyChanging("Address1_FreightTermsCode");
+ this.SetAttributeValue("address1_freighttermscode", value);
+ this.OnPropertyChanged("Address1_FreightTermsCode");
+ }
+ }
+
+ ///
+ /// Type the latitude value for the primary address for use in mapping and other applications.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("address1_latitude")]
+ public System.Nullable Address1_Latitude
+ {
+ get
+ {
+ return this.GetAttributeValue>("address1_latitude");
+ }
+ set
+ {
+ this.OnPropertyChanging("Address1_Latitude");
+ this.SetAttributeValue("address1_latitude", value);
+ this.OnPropertyChanged("Address1_Latitude");
+ }
+ }
+
+ ///
+ /// Type the first line of the primary address.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("address1_line1")]
+ public string Address1_Line1
+ {
+ get
+ {
+ return this.GetAttributeValue("address1_line1");
+ }
+ set
+ {
+ this.OnPropertyChanging("Address1_Line1");
+ this.SetAttributeValue("address1_line1", value);
+ this.OnPropertyChanged("Address1_Line1");
+ }
+ }
+
+ ///
+ /// Type the second line of the primary address.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("address1_line2")]
+ public string Address1_Line2
+ {
+ get
+ {
+ return this.GetAttributeValue("address1_line2");
+ }
+ set
+ {
+ this.OnPropertyChanging("Address1_Line2");
+ this.SetAttributeValue("address1_line2", value);
+ this.OnPropertyChanged("Address1_Line2");
+ }
+ }
+
+ ///
+ /// Type the third line of the primary address.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("address1_line3")]
+ public string Address1_Line3
+ {
+ get
+ {
+ return this.GetAttributeValue("address1_line3");
+ }
+ set
+ {
+ this.OnPropertyChanging("Address1_Line3");
+ this.SetAttributeValue("address1_line3", value);
+ this.OnPropertyChanged("Address1_Line3");
+ }
+ }
+
+ ///
+ /// Type the longitude value for the primary address for use in mapping and other applications.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("address1_longitude")]
+ public System.Nullable Address1_Longitude
+ {
+ get
+ {
+ return this.GetAttributeValue>("address1_longitude");
+ }
+ set
+ {
+ this.OnPropertyChanging("Address1_Longitude");
+ this.SetAttributeValue("address1_longitude", value);
+ this.OnPropertyChanged("Address1_Longitude");
+ }
+ }
+
+ ///
+ /// Type a descriptive name for the primary address, such as Corporate Headquarters.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("address1_name")]
+ public string Address1_Name
+ {
+ get
+ {
+ return this.GetAttributeValue("address1_name");
+ }
+ set
+ {
+ this.OnPropertyChanging("Address1_Name");
+ this.SetAttributeValue("address1_name", value);
+ this.OnPropertyChanged("Address1_Name");
+ }
+ }
+
+ ///
+ /// Type the ZIP Code or postal code for the primary address.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("address1_postalcode")]
+ public string Address1_PostalCode
+ {
+ get
+ {
+ return this.GetAttributeValue("address1_postalcode");
+ }
+ set
+ {
+ this.OnPropertyChanging("Address1_PostalCode");
+ this.SetAttributeValue("address1_postalcode", value);
+ this.OnPropertyChanged("Address1_PostalCode");
+ }
+ }
+
+ ///
+ /// Type the post office box number of the primary address.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("address1_postofficebox")]
+ public string Address1_PostOfficeBox
+ {
+ get
+ {
+ return this.GetAttributeValue("address1_postofficebox");
+ }
+ set
+ {
+ this.OnPropertyChanging("Address1_PostOfficeBox");
+ this.SetAttributeValue("address1_postofficebox", value);
+ this.OnPropertyChanged("Address1_PostOfficeBox");
+ }
+ }
+
+ ///
+ /// Type the name of the main contact at the account's primary address.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("address1_primarycontactname")]
+ public string Address1_PrimaryContactName
+ {
+ get
+ {
+ return this.GetAttributeValue("address1_primarycontactname");
+ }
+ set
+ {
+ this.OnPropertyChanging("Address1_PrimaryContactName");
+ this.SetAttributeValue("address1_primarycontactname", value);
+ this.OnPropertyChanged("Address1_PrimaryContactName");
+ }
+ }
+
+ ///
+ /// Select a shipping method for deliveries sent to this address.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("address1_shippingmethodcode")]
+ public Microsoft.Xrm.Sdk.OptionSetValue Address1_ShippingMethodCode
+ {
+ get
+ {
+ return this.GetAttributeValue("address1_shippingmethodcode");
+ }
+ set
+ {
+ this.OnPropertyChanging("Address1_ShippingMethodCode");
+ this.SetAttributeValue("address1_shippingmethodcode", value);
+ this.OnPropertyChanged("Address1_ShippingMethodCode");
+ }
+ }
+
+ ///
+ /// Type the state or province of the primary address.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("address1_stateorprovince")]
+ public string Address1_StateOrProvince
+ {
+ get
+ {
+ return this.GetAttributeValue("address1_stateorprovince");
+ }
+ set
+ {
+ this.OnPropertyChanging("Address1_StateOrProvince");
+ this.SetAttributeValue("address1_stateorprovince", value);
+ this.OnPropertyChanged("Address1_StateOrProvince");
+ }
+ }
+
+ ///
+ /// Type the main phone number associated with the primary address.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("address1_telephone1")]
+ public string Address1_Telephone1
+ {
+ get
+ {
+ return this.GetAttributeValue("address1_telephone1");
+ }
+ set
+ {
+ this.OnPropertyChanging("Address1_Telephone1");
+ this.SetAttributeValue("address1_telephone1", value);
+ this.OnPropertyChanged("Address1_Telephone1");
+ }
+ }
+
+ ///
+ /// Type a second phone number associated with the primary address.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("address1_telephone2")]
+ public string Address1_Telephone2
+ {
+ get
+ {
+ return this.GetAttributeValue("address1_telephone2");
+ }
+ set
+ {
+ this.OnPropertyChanging("Address1_Telephone2");
+ this.SetAttributeValue("address1_telephone2", value);
+ this.OnPropertyChanged("Address1_Telephone2");
+ }
+ }
+
+ ///
+ /// Type a third phone number associated with the primary address.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("address1_telephone3")]
+ public string Address1_Telephone3
+ {
+ get
+ {
+ return this.GetAttributeValue("address1_telephone3");
+ }
+ set
+ {
+ this.OnPropertyChanging("Address1_Telephone3");
+ this.SetAttributeValue("address1_telephone3", value);
+ this.OnPropertyChanged("Address1_Telephone3");
+ }
+ }
+
+ ///
+ /// Type the UPS zone of the primary address to make sure shipping charges are calculated correctly and deliveries are made promptly, if shipped by UPS.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("address1_upszone")]
+ public string Address1_UPSZone
+ {
+ get
+ {
+ return this.GetAttributeValue("address1_upszone");
+ }
+ set
+ {
+ this.OnPropertyChanging("Address1_UPSZone");
+ this.SetAttributeValue("address1_upszone", value);
+ this.OnPropertyChanged("Address1_UPSZone");
+ }
+ }
+
+ ///
+ /// Select the time zone, or UTC offset, for this address so that other people can reference it when they contact someone at this address.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("address1_utcoffset")]
+ public System.Nullable Address1_UTCOffset
+ {
+ get
+ {
+ return this.GetAttributeValue>("address1_utcoffset");
+ }
+ set
+ {
+ this.OnPropertyChanging("Address1_UTCOffset");
+ this.SetAttributeValue("address1_utcoffset", value);
+ this.OnPropertyChanged("Address1_UTCOffset");
+ }
+ }
+
+ ///
+ /// Unique identifier for address 2.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("address2_addressid")]
+ public System.Nullable Address2_AddressId
+ {
+ get
+ {
+ return this.GetAttributeValue>("address2_addressid");
+ }
+ set
+ {
+ this.OnPropertyChanging("Address2_AddressId");
+ this.SetAttributeValue("address2_addressid", value);
+ this.OnPropertyChanged("Address2_AddressId");
+ }
+ }
+
+ ///
+ /// Select the secondary address type.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("address2_addresstypecode")]
+ public Microsoft.Xrm.Sdk.OptionSetValue Address2_AddressTypeCode
+ {
+ get
+ {
+ return this.GetAttributeValue("address2_addresstypecode");
+ }
+ set
+ {
+ this.OnPropertyChanging("Address2_AddressTypeCode");
+ this.SetAttributeValue("address2_addresstypecode", value);
+ this.OnPropertyChanged("Address2_AddressTypeCode");
+ }
+ }
+
+ ///
+ /// Type the city for the secondary address.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("address2_city")]
+ public string Address2_City
+ {
+ get
+ {
+ return this.GetAttributeValue("address2_city");
+ }
+ set
+ {
+ this.OnPropertyChanging("Address2_City");
+ this.SetAttributeValue("address2_city", value);
+ this.OnPropertyChanged("Address2_City");
+ }
+ }
+
+ ///
+ /// Shows the complete secondary address.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("address2_composite")]
+ public string Address2_Composite
+ {
+ get
+ {
+ return this.GetAttributeValue("address2_composite");
+ }
+ }
+
+ ///
+ /// Type the country or region for the secondary address.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("address2_country")]
+ public string Address2_Country
+ {
+ get
+ {
+ return this.GetAttributeValue("address2_country");
+ }
+ set
+ {
+ this.OnPropertyChanging("Address2_Country");
+ this.SetAttributeValue("address2_country", value);
+ this.OnPropertyChanged("Address2_Country");
+ }
+ }
+
+ ///
+ /// Type the county for the secondary address.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("address2_county")]
+ public string Address2_County
+ {
+ get
+ {
+ return this.GetAttributeValue("address2_county");
+ }
+ set
+ {
+ this.OnPropertyChanging("Address2_County");
+ this.SetAttributeValue("address2_county", value);
+ this.OnPropertyChanged("Address2_County");
+ }
+ }
+
+ ///
+ /// Type the fax number associated with the secondary address.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("address2_fax")]
+ public string Address2_Fax
+ {
+ get
+ {
+ return this.GetAttributeValue("address2_fax");
+ }
+ set
+ {
+ this.OnPropertyChanging("Address2_Fax");
+ this.SetAttributeValue("address2_fax", value);
+ this.OnPropertyChanged("Address2_Fax");
+ }
+ }
+
+ ///
+ /// Select the freight terms for the secondary address to make sure shipping orders are processed correctly.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("address2_freighttermscode")]
+ public Microsoft.Xrm.Sdk.OptionSetValue Address2_FreightTermsCode
+ {
+ get
+ {
+ return this.GetAttributeValue("address2_freighttermscode");
+ }
+ set
+ {
+ this.OnPropertyChanging("Address2_FreightTermsCode");
+ this.SetAttributeValue("address2_freighttermscode", value);
+ this.OnPropertyChanged("Address2_FreightTermsCode");
+ }
+ }
+
+ ///
+ /// Type the latitude value for the secondary address for use in mapping and other applications.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("address2_latitude")]
+ public System.Nullable Address2_Latitude
+ {
+ get
+ {
+ return this.GetAttributeValue>("address2_latitude");
+ }
+ set
+ {
+ this.OnPropertyChanging("Address2_Latitude");
+ this.SetAttributeValue("address2_latitude", value);
+ this.OnPropertyChanged("Address2_Latitude");
+ }
+ }
+
+ ///
+ /// Type the first line of the secondary address.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("address2_line1")]
+ public string Address2_Line1
+ {
+ get
+ {
+ return this.GetAttributeValue("address2_line1");
+ }
+ set
+ {
+ this.OnPropertyChanging("Address2_Line1");
+ this.SetAttributeValue("address2_line1", value);
+ this.OnPropertyChanged("Address2_Line1");
+ }
+ }
+
+ ///
+ /// Type the second line of the secondary address.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("address2_line2")]
+ public string Address2_Line2
+ {
+ get
+ {
+ return this.GetAttributeValue("address2_line2");
+ }
+ set
+ {
+ this.OnPropertyChanging("Address2_Line2");
+ this.SetAttributeValue("address2_line2", value);
+ this.OnPropertyChanged("Address2_Line2");
+ }
+ }
+
+ ///
+ /// Type the third line of the secondary address.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("address2_line3")]
+ public string Address2_Line3
+ {
+ get
+ {
+ return this.GetAttributeValue("address2_line3");
+ }
+ set
+ {
+ this.OnPropertyChanging("Address2_Line3");
+ this.SetAttributeValue("address2_line3", value);
+ this.OnPropertyChanged("Address2_Line3");
+ }
+ }
+
+ ///
+ /// Type the longitude value for the secondary address for use in mapping and other applications.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("address2_longitude")]
+ public System.Nullable Address2_Longitude
+ {
+ get
+ {
+ return this.GetAttributeValue>("address2_longitude");
+ }
+ set
+ {
+ this.OnPropertyChanging("Address2_Longitude");
+ this.SetAttributeValue("address2_longitude", value);
+ this.OnPropertyChanged("Address2_Longitude");
+ }
+ }
+
+ ///
+ /// Type a descriptive name for the secondary address, such as Corporate Headquarters.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("address2_name")]
+ public string Address2_Name
+ {
+ get
+ {
+ return this.GetAttributeValue("address2_name");
+ }
+ set
+ {
+ this.OnPropertyChanging("Address2_Name");
+ this.SetAttributeValue("address2_name", value);
+ this.OnPropertyChanged("Address2_Name");
+ }
+ }
+
+ ///
+ /// Type the ZIP Code or postal code for the secondary address.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("address2_postalcode")]
+ public string Address2_PostalCode
+ {
+ get
+ {
+ return this.GetAttributeValue("address2_postalcode");
+ }
+ set
+ {
+ this.OnPropertyChanging("Address2_PostalCode");
+ this.SetAttributeValue("address2_postalcode", value);
+ this.OnPropertyChanged("Address2_PostalCode");
+ }
+ }
+
+ ///
+ /// Type the post office box number of the secondary address.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("address2_postofficebox")]
+ public string Address2_PostOfficeBox
+ {
+ get
+ {
+ return this.GetAttributeValue("address2_postofficebox");
+ }
+ set
+ {
+ this.OnPropertyChanging("Address2_PostOfficeBox");
+ this.SetAttributeValue("address2_postofficebox", value);
+ this.OnPropertyChanged("Address2_PostOfficeBox");
+ }
+ }
+
+ ///
+ /// Type the name of the main contact at the account's secondary address.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("address2_primarycontactname")]
+ public string Address2_PrimaryContactName
+ {
+ get
+ {
+ return this.GetAttributeValue("address2_primarycontactname");
+ }
+ set
+ {
+ this.OnPropertyChanging("Address2_PrimaryContactName");
+ this.SetAttributeValue("address2_primarycontactname", value);
+ this.OnPropertyChanged("Address2_PrimaryContactName");
+ }
+ }
+
+ ///
+ /// Select a shipping method for deliveries sent to this address.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("address2_shippingmethodcode")]
+ public Microsoft.Xrm.Sdk.OptionSetValue Address2_ShippingMethodCode
+ {
+ get
+ {
+ return this.GetAttributeValue("address2_shippingmethodcode");
+ }
+ set
+ {
+ this.OnPropertyChanging("Address2_ShippingMethodCode");
+ this.SetAttributeValue("address2_shippingmethodcode", value);
+ this.OnPropertyChanged("Address2_ShippingMethodCode");
+ }
+ }
+
+ ///
+ /// Type the state or province of the secondary address.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("address2_stateorprovince")]
+ public string Address2_StateOrProvince
+ {
+ get
+ {
+ return this.GetAttributeValue("address2_stateorprovince");
+ }
+ set
+ {
+ this.OnPropertyChanging("Address2_StateOrProvince");
+ this.SetAttributeValue("address2_stateorprovince", value);
+ this.OnPropertyChanged("Address2_StateOrProvince");
+ }
+ }
+
+ ///
+ /// Type the main phone number associated with the secondary address.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("address2_telephone1")]
+ public string Address2_Telephone1
+ {
+ get
+ {
+ return this.GetAttributeValue("address2_telephone1");
+ }
+ set
+ {
+ this.OnPropertyChanging("Address2_Telephone1");
+ this.SetAttributeValue("address2_telephone1", value);
+ this.OnPropertyChanged("Address2_Telephone1");
+ }
+ }
+
+ ///
+ /// Type a second phone number associated with the secondary address.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("address2_telephone2")]
+ public string Address2_Telephone2
+ {
+ get
+ {
+ return this.GetAttributeValue("address2_telephone2");
+ }
+ set
+ {
+ this.OnPropertyChanging("Address2_Telephone2");
+ this.SetAttributeValue("address2_telephone2", value);
+ this.OnPropertyChanged("Address2_Telephone2");
+ }
+ }
+
+ ///
+ /// Type a third phone number associated with the secondary address.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("address2_telephone3")]
+ public string Address2_Telephone3
+ {
+ get
+ {
+ return this.GetAttributeValue("address2_telephone3");
+ }
+ set
+ {
+ this.OnPropertyChanging("Address2_Telephone3");
+ this.SetAttributeValue("address2_telephone3", value);
+ this.OnPropertyChanged("Address2_Telephone3");
+ }
+ }
+
+ ///
+ /// Type the UPS zone of the secondary address to make sure shipping charges are calculated correctly and deliveries are made promptly, if shipped by UPS.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("address2_upszone")]
+ public string Address2_UPSZone
+ {
+ get
+ {
+ return this.GetAttributeValue("address2_upszone");
+ }
+ set
+ {
+ this.OnPropertyChanging("Address2_UPSZone");
+ this.SetAttributeValue("address2_upszone", value);
+ this.OnPropertyChanged("Address2_UPSZone");
+ }
+ }
+
+ ///
+ /// Select the time zone, or UTC offset, for this address so that other people can reference it when they contact someone at this address.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("address2_utcoffset")]
+ public System.Nullable Address2_UTCOffset
+ {
+ get
+ {
+ return this.GetAttributeValue>("address2_utcoffset");
+ }
+ set
+ {
+ this.OnPropertyChanging("Address2_UTCOffset");
+ this.SetAttributeValue("address2_utcoffset", value);
+ this.OnPropertyChanged("Address2_UTCOffset");
+ }
+ }
+
+ ///
+ /// For system use only.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("aging30")]
+ public Microsoft.Xrm.Sdk.Money Aging30
+ {
+ get
+ {
+ return this.GetAttributeValue("aging30");
+ }
+ }
+
+ ///
+ /// The base currency equivalent of the aging 30 field.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("aging30_base")]
+ public Microsoft.Xrm.Sdk.Money Aging30_Base
+ {
+ get
+ {
+ return this.GetAttributeValue("aging30_base");
+ }
+ }
+
+ ///
+ /// For system use only.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("aging60")]
+ public Microsoft.Xrm.Sdk.Money Aging60
+ {
+ get
+ {
+ return this.GetAttributeValue("aging60");
+ }
+ }
+
+ ///
+ /// The base currency equivalent of the aging 60 field.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("aging60_base")]
+ public Microsoft.Xrm.Sdk.Money Aging60_Base
+ {
+ get
+ {
+ return this.GetAttributeValue("aging60_base");
+ }
+ }
+
+ ///
+ /// For system use only.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("aging90")]
+ public Microsoft.Xrm.Sdk.Money Aging90
+ {
+ get
+ {
+ return this.GetAttributeValue("aging90");
+ }
+ }
+
+ ///
+ /// The base currency equivalent of the aging 90 field.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("aging90_base")]
+ public Microsoft.Xrm.Sdk.Money Aging90_Base
+ {
+ get
+ {
+ return this.GetAttributeValue("aging90_base");
+ }
+ }
+
+ ///
+ /// Select the legal designation or other business type of the account for contracts or reporting purposes.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("businesstypecode")]
+ public Microsoft.Xrm.Sdk.OptionSetValue BusinessTypeCode
+ {
+ get
+ {
+ return this.GetAttributeValue("businesstypecode");
+ }
+ set
+ {
+ this.OnPropertyChanging("BusinessTypeCode");
+ this.SetAttributeValue("businesstypecode", value);
+ this.OnPropertyChanged("BusinessTypeCode");
+ }
+ }
+
+ ///
+ /// Shows who created the record.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("createdby")]
+ public Microsoft.Xrm.Sdk.EntityReference CreatedBy
+ {
+ get
+ {
+ return this.GetAttributeValue("createdby");
+ }
+ }
+
+ ///
+ /// Shows the date and time when the record was created. The date and time are displayed in the time zone selected in Microsoft Dynamics CRM options.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("createdon")]
+ public System.Nullable CreatedOn
+ {
+ get
+ {
+ return this.GetAttributeValue>("createdon");
+ }
+ }
+
+ ///
+ /// Shows who created the record on behalf of another user.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("createdonbehalfby")]
+ public Microsoft.Xrm.Sdk.EntityReference CreatedOnBehalfBy
+ {
+ get
+ {
+ return this.GetAttributeValue("createdonbehalfby");
+ }
+ }
+
+ ///
+ /// Type the credit limit of the account. This is a useful reference when you address invoice and accounting issues with the customer.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("creditlimit")]
+ public Microsoft.Xrm.Sdk.Money CreditLimit
+ {
+ get
+ {
+ return this.GetAttributeValue("creditlimit");
+ }
+ set
+ {
+ this.OnPropertyChanging("CreditLimit");
+ this.SetAttributeValue("creditlimit", value);
+ this.OnPropertyChanged("CreditLimit");
+ }
+ }
+
+ ///
+ /// Shows the credit limit converted to the system's default base currency for reporting purposes.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("creditlimit_base")]
+ public Microsoft.Xrm.Sdk.Money CreditLimit_Base
+ {
+ get
+ {
+ return this.GetAttributeValue("creditlimit_base");
+ }
+ }
+
+ ///
+ /// Select whether the credit for the account is on hold. This is a useful reference while addressing the invoice and accounting issues with the customer.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("creditonhold")]
+ public System.Nullable CreditOnHold
+ {
+ get
+ {
+ return this.GetAttributeValue>("creditonhold");
+ }
+ set
+ {
+ this.OnPropertyChanging("CreditOnHold");
+ this.SetAttributeValue("creditonhold", value);
+ this.OnPropertyChanged("CreditOnHold");
+ }
+ }
+
+ ///
+ /// Select the size category or range of the account for segmentation and reporting purposes.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("customersizecode")]
+ public Microsoft.Xrm.Sdk.OptionSetValue CustomerSizeCode
+ {
+ get
+ {
+ return this.GetAttributeValue("customersizecode");
+ }
+ set
+ {
+ this.OnPropertyChanging("CustomerSizeCode");
+ this.SetAttributeValue("customersizecode", value);
+ this.OnPropertyChanged("CustomerSizeCode");
+ }
+ }
+
+ ///
+ /// Select the category that best describes the relationship between the account and your organization.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("customertypecode")]
+ public Microsoft.Xrm.Sdk.OptionSetValue CustomerTypeCode
+ {
+ get
+ {
+ return this.GetAttributeValue("customertypecode");
+ }
+ set
+ {
+ this.OnPropertyChanging("CustomerTypeCode");
+ this.SetAttributeValue("customertypecode", value);
+ this.OnPropertyChanged("CustomerTypeCode");
+ }
+ }
+
+ ///
+ /// Choose the default price list associated with the account to make sure the correct product prices for this customer are applied in sales opportunities, quotes, and orders.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("defaultpricelevelid")]
+ public Microsoft.Xrm.Sdk.EntityReference DefaultPriceLevelId
+ {
+ get
+ {
+ return this.GetAttributeValue("defaultpricelevelid");
+ }
+ set
+ {
+ this.OnPropertyChanging("DefaultPriceLevelId");
+ this.SetAttributeValue("defaultpricelevelid", value);
+ this.OnPropertyChanged("DefaultPriceLevelId");
+ }
+ }
+
+ ///
+ /// Type additional information to describe the account, such as an excerpt from the company's website.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("description")]
+ public string Description
+ {
+ get
+ {
+ return this.GetAttributeValue("description");
+ }
+ set
+ {
+ this.OnPropertyChanging("Description");
+ this.SetAttributeValue("description", value);
+ this.OnPropertyChanged("Description");
+ }
+ }
+
+ ///
+ /// Select whether the account allows bulk email sent through campaigns. If Do Not Allow is selected, the account can be added to marketing lists, but is excluded from email.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("donotbulkemail")]
+ public System.Nullable DoNotBulkEMail
+ {
+ get
+ {
+ return this.GetAttributeValue>("donotbulkemail");
+ }
+ set
+ {
+ this.OnPropertyChanging("DoNotBulkEMail");
+ this.SetAttributeValue("donotbulkemail", value);
+ this.OnPropertyChanged("DoNotBulkEMail");
+ }
+ }
+
+ ///
+ /// Select whether the account allows bulk postal mail sent through marketing campaigns or quick campaigns. If Do Not Allow is selected, the account can be added to marketing lists, but will be excluded from the postal mail.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("donotbulkpostalmail")]
+ public System.Nullable DoNotBulkPostalMail
+ {
+ get
+ {
+ return this.GetAttributeValue>("donotbulkpostalmail");
+ }
+ set
+ {
+ this.OnPropertyChanging("DoNotBulkPostalMail");
+ this.SetAttributeValue("donotbulkpostalmail", value);
+ this.OnPropertyChanged("DoNotBulkPostalMail");
+ }
+ }
+
+ ///
+ /// Select whether the account allows direct email sent from Microsoft Dynamics CRM.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("donotemail")]
+ public System.Nullable DoNotEMail
+ {
+ get
+ {
+ return this.GetAttributeValue>("donotemail");
+ }
+ set
+ {
+ this.OnPropertyChanging("DoNotEMail");
+ this.SetAttributeValue("donotemail", value);
+ this.OnPropertyChanged("DoNotEMail");
+ }
+ }
+
+ ///
+ /// Select whether the account allows faxes. If Do Not Allow is selected, the account will be excluded from fax activities distributed in marketing campaigns.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("donotfax")]
+ public System.Nullable DoNotFax
+ {
+ get
+ {
+ return this.GetAttributeValue>("donotfax");
+ }
+ set
+ {
+ this.OnPropertyChanging("DoNotFax");
+ this.SetAttributeValue("donotfax", value);
+ this.OnPropertyChanged("DoNotFax");
+ }
+ }
+
+ ///
+ /// Select whether the account allows phone calls. If Do Not Allow is selected, the account will be excluded from phone call activities distributed in marketing campaigns.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("donotphone")]
+ public System.Nullable DoNotPhone
+ {
+ get
+ {
+ return this.GetAttributeValue>("donotphone");
+ }
+ set
+ {
+ this.OnPropertyChanging("DoNotPhone");
+ this.SetAttributeValue("donotphone", value);
+ this.OnPropertyChanged("DoNotPhone");
+ }
+ }
+
+ ///
+ /// Select whether the account allows direct mail. If Do Not Allow is selected, the account will be excluded from letter activities distributed in marketing campaigns.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("donotpostalmail")]
+ public System.Nullable DoNotPostalMail
+ {
+ get
+ {
+ return this.GetAttributeValue>("donotpostalmail");
+ }
+ set
+ {
+ this.OnPropertyChanging("DoNotPostalMail");
+ this.SetAttributeValue("donotpostalmail", value);
+ this.OnPropertyChanged("DoNotPostalMail");
+ }
+ }
+
+ ///
+ /// Select whether the account accepts marketing materials, such as brochures or catalogs.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("donotsendmm")]
+ public System.Nullable DoNotSendMM
+ {
+ get
+ {
+ return this.GetAttributeValue>("donotsendmm");
+ }
+ set
+ {
+ this.OnPropertyChanging("DoNotSendMM");
+ this.SetAttributeValue("donotsendmm", value);
+ this.OnPropertyChanged("DoNotSendMM");
+ }
+ }
+
+ ///
+ /// Type the primary email address for the account.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("emailaddress1")]
+ public string EMailAddress1
+ {
+ get
+ {
+ return this.GetAttributeValue("emailaddress1");
+ }
+ set
+ {
+ this.OnPropertyChanging("EMailAddress1");
+ this.SetAttributeValue("emailaddress1", value);
+ this.OnPropertyChanged("EMailAddress1");
+ }
+ }
+
+ ///
+ /// Type the secondary email address for the account.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("emailaddress2")]
+ public string EMailAddress2
+ {
+ get
+ {
+ return this.GetAttributeValue("emailaddress2");
+ }
+ set
+ {
+ this.OnPropertyChanging("EMailAddress2");
+ this.SetAttributeValue("emailaddress2", value);
+ this.OnPropertyChanged("EMailAddress2");
+ }
+ }
+
+ ///
+ /// Type an alternate email address for the account.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("emailaddress3")]
+ public string EMailAddress3
+ {
+ get
+ {
+ return this.GetAttributeValue("emailaddress3");
+ }
+ set
+ {
+ this.OnPropertyChanging("EMailAddress3");
+ this.SetAttributeValue("emailaddress3", value);
+ this.OnPropertyChanged("EMailAddress3");
+ }
+ }
+
+ ///
+ /// Shows the default image for the record.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("entityimage")]
+ public byte[] EntityImage
+ {
+ get
+ {
+ return this.GetAttributeValue("entityimage");
+ }
+ set
+ {
+ this.OnPropertyChanging("EntityImage");
+ this.SetAttributeValue("entityimage", value);
+ this.OnPropertyChanged("EntityImage");
+ }
+ }
+
+ ///
+ ///
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("entityimage_timestamp")]
+ public System.Nullable EntityImage_Timestamp
+ {
+ get
+ {
+ return this.GetAttributeValue>("entityimage_timestamp");
+ }
+ }
+
+ ///
+ ///
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("entityimage_url")]
+ public string EntityImage_URL
+ {
+ get
+ {
+ return this.GetAttributeValue("entityimage_url");
+ }
+ }
+
+ ///
+ /// For internal use only.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("entityimageid")]
+ public System.Nullable EntityImageId
+ {
+ get
+ {
+ return this.GetAttributeValue>("entityimageid");
+ }
+ }
+
+ ///
+ /// Shows the conversion rate of the record's currency. The exchange rate is used to convert all money fields in the record from the local currency to the system's default currency.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("exchangerate")]
+ public System.Nullable ExchangeRate
+ {
+ get
+ {
+ return this.GetAttributeValue>("exchangerate");
+ }
+ }
+
+ ///
+ /// Type the fax number for the account.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("fax")]
+ public string Fax
+ {
+ get
+ {
+ return this.GetAttributeValue("fax");
+ }
+ set
+ {
+ this.OnPropertyChanging("Fax");
+ this.SetAttributeValue("fax", value);
+ this.OnPropertyChanged("Fax");
+ }
+ }
+
+ ///
+ /// Type the URL for the account's FTP site to enable users to access data and share documents.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("ftpsiteurl")]
+ public string FtpSiteURL
+ {
+ get
+ {
+ return this.GetAttributeValue("ftpsiteurl");
+ }
+ set
+ {
+ this.OnPropertyChanging("FtpSiteURL");
+ this.SetAttributeValue("ftpsiteurl", value);
+ this.OnPropertyChanged("FtpSiteURL");
+ }
+ }
+
+ ///
+ /// Unique identifier of the data import or data migration that created this record.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("importsequencenumber")]
+ public System.Nullable ImportSequenceNumber
+ {
+ get
+ {
+ return this.GetAttributeValue>("importsequencenumber");
+ }
+ set
+ {
+ this.OnPropertyChanging("ImportSequenceNumber");
+ this.SetAttributeValue("importsequencenumber", value);
+ this.OnPropertyChanged("ImportSequenceNumber");
+ }
+ }
+
+ ///
+ /// Select the account's primary industry for use in marketing segmentation and demographic analysis.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("industrycode")]
+ public Microsoft.Xrm.Sdk.OptionSetValue IndustryCode
+ {
+ get
+ {
+ return this.GetAttributeValue("industrycode");
+ }
+ set
+ {
+ this.OnPropertyChanging("IndustryCode");
+ this.SetAttributeValue("industrycode", value);
+ this.OnPropertyChanged("IndustryCode");
+ }
+ }
+
+ ///
+ /// Shows the date when the account was last included in a marketing campaign or quick campaign.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("lastusedincampaign")]
+ public System.Nullable LastUsedInCampaign
+ {
+ get
+ {
+ return this.GetAttributeValue>("lastusedincampaign");
+ }
+ set
+ {
+ this.OnPropertyChanging("LastUsedInCampaign");
+ this.SetAttributeValue("lastusedincampaign", value);
+ this.OnPropertyChanged("LastUsedInCampaign");
+ }
+ }
+
+ ///
+ /// Type the market capitalization of the account to identify the company's equity, used as an indicator in financial performance analysis.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("marketcap")]
+ public Microsoft.Xrm.Sdk.Money MarketCap
+ {
+ get
+ {
+ return this.GetAttributeValue("marketcap");
+ }
+ set
+ {
+ this.OnPropertyChanging("MarketCap");
+ this.SetAttributeValue("marketcap", value);
+ this.OnPropertyChanged("MarketCap");
+ }
+ }
+
+ ///
+ /// Shows the market capitalization converted to the system's default base currency.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("marketcap_base")]
+ public Microsoft.Xrm.Sdk.Money MarketCap_Base
+ {
+ get
+ {
+ return this.GetAttributeValue("marketcap_base");
+ }
+ }
+
+ ///
+ /// Shows the master account that the account was merged with.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("masterid")]
+ public Microsoft.Xrm.Sdk.EntityReference MasterId
+ {
+ get
+ {
+ return this.GetAttributeValue("masterid");
+ }
+ }
+
+ ///
+ /// Shows whether the account has been merged with another account.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("merged")]
+ public System.Nullable Merged
+ {
+ get
+ {
+ return this.GetAttributeValue>("merged");
+ }
+ }
+
+ ///
+ /// Shows who last updated the record.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("modifiedby")]
+ public Microsoft.Xrm.Sdk.EntityReference ModifiedBy
+ {
+ get
+ {
+ return this.GetAttributeValue("modifiedby");
+ }
+ }
+
+ ///
+ /// Shows the date and time when the record was last updated. The date and time are displayed in the time zone selected in Microsoft Dynamics CRM options.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("modifiedon")]
+ public System.Nullable ModifiedOn
+ {
+ get
+ {
+ return this.GetAttributeValue>("modifiedon");
+ }
+ }
+
+ ///
+ /// Shows who created the record on behalf of another user.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("modifiedonbehalfby")]
+ public Microsoft.Xrm.Sdk.EntityReference ModifiedOnBehalfBy
+ {
+ get
+ {
+ return this.GetAttributeValue("modifiedonbehalfby");
+ }
+ }
+
+ ///
+ /// Type the company or business name.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("name")]
+ public string Name
+ {
+ get
+ {
+ return this.GetAttributeValue("name");
+ }
+ set
+ {
+ this.OnPropertyChanging("Name");
+ this.SetAttributeValue("name", value);
+ this.OnPropertyChanged("Name");
+ }
+ }
+
+ ///
+ /// Type the number of employees that work at the account for use in marketing segmentation and demographic analysis.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("numberofemployees")]
+ public System.Nullable NumberOfEmployees
+ {
+ get
+ {
+ return this.GetAttributeValue>("numberofemployees");
+ }
+ set
+ {
+ this.OnPropertyChanging("NumberOfEmployees");
+ this.SetAttributeValue("numberofemployees", value);
+ this.OnPropertyChanged("NumberOfEmployees");
+ }
+ }
+
+ ///
+ /// Number of open opportunities against an account and its child accounts.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("opendeals")]
+ public System.Nullable OpenDeals
+ {
+ get
+ {
+ return this.GetAttributeValue>("opendeals");
+ }
+ }
+
+ ///
+ /// The date time for Open Deals.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("opendeals_date")]
+ public System.Nullable OpenDeals_Date
+ {
+ get
+ {
+ return this.GetAttributeValue>("opendeals_date");
+ }
+ }
+
+ ///
+ /// State of Open Deals.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("opendeals_state")]
+ public System.Nullable OpenDeals_State
+ {
+ get
+ {
+ return this.GetAttributeValue>("opendeals_state");
+ }
+ }
+
+ ///
+ /// Sum of open revenue against an account and its child accounts.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("openrevenue")]
+ public Microsoft.Xrm.Sdk.Money OpenRevenue
+ {
+ get
+ {
+ return this.GetAttributeValue("openrevenue");
+ }
+ }
+
+ ///
+ /// Sum of open revenue against an account and its child accounts.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("openrevenue_base")]
+ public Microsoft.Xrm.Sdk.Money OpenRevenue_Base
+ {
+ get
+ {
+ return this.GetAttributeValue("openrevenue_base");
+ }
+ }
+
+ ///
+ /// The date time for Open Revenue.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("openrevenue_date")]
+ public System.Nullable OpenRevenue_Date
+ {
+ get
+ {
+ return this.GetAttributeValue>("openrevenue_date");
+ }
+ }
+
+ ///
+ /// State of Open Revenue.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("openrevenue_state")]
+ public System.Nullable OpenRevenue_State
+ {
+ get
+ {
+ return this.GetAttributeValue>("openrevenue_state");
+ }
+ }
+
+ ///
+ /// Shows the lead that the account was created from if the account was created by converting a lead in Microsoft Dynamics CRM. This is used to relate the account to data on the originating lead for use in reporting and analytics.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("originatingleadid")]
+ public Microsoft.Xrm.Sdk.EntityReference OriginatingLeadId
+ {
+ get
+ {
+ return this.GetAttributeValue("originatingleadid");
+ }
+ set
+ {
+ this.OnPropertyChanging("OriginatingLeadId");
+ this.SetAttributeValue("originatingleadid", value);
+ this.OnPropertyChanged("OriginatingLeadId");
+ }
+ }
+
+ ///
+ /// Date and time that the record was migrated.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("overriddencreatedon")]
+ public System.Nullable OverriddenCreatedOn
+ {
+ get
+ {
+ return this.GetAttributeValue>("overriddencreatedon");
+ }
+ set
+ {
+ this.OnPropertyChanging("OverriddenCreatedOn");
+ this.SetAttributeValue("overriddencreatedon", value);
+ this.OnPropertyChanged("OverriddenCreatedOn");
+ }
+ }
+
+ ///
+ /// Enter the user or team who is assigned to manage the record. This field is updated every time the record is assigned to a different user.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("ownerid")]
+ public Microsoft.Xrm.Sdk.EntityReference OwnerId
+ {
+ get
+ {
+ return this.GetAttributeValue("ownerid");
+ }
+ set
+ {
+ this.OnPropertyChanging("OwnerId");
+ this.SetAttributeValue("ownerid", value);
+ this.OnPropertyChanged("OwnerId");
+ }
+ }
+
+ ///
+ /// Select the account's ownership structure, such as public or private.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("ownershipcode")]
+ public Microsoft.Xrm.Sdk.OptionSetValue OwnershipCode
+ {
+ get
+ {
+ return this.GetAttributeValue("ownershipcode");
+ }
+ set
+ {
+ this.OnPropertyChanging("OwnershipCode");
+ this.SetAttributeValue("ownershipcode", value);
+ this.OnPropertyChanged("OwnershipCode");
+ }
+ }
+
+ ///
+ /// Shows the business unit that the record owner belongs to.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("owningbusinessunit")]
+ public Microsoft.Xrm.Sdk.EntityReference OwningBusinessUnit
+ {
+ get
+ {
+ return this.GetAttributeValue("owningbusinessunit");
+ }
+ }
+
+ ///
+ /// Unique identifier of the team who owns the account.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("owningteam")]
+ public Microsoft.Xrm.Sdk.EntityReference OwningTeam
+ {
+ get
+ {
+ return this.GetAttributeValue("owningteam");
+ }
+ }
+
+ ///
+ /// Unique identifier of the user who owns the account.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("owninguser")]
+ public Microsoft.Xrm.Sdk.EntityReference OwningUser
+ {
+ get
+ {
+ return this.GetAttributeValue("owninguser");
+ }
+ }
+
+ ///
+ /// Choose the parent account associated with this account to show parent and child businesses in reporting and analytics.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("parentaccountid")]
+ public Microsoft.Xrm.Sdk.EntityReference ParentAccountId
+ {
+ get
+ {
+ return this.GetAttributeValue("parentaccountid");
+ }
+ set
+ {
+ this.OnPropertyChanging("ParentAccountId");
+ this.SetAttributeValue("parentaccountid", value);
+ this.OnPropertyChanged("ParentAccountId");
+ }
+ }
+
+ ///
+ /// For system use only. Legacy Microsoft Dynamics CRM 3.0 workflow data.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("participatesinworkflow")]
+ public System.Nullable ParticipatesInWorkflow
+ {
+ get
+ {
+ return this.GetAttributeValue>("participatesinworkflow");
+ }
+ set
+ {
+ this.OnPropertyChanging("ParticipatesInWorkflow");
+ this.SetAttributeValue("participatesinworkflow", value);
+ this.OnPropertyChanged("ParticipatesInWorkflow");
+ }
+ }
+
+ ///
+ /// Select the payment terms to indicate when the customer needs to pay the total amount.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("paymenttermscode")]
+ public Microsoft.Xrm.Sdk.OptionSetValue PaymentTermsCode
+ {
+ get
+ {
+ return this.GetAttributeValue("paymenttermscode");
+ }
+ set
+ {
+ this.OnPropertyChanging("PaymentTermsCode");
+ this.SetAttributeValue("paymenttermscode", value);
+ this.OnPropertyChanged("PaymentTermsCode");
+ }
+ }
+
+ ///
+ /// Select the preferred day of the week for service appointments.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("preferredappointmentdaycode")]
+ public Microsoft.Xrm.Sdk.OptionSetValue PreferredAppointmentDayCode
+ {
+ get
+ {
+ return this.GetAttributeValue("preferredappointmentdaycode");
+ }
+ set
+ {
+ this.OnPropertyChanging("PreferredAppointmentDayCode");
+ this.SetAttributeValue("preferredappointmentdaycode", value);
+ this.OnPropertyChanged("PreferredAppointmentDayCode");
+ }
+ }
+
+ ///
+ /// Select the preferred time of day for service appointments.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("preferredappointmenttimecode")]
+ public Microsoft.Xrm.Sdk.OptionSetValue PreferredAppointmentTimeCode
+ {
+ get
+ {
+ return this.GetAttributeValue("preferredappointmenttimecode");
+ }
+ set
+ {
+ this.OnPropertyChanging("PreferredAppointmentTimeCode");
+ this.SetAttributeValue("preferredappointmenttimecode", value);
+ this.OnPropertyChanged("PreferredAppointmentTimeCode");
+ }
+ }
+
+ ///
+ /// Select the preferred method of contact.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("preferredcontactmethodcode")]
+ public Microsoft.Xrm.Sdk.OptionSetValue PreferredContactMethodCode
+ {
+ get
+ {
+ return this.GetAttributeValue("preferredcontactmethodcode");
+ }
+ set
+ {
+ this.OnPropertyChanging("PreferredContactMethodCode");
+ this.SetAttributeValue("preferredcontactmethodcode", value);
+ this.OnPropertyChanged("PreferredContactMethodCode");
+ }
+ }
+
+ ///
+ /// Choose the account's preferred service facility or equipment to make sure services are scheduled correctly for the customer.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("preferredequipmentid")]
+ public Microsoft.Xrm.Sdk.EntityReference PreferredEquipmentId
+ {
+ get
+ {
+ return this.GetAttributeValue("preferredequipmentid");
+ }
+ set
+ {
+ this.OnPropertyChanging("PreferredEquipmentId");
+ this.SetAttributeValue("preferredequipmentid", value);
+ this.OnPropertyChanged("PreferredEquipmentId");
+ }
+ }
+
+ ///
+ /// Choose the account's preferred service for reference when you schedule service activities.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("preferredserviceid")]
+ public Microsoft.Xrm.Sdk.EntityReference PreferredServiceId
+ {
+ get
+ {
+ return this.GetAttributeValue("preferredserviceid");
+ }
+ set
+ {
+ this.OnPropertyChanging("PreferredServiceId");
+ this.SetAttributeValue("preferredserviceid", value);
+ this.OnPropertyChanged("PreferredServiceId");
+ }
+ }
+
+ ///
+ /// Choose the preferred service representative for reference when you schedule service activities for the account.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("preferredsystemuserid")]
+ public Microsoft.Xrm.Sdk.EntityReference PreferredSystemUserId
+ {
+ get
+ {
+ return this.GetAttributeValue("preferredsystemuserid");
+ }
+ set
+ {
+ this.OnPropertyChanging("PreferredSystemUserId");
+ this.SetAttributeValue("preferredsystemuserid", value);
+ this.OnPropertyChanged("PreferredSystemUserId");
+ }
+ }
+
+ ///
+ /// Choose the primary contact for the account to provide quick access to contact details.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("primarycontactid")]
+ public Microsoft.Xrm.Sdk.EntityReference PrimaryContactId
+ {
+ get
+ {
+ return this.GetAttributeValue("primarycontactid");
+ }
+ set
+ {
+ this.OnPropertyChanging("PrimaryContactId");
+ this.SetAttributeValue("primarycontactid", value);
+ this.OnPropertyChanged("PrimaryContactId");
+ }
+ }
+
+ ///
+ /// Shows the ID of the process.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("processid")]
+ public System.Nullable ProcessId
+ {
+ get
+ {
+ return this.GetAttributeValue>("processid");
+ }
+ set
+ {
+ this.OnPropertyChanging("ProcessId");
+ this.SetAttributeValue("processid", value);
+ this.OnPropertyChanged("ProcessId");
+ }
+ }
+
+ ///
+ /// Type the annual revenue for the account, used as an indicator in financial performance analysis.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("revenue")]
+ public Microsoft.Xrm.Sdk.Money Revenue
+ {
+ get
+ {
+ return this.GetAttributeValue("revenue");
+ }
+ set
+ {
+ this.OnPropertyChanging("Revenue");
+ this.SetAttributeValue("revenue", value);
+ this.OnPropertyChanged("Revenue");
+ }
+ }
+
+ ///
+ /// Shows the annual revenue converted to the system's default base currency. The calculations use the exchange rate specified in the Currencies area.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("revenue_base")]
+ public Microsoft.Xrm.Sdk.Money Revenue_Base
+ {
+ get
+ {
+ return this.GetAttributeValue("revenue_base");
+ }
+ }
+
+ ///
+ /// Type the number of shares available to the public for the account. This number is used as an indicator in financial performance analysis.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("sharesoutstanding")]
+ public System.Nullable SharesOutstanding
+ {
+ get
+ {
+ return this.GetAttributeValue>("sharesoutstanding");
+ }
+ set
+ {
+ this.OnPropertyChanging("SharesOutstanding");
+ this.SetAttributeValue("sharesoutstanding", value);
+ this.OnPropertyChanged("SharesOutstanding");
+ }
+ }
+
+ ///
+ /// Select a shipping method for deliveries sent to the account's address to designate the preferred carrier or other delivery option.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("shippingmethodcode")]
+ public Microsoft.Xrm.Sdk.OptionSetValue ShippingMethodCode
+ {
+ get
+ {
+ return this.GetAttributeValue("shippingmethodcode");
+ }
+ set
+ {
+ this.OnPropertyChanging("ShippingMethodCode");
+ this.SetAttributeValue("shippingmethodcode", value);
+ this.OnPropertyChanged("ShippingMethodCode");
+ }
+ }
+
+ ///
+ /// Type the Standard Industrial Classification (SIC) code that indicates the account's primary industry of business, for use in marketing segmentation and demographic analysis.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("sic")]
+ public string SIC
+ {
+ get
+ {
+ return this.GetAttributeValue("sic");
+ }
+ set
+ {
+ this.OnPropertyChanging("SIC");
+ this.SetAttributeValue("sic", value);
+ this.OnPropertyChanged("SIC");
+ }
+ }
+
+ ///
+ /// Shows the ID of the stage.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("stageid")]
+ public System.Nullable StageId
+ {
+ get
+ {
+ return this.GetAttributeValue>("stageid");
+ }
+ set
+ {
+ this.OnPropertyChanging("StageId");
+ this.SetAttributeValue("stageid", value);
+ this.OnPropertyChanged("StageId");
+ }
+ }
+
+ ///
+ /// Shows whether the account is active or inactive. Inactive accounts are read-only and can't be edited unless they are reactivated.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("statecode")]
+ public System.Nullable StateCode
+ {
+ get
+ {
+ Microsoft.Xrm.Sdk.OptionSetValue optionSet = this.GetAttributeValue("statecode");
+ if ((optionSet != null))
+ {
+ return ((AccountState)(System.Enum.ToObject(typeof(AccountState), optionSet.Value)));
+ }
+ else
+ {
+ return null;
+ }
+ }
+ }
+
+ ///
+ /// Select the account's status.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("statuscode")]
+ public Microsoft.Xrm.Sdk.OptionSetValue StatusCode
+ {
+ get
+ {
+ return this.GetAttributeValue("statuscode");
+ }
+ set
+ {
+ this.OnPropertyChanging("StatusCode");
+ this.SetAttributeValue("statuscode", value);
+ this.OnPropertyChanged("StatusCode");
+ }
+ }
+
+ ///
+ /// Type the stock exchange at which the account is listed to track their stock and financial performance of the company.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("stockexchange")]
+ public string StockExchange
+ {
+ get
+ {
+ return this.GetAttributeValue("stockexchange");
+ }
+ set
+ {
+ this.OnPropertyChanging("StockExchange");
+ this.SetAttributeValue("stockexchange", value);
+ this.OnPropertyChanged("StockExchange");
+ }
+ }
+
+ ///
+ /// Type the main phone number for this account.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("telephone1")]
+ public string Telephone1
+ {
+ get
+ {
+ return this.GetAttributeValue("telephone1");
+ }
+ set
+ {
+ this.OnPropertyChanging("Telephone1");
+ this.SetAttributeValue("telephone1", value);
+ this.OnPropertyChanged("Telephone1");
+ }
+ }
+
+ ///
+ /// Type a second phone number for this account.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("telephone2")]
+ public string Telephone2
+ {
+ get
+ {
+ return this.GetAttributeValue("telephone2");
+ }
+ set
+ {
+ this.OnPropertyChanging("Telephone2");
+ this.SetAttributeValue("telephone2", value);
+ this.OnPropertyChanged("Telephone2");
+ }
+ }
+
+ ///
+ /// Type a third phone number for this account.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("telephone3")]
+ public string Telephone3
+ {
+ get
+ {
+ return this.GetAttributeValue("telephone3");
+ }
+ set
+ {
+ this.OnPropertyChanging("Telephone3");
+ this.SetAttributeValue("telephone3", value);
+ this.OnPropertyChanged("Telephone3");
+ }
+ }
+
+ ///
+ /// Select a region or territory for the account for use in segmentation and analysis.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("territorycode")]
+ public Microsoft.Xrm.Sdk.OptionSetValue TerritoryCode
+ {
+ get
+ {
+ return this.GetAttributeValue("territorycode");
+ }
+ set
+ {
+ this.OnPropertyChanging("TerritoryCode");
+ this.SetAttributeValue("territorycode", value);
+ this.OnPropertyChanged("TerritoryCode");
+ }
+ }
+
+ ///
+ /// Choose the sales region or territory for the account to make sure the account is assigned to the correct representative and for use in segmentation and analysis.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("territoryid")]
+ public Microsoft.Xrm.Sdk.EntityReference TerritoryId
+ {
+ get
+ {
+ return this.GetAttributeValue("territoryid");
+ }
+ set
+ {
+ this.OnPropertyChanging("TerritoryId");
+ this.SetAttributeValue("territoryid", value);
+ this.OnPropertyChanged("TerritoryId");
+ }
+ }
+
+ ///
+ /// Type the stock exchange symbol for the account to track financial performance of the company. You can click the code entered in this field to access the latest trading information from MSN Money.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("tickersymbol")]
+ public string TickerSymbol
+ {
+ get
+ {
+ return this.GetAttributeValue("tickersymbol");
+ }
+ set
+ {
+ this.OnPropertyChanging("TickerSymbol");
+ this.SetAttributeValue("tickersymbol", value);
+ this.OnPropertyChanged("TickerSymbol");
+ }
+ }
+
+ ///
+ /// For internal use only.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("timezoneruleversionnumber")]
+ public System.Nullable TimeZoneRuleVersionNumber
+ {
+ get
+ {
+ return this.GetAttributeValue>("timezoneruleversionnumber");
+ }
+ set
+ {
+ this.OnPropertyChanging("TimeZoneRuleVersionNumber");
+ this.SetAttributeValue("timezoneruleversionnumber", value);
+ this.OnPropertyChanged("TimeZoneRuleVersionNumber");
+ }
+ }
+
+ ///
+ /// Choose the local currency for the record to make sure budgets are reported in the correct currency.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("transactioncurrencyid")]
+ public Microsoft.Xrm.Sdk.EntityReference TransactionCurrencyId
+ {
+ get
+ {
+ return this.GetAttributeValue("transactioncurrencyid");
+ }
+ set
+ {
+ this.OnPropertyChanging("TransactionCurrencyId");
+ this.SetAttributeValue("transactioncurrencyid", value);
+ this.OnPropertyChanged("TransactionCurrencyId");
+ }
+ }
+
+ ///
+ /// A comma separated list of string values representing the unique identifiers of stages in a Business Process Flow Instance in the order that they occur.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("traversedpath")]
+ public string TraversedPath
+ {
+ get
+ {
+ return this.GetAttributeValue("traversedpath");
+ }
+ set
+ {
+ this.OnPropertyChanging("TraversedPath");
+ this.SetAttributeValue("traversedpath", value);
+ this.OnPropertyChanged("TraversedPath");
+ }
+ }
+
+ ///
+ /// Time zone code that was in use when the record was created.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("utcconversiontimezonecode")]
+ public System.Nullable UTCConversionTimeZoneCode
+ {
+ get
+ {
+ return this.GetAttributeValue>("utcconversiontimezonecode");
+ }
+ set
+ {
+ this.OnPropertyChanging("UTCConversionTimeZoneCode");
+ this.SetAttributeValue("utcconversiontimezonecode", value);
+ this.OnPropertyChanged("UTCConversionTimeZoneCode");
+ }
+ }
+
+ ///
+ /// Version number of the account.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("versionnumber")]
+ public System.Nullable VersionNumber
+ {
+ get
+ {
+ return this.GetAttributeValue>("versionnumber");
+ }
+ }
+
+ ///
+ /// Type the account's website URL to get quick details about the company profile.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("websiteurl")]
+ public string WebSiteURL
+ {
+ get
+ {
+ return this.GetAttributeValue("websiteurl");
+ }
+ set
+ {
+ this.OnPropertyChanging("WebSiteURL");
+ this.SetAttributeValue("websiteurl", value);
+ this.OnPropertyChanged("WebSiteURL");
+ }
+ }
+
+ ///
+ /// Type the phonetic spelling of the company name, if specified in Japanese, to make sure the name is pronounced correctly in phone calls and other communications.
+ ///
+ [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("yominame")]
+ public string YomiName
+ {
+ get
+ {
+ return this.GetAttributeValue("yominame");
+ }
+ set
+ {
+ this.OnPropertyChanging("YomiName");
+ this.SetAttributeValue("yominame", value);
+ this.OnPropertyChanged("YomiName");
+ }
+ }
+
+ ///
+ /// 1:N account_activity_parties
+ ///
+ [Microsoft.Xrm.Sdk.RelationshipSchemaNameAttribute("account_activity_parties")]
+ public System.Collections.Generic.IEnumerable account_activity_parties
+ {
+ get
+ {
+ return this.GetRelatedEntities