CRM Module update

This commit is contained in:
dev_amdtel 2013-12-10 22:34:39 +04:00
parent 4f6d1f2c50
commit f500906c68
18 changed files with 150 additions and 17 deletions

View file

@ -2732,3 +2732,16 @@ END
GO
-- CRM Quota
BEGIN
UPDATE [dbo].[Quotas] SET QuotaOrder = 5 WHERE [QuotaName] = 'HostedCRM.MaxDatabaseSize'
END
GO
IF NOT EXISTS (SELECT * FROM [dbo].[Quotas] WHERE [QuotaName] = 'HostedCRM.ESSUsers')
BEGIN
INSERT [dbo].[Quotas] ([QuotaID], [GroupID],[QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID]) VALUES (462, 21, 4, N'HostedCRM.ESSUsers', N'ESS licenses per organization',3, 0 , NULL)
END
GO

View file

@ -160,6 +160,7 @@ order by rg.groupOrder
public const string CRM_USERS = "HostedCRM.Users";
public const string CRM_ORGANIZATION = "HostedCRM.Organization";
public const string CRM_LIMITEDUSERS = "HostedCRM.LimitedUsers";
public const string CRM_ESSUSERS = "HostedCRM.ESSUsers";
public const string CRM_MAXDATABASESIZE = "HostedCRM.MaxDatabaseSize";
public const string VPS_SERVERS_NUMBER = "VPS.ServersNumber"; // Number of VPS

View file

