예제 #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);
 }