Ejemplo n.º 1
0
        /// <summary>
        /// 核心的执行逻辑。
        /// </summary>
        protected override void Execute()
        {
            //读取所有的要批处理的实体
            var reader    = new EntityBatchReader(_entityOrList);
            var batchList = reader.Read();

            //反向先删除实体。从子表中的数据开始删除。
            for (int i = batchList.Count - 1; i >= 0; i--)
            {
                var batch = batchList[i];
                if (batch.DeleteBatch.Count > 0)
                {
                    this.ImportDelete(batch);
                    this.SetStatus(batch.DeleteBatch, PersistenceStatus.New);
                }
            }

            //再插入、更新数据
            for (int i = 0, c = batchList.Count; i < c; i++)
            {
                var batch = batchList[i];
                if (batch.InsertBatch.Count > 0)
                {
                    this.ImportInsert(batch);
                    this.SetStatus(batch.InsertBatch, PersistenceStatus.Unchanged);
                }
                if (batch.UpdateBatch.Count > 0)
                {
                    this.ImportUpdate(batch);
                    this.SetStatus(batch.UpdateBatch, PersistenceStatus.Unchanged);
                }
            }

            //更新缓存
            for (int i = 0, c = batchList.Count; i < c; i++)
            {
                var batch = batchList[i];
                if (VersionSyncMgr.IsEnabled)
                {
                    VersionSyncMgr.Repository.UpdateVersion(batch.EntityType);
                }

                if (batch.UpdateBatch.Count > 0)
                {
                    var redundancyUpdater = batch.Repository.DataProvider.DataSaver.CreateRedundanciesUpdater();
                    foreach (var property in batch.Repository.GetPropertiesInRedundancyPath())
                    {
                        foreach (var path in property.InRedundantPathes)
                        {
                            redundancyUpdater.RefreshRedundancy(path.Redundancy);
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 核心的执行逻辑。
        /// </summary>
        protected override void Execute()
        {
            //读取所有的要批处理的实体
            var reader = new EntityBatchReader(_entityOrList);
            var batchList = reader.Read();

            //反向先删除实体。从子表中的数据开始删除。
            for (int i = batchList.Count - 1; i >= 0; i--)
            {
                var batch = batchList[i];
                if (batch.DeleteBatch.Count > 0)
                {
                    this.ImportDelete(batch);
                    this.SetStatus(batch.DeleteBatch, PersistenceStatus.New);
                }
            }

            //再插入、更新数据
            for (int i = 0, c = batchList.Count; i < c; i++)
            {
                var batch = batchList[i];
                if (batch.InsertBatch.Count > 0)
                {
                    this.ImportInsert(batch);
                    this.SetStatus(batch.InsertBatch, PersistenceStatus.Unchanged);
                }
                if (batch.UpdateBatch.Count > 0)
                {
                    this.ImportUpdate(batch);
                    this.SetStatus(batch.UpdateBatch, PersistenceStatus.Unchanged);
                }
            }

            //更新缓存
            for (int i = 0, c = batchList.Count; i < c; i++)
            {
                var batch = batchList[i];
                if (VersionSyncMgr.IsEnabled)
                {
                    VersionSyncMgr.Repository.UpdateVersion(batch.EntityType);
                }

                if (batch.UpdateBatch.Count > 0)
                {
                    var redundancyUpdater = batch.Repository.DataProvider.DataSaver.CreateRedundanciesUpdater();
                    foreach (var property in batch.Repository.GetPropertiesInRedundancyPath())
                    {
                        foreach (var path in property.InRedundantPathes)
                        {
                            redundancyUpdater.RefreshRedundancy(path.Redundancy);
                        }
                    }
                }
            }
        }