Plumbling put in place to set Lync SipAddress and LineUri

This commit is contained in:
robvde 2012-11-20 21:10:51 +04:00
parent ad52464658
commit 65ab6722fd
10 changed files with 597 additions and 432 deletions

View file

@ -228,7 +228,7 @@ namespace WebsitePanel.EnterpriseServer.Code.HostedSolution
LyncUserPlan plan = GetLyncUserPlan(itemId, lyncUserPlanId);
if (!lync.CreateUser(org.OrganizationId, user.PrimaryEmailAddress, plan))
if (!lync.CreateUser(org.OrganizationId, user.UserPrincipalName, plan))
{
TaskManager.CompleteResultTask(res, LyncErrorCodes.CANNOT_ADD_LYNC_USER);
return res;
@ -318,7 +318,7 @@ namespace WebsitePanel.EnterpriseServer.Code.HostedSolution
usr = OrganizationController.GetAccount(itemId, accountId);
if (usr != null)
user = lync.GetLyncUserGeneralSettings(org.OrganizationId, usr.PrimaryEmailAddress);
user = lync.GetLyncUserGeneralSettings(org.OrganizationId, usr.UserPrincipalName);
if (user != null)
{
@ -341,6 +341,59 @@ namespace WebsitePanel.EnterpriseServer.Code.HostedSolution
}
public static bool SetLyncUserGeneralSettings(int itemId, int accountId, string sipAddress, string lineUri)
{
TaskManager.StartTask("LYNC", "SET_LYNC_USER_GENERAL_SETTINGS");
LyncUser user = null;
bool ret = true;
try
{
Organization org = (Organization)PackageController.GetPackageItem(itemId);
if (org == null)
{
throw new ApplicationException(
string.Format("Organization is null. ItemId={0}", itemId));
}
int lyncServiceId = GetLyncServiceID(org.PackageId);
LyncServer lync = GetLyncServer(lyncServiceId, org.ServiceId);
OrganizationUser usr;
usr = OrganizationController.GetAccount(itemId, accountId);
if (usr != null)
user = lync.GetLyncUserGeneralSettings(org.OrganizationId, usr.UserPrincipalName);
if (user != null)
{
LyncUserPlan plan = ObjectUtils.FillObjectFromDataReader<LyncUserPlan>(DataProvider.GetLyncUserPlanByAccountId(accountId));
if (plan != null)
{
user.LyncUserPlanId = plan.LyncUserPlanId;
user.LyncUserPlanName = plan.LyncUserPlanName;
}
user.PrimaryUri = sipAddress;
user.LineUri = lineUri;
lync.SetLyncUserGeneralSettings(org.OrganizationId, usr.UserPrincipalName, user);
}
}
catch (Exception ex)
{
ret = false;
throw TaskManager.WriteError(ex);
}
TaskManager.CompleteTask();
return ret;
}
public static int DeleteOrganization(int itemId)
{
// check account
@ -403,7 +456,7 @@ namespace WebsitePanel.EnterpriseServer.Code.HostedSolution
OrganizationUser user;
user = OrganizationController.GetAccount(itemId, accountId);
if (!lync.SetLyncUserPlan(org.OrganizationId, user.PrimaryEmailAddress, plan))
if (!lync.SetLyncUserPlan(org.OrganizationId, user.UserPrincipalName, plan))
{
TaskManager.CompleteResultTask(res, LyncErrorCodes.CANNOT_ADD_LYNC_USER);
return res;
@ -518,7 +571,7 @@ namespace WebsitePanel.EnterpriseServer.Code.HostedSolution
user = OrganizationController.GetAccount(itemId, accountId);
if (user != null)
lync.DeleteUser(user.PrimaryEmailAddress);
lync.DeleteUser(user.UserPrincipalName);
}
catch (Exception ex)
{

View file

@ -5,11 +5,19 @@
</configSections>
<!-- Connection strings -->
<connectionStrings>
<add name="EnterpriseServer" connectionString="Server=(local)\SQLExpress;Database=WebsitePanel;uid=sa;pwd=Password12" providerName="System.Data.SqlClient" />
<!--
<add name="EnterpriseServer" connectionString="server=HSTPROV01;database=WebsitePanelMerge;uid=WebsitePanel;pwd=aj7ep6fyhmw3b5qeth7c;" />
<add name="EnterpriseServer" connectionString="server=HSTWSP01;database=WebsitePanelMerge;uid=WebsitePanel;pwd=pserxfbnlc6hwmdedbp0;" providerName="System.Data.SqlClient" />
-->
<add name="EnterpriseServer" connectionString="server=HSTPROV01;database=WebsitePanelMerge;uid=WebsitePanel;pwd=aj7ep6fyhmw3b5qeth7c;" />
</connectionStrings>
<appSettings>
<!-- Encryption util settings -->
<add key="WebsitePanel.CryptoKey" value="1234567890" />
<!-- A1D4KDHUE83NKHddF -->
<!--
<add key="WebsitePanel.CryptoKey" value="3x7eqt7zabc5n5afs6dg" />
<add key="WebsitePanel.CryptoKey" value="fr2ym4wn2gmbrj7dz336" />
-->
<add key="WebsitePanel.CryptoKey" value="3x7eqt7zabc5n5afs6dg" />
<!-- A1D4KDHUE83NKHddF -->
<add key="WebsitePanel.EncryptionEnabled" value="true" />
<!-- Web Applications -->

View file

@ -119,6 +119,13 @@ namespace WebsitePanel.EnterpriseServer
return LyncController.GetLyncUserGeneralSettings(itemId, accountId);
}
[WebMethod]
public bool SetLyncUserGeneralSettings(int itemId, int accountId, string sipAddress, string lineUri)
{
return LyncController.SetLyncUserGeneralSettings(itemId, accountId, sipAddress, lineUri);
}
[WebMethod]
public LyncUserResult SetUserLyncPlan(int itemId, int accountId, int lyncUserPlanId)
{