Get Task Status (C# code sample)
Problem this snippet solves:
This C# client code sample uses Enterprise Manager's device inventory to get the status for a specific task executed by the referenced Enterprise Manager.
Code :
using System; using iControl; /** * A class for testing the Management::EM::get_task_status iControl interface. */ class ManagementEMGetTaskStatus { private static int MIN_ARGS = 3; private static string USAGE = "ManagementEMGetTaskStatus " + "[]"; private static int EM_PORT = 443; /** * The main method. * * @param args command line arguments */ static void Main(string[] args) { if (args.Length < MIN_ARGS) { Console.WriteLine("Usage: " + USAGE); Environment.Exit(1); } string emAddress = args[0]; string emUsername = args[1]; string emPassword = args[2]; String[] taskIds = new String[args.Length - MIN_ARGS]; for (int i = 0; i < taskIds.Length; i++) { taskIds[i] = args[i + MIN_ARGS]; } iControl.ManagementEMTaskStatus[] statuses = null; try { Interfaces ic = new Interfaces(); ic.initialize(emAddress, EM_PORT, emUsername, emPassword); statuses = ic.ManagementEM.get_task_status(taskIds); if (statuses.Length != taskIds.Length) { throw new Exception("wrong number of status values returned"); } } catch (Exception e) { Console.WriteLine("Failed to get task status: " + e.Message); Environment.Exit(1); } for (int i = 0; i < taskIds.Length; i++) { Console.Write("Task "); Console.Write(taskIds[i]); Console.Write(": "); Console.WriteLine(statuses[i]); } } // Main } // class ManagementEMGetTaskStatus
Published Mar 09, 2015
Version 1.0CodeCentral_194
Cirrus
Joined May 05, 2019
CodeCentral_194
Cirrus
Joined May 05, 2019
No CommentsBe the first to comment