Skip to content

Instantly share code, notes, and snippets.

@opello
Created November 14, 2012 16:52
Show Gist options
  • Save opello/4073274 to your computer and use it in GitHub Desktop.
Save opello/4073274 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Web.Administration;
namespace ConsoleApplication1
{
class Program
{
static void Main( string[] args )
{
ServerManager serverManager = new ServerManager();
ApplicationPool applicationPool = null;
try
{
applicationPool = serverManager.ApplicationPools["Smooth"];
}
catch
{
Console.WriteLine( "Unable to find Application Pool named \"Smooth\"" );
Environment.Exit( 1 );
}
WorkerProcess workerProcess = null;
try
{
workerProcess = applicationPool.WorkerProcesses[0];
}
catch
{
Console.WriteLine( "Unable to find first Worker Process" );
Environment.Exit( 1 );
}
try
{
PublishingPointUtils.Shutdown( workerProcess, "Smooth", "/", "mss.isml" );
}
catch( Exception e )
{
Console.WriteLine( e.Message );
throw;
}
try
{
PublishingPointUtils.Start( workerProcess, "Smooth", "/", "mss.isml" );
}
catch( Exception e )
{
Console.WriteLine( e.Message );
throw;
}
Console.WriteLine( "Done" );
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Web.Administration;
using System.Globalization;
namespace ConsoleApplication1
{
public static class PublishingPointUtils
{
private static void ExecuteRscaFunction( ConfigurationElement workerProcess,
string siteName,
string applicationPath,
string fileName,
string functionName )
{
ConfigurationMethod configurationMethod = workerProcess.Methods["GetCustomData"];
ConfigurationMethodInstance instance = configurationMethod.CreateInstance();
instance.Input["guidIdOfFunctionCall"] = "Media_LiveStreaming_Control";
string currentLogicalPath = applicationPath;
if( !currentLogicalPath.EndsWith( "/", StringComparison.OrdinalIgnoreCase ) )
{
currentLogicalPath = currentLogicalPath + "/";
}
string fullPath = string.Concat( currentLogicalPath, fileName );
string parameters = string.Format( CultureInfo.InvariantCulture, "{0};{1};{2}",
functionName, siteName, fullPath );
instance.Input["parametersOfFunctionCall"] = parameters;
instance.Execute();
}
public static void Start( ConfigurationElement workerProcess,
string siteName,
string applicationPath,
string fileName )
{
ExecuteRscaFunction( workerProcess, siteName, applicationPath, fileName, "StartPublishingPoint" );
}
public static void Stop( ConfigurationElement workerProcess,
string siteName,
string applicationPath,
string fileName )
{
ExecuteRscaFunction( workerProcess, siteName, applicationPath, fileName, "StopPublishingPoint" );
}
public static void Shutdown( ConfigurationElement workerProcess,
string siteName,
string applicationPath,
string fileName )
{
ExecuteRscaFunction( workerProcess, siteName, applicationPath, fileName, "ShutdownPublishingPoint" );
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment