Beispiel #1
0
        static void Main(string[] args)
        {
            //Loop thru all the scmp from the directory. This set to max 2 thread that run parallel and update together
            Parallel.ForEach(Directory.GetFiles(schemaDirectory), new ParallelOptions {
                MaxDegreeOfParallelism = 2
            }, (file) =>
            {
                try
                {
                    // Load comparison from Schema Compare (.scmp) file
                    var comparison = new SchemaComparison(file);

                    Console.WriteLine("Processing " + Path.GetFileName(file));
                    Console.WriteLine("Comparing schema...");

                    SchemaComparisonResult comparisonResult = comparison.Compare();

                    // Publish the changes to the target database
                    Console.WriteLine("Publishing schema...");

                    SchemaComparePublishResult publishResult = comparisonResult.PublishChangesToTarget();

                    Console.WriteLine(publishResult.Success ? "Publish succeeded." : "Publish failed.");
                    Console.WriteLine(" ");
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            });

            Console.ReadLine();
        }
Beispiel #2
0
        public void Execute(TaskExecutionMode mode)
        {
            if (this.CancellationToken.IsCancellationRequested)
            {
                throw new OperationCanceledException(this.CancellationToken);
            }

            try
            {
                this.PublishResult = this.ComparisonResult.PublishChangesToTarget();
            }
            catch (Exception e)
            {
                ErrorMessage = e.Message;
                Logger.Write(TraceEventType.Error, string.Format("Schema compare publish changes operation {0} failed with exception {1}", this.OperationId, e.Message));
                throw;
            }
        }
Beispiel #3
0
        public void Execute(TaskExecutionMode mode)
        {
            if (this.CancellationToken.IsCancellationRequested)
            {
                throw new OperationCanceledException(this.CancellationToken);
            }

            try
            {
                this.PublishResult = this.ComparisonResult.PublishChangesToTarget(this.CancellationToken);
                if (!this.PublishResult.Success)
                {
                    // Sending only errors and warnings - because overall message might be too big for task view
                    ErrorMessage = string.Join(Environment.NewLine, this.PublishResult.Errors.Where(x => x.MessageType == SqlServer.Dac.DacMessageType.Error || x.MessageType == SqlServer.Dac.DacMessageType.Warning));
                    throw new Exception(ErrorMessage);
                }
            }
            catch (Exception e)
            {
                ErrorMessage = e.Message;
                Logger.Write(TraceEventType.Error, string.Format("Schema compare publish changes operation {0} failed with exception {1}", this.OperationId, e.Message));
                throw;
            }
        }