public void InsertProcessedControlLoopData(ControlLoopDataCollection processedCLDataCollection, string dateId) { using (SqlConnection conn = new SqlConnection(_sqlConnection)) { using (SqlCommand comm = new SqlCommand("[ThreeRates].[dbo].[INSERT_CurrentShiftControlLoopData]") { CommandType = CommandType.StoredProcedure }) { comm.Connection = conn; //comm.Parameters.Add("@Result", SqlDbType.Int).Direction = ParameterDirection.Output; //deleted from the db comm.Parameters.Add("@DateID", SqlDbType.VarChar).Value = dateId; comm.Parameters.Add("@CRData", SqlDbType.Structured).Value = processedCLDataCollection; try { conn.Open(); comm.ExecuteNonQuery(); //result = Convert.ToInt32(comm.Parameters["@Result"].Value); //no returning value conn.Close(); } catch (SqlException e) { Console.WriteLine("An errror occured during executing the SQL query: " + e.Message); } if (conn.State == ConnectionState.Open) { conn.Close(); } } } }
public void ProcessCRData(DateTime queryStart, DateTime queryEnd) { var modeTagsData = _sqlDataAccess.GetModeTagsToProcess(); var processedCLData = _historianDataAccess.QueryControlLoopsTagData(modeTagsData, queryStart, queryEnd); var processedCLDataCollection = new ControlLoopDataCollection(processedCLData); string dateId = queryStart.ToString("yyyy.MM.dd. HH:mm"); _sqlDataAccess.InsertProcessedControlLoopData(processedCLDataCollection, dateId); }