void AddConfigWorkGroup(object parameter) { if (WindowMain.current?.EnableConnect?.SshManager?.IsConnected != true) { return; } Window_AddConfigWorkGroup wms = new Window_AddConfigWorkGroup(); Point pt = this.PointToScreen(new Point(0, 0)); wms.Left = pt.X; wms.Top = pt.Y; if (wms.ShowDialog() == true) { try { string work_group_name = wms.textBox_name.Text; JObject cloneRoot = this.Root?.DeepClone() as JObject; JProperty jprop_new = new JProperty(work_group_name, new JObject(new JProperty("processes", new JArray()))); if (cloneRoot?["work_group"] as JObject == null) { return; } (cloneRoot?["work_group"] as JObject).Add(jprop_new); if (ConfigOptionManager.SaveOption(cloneRoot) != 0) { return; } (this.Root?["work_group"] as JObject)?.Add(jprop_new); ConfigMenuTreeViewItem ui_config_group = new ConfigMenuTreeViewItem() { ConfigIdx = new ConfigMenuModel(this.Root) { WorkName = work_group_name } }; ui_config_group.IsExpanded = true; this.DetailView?.Items.Add(ui_config_group); } catch (Exception ex) { Log.ErrorIntoUI("config 그룹명이 중복됩니다.\r", "Add Config Group Name", Status.current.richTextBox_status); Log.PrintError(ex.Message, "UserControls.ConfigOptions.ConfigPanel.ConfigInfoPanel"); Console.WriteLine("JHLIM_DEBUG : " + ex.Message); WindowMain.current?.ShowMessageDialog("Add Config Fail", "그룹명이 중복됩니다.\n" + ex.Message, MahApps.Metro.Controls.Dialogs.MessageDialogStyle.Affirmative); } } }
protected override void OnDrop(DragEventArgs e) { base.OnDrop(e); if (this.ConfigIdx?.JobjRoot == null) { return; } Object data_obj = (Object)e.Data.GetData("Object"); List <LinuxTreeViewItem> list_ltvi = data_obj as List <LinuxTreeViewItem>; if (list_ltvi != null) { List <string> list_cofile_opt = new List <string>(); int i; for (i = 0; i < list_ltvi.Count; i++) { LinuxTreeViewItem ltvi = list_ltvi[i]; string tmp_index = ""; bool? retval = false; if (this.WorkName != null && this.ProcessIndex == null && ltvi.IsDirectory) { JObject jobj; if (this.ConfigIdx?.Type == "file") { jobj = new JObject(new JProperty("enc_option", new JObject(new JProperty("input_dir", ltvi.Path)))); } else { jobj = new JObject(new JProperty("comm_option", new JObject(new JProperty("input_dir", ltvi.Path)))); } if (jobj != null) { JObject tmp_root = this.ConfigIdx?.JobjRoot.DeepClone() as JObject; (tmp_root?["work_group"]?[WorkName]?["processes"] as JArray)?.Add(jobj); tmp_index = this.Items.Count.ToString(); Window_Config wc = new Window_Config(tmp_root, this.WorkName, tmp_index, true, ltvi.Path); Point pt = WindowMain.current.PointToScreen(new Point(WindowMain.current.Width - wc.Width, WindowMain.current.Height - wc.Height)); wc.Left = pt.X; wc.Top = pt.Y; retval = wc.ShowDialog(); if (retval == true) { (this.ConfigIdx?.JobjRoot["work_group"]?[WorkName]?["processes"] as JArray)?.Add(jobj); ConfigMenuTreeViewItem new_cip = new ConfigMenuTreeViewItem() { ConfigIdx = new ConfigMenuModel(this.ConfigIdx?.JobjRoot) { WorkName = this.WorkName, ProcessIndex = tmp_index } }; this.Items.Add(new_cip); //string cofile_type = this.root["type"].ToString(); //string config_info = WindowMain.current?.enableConnect?.sshManager?.EnvCoHome + "/var/conf/test/" + cofile_type + ".json"; //WindowMain.current?.enableConnect?.sshManager?.NewSendNRecvCofileCommand(list_ltvi, true, config_info, cofile_type); Console.WriteLine("JHLIM_DEBUG : Encrypt {0} {1} {2} [{3}]", this.ConfigIdx?.Type, this.WorkName, tmp_index, ltvi.Path); //string config_info = new_cip.work_name; //if(new_cip.index != null) // config_info += "_" + new_cip.index; string config_info = "/home/test/var/conf/test/" + this.ConfigIdx?.Type + ".json"; list_cofile_opt.Add("-c " + config_info); } else { break; } } } else { //string config_info = this.work_name; //if(this.index != null) // config_info += "_" + this.index; string config_info = "/home/test/var/conf/test/" + this.ConfigIdx?.Type + ".json"; if (ltvi.IsDirectory) { list_cofile_opt.Add("-c " + config_info + " -id " + ltvi.Path + " -od " + ltvi.Path); } else { string dir = ltvi.Path.Substring(0, ltvi.Path.Length - ltvi.FileName.Length); list_cofile_opt.Add("-c " + config_info + " -id " + dir + " -od " + dir + " -f " + ltvi.FileName); } } } if (i == list_ltvi.Count) { RequestEncryption(list_cofile_opt); } } e.Handled = true; }
void RefreshChild() { this.detailView?.Items.Clear(); JObject jobj_work_group_root = this.Root?["work_group"] as JObject; if (jobj_work_group_root == null) { return; } foreach (var work in jobj_work_group_root.Properties()) { JObject jobj_config_menu = work.Value as JObject; if (jobj_config_menu == null) { continue; } ConfigMenuTreeViewItem ui_config_group = new ConfigMenuTreeViewItem() { ConfigIdx = new ConfigMenuModel(this.Root) { WorkName = work.Name } }; ui_config_group.IsExpanded = true; this.detailView?.Items.Add(ui_config_group); JArray jarr_processes = jobj_config_menu?["processes"] as JArray; if (jarr_processes == null) { continue; } int i = 0; foreach (var jprop_config_info in jarr_processes) { JObject jobj_process_info = jprop_config_info as JObject; if (jobj_process_info == null) { continue; } string dir = null; if (this.Root["type"].ToString() == "file") { dir = (jobj_process_info["enc_option"] as JObject)?["input_dir"]?.ToString(); } else { dir = (jobj_process_info["comm_option"] as JObject)?["input_dir"]?.ToString(); } ui_config_group.Items.Add(new ConfigMenuTreeViewItem() { ConfigIdx = new ConfigMenuModel(this.Root) { WorkName = work.Name, ProcessIndex = i.ToString(), } }); i++; } } }