protected override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();

            IEnumerable <OrganizationDetail> result = _repository.GetOrganization();

            if (!string.IsNullOrWhiteSpace(Name))
            {
                WildcardPattern includePattern = new WildcardPattern(Name, WildcardOptions.IgnoreCase);
                result = result.Where(o =>
                                      includePattern.IsMatch(o.UniqueName) ||
                                      includePattern.IsMatch(o.FriendlyName) ||
                                      includePattern.IsMatch(o.UrlName)
                                      );
            }
            if (!string.IsNullOrWhiteSpace(Exclude))
            {
                WildcardPattern excludePattern = new WildcardPattern(Exclude, WildcardOptions.IgnoreCase);
                result = result.Where(o =>
                                      !(excludePattern.IsMatch(o.UniqueName) ||
                                        excludePattern.IsMatch(o.FriendlyName) ||
                                        excludePattern.IsMatch(o.UrlName))
                                      );
            }

            result = result.OrderBy(o => o.UrlName);

            WriteObject(result, true);
        }
        private void ConnectByName()
        {
            var org = _repository.GetOrganization(Name);

            if (org == null)
            {
                base.ThrowTerminatingError(new ErrorRecord(new ItemNotFoundException($"No organization found with name: {Name}"), "", ErrorCategory.ConnectionError, this));
            }
            CrmContext.ConnectOrganization(org);

            WriteObject(org, false);
        }
Beispiel #3
0
        private void ConnectByName()
        {
            var org = _repository.GetOrganization(Name);

            if (org == null)
            {
                base.ThrowTerminatingError(new ErrorRecord(new InvalidOperationException(), "", ErrorCategory.InvalidData, this));
            }
            CrmContext.ConnectOrganization(org);

            WriteObject(org, false);
        }
Beispiel #4
0
        protected override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();

            switch (this.ParameterSetName)
            {
            case ConnectOnlineParameterSet:
                ConnectOnline();
                break;

            case ConnectOnPremisesParameterSet:
                ConnectOnPremises();
                break;

            default:
                break;
            }

            WriteObject(_repository.GetOrganization().OrderBy(o => o.UrlName), true);
        }