public IBLL.DTO.AnalisiDTO UpdateAnalisi(IBLL.DTO.AnalisiDTO data) { Stopwatch tw = new Stopwatch(); tw.Start(); log.Info(string.Format("Starting ...")); int stored = 0; IBLL.DTO.AnalisiDTO toReturn = null; try { IDAL.VO.AnalisiVO data_ = AnalisiMapper.AnalMapper(data); log.Info(string.Format("{0} {1} mapped to {2}", LibString.ItemsNumber(data_), LibString.TypeName(data), LibString.TypeName(data_))); stored = dal.SetAnalisi(data_); toReturn = GetAnalisiById(data.analidid.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 IBLL.DTO.AnalisiDTO GetAnalisiById(string analidid) { Stopwatch tw = new Stopwatch(); tw.Start(); log.Info(string.Format("Starting ...")); IBLL.DTO.AnalisiDTO anal = null; try { IDAL.VO.AnalisiVO dalRes = this.dal.GetAnalisiById(analidid); anal = AnalisiMapper.AnalMapper(dalRes); log.Info(string.Format("{0} VOs mapped to {1}", LibString.ItemsNumber(anal), LibString.TypeName(anal))); } 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(anal); }
// NO ENTITYFRAMEWORK public IDAL.VO.AnalisiVO GetAnalisiById(string analidid) { Stopwatch tw = new Stopwatch(); tw.Start(); log.Info(string.Format("Starting ...")); IDAL.VO.AnalisiVO anal = null; try { string connectionString = this.GRConnectionString; long esamidid_ = long.Parse(analidid); string table = this.AnalisiTabName; Dictionary <string, DBSQL.QueryCondition> conditions = new Dictionary <string, DBSQL.QueryCondition>() { { "id", new DBSQL.QueryCondition() { Key = "analidid", 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) { anal = AnalisiMapper.AnalMapper(data.Rows[0]); log.Info(string.Format("{0} Records mapped to {1}", LibString.ItemsNumber(anal), LibString.TypeName(anal))); } } } 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(anal); }
public IDAL.VO.AnalisiVO NewAnalisi(IDAL.VO.AnalisiVO data) { IDAL.VO.AnalisiVO result = null; Stopwatch tw = new Stopwatch(); tw.Start(); log.Info(string.Format("Starting ...")); string table = this.AnalisiTabName; try { string connectionString = this.GRConnectionString; List <string> pk = new List <string>() { "ANALIDID" }; List <string> autoincrement = new List <string>() { "aNalIdiD" }; // INSERT NUOVA DataTable res = DBSQL.InsertBackOperation(connectionString, table, data, pk, autoincrement); if (res != null) { if (res.Rows.Count > 0) { result = AnalisiMapper.AnalMapper(res.Rows[0]); log.Info(string.Format("Inserted new record with ID: {0}!", result.analidid)); } } } 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 IDAL.VO.AnalisiVO AnalMapper(DataRow row) { IDAL.VO.AnalisiVO anal = new IDAL.VO.AnalisiVO(); anal.analidid = row["analidid"] != DBNull.Value ? (int)row["analidid"] : (int?)null; anal.analesam = row["analesam"] != DBNull.Value ? (int)row["analesam"] : (int?)null; anal.analcodi = row["analcodi"] != DBNull.Value ? (string)row["analcodi"] : null; anal.analnome = row["analnome"] != DBNull.Value ? (string)row["analnome"] : null; anal.analinvi = row["analinvi"] != DBNull.Value ? (short)row["analinvi"] : (short?)null; anal.analflro = row["analflro"] != DBNull.Value ? (short)row["analflro"] : (short?)null; anal.analextb = row["analextb"] != DBNull.Value ? (string)row["analextb"] : null; anal.hl7_stato = row["hl7_stato"] != DBNull.Value ? (string)row["hl7_stato"] : null; anal.hl7_msg = row["hl7_msg"] != DBNull.Value ? (string)row["hl7_msg"] : null; return(anal); }
public static List <IDAL.VO.AnalisiVO> AnalMapper(DataTable rows) { List <IDAL.VO.AnalisiVO> data = new List <IDAL.VO.AnalisiVO>(); if (rows != null) { if (rows.Rows.Count > 0) { foreach (DataRow row in rows.Rows) { IDAL.VO.AnalisiVO tmp = AnalMapper(row); data.Add(tmp); } } } return(data); }
static void Main(string[] args) { Console.WriteLine("Inizio Test ... "); DataAccessLayer.LISDAL dal = new DataAccessLayer.LISDAL(); IDAL.VO.AnalisiVO data = new IDAL.VO.AnalisiVO(); data.analcodi = "32434"; data.analesam = 123; data.analnome = "Gattica"; IDAL.VO.AnalisiVO data2 = new IDAL.VO.AnalisiVO(); data2.analcodi = "544544"; data2.analesam = 983; data2.analnome = "Delezione Rettale"; IDAL.VO.AnalisiVO data3 = new IDAL.VO.AnalisiVO(); data3.analcodi = "101020"; data3.analesam = 3430; data3.analnome = "Gesù"; List <IDAL.VO.AnalisiVO> datas = dal.NewAnalisi(new List <IDAL.VO.AnalisiVO>() { data, data2, data3 }); /* * string v1 = "refew"; * bool v2 = true; * double v3 = 23.4432; * * SqlParameter p = new SqlParameter(); * p.Value = "cieiroeieor"; * * bool isNum1 = LibString.IsNumericType(v1); * bool isNum2 = LibString.IsNumericType(v2); * bool isNum3 = LibString.IsNumericType(v3); * bool isNum4 = LibString.IsNumericType(p.Value); */ Console.WriteLine("Premere un tasto per continuare ... "); Console.ReadKey(); Console.WriteLine("Test Concluso!"); }
public static IDAL.VO.AnalisiVO AnalMapper(IBLL.DTO.AnalisiDTO data) { IDAL.VO.AnalisiVO esam = null; try { Mapper.Initialize(cfg => cfg.CreateMap <IBLL.DTO.AnalisiDTO, IDAL.VO.AnalisiVO>()); Mapper.AssertConfigurationIsValid(); esam = Mapper.Map <IDAL.VO.AnalisiVO>(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 SetAnalisi(IDAL.VO.AnalisiVO data) { int result = 0; Stopwatch tw = new Stopwatch(); tw.Start(); log.Info(string.Format("Starting ...")); string table = this.AnalisiTabName; try { string connectionString = this.GRConnectionString; string analidid = data.analidid.HasValue ? data.analidid.Value.ToString() : null; List <string> autoincrement = new List <string>() { "analidid" }; if (analidid == null) { // INSERT NUOVA result = DBSQL.InsertOperation(connectionString, table, data, autoincrement); log.Info(string.Format("Inserted {0} new records!", result)); } else { long analidid_ = long.Parse(analidid); // UPDATE Dictionary <string, DBSQL.QueryCondition> conditions = new Dictionary <string, DBSQL.QueryCondition>() { { "id", new DBSQL.QueryCondition() { Key = "analidid", Value = analidid_, Op = DBSQL.Op.Equal, Conj = DBSQL.Conj.None, } }, }; result = DBSQL.UpdateOperation(connectionString, table, data, conditions, new List <string>() { "analidid" }); 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); }