コード例 #1
0
ファイル: SyncManager.cs プロジェクト: ue96/ue96
        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();
            }
        }
コード例 #2
0
ファイル: SyncDac.cs プロジェクト: ue96/ue96
        public int Insert(SyncInfo oParam)
        {
            string sql = @"INSERT INTO Sys_Sync
                            (
                            SyncType, LastVersionTime
                            )
                            VALUES (
                            @SyncType, @LastVersionTime
                            );set @SysNo = SCOPE_IDENTITY();";

            SqlCommand cmd = new SqlCommand(sql);

            SqlParameter paramSysNo = new SqlParameter("@SysNo", SqlDbType.Int,4);
            SqlParameter paramSyncType = new SqlParameter("@SyncType", SqlDbType.Int,4);
            SqlParameter paramLastVersionTime = new SqlParameter("@LastVersionTime", SqlDbType.DateTime);

            paramSysNo.Direction = ParameterDirection.Output;

            if ( oParam.SyncType != AppConst.IntNull)
                paramSyncType.Value = oParam.SyncType;
            else
                paramSyncType.Value = System.DBNull.Value;
            if ( oParam.LastVersionTime != AppConst.DateTimeNull)
                paramLastVersionTime.Value = oParam.LastVersionTime;
            else
                paramLastVersionTime.Value = System.DBNull.Value;

            cmd.Parameters.Add(paramSysNo);
            cmd.Parameters.Add(paramSyncType);
            cmd.Parameters.Add(paramLastVersionTime);

            return SqlHelper.ExecuteNonQuery(cmd, out oParam.SysNo);
        }
コード例 #3
0
ファイル: SyncDac.cs プロジェクト: ue96/ue96
        public int Update(SyncInfo oParam)
        {
            string sql = @"UPDATE Sys_Sync SET
                            LastVersionTime=@LastVersionTime
                            WHERE SyncType=@SyncType";
            SqlCommand cmd = new SqlCommand(sql);

            SqlParameter paramSyncType = new SqlParameter("@SyncType", SqlDbType.Int,4);
            SqlParameter paramLastVersionTime = new SqlParameter("@LastVersionTime", SqlDbType.DateTime);

            if ( oParam.SyncType != AppConst.IntNull)
                paramSyncType.Value = oParam.SyncType;
            else
                paramSyncType.Value = System.DBNull.Value;
            if ( oParam.LastVersionTime != AppConst.DateTimeNull)
                paramLastVersionTime.Value = oParam.LastVersionTime;
            else
                paramLastVersionTime.Value = System.DBNull.Value;

            cmd.Parameters.Add(paramSyncType);
            cmd.Parameters.Add(paramLastVersionTime);

            return SqlHelper.ExecuteNonQuery(cmd);
        }
コード例 #4
0
ファイル: SyncManager.cs プロジェクト: ue96/ue96
 private void map(SyncInfo oParam, DataRow tempdr)
 {
     oParam.SysNo = Util.TrimIntNull(tempdr["SysNo"]);
     oParam.SyncType = Util.TrimIntNull(tempdr["SyncType"]);
     oParam.LastVersionTime = Util.TrimDateNull(tempdr["LastVersionTime"]);
 }
コード例 #5
0
ファイル: SyncManager.cs プロジェクト: ue96/ue96
 private Hashtable GetDbLastVersion()
 {
     string sql = "select * from sys_sync";
     DataSet ds = SqlHelper.ExecuteDataSet(sql);
     if ( !Util.HasMoreRow(ds))
         return null;
     Hashtable ht = new Hashtable(5);
     foreach(DataRow dr in ds.Tables[0].Rows)
     {
         SyncInfo oInfo = new SyncInfo();
         map(oInfo, dr);
         ht.Add(oInfo.SyncType, oInfo);
     }
     return ht;
 }
コード例 #6
0
ファイル: SyncManager.cs プロジェクト: ue96/ue96
 public void SetDbLastVersion(int syncType)
 {
     SyncInfo oInfo = new SyncInfo();
     oInfo.SyncType = syncType;
     oInfo.LastVersionTime = DateTime.Now;
     new SyncDac().Update(oInfo);
 }