Пример #1
0
        ///<inheritdoc cref="IProjectInfoTransmitter"/>
        public async Task <RepositoryImportResult> Work(TransmitterArguments args, IInputUriProvider uriProvider = null, IProjectInfoBuilder projectInfoBuilder = null)
        {
            if (args == null)
            {
                throw new ArgumentNullException(nameof(args));
            }

            try
            {
                this.DisplayParameters(args);

                IEnumerable <string> uris = this.GetPaths(args, uriProvider ?? UriProviderFactory.Get(args, this.logger));

                if (projectInfoBuilder == null)
                {
                    projectInfoBuilder = ProjectInfoBuilderFactory.Get(args, this.logger);
                }

                this.AddEnrichersToBuilder(projectInfoBuilder);

                IEnumerable <ProjectInfo> infos = projectInfoBuilder.GetInfos(uris);

                this.projectInfoSender.SetBaseAddress(args.ApiBaseUri);

                var result = await this.projectInfoSender.Send(infos).ConfigureAwait(false);

                this.logger.Info("All done");
                return(result);
            }
            catch (Exception ex)
            {
                this.logger.Fatal(ex);
                throw;
            }
        }
        public static IProjectInfoBuilder Get(TransmitterArguments args, ILogger logger)
        {
            if (args == null)
            {
                throw new ArgumentNullException(nameof(args));
            }
            IProjectEnrichersFunnel enrichersFunnel = new ProjectEnrichersFunnel();
            IProjectInfoBuilder     infoBuilder;

            if (args.TransmissionMode == TransmissionMode.LocalDotNetProjects)
            {
                infoBuilder = new DotNetProjectInfoBuilder(logger, enrichersFunnel, args);
                infoBuilder.ProjectInfoEnrichers.Add(new FileListPropertyEnricher());
            }
            else if (args.TransmissionMode == TransmissionMode.ExcelDatabaseBased)
            {
                infoBuilder = new ExcelBasedProjectInfoBuilder(logger, enrichersFunnel, args.PropertyMappings);
            }
            else
            {
                infoBuilder = new ManifestBasedProjectInfoBuilder(logger, enrichersFunnel);
                infoBuilder.ProjectInfoEnrichers.Add(new RelativePathResolvingEnricher());
                infoBuilder.ProjectInfoEnrichers.Add(new AssemblyInfoResolvingEnricher());
            }
            AddGenericEnrichersToProvider(args, infoBuilder, logger);
            return(infoBuilder);
        }
Пример #3
0
        private IEnumerable <string> GetPaths(TransmitterArguments args, IInputUriProvider provider)
        {
            IEnumerable <string> uris;

            if (!string.IsNullOrEmpty(args.ProjectPathsListInputFilePath))
            {
                this.logger.Info($"File paths will be loaded from input file [{args.ProjectPathsListInputFilePath}].");
                var lines = File.ReadAllLines(args.ProjectPathsListInputFilePath);
                this.logger.Info($"Files will be loaded from [{lines.Length}] paths specified in the input file [{args.ProjectPathsListInputFilePath}].");
                return(lines);
            }

            if (args.ProjectPaths != null && args.ProjectPaths.Any())
            {
                this.logger.Info($"Files will be loaded from [{args.ProjectPaths.Count}] paths specified in the arguments.");
                uris = args.ProjectPaths;
            }
            else
            {
                Regex regex = null;
                if (!string.IsNullOrEmpty(args.IgnoredPathsRegex))
                {
                    regex = new Regex(args.IgnoredPathsRegex);
                }
                this.logger.Info($"Loading files from [{args.CodeRootFolder}], excluding those which match regex [{args.IgnoredPathsRegex}]");
                uris = provider.GetUris(args.CodeRootFolder, regex);
            }

            return(uris);
        }
Пример #4
0
        ///<inheritdoc cref="IProjectInfoTransmitter"/>
        public Task Work(string[] args)
        {
            TransmitterArguments arguments = new TransmitterArguments(args);

            this.logger.Debug($"Arguments: {arguments.OriginalParameterInputString}");
            return(this.Work(arguments));
        }
