示例#1
0
        private void Clone()
        {
            if (config.Object is NotificationTrigger)
            {
                CloneTrigger();
                return;
            }

            var id = config.Cloner(client, DestinationId);

            if (Resolve)
            {
                ResolveObject(id, config.GetObjects, config.Object.GetType());
            }
            else
            {
                if (!config.AllowBasic)
                {
                    return;
                }

                var response = new PSObject();
                response.Properties.Add(new PSNoteProperty("Id", id));
                response.Properties.Add(new PSNoteProperty("Name", config.Name));

                if (config.Host != null)
                {
                    response.Properties.Add(new PSNoteProperty("Host", config.Host));
                }

                WriteObject(response);
            }
        }
示例#2
0
        private void Clone()
        {
            if (config.Object is NotificationTrigger)
            {
                CloneTrigger();
                return;
            }

            if (SkipParent && ParameterSetName == ParameterSet.TargetForSource)
            {
                var source = config.Object as IPrtgObject;

                if (source != null && source.ParentId == DestinationId)
                {
                    WriteWarning($"Skipping '{Destination}' (ID: {DestinationId}) as it is the parent of clone source '{source}' (ID: {source.Id}).");
                    return;
                }
            }

            var id = config.Cloner(client, DestinationId);

            if (Resolve)
            {
                ResolveObject(id, config.GetObjects, config.Object.GetType());
            }
            else
            {
                if (!config.AllowBasic)
                {
                    return;
                }

                var response = new PSObject();
                response.Properties.Add(new PSNoteProperty("Id", id));
                response.Properties.Add(new PSNoteProperty("Name", config.Name));

                if (config.Host != null)
                {
                    response.Properties.Add(new PSNoteProperty("Host", config.Host));
                }

                WriteObject(response);
            }

            //This method is called from ProcessRecordEx; as such it's OK if we try and resume an unresumable object -
            //our exception will be converted into a non-terminating exception and we'll carry on with the next element
            //in the pipeline.
            if (Resume)
            {
                client.ResumeObject(id);
            }
        }
示例#3
0
        private void Clone()
        {
            if (config.Object is NotificationTrigger)
            {
                CloneTrigger();
                return;
            }

            if (SkipParent && ParameterSetName == ParameterSet.TargetForSource)
            {
                var source = config.Object as IPrtgObject;

                if (source != null && source.ParentId == DestinationId)
                {
                    WriteWarning($"Skipping '{Destination}' (ID: {DestinationId}) as it is the parent of clone source '{source}' (ID: {source.Id}).");
                    return;
                }
            }

            var id = config.Cloner(client, DestinationId);

            if (Resolve)
            {
                ResolveObject(id, config.GetObjects, config.Object.GetType());
            }
            else
            {
                if (!config.AllowBasic)
                {
                    return;
                }

                var response = new PSObject();
                response.Properties.Add(new PSNoteProperty("Id", id));
                response.Properties.Add(new PSNoteProperty("Name", config.Name));

                if (config.Host != null)
                {
                    response.Properties.Add(new PSNoteProperty("Host", config.Host));
                }

                WriteObject(response);
            }
        }