Restart Services
- Last UpdatedJun 10, 2024
- 1 minute read
Dll REFERENCE
Workflow.NET.NET2.dll
NAMESPACE USED
Workflow.NET
Skelta.Core
Skelta.FarmManager
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Workflow.NET;
using Skelta.Configurations.DB;
using Skelta.Configurations.DB.Interfaces;
using Skelta.FarmManager;
using Skelta.Core;
namespace Scenarios
{
public partial class SkeltaFarmConfigurations : Form
{
// Change this connection string with actual connection string
string connectionString = "Data Source=sqlServerName;Integrated Security=True;";
string databaseType = "SQL server";
string databaseName = "SkeltaFarm";
// Settings for a Database user having sysadmin rights in SQL server instance
string databaseUser = "John";
string databasePassword = "John";
string databaseDomain = "domain1";
public SkeltaFarmConfigurations()
{
InitializeComponent();
}
#region "Restart Services"
/// <summary>
/// Restart workflow engine
/// </summary>
private void RestartEngine()
{
RestartService("SkeltaWorkflow2");
}
/// <summary>
/// Restart Advanced Server
/// </summary>
private void RestartAdvancedServer()
{
RestartService("SkeltaAdvanceServer");
}
/// <summary>
/// Restart SMTP notification
/// </summary>
private void RestartNotification()
{
RestartService("SMTPNotificationEngine2");
}
/// <summary>
/// Restart Task Schedular
/// </summary>
private void RestartTaskSchedular()
{
RestartService("SkeltaTaskScheduler2");
}
/// <summary>
/// Restarts service
/// </summary>
/// <param name="serviceName">Name of the service to be restarted</param>
private void RestartService( string serviceName )
{
if (ServiceMapping.IsServiceMappedForCurrentServer(serviceName))
{
ServiceMapping serviceMapping = new ServiceMapping(serviceName, Server.Local);
SkeltaClientService clientService = new SkeltaClientService();
try
{
clientService.Stop(serviceMapping);
clientService.Start(serviceMapping);
}
finally
{
clientService.Close();
}
}
else
throw new Exception("This service is not mapped to the current server");
}
#endregion
}
}