AdvancedLogParser.InfoGather.GetLogins C# (CSharp) Method

GetLogins() public static method

public static GetLogins ( ) : void
return void
        public static void GetLogins()
        {
            currentLoader.status.Text = "Querying logins...";
            Application.DoEvents();
            DateTime checkFrom = DateTime.UtcNow.Subtract(TimeSpan.FromDays(30));
            try
            {
                using (MySqlDataReader reader = MySqlHelper.ExecuteReader(ConnectionString, String.Format("SELECT * FROM alandsyu_live.logs WHERE Date > '{0}/{1}/{2}' AND Event = \"Login\"", checkFrom.Year, checkFrom.Month, checkFrom.Day)))
                {
                    currentLoader.status.Text = "Loading logins...";
                    Application.DoEvents();
                    uint id;
                    ushort serverId;
                    uint characterId;
                    string eventName;
                    string eventDescription;
                    DateTime time;
                    uint dmId;

                    while (reader.Read())
                    {
                        try
                        {
                            id = (uint)reader.GetValue(0);
                            serverId = (ushort)reader.GetValue(1);
                            characterId = (uint)reader.GetValue(2);
                            eventName = (string)reader.GetValue(3);
                            eventDescription = (string)reader.GetValue(4);
                            time = (DateTime)reader.GetValue(5);
                            if (!reader.IsDBNull(6))
                            {
                                dmId = (uint)reader.GetValue(6);
                            }
                            else
                            {
                                dmId = 0;
                            }
                        }
                        catch
                        {
                            continue;
                        }

                        Log newLog = new Log()
                        {
                            Id = id,
                            ServerId = serverId,
                            CharacterId = characterId,
                            DMId = dmId,
                            Event = eventName,
                            EventDescription = eventDescription,
                            Time = time
                        };
                        Logs.RecentLogins.Add(newLog.Id, newLog);
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
                Application.Exit();
            }
        }

Usage Example

Beispiel #1
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            InfoGather.DatabasePassword = ConfigurationSettings.AppSettings["DatabasePassword"];
            InfoGather.DatabaseSchema   = ConfigurationSettings.AppSettings["DatabaseSchema"];
            InfoGather.DatabaseServer   = ConfigurationSettings.AppSettings["DatabaseServer"];
            InfoGather.DatabasePort     = ConfigurationSettings.AppSettings["DatabasePort"];
            InfoGather.DatabaseUser     = ConfigurationSettings.AppSettings["DatabaseUser"];
            InfoGather.BuildConnectionString();
            Players.ListByPlayerId = new Dictionary <uint, Player>();
            Players.ListByKey      = new Dictionary <string, Player>();
            Characters.List        = new Dictionary <uint, Character>();
            Logs.AdvancementAlerts = new Dictionary <uint, Log>();
            Logs.DeathAlerts       = new Dictionary <uint, Log>();
            Logs.EnforcementAlerts = new Dictionary <uint, Log>();
            Logs.RecentLogins      = new Dictionary <uint, Log>();
            Servers.List           = new Dictionary <uint, Server>();
            if (InfoGather.GetPlayers())
            {
                InfoGather.GetCharacters();
                InfoGather.CountBankValue();
                InfoGather.CountpChestValue();
                InfoGather.GetAlerts();
                InfoGather.GetLogins();
                InfoGather.IdentifyLogins();
                InfoGather.GetDMTime();
                InfoGather.currentLoader.Close();
                InfoGather.currentLoader.Dispose();
                if (ServerFocus >= 0)
                {
                    foreach (Server srv in Servers.List.Values)
                    {
                        if (srv.ServerId == Math.Abs(ServerFocus))
                        {
                            Application.Run(new ServerView(srv));
                        }
                    }
                }
                else
                {
                    foreach (Server srv in Servers.List.Values)
                    {
                        new ServerView(srv).Show();
                    }
                    new ServerView(null).Show();
                    Application.Run(new PrimaryDisplay());
                }
            }
        }