public bool IsTableExist(string conStr, string tableName) { var service = new DatabaseOperate(_log, conStr); var cmd = $"select top 1 * from {tableName}"; return(service.Execute(cmd)); }
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); } } }
public Guid CreateBiRecord(string sn, string productType, string testPlan, string board, string slot) { var id = Guid.NewGuid(); var cmd = $"insert into {DataTables.LocalBiSummaryDataTable} (DataSetId,Sn,ProductType,Station,TestPlan,Board,Slot,Flag) VALUES " + $"('{id}','{sn}','{productType}','{Environment.MachineName}','{testPlan}','{board}','{slot}',{(int)BurnState.Created} )"; if (!_dbService.Execute(cmd)) { throw new Exception($"Insert bi record into BI_Data_Summary error,cmd={cmd}"); } return(id); }