public IDAL.VO.RisultatoVO GetRisultatoById(string id) { Stopwatch tw = new Stopwatch(); tw.Start(); log.Info(string.Format("Starting ...")); IDAL.VO.RisultatoVO ris = null; try { string connectionString = this.GRConnectionString; long id_ = long.Parse(id); string table = this.RisultatoTabName; Dictionary <string, DBSQL.QueryCondition> conditions = new Dictionary <string, DBSQL.QueryCondition>() { { "id", new DBSQL.QueryCondition() { Key = "anreidid", Op = DBSQL.Op.Equal, Value = id_, 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) { ris = Mappers.RisultatoMapper.AnreMapper(data.Rows[0]); log.Info(string.Format("{0} Records mapped to {1}", LibString.ItemsNumber(ris), LibString.TypeName(ris))); } } } 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(ris); }
public IDAL.VO.RisultatoVO NewRisultato(IDAL.VO.RisultatoVO data) { IDAL.VO.RisultatoVO result = null; Stopwatch tw = new Stopwatch(); tw.Start(); log.Info(string.Format("Starting ...")); string table = this.RisultatoTabName; try { string connectionString = this.GRConnectionString; List <string> pk = new List <string>() { "ANREIDID" }; List <string> autoincrement = new List <string>() { "anreIdiD" }; // INSERT NUOVA DataTable res = DBSQL.InsertBackOperation(connectionString, table, data, pk, autoincrement); if (res != null) { if (res.Rows.Count > 0) { result = Mappers.RisultatoMapper.AnreMapper(res.Rows[0]); log.Info(string.Format("Inserted new record with ID: {0}!", result.anreidid)); } } } 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.RisultatoVO> AnreMapper(DataTable rows) { List <IDAL.VO.RisultatoVO> riss = null; foreach (DataRow row in rows.Rows) { IDAL.VO.RisultatoVO ris = AnreMapper(row); if (riss == null) { riss = new List <IDAL.VO.RisultatoVO>(); } riss.Add(ris); } return(riss); }
public static IDAL.VO.RisultatoVO AnreMapper(IBLL.DTO.RisultatoDTO data) { IDAL.VO.RisultatoVO anre = null; try { Mapper.Initialize(cfg => cfg.CreateMap <IBLL.DTO.RisultatoDTO, IDAL.VO.RisultatoVO>()); Mapper.AssertConfigurationIsValid(); anre = Mapper.Map <IDAL.VO.RisultatoVO>(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(anre); }
public static IDAL.VO.RisultatoVO AnreMapper(DataRow row) { IDAL.VO.RisultatoVO anre = new IDAL.VO.RisultatoVO(); anre.anreidid = row["anreidid"] != DBNull.Value ? (long)row["anreidid"] : (long?)null; anre.anreanal = row["anreanal"] != DBNull.Value ? (long)row["anreanal"] : (long?)null; anre.anreprog = row["anreprog"] != DBNull.Value ? (int)row["anreprog"] : (int?)null; anre.anretipo = row["anretipo"] != DBNull.Value ? (string)row["anretipo"] : null; anre.anreidsn = row["anreidsn"] != DBNull.Value ? (string)row["anreidsn"] : null; anre.anreidsn = row["anredsmu"] != DBNull.Value ? (string)row["anredsmu"] : null; anre.anreidmu = row["anreidmu"] != DBNull.Value ? (string)row["anreidmu"] : null; anre.anrerisu = row["anrerisu"] != DBNull.Value ? (string)row["anrerisu"] : null; anre.anrerisucomm = row["anrerisucomm"] != DBNull.Value ? (string)row["anrerisucomm"] : null; anre.anreunim = row["anreunim"] != DBNull.Value ? (string)row["anreunim"] : null; anre.anrerife = row["anrerife"] != DBNull.Value ? (string)row["anrerife"] : null; anre.anreanom = row["anreanom"] != DBNull.Value ? (string)row["anreanom"] : null; anre.anrestat = row["anrestat"] != DBNull.Value ? (string)row["anrestat"] : null; anre.anredata = row["anredata"] != DBNull.Value ? (DateTime)row["anredata"] : (DateTime?)null; return(anre); }