Esempio n. 1
0
        /// <summary>
        /// Performs enhanced record-by-record processing functionality for the cmdlet.
        /// </summary>
        protected override void ProcessRecordEx()
        {
            var ids = new[] { Id };
            var id  = GetSingleOperationId(Device, ids)[0];

            if (ShouldProcess(GetShouldProcessMessage(Device, ids)))
            {
                if (TemplateName != null && TemplateName.Length > 0)
                {
                    var templates = client.GetDeviceTemplates(id);

                    Template = templates.Where(template => TemplateName
                                               .Select(name => new WildcardPattern(name, WildcardOptions.IgnoreCase))
                                               .Any(filter => filter.IsMatch(template.Name) || filter.IsMatch(template.Value))
                                               ).ToArray();

                    if (Template.Length == 0)
                    {
                        throw new ArgumentException($"No device templates could be found that match the specified template names {TemplateName.ToQuotedList()}.");
                    }
                }

                ExecuteOperation(
                    () => client.AutoDiscover(id, Template),
                    GetSingleOperationProgressMessage(Device, ids, "Starting Auto-Discovery on", "device")
                    );
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Performs enhanced record-by-record processing functionality for the cmdlet.
        /// </summary>
        protected override void ProcessRecordEx()
        {
            if (ShouldProcess($"'{Device.Name}' (ID: {Device.Id})"))
            {
                if (TemplateName != null && TemplateName.Length > 0)
                {
                    var templates = client.GetDeviceTemplates(Device.Id);

                    Template = templates.Where(template => TemplateName
                                               .Select(name => new WildcardPattern(name, WildcardOptions.IgnoreCase))
                                               .Any(filter => filter.IsMatch(template.Name) || filter.IsMatch(template.Value))
                                               ).ToArray();

                    if (Template.Length == 0)
                    {
                        throw new ArgumentException($"No device templates could be found that match the specified template names {string.Join(", ", TemplateName.Select(t => $"'{t}'"))}");
                    }
                }

                ExecuteOperation(() => client.AutoDiscover(Device.Id, Template), $"Starting Auto-Discovery on device '{Device}'");
            }
        }