Beispiel #1
0
        public IBLL.DTO.PrestazioneDTO AddPrestazione(IBLL.DTO.PrestazioneDTO data)
        {
            Stopwatch tw = new Stopwatch();

            tw.Start();

            log.Info(string.Format("Starting ..."));

            IBLL.DTO.PrestazioneDTO toReturn = null;

            try
            {
                data.presidid = null;
                IDAL.VO.PrestazioneVO data_ = PrestazioneMapper.PresMapper(data);
                log.Info(string.Format("{0} {1} mapped to {2}", LibString.ItemsNumber(data_), LibString.TypeName(data), LibString.TypeName(data_)));
                IDAL.VO.PrestazioneVO stored = dal.NewPrestazione(data_);
                log.Info(string.Format("{0} {1} items added and got back!", LibString.ItemsNumber(stored), LibString.TypeName(stored)));
                toReturn = PrestazioneMapper.PresMapper(stored);
                log.Info(string.Format("{0} {1} mapped to {2}", LibString.ItemsNumber(toReturn), LibString.TypeName(stored), 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);
        }
Beispiel #2
0
        public IBLL.DTO.PrestazioneDTO GetPrestazioneByEvento(string evenidid)
        {
            Stopwatch tw = new Stopwatch();

            tw.Start();

            log.Info(string.Format("Starting ..."));

            IBLL.DTO.PrestazioneDTO pres = null;

            try
            {
                IDAL.VO.PrestazioneVO pres_ = this.dal.GetPrestazioneByEvento(evenidid);
                pres = PrestazioneMapper.PresMapper(pres_);
                log.Info(string.Format("{0} {1} mapped to {2}", LibString.ItemsNumber(pres), LibString.TypeName(pres_), LibString.TypeName(pres)));
            }
            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(pres);
        }
Beispiel #3
0
        public IDAL.VO.PrestazioneVO GetPrestazioneByEvento(string evenidid)
        {
            Stopwatch tw = new Stopwatch();

            tw.Start();

            log.Info(string.Format("Starting ..."));

            IDAL.VO.PrestazioneVO pres = null;
            try
            {
                string connectionString = this.GRConnectionString;

                string table = this.PrestazioneTabName;

                Dictionary <string, DBSQL.QueryCondition> conditions = new Dictionary <string, DBSQL.QueryCondition>()
                {
                    {
                        "id",
                        new DBSQL.QueryCondition()
                        {
                            Key   = "preseven",
                            Op    = DBSQL.Op.Equal,
                            Value = evenidid,
                            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)
                    {
                        pres = PrestazioneMapper.PresMapper(data.Rows[0]);
                        log.Info(string.Format("{0} Records mapped to {1}", LibString.ItemsNumber(pres), LibString.TypeName(pres)));
                    }
                }
            }
            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(pres);
        }
Beispiel #4
0
        public IDAL.VO.PrestazioneVO NewPrestazione(IDAL.VO.PrestazioneVO data)
        {
            IDAL.VO.PrestazioneVO result = null;

            Stopwatch tw = new Stopwatch();

            tw.Start();

            log.Info(string.Format("Starting ..."));

            string table = this.PrestazioneTabName;

            try
            {
                string connectionString = this.GRConnectionString;

                List <string> pk = new List <string>()
                {
                    "PRESIDID"
                };
                List <string> autoincrement = new List <string>()
                {
                    "pResIdiD"
                };
                // INSERT NUOVA
                DataTable res = DBSQL.InsertBackOperation(connectionString, table, data, pk, autoincrement);
                if (res != null)
                {
                    if (res.Rows.Count > 0)
                    {
                        result = PrestazioneMapper.PresMapper(res.Rows[0]);
                        log.Info(string.Format("Inserted new record with ID: {0}!", result.presidid));
                    }
                }
            }
            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);
        }
Beispiel #5
0
        public static List <IDAL.VO.PrestazioneVO> PresMapper(DataTable rows)
        {
            List <IDAL.VO.PrestazioneVO> data = new List <IDAL.VO.PrestazioneVO>();

            if (rows != null)
            {
                if (rows.Rows.Count > 0)
                {
                    foreach (DataRow row in rows.Rows)
                    {
                        IDAL.VO.PrestazioneVO tmp = PresMapper(row);
                        data.Add(tmp);
                    }
                }
            }

            return(data);
        }
Beispiel #6
0
        public static IDAL.VO.PrestazioneVO PresMapper(DataRow row)
        {
            IDAL.VO.PrestazioneVO pres = new IDAL.VO.PrestazioneVO();

            pres.presidid       = row["presidid"] != DBNull.Value ? (int)row["presidid"] : (int?)null;
            pres.preseven       = row["preseven"] != DBNull.Value ? (int)row["preseven"] : (int?)null;
            pres.presques       = row["presques"] != DBNull.Value ? (string)row["presques"] : null;
            pres.prescons       = row["prescons"] != DBNull.Value ? (string)row["prescons"] : null;
            pres.presstat       = row["presstat"] != DBNull.Value ? (short)row["presstat"] : (short?)null;
            pres.prestipo       = row["prestipo"] != DBNull.Value ? (int)row["prestipo"] : (int?)null;
            pres.presurge       = row["presurge"] != DBNull.Value ? (bool)row["presurge"] : (bool?)null;
            pres.prespren       = row["prespren"] != DBNull.Value ? (DateTime)row["prespren"] : (DateTime?)null;
            pres.presrico       = row["presrico"] != DBNull.Value ? (int)row["presrico"] : (int?)null;
            pres.presesec       = row["presesec"] != DBNull.Value ? (DateTime)row["presesec"] : (DateTime?)null;
            pres.presflcc       = row["presflcc"] != DBNull.Value ? (int)row["presflcc"] : (int?)null;
            pres.presconf       = row["presconf"] != DBNull.Value ? (int)row["presconf"] : (int?)null;
            pres.presdmod       = row["presdmod"] != DBNull.Value ? (string)row["presdmod"] : null;
            pres.presnote       = row["presnote"] != DBNull.Value ? (string)row["presnote"] : null;
            pres.presdtri       = row["presdtri"] != DBNull.Value ? (DateTime)row["presdtri"] : (DateTime?)null;
            pres.presdtco       = row["presdtco"] != DBNull.Value ? (DateTime)row["presdtco"] : (DateTime?)null;
            pres.prespers       = row["prespers"] != DBNull.Value ? (string)row["prespers"] : null;
            pres.preserog       = row["preserog"] != DBNull.Value ? (short)row["preserog"] : (short?)null;
            pres.prespren2      = row["prespren2"] != DBNull.Value ? (DateTime)row["prespren2"] : (DateTime?)null;
            pres.presdimi       = row["presdimi"] != DBNull.Value ? (int)row["presdimi"] : (int?)null;
            pres.presecocardio  = row["presecocardio"] != DBNull.Value ? (int)row["presecocardio"] : (int?)null;
            pres.presvisicardio = row["presvisicardio"] != DBNull.Value ? (int)row["presvisicardio"] : (int?)null;
            pres.presappu       = row["presappu"] != DBNull.Value ? (string)row["presappu"] : null;
            pres.presannu       = row["presannu"] != DBNull.Value ? (int)row["presannu"] : (int?)null;
            pres.hl7_stato      = row["hl7_stato"] != DBNull.Value ? (string)row["hl7_stato"] : null;
            pres.hl7_msg        = row["hl7_msg"] != DBNull.Value ? (string)row["hl7_msg"] : null;
            pres.prespadre      = row["prespadre"] != DBNull.Value ? (int)row["prespadre"] : (int?)null;
            pres.presconscardio = row["presconscardio"] != DBNull.Value ? (int)row["presconscardio"] : (int?)null;
            pres.prespagatipo   = row["prespagatipo"] != DBNull.Value ? (int)row["prespagatipo"] : (int?)null;
            pres.prespagastat   = row["prespagastat"] != DBNull.Value ? (int)row["prespagastat"] : (int?)null;
            pres.prespagadata   = row["prespagadata"] != DBNull.Value ? (DateTime)row["prespagadata"] : (DateTime?)null;
            pres.prespagauser   = row["prespagauser"] != DBNull.Value ? (int)row["prespagauser"] : (int?)null;
            pres.prescdc        = row["prescdc"] != DBNull.Value ? (string)row["prescdc"] : null;
            pres.presrefe       = row["presrefe"] != DBNull.Value ? (int)row["presrefe"] : (int?)null;
            pres.presimgstat    = row["presimgstat"] != DBNull.Value ? (int)row["presimgstat"] : (int?)null;
            pres.presimg        = row["presimg"] != DBNull.Value ? (byte[])row["presimg"] : null;
            pres.presacqu       = row["presacqu"] != DBNull.Value ? (DateTime)row["presacqu"] : (DateTime?)null;

            return(pres);
        }
Beispiel #7
0
        public static IBLL.DTO.PrestazioneDTO PresMapper(IDAL.VO.PrestazioneVO raw)
        {
            IBLL.DTO.PrestazioneDTO pres = null;
            try
            {
                Mapper.Initialize(cfg => cfg.CreateMap <IDAL.VO.PrestazioneVO, IBLL.DTO.PrestazioneDTO>());
                Mapper.AssertConfigurationIsValid();
                pres = Mapper.Map <IBLL.DTO.PrestazioneDTO>(raw);
            }
            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(pres);
        }
Beispiel #8
0
        public IBLL.DTO.PrestazioneDTO UpdatePrestazione(IBLL.DTO.PrestazioneDTO data)
        {
            Stopwatch tw = new Stopwatch();

            tw.Start();

            log.Info(string.Format("Starting ..."));

            int stored = 0;

            IBLL.DTO.PrestazioneDTO toReturn = null;
            string id = data.presidid.ToString();

            try
            {
                if (id == null || GetPrestazioneById(id) == null)
                {
                    string msg = string.Format("No record found with the id {0}! Updating is impossible!", id);
                    log.Info(msg);
                    log.Error(msg);
                    return(null);
                }
                IDAL.VO.PrestazioneVO data_ = PrestazioneMapper.PresMapper(data);
                log.Info(string.Format("{0} {1} mapped to {2}", LibString.ItemsNumber(data_), LibString.TypeName(data), LibString.TypeName(data_)));
                stored   = dal.SetPrestazione(data_);
                toReturn = GetPrestazioneById(id);
                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);
        }
Beispiel #9
0
        public int SetPrestazione(IDAL.VO.PrestazioneVO data)
        {
            int result = 0;

            Stopwatch tw = new Stopwatch();

            tw.Start();

            log.Info(string.Format("Starting ..."));

            string table = this.PrestazioneTabName;

            try
            {
                string        connectionString = this.GRConnectionString;
                string        presidid         = data.presidid.HasValue ? data.presidid.Value.ToString() : null;
                List <string> autoincrement    = new List <string>()
                {
                    "presidid"
                };

                if (presidid == null)
                {
                    // INSERT NUOVA
                    result = DBSQL.InsertOperation(connectionString, table, data, autoincrement);
                    log.Info(string.Format("Inserted {0} new records!", result));
                }
                else
                {
                    // UPDATE
                    Dictionary <string, DBSQL.QueryCondition> conditions = new Dictionary <string, DBSQL.QueryCondition>()
                    {
                        { "id",
                          new DBSQL.QueryCondition()
                          {
                              Key   = "presidid",
                              Value = presidid,
                              Op    = DBSQL.Op.Equal,
                              Conj  = DBSQL.Conj.None,
                          } },
                    };
                    result = DBSQL.UpdateOperation(connectionString, table, data, conditions, new List <string>()
                    {
                        "presidid"
                    });
                    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);
        }