@ -269,7 +269,7 @@ namespace WebsitePanel.EnterpriseServer
string rootOU = GetProviderProperty(serviceid, "rootou");
PackageContext cntx = PackageController.GetPackageContext(org.PackageId);
int maxDBSize = cntx.Quotas[Quotas.CRM_MAXDATABASESIZE].QuotaAllocatedValue;
long maxDBSize = cntx.Quotas[Quotas.CRM_MAXDATABASESIZE].QuotaAllocatedValue;
if (maxDBSize != -1) maxDBSize = maxDBSize * 1024 * 1024;
org.CrmAdministratorId = user.AccountId;
@ -676,7 +676,7 @@ namespace WebsitePanel.EnterpriseServer
if (!quotaRes.Value)
{
CompleteTask(ret, CrmErrorCodes.USER_QUOTA_HAS_BEEN_REACHED, null, "CRM user quota has been reached.");
CompleteTask(ret, CrmErrorCodes.USER_QUOTA_HAS_BEEN_REACHED + CALType.ToString(), null, "CRM user quota has been reached.");
return ret;
}
@ -971,7 +971,7 @@ namespace WebsitePanel.EnterpriseServer
try
{
CrmUserResult user = GetCrmUser(itemId, accountId);
if (user.Value.CALType == CALType)
if (user.Value.CALType + ((int)user.Value.ClientAccessMode)*10 == CALType)
{
res.IsSuccess = true;
CompleteTask();
@ -1012,8 +1012,7 @@ namespace WebsitePanel.EnterpriseServer
}
if (!quotaRes.Value)
{
CompleteTask(res, CrmErrorCodes.USER_QUOTA_HAS_BEEN_REACHED + CALType.ToString(), null, "CRM user quota " +
(CALType==0 ? "(full license)" : "(limited license)") +" has been reached.");
CompleteTask(res, CrmErrorCodes.USER_QUOTA_HAS_BEEN_REACHED + CALType.ToString(), null, "CRM user quota has been reached.");
return res;
}
@ -1106,7 +1105,20 @@ namespace WebsitePanel.EnterpriseServer
return res;
}
string quotaName = CALType == 0 ? Quotas.CRM_USERS : Quotas.CRM_LIMITEDUSERS;
string quotaName = Quotas.CRM_USERS;
switch (CALType)
{
case 0:
quotaName = Quotas.CRM_USERS;
break;
case 2:
quotaName = Quotas.CRM_LIMITEDUSERS;
break;
case 22:
quotaName = Quotas.CRM_ESSUSERS;
break;
}
int allocatedCrmUsers = cntx.Quotas[quotaName].QuotaAllocatedValue;
res.Value = allocatedCrmUsers == -1 || allocatedCrmUsers > tmp.Value;
@ -1157,7 +1169,7 @@ namespace WebsitePanel.EnterpriseServer
PackageContext cntx = PackageController.GetPackageContext(packageId);
int limitSize = cntx.Quotas[Quotas.CRM_MAXDATABASESIZE].QuotaAllocatedValue;
long limitSize = cntx.Quotas[Quotas.CRM_MAXDATABASESIZE].QuotaAllocatedValue;
if (limitSize != -1)
{

View file

@ -934,6 +934,7 @@ namespace WebsitePanel.EnterpriseServer
{
stats.CreatedCRMUsers = CRMController.GetCRMUsersCount(org.Id, string.Empty, string.Empty, 0).Value;
stats.CreatedLimitedCRMUsers = CRMController.GetCRMUsersCount(org.Id, string.Empty, string.Empty, 2).Value;
stats.CreatedESSCRMUsers = CRMController.GetCRMUsersCount(org.Id, string.Empty, string.Empty, 22).Value;
stats.UsedCRMDiskSpace = CRMController.GetDBSize(org.Id, org.PackageId);
stats.AllocatedCRMDiskSpace = CRMController.GetMaxDBSize(org.Id, org.PackageId);
@ -997,6 +998,7 @@ namespace WebsitePanel.EnterpriseServer
{
stats.CreatedCRMUsers += CRMController.GetCRMUsersCount(o.Id, string.Empty, string.Empty, 0 ).Value;
stats.CreatedLimitedCRMUsers += CRMController.GetCRMUsersCount(o.Id, string.Empty, string.Empty, 2).Value;
stats.CreatedESSCRMUsers += CRMController.GetCRMUsersCount(o.Id, string.Empty, string.Empty, 22).Value;
stats.UsedCRMDiskSpace += CRMController.GetDBSize(o.Id, o.PackageId);
stats.AllocatedCRMDiskSpace += CRMController.GetMaxDBSize(o.Id, o.PackageId);
}
@ -1044,6 +1046,7 @@ namespace WebsitePanel.EnterpriseServer
{
stats.AllocatedCRMUsers = cntx.Quotas[Quotas.CRM_USERS].QuotaAllocatedValue;
stats.AllocatedLimitedCRMUsers = cntx.Quotas[Quotas.CRM_LIMITEDUSERS].QuotaAllocatedValue;
stats.AllocatedESSCRMUsers = cntx.Quotas[Quotas.CRM_ESSUSERS].QuotaAllocatedValue;
}
if (cntx.Groups.ContainsKey(ResourceGroups.BlackBerry))

View file

@ -42,6 +42,7 @@ namespace WebsitePanel.Providers.HostedSolution
public string СRMOrganizationName { get; set; }
public int CRMUsersFullLicenceCount { get; set; }
public int CRMUsersReadOnlyLicenceCount { get; set; }
public int CRMUsersESSLicenceCount { get; set; }
public int UsedSpace { get; set; }
public string UsageMonth { get; set; }

View file

@ -64,6 +64,9 @@ namespace WebsitePanel.Providers.HostedSolution
private int createdLimitedCRMUsers;
private int allocatedLimitedCRMUsers;
private int createdESSCRMUsers;
private int allocatedESSCRMUsers;
private long usedCRMDiskSpace;
private long allocatedCRMDiskSpace;
@ -97,7 +100,19 @@ namespace WebsitePanel.Providers.HostedSolution
get { return allocatedLimitedCRMUsers; }
set { allocatedLimitedCRMUsers = value; }
}
public int CreatedESSCRMUsers
{
get { return createdESSCRMUsers; }
set { createdESSCRMUsers = value; }
}
public int AllocatedESSCRMUsers
{
get { return allocatedESSCRMUsers; }
set { allocatedESSCRMUsers = value; }
}
public int AllocatedUsers
{
get { return allocatedUsers; }

View file

@ -951,6 +951,10 @@ namespace WebsitePanel.Providers.HostedSolution
// 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
{
@ -963,7 +967,8 @@ namespace WebsitePanel.Providers.HostedSolution
Name = BusinessUnit.EntityLogicalName,
Id = defaultBusinessUnit.Id
},
CALType = new OptionSetValue(CALType)
CALType = new OptionSetValue(caltype),
AccessMode = new OptionSetValue(accessmode)
};
userId = serviceProxy.Create(user);
@ -1930,7 +1935,12 @@ namespace WebsitePanel.Providers.HostedSolution
SystemUser user =
serviceProxy.Retrieve(SystemUser.EntityLogicalName, userId, new Microsoft.Xrm.Sdk.Query.ColumnSet("domainname", "businessunitid", "accessmode", "isdisabled", "caltype")).ToEntity<SystemUser>();
user.CALType = new OptionSetValue(CALType);
// CALType and AccessMode
int accessmode = CALType / 10;
int caltype = CALType % 10;
user.CALType = new OptionSetValue(caltype);
user.AccessMode = new OptionSetValue(accessmode);
serviceProxy.Update(user);

View file

@ -5374,4 +5374,10 @@
<data name="HostedCRM.USER_QUOTA_HAS_BEEN_REACHED2" xml:space="preserve">
<value>CRM users quota (limited license) has been reached.</value>
</data>
<data name="HostedCRM.USER_QUOTA_HAS_BEEN_REACHED22" xml:space="preserve">
<value>CRM users quota (ESS license) has been reached.</value>
</data>
<data name="Quota.HostedCRM.ESSUsers" xml:space="preserve">
<value>ESS licenses per organization</value>
</data>
</root>

View file

@ -42,10 +42,19 @@ namespace WebsitePanel.Portal
protected void Page_Load(object sender, EventArgs e)
{
warningValue.UnlimitedText = GetLocalizedString("WarningUnlimitedValue");
if (!IsPostBack)
{
BindValues();
Organization org = ES.Services.Organizations.GetOrganization(PanelRequest.ItemID);
if (org.CrmOrganizationId == Guid.Empty)
{
messageBox.ShowErrorMessage("NOT_CRM_ORGANIZATION");
StorageLimits.Enabled = false;
btnSave.Enabled = false;
}
else
{
BindValues();
}
}
}
@ -77,9 +86,9 @@ namespace WebsitePanel.Portal
try
{
PackageContext cntx = PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId);
int limitSize = cntx.Quotas[Quotas.CRM_MAXDATABASESIZE].QuotaAllocatedValue;
long limitSize = cntx.Quotas[Quotas.CRM_MAXDATABASESIZE].QuotaAllocatedValue;
int maxSize = maxStorageSettingsValue.QuotaValue;
long maxSize = maxStorageSettingsValue.QuotaValue;
if (limitSize != -1)
{

View file

@ -56,6 +56,7 @@
<asp:DropDownList ID="ddlLicenseType" runat="server" CssClass="NormalTextBox" AutoPostBack="false">
<asp:ListItem Value="0" meta:resourcekey="ddlLicenseTypeFull">Full</asp:ListItem>
<asp:ListItem Value="2" meta:resourcekey="ddlLicenseTypeLimited">Limited</asp:ListItem>
<asp:ListItem Value="22" meta:resourcekey="ddlLicenseTypeESS">ESS</asp:ListItem>
</asp:DropDownList>
</td>
</tr>

View file

@ -59,12 +59,13 @@ namespace WebsitePanel.Portal.CRM
lblEmailAddress.Text = user.PrimaryEmailAddress;
lblDomainName.Text = user.DomainUserName;
int cALType = userResult.Value.CALType;
int cALType = userResult.Value.CALType + ((int)userResult.Value.ClientAccessMode) * 10;
switch (cALType)
{
case 0 :
case 2 :
case 22:
ddlLicenseType.SelectedValue = cALType.ToString();
break;
default:

View file

@ -97,6 +97,14 @@
<wsp:QuotaViewer ID="limitedusersQuota" runat="server" QuotaTypeId="2" />
</td>
</tr>
<tr>
<td align="right" nowrap>
<asp:Localize ID="locESSQuota" runat="server" meta:resourcekey="locESSQuota" Text="ESS licenses :"></asp:Localize>
</td>
<td>
<wsp:QuotaViewer ID="essusersQuota" runat="server" QuotaTypeId="2" />
</td>
</tr>
</table>
</div>

View file

@ -57,6 +57,10 @@ namespace WebsitePanel.Portal.CRM
//if (stats.AllocatedCRMUsers != -1) usersQuota.QuotaAvailable = tenantStats.AllocatedCRMUsers - tenantStats.CreatedCRMUsers;
//if (stats.AllocatedLimitedCRMUsers != -1) limitedusersQuota.QuotaAvailable = tenantStats.AllocatedLimitedCRMUsers - tenantStats.CreatedLimitedCRMUsers;
essusersQuota.QuotaUsedValue = stats.CreatedESSCRMUsers;
essusersQuota.QuotaValue = stats.AllocatedESSCRMUsers;
}
}

View file

@ -201,5 +201,23 @@ namespace WebsitePanel.Portal.CRM {
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::WebsitePanel.Portal.QuotaViewer limitedusersQuota;
/// <summary>
/// locESSQuota control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Localize locESSQuota;
/// <summary>
/// essusersQuota control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::WebsitePanel.Portal.QuotaViewer essusersQuota;
}
}

