static IEnumerable<string> GetAssemblyInfoFiles(string workingDirectory, Arguments args, IFileSystem fileSystem)
        {
            if (args.UpdateAssemblyInfoFileName != null)
            {
                var fullPath = Path.Combine(workingDirectory, args.UpdateAssemblyInfoFileName);

                if (fileSystem.Exists(fullPath))
                {
                    return new[] { fullPath };
                }
            }

            return fileSystem.DirectoryGetFiles(workingDirectory, "AssemblyInfo.*", SearchOption.AllDirectories)
                .Where(f => f.EndsWith(".cs", StringComparison.OrdinalIgnoreCase) || f.EndsWith(".vb", StringComparison.OrdinalIgnoreCase));
        }
        private async Task <List <CmdLineResult> > GetConnectorsConfig(List <string> connectors)
        {
            return(await Task.Run(() =>
            {
                var ret = new List <CmdLineResult>();
                connectors.ForEach(p =>
                {
                    var files = _filesystem.DirectoryGetFiles(p).ToList();
                    files.ForEach(file =>
                    {
                        if (string.Equals(_filesystem.Path.GetExtension(file), ".config", StringComparison.InvariantCultureIgnoreCase))
                        {
                            ret.Add(new CmdLineResult {
                                Name = $"{_filesystem.Path.GetFileName(p)}_{_filesystem.Path.GetFileName(file)}", Cmd = file, ExecType = CmdLineExecType.FileContent
                            });
                        }
                    });
                });

                return ret;
            }).ConfigureAwait(false));
        }
Example #3
0
        static IEnumerable <string> GetAssemblyInfoFiles(string workingDirectory, Arguments args, IFileSystem fileSystem)
        {
            if (args.UpdateAssemblyInfoFileName != null && args.UpdateAssemblyInfoFileName.Any(x => !string.IsNullOrWhiteSpace(x)))
            {
                foreach (var item in args.UpdateAssemblyInfoFileName)
                {
                    var fullPath = Path.Combine(workingDirectory, item);

                    if (EnsureVersionAssemblyInfoFile(args, fileSystem, fullPath))
                    {
                        yield return(fullPath);
                    }
                }
            }
            else
            {
                foreach (var item in fileSystem.DirectoryGetFiles(workingDirectory, "AssemblyInfo.*", SearchOption.AllDirectories)
                         .Where(f => f.EndsWith(".cs", StringComparison.OrdinalIgnoreCase) || f.EndsWith(".vb", StringComparison.OrdinalIgnoreCase)))
                {
                    yield return(item);
                }
            }
        }
Example #4
0
        private void Reload(string filePath)
        {
            GetCurrentReloadStatus = "Starting";
            ValidateStartup();
            if (filePath == null || (!_filesystem.FileExists(filePath) && !_filesystem.DirectoryExists(filePath)))
            {
                SetInfoMessage("ERROR Path is not correct. Could not load.");
                return;
            }

            LogCollectorOutput = null;
            _zipFilePath       = string.Empty;
            if (_filesystem.Path.GetExtension(filePath).Equals(".zip", StringComparison.InvariantCultureIgnoreCase))
            {
                GetCurrentReloadStatus = "Reading zip file";
                string outputFolderPath = _filesystem.Path.Combine(_filesystem.Path.GetTempPath(), RemoveAllDots(filePath) + "_" + RemoveAllDots(_filesystem.Path.GetTempFileName()));
                if (_filesystem.DirectoryExists(outputFolderPath))
                {
                    outputFolderPath = _filesystem.Path.Combine(outputFolderPath, _filesystem.Path.GetTempFileName());
                }
                _zipFilePath = outputFolderPath;
                int fileCount = 0;
                int totalCount;
                using (var archive = ZipFile.OpenRead(filePath))
                {
                    totalCount = archive.Entries.Count;
                }
                var     events  = new FastZipEvents();
                FastZip fastZip = new FastZip(events);
                events.CompletedFile += (sender, args) =>
                {
                    fileCount++;
                    GetCurrentReloadStatus = $"Unzipping file # {fileCount} of {totalCount}";
                };

                // Will always overwrite if target filenames already exist
                fastZip.ExtractZip(filePath, outputFolderPath, null);

                if (!_filesystem.DirectoryGetFiles(outputFolderPath).Any())
                {
                    if (_filesystem.GetDirectories(outputFolderPath).Count() == 1)
                    {
                        outputFolderPath = _filesystem.GetDirectories(outputFolderPath).First();
                    }
                    else
                    {
                        GetCurrentReloadStatus = "Failed reading the zipfile";
                        throw new Exception("I can't understand the format of this zipfile.");
                    }
                }
                ParsePathForLogs(outputFolderPath);
            }
            else
            {
                ParsePathForLogs(filePath);
            }

            GetCurrentReloadStatus = "Reading files";
            LogCollectorOutput?.GroupedServerInfo?.ForEach(p =>
                                                           LoadPanelHelper.AddSenseLogsForHost(
                                                               p.QlikSenseMachineInfo.HostName + (p.QlikSenseMachineInfo.IsCentral ? " (Central node)" : ""),
                                                               p.Logs
                                                               ));
            GetCurrentReloadStatus = "";
        }
        static IEnumerable<FileInfo> GetAssemblyInfoFiles(string workingDirectory, Arguments args, IFileSystem fileSystem)
        {
            if (args.UpdateAssemblyInfoFileName != null && args.UpdateAssemblyInfoFileName.Any(x => !string.IsNullOrWhiteSpace(x)))
            {
                foreach (var item in args.UpdateAssemblyInfoFileName)
                {
                    var fullPath = Path.Combine(workingDirectory, item);

                    if (EnsureVersionAssemblyInfoFile(args, fileSystem, fullPath))
                    {
                        yield return new FileInfo(fullPath);
                    }
                }
            }
            else
            {
                foreach (var item in fileSystem.DirectoryGetFiles(workingDirectory, "AssemblyInfo.*", SearchOption.AllDirectories))
                {
                    var assemblyInfoFile = new FileInfo(item);

                    if (AssemblyVersionInfoTemplates.IsSupported(assemblyInfoFile.Extension))
                        yield return assemblyInfoFile;
                }
            }
        }
        static IEnumerable<string> GetAssemblyInfoFiles(string workingDirectory, Arguments args, IFileSystem fileSystem)
        {
            if (args.UpdateAssemblyInfoFileName != null && args.UpdateAssemblyInfoFileName.Any(x => !string.IsNullOrWhiteSpace(x)))
            {
                foreach (var item in args.UpdateAssemblyInfoFileName)
                {
                    var fullPath = Path.Combine(workingDirectory, item);

                    if (EnsureVersionAssemblyInfoFile(args, fileSystem, fullPath))
                    {
                        yield return fullPath;
                    }
                }
            }
            else
            {
                foreach (var item in fileSystem.DirectoryGetFiles(workingDirectory, "AssemblyInfo.*", SearchOption.AllDirectories)
                    .Where(f => f.EndsWith(".cs", StringComparison.OrdinalIgnoreCase) || f.EndsWith(".vb", StringComparison.OrdinalIgnoreCase)))
                {
                    yield return item;
                }
            }
        }
        static IEnumerable<string> GetAssemblyInfoFiles(string workingDirectory, Arguments args, IFileSystem fileSystem)
        {
            if (args.UpdateAssemblyInfoFileName != null)
            {
                var fullPath = Path.Combine(workingDirectory, args.UpdateAssemblyInfoFileName);

                if (fileSystem.Exists(fullPath))
                {
                    return new[] { fullPath };
                }
            }

            return fileSystem.DirectoryGetFiles(workingDirectory, "AssemblyInfo.cs", SearchOption.AllDirectories);
        }
