public static EventVisitModel getEvent(int eventId)
 {
     try
     {
         for (int i = 0; i < _events.Count; i++)
         {
             EventVisitModel ev = _events[i];
             if (ev.id == eventId)
             {
                 return(ev);
             }
         }
     }
     catch (Exception ex)
     {
         SaveLog.fatal(ex.ToString());
         Printf.b_danger("[EventVisitSyncer] Fatal Error!");
     }
     return(null);
 }
 public static EventVisitModel getRunningEvent()
 {
     try
     {
         uint date = uint.Parse(DateTime.Now.ToString("yyMMddHHmm"));
         for (int i = 0; i < _events.Count; i++)
         {
             EventVisitModel ev = _events[i];
             if (ev.startDate <= date && date < ev.endDate)
             {
                 return(ev);
             }
         }
     }
     catch (Exception ex)
     {
         SaveLog.fatal(ex.ToString());
         Printf.b_danger("[EventVisitSyncer] Fatal Error!");
     }
     return(null);
 }
        public static void GenerateList()
        {
            try
            {
                using (NpgsqlConnection connection = SQLjec.getInstance().conn())
                {
                    NpgsqlCommand command = connection.CreateCommand();
                    connection.Open();
                    command.CommandText = "SELECT * FROM events_visit";
                    command.CommandType = CommandType.Text;
                    NpgsqlDataReader data = command.ExecuteReader();
                    while (data.Read())
                    {
                        EventVisitModel ev = new EventVisitModel
                        {
                            id        = data.GetInt32(0),
                            startDate = (UInt32)data.GetInt64(1),
                            endDate   = (UInt32)data.GetInt64(2),
                            title     = data.GetString(3),
                            checks    = data.GetInt32(4)
                        };
                        string goods1  = data.GetString(5);
                        string counts1 = data.GetString(6);
                        string goods2  = data.GetString(7);
                        string counts2 = data.GetString(8);

                        string[] goodsarray1 = goods1.Split(',');
                        string[] goodsarray2 = goods2.Split(',');

                        for (int i = 0; i < goodsarray1.Length; i++)
                        {
                            ev.box[i].reward1.good_id = int.Parse(goodsarray1[i]);
                        }
                        for (int i = 0; i < goodsarray2.Length; i++)
                        {
                            ev.box[i].reward2.good_id = int.Parse(goodsarray2[i]);
                        }

                        string[] countarray1 = counts1.Split(',');
                        string[] countarray2 = counts2.Split(',');
                        for (int i = 0; i < countarray1.Length; i++)
                        {
                            VisitItem item = ev.box[i].reward1;
                            item.SetCount(countarray1[i]);
                        }
                        for (int i = 0; i < countarray2.Length; i++)
                        {
                            VisitItem item = ev.box[i].reward2;
                            item.SetCount(countarray2[i]);
                        }
                        ev.SetBoxCounts();
                        _events.Add(ev);
                    }
                    command.Dispose();
                    data.Close();
                    connection.Dispose();
                    connection.Close();
                }
            }
            catch (Exception ex)
            {
                SaveLog.fatal(ex.ToString());
                Printf.b_danger("[EventVisitSyncer] Fatal Error!");
            }
        }