コード例 #1
0
 protected ContentTextNodeParserBase([NotNull] IFactory factory, [NotNull] ITraceService trace, [NotNull] IReferenceParserService referenceParser, [NotNull] ISchemaService schemaService, double priority) : base(priority)
 {
     Factory         = factory;
     Trace           = trace;
     ReferenceParser = referenceParser;
     SchemaService   = schemaService;
 }
コード例 #2
0
        /// <summary>
        /// Executes SQL statement against the active connection and returns scalar value in string.
        /// </summary>
        /// <param name="connection">An active connection.</param>
        /// <param name="commandText">The sql statement to execute with the active connection.</param>
        /// <param name="commandTimeout">Command timeout in seconds.</param>
        /// <param name="transaction">An active transaction.</param>
        /// <param name="traceService">Trace service provider where trace messages will be written.</param>
        /// <returns></returns>
        public static string QuerySingleString(
            this IDbConnection connection,
            string commandText,
            int?commandTimeout         = null,
            IDbTransaction transaction = null,
            ITraceService traceService = null)
        {
            if (null != traceService)
            {
                traceService.Debug($"Executing statement: {Environment.NewLine}{commandText}");
            }

            var command = connection
                          .KeepOpen()
                          .CreateCommand(
                commandText: commandText,
                commandTimeout: commandTimeout,
                transaction: transaction);

            using var reader = command.ExecuteReader();
            if (reader.Read())
            {
                return(reader.GetString(0));
            }

            return(null);
        }
コード例 #3
0
        public void Start(string projectDirectory, [CanBeNull] Action mock = null)
        {
            var toolsDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? string.Empty;

            var app = new Startup().WithToolsDirectory(toolsDirectory).WithProjectDirectory(projectDirectory).Start();
            if (app == null)
            {
                throw new ConfigurationException("Oh no, nothing works!");
            }

            Configuration = app.Configuration;
            CompositionService = app.CompositionService;

            mock?.Invoke();

            Trace = CompositionService.Resolve<ITraceService>();
            FileSystem = CompositionService.Resolve<IFileSystemService>();
            ParseService = CompositionService.Resolve<IParseService>();
            ProjectService = CompositionService.Resolve<IProjectService>();
            ConfigurationService = CompositionService.Resolve<IConfigurationService>();
            SnapshotService = CompositionService.Resolve<ISnapshotService>();
            CheckerService = CompositionService.Resolve<ICheckerService>();
            QueryService = CompositionService.Resolve<IQueryService>();
            LanguageService = CompositionService.Resolve<ILanguageService>();
            RuleService = CompositionService.Resolve<IRuleService>();
            XPathService = CompositionService.Resolve<IXPathService>();
        }
コード例 #4
0
 public TraceController()
 {
     _traceService       = new TraceService();
     _commonService      = new CommonService();
     _aspNetUsersService = new AspNetUsersService();
     _vehicleService     = new VehicleService();
 }
コード例 #5
0
 public TraceServiceTest()
 {
     _traceRepositoryMock     = MockRepository.Create <ITraceRepository>();
     _requestContextMock      = MockRepository.Create <IRequestContext>();
     _apaleoClientFactoryMock = MockRepository.Create <IApaleoClientsFactory>();
     _traceService            = new TraceService(_traceRepositoryMock.Object, _requestContextMock.Object, _apaleoClientFactoryMock.Object);
 }
コード例 #6
0
        public static ITraceService AddDefaultScene(this ITraceService traceService)
        {
            traceService.AddLight(new PointLightEntity()
            {
                Position  = new Vector3(0.0f, 50.0f, 0.0f),
                Intensity = 0.8f,
                Color     = new ColorEntity(1.0f, 1.0f, 1.0f)
            });
            traceService.AddLight(new PointLightEntity()
            {
                Position  = new Vector3(-20.0f, 50.0f, 100.0f),
                Intensity = 0.8f,
                Color     = new ColorEntity(1.0f, 1.0f, 1.0f)
            });
            traceService.AddEssence(new SphereEntity(new Vector3(0.0f, -5.0f, 100.0f), 15.0f));
            traceService.AddEssence(new QuadEntity(
                                        new Vector3(0.0f, -20.0f, 0.0f),
                                        new[]
            {
                new Vector3(-1000.0f, 0.0f, 1000.0f),
                new Vector3(1000.0f, 0.0f, 1000.0f),
                new Vector3(1000.0f, 0.0f, -1000.0f),
                new Vector3(-1000.0f, 0.0f, -1000.0f),
            },
                                        new MaterialEntity()
            {
                Color            = ColorEntity.White,
                DiffuseComponent = 0.7f,
                ReflectComponent = 0.3f,
            }));

            return(traceService);
        }
