internal void WriteChatMsgSafe(string message) { if (InvokeRequired) { BeginInvoke((MethodInvoker)(() => WriteChatMsgSafe(message))); return; } if (string.IsNullOrEmpty(message)) { return; } var msg = HelperErrors.Marker() + "<FONT color=#000000> " + message + "</FONT><BR>"; if (AppVars.Profile.ServDiff != TimeSpan.MinValue) { var ts = DateTime.Now.Subtract(AppVars.Profile.ServDiff); var st = $"{ts.Hour:00}:{ts.Minute:00}:{ts.Second:00}"; msg = "<font class=chattime> " + st + " </font>" + msg; } WriteColorMessageToChat(msg); }
private bool CheckCrap(TimeSpan diff) { if (AppVars.ContentMainPhp != null && (AppVars.ContentMainPhp.IndexOf(HelperErrors.Marker(), StringComparison.OrdinalIgnoreCase) != -1 || AppVars.ContentMainPhp.IndexOf(HelperErrors.Head(), StringComparison.OrdinalIgnoreCase) != -1)) { try { if (AppVars.MainForm != null) { AppVars.MainForm.BeginInvoke( new ReloadMainPhpInvokeDelegate(AppVars.MainForm.ReloadMainPhpInvoke), new object[] { }); } } catch (InvalidOperationException) { } return(true); } if (diff.TotalSeconds > 360) { try { if (AppVars.MainForm != null) { AppVars.MainForm.BeginInvoke( new ReloadMainPhpInvokeDelegate(AppVars.MainForm.ReloadMainPhpInvoke), new object[] { }); } } catch (InvalidOperationException) { } return(true); } if (diff.TotalSeconds > 420) { UpdateGame("Перезаход из-за подвисания или обрыва"); return(true); } var last = DateTime.Now.Subtract(AppVars.LastInitForm).TotalMinutes; try { if (browserGame.Document == null) { if (last > 2) { UpdateGame("Сбой главной страницы (Document == null)"); return(true); } return(false); } if (browserGame.Document.All.Count == 0) { if (last > 2) { UpdateGame("Сбой главной страницы (Document.All.Count == 0)"); return(true); } return(false); } if (browserGame.Document.Body == null) { if (last > 2) { UpdateGame("Сбой главной страницы (Document.Body == null)"); return(true); } return(false); } if (browserGame.Document.Body.InnerHtml == null) { if (last > 2) { UpdateGame("Сбой главной страницы (Document.Body.InnerHtml == null)"); return(true); } return(false); } var currentWindow = browserGame.Document.Window; if (currentWindow == null) { if (last > 2) { UpdateGame("Сбой главной страницы (Document.Window == null)"); return(true); } return(false); } if (currentWindow.Frames == null || currentWindow.Frames.Count == 0) { if (last > 2) { UpdateGame("Сбой главной страницы (Document.Window.Frames.Count == 0)"); return(true); } return(false); } var frame = currentWindow.Frames["main_top"]; if (frame == null) { if (last > 2) { UpdateGame("Сбой главной страницы (frame == null)"); return(true); } return(false); } if (frame.Document == null) { if (last > 2) { try { if (AppVars.MainForm != null) { AppVars.MainForm.BeginInvoke( new ReloadMainPhpInvokeDelegate(AppVars.MainForm.ReloadMainPhpInvoke), new object[] { }); } } catch (InvalidOperationException) { } return(true); } return(false); } if (frame.Document.Body == null) { if (last > 2) { AppVars.DocumentBodyNullCount++; if (AppVars.DocumentBodyNullCount > 5) { UpdateGame("Сбой верхнего фрейма (Document.Body == null)"); return(true); } UpdateTexLog("Сбой верхнего фрейма (Document.Body == null). Счетчик: " + AppVars.DocumentBodyNullCount); } return(false); } AppVars.DocumentBodyNullCount = 0; if (frame.Document.All.Count == 0) { if (last > 2) { try { if (AppVars.MainForm != null) { AppVars.MainForm.BeginInvoke( new ReloadMainPhpInvokeDelegate(AppVars.MainForm.ReloadMainPhpInvoke), new object[] { }); } } catch (InvalidOperationException) { } return(true); } return(false); } if (!string.IsNullOrEmpty(AppVars.ContentMainPhp) && DateTime.Now.Subtract(AppVars.LastMainPhp).TotalSeconds > 30) { if (AppVars.ContentMainPhp.IndexOf(HelperErrors.Marker(), StringComparison.OrdinalIgnoreCase) != -1) { if (AppVars.ContentMainPhp.IndexOf(AppConsts.HttpServerError, StringComparison.Ordinal) != -1 || AppVars.ContentMainPhp.IndexOf("Connection error", StringComparison.Ordinal) != -1 || AppVars.ContentMainPhp.IndexOf("Server failure", StringComparison.Ordinal) != -1) { UpdateGame("Ошибка связи с сервером игры"); } else { try { if (AppVars.MainForm != null) { AppVars.MainForm.BeginInvoke( new ReloadMainPhpInvokeDelegate(AppVars.MainForm.ReloadMainPhpInvoke), new object[] { }); } } catch (InvalidOperationException) { } } return(true); } } } catch (Exception ex) { try { if (AppVars.MainForm != null) { AppVars.MainForm.BeginInvoke( new UpdateTexLogDelegate(AppVars.MainForm.UpdateTexLog), new object[] { "Ошибка с IE: " + ex.Message }); } } catch (InvalidOperationException) { } } return(false); }