View file

@ -45,6 +45,7 @@
<asp:DropDownList ID="ddlLicenseType" runat="server" CssClass="NormalTextBox" AutoPostBack="false">
<asp:ListItem Value="0" meta:resourcekey="ddlLicenseTypeFull">Full</asp:ListItem>
<asp:ListItem Value="2" meta:resourcekey="ddlLicenseTypeLimited">Limited</asp:ListItem>
<asp:ListItem Value="22" meta:resourcekey="ddlLicenseTypeESS">ESS</asp:ListItem>
</asp:DropDownList>
</td>
</tr>

View file

@ -224,7 +224,15 @@
</tr>
<tr class="OrgStatsRow">
<td align="right" nowrap>
<asp:HyperLink ID="lnkCRMDBSize" runat="server" meta:resourcekey="lnkCRMDBSize" Text="Storage size (ÌÂ):"></asp:HyperLink>
<asp:HyperLink ID="lnkESSCRMUsers" runat="server" meta:resourcekey="lnkESSCRMUsers" Text="ESS licenses :"></asp:HyperLink>
</td>
<td>
<wsp:QuotaViewer ID="crmESSUsersStats" QuotaTypeId="2" runat="server" DisplayGauge="true" />
</td>
</tr>
<tr class="OrgStatsRow">
<td align="right" nowrap>
<asp:HyperLink ID="lnkCRMDBSize" runat="server" meta:resourcekey="lnkCRMDBSize" Text="Storage size (MB):"></asp:HyperLink>
</td>
<td>
<wsp:QuotaViewer ID="crmDBSize" runat="server" QuotaTypeId="2" DisplayGauge="true" />