コード例 #7
0
ファイル: Document.cs プロジェクト: nxkit/nxkit
        /// <summary>
        /// Initializes a new instance.
        /// </summary>
        /// <param name="xml"></param>
        /// <param name="catalog"></param>
        /// <param name="exports"></param>
        Document(
            Func<Document, XDocument> xml,
            ComposablePartCatalog catalog,
            ExportProvider exports)
        {
            Contract.Requires<ArgumentNullException>(xml != null);

            // configure composition
            this.configuration = GetConfiguration(catalog, exports);
            this.container = new CompositionContainer(configuration.HostCatalog, true, new CompositionContainer(configuration.GlobalCatalog, true, configuration.Exports));
            this.container.GetExportedValue<DocumentEnvironment>().SetHost(this);

            // required services
            this.invoker = container.GetExportedValue<IInvoker>();
            this.trace = container.GetExportedValue<ITraceService>();

            // initialize xml
            this.xml = xml(this);
            this.xml.AddAnnotation(this);

            // parallel initialization of common interfaces
            Parallel.ForEach(this.xml.DescendantNodesAndSelf(), i =>
            {
                Enumerable.Empty<object>()
                    .Concat(i.Interfaces<IOnInit>())
                    .Concat(i.Interfaces<IOnLoad>())
                    .ToLinkedList();
            });

            // initial invocation entry
            this.invoker.Invoke(() => { });
        }
コード例 #8
0
        public Project([NotNull] IConfiguration configuration, [NotNull] ITraceService trace, [NotNull] IFactory factory, [NotNull] IFileSystem fileSystem, [NotNull] IParseService parseService, [NotNull] IPipelineService pipelines, [NotNull] ICheckerService checker)
        {
            Configuration = configuration;
            Trace         = trace;
            Factory       = factory;
            FileSystem    = fileSystem;
            ParseService  = parseService;
            Pipelines     = pipelines;
            Checker       = checker;

            Context = Factory.ProjectContext();
            Indexes = Factory.ProjectIndexes(this);

            _projectItems = new LockableList <IProjectItem>(this);
            _diagnostics  = new SynchronizedList <IDiagnostic>();

            Options = ProjectOptions.Empty;

            // load databases from configuration
            foreach (var pair in Configuration.GetSubKeys(Constants.Configuration.Databases))
            {
                var languageNames = Configuration.GetArray(Constants.Configuration.Databases + ":" + pair.Key + ":languages");
                _databases[pair.Key.ToUpperInvariant()] = Factory.Database(this, pair.Key, languageNames);
            }

            // set Context language
            var database = GetDatabase(Configuration.GetString(Constants.Configuration.Database, "master"));

            Assert.IsNotNull(database, "Database specified in 'database' configuration not found");
            Context.Language = database.Languages.First();
        }
コード例 #9
0
        /// <summary>
        /// Initializes a new instance.
        /// </summary>
        /// <param name="xml"></param>
        /// <param name="catalog"></param>
        /// <param name="exports"></param>
        Document(
            Func <Document, XDocument> xml,
            ComposablePartCatalog catalog,
            ExportProvider exports)
        {
            Contract.Requires <ArgumentNullException>(xml != null);

            // configure composition
            this.configuration = GetConfiguration(catalog, exports);
            this.container     = new CompositionContainer(configuration.HostCatalog, true, new CompositionContainer(configuration.GlobalCatalog, true, configuration.Exports));
            this.container.GetExportedValue <DocumentEnvironment>().SetHost(this);

            // required services
            this.invoker = container.GetExportedValue <IInvoker>();
            this.trace   = container.GetExportedValue <ITraceService>();

            // initialize xml
            this.xml = xml(this);
            this.xml.AddAnnotation(this);

            // parallel initialization of common interfaces
            Parallel.ForEach(this.xml.DescendantNodesAndSelf(), i =>
            {
                Enumerable.Empty <object>()
                .Concat(i.Interfaces <IOnInit>())
                .Concat(i.Interfaces <IOnLoad>())
                .ToLinkedList();
            });

            // initial invocation entry
            this.invoker.Invoke(() => { });
        }