Example #8
0
        private void InitCache()
        {
            List <FileTemplateInfo> viewTemplates = new List <FileTemplateInfo>();

            foreach (var viewPath in _configuration.ViewPaths)
            {
                foreach (var configurationExtension in _configuration.Extensions)
                {
                    viewTemplates.AddRange(
                        _fileSystem.DirectoryGetFiles(viewPath, configurationExtension).Select(f =>
                    {
                        var relativePath = GetTemplateId(f).RemoveStartSlash();
                        return(new FileTemplateInfo(relativePath.ToString(), TemplateType.View, f, _fileSystem));
                    }));
                }
            }

            List <FileTemplateInfo> partialTemplates = new List <FileTemplateInfo>();

            foreach (var partialPath in _configuration.PartialPaths)
            {
                foreach (var configurationExtension in _configuration.Extensions)
                {
                    partialTemplates.AddRange(
                        _fileSystem.DirectoryGetFiles(partialPath, configurationExtension).Select(f =>
                    {
                        var relativePath = GetTemplateId(f).RemoveStartSlash();
                        return(new FileTemplateInfo(relativePath.ToString(), TemplateType.Partial, f, _fileSystem));
                    }));
                }
            }

            List <FileTemplateInfo> componentTemplates = new List <FileTemplateInfo>();

            foreach (var componentPath in _configuration.ComponentPaths)
            {
                foreach (var configurationExtension in _configuration.Extensions)
                {
                    componentTemplates.AddRange(
                        _fileSystem.DirectoryGetFiles(componentPath, configurationExtension).Select(f =>
                    {
                        var relativePath = GetTemplateId(f).RemoveStartSlash();
                        return(new FileTemplateInfo(relativePath.ToString(), TemplateType.Component, f, _fileSystem));
                    }));
                }
            }

            var templates = componentTemplates
                            .Concat(partialTemplates)
                            .Concat(viewTemplates)
                            .GroupBy(p => p.Id, StringComparer.InvariantCultureIgnoreCase)
                            .ToDictionary(i => i.Key, i => i.First(), StringComparer.InvariantCultureIgnoreCase);

            _templates       = FilterTemplates(templates);
            _templatesByName = new Dictionary <string, List <FileTemplateInfo> >();
            foreach (var template in _templates)
            {
                var templateName = template.Value.Name;
                if (_templatesByName.ContainsKey(templateName))
                {
                    _templatesByName[templateName].Add(template.Value);
                }
                else
                {
                    _templatesByName[templateName] = new List <FileTemplateInfo> {
                        template.Value
                    };
                }
            }
        }