Decoupling of userprincipalName and PrimaryEmailAddress
OrganizationUsers updated with image buttons with the ability to go directly
to offering settings
When changing primaryemailaddress, sip address changes accordingly
Mailboxes list view updated with Login (=userprincipalName) with the ability
to go directly to user setting
Lync list view updated with Login (=userprincipalName) with the ability
to go directly to user setting
This commit is contained in:
robvde 2012-11-22 13:16:41 +04:00
parent bc1168a1a4
commit 6cf946b6b4
30 changed files with 869 additions and 121 deletions

View file

@ -3257,7 +3257,7 @@ namespace WebsitePanel.EnterpriseServer
#region Lync
public static void AddLyncUser(int accountId, int lyncUserPlanId)
public static void AddLyncUser(int accountId, int lyncUserPlanId, string sipAddress)
{
SqlHelper.ExecuteNonQuery(ConnectionString,
CommandType.StoredProcedure,
@ -3265,10 +3265,24 @@ namespace WebsitePanel.EnterpriseServer
new[]
{
new SqlParameter("@AccountID", accountId),
new SqlParameter("@LyncUserPlanID", lyncUserPlanId)
new SqlParameter("@LyncUserPlanID", lyncUserPlanId),
new SqlParameter("@SipAddress", sipAddress)
});
}
public static void UpdateLyncUser(int accountId, string sipAddress)
{
SqlHelper.ExecuteNonQuery(ConnectionString,
CommandType.StoredProcedure,
"UpdateLyncUser",
new[]
{
new SqlParameter("@AccountID", accountId),
new SqlParameter("@SipAddress", sipAddress)
});
}
public static bool CheckLyncUserExists(int accountId)
{
int res = (int)SqlHelper.ExecuteScalar(ConnectionString, CommandType.StoredProcedure, "CheckLyncUserExists",
@ -3276,6 +3290,25 @@ namespace WebsitePanel.EnterpriseServer
return res > 0;
}
public static bool LyncUserExists(int accountId, string sipAddress)
{
SqlParameter outParam = new SqlParameter("@Exists", SqlDbType.Bit);
outParam.Direction = ParameterDirection.Output;
SqlHelper.ExecuteNonQuery(
ConnectionString,
CommandType.StoredProcedure,
"LyncUserExists",
new SqlParameter("@AccountID", accountId),
new SqlParameter("@SipAddress", sipAddress),
outParam
);
return Convert.ToBoolean(outParam.Value);
}
public static IDataReader GetLyncUsers(int itemId, string sortColumn, string sortDirection, int startRow, int count)
{
SqlParameter[] sqlParams = new SqlParameter[]

View file

@ -2119,6 +2119,11 @@ namespace WebsitePanel.EnterpriseServer
ocs.SetUserPrimaryUri(instanceId, emailAddress);
}
if (DataProvider.CheckLyncUserExists(account.AccountId))
{
LyncController.SetLyncUserGeneralSettings(itemId, accountId, emailAddress, null);
}
// save account
UpdateAccount(account);

View file

@ -250,7 +250,7 @@ namespace WebsitePanel.EnterpriseServer.Code.HostedSolution
try
{
DataProvider.AddLyncUser(accountId, lyncUserPlanId);
DataProvider.AddLyncUser(accountId, lyncUserPlanId, user.UserPrincipalName);
}
catch (Exception ex)
{
@ -341,12 +341,11 @@ namespace WebsitePanel.EnterpriseServer.Code.HostedSolution
}
public static bool SetLyncUserGeneralSettings(int itemId, int accountId, string sipAddress, string lineUri)
public static LyncUserResult SetLyncUserGeneralSettings(int itemId, int accountId, string sipAddress, string lineUri)
{
TaskManager.StartTask("LYNC", "SET_LYNC_USER_GENERAL_SETTINGS");
LyncUserResult res = TaskManager.StartResultTask<LyncUserResult>("LYNC", "SET_LYNC_USER_GENERAL_SETTINGS");
LyncUser user = null;
bool ret = true;
try
{
@ -376,19 +375,38 @@ namespace WebsitePanel.EnterpriseServer.Code.HostedSolution
user.LyncUserPlanName = plan.LyncUserPlanName;
}
user.PrimaryUri = sipAddress;
user.LineUri = lineUri;
if (!string.IsNullOrEmpty(sipAddress))
{
if (sipAddress != usr.UserPrincipalName)
{
if (DataProvider.LyncUserExists(accountId, sipAddress))
{
TaskManager.CompleteResultTask(res, LyncErrorCodes.ADDRESS_ALREADY_USED);
return res;
}
}
user.SipAddress = sipAddress;
}
if (!string.IsNullOrEmpty(lineUri)) user.LineUri = lineUri;
lync.SetLyncUserGeneralSettings(org.OrganizationId, usr.UserPrincipalName, user);
DataProvider.UpdateLyncUser(accountId, sipAddress);
}
}
catch (Exception ex)
{
ret = false;
throw TaskManager.WriteError(ex);
TaskManager.CompleteResultTask(res, LyncErrorCodes.FAILED_SET_SETTINGS, ex);
return res;
}
TaskManager.CompleteTask();
return ret;
res.IsSuccess = true;
TaskManager.CompleteResultTask();
return res;
}

View file

@ -511,7 +511,7 @@ namespace WebsitePanel.EnterpriseServer.Code.HostedSolution
try
{
stats.SipAddress = lyncUser.PrimaryEmailAddress;
stats.SipAddress = lyncUser.SipAddress;
if (string.IsNullOrEmpty(lyncUser.LineUri)) stats.PhoneNumber = string.Empty; else stats.PhoneNumber = lyncUser.LineUri;
LyncUserPlan plan = LyncController.GetLyncUserPlan(org.Id, lyncUser.LyncUserPlanId);