using System; using System.Net; using System.Threading; using GrassValley.Mseries.AppServer; using GrassValley.Mseries.AppServerLog; using GrassValley.Mseries.ChanStatus; using GrassValley.Mseries.ConfigMgr; using GrassValley.Mseries.Control; using GrassValley.Mseries.DVCapture; using GrassValley.Mseries.Editor; using GrassValley.Mseries.MediaMgr; using GrassValley.Mseries.Security; using GrassValley.Mseries.Status; using GrassValley.Mseries.TransferQueue; // Leave the following "css_reference" lines in when running with CS-Script. They're // more than just comments - they tell CS-Script which DLLs to load if the DLL // name does not match the namespace that it implements. //css_reference Credentials.dll; //css_reference ServerUtil.dll; /// /// This is a sample CS-Script app for controlling the Grass Valley K2 server. /// The code is regular C# code, but it's written for CS-Script which can /// run it as a script from a DOS command prompt. /// /// Go to the K2 AppServer Developer's Guide for more information: /// http://www.gvgdevelopers.com/K2DevGuide/K2DevGuide.html#%5B%5BCS-Script%20Sample%20Scripts%5D%5D /// /// For more information about CS-Script go to: /// http://www.members.optusnet.com.au/~olegshilo/ /// class K2Sample { [STAThread] static void Main() { try { ////////////////////////// // SETUP ////////////////////////// AppServerMgrProxy appServerMgrProxy = null; // get the application's name & create a unique suite name from it string appName = Environment.GetCommandLineArgs()[0]; string suiteName = appName + "_" + System.Guid.NewGuid().ToString("N"); // setup user, password, and domain info string userName = ""; string password = ""; string domain = ""; // ask which K2 should we connect to Console.Write("Connect to AppService on which system? [" + Dns.GetHostName() + "]: "); string host = Console.ReadLine(); if (null == host || 0 == host.Length) host = Dns.GetHostName(); ////////////////////////// // CONNECT TO K2 ////////////////////////// // create an AppServerMgr proxy object Console.WriteLine("create AppServerMgr proxy object"); appServerMgrProxy = new AppServerMgrProxy(); // tell it which K2 we're connecting to Console.WriteLine("set the host name"); appServerMgrProxy.SetHost(host); // give it the user credentials we want to use Console.WriteLine("set the credentials"); appServerMgrProxy.SetUserCredentials(userName, password, domain, false); // connect to the K2's AppServerMgr Console.WriteLine("try to connect"); if ( !appServerMgrProxy.Connect() ) { // if the connection failed, report an error and exit appServerMgrProxy = null; Console.WriteLine("ERROR: Could not connect to AppService on " + host + "."); return; } ////////////////////////// // CREATE AN APPSERVER ////////////////////////// // if we got here we're connected Console.WriteLine("got connection to AppService"); // create an AppServer Console.WriteLine("create an AppServer"); bool newConnection = false; IAppServer iappServer = appServerMgrProxy.CreateAppServer(suiteName, appName, out newConnection); ////////////////////////// // DO WORK ////////////////////////// // here is where you'd do work (i.e create subsystem objects, make calls on them, etc.) Console.WriteLine("\n(... do work here...)\n"); ////////////////////////// // CLEANUP ////////////////////////// Console.WriteLine("close the AppServer"); iappServer.CloseConnection(); } catch (Exception e) { Console.WriteLine(e); } } }