/// <summary> /// 开启循环并执行主体功能 /// </summary> /// <param name="method"></param> /// <param name="secondsInterval">执行间隔时间</param> public void StartWhile( System.Windows.Forms.MethodInvoker method, int secondsInterval) { #region while (true) { if (!_enableStop || _status == ThreadStatus.Started) { try { if (method != null) { method(); } } catch (Exception e) { LogInterface.Write(e.ToString()); } } System.Threading.Thread.Sleep( TimeSpan.FromSeconds(secondsInterval)); } #endregion }
public static void RegisterLog(LogInterface log) { if (!_logs.Contains(log)) { _logs.Add(log); } }
public void PlayerAttackMonster(Connection client, AttackTargetRequest atr) { if (!_monsters.ContainsKey(atr.TargetID)) { LogInterface.Log(string.Format("Character({0}) attacking non existant monster {1} on map {2}", client.Character.ID, atr.TargetID, client.Character.MapID), LogInterface.LogMessageType.Game); client.SendPacket(new SeePlayerAttack(atr.TargetID, 0, client.Character, atr, 6)); // Wrong target } else { Monster m = _monsters[atr.TargetID]; client.Character.AttackTarget(m, atr); SeePlayerAttack pkt = new SeePlayerAttack(m.ID, m.CurHP, client.Character, atr); foreach (Connection c in _players.Values) { c.SendPacket(pkt); } if (m.Dead) { // Do loot! m.GiveLoot(client); } } }
static void Main() { OSProcess.HasSingle(); CustomConfig.Init(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); LogInterface.Listen(CustomConfig._LogDirectoryName.ToString()); Application.Run(new FrmMain()); }
void LogMessage(string strMsg, params object [] msgparams) { if (LogInterface != null) { LogInterface.LogMessage(this.JID, MessageImportance.Medium, strMsg, msgparams); } else { System.Diagnostics.Debug.WriteLine(strMsg, msgparams); } }
static void Main() { //zh Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); CustomConfig.GetSystemParameters(); LogInterface.Listen(CustomConfig.LogDirectoryName.ToString()); Application.Run(new Logon()); }
public Main() { LogInterface.InitMap("INFO:", "gray"); SimpleJSON.JSONNode node; //Read items node = SimpleJSON.JSONNode.Parse(Resources.Load <TextAsset>("data/world").text); ItemsManager.Init(node["items"]); LogInterface.InfoLog("INFO: Main init"); }
public IActionResult Log(LogInterfaceModel model) { try { LogInterface log = _mapper.Map <LogInterface>(model); log.additions = JsonSerializer.Serialize(model.additional); _loggerService.save(log); } catch (System.Exception ex) { Console.WriteLine(ex); } return(Ok()); }
public void Database_OnQueryComplete(object sender, EventArgs e) { DBQuery q = (DBQuery)sender; _pqLock.WaitOne(); LogInterface.Log("Finishing Query with key: " + q.Key, LogInterface.LogMessageType.Debug); Task task = _pendingQueries[q.Key]; _pendingQueries.Remove(q.Key); _pqLock.ReleaseMutex(); // reschedule the task to deal with the new data\ if (task.Type >= 0) { AddTask(task); } }
public void RegisterAuthString(string authString, int accountId, int hardCurrency, int vip, string displayName) { if (_accounts.Count > MAX_CACHED_ACCOUNTS) { int preDump = _accounts.Count; // Dump accounts that are a day old or more DumpAccounts(24 * 60 * 60); LogInterface.Log(string.Format("Dumping cached accounts: ({0}) -> ({1})", preDump, _accounts.Count), LogInterface.LogMessageType.System, true); } AuthAccountInfo aai = new AuthAccountInfo(); aai.AccountID = accountId; aai.HardCurrency = hardCurrency; aai.Vip = vip; aai.Timestamp = DateTime.Now.Ticks; aai.DisplayName = displayName; _accounts[authString] = aai; }
public DBQuery AddDBQuery(string sql, Task task, bool read = true) { if (task == null) { task = new Task(-1); } long key = UniqueKey(); DBQuery q = new DBQuery(sql, read, key); task.Query = q; _pqLock.WaitOne(); LogInterface.Log("Adding Query with key: " + key, LogInterface.LogMessageType.Debug); _pendingQueries[key] = task; _pqLock.ReleaseMutex(); _db.AddQuery(q); return(q); }
public void WriteException(LogInterface.LogLevel level, string message, Exception exception, string exMsg) { WriteToAppendBlob(DefaultLog.GetExceptionString(level, message, exception, exMsg)); }
public void WriteLog(LogInterface.LogLevel level, string message, string format, params object[] args) { WriteToAppendBlob(DefaultLog.GetLogString(level, message, format, args)); }
public void save(LogInterface log) { _context.Add(log); _context.SaveChanges(); }
void BeginPacket(HPacketType type) { LogInterface.Log(string.Format("BeginPacket({0})", type), LogInterface.LogMessageType.Debug); BeginPacket((ushort)type); }
public void WriteLog(LogInterface.LogLevel level, string message) { WriteToAppendBlob(DefaultLog.GetLogString(level, message)); }
public static void Start() { SortedDictionary <int, List <Load> > Queue = new SortedDictionary <int, List <Load> >(); foreach (int i in Enum.GetValues(typeof(Priority))) { List <Load> list = new List <Load>(); Queue.Add(i, list); } Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); m_parentInterface = new ParentInterface(); m_logInterface = new LogInterface(); m_logInterface.MdiParent = m_parentInterface; Assembly ourAssembly = Assembly.GetExecutingAssembly(); //This is where we will search for and queue all loading attributes foreach (Type type in ourAssembly.GetTypes()) { //First of all, search the class for a load method if possible Load[] load = (Load[])type.GetCustomAttributes(typeof(Load), false); if (load.Length > 0) { if (load[0].VisibleName == "") { load[0].VisibleName = type.Name; } load[0].Type = type; Queue[(int)load[0].Priority].Add(load[0]); } //Now search for any initialize static methods foreach (MethodInfo method in type.GetMethods(BindingFlags.Public | BindingFlags.Static)) { load = (Load[])method.GetCustomAttributes(typeof(Load), false); foreach (Load loadItem in load) { if (loadItem.VisibleName == "") { loadItem.VisibleName = method.Name; } loadItem.Type = type; loadItem.Initialize = method; Queue[(int)loadItem.Priority].Add(loadItem); } } } //This is where we enumerate the load queue and start activating things in order foreach (List <Load> list in Queue.Values) { foreach (Load load in list) { if (load.IsClass) { try { Log("Loading dynamic content: {0}\n", load.VisibleName); Activator.CreateInstance(load.Type, load.Parameters); } catch (Exception exception) { MessageBox.Show("An error has occured, the program must now close.", "Fatal Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); Application.Exit(); } } else { Log("Executing static method: {0}\n", load.VisibleName); load.Initialize.Invoke(null, null); } } } }
private void MainForm_Load(object sender, EventArgs e) { CustomConfig.GetSystemParameters(); LogInterface.Listen(CustomConfig.LogDirectoryName.ToString()); Console.Write(sizeof(int)); }