예제 #1
0
        public int SetEvento(EventoVO data)
        {
            int result = 0;

            Stopwatch tw = new Stopwatch();

            tw.Start();

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

            string table = this.EventoTabName;

            try
            {
                string connectionString = this.GRConnectionString;
                string evenidid         = data.evenidid.HasValue ? data.evenidid.Value.ToString() : null;

                if (evenidid == null)
                {
                    // INSERT NUOVA
                    result = DBSQL.InsertOperation(connectionString, table, data);
                    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   = "EVENIDID",
                              Value = evenidid,
                              Op    = DBSQL.Op.Equal,
                              Conj  = DBSQL.Conj.None,
                          } },
                    };
                    result = DBSQL.UpdateOperation(connectionString, table, data, conditions);
                    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);
        }
예제 #2
0
        public EventoVO GetEventoById(string evenidid)
        {
            Stopwatch tw = new Stopwatch();

            tw.Start();

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

            EventoVO even = null;

            try
            {
                string connectionString = this.GRConnectionString;

                long   evenidid_ = long.Parse(evenidid);
                string table     = this.EventoTabName;

                Dictionary <string, DBSQL.QueryCondition> conditions = new Dictionary <string, DBSQL.QueryCondition>()
                {
                    {
                        "id",
                        new DBSQL.QueryCondition()
                        {
                            Key   = "evenidid",
                            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)
                    {
                        even = EventoMapper.EvenMapper(data.Rows[0]);
                        log.Info(string.Format("{0} Records mapped to {1}", LibString.ItemsNumber(even), LibString.TypeName(even)));
                    }
                }
            }
            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(even);
        }
예제 #3
0
        public EventoVO NewEvento(EventoVO data)
        {
            EventoVO result = null;

            Stopwatch tw = new Stopwatch();

            tw.Start();

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

            string table = this.EventoTabName;

            try
            {
                string connectionString = this.GRConnectionString;

                List <string> pk = new List <string>()
                {
                    "EVENIDID"
                };
                List <string> autoincrement = new List <string>()
                {
                    "evenIdiD"
                };
                // INSERT NUOVA
                DataTable res = DBSQL.InsertBackOperation(connectionString, table, data, pk, autoincrement);
                if (res != null)
                {
                    if (res.Rows.Count > 0)
                    {
                        result = EventoMapper.EvenMapper(res.Rows[0]);
                        log.Info(string.Format("Inserted new record with ID: {0}!", result.evenidid));
                    }
                }
            }
            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);
        }