Beispiel #1
0
 public static void StartJob(this IMergeLog @this, [CallerMemberName] string name = "")
 {
     //if (_stopwatch != null) { _stopwatch.Stop(); }
     //_stopwatch = Stopwatch.StartNew();
     @this.PostStatus("Starting " + name);
     Debug.WriteLine("Started job component " + name);
 }
Beispiel #2
0
        public static void MakeMergeTables(
            DAL master,
            IEnumerable <MergeTableCommandBuilder> commandBuilders,
            CancellationToken cancellation,
            IProgress <int> progress,
            IMergeLog log)
        {
            log?.StartJob();
            var unitsOfWork = commandBuilders.Count();

            master.BeginTransaction();
            try
            {
                var i = 0;
                foreach (MergeTableCommandBuilder cmdBldr in commandBuilders)
                {
                    log?.PostStatus("Create " + cmdBldr.MergeTableName);

                    master.Execute("DROP TABLE IF EXISTS " + cmdBldr.MergeTableName + ";");
                    master.Execute(cmdBldr.MakeMergeTableCommand);
                    progress?.Report((++i * 100) / unitsOfWork);
                }

                master.CommitTransaction();
            }
            catch
            {
                master.RollbackTransaction();
                throw;
            }
        }
Beispiel #3
0
        public static void ProcessMergeTable(DAL master,
                                             MergeTableCommandBuilder commandBuider,
                                             IEnumerable <ComponentFile> components,
                                             IMergeLog log)
        {
            log?.PostStatus("Processing " + commandBuider.MergeTableName);

            //run various comparisons
            ProcessComparisons(master, commandBuider);

            //ProcessInvalidMatchs(mergeDB, commandBuider);
            ProcessFullMatchs(master, commandBuider);
            SetPartialMatches(master, commandBuider);

            IdentifySiblingRecords(master, commandBuider);
            FindNaturalSiblingMatches(master, commandBuider);

            if (commandBuider.HasRowVersion)
            {
                SetMasterRowVersion(master, commandBuider);//master row version is used to determine which file has the changes in the case where the master can update the component.
            }

            if (commandBuider.MergeNewFromMaster)
            {
                ProcessMasterNew(master, commandBuider, components);//add merge records for records that are new on the master side
            }
        }
Beispiel #4
0
 public static void EndJob(this IMergeLog @this, [CallerMemberName] string name = "")
 {
     //if (_stopwatch != null)
     //{
     //    _stopwatch.Stop();
     //    Debug.WriteLine("Ended job component " + _currentJobName + " in " + _stopwatch.ElapsedMilliseconds + "mSec");
     //}
     @this.PostStatus(name + ": done");
 }
Beispiel #5
0
 private static void ExecuteMaintenanceScript(
     ISimpleSQLScript maintenanceScript,
     DAL master,
     IEnumerable <ComponentFile> components,
     IMergeLog log)
 {
     if (master != null && maintenanceScript.CheckCanExecute(master))
     {
         log?.PostStatus($"Applying {maintenanceScript.Name} To Master");
         maintenanceScript.Execute(master);
     }
     if (components != null)
     {
         foreach (var comp in components)
         {
             if (maintenanceScript.CheckCanExecute(comp.Database))
             {
                 log?.PostStatus($"Applying {maintenanceScript.Name} Fix To " + comp.FileName);
                 maintenanceScript.Execute(comp.Database);
             }
         }
     }
 }
Beispiel #6
0
        public static void PopulateMergeTables(
            DAL master,
            ComponentFile comp,
            IEnumerable <MergeTableCommandBuilder> commandBuilders,
            CancellationToken cancellation,
            IProgress <int> progress,
            IMergeLog log)
        {
            var compNumber = comp.Component_CN;

            master.AttachDB(comp.Database, COMP_ALIAS); //may throw exception
            master.BeginTransaction();
            try
            {
                var unitsOfWork = commandBuilders.Count();
                var i           = 0;
                foreach (var cmdBldr in commandBuilders)
                {
                    cancellation.ThrowIfCancellationRequested();

                    var comp_CN = (int)comp.Component_CN.Value;

                    master.Execute(cmdBldr.GetPopulateMergeTableCommand(comp_CN));
                    master.Execute(cmdBldr.GetPopulateDeletedRecordsCommand(comp_CN));
                    progress?.Report((++i * 100) / unitsOfWork);
                }

                master.CommitTransaction();
                log?.PostStatus("Imported Merge Info For Component #" + compNumber);
            }
            catch
            {
                master.RollbackTransaction();
                throw;
            }
            finally
            {
                master.DetachDB(COMP_ALIAS);
            }
        }