Exemple #1
0
        public IBLL.DTO.EpisodioDTO AddEpisodio(IBLL.DTO.EpisodioDTO data)
        {
            Stopwatch tw = new Stopwatch();

            tw.Start();

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

            IBLL.DTO.EpisodioDTO toReturn = null;

            try
            {
                data.episidid = null;
                IDAL.VO.EpisodioVO data_ = EpisodioMapper.EpisMapper(data);
                log.Info(string.Format("{0} {1} mapped to {2}", LibString.ItemsNumber(data_), LibString.TypeName(data), LibString.TypeName(data_)));
                IDAL.VO.EpisodioVO stored = dal.NewEpisodio(data_);
                log.Info(string.Format("{0} {1} items added and got back!", LibString.ItemsNumber(stored), LibString.TypeName(stored)));
                toReturn = EpisodioMapper.EpisMapper(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);
        }
Exemple #2
0
        public IBLL.DTO.EpisodioDTO GetEpisodioById(string id)
        {
            Stopwatch tw = new Stopwatch();

            tw.Start();

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

            IBLL.DTO.EpisodioDTO epis = null;

            try
            {
                IDAL.VO.EpisodioVO dalRes = this.dal.GetEpisodioById(id);
                epis = EpisodioMapper.EpisMapper(dalRes);
                log.Info(string.Format("{0} VOs mapped to {1}", LibString.ItemsNumber(epis), LibString.TypeName(epis)));
            }
            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(epis);
        }
Exemple #3
0
        public EpisodioVO GetEpisodioById(string episidid)
        {
            Stopwatch tw = new Stopwatch();

            tw.Start();

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

            EpisodioVO epis = null;

            try
            {
                string connectionString = this.GRConnectionString;

                long   episidid_ = long.Parse(episidid);
                string table     = this.EpisodioTabName;

                Dictionary <string, DBSQL.QueryCondition> conditions = new Dictionary <string, DBSQL.QueryCondition>()
                {
                    {
                        "id",
                        new DBSQL.QueryCondition()
                        {
                            Key   = "episidid",
                            Op    = DBSQL.Op.Equal,
                            Value = episidid_,
                            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)
                    {
                        epis = EpisodioMapper.EpisMapper(data.Rows[0]);
                        log.Info(string.Format("{0} Records mapped to {1}", LibString.ItemsNumber(epis), LibString.TypeName(epis)));
                    }
                }
            }
            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(epis);
        }
Exemple #4
0
        public EpisodioVO NewEpisodio(EpisodioVO data)
        {
            EpisodioVO result = null;

            Stopwatch tw = new Stopwatch();

            tw.Start();

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

            string table = this.EpisodioTabName;

            try
            {
                string connectionString = this.GRConnectionString;

                List <string> pk = new List <string>()
                {
                    "EPISIDID"
                };
                List <string> autoincrement = new List <string>()
                {
                    "episIdiD"
                };
                // INSERT NUOVA
                DataTable res = DBSQL.InsertBackOperation(connectionString, table, data, pk, autoincrement);
                if (res != null)
                {
                    if (res.Rows.Count > 0)
                    {
                        result = EpisodioMapper.EpisMapper(res.Rows[0]);
                        log.Info(string.Format("Inserted new record with ID: {0}!", result.episidid));
                    }
                }
            }
            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);
        }
Exemple #5
0
        public IDAL.VO.EpisodioVO GetEpisodioById(string episidid)
        {
            Stopwatch tw = new Stopwatch();

            tw.Start();

            IDAL.VO.EpisodioVO epis = null;
            try
            {
                string connectionString = this.HLTDesktopConnectionString;

                string query = "SELECT * FROM Episodi WHERE seriale = @seriale";
                Dictionary <string, object> pars = new Dictionary <string, object>();
                pars["seriale"] = episidid;

                log.Info(string.Format("Query: {0}", query));
                log.Info(string.Format("Params: {0}", string.Join(";", pars.Select(x => x.Key + "=" + x.Value).ToArray())));

                DataTable data = DAL.DBSQL.ExecuteQueryWithParams(connectionString, query, pars);

                log.Info(string.Format("Query Executed! Retrieved {0} records!", data.Rows.Count));

                if (data != null && data.Rows.Count == 1)
                {
                    DataRow row = data.Rows[0];

                    epis = EpisodioMapper.EpisMapper(row);

                    log.Info(string.Format("Record mapped to {0}", epis.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(epis);
        }
Exemple #6
0
        public IBLL.DTO.EpisodioDTO UpdateEpisodio(IBLL.DTO.EpisodioDTO data)
        {
            Stopwatch tw = new Stopwatch();

            tw.Start();

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

            int stored = 0;

            IBLL.DTO.EpisodioDTO toReturn = null;
            string id = data.episidid.ToString();

            try
            {
                if (id == null || GetEpisodioById(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.EpisodioVO data_ = EpisodioMapper.EpisMapper(data);
                log.Info(string.Format("{0} {1} mapped to {2}", LibString.ItemsNumber(data_), LibString.TypeName(data), LibString.TypeName(data_)));
                stored   = dal.SetEpisodio(data_);
                toReturn = GetEpisodioById(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);
        }
Exemple #7
0
 public IBLL.DTO.EpisodioDTO GetEpisodioById(string id)
 {
     IDAL.VO.EpisodioVO dalRes = this.dal.GetEpisodioById(id);
     return(EpisodioMapper.EpisMapper(dalRes));
 }