public static void Advance_process(long idrecep_sample_detail_elem, string process) { CTrace_sample_elemFactory faTrace_sample_elem = new CTrace_sample_elemFactory(); // --- get a process existing CTrace_sample_elem oTrace_sample_elem = faTrace_sample_elem.GetAll() .Where(x => x.Idrecep_sample_detail_elem == idrecep_sample_detail_elem && x.Cod_process == process) .OrderBy(x => x.Idtrace_sample_elem).OrderByDescending(x => x.Date_in).FirstOrDefault(); if (oTrace_sample_elem == null) { oTrace_sample_elem = new CTrace_sample_elem(); oTrace_sample_elem.Usernew = Comun.GetUser(); oTrace_sample_elem.Date_in = Comun.GetDate(); } oTrace_sample_elem.Cod_process = process; oTrace_sample_elem.Idrecep_sample_detail_elem = idrecep_sample_detail_elem; oTrace_sample_elem.Status_process = Convert.ToChar(LimsProcess.ModuleStatus.InProcess); oTrace_sample_elem.Useredit = Comun.GetUser(); if (!faTrace_sample_elem.Update(oTrace_sample_elem)) { faTrace_sample_elem.Insert(oTrace_sample_elem); } }
public static void Finalize_process(long idrecep_sample_detail_elem, string process, string sgtProcess) { CTrace_sample_elemFactory faTrace_sample_elem = new CTrace_sample_elemFactory(); // --- get a process existing CTrace_sample_elem oTrace_sample_elem = faTrace_sample_elem.GetAll() .Where(x => x.Idrecep_sample_detail_elem == idrecep_sample_detail_elem && x.Cod_process == process) .OrderBy(x => x.Idtrace_sample_elem).OrderByDescending(x => x.Date_in).FirstOrDefault(); if (oTrace_sample_elem == null) { oTrace_sample_elem = new CTrace_sample_elem(); oTrace_sample_elem.Date_in = Comun.GetDate(); oTrace_sample_elem.Usernew = Comun.User_system.Cod_user; oTrace_sample_elem.Idrecep_sample_detail_elem = idrecep_sample_detail_elem; //oTrace_sample_elem.Cod_module = module; oTrace_sample_elem.Cod_process = process; } oTrace_sample_elem.Date_out = Comun.GetDate(); oTrace_sample_elem.Status_process = Convert.ToChar(LimsProcess.Status_Process.Finished); oTrace_sample_elem.Useredit = Comun.GetUser(); if (!faTrace_sample_elem.Update(oTrace_sample_elem)) { faTrace_sample_elem.Insert(oTrace_sample_elem); } // --- create a new process Initialize_process(idrecep_sample_detail_elem, sgtProcess); }
/// <summary> /// Populate business objects from the data reader /// </summary> /// <param name="dataReader">data reader</param> /// <returns>list of CTrace_sample_elem</returns> internal List <CTrace_sample_elem> PopulateObjectsFromReader(IDataReader dataReader) { List <CTrace_sample_elem> list = new List <CTrace_sample_elem>(); while (dataReader.Read()) { CTrace_sample_elem businessObject = new CTrace_sample_elem(); PopulateBusinessObjectFromReader(businessObject, dataReader); list.Add(businessObject); } return(list); }
public static void Initialize_process(long idrecep_sample_detail_elem, string process) { // --- register the finished process, CTrace_sample_elemFactory faTrace_sample_elem = new CTrace_sample_elemFactory(); CTrace_sample_elem oTrace_sample_elem = new CTrace_sample_elem(); // --- register the initiatied process oTrace_sample_elem = new CTrace_sample_elem(); oTrace_sample_elem.Date_in = Comun.GetDate(); //oTrace_sample_elem.Cod_module = module; oTrace_sample_elem.Cod_process = process; oTrace_sample_elem.Idrecep_sample_detail_elem = idrecep_sample_detail_elem; oTrace_sample_elem.Status_process = Convert.ToChar(LimsProcess.Status_Process.Waiting); oTrace_sample_elem.Usernew = Comun.GetUser(); oTrace_sample_elem.Useredit = Comun.GetUser(); faTrace_sample_elem.Insert(oTrace_sample_elem); }
/// <summary> /// Select by primary key /// </summary> /// <param name="keys">primary keys</param> /// <returns>CTrace_sample_elem business object</returns> public CTrace_sample_elem SelectByPrimaryKey(CTrace_sample_elemKeys keys) { NpgsqlCommand sqlCommand = new NpgsqlCommand(); sqlCommand.CommandText = "public.sp_trace_sample_elem_SelectByPrimaryKey"; sqlCommand.CommandType = CommandType.StoredProcedure; // Use connection object of base class sqlCommand.Connection = MainConnection; try { sqlCommand.Parameters.Add(new NpgsqlParameter("p_idtrace_sample_elem", NpgsqlDbType.Bigint, 8, "", ParameterDirection.Input, false, 0, 0, DataRowVersion.Proposed, keys.Idtrace_sample_elem)); MainConnection.Open(); NpgsqlDataReader dataReader = sqlCommand.ExecuteReader(); if (dataReader.Read()) { CTrace_sample_elem businessObject = new CTrace_sample_elem(); PopulateBusinessObjectFromReader(businessObject, dataReader); return(businessObject); } else { return(null); } } catch (Exception ex) { throw new Exception("CTrace_sample_elem::SelectByPrimaryKey::Error occured.", ex); } finally { MainConnection.Close(); sqlCommand.Dispose(); } }
/// <summary> /// Populate business object from data reader /// </summary> /// <param name="businessObject">business object</param> /// <param name="dataReader">data reader</param> internal void PopulateBusinessObjectFromReader(CTrace_sample_elem businessObject, IDataReader dataReader) { businessObject.Idtrace_sample_elem = dataReader.GetInt64(dataReader.GetOrdinal(CTrace_sample_elem.CTrace_sample_elemFields.Idtrace_sample_elem.ToString())); if (!dataReader.IsDBNull(dataReader.GetOrdinal(CTrace_sample_elem.CTrace_sample_elemFields.Cod_module.ToString()))) { businessObject.Cod_module = dataReader.GetString(dataReader.GetOrdinal(CTrace_sample_elem.CTrace_sample_elemFields.Cod_module.ToString())); } if (!dataReader.IsDBNull(dataReader.GetOrdinal(CTrace_sample_elem.CTrace_sample_elemFields.Cod_process.ToString()))) { businessObject.Cod_process = dataReader.GetString(dataReader.GetOrdinal(CTrace_sample_elem.CTrace_sample_elemFields.Cod_process.ToString())); } if (!dataReader.IsDBNull(dataReader.GetOrdinal(CTrace_sample_elem.CTrace_sample_elemFields.Cod_area.ToString()))) { businessObject.Cod_area = dataReader.GetString(dataReader.GetOrdinal(CTrace_sample_elem.CTrace_sample_elemFields.Cod_area.ToString())); } if (!dataReader.IsDBNull(dataReader.GetOrdinal(CTrace_sample_elem.CTrace_sample_elemFields.Idrecep_sample_detail_elem.ToString()))) { businessObject.Idrecep_sample_detail_elem = dataReader.GetInt64(dataReader.GetOrdinal(CTrace_sample_elem.CTrace_sample_elemFields.Idrecep_sample_detail_elem.ToString())); } if (!dataReader.IsDBNull(dataReader.GetOrdinal(CTrace_sample_elem.CTrace_sample_elemFields.Idbatch.ToString()))) { businessObject.Idbatch = dataReader.GetInt64(dataReader.GetOrdinal(CTrace_sample_elem.CTrace_sample_elemFields.Idbatch.ToString())); } if (!dataReader.IsDBNull(dataReader.GetOrdinal(CTrace_sample_elem.CTrace_sample_elemFields.Status_process.ToString()))) { businessObject.Status_process = dataReader.GetChar(dataReader.GetOrdinal(CTrace_sample_elem.CTrace_sample_elemFields.Status_process.ToString())); } if (!dataReader.IsDBNull(dataReader.GetOrdinal(CTrace_sample_elem.CTrace_sample_elemFields.Date_in.ToString()))) { businessObject.Date_in = dataReader.GetDateTime(dataReader.GetOrdinal(CTrace_sample_elem.CTrace_sample_elemFields.Date_in.ToString())); } if (!dataReader.IsDBNull(dataReader.GetOrdinal(CTrace_sample_elem.CTrace_sample_elemFields.Date_out.ToString()))) { businessObject.Date_out = dataReader.GetDateTime(dataReader.GetOrdinal(CTrace_sample_elem.CTrace_sample_elemFields.Date_out.ToString())); } if (!dataReader.IsDBNull(dataReader.GetOrdinal(CTrace_sample_elem.CTrace_sample_elemFields.Status_result.ToString()))) { businessObject.Status_result = (short?)dataReader.GetInt16(dataReader.GetOrdinal(CTrace_sample_elem.CTrace_sample_elemFields.Status_result.ToString())); } if (!dataReader.IsDBNull(dataReader.GetOrdinal(CTrace_sample_elem.CTrace_sample_elemFields.Idtrace_prev.ToString()))) { businessObject.Idtrace_prev = dataReader.GetInt64(dataReader.GetOrdinal(CTrace_sample_elem.CTrace_sample_elemFields.Idtrace_prev.ToString())); } if (!dataReader.IsDBNull(dataReader.GetOrdinal(CTrace_sample_elem.CTrace_sample_elemFields.Idtrace_next.ToString()))) { businessObject.Idtrace_next = dataReader.GetInt64(dataReader.GetOrdinal(CTrace_sample_elem.CTrace_sample_elemFields.Idtrace_next.ToString())); } if (!dataReader.IsDBNull(dataReader.GetOrdinal(CTrace_sample_elem.CTrace_sample_elemFields.Observation.ToString()))) { businessObject.Observation = dataReader.GetString(dataReader.GetOrdinal(CTrace_sample_elem.CTrace_sample_elemFields.Observation.ToString())); } if (!dataReader.IsDBNull(dataReader.GetOrdinal(CTrace_sample_elem.CTrace_sample_elemFields.Usernew.ToString()))) { businessObject.Usernew = dataReader.GetString(dataReader.GetOrdinal(CTrace_sample_elem.CTrace_sample_elemFields.Usernew.ToString())); } if (!dataReader.IsDBNull(dataReader.GetOrdinal(CTrace_sample_elem.CTrace_sample_elemFields.Datenew.ToString()))) { businessObject.Datenew = dataReader.GetDateTime(dataReader.GetOrdinal(CTrace_sample_elem.CTrace_sample_elemFields.Datenew.ToString())); } if (!dataReader.IsDBNull(dataReader.GetOrdinal(CTrace_sample_elem.CTrace_sample_elemFields.Useredit.ToString()))) { businessObject.Useredit = dataReader.GetString(dataReader.GetOrdinal(CTrace_sample_elem.CTrace_sample_elemFields.Useredit.ToString())); } if (!dataReader.IsDBNull(dataReader.GetOrdinal(CTrace_sample_elem.CTrace_sample_elemFields.Dateedit.ToString()))) { businessObject.Dateedit = dataReader.GetDateTime(dataReader.GetOrdinal(CTrace_sample_elem.CTrace_sample_elemFields.Dateedit.ToString())); } if (!dataReader.IsDBNull(dataReader.GetOrdinal(CTrace_sample_elem.CTrace_sample_elemFields.Status.ToString()))) { businessObject.Status = dataReader.GetBoolean(dataReader.GetOrdinal(CTrace_sample_elem.CTrace_sample_elemFields.Status.ToString())); } }
/// <summary> /// insert new row in the table /// </summary> /// <param name="businessObject">business object</param> /// <returns>true of successfully insert</returns> public bool Insert(CTrace_sample_elem businessObject) { NpgsqlCommand sqlCommand = new NpgsqlCommand(); sqlCommand.CommandText = "public.sp_trace_sample_elem_Insert"; sqlCommand.CommandType = CommandType.StoredProcedure; // Use connection object of base class sqlCommand.Connection = MainConnection; try { sqlCommand.Parameters.AddWithValue("p_idtrace_sample_elem", businessObject.Idtrace_sample_elem); sqlCommand.Parameters["p_idtrace_sample_elem"].NpgsqlDbType = NpgsqlDbType.Bigint; sqlCommand.Parameters["p_idtrace_sample_elem"].Direction = ParameterDirection.InputOutput; sqlCommand.Parameters.AddWithValue("p_cod_module", businessObject.Cod_module); sqlCommand.Parameters["p_cod_module"].NpgsqlDbType = NpgsqlDbType.Varchar; sqlCommand.Parameters.AddWithValue("p_cod_process", businessObject.Cod_process); sqlCommand.Parameters["p_cod_process"].NpgsqlDbType = NpgsqlDbType.Varchar; sqlCommand.Parameters.AddWithValue("p_cod_area", businessObject.Cod_area); sqlCommand.Parameters["p_cod_area"].NpgsqlDbType = NpgsqlDbType.Varchar; sqlCommand.Parameters.AddWithValue("p_idrecep_sample_detail_elem", businessObject.Idrecep_sample_detail_elem); sqlCommand.Parameters["p_idrecep_sample_detail_elem"].NpgsqlDbType = NpgsqlDbType.Bigint; sqlCommand.Parameters.AddWithValue("p_idbatch", businessObject.Idbatch); sqlCommand.Parameters["p_idbatch"].NpgsqlDbType = NpgsqlDbType.Bigint; sqlCommand.Parameters.AddWithValue("p_status_process", businessObject.Status_process); sqlCommand.Parameters["p_status_process"].NpgsqlDbType = NpgsqlDbType.Char; sqlCommand.Parameters.AddWithValue("p_date_in", businessObject.Date_in); sqlCommand.Parameters["p_date_in"].NpgsqlDbType = NpgsqlDbType.Timestamp; sqlCommand.Parameters.AddWithValue("p_date_out", businessObject.Date_out); sqlCommand.Parameters["p_date_out"].NpgsqlDbType = NpgsqlDbType.Timestamp; sqlCommand.Parameters.AddWithValue("p_status_result", businessObject.Status_result); sqlCommand.Parameters["p_status_result"].NpgsqlDbType = NpgsqlDbType.Smallint; sqlCommand.Parameters.AddWithValue("p_idtrace_prev", businessObject.Idtrace_prev); sqlCommand.Parameters["p_idtrace_prev"].NpgsqlDbType = NpgsqlDbType.Bigint; sqlCommand.Parameters.AddWithValue("p_idtrace_next", businessObject.Idtrace_next); sqlCommand.Parameters["p_idtrace_next"].NpgsqlDbType = NpgsqlDbType.Bigint; sqlCommand.Parameters.AddWithValue("p_observation", businessObject.Observation); sqlCommand.Parameters["p_observation"].NpgsqlDbType = NpgsqlDbType.Varchar; sqlCommand.Parameters.AddWithValue("p_usernew", businessObject.Usernew); sqlCommand.Parameters["p_usernew"].NpgsqlDbType = NpgsqlDbType.Varchar; sqlCommand.Parameters.AddWithValue("p_datenew", businessObject.Datenew); sqlCommand.Parameters["p_datenew"].NpgsqlDbType = NpgsqlDbType.Timestamp; sqlCommand.Parameters.AddWithValue("p_useredit", businessObject.Useredit); sqlCommand.Parameters["p_useredit"].NpgsqlDbType = NpgsqlDbType.Varchar; sqlCommand.Parameters.AddWithValue("p_dateedit", businessObject.Dateedit); sqlCommand.Parameters["p_dateedit"].NpgsqlDbType = NpgsqlDbType.Timestamp; sqlCommand.Parameters.AddWithValue("p_status", businessObject.Status); sqlCommand.Parameters["p_status"].NpgsqlDbType = NpgsqlDbType.Boolean; MainConnection.Open(); sqlCommand.ExecuteNonQuery(); businessObject.Idtrace_sample_elem = Convert.ToInt64(sqlCommand.Parameters["p_idtrace_sample_elem"].Value); return(true); } catch (Exception ex) { throw new Exception("CTrace_sample_elem::Insert::Error occured.", ex); } finally { MainConnection.Close(); sqlCommand.Dispose(); } }
public static void Finalize_process(long idrecep_sample_detail_elem, string process, string sgtProcess) { CTrace_sample_elemFactory faTrace_sample_elem = new CTrace_sample_elemFactory(); // --- get a process existing CTrace_sample_elem oTrace_sample_elem = faTrace_sample_elem.GetAll() .Where(x => x.Idrecep_sample_detail_elem == idrecep_sample_detail_elem && x.Cod_process == process) .OrderBy(x => x.Idtrace_sample_elem).OrderByDescending(x => x.Date_in).FirstOrDefault(); if (oTrace_sample_elem == null) { oTrace_sample_elem = new CTrace_sample_elem(); oTrace_sample_elem.Date_in = Comun.GetDate(); oTrace_sample_elem.Usernew = Comun.User_system.Cod_user; oTrace_sample_elem.Idrecep_sample_detail_elem = idrecep_sample_detail_elem; //oTrace_sample_elem.Cod_module = module; oTrace_sample_elem.Cod_process = process; } oTrace_sample_elem.Date_out = Comun.GetDate(); oTrace_sample_elem.Status_process = Convert.ToChar(LimsProcess.Status_Process.Finished); oTrace_sample_elem.Useredit = Comun.GetUser(); if (!faTrace_sample_elem.Update(oTrace_sample_elem)) faTrace_sample_elem.Insert(oTrace_sample_elem); // --- create a new process Initialize_process(idrecep_sample_detail_elem, sgtProcess); }
public static void Advance_process(long idrecep_sample_detail_elem, string process) { CTrace_sample_elemFactory faTrace_sample_elem = new CTrace_sample_elemFactory(); // --- get a process existing CTrace_sample_elem oTrace_sample_elem = faTrace_sample_elem.GetAll() .Where(x => x.Idrecep_sample_detail_elem == idrecep_sample_detail_elem && x.Cod_process == process) .OrderBy(x => x.Idtrace_sample_elem).OrderByDescending(x => x.Date_in).FirstOrDefault(); if (oTrace_sample_elem == null) { oTrace_sample_elem = new CTrace_sample_elem(); oTrace_sample_elem.Usernew = Comun.GetUser(); oTrace_sample_elem.Date_in = Comun.GetDate(); } oTrace_sample_elem.Cod_process = process; oTrace_sample_elem.Idrecep_sample_detail_elem = idrecep_sample_detail_elem; oTrace_sample_elem.Status_process = Convert.ToChar(LimsProcess.ModuleStatus.InProcess); oTrace_sample_elem.Useredit = Comun.GetUser(); if (!faTrace_sample_elem.Update(oTrace_sample_elem)) faTrace_sample_elem.Insert(oTrace_sample_elem); }