private void AddClientDbStatus(DbSyncStatus status) { var bll = new DbSyncStatusBll(); for (var i = 0; i < 5; i++) { bll.Insert(status); if (status.Id > 0) { return; } } throw new Exception($"插入 DbSyncStatus 失败,Identity={status.DbIdentity}, Position=${status.Position}, LastTime={status.LastTime}"); }
public SyncInfo Export(SyncInfo syncInfo) { var dbLogMaxId = syncInfo.DbUpdateLogMaxId; var bll = new DbSyncStatusBll(); var status = bll.QuerySingle($"[DbIdentity]='{syncInfo.DbIdentity}'"); if (status == null) { status = new DbSyncStatus { DbIdentity = syncInfo.DbIdentity.ToString(), LastTime = DateTime.Now, Position = dbLogMaxId, TableName = nameof(DbUpdateLog) }; AddClientDbStatus(status); } if (syncInfo.ClientWriteSuccess) { status.Position = dbLogMaxId; status.LastTime = DateTime.Now; bll.Update(status); } else { dbLogMaxId = status.Position; } var newData = GetNewData(dbLogMaxId); syncInfo.ServerData = newData.Data; syncInfo.PathList = newData.PathList; syncInfo.ClientWriteSuccess = false; syncInfo.ServerNewDataFlag = newData.NewDataFlag; var dbLogBll = new DbUpdateLogBll(); syncInfo.DbUpdateLogMaxId = (int)dbLogBll.GetMaxId(); return(syncInfo); }