/// <summary> /// 删除消息。 /// </summary> /// <param name="type"></param> /// <param name="xxbh"></param> /// <param name="userId"></param> /// <returns></returns> public bool DelMessage(int type, string xxbh, string userId) { DataTableOperation dtOperation = new DataTableOperation(); OracleDbOperation dbOperation = new OracleDbOperation(OracleHelper.ConnectionString); dbOperation.BeginTransaction(); string tableName; string sql; List <OracleParameter> parameters = new List <OracleParameter>(); tableName = "xtxx"; sql = "select * from " + tableName + " a where a.xxbh = :xxbh"; parameters.Clear(); parameters.Add(new OracleParameter("xxbh", xxbh)); DataTable dtXtxx = dbOperation.ExecuteDataTable(sql, tableName, parameters); if (dtXtxx.Rows.Count > 0) { DataRow drXtxx = dtXtxx.Rows[0]; tableName = "xtxxjs"; sql = "select * from " + tableName + " a where a.jsxxbh = :jsxxbh"; parameters.Clear(); parameters.Add(new OracleParameter("jsxxbh", xxbh)); DataTable dtXtxxjs = dbOperation.ExecuteDataTable(sql, tableName, parameters); switch (type) { case 0: var drXtxxjs = (from DataRow dr in dtXtxxjs.Rows where dr["JSR"].ToString() == userId select dr).First(); drXtxxjs["jsrsc"] = "1"; break; case 1: drXtxx["fsrsc"] = "1"; break; } int xtxxjsUndeleteCount = (from DataRow dr in dtXtxxjs.Rows where dr["jsrsc"].ToString() == "0" select dr).Count(); string xtxxDeleteState = drXtxx["fsrsc"].ToString(); if (xtxxjsUndeleteCount == 0 && xtxxDeleteState == "1") { dtOperation.ClearDbDataTable(dtXtxx); dtOperation.ClearDbDataTable(dtXtxxjs); DeleteMessageFile(xxbh, null); } dbOperation.UpdateDataTable(dtXtxx); dbOperation.UpdateDataTable(dtXtxxjs); dbOperation.Commit(); } else { dbOperation.Rollback(); return(false); } return(true); }
/// <summary> /// 删除消息。 /// </summary> /// <param name="type"></param> /// <param name="xxbh"></param> /// <param name="userId"></param> /// <returns></returns> public bool DelMessage(int type, string xxbh, string userId) { DataTableOperation dtOperation = new DataTableOperation(); OracleDbOperation dbOperation = new OracleDbOperation(OracleHelper.ConnectionString); dbOperation.BeginTransaction(); string tableName; string sql; List<OracleParameter> parameters = new List<OracleParameter>(); tableName = "xtxx"; sql = "select * from " + tableName + " a where a.xxbh = :xxbh"; parameters.Clear(); parameters.Add(new OracleParameter("xxbh", xxbh)); DataTable dtXtxx = dbOperation.ExecuteDataTable(sql, tableName, parameters); if (dtXtxx.Rows.Count > 0) { DataRow drXtxx = dtXtxx.Rows[0]; tableName = "xtxxjs"; sql = "select * from " + tableName + " a where a.jsxxbh = :jsxxbh"; parameters.Clear(); parameters.Add(new OracleParameter("jsxxbh", xxbh)); DataTable dtXtxxjs = dbOperation.ExecuteDataTable(sql, tableName, parameters); switch (type) { case 0: var drXtxxjs = (from DataRow dr in dtXtxxjs.Rows where dr["JSR"].ToString() == userId select dr).First(); drXtxxjs["jsrsc"] = "1"; break; case 1: drXtxx["fsrsc"] = "1"; break; } int xtxxjsUndeleteCount = (from DataRow dr in dtXtxxjs.Rows where dr["jsrsc"].ToString() == "0" select dr).Count(); string xtxxDeleteState = drXtxx["fsrsc"].ToString(); if (xtxxjsUndeleteCount == 0 && xtxxDeleteState == "1") { dtOperation.ClearDbDataTable(dtXtxx); dtOperation.ClearDbDataTable(dtXtxxjs); DeleteMessageFile(xxbh, null); } dbOperation.UpdateDataTable(dtXtxx); dbOperation.UpdateDataTable(dtXtxxjs); dbOperation.Commit(); } else { dbOperation.Rollback(); return false; } return true; }
/// <summary> /// 同步。 /// </summary> /// <param name="setting">同步配置。</param> /// <param name="log">日志信息。</param> /// <returns>同步是否成功。</returns> public bool Sync(SyncConfig syncConfig, SyncConfigTarget targetConfig, SyncConfigLocal localConfig, ref StringBuilder sbLog) { bool result = false; LogOperation.Append(sbLog, string.Format("开始同步数据:{0}({1}) 开始时间:{2}", targetConfig.Name, targetConfig.Code, DateTime.Now)); OracleDbOperation localDb = new OracleDbOperation(localConfig.DbConfig.ConnStr); FtpHelper localFtp = new FtpHelper(localConfig.FtpConfig.Ip, localConfig.FtpConfig.Port, localConfig.FtpConfig.Username, localConfig.FtpConfig.Password); OracleDbOperation targetDb = new OracleDbOperation(targetConfig.DbConfig.ConnStr); FtpHelper targetFtp = new FtpHelper(targetConfig.FtpConfig.Ip, targetConfig.FtpConfig.Port, targetConfig.FtpConfig.Username, targetConfig.FtpConfig.Password); try { targetDb.BeginTransaction(); localDb.BeginTransaction(); List <SyncData> syncDataList = new List <SyncData>(); ////系统数据 syncDataList.Add(new SyncDataSystemInfo(targetDb, localDb, targetConfig.Code, localConfig.Code, targetFtp, localFtp, sbLog)); ////项目数据 syncDataList.Add(new SyncDataItem(syncConfig, targetDb, localDb, targetConfig.Code, localConfig.Code, targetFtp, localFtp, sbLog)); ////流程数据 syncDataList.Add(new SyncDataWorkflow(targetDb, localDb, targetConfig.Code, localConfig.Code, targetFtp, localFtp, sbLog)); ////Syncs.Add(new SyncXtxx(targetDbOperation, localDbOperation, targetSetting.Code, localSetting.Code, targetFtpOperation, localFtpOperation, sbLog)); foreach (var syncData in syncDataList) { syncData.Sync(); } targetDb.Commit(); localDb.Commit(); result = true; } catch (Exception e) { targetDb.Rollback(); localDb.Rollback(); LogOperation.WriteExceptionLog(sbLog, e); } sbLog.AppendLine(); sbLog.AppendLine("结束时间:" + DateTime.Now); return(result); }
/// <summary> /// 同步。 /// </summary> /// <param name="setting">同步配置。</param> /// <param name="log">日志信息。</param> /// <returns>同步是否成功。</returns> public bool Sync(SyncConfig syncConfig, SyncConfigTarget targetConfig, SyncConfigLocal localConfig, ref StringBuilder sbLog) { bool result = false; LogOperation.Append(sbLog, string.Format("开始同步数据:{0}({1}) 开始时间:{2}", targetConfig.Name, targetConfig.Code, DateTime.Now)); OracleDbOperation localDb = new OracleDbOperation(localConfig.DbConfig.ConnStr); FtpHelper localFtp = new FtpHelper(localConfig.FtpConfig.Ip, localConfig.FtpConfig.Port, localConfig.FtpConfig.Username, localConfig.FtpConfig.Password); OracleDbOperation targetDb = new OracleDbOperation(targetConfig.DbConfig.ConnStr); FtpHelper targetFtp = new FtpHelper(targetConfig.FtpConfig.Ip, targetConfig.FtpConfig.Port, targetConfig.FtpConfig.Username, targetConfig.FtpConfig.Password); try { targetDb.BeginTransaction(); localDb.BeginTransaction(); List<SyncData> syncDataList = new List<SyncData>(); ////系统数据 syncDataList.Add(new SyncDataSystemInfo(targetDb, localDb, targetConfig.Code, localConfig.Code, targetFtp, localFtp, sbLog)); ////项目数据 syncDataList.Add(new SyncDataItem(syncConfig, targetDb, localDb, targetConfig.Code, localConfig.Code, targetFtp, localFtp, sbLog)); ////流程数据 syncDataList.Add(new SyncDataWorkflow(targetDb, localDb, targetConfig.Code, localConfig.Code, targetFtp, localFtp, sbLog)); ////Syncs.Add(new SyncXtxx(targetDbOperation, localDbOperation, targetSetting.Code, localSetting.Code, targetFtpOperation, localFtpOperation, sbLog)); foreach (var syncData in syncDataList) { syncData.Sync(); } targetDb.Commit(); localDb.Commit(); result = true; } catch (Exception e) { targetDb.Rollback(); localDb.Rollback(); LogOperation.WriteExceptionLog(sbLog, e); } sbLog.AppendLine(); sbLog.AppendLine("结束时间:" + DateTime.Now); return result; }