コード例 #10
0
ファイル: Program.cs プロジェクト: gvondra/BrassLoon
        public static async Task Main(string[] args)
        {
            DateTime startTime;

            try
            {
                _settings  = LoadSettings(args);
                _container = LoadDiContainer();
                startTime  = DateTime.UtcNow;
                while (true)
                {
                    await StartPurge();

                    startTime = GetNextStartTime(startTime);
                    using (ILifetimeScope scope = _container.BeginLifetimeScope())
                    {
                        SettingsFactory settingsFactory = scope.Resolve <SettingsFactory>();
                        ITraceService   traceService    = scope.Resolve <ITraceService>();
                        await WriteTrace(traceService, settingsFactory, $"Next start time {startTime:O}");
                    }
                    await Task.Delay(startTime.Subtract(DateTime.UtcNow));
                }
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine(ex.ToString());
            }
            finally
            {
                if (_container != null)
                {
                    _container.Dispose();
                }
            }
        }
コード例 #11
0
 public BinFileCompiler([NotNull] IConfiguration configuration, [NotNull] IFactory factory, [NotNull] ITraceService trace, [NotNull] IPipelineService pipelines) : base(1000)
 {
     Configuration = configuration;
     Factory       = factory;
     Trace         = trace;
     Pipelines     = pipelines;
 }
コード例 #12
0
 public SnapshotLayoutFileCompiler([NotNull] IFactory factory, [NotNull] ITraceService trace, [NotNull] IFileSystem fileSystem, [NotNull] ISnapshotService snapshotService, [NotNull] IPathMapperService pathMapper) : base(factory)
 {
     Trace           = trace;
     FileSystem      = fileSystem;
     SnapshotService = snapshotService;
     PathMapper      = pathMapper;
 }
コード例 #13
0
        /// <summary>
        /// Runs database migrations with Yuniql. Use this interface to run migrations targeting non-sqlserver platforms such as PostgreSql and MySql.
        /// </summary>
        /// <param name="builder"></param>
        /// <param name="dataService">Implementation of <see cref="IDataService". See Yuniql.PostgreSql and Yuniql.MySql pacages./></param>
        /// <param name="bulkImportService">Implementation of <see cref="IBulkImportService". See Yuniql.PostgreSql and Yuniql.MySql pacages./></param>
        /// <param name="traceService">Your custom implementation of ITraceService interface</param>
        /// <param name="configuration">Desired configuration when yuniql runs. Set your workspace location, connection string, target version and other parameters.</param>
        /// <returns></returns>
        public static IHostBuilder UseYuniql(
            this IHostBuilder builder,
            IDataService dataService,
            IBulkImportService bulkImportService,
            ITraceService traceService,
            YuniqlConfiguration configuration
            )
        {
            var migrationServiceFactory = new MigrationServiceFactory(traceService);
            var migrationService        = migrationServiceFactory.Create(dataService, bulkImportService);

            migrationService.Initialize(configuration.ConnectionString);
            migrationService.Run(
                configuration.WorkspacePath,
                configuration.TargetVersion,
                configuration.AutoCreateDatabase,
                configuration.Tokens,
                configuration.VerifyOnly,
                configuration.Delimiter,
                configuration.BatchSize,
                configuration.CommandTimeout,
                configuration.ApplyByTool,
                configuration.ApplyByToolVersion,
                configuration.Environment);

            return(builder);
        }
コード例 #14
0
        /// <summary>
        ///     Constructor.
        /// </summary>
        ///
        /// <exception cref="ArgumentNullException">    Thrown when one or more required arguments are null. </exception>
        ///
        /// <param name="messengerService">     The messenger service. This cannot be null. </param>
        /// <param name="localisationService">  The localisation service. This cannot be null. </param>
        /// <param name="traceService">         The trace service. This cannot be null. </param>
        /// <param name="logger">               The logger. This cannot be null. </param>
        /// <param name="messageFactory">       The message factory. This cannot be null. </param>
        /// <param name="dateTimeService">      The date time service. This cannot be null. </param>
        public LoggingServiceSingleton(
            [NotNull] IMessengerService messengerService,
            [NotNull] ILocalisationService localisationService,
            [NotNull] ITraceService traceService,
            [NotNull] ILogger logger,
            [NotNull] IMessageFactory messageFactory,
            [NotNull] IDateTimeService dateTimeService)
        {
            if (logger is null)
            {
                throw new ArgumentNullException(nameof(logger));
            }

            _messengerService    = messengerService ?? throw new ArgumentNullException(nameof(messengerService));
            _localisationService = localisationService ?? throw new ArgumentNullException(nameof(localisationService));
            _traceService        = traceService ?? throw new ArgumentNullException(nameof(traceService));
            _messageFactory      = messageFactory ?? throw new ArgumentNullException(nameof(messageFactory));
            _dateTimeService     = dateTimeService ?? throw new ArgumentNullException(nameof(dateTimeService));

            _logActionDictionary = new Dictionary <MessageLevelEnum, Action <string> >(6)
            {
                { MessageLevelEnum.Verbose, logger.Verbose },
                { MessageLevelEnum.Debug, logger.Debug },
                { MessageLevelEnum.Information, logger.Information },
                { MessageLevelEnum.Warning, logger.Warning },
                { MessageLevelEnum.Error, logger.Error },
                { MessageLevelEnum.Fatal, logger.Fatal }
            };
        }
