Ejemplo n.º 1
0
        /// <summary>
        /// Process Records
        /// </summary>
        protected override void ProcessRecord()
        {
            var queries = new QuerystringBuilder();

            if (StartIndex != null)
            {
                queries.Add("startIndex", StartIndex.Value);
            }

            if (PageCount != null)
            {
                queries.Add("pageCount", PageCount.Value);
            }

            if (Domains != null && Domains.Any())
            {
                queries.Add("domains", string.Join(",", Domains));
            }

            if (EntityTypes != null && EntityTypes.Any())
            {
                queries.Add("entityTypes", string.Join(",", EntityTypes));
            }

            if (Actions != null && Actions.Any())
            {
                queries.Add("actions", string.Join(",", Actions));
            }

            if (!string.IsNullOrWhiteSpace(Search))
            {
                queries.Add("search", Search.Trim());
            }

            if (UserNames != null && UserNames.Any())
            {
                queries.Add("userNames", string.Join(",", UserNames));
            }

            if (StartTime.HasValue)
            {
                queries.Add("startTimeUsecs", StartTime.ToString());
            }

            if (EndTime.HasValue)
            {
                queries.Add("endTimeUsecs", EndTime.ToString());
            }

            var preparedUrl = $"/public/auditLogs/cluster{queries.Build()}";

            WriteDebug(preparedUrl);
            var result = Session.ApiClient.Get <Model.ClusterAuditLogsSearchResult>(preparedUrl);

            WriteObject(result.ClusterAuditLogs, true);
        }
Ejemplo n.º 2
0
        private static void GetAssemblies()
        {
            var files = Directory
                        .GetFiles($@"{BaseDirectory}\Plugins", "*.dll")
                        .ToList();

            newDomains = files.Select(GetDomain).Where(f => f != null).ToList();
            var existingDomains = newDomains.Where(d => Domains.Any(ed => ed.FriendlyName == d.FriendlyName)).ToList();

            existingDomains.ForEach(a => newDomains.Remove(a));
        }
Ejemplo n.º 3
0
        public string GetContent(HttpWebResponse response)
        {
            if (Domains.Any(d => response.ResponseUri.AbsoluteUri.StartsWith(d, StringComparison.OrdinalIgnoreCase)))
            {
                var args = ExtractParameters(response.ResponseUri);
                if (args == null || !args.Any())
                {
                    return(null);
                }

                return(String.Format(MediaFormatSting, args.ToArray()));
            }
            return(null);
        }
Ejemplo n.º 4
0
        private static AppDomain GetDomain(string path)
        {
            if (Domains.Any(d => d.GetAssemblies().Any(a => a.CodeBase == path)))
            {
                return(null);
            }
            var name        = Path.GetFileNameWithoutExtension(path);
            var _appDomain  = AppDomain.CreateDomain(name);
            var runtimePath = $@"{BaseDirectory}\{name}.dll";

            if (!File.Exists(runtimePath))
            {
                File.Copy(path, runtimePath);
            }
            _appDomain.Load(AssemblyName.GetAssemblyName(runtimePath));
            return(_appDomain);
        }
Ejemplo n.º 5
0
        private void Validate()
        {
            var errors = new List <ValidationFailure>();

            foreach (var result in Variables.Select(variable => new VariableValidator <T>().Validate(variable)).Where(result => !result.IsValid))
            {
                errors.AddRange(result.Errors.ToList());
            }

            foreach (var result in Domains.Select(domain => new DomainValidator <T>().Validate(domain)).Where(result => !result.IsValid))
            {
                errors.AddRange(result.Errors.ToList());
            }

            foreach (var result in Relations.Select(relation => new RelationsValidator <T>().Validate(relation)).Where(result => !result.IsValid))
            {
                errors.AddRange(result.Errors.ToList());
            }

            foreach (var result in Constraints.Select(constraint => new ConstraintValidator <T>().Validate(constraint)).Where(result => !result.IsValid))
            {
                errors.AddRange(result.Errors.ToList());
            }

            if (errors.Any())
            {
                throw new ArgumentException(errors.Select(e => e.ErrorMessage).Aggregate((a, b) => $"{a},{b}"));
            }

            if (Relations.Any(r => Variables.All(v => v.Key != r.Key)))
            {
                throw new ArgumentException("Relationships/Variables mismatch");
            }

            if (Relations.Any(r => r.Values.Any(rv => Variables.All(v => v.Key != rv.Key))))
            {
                throw new ArgumentException("Relationships/Variables mismatch");
            }

            if (Domains.Any(d => !d.Values.Any()))
            {
                throw new ArgumentException("Domain start size cannot be zero");
            }
        }
Ejemplo n.º 6
0
 public override bool IsValidContent(Uri uri)
 {
     return(Domains.Any(d => uri.AbsoluteUri.StartsWith(d, StringComparison.OrdinalIgnoreCase)));
 }
Ejemplo n.º 7
0
 protected override bool IsValidContent(HttpWebResponse response)
 {
     return(Domains.Any(d => response.ResponseUri.AbsoluteUri.StartsWith(d, StringComparison.OrdinalIgnoreCase)));
 }