//private DispatcherTimer _dispatcherTimer; private void OnUploadCfgFile_Button_Click(object sender, RoutedEventArgs e) { // Configure open file dialog box Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog(); dlg.FileName = "origin"; // Default file name dlg.DefaultExt = ".csv"; // Default file extension dlg.Filter = "CSV documents (.csv)|*.csv"; // Filter files by extension // Show open file dialog box bool?result = dlg.ShowDialog(); // Process open file dialog box results if (result == true) { try { // Open document var filePath = dlg.FileName; HttpHandlers.SendFileContent(filePath, this); } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
private void OnSetExceptionCount_Button_Click(object sender, RoutedEventArgs e) { try { HttpHandlers.SendGetMethod("/incrRoomException", null); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private async Task ExportOpsFromAcc(string text, string fileName) { var result = await HttpHandlers.ExportRoomOpsAcc(text, this); if (result == null) { return; } var accRR = result.ToProto <accessory.MsgAccLoadReplayRecord>(); await parseAndSaveRecord(accRR.replayRecordBytes, fileName, false); }
private async Task LoadAndSaveRoomConfig(string recorderRoomConfigId, string jsonFileName) { var result = await HttpHandlers.ExportRoomCfg(recorderRoomConfigId, this); if (result == null) { return; } using (var textWriter = new StreamWriter(new FileStream(jsonFileName, FileMode.Create, FileAccess.ReadWrite), Encoding.Default)) { textWriter.Write(Encoding.UTF8.GetString(result)); } }
private async Task ExportAllRoomOps(string text) { string xid = "recordSID=" + text; var result = await HttpHandlers.ExportRoomShareIDs(xid, this); if (result == null) { return; } var strArray = ParseRoomShareIDs(result); for (var i = 0; i < strArray.Length; i++) { string recordID = strArray[i]; var filename = $"room-{i}-{recordID}"; await ExportOps(recordID, filename); } }
public static void LoadConfigFromFile() { var dir = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); if (string.IsNullOrWhiteSpace(dir)) { return; } var filePath = Path.Combine(dir, ConfigFileName); if (!File.Exists(filePath)) { return; } var str = HttpHandlers.WriteSafeReadAllLines(filePath); if (!string.IsNullOrWhiteSpace(str)) { //var a = JObject.Parse(str); //var url = (string) a["serverUrl"]; //if (!string.IsNullOrWhiteSpace(url)) //{ // ServerUrl = url; //} var des = (ProgramConfigJSON)JsonConvert.DeserializeObject(str, typeof(ProgramConfigJSON)); configJSON = des; ServerUrl = configJSON.serverURL; if (!string.IsNullOrWhiteSpace(configJSON.account)) { Account = configJSON.account; } if (!string.IsNullOrWhiteSpace(configJSON.password)) { Password = configJSON.password; } } }
private async Task ExportOps(string text, string fileName) { string xid; if (RbUserId.IsChecked == true) { xid = "userID=" + text; } else { xid = "recordSID=" + text; } var result = await HttpHandlers.ExportRoomOps(xid, this); if (result == null) { return; } await parseAndSaveRecord(result, fileName, true); }
private void OnKickAllInRoom_Button_Click(object sender, RoutedEventArgs e) { try { var inputWnd = new InputWnd { Owner = this, IsNeedUserId = false }; var result = inputWnd.ShowDialog(); if (result == false) { return; } var roomNumber = inputWnd.TextBoxRoomId.Text; HttpHandlers.SendPostMethod("/support/kickAll", roomNumber, "&roomNumber=" + roomNumber); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void OnAttachDealCfg_Button_Click(object sender, RoutedEventArgs e) { //TestManualProto(); // Configure open file dialog box Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog(); dlg.FileName = "origin"; // Default file name dlg.DefaultExt = ".csv"; // Default file extension dlg.Filter = "CSV documents (.csv)|*.csv"; // Filter files by extension // Show open file dialog box bool?result = dlg.ShowDialog(); // Process open file dialog box results if (result == true) { try { var inputWnd = new InputWnd { Owner = this, IsNeedUserId = false }; result = inputWnd.ShowDialog(); if (result == false) { return; } var roomNumber = inputWnd.TextBoxRoomId.Text; // Open document var filePath = dlg.FileName; HttpHandlers.SendFileContent2(filePath, roomNumber, HttpHandlers.PathAttachDealCfgFile, this); } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
private void OnLoad_Button_Clicked(object sender, RoutedEventArgs e) { Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog(); dlg.FileName = "origin"; // Default file name dlg.DefaultExt = ".csv"; // Default file extension dlg.Filter = "CSV documents (.csv)|*.csv"; // Filter files by extension // Show open file dialog box bool?result = dlg.ShowDialog(); // Process open file dialog box results if (result == true) { try { var x = HttpHandlers.WriteSafeReadAllLines(dlg.FileName); if (!string.IsNullOrWhiteSpace(x)) { using (var stringReader = new StringReader(x)) { // csv reader var csvReader = new CsvReader(stringReader); var expectedHeaders = MyCsvHeaders.GetHeaders(_gameType); // 读取头部 if (!csvReader.ReadHeader()) { MessageBox.Show("Invalid input csv file, no record found"); return; } if (expectedHeaders.Length != csvReader.FieldHeaders.Length) { MessageBox.Show("Invalid input csv file, header count not match"); return; } for (var i = 0; i < expectedHeaders.Length; i++) { if (string.Compare(expectedHeaders[i], csvReader.FieldHeaders[i], StringComparison.Ordinal) != 0) { MessageBox.Show("Invalid input csv file, header not match"); return; } } while (csvReader.Read()) { for (var i = 0; i < 4; i++) { var dealCfg = _dealCfgs[i]; dealCfg.ReadCsv(csvReader); dealCfg.Tiles2Ui(); } _drawCfg.ReadCsv(csvReader); _drawCfg.Tiles2Ui(); WallTiles2Ui(); // 仅读取第一个记录 break; } } } } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
private void OnDestroyRoom_Button_Click(object sender, RoutedEventArgs e) { HttpHandlers.SendPostMethod(@"/support/destroyMonkeyRoom", "", null); IsPlaying = false; }
private void OnCreateRoom_Button_Click(object sender, RoutedEventArgs e) { HttpHandlers.SendPostMethod(@"/support/createMonkeyRoom", "monkey", null); }