コード例 #15
0
        public static void Trace([NotNull] this Exception exception, [NotNull] ITraceService trace, [NotNull] IConfiguration configuration)
        {
            var aggregateException = exception as AggregateException;

            if (aggregateException != null)
            {
                foreach (var ex in aggregateException.InnerExceptions)
                {
                    Trace(ex, trace, configuration);
                }

                return;
            }

            trace.TraceError(Msg.I1007, exception.Message);
            if (configuration.GetBool(Constants.Configuration.System.ShowStackTrace))
            {
                trace.WriteLine(exception.StackTrace);
            }

            var innerException = exception.InnerException;

            while (innerException != null)
            {
                Trace(innerException, trace, configuration);
                innerException = innerException.InnerException;
            }
        }
コード例 #16
0
        /// <summary>
        /// Runs database migrations with Yuniql. Use this interface to run migrations targeting non-sqlserver platforms such as PostgreSql and MySql.
        /// </summary>
        /// <param name="builder"></param>
        /// <param name="dataService">Implementation of <see cref="IDataService". See Yuniql.PostgreSql and Yuniql.MySql pacages./></param>
        /// <param name="bulkImportService">Implementation of <see cref="IBulkImportService". See Yuniql.PostgreSql and Yuniql.MySql pacages./></param>
        /// <param name="traceService">Your custom implementation of ITraceService interface</param>
        /// <param name="configuration">Desired configuration when yuniql runs. Set your workspace location, connection string, target version and other parameters.</param>
        /// <returns></returns>
        public static IWebHostBuilder UseYuniql(
            this IWebHostBuilder builder,
            IDataService dataService,
            IBulkImportService bulkImportService,
            ITraceService traceService,
            Configuration configuration
            )
        {
            var migrationServiceFactory = new MigrationServiceFactory(traceService);
            var migrationService        = migrationServiceFactory.Create(dataService, bulkImportService);

            migrationService.Initialize(configuration.ConnectionString);
            migrationService.Run(
                configuration.WorkspacePath,
                targetVersion: configuration.TargetVersion,
                autoCreateDatabase: configuration.AutoCreateDatabase,
                tokens: configuration.Tokens,
                verifyOnly: configuration.VerifyOnly,
                bulkSeparator: configuration.BulkSeparator,
                metaSchemaName: configuration.MetaSchemaName,
                metaTableName: configuration.MetaTableName,
                commandTimeout: configuration.CommandTimeout,
                bulkBatchSize: configuration.BulkBatchSize,
                appliedByTool: configuration.AppliedByTool,
                appliedByToolVersion: configuration.AppliedByToolVersion,
                environmentCode: configuration.Environment,
                resumeFromFailure: configuration.ContinueAfterFailure.HasValue && configuration.ContinueAfterFailure.Value ? NonTransactionalResolvingOption.ContinueAfterFailure : (NonTransactionalResolvingOption?)null,
                noTransaction: configuration.NoTransaction
                );

            return(builder);
        }
コード例 #17
0
        public NavigationService(IPageLoaderService pageLoaderService, ITraceService traceService)
        {
            this.pageLoaderService = pageLoaderService;
            this.traceService      = traceService;

            Root = pageLoaderService.GetDefaultNavigationPage();
        }
