How to: Integrate Hosted Email Global Administrative Tasks
Applies To: Windows Server 2012 Essentials
As with other Dashboard add-ins, you can integrate hosted email service global tasks to the UI. Normally, these tasks will be administrative tasks, such as accessing the admin email account, or disabling the email service itself. Other than using HEI-specific interfaces (such as HostedEmailManager or HostedEmailIntegrationManager), a hosted email global task is created in the same way as any other global task. You add a task or a collection of tasks when you modify the UI with a call to PageContent.Create. For more information, see the Create a Top-Level Tab topic and associated subtopics.
The following code samples describe a series of custom administrative tasks added to a sub-tab. For the complete example, see the ContosoHostedEmailAddin
project in Quickstart: Creating a Hosted Email Adapter.
Example
The following code adds the global tasks to the task pane, along with the associated custom Windows Form.
protected override PageContent CreateContent()
{
return PageContent.Create((content, owner) => new SampleAddinForm(), GlobalTasks.CreateGlobalTasks(), null);
}
Example
The following code sample describes the three global tasks created in the above sample: changing the admin account, disabling the service, and accessing the admin account.
namespace Contoso.HostedEmail.DashboardAddin
{
internal static class GlobalTasks
{
private static TaskCollection globalTasks = null;
private static bool ContosoEmailEnabled
{
get
{
return (HostedEmailIntegrationManager.IsEnabled() && HostedEmailIntegrationManager.EnabledAddinId.Equals(Constants.AdaptorId));
}
}
[MethodImpl(MethodImplOptions.Synchronized)]
internal static TaskCollection CreateGlobalTasks()
{
if (globalTasks == null)
{
globalTasks = new TaskCollection();
globalTasks.Add(CreateChangeAdminAccountTask());
globalTasks.Add(CreateDisableServicesTask());
globalTasks.Add(CreateVisitMyAccountTask());
}
return globalTasks;
}
private static AsyncUiTask CreateVisitMyAccountTask()
{
AsyncUiTask task = new AsyncUiTask(
UIConstants.VisitMyAccountTask,
Resources.ContosoServicesVisitMyAccountTask_DisplayName,
delegate(object obj)
{
Uri userPortal = null;
if (ContosoEmailEnabled)
{
userPortal = HostedEmailIntegrationManager.Configuration.Service.ServiceUserPortal;
}
if(userPortal == null)
{
userPortal = new Uri(Resources.ContosoServices_DefaultUserPortal);
}
System.Diagnostics.Process.Start(userPortal.ToString());
return null;
},
true //global task
);
return task;
}
private static AsyncUiTask CreateChangeAdminAccountTask()
{
AsyncUiTask task = new AsyncUiTask(
UIConstants.ChangeAdminAccountTask,
Resources.ContosoServicesChangeAdminAccountTask_DisplayName,
delegate(object obj)
{
//do not need to check if addin Id is valid since it has been checked when tab loaded
string configureWizardResetRelativePath = "Wssg.HostedEmailConfigureWizard.Reset.vbs";
System.Diagnostics.Process.Start(configureWizardResetRelativePath);
return null;
},
true //global task
);
task.ConditionProvider = ChangeAdminAccountCondition;
return task;
}
private static AsyncUiTask CreateDisableServicesTask()
{
AsyncUiTask task = new AsyncUiTask(
UIConstants.DisableServicesTask,
Resources.ContosoServicesDisableServicesTask_DisplayName,
delegate(object obj)
{
string configureWizardRelativePath = "Wssg.HostedEmailConfigureWizard.vbs";
System.Diagnostics.Process.Start(configureWizardRelativePath);
return null;
},
true //global task
);
task.ConditionProvider = DisableServicesCondition;
return task;
}
private static TaskCondition ChangeAdminAccountCondition(object obj)
{
return ContosoEmailEnabled ? TaskCondition.Normal : TaskCondition.NotApplicable;
}
private static TaskCondition DisableServicesCondition(object obj)
{
return ContosoEmailEnabled ? TaskCondition.Normal : TaskCondition.NotApplicable;
}
}
}