public static Dictionary <string, string> GetAllConfigs() { Dictionary <string, string> ret = new Dictionary <string, string>(); DBProvider db = new DBProvider("Game"); var configs = db.Select("configs", "Name,Value", ""); foreach (var config in configs) { ret.Add((string)config["Name"], (string)config["Value"]); } return(ret); }
public static Dictionary <string, string> GetConfigs(int type) { Dictionary <string, string> ret = new Dictionary <string, string>(); DBProvider db = new DBProvider("Game"); var configs = db.Select("configs", "Name,Value", "Type=" + type.ToString() + " or Type=0"); foreach (var config in configs) { ret.Add((string)config["Name"], (string)config["Value"]); } return(ret); }
public static void CheckAndUpdateDataTable(object state) { DBProvider db = new DBProvider("Game"); var versions = db.Select("dataTableVersions", "Name,UsedVersion,LatestVersion", ""); foreach (var version in versions) { if ((int)version["LatestVersion"] > (int)version["UsedVersion"]) { FileInfo dtfile = new FileInfo("DataTables/" + (string)version["Name"] + ".txt"); DataTableLoader.LoadDataTableFile(dtfile); Dictionary <string, object> sqlparams = new Dictionary <string, object>(); sqlparams["UsedVersion"] = version["LatestVersion"]; db.Update("dataTableVersions", sqlparams, "Name = '" + version["Name"] + "'"); } } }
public void Execute() { DBProvider db = new DBProvider("Game"); string now = DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss"); string condition = string.Format("BeginTime < '{0}' and ExpireTime > '{1}'", now, now); var announces = db.Select(Table, "Id,Type,Message,BeginTime,IntervalMinutes", condition); foreach (var announce in announces) { if ((int)announce["IntervalMinutes"] == 0 && (int)announce["Pushed"] == 0) { var dt = (DateTime)announce["BeginTime"]; if (DateTime.UtcNow.Ticks - dt.Ticks <= TimeSpan.TicksPerMinute) { if ((int)announce["Type"] == (int)AnnounceType.SystemNotice) { AnnouncementLogic.PushSystemNotice((string)announce["Message"]); } else { AnnouncementLogic.PushAdvertisement((string)announce["Message"]); } } } else if ((int)announce["IntervalMinutes"] != 0) { var dt = (DateTime)announce["BeginTime"]; if (((DateTime.UtcNow.Ticks - dt.Ticks) / TimeSpan.TicksPerMinute) % (int)announce["IntervalMinutes"] == 0) { if ((int)announce["Type"] == (int)AnnounceType.SystemNotice) { AnnouncementLogic.PushSystemNotice((string)announce["Message"]); } else { AnnouncementLogic.PushAdvertisement((string)announce["Message"]); } } } else { continue; } } }
public void AddNewMail(string message, int AttachId, int AttachCount) { if (CacheSet.ItemTable.GetData(AttachId) == null && CacheSet.GearTable.GetData(AttachId) == null && CacheSet.SoulTable.GetData(AttachId) == null && CacheSet.EpigraphTable.GetData(AttachId) == null) { return; } DBProvider db = new DBProvider("Game"); Dictionary <string, object> values = new Dictionary <string, object>(); values["Message"] = message; values["AttachType"] = AttachId; values["AttachCount"] = AttachCount; values["BeginTime"] = DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss"); DateTime expireDay = DateTime.UtcNow.AddDays(GameConfigs.GetInt("Mail_Expire_Days", 7)); values["ExpireTime"] = expireDay.ToString("yyyy-MM-dd HH:mm:ss"); values["ToUser"] = m_UserId; db.Insert("mails", values); }
public override bool TakeAction() { DBProvider db = new DBProvider("Game"); var localNotifications = db.Select("localNotifications", "Name,Time,Message,Status"); foreach (var ln in localNotifications) { if ((int)ln["Status"] == 1) { m_ResponsePacket.RegisterKey.Add((string)ln["Name"]); m_ResponsePacket.RegisterDate.Add((string)ln["Time"]); m_ResponsePacket.RegisterMessage.Add((string)ln["Message"]); } else { m_ResponsePacket.CanceledKey.Add((string)ln["Name"]); } } return(true); }
public int GetMailsFromDB() { DBProvider db = new DBProvider("Game"); PlayerLogic p = new PlayerLogic(); p.SetUser(m_UserId); string condition = String.Format("Id > {0} AND ToUser in ({1}) AND BeginTime < '{2}' AND ExpireTime > '{3}' AND BeginTime > '{4}'", m_Mails.ReceivedId, "-1," + m_UserId, DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss"), DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss"), new DateTime(p.MyPlayer.CreateTime).ToString("yyyy-MM-dd HH:mm:ss")); var newMails = db.Select("mails", "Id,Message,AttachType,AttachCount,BeginTime,ExpireTime", condition); foreach (var mail in newMails) { Mail m = new Mail(); m.Message = (string)mail["Message"]; m.AttachedId = (int)(uint)mail["AttachType"]; m.AttachedCount = (int)(uint)mail["AttachCount"]; m.ExpireTime = ((DateTime)mail["ExpireTime"]).Ticks; m.StartTime = ((DateTime)mail["BeginTime"]).Ticks; m_Mails.Mails.Add((int)(uint)mail["Id"], m); m_Mails.ReceivedId = (int)(uint)mail["Id"]; } return(m_Mails.Mails.Count); }
public BILogger() { db = new DBProvider("BI"); }