コード例 #18
0
        /// <summary>
        /// Runs database migrations with Yuniql. Use this interface to run migrations targeting non-sqlserver platforms such as PostgreSql and MySql.
        /// </summary>
        /// <param name="builder"></param>
        /// <param name="dataService">Implementation of <see cref="IDataService". See Yuniql.PostgreSql and Yuniql.MySql pacages./></param>
        /// <param name="bulkImportService">Implementation of <see cref="IBulkImportService". See Yuniql.PostgreSql and Yuniql.MySql pacages./></param>
        /// <param name="traceService">Your custom implementation of ITraceService interface</param>
        /// <param name="configuration">Desired configuration when yuniql runs. Set your workspace location, connection string, target version and other parameters.</param>
        /// <returns></returns>
        public static IWebHostBuilder UseYuniql(
            this IWebHostBuilder builder,
            IDataService dataService,
            IBulkImportService bulkImportService,
            ITraceService traceService,
            YuniqlConfiguration configuration
            )
        {
            var migrationServiceFactory = new MigrationServiceFactory(traceService);
            var migrationService        = migrationServiceFactory.Create(dataService, bulkImportService);

            migrationService.Initialize(configuration.ConnectionString);
            migrationService.Run(
                configuration.WorkspacePath,
                configuration.TargetVersion,
                autoCreateDatabase: configuration.AutoCreateDatabase,
                tokens: configuration.Tokens,
                verifyOnly: configuration.VerifyOnly,
                bulkSeparator: configuration.BulkSeparator,
                metaSchemaName: configuration.MetaSchemaName,
                metaTableName: configuration.MetaTableName,
                commandTimeout: configuration.CommandTimeout,
                bulkBatchSize: configuration.BulkBatchSize,
                appliedByTool: configuration.ApplyByTool,
                appliedByToolVersion: configuration.ApplyByToolVersion,
                environmentCode: configuration.Environment);

            return(builder);
        }
コード例 #19
0
        ///<inheritdoc/>
        public bool UpdateDatabaseConfiguration(IDbConnection dbConnection, ITraceService traceService = null, string schemaName = null, string tableName = null)
        {
            var columnsTable     = GetVersionTableColumns(dbConnection, traceService, tableName);
            var columnsTableRows = columnsTable.Rows.Cast <DataRow>().Select(x => new { ColumnName = x.Field <string>("COLUMN_NAME"), ColumnType = x.Field <string>("COLUMN_TYPE") }).ToDictionary(x => x.ColumnName, StringComparer.OrdinalIgnoreCase);

            //Add new columns into old version of table
            bool databaseUpdated = false;

            if (!columnsTableRows.ContainsKey("status"))
            {
                this.ExecuteNonQuery(dbConnection, $"ALTER TABLE {tableName ?? this.TableName} ADD COLUMN status VARCHAR(32) NOT NULL", traceService);
                databaseUpdated = true;
            }

            if (!columnsTableRows.ContainsKey("failed_script_path"))
            {
                this.ExecuteNonQuery(dbConnection, $"ALTER TABLE {tableName ?? this.TableName} ADD COLUMN failed_script_path VARCHAR(4000) NULL", traceService);
                databaseUpdated = true;
            }

            if (!columnsTableRows.ContainsKey("failed_script_error"))
            {
                this.ExecuteNonQuery(dbConnection, $"ALTER TABLE {tableName ?? this.TableName} ADD COLUMN failed_script_error VARCHAR(4000) NULL", traceService);
                databaseUpdated = true;
            }

            return(databaseUpdated);
        }
コード例 #20
0
        public CheckerService([NotNull] IConfiguration configuration, [NotNull] IFactory factory, [NotNull] ITraceService trace, [NotNull, ItemNotNull, ImportMany] IEnumerable <IChecker> checkers)
        {
            Configuration = configuration;
            Factory       = factory;
            Trace         = trace;

            var list = new List <CheckerInfo>();

            foreach (var checker in checkers)
            {
                foreach (var method in checker.GetType().GetMethods(BindingFlags.Public | BindingFlags.Instance))
                {
                    if (method.GetCustomAttribute <CheckAttribute>() == null)
                    {
                        continue;
                    }

                    var checkerInfo = new CheckerInfo(method.DeclaringType.Name, method.Name, context =>
                    {
                        var parameters = new object[]
                        {
                            context
                        };

                        return(method.Invoke(checker, parameters) as IEnumerable <IDiagnostic>);
                    });

                    list.Add(checkerInfo);
                }
            }

            Checkers = list;
        }
コード例 #21
0
 public ProjectImportsService([NotNull] IConfiguration configuration, [NotNull] ITraceService trace, [NotNull] IFactory factory, [NotNull] IFileSystem fileSystem)
 {
     Configuration = configuration;
     Trace         = trace;
     Factory       = factory;
     FileSystem    = fileSystem;
 }
