public IBLL.DTO.EsameDTO GetEsameById(string esamidid) { Stopwatch tw = new Stopwatch(); tw.Start(); IBLL.DTO.EsameDTO esam = null; try { IDAL.VO.EsameVO dalRes = this.dal.GetEsameById(esamidid); esam = EsameMapper.EsamMapper(dalRes); log.Info(string.Format("1 VO mapped to {0}", esam.GetType().ToString())); } catch (Exception ex) { string msg = "An Error occured! Exception detected!"; log.Info(msg); log.Error(msg + "\n" + ex.Message); } tw.Stop(); log.Info(string.Format("Completed! Elapsed time {0}", LibString.TimeSpanToTimeHmsms(tw.Elapsed))); return(esam); }
public static IDAL.VO.EsameVO EsamMapper(DataRow row) { IDAL.VO.EsameVO esam = new IDAL.VO.EsameVO(); esam.radioidid = row["radioidid"] != DBNull.Value ? (int)row["radioidid"] : (int?)null; esam.radiopres = row["radiopres"] != DBNull.Value ? (int)row["radiopres"] : (int?)null; esam.radiodesc = row["radiodesc"] != DBNull.Value ? (string)row["radiodesc"] : null; esam.radiotipo = row["radiotipo"] != DBNull.Value ? (int)row["radiotipo"] : (int?)null; esam.radiodass = row["radiodass"] != DBNull.Value ? (DateTime)row["radiodass"] : (DateTime?)null; esam.es_dett_key = row["es_dett_key"] != DBNull.Value ? (string)row["es_dett_key"] : null; esam.es_data = row["es_data"] != DBNull.Value ? (DateTime)row["es_data"] : (DateTime?)null; esam.es_stato = row["es_stato"] != DBNull.Value ? (string)row["es_stato"] : null; esam.es_ref = row["es_ref"] != DBNull.Value ? (string)row["es_ref"] : null; esam.data_verifica = row["data_verifica"] != DBNull.Value ? (DateTime)row["data_verifica"] : (DateTime?)null; esam.esito_verifica = row["esito_verifica"] != DBNull.Value ? (string)row["esito_verifica"] : null; esam.es_data_referto = row["es_data_referto"] != DBNull.Value ? (DateTime)row["es_data_referto"] : (DateTime?)null; esam.es_data_validazione_referto = row["es_data_validazione_referto"] != DBNull.Value ? (DateTime)row["es_data_validazione_referto"] : (DateTime?)null; esam.hl7_stato = row["hl7_stato"] != DBNull.Value ? (string)row["hl7_stato"] : null; esam.radioass2 = row["radioass2"] != DBNull.Value ? (string)row["radioass2"] : null; esam.radioass3 = row["radioass3"] != DBNull.Value ? (string)row["radioass3"] : null; esam.radioass1 = row["radioass1"] != DBNull.Value ? (string)row["radioass1"] : null; esam.radiolink = row["radiolink"] != DBNull.Value ? (string)row["radiolink"] : null; esam.radioass4 = row["radioass4"] != DBNull.Value ? (string)row["radioass4"] : null; esam.radiolink2 = row["radiolink2"] != DBNull.Value ? (string)row["radiolink2"] : null; esam.radiorefe = row["radiorefe"] != DBNull.Value ? (string)row["radiorefe"] : null; esam.radiorefestat = row["radiorefestat"] != DBNull.Value ? (string)row["radiorefestat"] : null; return(esam); }
public int UpdateEsameById(IBLL.DTO.EsameDTO data, string esamidid) { Stopwatch tw = new Stopwatch(); tw.Start(); int result = 0; try { IDAL.VO.EsameVO data_ = EsameMapper.EsamMapper(data); log.Info(string.Format("1 {0} mapped to {1}", data.GetType().ToString(), data_.GetType().ToString())); result = dal.UpdateEsameByPk(data_, esamidid); } catch (Exception ex) { string msg = "An Error occured! Exception detected!"; log.Info(msg); log.Error(msg + "\n" + ex.Message); } tw.Stop(); log.Info(string.Format("Completed! Elapsed time {0}", LibString.TimeSpanToTimeHmsms(tw.Elapsed))); return(result); }
public IBLL.DTO.EsameDTO UpdateEsame(IBLL.DTO.EsameDTO data) { Stopwatch tw = new Stopwatch(); tw.Start(); log.Info(string.Format("Starting ...")); int stored = 0; IBLL.DTO.EsameDTO toReturn = null; try { IDAL.VO.EsameVO data_ = EsameMapper.EsamMapper(data); log.Info(string.Format("{0} {1} mapped to {2}", LibString.ItemsNumber(data_), LibString.TypeName(data), LibString.TypeName(data_))); stored = dal.SetEsame(data_); toReturn = GetEsameById(data.radioidid.ToString()); log.Info(string.Format("{0} {1} items added and {2} {3} retrieved back!", stored, LibString.TypeName(data_), LibString.ItemsNumber(toReturn), LibString.TypeName(toReturn))); } catch (Exception ex) { string msg = "An Error occured! Exception detected!"; log.Info(msg); log.Error(msg + "\n" + ex.Message); } tw.Stop(); log.Info(string.Format("Completed! Elapsed time {0}", LibString.TimeSpanToTimeHmsms(tw.Elapsed))); return(toReturn); }
public IDAL.VO.EsameVO GetEsameById(string esamidid) { Stopwatch tw = new Stopwatch(); tw.Start(); IDAL.VO.EsameVO esam = null; try { long esamidid_ = long.Parse(esamidid); hlt_esameradio esam_ = hltCC.hlt_esameradio.Single(t => t.esameidid == esamidid_); log.Info(string.Format("Entity Framework Query Executed! Retrieved 1 record!")); esam = EsameMapper.EsamMapper(esam_); log.Info(string.Format("Record mapped to {0}", esam.GetType().ToString())); } catch (Exception ex) { log.Info(string.Format("Entity Framework Query Executed! Retrieved 0 record!")); string msg = "An Error occured! Exception detected!"; log.Info(msg); log.Error(msg + "\n" + ex.Message); } tw.Stop(); log.Info(string.Format("Completed! Elapsed time {0}", LibString.TimeSpanToTimeHmsms(tw.Elapsed))); return(esam); }
public int DeleteEsame(IDAL.VO.EsameVO data) { Stopwatch tw = new Stopwatch(); tw.Start(); int result = 0; try { hlt_esameradio data_ = EsameMapper.EsamMapper(data); hltCC.Entry(data_).State = System.Data.EntityState.Deleted; result = hltCC.SaveChanges(); log.Info(string.Format("Entity Framework Query Executed! Deleted {0} record!", result)); } catch (Exception ex) { log.Info(string.Format("Entity Framework Query Executed! Deleted 0 record!")); string msg = "An Error occured! Exception detected!"; log.Info(msg); log.Error(msg + "\n" + ex.Message); } tw.Stop(); log.Info(string.Format("Completed! Elapsed time {0}", LibString.TimeSpanToTimeHmsms(tw.Elapsed))); return(result); }
// NO ENTITYFRAMEWORK public IDAL.VO.EsameVO GetEsameById(string esamidid) { Stopwatch tw = new Stopwatch(); tw.Start(); log.Info(string.Format("Starting ...")); IDAL.VO.EsameVO esam = null; try { string connectionString = this.CCConnectionString; long esamidid_ = long.Parse(esamidid); string table = this.EsameTabName; Dictionary <string, DBSQL.QueryCondition> conditions = new Dictionary <string, DBSQL.QueryCondition>() { { "id", new DBSQL.QueryCondition() { Key = "esameidid", Op = DBSQL.Op.Equal, Value = esamidid_, Conj = DBSQL.Conj.None } } }; DataTable data = DBSQL.SelectOperation(connectionString, table, conditions); log.Info(string.Format("DBSQL Query Executed! Retrieved {0} record!", LibString.ItemsNumber(data))); if (data != null) { if (data.Rows.Count == 1) { esam = EsameMapper.EsamMapper(data.Rows[0]); log.Info(string.Format("{0} Records mapped to {1}", LibString.ItemsNumber(esam), LibString.TypeName(esam))); } } } catch (Exception ex) { log.Info(string.Format("DBSQL Query Executed! Retrieved 0 record!")); string msg = "An Error occured! Exception detected!"; log.Info(msg); log.Error(msg + "\n" + ex.Message); } tw.Stop(); log.Info(string.Format("Completed! Elapsed time {0}", LibString.TimeSpanToTimeHmsms(tw.Elapsed))); return(esam); }
public IDAL.VO.EsameVO NewEsame(IDAL.VO.EsameVO data) { IDAL.VO.EsameVO result = null; Stopwatch tw = new Stopwatch(); tw.Start(); log.Info(string.Format("Starting ...")); string table = this.EsameTabName; try { string connectionString = this.GRConnectionString; List <string> pk = new List <string>() { "RADIOIDID" }; List <string> autoincrement = new List <string>() { "RaDiOIdiD" }; // INSERT NUOVA DataTable res = DBSQL.InsertBackOperation(connectionString, table, data, pk, autoincrement); if (res != null) { if (res.Rows.Count > 0) { result = EsameMapper.EsamMapper(res.Rows[0]); log.Info(string.Format("Inserted new record with ID: {0}!", result.radioidid)); } } } catch (Exception ex) { string msg = "An Error occured! Exception detected!"; log.Info(msg); log.Error(msg + "\n" + ex.Message); } tw.Stop(); log.Info(string.Format("Completed! Elapsed time {0}", LibString.TimeSpanToTimeHmsms(tw.Elapsed))); return(result); }
public static List <IDAL.VO.EsameVO> EsamMapper(DataTable rows) { List <IDAL.VO.EsameVO> data = new List <IDAL.VO.EsameVO>(); if (rows != null) { if (rows.Rows.Count > 0) { foreach (DataRow row in rows.Rows) { IDAL.VO.EsameVO tmp = EsamMapper(row); data.Add(tmp); } } } return(data); }
public static IDAL.VO.EsameVO EsamMapper(IBLL.DTO.EsameDTO data) { IDAL.VO.EsameVO esam = null; try { Mapper.Initialize(cfg => cfg.CreateMap <IBLL.DTO.EsameDTO, IDAL.VO.EsameVO>()); Mapper.AssertConfigurationIsValid(); esam = Mapper.Map <IDAL.VO.EsameVO>(data); } catch (AutoMapperConfigurationException ex) { log.Error(string.Format("AutoMapper Configuration Error!\n{0}", ex.Message)); } catch (AutoMapperMappingException ex) { log.Error(string.Format("AutoMapper Mapping Error!\n{0}", ex.Message)); } return(esam); }
public int UpdateEsameByPk(IDAL.VO.EsameVO data, string esamidid) { Stopwatch tw = new Stopwatch(); tw.Start(); int result = 0; try { long esamidid_ = long.Parse(esamidid); hlt_esameradio esam = hltCC.hlt_esameradio.First(t => t.esameidid == esamidid_); hlt_esameradio data_ = EsameMapper.EsamMapper(data); foreach (System.Reflection.PropertyInfo prop in data_.GetType().GetProperties()) { if (esam.GetType().GetProperty(prop.Name) != null) { object val = prop.GetValue(data_, null); esam.GetType().GetProperty(prop.Name).SetValue(esam, Convert.ChangeType(val, Nullable.GetUnderlyingType(prop.PropertyType) ?? prop.PropertyType), null); } } result = hltCC.SaveChanges(); log.Info(string.Format("Entity Framework Query Executed! Updated {0} record!", result)); } catch (Exception ex) { log.Info(string.Format("Entity Framework Query Executed! Updated 0 record!")); string msg = "An Error occured! Exception detected!"; log.Info(msg); log.Error(msg + "\n" + ex.Message); } tw.Stop(); log.Info(string.Format("Completed! Elapsed time {0}", LibString.TimeSpanToTimeHmsms(tw.Elapsed))); return(result); }
public static List <IDAL.VO.EsameVO> EsamMapper(List <hlt_esameradio> data) { List <IDAL.VO.EsameVO> esams = null; if (data != null && data.Count > 0) { esams = new List <IDAL.VO.EsameVO>(); foreach (hlt_esameradio datum in data) { IDAL.VO.EsameVO tmp = null; tmp = EsamMapper(datum); if (tmp != null) { esams.Add(tmp); } } } return(esams); }
public int SetEsame(IDAL.VO.EsameVO data) { int result = 0; Stopwatch tw = new Stopwatch(); tw.Start(); log.Info(string.Format("Starting ...")); string table = this.EsameTabName; try { string connectionString = this.GRConnectionString; string esamidid = data.radioidid.HasValue ? data.radioidid.Value.ToString() : null; List <string> autoincrement = new List <string>() { "radioidid" }; if (esamidid == null) { // INSERT NUOVA result = DBSQL.InsertOperation(connectionString, table, data, autoincrement); log.Info(string.Format("Inserted {0} new records!", result)); } else { long radioidid_ = long.Parse(esamidid); // UPDATE Dictionary <string, DBSQL.QueryCondition> conditions = new Dictionary <string, DBSQL.QueryCondition>() { { "id", new DBSQL.QueryCondition() { Key = "radioidid", Value = radioidid_, Op = DBSQL.Op.Equal, Conj = DBSQL.Conj.None, } }, }; result = DBSQL.UpdateOperation(connectionString, table, data, conditions, new List <string>() { "radioidid" }); log.Info(string.Format("Updated {0} records!", result)); } } catch (Exception ex) { string msg = "An Error occured! Exception detected!"; log.Info(msg); log.Error(msg + "\n" + ex.Message); } tw.Stop(); log.Info(string.Format("Completed! Elapsed time {0}", LibString.TimeSpanToTimeHmsms(tw.Elapsed))); return(result); }