Beispiel #1
0
        protected override void EndProcessing()
        {
            taskCount = Tasks.Count;
            if (SearchMethod != BROWSER)
            {
                IList <SqlInstanceResult> list = base.ProcessTasksWithProgressOutput(Tasks).ToList();
                if (this.MyInvocation.BoundParameters.ContainsKey("Name"))
                {
                    list = this.FilterByNameParameter(list, this.GetWildcard(Name));
                }

                WriteObject(list, true);
            }
            else
            {
                using (var udpClient = new UdpClient())
                {
                    int to = THREE;
                    if (_dynLib != null && _dynLib.ParameterHasValue(pName))
                    {
                        to = _dynLib.GetParameterValue <int>(pName) * THOUSAND;
                    }

                    udpClient.Client.ReceiveTimeout = to;
                    List <SqlInstanceResult> results = this.SqlBrowserQuery(Names, udpClient);
                    WriteObject(results, true);
                    this.UpdateProgress(0);
                }
            }
        }
Beispiel #2
0
        protected override void ProcessRecord()
        {
            var newRestrict = new Restriction();

            if (_lib.ParameterHasValue(PARAM))
            {
                newRestrict.Tags.UnionWith(_lib.GetUnderlyingValues <Tag>(PARAM).Select(x => x.Id));
            }

            if (this.ContainsParameter(x => x.IgnoredTerms))
            {
                newRestrict.Ignored.UnionWith(this.IgnoredTerms);
            }

            if (this.ContainsParameter(x => x.RequiredTerms))
            {
                newRestrict.Required.UnionWith(this.RequiredTerms);
            }

            if (base.ShouldProcess(string.Format(SHOULD_MSG, newRestrict.Ignored.ToJson(), newRestrict.Required.ToJson()), "New"))
            {
                Restriction restriction = base.SendSonarrPost <Restriction>(ApiEndpoints.Restriction, newRestrict);
                base.SendToPipeline(restriction);
            }
        }
Beispiel #3
0
        protected override void BeginProcessing()
        {
            base.BeginProcessing();

            if (_dynLib != null && _dynLib.ParameterHasValue("DefaultDatabase"))
            {
                _defDb = _dynLib.GetParameterValue <string>("DefaultDatabase");
            }
        }
Beispiel #4
0
        protected override void BeginProcessing()
        {
            base.BeginProcessing();
            _enc = _dynLib != null && _dynLib.ParameterHasValue(ENCODING)
                ? _dynLib.GetUnderlyingValue <EncodingInfo>(ENCODING).GetEncoding()
                : Encoding.UTF8;

            _so = this.SetOptions(this.MyInvocation.BoundParameters);
        }
Beispiel #5
0
        protected override void BeginProcessing()
        {
            base.BeginProcessing();
            jobs = new List <SmoJob>();
            if (!this.JobId.Equals(Guid.Empty))
            {
                jobs.Add(SmoContext.Connection.JobServer.Jobs.ItemById(this.JobId));
            }

            else if (_dynLib != null && _dynLib.ParameterHasValue("JobName"))
            {
                jobs.AddRange(_dynLib.GetUnderlyingValues <SmoJob>("JobName"));
            }

            else if (this.SqlServer == null && _dynLib != null)
            {
                jobs.AddRange(_dynLib.GetBackingItems <SmoJob>("JobName"));
            }
        }
Beispiel #6
0
        protected override void BeginProcessing()
        {
            base.BeginProcessing();

            if (_dynLib.ParameterHasValue("Database"))
            {
                _dbs = _dynLib.GetUnderlyingValues <Database>("Database");
            }

            _users = new List <SqlUserBase>();
        }
        protected override void EndProcessing()
        {
            if (!NoEnd)
            {
                switch (this.OutputAs)
                {
                case OutputAs.String:
                {
                    byte[] bytes = outStr.GetBytes();
                    base.WriteObject(Encoding.UTF8.GetString(bytes));
                    break;
                }

                case OutputAs.PSCredential:
                {
                    var userName = _dynLib.GetParameterValue <string>(USERNAME);
                    var psCreds  = new PSCredential(userName, outStr.AsSecureString());
                    base.WriteObject(psCreds);
                    break;
                }

                case OutputAs.SecureString:
                    base.WriteObject(outStr.AsSecureString());
                    break;

                case OutputAs.NetworkCredential:
                {
                    NetworkCredential netCreds = null;
                    string            un       = _dynLib.GetParameterValue <string>(USERNAME);
                    SecureString      ss       = outStr.AsSecureString();

                    netCreds = _dynLib.ParameterHasValue(DOMAIN)
                            ? new NetworkCredential(un, ss, _dynLib.GetParameterValue <string>(DOMAIN))
                            : new NetworkCredential(un, ss);

                    base.WriteObject(netCreds);
                    break;
                }

                case OutputAs.SqlCredential:
                {
                    var sqlCreds = new SqlCredential(_dynLib.GetParameterValue <string>(USERNAME), outStr.AsSecureString());
                    base.WriteObject(sqlCreds);
                    break;
                }
                }
            }
        }
