Partager via


DevicesManager.ReportDeviceAsync Method (String, Guid, String, DeviceIdentityStatus, String)

 

Asynchronously reports when a new device is added; or a name, or identity status of a device is updated.

Namespace:   Microsoft.WindowsServerSolutions.Common.Devices
Assembly:  DevicesOM (in DevicesOM.dll)

Syntax

public void ReportDeviceAsync(
    string deviceId,
    Guid deviceType,
    string deviceName,
    DeviceIdentityStatus status,
    string additionalIdInfo
)
public:
void ReportDeviceAsync(
    String^ deviceId,
    Guid deviceType,
    String^ deviceName,
    DeviceIdentityStatus status,
    String^ additionalIdInfo
)
Public Sub ReportDeviceAsync (
    deviceId As String,
    deviceType As Guid,
    deviceName As String,
    status As DeviceIdentityStatus,
    additionalIdInfo As String
)

Parameters

  • deviceId
    Type: System.String

    The identifier of the device to be reported.

  • deviceType
    Type: System.Guid

    The type of the device to be reported.

  • deviceName
    Type: System.String

    The name of the device to be reported.

  • additionalIdInfo
    Type: System.String

    The additional identity information, which is the certificate serial number.

Exceptions

Exception Condition
ArgumentNullException

The argument is null or empty.

ArgumentException

The deviceType is Guid.Empty.

Remarks

The caller of this method must subscribe to the ReportDeviceCompleted event to know the result of the report operation. ReportOperationCompletedEventArgs.Error should also be checked to know whether an error occurred with the operation.

Administrator rights are required to perform this operation.

Only devices with a device type from DeviceTypes are listed in the Dashboard.

Examples

The following code example shows how to asynchronously report a device.

using (DevicesManager dm = new DevicesManager())
{
  string deviceId = Guid.NewGuid().ToString();
  Guid deviceType = Constant.MyDeviceType;

  dm.ReportDeviceCompleted += 
    new EventHandler<ReportOperationCompletedEventArgs>(
      dm_ReportDeviceCompleted);

  dm.ReportDevice(deviceId,
                  deviceType,
                  "SDK Device",
                  DeviceIdentityStatus.Active,
                  null);
}

The following code example shows the delegate method.

static void dm_ReportDeviceCompleted(object sender, 
   ReportOperationCompletedEventArgs e)
{
   if (e.Error == null)    // if there was no error
   {
      Console.WriteLine("Successfully reported device {0}", e.DeviceId);
   }
   else
   {
      Console.WriteLine(e.Error.ToString()); // print exception
   }
}

See Also

DeviceTypes
DeviceIdentityStatus
ReportDeviceAsync Overload
DevicesManager Class
Microsoft.WindowsServerSolutions.Common.Devices Namespace

Return to top