ScreenCloud API and C# App

19 Feb

For a while, I’ve had little agent rolled out to all domain machines which sits in the notification area and initially it just provided shortcuts and useful user information.

I’ve slowly changed it over time to add a bit more information and also regularly poll machine data back to a custom API which is then stored in a SQL database allowing me to report on the number of active machines on my PRTG dashboard. (I kinda have a longer-term vision to use the WAN IP address  and the Google Maps API to display a map on my dashboard with user photos overlayed at their last known location using some geolocation, I can’t really justify the business case for this one though)

Recently, with the addition of the ScreenCloud API, I decided to add a new form, which is locked down to members of a new security group that provides instant control of all the digital signage in the office.

The code first gets all the screen ID’s when it loads (V2 shall have a checkbox list to allow users to control individual screens). The idea being when the fire alarm test is carried out, they can press the corresponding button and change all the displays to a big red ‘Fire Alarm Test in Progress’ image, also reception can advertise when the sandwiches have arrived. Sky News is simply a YouTube app pointing to the live feed of SkyNews. And I threw in a blank screen just in case they all needed to be turned off for whatever reason.

var identity = WindowsIdentity.GetCurrent();

foreach (var groupId in identity.Groups)
	var group = groupId.Translate(typeof(NTAccount));
	if (group.Value == "Domain\\Signage Control")
		menu_RightClick.Items[2].Enabled = true;

The left button options perform the takeover until the “Clear All” is pressed which then resets each screen back to its original playlist. The right side buttons change the screens and it uses a timer to countdown from 3 minutes and then automatically cancel all the takeovers.

var httpWebRequest = (HttpWebRequest)WebRequest.Create(tempurl);

httpWebRequest.Method = methodtype;

httpWebRequest.Headers["Authorization"] = "Basic " + Convert.ToBase64String(Encoding.Default.GetBytes(username + ":" + password));
httpWebRequest.ContentType = "application/json";
using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))

	var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
	using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
		var result = streamReader.ReadToEnd();

Update: Just a little update on this, I’ve started making use of the DURATION parameter now to pass in a time for the takeovers rather than relying on my own app and a Timer. I also created a new page which accepts a querystring text value to display a welcome for guests, nice and easy for staff to set now without needing to login to ScreenCloud and change playlists etc. I also added an option to pass any URL into the selected single screen.