Beispiel #8
0
        protected override void BeginProcessing()
        {
            base.BeginProcessing();
            _collation = !_dynLib.ParameterHasValue("Collation")
                ? SmoContext.Connection.Collation
                : _dynLib.GetParameterValue <string>("Collation");

            if (string.IsNullOrEmpty(this.DataFilePath))
            {
                this.DataFilePath = SmoDatabase.GetDefaultDatabasePath();
            }

            if (string.IsNullOrEmpty(this.LogFilePath))
            {
                this.LogFilePath = SmoDatabase.GetDefaultLogPath();
            }
        }
Beispiel #9
0
        protected override void ProcessRecord()
        {
            var smoServer = (SmoServer)SmoContext.Connection;

            if (_dynLib.ParameterHasValue(PROPERTIES))
            {
                string[] props = _dynLib.GetParameterValue <string[]>(PROPERTIES);
                if (props.Contains("*"))
                {
                    WriteWarning("Loading all properties can cause PowerShell to use large amounts of memory if enumerated.  Use caution.");
                    smoServer.LoadProperty(AllProps);
                }
                else
                {
                    smoServer.LoadProperty(props);
                }
            }
            WriteObject(smoServer, false);
        }
Beispiel #10
0
 protected override void ProcessRecord()
 {
     if (!this.ContainsParameter(x => x.Id))
     {
         IEnumerable <Restriction> restrictions = this.GetAllRestrictions();
         restrictions = base.FilterByStringParameter(restrictions, r => r.Ignored, this, cmd => cmd.IgnoredTerms);
         restrictions = base.FilterByStringParameter(restrictions, r => r.Required, this, cmd => cmd.RequiredTerms);
         if (_lib.ParameterHasValue(PARAM))
         {
             IEnumerable <Tag> tags = _lib.GetUnderlyingValues <Tag>(PARAM);
             restrictions = restrictions
                            .Where(x => x.Tags.Overlaps(tags.Select(t => t.Id)));
         }
         base.SendToPipeline(restrictions);
     }
     else
     {
         for (int i = 0; i < this.Id.Length; i++)
         {
             base.SendToPipeline(this.GetRestrictionById(this.Id[i]));
         }
     }
 }
Beispiel #11
0
        private void Sort(ref CollationCollection cols)
        {
            switch (this.SortBy)
            {
            case "Name":
            {
                cols.SortByName(_dynLib.ParameterHasValue("Ascending"));
                break;
            }

            case "LocaleID":
            {
                cols.SortByLocaleID();
                break;
            }

            case "Version":
            {
                cols.SortByVersion();
                break;
            }
            }
        }
Beispiel #12
0
 protected private IEnumerable <Database> RetrieveDatabases()
 {
     return(_dynLib != null && _dynLib.ParameterHasValue(DBNAME)
         ? _dynLib.GetUnderlyingValues <Database>(DBNAME)
         : _dynLib.GetBackingItems <Database>(DBNAME));
 }
Beispiel #13
0
        protected override void ProcessRecord()
        {
            if (_server == null && this.InputObject != null)
            {
                _server = this.InputObject.Parent;
            }

            if (_server == null)
            {
                throw new SmoContextNotSetException();
            }

            if (!string.IsNullOrEmpty(this.LoginName) && base.GetLoginFromName(this.LoginName, out SmoLogin found))
            {
                this.InputObject = found;
            }

            if (this.MyInvocation.BoundParameters.ContainsKey("ProcessId"))
            {
                base.WriteObject(this.FindProcess(this.ProcessId));
            }

            else
            {
                SqlProcessCollection col = this.InputObject != null
                    ? this.FindProcess(this.InputObject)
                    : this.FindProcess();

                if (this.Status.HasValue)
                {
                    col = (SqlProcessCollection)col.FindAll(x => x.Status.HasValue && x.Status.Value == this.Status.Value);
                }

                switch (this.SortBy)
                {
                case "Id":
                {
                    if (_dynLib.ParameterHasValue("Ascending") && _dynLib.GetParameterValue <bool>("Ascending"))
                    {
                        col.SortBySpid(true);
                    }

                    else
                    {
                        col.SortBySpid(false);
                    }

                    break;
                }

                case "Login":
                    col.SortByLogin();
                    break;

                case "Program":
                    col.SortByProgram();
                    break;

                default:
                    col.SortBySpid(false);
                    break;
                }
                base.WriteObject(col, true);
            }
        }