From f38530fd667a35333f48f5d2e5dfd97a3697ed1c Mon Sep 17 00:00:00 2001 From: robvde Date: Tue, 22 Apr 2014 17:09:35 +0400 Subject: [PATCH] Lync User Provisioning retry added --- .../Lync2013.cs | 12 ++++-------- .../Lync2013HP.cs | 15 +++++++++++++-- .../Lync2010.cs | 11 ++++++++++- 3 files changed, 27 insertions(+), 11 deletions(-) diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution.Lync2013/Lync2013.cs b/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution.Lync2013/Lync2013.cs index a8d9c368..959b5ba3 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution.Lync2013/Lync2013.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution.Lync2013/Lync2013.cs @@ -274,7 +274,7 @@ namespace WebsitePanel.Providers.HostedSolution command = new Command("Update-CsUserDatabase"); ExecuteShellCommand(runspace, command, false); - int trySleep = 5000; int tryMaxCount = 10; bool PlanSet = false; + int trySleep = 2000; int tryMaxCount = 10; bool PlanSet = false; for (int tryCount = 0; (tryCount < tryMaxCount) && (!PlanSet); tryCount++ ) { try @@ -285,10 +285,6 @@ namespace WebsitePanel.Providers.HostedSolution if (!PlanSet) System.Threading.Thread.Sleep(trySleep); } - command = new Command("Update-CsAddressBook"); - ExecuteShellCommand(runspace, command, false); - command = new Command("Update-CsUserDatabase"); - ExecuteShellCommand(runspace, command, false); } catch (Exception ex) { @@ -474,7 +470,7 @@ namespace WebsitePanel.Providers.HostedSolution HostedSolutionLog.DebugInfo("organizationId: {0}", organizationId); HostedSolutionLog.DebugInfo("userUpn: {0}", userUpn); bool bCloseRunSpace = false; - bool bResult = false; + bool ret = true; try { @@ -533,7 +529,7 @@ namespace WebsitePanel.Providers.HostedSolution command = new Command("Update-CsUserDatabase"); ExecuteShellCommand(runspace, command, false); - bResult = true; + ret = false; } catch (Exception ex) { @@ -550,7 +546,7 @@ namespace WebsitePanel.Providers.HostedSolution HostedSolutionLog.LogEnd("SetLyncUserPlanInternal"); - return bResult; + return ret; } /// Deletes user. diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution.Lync2013HP/Lync2013HP.cs b/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution.Lync2013HP/Lync2013HP.cs index 5b34ed09..ae48541d 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution.Lync2013HP/Lync2013HP.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution.Lync2013HP/Lync2013HP.cs @@ -509,8 +509,16 @@ namespace WebsitePanel.Providers.HostedSolution } user.CommitChanges(); - //set-plan - SetLyncUserPlanInternal(organizationId, userUpn, plan, runSpace); + int trySleep = 2000; int tryMaxCount = 10; bool PlanSet = false; + for (int tryCount = 0; (tryCount < tryMaxCount) && (!PlanSet); tryCount++) + { + try + { + PlanSet = SetLyncUserPlanInternal(organizationId, userUpn, plan, runSpace); + } + catch { } + if (!PlanSet) System.Threading.Thread.Sleep(trySleep); + } //initiate addressbook generation cmd = new Command("Update-CsAddressBook"); @@ -519,6 +527,9 @@ namespace WebsitePanel.Providers.HostedSolution //initiate user database replication cmd = new Command("Update-CsUserDatabase"); ExecuteShellCommand(runSpace, cmd, false); + + + } else { diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/Lync2010.cs b/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/Lync2010.cs index 653ab69c..9a3eaee6 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/Lync2010.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/Lync2010.cs @@ -509,7 +509,16 @@ namespace WebsitePanel.Providers.HostedSolution user.CommitChanges(); //set-plan - SetLyncUserPlanInternal(organizationId, userUpn, plan, runSpace); + int trySleep = 2000; int tryMaxCount = 10; bool PlanSet = false; + for (int tryCount = 0; (tryCount < tryMaxCount) && (!PlanSet); tryCount++) + { + try + { + PlanSet = SetLyncUserPlanInternal(organizationId, userUpn, plan, runSpace); + } + catch { } + if (!PlanSet) System.Threading.Thread.Sleep(trySleep); + } //initiate addressbook generation cmd = new Command("Update-CsAddressBook");