Пример #5
0
        private void DisplayParameters(TransmitterArguments args)
        {
            this.logger.Info($"Command line string: [{args.OriginalParameterInputString}]");
            this.logger.Info($"Resolved parameters:");

            foreach (KeyValuePair <string, string> parameter in args.GetParameterCollection())
            {
                this.logger.Info($"{parameter.Key}: [{parameter.Value}]");
            }
        }
Пример #6
0
 private static IDictionary <string, string> GetProperties(TransmitterArguments arguments)
 {
     return(new Dictionary <string, string>()
     {
         { PropertyKeys.OrganizationName, arguments?.OrganizationName ?? "NULL" },
         { PropertyKeys.RepositoryName, arguments?.RepositoryName ?? "NULL" },
         { PropertyKeys.RepositoryPath, arguments?.CodeRootFolder ?? "NULL" },
         { PropertyKeys.RepositoryMode, arguments?.RepositoryMode.ToString() },
         { PropertyKeys.TransmissionMode, arguments?.TransmissionMode.ToString() },
     });
 }
Пример #7
0
 public static IInputUriProvider Get(TransmitterArguments args, ILogger logger)
 {
     if (args == null)
     {
         throw new ArgumentNullException(nameof(args));
     }
     if (args.TransmissionMode == TransmissionMode.LocalDotNetProjects)
     {
         return(new LocalDotNetProjectUriProvider(logger));
     }
     else if (args.TransmissionMode == TransmissionMode.ExcelDatabaseBased)
     {
         return(new ExcelBasedUriProvider(logger));
     }
     else
     {
         return(new ManifestBasedUriProvider(logger));
     }
 }
Пример #8
0
        public void TestPathsArray()
        {
            var arg = new TransmitterArguments()
            {
                RepositoryName = "MakeSureThisIsNotSplitAsPathsAre",
                ProjectPaths   = new List <string>()
                {
                    @"C:\Folder1\Project", @"C:\Folder2\Project", @"C:\Folder3\Project"
                }
            };

            var stringified = arg.SaveAsParameters();

            stringified.Should().Contain("MakeSureThisIsNotSplitAsPathsAre");
            var resolved = new TransmitterArguments();

            resolved.LoadParameters(stringified);

            resolved.ProjectPaths.Should().Contain(arg.ProjectPaths);
            resolved.RepositoryName.Should().Be("MakeSureThisIsNotSplitAsPathsAre");
        }
 private static void AddGenericEnrichersToProvider(TransmitterArguments args, IProjectInfoBuilder infoBuilder, ILogger logger)
 {
     infoBuilder.ProjectInfoEnrichers.Add(new RepositoryStampAddingEnricher(args.RepositoryStamp, logger));
     infoBuilder.ProjectInfoEnrichers.Add(new RepositoryInfoAddingEnricher(args));
 }
 public DotNetProjectInfoBuilder(ILogger logger, IProjectEnrichersFunnel projectEnrichers, TransmitterArguments args) : base(logger, projectEnrichers)
 {
     this.logger = logger;
     this.args   = args;
 }
 public RepositoryInfoAddingEnricher(TransmitterArguments arguments)
 {
     this.arguments = arguments;
 }
Пример #12
0
        /// <summary>
        /// Ater execution finished
        /// </summary>
        /// <param name="telemetryClient"></param>
        /// <param name="arguments"></param>
        /// <param name="result"></param>
        /// <exception cref="ArgumentNullException"></exception>
        public static void TrackRecurringJobFinished(this TelemetryClient telemetryClient, TransmitterArguments arguments, RepositoryImportResult result)
        {
            if (telemetryClient == null)
            {
                throw new ArgumentNullException(nameof(telemetryClient));
            }
            var props = GetProperties(arguments);

            props.Add(PropertyKeys.SuccessCount, result?.SuccessCount.ToString(CultureInfo.InvariantCulture));
            props.Add(PropertyKeys.FailedCount, result?.FailedCount.ToString(CultureInfo.InvariantCulture));
            telemetryClient.TrackEvent(Names.RecurringJobFinished, props);
        }