示例#1
0
        private void SetSourceIdObject()
        {
            var sensor = client.GetSensors(Property.Id, SourceId).FirstOrDefault();

            if (sensor != null)
            {
                sourceObj         = sensor;
                sourceObjResolver = GetSensors;
                return;
            }

            var device = client.GetDevices(Property.Id, SourceId).FirstOrDefault();

            if (device != null)
            {
                sourceObj         = device;
                sourceObjResolver = GetDevices;
                return;
            }

            var group = client.GetGroups(Property.Id, SourceId).FirstOrDefault();

            if (group != null)
            {
                sourceObj         = group;
                sourceObjResolver = GetGroups;
                return;
            }

            throw new PSArgumentException($"Cannot clone object with ID '{SourceId}' as it is not a sensor, device or group.");
        }
示例#2
0
 private void ExecuteOperation(SensorOrDeviceOrGroupOrProbe obj)
 {
     if (ShouldProcess($"'{obj.Name}' (ID: {obj.Id}) (Destination ID: {DestinationId})"))
     {
         ExecuteOperation(() => client.MoveObject(obj.Id, DestinationId), $"Moving {obj.BaseType.ToString().ToLower()} {obj.Name} (ID: {obj.Id}) to object ID {DestinationId}");
     }
 }
示例#3
0
        private static int ValidateObject(SensorOrDeviceOrGroupOrProbe obj)
        {
            if (obj == null)
            {
                throw new ArgumentNullException(nameof(obj));
            }

            return(obj.Id);
        }
示例#4
0
        private void ExecuteOperation(SensorOrDeviceOrGroupOrProbe obj)
        {
            var ids = new[] { Id };

            if (ShouldProcess(GetShouldProcessMessage(obj, new[] { Id }, $"Destination ID: {DestinationId}")))
            {
                ExecuteOperation(
                    () => client.MoveObject(GetSingleOperationId(obj, ids)[0], DestinationId),
                    GetSingleOperationProgressMessage(obj, ids, "Moving", obj?.BaseType.ToString().ToLower() ?? "object", $"to object ID {DestinationId}")
                    );
            }
        }
示例#5
0
        public SetPositionParameters(SensorOrDeviceOrGroupOrProbe obj, int position) : base(ValidateObject(obj))
        {
            var newPos = PositionConverter.SerializePosition(position) + (position > obj.Position ? 1 : -1);

            Position = newPos;
        }
示例#6
0
 /// <summary>
 /// If <see cref="Batch"/> is true, queues the object for processing after all items have been identified. Otherwise, executes this cmdlet's action immediately.
 /// </summary>
 /// <param name="obj">The object to process.</param>
 protected void ExecuteOrQueue(SensorOrDeviceOrGroupOrProbe obj)
 {
     ExecuteOrQueue(obj, $"Queuing {obj.BaseType.ToString().ToLower()} '{obj.Name}'");
 }
示例#7
0
        public SetPositionParameters(SensorOrDeviceOrGroupOrProbe obj, int position) : base(ValidateObject(obj))
        {
            var newPos = position * 10 + (position > obj.Position ? 1 : -1);

            Position = newPos;
        }