private void OnClickButtonNewJsonFile(object sender, RoutedEventArgs e) { if (!SSHController.ReConnect()) { return; } if (ConfigOptionManager.Path != null) { ; } WindowMain.CallBack afterSave_callback = null; MenuItem mi = sender as MenuItem; if (mi.Header as string == "_File") { afterSave_callback = NewJsonFile_File; } if (mi.Header as string == "_Sam") { afterSave_callback = NewJsonFile_Sam; } if (mi.Header as string == "_Tail") { afterSave_callback = NewJsonFile_Tail; } ConfirmSave(afterSave_callback); }
private void TabUpdate() { SSHController.ReConnect(); if (SSHController.IsConnected) { if (!bUpdateLinuxTree && UserControls.Cofile.current != null && tabControl.SelectedIndex == 0) { UserControls.Cofile.current.Refresh(); bUpdateLinuxTree = true; } if (!bUpdateDataBase && (tabControl.SelectedIndex == 2 || tabControl.SelectedIndex == 3)) //&& idx_tab_before_change != 2 && idx_tab_before_change != 3 //&& (tabControl.SelectedIndex == 2 || tabControl.SelectedIndex == 3)) { //UserControls.DataBaseInfo.RefreshUi(Changed_server_name); UserControls.DataBaseInfo.RefreshUi(); bUpdateDataBase = true; } if (!bUpdateConfigFile && UserControls.ConfigOption.current != null && tabControl.SelectedIndex == 1) { UserControls.ConfigOption.current.Clear(); bUpdateConfigFile = true; } } }
private void SaveFile(string path) { if (!CheckJson()) { return; } JToken Jtok_root = JsonTreeViewItem.convertToJToken(json_tree_view.Items[0] as JsonTreeViewItem); if (Jtok_root != null && FileContoller.Write(path, Jtok_root.ToString())) { if (SSHController.SetConfig(path, cur_root_path) == null) { WindowMain.current.ShowMessageDialog("Save", "서버 연결 에러"); } else { WindowMain.current.ShowMessageDialog("Save", path + " 파일이 저장되었습니다."); } } else { string caption = "Save Error"; string message = path + " 파일을 저장하는데 문제가 생겼습니다."; WindowMain.current.ShowMessageDialog(caption, message); Console.WriteLine("[" + caption + "] " + message); } }
private void KillAll() { SSHController.RunCofileCommand("cofile_monitor -killall"); DelayRefresh(); //UserControls.DataBaseInfo.RefreshUi(); }
private void OnClickServerLogRefresh(object sender, RoutedEventArgs e) { //TextRange rangeOfWord = new TextRange(richTextBox_serverLog.Document.ContentStart, richTextBox_serverLog.Document.ContentEnd); //rangeOfWord.Text = SSHController.GetEventLog(); textBox_serverLog.Text = SSHController.GetEventLog((int)numericUpDown_count.Value); //rangeOfWord.ApplyPropertyValue(TextElement.ForegroundProperty, Brushes.Red); }
private void KillSelected() { StringBuilder command = new StringBuilder(); command.Append("cofile_monitor -k "); foreach (var v in dataGrid.SelectedItems) { DataRowView drv = v as DataRowView; if (drv == null) { continue; } if (drv.Row.ItemArray.Length > 0) { command.Append(drv.Row.ItemArray[0].ToString()); command.Append(","); } } command.Remove(command.Length - 1, 1); SSHController.RunCofileCommand(command.ToString()); DelayRefresh(); //UserControls.DataBaseInfo.RefreshUi(); }
private void DelayRefresh() { SSHController.RunCofileCommand("cofile_monitor"); Log.PrintConsole("ssh connected = " + SSHController.ssh.IsConnected.ToString(), "JHLIM_DEBUG"); Thread.Sleep(500); UserControls.DataBaseInfo.RefreshUi(); }
private void OnClickButtonNewJsonFile(object sender, RoutedEventArgs e) { if (!SSHController.ReConnect()) { return; } if (ConfigOptionManager.Path != null) { ; } WindowMain.CallBack afterSave_callback = null; MenuItem mi = sender as MenuItem; if (mi.Header as string == "_File") { afterSave_callback = NewJsonFile_File; } if (mi.Header as string == "_Sam") { afterSave_callback = NewJsonFile_Sam; } if (mi.Header as string == "_Tail") { afterSave_callback = NewJsonFile_Tail; } //if(mi.Header as string == "_File") // afterSave_callback = delegate { WindowMain.current.ShowMessageDialog("New File Config", "새로만드시겠습니까?", MessageDialogStyle.AffirmativeAndNegative, NewJsonFile_File); }; //if(mi.Header as string == "_Sam") // afterSave_callback = delegate { WindowMain.current.ShowMessageDialog("New File Config", "새로만드시겠습니까?", MessageDialogStyle.AffirmativeAndNegative, NewJsonFile_Sam); }; //if(mi.Header as string == "_Tail") // afterSave_callback = delegate { WindowMain.current.ShowMessageDialog("New File Config", "새로만드시겠습니까?", MessageDialogStyle.AffirmativeAndNegative, NewJsonFile_Tail); }; ConfirmSave(afterSave_callback); }
private void OnClickDisConnectServer(object sender, RoutedEventArgs e) { SSHController.DisConnect(); if (WindowMain.current != null) { WindowMain.current.Clear(); } }
private void Decrypt() { TextRange txt = new TextRange(Status.current.richTextBox_status.Document.ContentStart, Status.current.richTextBox_status.Document.ContentEnd); txt.Text = ""; SSHController.view_message_caption = "Decrypt"; SSHController.SendNRecvCofileCommand(selected_list.ToArray(), false); //LinuxTreeViewItem.Refresh(); }
// remind_path = '/' 부터 시작 void ReLoadDirectory(string remainned_path = null) { SftpFile[] files; files = SSHController.PullListInDirectory(this.path); if (files == null) { this.IsExpanded = false; return; } this.Items.Clear(); int count_have_directory = 0; foreach (var file in files) { int i; for (i = 0; i < IGNORE_FILENAME.Length; i++) { if (file.Name == IGNORE_FILENAME[i]) { break; } } if (i != IGNORE_FILENAME.Length) { continue; } LinuxTreeViewItem ltvi; if (file.IsDirectory) { //this.Items.Insert(0, new LinuxTreeViewItem(file.FullName, file.Name, true)); //this.Items.Add(new LinuxTreeViewItem(file.FullName, file.Name, true)); ltvi = new LinuxTreeViewItem(file.FullName, file, file.Name, true, this); this.Items.Insert(count_have_directory++, ltvi); // remainned_path = '/' 부터 시작 if (remainned_path != null) { string[] split = remainned_path.Split('/'); if (split.Length > 1 && split[1] == file.Name) { ltvi.RefreshChild(remainned_path.Substring(split[1].Length + 1)); } } } else { ltvi = new LinuxTreeViewItem(file.FullName, file, file.Name, false, this); this.Items.Add(ltvi); } } }
public void RefreshListView(string path) { SftpFile[] files = SSHController.PollListInDirectory(path); if (files == null) { return; } label_listView.Content = path; RefreshListView(files); }
public void Refresh() { if (ServerList.selected_serverinfo_textblock == null || ServerList.selected_serverinfo_textblock.serverinfo == null) { return; } cur_root_path = root_path; cur_root_path += ServerList.selected_serverinfo_textblock.serverinfo.name + @"\"; SSHController.GetConfig(cur_root_path); }
private void OnClickConnectServer(object sender, RoutedEventArgs e) { //if(ServerList.selected_serverinfo_textblock == null) // return; ServerInfoTextBlock sitb = this.SelectedItem as ServerInfoTextBlock; if (sitb == null) { return; } SSHController.ReConnect(); WindowMain.current.Refresh(sitb.serverinfo.name); }
void loadDirectory() { SftpFile[] files; // path 가 null 이라면 부모 files = SSHController.PollListInDirectory(this.path); if (files == null) { this.IsExpanded = false; return; } this.Items.Clear(); Cofile.current.RefreshListView(files); int count_have_directory = 0; foreach (var file in files) { int i; for (i = 0; i < IGNORE_FILENAME.Length; i++) { if (file.Name == IGNORE_FILENAME[i]) { break; } } if (i != IGNORE_FILENAME.Length) { continue; } LinuxTreeViewItem ltvi; if (file.IsDirectory) { //this.Items.Insert(0, new LinuxTreeViewItem(file.FullName, file.Name, true)); //this.Items.Add(new LinuxTreeViewItem(file.FullName, file.Name, true)); ltvi = new LinuxTreeViewItem(file.FullName, file.Name, true); this.Items.Insert(count_have_directory++, ltvi); } else { //this.Items.Insert(0, new LinuxTreeViewItem(file.FullName, file.Name, false)); ltvi = new LinuxTreeViewItem(file.FullName, file.Name, false); this.Items.Add(ltvi); //if(file.Name.Substring(file.Name.Length - test_filter.Length, test_filter.Length) != test_filter) // ltvi.Visibility = Visibility.Collapsed; } } }
public void ConfirmEncDec(IEnumerable <Object> selected_list, bool isEncrypt) { string title = "", message = ""; var enumerator = selected_list.GetEnumerator(); for (int i = 0; enumerator.MoveNext(); i++) { LinuxTreeViewItem ltvi = enumerator.Current as LinuxTreeViewItem; Manager_proj_4_net4.UserControls.Cofile.LinuxListViewItem llvi = enumerator.Current as Manager_proj_4_net4.UserControls.Cofile.LinuxListViewItem; if (llvi != null) { ltvi = llvi.LinuxTVI as LinuxTreeViewItem; } if (ltvi == null) { break; } message += ltvi.Path + "\n"; } message += "\n"; if (isEncrypt) { SSHController.view_message_caption = "Encrypt"; title += Resources["String.MainDialog.Encrypt.Title"]; message += Resources["String.MainDialog.Encrypt.Message"]; } else { SSHController.view_message_caption = "Decrypt"; title += Resources["String.MainDialog.Decrypt.Title"]; message += Resources["String.MainDialog.Decrypt.Message"]; } WindowMain.current.ShowMessageDialog(title , message , MahApps.Metro.Controls.Dialogs.MessageDialogStyle.AffirmativeAndNegative , delegate { TextRange txt = new TextRange(Status.current.richTextBox_status.Document.ContentStart, Status.current.richTextBox_status.Document.ContentEnd); txt.Text = ""; SSHController.SendNRecvCofileCommand(selected_list, isEncrypt); //LinuxTreeViewItem.Refresh(); }); }
public static void RefreshUi(string changed_server_name) { string db_name = changed_server_name + ".db"; Path = SSHController.GetDataBase(path_root, db_name); if (Sqlite_LogTable.current != null) { Sqlite_LogTable.current.Refresh(); } if (Sqlite_StatusTable.current != null) { Sqlite_StatusTable.current.Refresh(); } }
public static void RefreshUi(string db_name = "") { db_name = db_name + (Idx_db_name++) + ".db"; Path = SSHController.GetDataBase(path_root, db_name); if (Sqlite_LogTable.current != null) { Sqlite_LogTable.current.Refresh(); } if (Sqlite_StatusTable.current != null) { Sqlite_StatusTable.current.Refresh(); } //FileContoller.FileDelete(path_root + prev_db_name); prev_db_name = db_name; }
public int InitOpenFile() { if (SSHController.ReConnect()) { //if(RemoveConfigFile(CurRootPathLocal) != 0) // return -2; if (SSHController.GetConfig(CurRootPathLocal) == null) { return(-1); } return(0); } return(-3); }
public static void RefreshUi(string db_name = "") { FileContoller.DeleteFilesInDirectory(path_root); db_name = db_name + (Idx_db_name++) + ".db"; Path = SSHController.GetDataBase(path_root, db_name); if (Sqlite_LogTable.current != null) { Sqlite_LogTable.current.Refresh(); } if (Sqlite_StatusTable.current != null) { Sqlite_StatusTable.current.Refresh(); } //FileContoller.DeleteFile(path_root + prev_db_name); prev_db_name = db_name; bUpdated = true; }
public int InitOpenFile() { if (SSHController.ReConnect()) { int retval = 0; if (RemoveConfigFile(CurRootPathLocal) != 0) { retval = -2; } if (SSHController.GetConfig(CurRootPathLocal) == null) { return(-1); } return(retval); } return(-3); }
private int SaveFile(string path_local) { if (!CheckJson()) { return(-1); } //JToken Jtok_root = JsonTreeViewItem.convertToJToken(json_tree_view.Items[0] as JsonTreeViewItem); JToken Jtok_root = Root; if (Jtok_root != null && FileContoller.Write(path_local, Jtok_root.ToString())) { string path_remote; if ((path_remote = SSHController.SetConfig(path_local, CurRootPathLocal)) == null) { //FileContoller.FileDelete(path_local); string caption = "Save Error"; string message = "서버 연결 에러"; WindowMain.current.ShowMessageDialog(caption, message); Log.PrintError(message, "UserControls.ConfigJsonTree.SaveFile"); return(-3); } else { string message = path_remote + " 파일이 저장되었습니다."; WindowMain.current.ShowMessageDialog("Save", message); Log.PrintLog(message, "UserControls.ConfigJsonTree.SaveFile"); ConfigOptions.ConfigOptionManager.bChanged = false; return(0); } } else { string caption = "Save Error"; string message = path_local + " 파일을 저장하는데 문제가 생겼습니다."; WindowMain.current.ShowMessageDialog(caption, message); Log.PrintError(message, "UserControls.ConfigJsonTree.SaveFile"); return(-2); } }
/// <summary> /// Sends a command with or without arguments to a remote SSH server, and then returns the response. (Ensure the response will be a single line with no required input!) /// </summary> /// <param name="address">The address to connect to</param> /// <param name="username">The username to use to connect with</param> /// <param name="password">The password for the username to connect to</param> /// <param name="scriptName">The name of the script to run</param> /// <param name="arguments">The arguments (if any) to send after the scriptName</param> /// <returns>Either the response from the remote client (prefixed with 'P'), or the error that occurred (prefixed with 'F')</returns> public static string SendCommand(string address, string username, string password, string scriptName, string arguments = "") { string response = string.Empty; try { SSHController controller = new SSHController(address, username, password); controller.Connect(); if (controller.IsConnected) { controller.CreateCommand($"{scriptName} {arguments}"); controller.Execute(); response = controller.Result(); } controller.CleanUp(); } catch (Exception exception) { return("F" + exception.Message); // F = Fail } return("P" + response); // P = Pass }
public bool LoadChild() { if (IsLoaded) { return(true); } SftpFile[] files; files = SSHController.PullListInDirectory(Fileinfo.FullName); if (files == null) { return(false); } this.Childs.Clear(); foreach (var file in files) { this.Childs.Add(new LinuxTree(file)); } IsLoaded = true; return(true); }
private bool LoadChild() { if (!IsLoaded) { return(true); } SftpFile[] files; // path 가 null 이라면 부모 files = SSHController.PollListInDirectory(fileinfo.FullName); if (files == null) { return(false); } this.Childs.Clear(); foreach (var file in files) { this.Childs.Add(new LinuxDirectoryTree(file)); } IsLoaded = true; return(true); }
private void OnKeyDownNumericUpDown(object sender, KeyEventArgs e) { textBox_serverLog.Text = SSHController.GetEventLog((int)numericUpDown_count.Value); }
private void DisconnectTimeout() { SSHController.DisConnect(); }
public void ConfirmEncDec(IEnumerable <Object> selected_list, bool isEncrypt) { string title = "", message = ""; MessageDialogStyle dialog_style = MessageDialogStyle.AffirmativeAndNegative; WindowMain.CallBack affirmative_callback = delegate { //TextRange txt = new TextRange(Status.current.richTextBox_status.Document.ContentStart, Status.current.richTextBox_status.Document.ContentEnd); //txt.Text = ""; SSHController.SendNRecvCofileCommand(selected_list, isEncrypt, true); //LinuxTreeViewItem.Refresh(); }; WindowMain.CallBack negative_callback = null; MetroDialogSettings settings = null; message += GetFileListString(selected_list); message += "\n"; CofileType cofileType = this.GetSelectedType(); if (cofileType == CofileType.undefined) { return; } if (isEncrypt && cofileType == CofileType.tail && !CheckHaveDirectory(selected_list)) { SSHController.view_message_caption = "Encrypt"; title += Resources["String.MainDialog.Encrypt.Title"]; message += Resources["String.MainDialog.Encrypt.Message.Tail"]; dialog_style = MessageDialogStyle.AffirmativeAndNegativeAndSingleAuxiliary; negative_callback = delegate { SSHController.SendNRecvCofileCommand(selected_list, isEncrypt, false); }; settings = new MetroDialogSettings() { AffirmativeButtonText = "Yes" , NegativeButtonText = "No" , FirstAuxiliaryButtonText = "Cancel" //, ColorScheme = MetroDialogOptions.ColorScheme }; } else if (isEncrypt) { SSHController.view_message_caption = "Encrypt"; title += Resources["String.MainDialog.Encrypt.Title"]; message += Resources["String.MainDialog.Encrypt.Message"]; } else { SSHController.view_message_caption = "Decrypt"; title += Resources["String.MainDialog.Decrypt.Title"]; message += Resources["String.MainDialog.Decrypt.Message"]; } message += "\n [ Type = " + cofileType.ToString().ToUpper() + " ]"; WindowMain.current.ShowMessageDialog(title, message, dialog_style, affirmative_callback, negative_callback, settings: settings); }
private int OpenEncryptFile() { if (listView_linux_files.SelectedItems.Count < 1) { return(-1); } LinuxListViewItem llvi = listView_linux_files.SelectedItems[0] as LinuxListViewItem; if (llvi == null) { return(-2); } string remote_path = llvi.LinuxTVI.Path; string local_filename = "temp" + Idx_Encrypt_File_Open++; string remote_path_dec_file = FindDecryptFile(remote_path); if (remote_path_dec_file == null) { return(-3); } if (SSHController.SendNRecvCofileCommandPreview(listView_linux_files.SelectedItems.Cast <Object>(), false)) { StartCoRoutine(10000, delegate { if (SSHController.MoveFileToLocal(root_path, remote_path_dec_file, local_filename, 0)) { llvi.LinuxTVI.RefreshChildFromParent(); Cofile.current.RefreshListView(Cofile.cur_LinuxTreeViewItem); string url_localfile = root_path + local_filename; string[] split = remote_path.Split('.'); string expansion = split[split.Length - 2]; if (expansion == "png" || expansion == "dib" || expansion == "bmp" || expansion == "jpg" || expansion == "jpeg" || expansion == "jpe" || expansion == "jfif" || expansion == "gif" || expansion == "tif" || expansion == "tiff" ) { Window_ViewImage wvi = new Window_ViewImage(LoadImage(url_localfile), llvi.LinuxTVI.FileInfo.Name); FileContoller.DeleteFile(url_localfile); Point pt = this.PointToScreen(new Point(0, 0)); wvi.Left = pt.X; wvi.Top = pt.Y; wvi.ShowDialog(); } else { string str = FileContoller.Read(url_localfile); FileContoller.DeleteFile(url_localfile); Window_ViewFile wvf = new Window_ViewFile(str, llvi.LinuxTVI.FileInfo.Name); Point pt = this.PointToScreen(new Point(0, 0)); wvf.Left = pt.X; wvf.Top = pt.Y; wvf.ShowDialog(); } return(0); } else { //Log.ErrorIntoUI("Check the Cofile Config File or Check File To Decrypt", "Decrypt Failed", Status.current.richTextBox_status); //Log.PrintError("Cant Download Decrypt File", "UserControls.Cofile.OpenEncryptFile"); return(-1); } }, "Check the Cofile Config File or Check File To Decrypt", "Decrypt Failed"); } return(-4); }
void EncryptFileOpen() { if (listView_linux_files.SelectedItems.Count < 1) { return; } LinuxListViewItem llvi = listView_linux_files.SelectedItems[0] as LinuxListViewItem; if (llvi == null) { return; } if (SSHController.SendNRecvCofileCommand(listView_linux_files.SelectedItems.Cast <Object>(), false)) { string remote_path = llvi.LinuxTVI.Path; JToken jtok = JsonController.parseJson(FileContoller.Read(current.Selected_config_file_path)); if (jtok == null) { return; } JValue jval_input_extansion = jtok["dec_option"]["input_extension"] as JValue; JValue jval_output_extension = jtok["dec_option"]["output_extension"] as JValue; if (remote_path.Length > jval_input_extansion.Value.ToString().Length + 1 && remote_path.Substring(remote_path.Length - jval_input_extansion.Value.ToString().Length) == jval_input_extansion.Value.ToString()) { remote_path = remote_path.Substring(0, remote_path.Length - jval_input_extansion.Value.ToString().Length - 1); } string remote_dec_path = remote_path + "." + jval_output_extension.Value.ToString(); string[] split_remote_path = remote_path.Split('/'); string local_filename = split_remote_path[split_remote_path.Length - 1] + Idx_Encrypt_File_Open++; if (SSHController.moveFileToLocal(root_path, remote_dec_path, local_filename)) { llvi.LinuxTVI.RefreshChildFromParent(); Cofile.current.RefreshListView(Cofile.cur_LinuxTreeViewItem); string url_localfile = root_path + local_filename; string[] split = remote_path.Split('.'); if (split[split.Length - 1] == "gif" || split[split.Length - 1] == "bmp" || split[split.Length - 1] == "jpg" || split[split.Length - 1] == "png" ) { Window_ViewImage wvi = new Window_ViewImage(LoadImage(url_localfile), llvi.LinuxTVI.FileInfo.Name); File.Delete(url_localfile); wvi.ShowDialog(); } else { string str = FileContoller.Read(url_localfile); File.Delete(url_localfile); Window_ViewFile wvf = new Window_ViewFile(str, llvi.LinuxTVI.FileInfo.Name); wvf.ShowDialog(); } } else { Log.PrintError("Decryption Failed\r\tCheck the config file", "ListView_linux_files_MouseDoubleClick", Status.current.richTextBox_status); } } }