コード例 #22
0
        /// <summary>
        /// Executes SQL statement against the active connection and returns scalar value in boolean.
        /// </summary>
        /// <param name="connection">An active connection.</param>
        /// <param name="commandText">The sql statement to execute with the active connection.</param>
        /// <param name="commandTimeout">Command timeout in seconds.</param>
        /// <param name="transaction">An active transaction.</param>
        /// <param name="traceService">Trace service provider where trace messages will be written.</param>
        /// <returns></returns>
        public static bool QuerySingleBool(
            this IDbConnection connection,
            string commandText,
            int?commandTimeout         = null,
            IDbTransaction transaction = null,
            ITraceService traceService = null)
        {
            var stopwatch = new Stopwatch();

            stopwatch.Start();
            var statementCorrelationId = Guid.NewGuid().ToString().Fixed();

            traceService?.Debug($"Executing statement {statementCorrelationId}: {Environment.NewLine}{commandText}");

            var command = connection
                          .KeepOpen()
                          .CreateCommand(
                commandText: commandText,
                commandTimeout: commandTimeout,
                transaction: transaction);

            var result = false;

            using var reader = command.ExecuteReader();
            if (reader.Read())
            {
                result = Convert.ToBoolean(reader.GetValue(0));
            }

            stopwatch.Stop();
            traceService?.Debug($"Statement {statementCorrelationId} executed in {stopwatch.ElapsedMilliseconds} ms");

            return(result);
        }
コード例 #23
0
        /// <summary>
        /// Execute SQL statement against the active connection and returns number of affected rows.
        /// </summary>
        /// <param name="connection">An active connection.</param>
        /// <param name="commandText">The sql statement to execute with the active connection.</param>
        /// <param name="commandTimeout">Command timeout in seconds.</param>
        /// <param name="transaction">An active transaction.</param>
        /// <param name="traceService">Trace service provider where trace messages will be written.</param>
        /// <returns></returns>
        public static int ExecuteNonQuery(
            this IDbConnection connection,
            string commandText,
            int?commandTimeout         = null,
            IDbTransaction transaction = null,
            ITraceService traceService = null)
        {
            var stopwatch = new Stopwatch();

            stopwatch.Start();
            var statementCorrelationId = Guid.NewGuid().ToString().Fixed();

            traceService?.Debug($"Executing statement {statementCorrelationId}: {Environment.NewLine}{commandText}");

            var command = connection
                          .KeepOpen()
                          .CreateCommand(
                commandText: commandText,
                commandTimeout: commandTimeout,
                transaction: transaction);

            var result = command.ExecuteNonQuery();

            stopwatch.Stop();
            traceService?.Debug($"Statement {statementCorrelationId} executed in {stopwatch.ElapsedMilliseconds} ms");

            return(result);
        }
コード例 #24
0
 public static void TraceDiagnostics([NotNull] this ITraceService trace, [NotNull, ItemNotNull] IEnumerable <IDiagnostic> diagnostics, Severity severity, bool treatWarningsAsErrors)
 {
     foreach (var diagnostic in diagnostics)
     {
         TraceDiagnostic(trace, diagnostic, severity, treatWarningsAsErrors);
     }
 }
コード例 #25
0
 /// <inheritdoc />
 public MigrationService(
     ILocalVersionService localVersionService,
     IDataService dataService,
     IBulkImportService bulkImportService,
     IConfigurationDataService configurationDataService,
     ITokenReplacementService tokenReplacementService,
     IDirectoryService directoryService,
     IFileService fileService,
     ITraceService traceService)
     : base(
         localVersionService,
         dataService,
         bulkImportService,
         configurationDataService,
         tokenReplacementService,
         directoryService,
         fileService,
         traceService
         )
 {
     this._localVersionService      = localVersionService;
     this._dataService              = dataService;
     this._bulkImportService        = bulkImportService;
     this._tokenReplacementService  = tokenReplacementService;
     this._directoryService         = directoryService;
     this._fileService              = fileService;
     this._traceService             = traceService;
     this._configurationDataService = configurationDataService;
 }
