Beispiel #1
0
        private void ValidateAndConfigureDatabaseInterface()
        {
            IDatabaseConfigurator configurator = Services.GetService <IDatabaseConfigurator>();

            configurator
            .UseDatabaseProvider(Settings.DatabaseSettings.DatabaseProvider)
            .UseConnectionString(Settings.DatabaseSettings.ConnectionString);

            if (!configurator.TryOpenInfoBase(out InfoBase infoBase, out string errorMessage))
            {
                throw new Exception($"Failed to load 1C metadata:\n{errorMessage}");
            }

            ApplicationObject queue = configurator.GetOutgoingQueueMetadata(infoBase);

            if (queue == null)
            {
                throw new Exception($"Failed to load 1C metadata for the incoming queue.");
            }

            if (!configurator.OutgoingQueueSequenceExists())
            {
                configurator.ConfigureOutgoingQueue(queue);
            }
        }
        private static void ExecuteCommand(string ms, string pg, string db, string usr, string pwd, bool verbose)
        {
            if (string.IsNullOrWhiteSpace(ms) && string.IsNullOrWhiteSpace(pg))
            {
                ShowErrorMessage(SERVER_IS_NOT_DEFINED_ERROR); return;
            }

            if (string.IsNullOrWhiteSpace(db))
            {
                ShowErrorMessage(DATABASE_IS_NOT_DEFINED_ERROR); return;
            }

            IMetadataService metadataService = ConfigureMetadataService(ms, pg, db, usr, pwd);

            DbConfigurator
            .UseDatabaseProvider(metadataService.DatabaseProvider)
            .UseConnectionString(metadataService.ConnectionString);

            if (TryOpenInfoBase(metadataService, out InfoBase infoBase, out string errorMessage))
            {
                ShowInfoBaseInfo(infoBase);
                SetupDatabase(infoBase);
            }