public bool IsTableExist(string conStr, string tableName) { var service = new DatabaseOperate(_log, conStr); var cmd = $"select top 1 * from {tableName}"; return(service.Execute(cmd)); }
public DataService37(string constr) { _deletePeriodDays = 1; _bakupPeriodMinutes = 1; _log = LogManager.GetLogger("DataServiceLog"); _dbService = new DatabaseOperate(_log, constr); DataTables = new BakupTable { LocalBiDataTable = "BI_Data", RemoteBiDataTable = "BI_Data_TEST", LocalBiSummaryDataTable = "BI_Data_Summary", RemoteBiSummaryDataTable = "BI_Data_Summary_TEST", LocalBiSpecificationTable = "BI_Specification", RemoteBiBiSpecificationTable = "BI_Specification", LocalBiMap = "BI_Map" }; InitTimer(); }
private void UpdateRemoteBiSummaryData(string remoteConStr) { var table = FetchLocalUploadData(DataTables.LocalBiSummaryDataTable, BurnState.End); if (table.Rows.Count <= 0) { return; } //UPDATE A SET A1 = B1, A2 = B2, A3 = B3 FROM A LEFT JOIN B ON A.ID = B.ID var remoteService = new DatabaseOperate(_log, remoteConStr); //var cmd = $"update R set " + // $"R.Result= L.Result," + // $"R.Comment = L.Comment,"+ // $"R.FinishTime = L.FinishTime," + // $"R.CostTime = L.CostTime," + // $"R.Flag = L.Flag "+ // $"from {DataTables.RemoteBiSummaryDataTable} R left join {DataTables.LocalBiSummaryDataTable} L ON R.DataSetId = L.DataSetId"; foreach (DataRow row in table.Rows) { var cmd = $"update R set " + $"R.Result= '{row["Result"]}'," + $"R.Comment = '{row["Comment"]}'," + $"R.FinishTime = '{row["FinishTime"]}'," + $"R.CostTime = '{row["CostTime"]}'," + $"R.Flag = {row["Flag"]} " + $"from {DataTables.RemoteBiSummaryDataTable} R where R.DataSetId = '{row["DataSetId"]}'"; if (!remoteService.Execute(cmd)) { _log.Error($"Update remote bi summary data error,cmd={cmd}"); } else { UpdateTableUploadStatus(DataTables.LocalBiSummaryDataTable, table, BurnState.Delete); } } }