View file

@ -247,6 +247,7 @@ namespace WebsitePanel.Portal.ExchangeServer
"SpaceID=" + PanelSecurity.PackageId);
lnkLimitedCRMUsers.NavigateUrl = lnkCRMUsers.NavigateUrl;
lnkESSCRMUsers.NavigateUrl = lnkCRMUsers.NavigateUrl;
lnkCRMDBSize.NavigateUrl = EditUrl("ItemID", PanelRequest.ItemID.ToString(), "crm_storage_settings",
"SpaceID=" + PanelSecurity.PackageId);
@ -259,7 +260,10 @@ namespace WebsitePanel.Portal.ExchangeServer
crmLimitedUsersStats.QuotaUsedValue = stats.CreatedLimitedCRMUsers;
crmLimitedUsersStats.QuotaValue = stats.AllocatedLimitedCRMUsers;
crmDBSize.QuotaUsedValue = Convert.ToInt32( stats.UsedCRMDiskSpace>0 ? stats.UsedCRMDiskSpace/(1024*1024) : -1);
crmESSUsersStats.QuotaUsedValue = stats.CreatedESSCRMUsers;
crmESSUsersStats.QuotaValue = stats.AllocatedESSCRMUsers;
crmDBSize.QuotaUsedValue = Convert.ToInt32(stats.UsedCRMDiskSpace > 0 ? stats.UsedCRMDiskSpace / (1024 * 1024) : -1);
crmDBSize.QuotaValue = Convert.ToInt32(stats.AllocatedCRMDiskSpace>0 ? stats.AllocatedCRMDiskSpace/(1024*1024) : -1);
}

View file

@ -553,6 +553,24 @@ namespace WebsitePanel.Portal.ExchangeServer {
/// </remarks>
protected global::WebsitePanel.Portal.QuotaViewer crmLimitedUsersStats;
/// <summary>
/// lnkESSCRMUsers control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.HyperLink lnkESSCRMUsers;
/// <summary>
/// crmESSUsersStats control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::WebsitePanel.Portal.QuotaViewer crmESSUsersStats;
/// <summary>
/// lnkCRMDBSize control.
/// </summary>