//public static event EventHandler ErrorEvent; public static void CoreError(string modul, string function, Exception ex) { string msg = ClsFunktionen.MakeErrorMessage(modul, function, ex); ClsCommand cmd = new ClsCommand(); cmd.Domain = "Error"; cmd.Value1 = msg; GlobalServerEvents.SendMessage(null, new Classes.ClsStringEventArgs(new JavaScriptSerializer().Serialize(cmd))); }
internal static void Error(string modul, string function, Exception ex, bool silent = false) { string msg = ClsFunktionen.MakeErrorMessage(modul, function, ex); string nurLog = ""; if (silent) { nurLog = "silent"; } ClsCommand cmd = new ClsCommand(); cmd.Domain = "Error"; cmd.Value1 = msg; cmd.Value2 = nurLog; GlobalServerEvents.SendMessage(null, new Classes.ClsStringEventArgs(new JavaScriptSerializer().Serialize(cmd))); }
//private Display.ClsKommunikation ddk = new Display.ClsKommunikation(); protected override void OnMessage(MessageEventArgs e) { try { var name = this.Context.QueryString["name"]; if (e.IsBinary && this.loggedon) { byte[] bytearr = e.RawData; File.WriteAllBytes(this.binPfad, bytearr); if (this.binTyp == "Bild") { // Bildliste senden string ret = ClsRequests.DataRequest(new ClsCommand(command: "PictureList")); this.SendAsync(ret, null); } if (this.binTyp == "Font") { // Fontliste senden string ret = ClsRequests.DataRequest(new ClsCommand(command: "FontList")); this.SendAsync(ret, null); } if (this.binTyp == "Audio") { // Audiofileliste senden string ret = ClsRequests.DataRequest(new ClsCommand(command: "AudioFileList")); this.SendAsync(ret, null); } return; } string x = !name.IsNullOrEmpty() ? String.Format("\"{0}\" to {1}", e.Data, name) : e.Data; GlobalServerEvents.Fire_GotMessage(this, new ClsStringEventArgs(x)); ClsCommand rb = new JavaScriptSerializer().Deserialize <ClsCommand>(e.Data); if (rb.Command == "strPic") { this.binTyp = "Bild"; this.binPfad = Folder(rb.Value1, @"pictures\" + rb.Value2); return; } if (rb.Command == "strFont") { this.binTyp = "Font"; this.binPfad = Folder(rb.Value1, "fonts"); return; } if (rb.Command == "strSnd") { this.binTyp = "Audio"; this.binPfad = Folder(rb.Value1, "sounds"); return; } if (rb.Domain == "AN") { if (rb.Command == "allVarValues") { List <ClsTextVariabeln> tvl = ClsDBVariablen.Instance.GetAllTextVariablen(); for (int i = 0; i < tvl.Count; i++) { GlobalServerEvents.SendMessage("server", new ClsStringEventArgs(ClsVarCom.UpdateDivContentStr(tvl[i].ID, tvl[i].Wert))); } } } if (rb.Type == "req") { string ret = ClsRequests.DataRequest(rb); //int z = 0; do { //z++; //if (z > 10000) //{ // throw new Exception("Connection not open"); //} } while (this.State != WebSocketState.Open); this.SendAsync(ret, null); } else if (rb.Type == "logon") // Anmeldung { //string user = Core.DBControler.ClsOptionsControler.Options3("UserName").Value; string pwd = Core.DBControler.ClsOptionsControler.Password("Password"); if (pwd == rb.Value1) { this.loggedon = true; } ClsCommand cmd = new ClsCommand(); cmd.Domain = "loggedon"; cmd.Value1 = this.loggedon.ToString(); this.SendAsync(new JavaScriptSerializer().Serialize(cmd), null); return; } else if (rb.Type == "loggedon") // Fragen ob angemeldet { ClsCommand cmd = new ClsCommand(); cmd.Domain = "loggedon"; cmd.Value1 = this.loggedon.ToString(); this.SendAsync(new JavaScriptSerializer().Serialize(cmd), null); return; } else { if (!this.loggedon) { ClsCommand cmd = new ClsCommand(); cmd.Command = "nologgedon"; this.SendAsync(new JavaScriptSerializer().Serialize(cmd), null); return; } ClsCommands.Command(rb); } } catch (Exception) { } }