public void Import() { if (!AppConfig.IsImportable) { throw new BizException("Is Importable is false"); } string sql = " select top 1 * from Sys_Sync "; DataSet ds = SqlHelper.ExecuteDataSet(sql); if (Util.HasMoreRow(ds)) { throw new BizException("the table Sync is not empty"); } TransactionOptions options = new TransactionOptions(); options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted; options.Timeout = TransactionManager.DefaultTimeout; using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options)) { SortedList sl = AppEnum.GetSync(); foreach (int syncType in sl.Keys) { SyncInfo oInfo = new SyncInfo(); oInfo.SyncType = syncType; oInfo.LastVersionTime = DateTime.Now; new SyncDac().Insert(oInfo); } scope.Complete(); } }
private void DoSync(int syncType) { string className = AppEnum.GetSync(syncType); Type type = Type.GetType(className); if (type == null) //如果添加新的需要同步的类,就先在数据库里增加,在没有更新程序以前,className 应该是Unknown, Type.GetType的返回就会是null。 { return; } MethodInfo method = type.GetMethod("GetInstance"); IInitializable iInit = (IInitializable)method.Invoke(null, null); iInit.Init(); RegisterLastVersion(syncType); }