Hello,
I have a web app with multiple pages relating to performing Exchange tasks for non exchange administrators.
One of these pages will allow a user to view / add / remove permissions from a mailbox.
It works fine, but the viewing takes around 40 seconds because of all the calls to exchange cmdlets.
So, I thought I'd add an Update Panel and provide progress on each step.
That works great if only one user uses the page at a time, but if multiple people run it, the data is either combined for both or one person gets the other's data.
This is my update panel:
<asp:UpdatePanel ID="pnlResults" runat="server" UpdateMode="Conditional" Visible="false" ChildrenAsTriggers="false"><ContentTemplate><asp:Label ID="lblResults" runat="server" Height="150px"></asp:Label><br /><asp:TextBox ID="txtProgress" runat="server" Visible="false" TextMode="MultiLine" BorderStyle="None" Width="95%" Style="overflow: hidden;" AutoPostBack="false"></asp:TextBox><br /><br /><asp:Table ID="thePermissionTable" runat="server" AutoPostBack="true" BorderStyle="None"></asp:Table><br /><asp:Button ID="btnRemoveAccess" runat="server" Visible="false" Text="!Remove Access!"></asp:Button><br /><asp:Button ID="btnBack" Text="Return" runat="server" OnClick="BtnBack_Click" Visible="true" AutoPostBack="true"></asp:Button><asp:TextBox ID="txtPermissionToRevoke" runat="server" Width="0px" Height="0px" BorderStyle="None"></asp:TextBox><asp:TextBox ID="txtSendOnBehalf" runat="server" Width="0px" Height="0px" BorderStyle="None"></asp:TextBox><asp:TextBox ID="txtSendOnBehalfToRevoke" runat="server" Width="0px" Height="0px" BorderStyle="None"></asp:TextBox></ContentTemplate><Triggers><asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" /></Triggers></asp:UpdatePanel>
This is timer1_tick:
protected void Timer1_Tick(object sender, EventArgs e)
{
if (inProcess)
{
txtProgress.Rows = content.Split('\r').Length + 1;
txtProgress.Text = content;
}
if (processComplete && content.Substring(content.Length - processCompleteMsg.Length) == processCompleteMsg) //has final message been set?
{
inProcess = false;
btnNext.Visible = false;
btnBack.Visible = true;
txtProgress.Text = content;
if (tableDone)
{
if (rdoAction.SelectedValue.ToString().ToLower() == "remove-access")
{
pnlButtons.Visible = true;
btnRemoveAccess.Visible = true;
}
thePermissionTable.Visible = true;
}
Timer1.Enabled = false;
}
else
{
if (displayTable)
CreateTable();
if (rdoAction.SelectedValue.ToString().ToLower() == "remove-access")
{
pnlButtons.Visible = true;
btnRemoveAccess.Visible = true;
}
}
}I start the process with my button click in RaisePostBackEvent like so:
switch (action)
{
case "display-access":
Timer1.Enabled = true;
inProcess = true;
pnlButtons.Visible = false;
Thread workerThread = new Thread(new ThreadStart(() =>
{
FnGetCurrentAccess();
}));
workerThread.Start();
break;
}
FnGetCurrentAccess() does almost all of the exchange cmdlets by calling my commonfunctions class, and adds to the content which is a private static string.
I have no idea how to make this work, so I appreciate any ideas.
Karl