コード例 #26
0
        public static void TraceDiagnostic([NotNull] this ITraceService trace, [NotNull] IDiagnostic diagnostic, Severity severity, bool treatWarningsAsErrors)
        {
            switch (severity)
            {
            case Severity.Error:
                trace.TraceError(diagnostic.Msg, diagnostic.Text, diagnostic.FileName, diagnostic.Span);
                break;

            case Severity.Warning:
                if (treatWarningsAsErrors)
                {
                    trace.TraceError(diagnostic.Msg, diagnostic.Text, diagnostic.FileName, diagnostic.Span);
                }
                else
                {
                    trace.TraceWarning(diagnostic.Msg, diagnostic.Text, diagnostic.FileName, diagnostic.Span);
                }

                break;

            case Severity.Information:
                trace.TraceInformation(diagnostic.Msg, diagnostic.Text, diagnostic.FileName, diagnostic.Span);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
コード例 #27
0
        public void Start(string projectDirectory, [CanBeNull] Action mock = null)
        {
            var toolsDirectory = Path.Combine(projectDirectory, "sitecore.tools");

            var app = new Startup().WithToolsDirectory(toolsDirectory).WithProjectDirectory(projectDirectory).WithWebsiteAssemblyResolver().Start();
            if (app == null)
            {
                Debug.Write(projectDirectory);
                throw new ConfigurationException(string.Format("Project path not found: {0}", projectDirectory));
            }

            Configuration = app.Configuration;
            CompositionService = app.CompositionService;

            mock?.Invoke();

            Trace = CompositionService.Resolve<ITraceService>();
            FileSystem = CompositionService.Resolve<IFileSystemService>();
            ParseService = CompositionService.Resolve<IParseService>();
            ProjectService = CompositionService.Resolve<IProjectService>();
            ConfigurationService = CompositionService.Resolve<IConfigurationService>();
            SnapshotService = CompositionService.Resolve<ISnapshotService>();
            CheckerService = CompositionService.Resolve<ICheckerService>();
            QueryService = CompositionService.Resolve<IQueryService>();
        }
コード例 #28
0
ファイル: MySqlDataService.cs プロジェクト: mguoth/yuniql
        /// <summary>
        /// Updates the database migration tracking table.
        /// </summary>
        /// <param name="dbConnection">The database connection.</param>
        /// <param name="traceService">The trace service.</param>
        /// <returns>
        /// True if target database was updated, otherwise returns false
        /// </returns>
        public bool UpdateDatabaseConfiguration(IDbConnection dbConnection, ITraceService traceService = null)
        {
            DataTable columnsTable = GetVersionTableColumns(dbConnection, traceService);

            var columnsTableRows = columnsTable.Rows.Cast <DataRow>().Select(x => new { ColumnName = x.Field <string>("COLUMN_NAME"), ColumnType = x.Field <string>("COLUMN_TYPE") }).ToDictionary(x => x.ColumnName, StringComparer.OrdinalIgnoreCase);

            bool databaseUpdated = false;

            //Add new columns into old version of table
            if (!columnsTableRows.ContainsKey("status_id"))
            {
                this.ExecuteNonQuery(dbConnection, "ALTER TABLE ${YUNIQL_TABLE_NAME} ADD COLUMN status_id INT NOT NULL DEFAULT 1 COMMENT '1 - Succeeded, 2 - Failed'", traceService);
                databaseUpdated = true;
            }

            if (!columnsTableRows.ContainsKey("failed_script_path"))
            {
                this.ExecuteNonQuery(dbConnection, "ALTER TABLE ${YUNIQL_TABLE_NAME} ADD COLUMN failed_script_path VARCHAR(4000) NULL", traceService);
                databaseUpdated = true;
            }

            if (!columnsTableRows.ContainsKey("failed_script_error"))
            {
                this.ExecuteNonQuery(dbConnection, "ALTER TABLE ${YUNIQL_TABLE_NAME} ADD COLUMN failed_script_error VARCHAR(4000) NULL", traceService);
                databaseUpdated = true;
            }

            return(databaseUpdated);
        }
コード例 #29
0
 public QueueMessageProcessor(ISleepService sleepService, IQueue queue, ITraceService traceService, IQueueMessageParser messageParser)
 {
     _sleepService = sleepService;
     _queue = queue;
     _traceService = traceService;
     _messageParser = messageParser;
 }
コード例 #30
0
        private DataTable GetVersionTableColumns(IDbConnection dbConnection, ITraceService traceService = null, string tableName = null)
        {
            var dbCommand = (MySqlCommand)dbConnection.CreateCommand();

            dbCommand.CommandText = $"SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = '{tableName ?? this.TableName}' AND table_schema = DATABASE()";

            return(this.FillDataTable(dbCommand, traceService));
        }
コード例 #31
0
 public Factory([NotNull] IConfiguration configuration, [NotNull] ICompositionService compositionService, [NotNull] ITraceService trace, [NotNull] IConsoleService console, [NotNull] IFileSystem fileSystem)
 {
     Configuration      = configuration;
     CompositionService = compositionService;
     Trace      = trace;
     Console    = console;
     FileSystem = fileSystem;
 }
コード例 #32
0
ファイル: MySqlDataService.cs プロジェクト: mguoth/yuniql
        private DataTable GetVersionTableColumns(IDbConnection dbConnection, ITraceService traceService = null)
        {
            MySqlCommand dbCommand = (MySqlCommand)dbConnection.CreateCommand();

            dbCommand.CommandText = "SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = '${YUNIQL_TABLE_NAME}' AND table_schema = DATABASE()";

            return(this.FillDataTable(dbCommand, traceService));
        }
コード例 #33
0
 public DigitalAssetController(ICacheProvider cacheProvider, IDigialAssetService digitalAssetService, IUow uow, ITraceService traceService)
 {
     _digitalAssetService = digitalAssetService;
     _uow          = uow;
     _repository   = uow.DigitalAssets;
     _cache        = cacheProvider.GetCache();
     _traceService = traceService;
 }
コード例 #34
0
 protected TemplateTextNodeParserBase([NotNull] IFactory factory, [NotNull] ITraceService trace, [NotNull] IPipelineService pipelines, [NotNull] IReferenceParserService referenceParser, [NotNull] ISchemaService schemaService, double priority) : base(priority)
 {
     Factory         = factory;
     Trace           = trace;
     Pipelines       = pipelines;
     ReferenceParser = referenceParser;
     SchemaService   = schemaService;
 }
コード例 #35
0
ファイル: Include.cs プロジェクト: nxkit/nxkit
 public Include(
     XElement element,
     IncludeProperties properties,
     ITraceService trace,
     IIOService io)
     : this(element, () => properties, trace, io)
 {
     Contract.Requires<ArgumentNullException>(element != null);
     Contract.Requires<ArgumentNullException>(properties != null);
     Contract.Requires<ArgumentNullException>(trace != null);
     Contract.Requires<ArgumentNullException>(io != null);
 }
コード例 #36
0
ファイル: Include.cs プロジェクト: nxkit/nxkit
 public Include(
     XElement element,
     Extension<IncludeProperties> properties,
     ITraceService trace,
     IIOService io)
     : base(element, () => properties.Value, trace, io)
 {
     Contract.Requires<ArgumentNullException>(element != null);
     Contract.Requires<ArgumentNullException>(properties != null);
     Contract.Requires<ArgumentNullException>(trace != null);
     Contract.Requires<ArgumentNullException>(io != null);
 }
コード例 #37
0
 protected override void TraceLine(ITraceService trace, int msg, string text, ITextNode textNode, ISnapshot snapshot, string details)
 {
     if (textNode != null)
     {
         trace.TraceInformation(msg, text, textNode, details);
     }
     else if (snapshot != null)
     {
         trace.TraceInformation(msg, text, snapshot.SourceFile, details);
     }
     else
     {
         trace.TraceInformation(msg, text, details);
     }
 }
コード例 #38
0
ファイル: Include.cs プロジェクト: nxkit/nxkit
        /// <summary>
        /// Initializes a new instance.
        /// </summary>
        /// <param name="element"></param>
        /// <param name="properties"></param>
        /// <param name="trace"></param>
        /// <param name="io"></param>
        public Include(
            XElement element,
            Func<IncludeProperties> properties,
            ITraceService trace,
            IIOService io)
            : base(element)
        {
            Contract.Requires<ArgumentNullException>(element != null);
            Contract.Requires<ArgumentNullException>(properties != null);
            Contract.Requires<ArgumentNullException>(trace != null);
            Contract.Requires<ArgumentNullException>(io != null);

            this.properties = properties;
            this.trace = trace;
            this.io = io;
        }
コード例 #39
0
        public IParseContext With(IProject project, ISnapshot snapshot)
        {
            Project = project;
            Snapshot = snapshot;
            Trace = new ProjectDiagnosticTraceService(Configuration, Console, Factory).With(Project);

            var fileContext = FileContext.GetFileContext(Project, Configuration, snapshot.SourceFile);
            FilePath = fileContext.FilePath;
            ItemName = fileContext.ItemName;
            ItemPath = fileContext.ItemPath;
            DatabaseName = fileContext.DatabaseName;
            IsExtern = fileContext.IsExtern;
            UploadMedia = fileContext.UploadMedia;

            return this;
        }
コード例 #40
0
ファイル: EventTarget.cs プロジェクト: nxkit/nxkit
        public EventTarget(
            XNode node,
            IEventFactory events,
            ITraceService trace,
            IInvoker invoker)
            : base(node)
        {
            Contract.Requires<ArgumentNullException>(node != null);
            Contract.Requires<ArgumentNullException>(events != null);
            Contract.Requires<ArgumentNullException>(trace != null);
            Contract.Requires<ArgumentNullException>(invoker != null);

            this.node = node;
            this.events = events;
            this.trace = trace;
            this.invoker = invoker;
            this.state = node.AnnotationOrCreate<EventTargetState>();
        }
コード例 #41
0
 public TraceLogger([NotNull] ITraceService trace)
 {
     _trace = trace;
 }
コード例 #42
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="trace"></param>
 public ThreadHelper(ITraceService trace)
 {
     Trace = trace;
 }
コード例 #43
0
 public TraceLogger(ITraceService trace)
 {
     _trace = trace;
 }