Page 1 of 1

Entering Maintenance Mode for a device in C# and bug

Posted: Sat Apr 13, 2019 3:14 am
by zenny7100
Is there a way to do this in C#? I know how to do it in PS but there doesn't seem to be a method in the IDevice class to enter maintenance mode.

Also, there is a bug in the C# method GetDeviceByID - the following code doesn't work but should: d.DeviceID returns some string like "0x000001D35A748540" but attempting to find this device using that id and server.GetDeviceById() throws an exception:

IStarWindServer starWindServer1 = ... set up and connect to server
IDevice d = {some device}
starWindServer1.GetDeviceByID(d.DeviceId) => returns "device not found"

Re: Entering Maintenance Mode for a device in C# and bug

Posted: Sun Apr 14, 2019 8:34 pm
by Sekkmer
You have to cast your IDevice to IHADevice than you can use the SwitchMaintenanceMode function.

As for the problem, I never used the GetDeviceByID function but you can use this instead:

var device = Server.Devices.Cast<IDevice>().FirstOrDefault(d => d.DeviceId == "{your device id}");

Re: Entering Maintenance Mode for a device in C# and bug

Posted: Fri Apr 19, 2019 11:15 am
by Oleg(staff)
Yes, GetDeviceByID was not working on the older builds.
Sekkmer, thank you for your input.

Re: Entering Maintenance Mode for a device in C# and bug

Posted: Fri Apr 19, 2019 1:26 pm
by elaw
Hey... is documentation available online for accessing Starwind via C#?

I'd like to do something like the OP is doing... wasn't aware it is possible!

Re: Entering Maintenance Mode for a device in C# and bug

Posted: Fri Apr 19, 2019 3:14 pm
by Oleg(staff)
Hi elaw,
Unfortunately, there is no documentation available online for accessing Starwind via C#.