Esempio n. 1
0
        public int Refresh()
        {
            if (WindowMain.current == null)
            {
                return(-1);
            }

            //if(ssh != null && ssh.IsConnected)
            //	ssh.Disconnect();
            //if(sftp != null && sftp.IsConnected)
            //	sftp.Disconnect();

            // 삭제
            //treeView_linux_directory.Items.Clear();
            //listView_linux_files.Items.Clear();
            LinuxTreeViewItem.Clear();
            treeView_linux_directory.Items.Clear();
            listView_linux_files.Items.Clear();
            listView_work_files.Items.Clear();

            // 추가
            //string home_dir = sftp.WorkingDirectory;
            // root 의 path 는 null 로 초기화
            string working_dir = SSHController.WorkingDirectory;

            if (working_dir == null)
            {
                return(-1);
            }

            LinuxTreeViewItem.root = new LinuxTreeViewItem("/", null, "/", true, null);
            treeView_linux_directory.Items.Add(LinuxTreeViewItem.root);
            LinuxTreeViewItem.root.RefreshChild(working_dir, false);
            Cofile.current.RefreshListView(LinuxTreeViewItem.Last_Refresh);
            Log.PrintLog("[refresh]", "UserControls.Cofile.Refresh");

            return(0);
            //LinuxTreeViewItem.ReconnectServer();
        }
Esempio n. 2
0
        string GetFileListString(IEnumerable <Object> selected_list)
        {
            string str        = "";
            var    enumerator = selected_list.GetEnumerator();

            for (int i = 0; enumerator.MoveNext(); i++)
            {
                LinuxTreeViewItem ltvi = enumerator.Current as LinuxTreeViewItem;

                CofileUI.UserControls.Cofile.LinuxListViewItem llvi = enumerator.Current as CofileUI.UserControls.Cofile.LinuxListViewItem;
                if (llvi != null)
                {
                    ltvi = llvi.LinuxTVI as LinuxTreeViewItem;
                }

                if (ltvi == null)
                {
                    continue;
                }

                str += ltvi.Path + "\n";
            }
            return(str);
        }
Esempio n. 3
0
        public LinuxTreeViewItem(string _path, SftpFile _file, string header, bool _isDirectory, LinuxTreeViewItem _parent)
        {
            if (header == null && _path != null)
            {
                string[] splited = _path.Split('/');
                header = splited[splited.Length - 1];
            }

            this.Header = new Grid_Header(header, _isDirectory);
            this.Cursor = Cursors.Hand;
            this.Path   = _path;
            this.parent = _parent;

            FileInfo = _file;

            //InitContextMenu();

            this.IsDirectory = _isDirectory;

            if (this.IsDirectory)
            {
                // 임시
                Label dummy = new Label();
                this.Items.Add(dummy);
                TextBlock tb = this.Header.Tb_name as TextBlock;
                if (tb == null)
                {
                    return;
                }

                tb.FontWeight = FontWeights.Bold;
                tb.Foreground = _Color.Folder_foreground;
            }

            if (this.Header.Text != null && this.Header.Text.Length > 0 && this.Header.Text[0] == '.')
            {
                this.Header.Opacity = .5;
            }
        }
Esempio n. 4
0
        public LinuxTreeViewItem(string _path, SftpFile _file, string header, bool _isDirectory, LinuxTreeViewItem _parent)
        {
            if (header == null && _path != null)
            {
                string[] splited = _path.Split('/');
                header = splited[splited.Length - 1];
            }

            this.Header = new Grid_Header(header, _isDirectory);
            this.Cursor = Cursors.Hand;
            this.Path   = _path;
            this.parent = _parent;

            FileInfo = _file;

            //InitContextMenu();

            this.IsDirectory = _isDirectory;

            if (this.IsDirectory)
            {
                // 임시
                Label dummy = new Label();
                this.Items.Add(dummy);
            }

            if (this.Header.Text.Length > 0 && this.Header.Text[0] == '.')
            {
                this.Header.Opacity = .5;
            }
        }
Esempio n. 5
0
        protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
        {
            isMouseDownHandled = true;

            if (WindowMain.bCtrl)
            {
                MySelected = !MySelected;
            }
            else if (WindowMain.bShift && root_view.SelectedList.Count > 0)
            {
                ItemCollection Items = (this.Parent as ItemsControl)?.Items;
                if (Items != null)
                {
                    int idx_start = Items.IndexOf(root_view.SelectedList[0]);
                    int idx_end   = Items.IndexOf(this);

                    if (idx_start >= 0 && idx_end >= 0)
                    {
                        // 선택 초기화
                        while (root_view.SelectedList.Count > 0)
                        {
                            root_view.SelectedList[0].MySelected = false;
                        }

                        // 선택
                        int add_i = idx_start < idx_end ? 1 : -1;
                        for (int i = idx_start; i != idx_end + add_i; i += add_i)
                        {
                            LinuxTreeViewItem child = Items[i] as LinuxTreeViewItem;
                            if (child == null)
                            {
                                continue;
                            }

                            child.MySelected = true;
                        }
                    }
                    else
                    {
                        Focus();
                    }
                }
                else
                {
                    Focus();
                }
            }
            else if (!MySelected)
            {
                Focus();
            }
            else
            {
                isMouseDownHandled = false;
            }

            if (e.ClickCount > 1)
            {
                this.IsExpanded = !this.IsExpanded;
            }
            e.Handled = true;
        }
Esempio n. 6
0
        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;
        }
Esempio n. 7
0
 public void Clear()
 {
     this.SelectedList.Clear();
     this.Items.Clear();
     this.LastRefreshItem = null;
 }
Esempio n. 8
0
        public int LoadDaemonInfo()
        {
            if (WindowMain.current?.EnableConnect?.SshManager?.GetDaemonInfo(MainSettings.Path.PathDirConfigFile) == 0)
            {
                string daemon_info_json = FileContoller.Read(MainSettings.Path.PathDirConfigFile + "/daemon_info.json");
                if (daemon_info_json == null || daemon_info_json.Length == 0)
                {
                    daemon_info_json = Properties.Resources.daemon_info_default;
                }

                JObject root;
                try
                {
                    root = JObject.Parse(daemon_info_json);
                }
                catch (Exception e)
                {
                    Console.WriteLine("JHLIM_DEBUG : JObject parse " + e.Message);
                    return(-2);
                }

                JArray jarr = root?["daemon_info"] as JArray;
                if (jarr == null)
                {
                    return(-3);
                }

                try
                {
                    foreach (JObject jobj in jarr)
                    {
                        string[]     arr_path_names = jobj["path"]?.ToString().Split('/');
                        ItemsControl ic_cur         = this;

                        for (int i = 0; i < arr_path_names.Length; i++)
                        {
                            if (arr_path_names[i] == null || arr_path_names[i] == "")
                            {
                                continue;
                            }

                            int j;
                            int count = ic_cur.Items.Count;
                            for (j = 0; j < count; j++)
                            {
                                LinuxTreeViewItem ltvi_child = ic_cur.Items[j] as LinuxTreeViewItem;
                                if (ltvi_child == null)
                                {
                                    continue;
                                }

                                if (ltvi_child.FileName == arr_path_names[i])
                                {
                                    if (ltvi_child.Path == jobj["path"]?.ToString())
                                    {
                                        ltvi_child.ConfigPath = jobj["config"]?.ToString();
                                        ic_cur = null;
                                    }
                                    else
                                    {
                                        ltvi_child.ConfigPath = "";
                                        ic_cur = ltvi_child;
                                    }
                                    break;
                                }
                            }
                            if (j == count || ic_cur == null)
                            {
                                break;
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine("JHLIM_DEBUG : SetConfigInfo " + e.Message);
                }
            }
            return(0);
        }
Esempio n. 9
0
        public ConfigPanel ConvertFromJson(JObject jobj_root)
        {
            if (jobj_root == null)
            {
                return(null);
            }

            servergrid = new ConfigPanel();
            try
            {
                foreach (var v in jobj_root.Properties())
                {
                    JObject jobj_config_root = v.Value as JObject;
                    if (jobj_config_root == null)
                    {
                        continue;
                    }

                    ConfigMenuButton smbtn = new ConfigMenuButton(servergrid, jobj_config_root, v.Name);
                    servergrid.Children.Add(smbtn);
                    servergrid.SubPanel.Children.Add(smbtn.child);

                    JObject jobj_work_group_root = jobj_config_root.GetValue("work_group") as JObject;
                    if (jobj_work_group_root == null)
                    {
                        continue;
                    }

                    foreach (var work in jobj_work_group_root.Properties())
                    {
                        JObject jobj_server_menu = work.Value as JObject;
                        if (jobj_server_menu == null)
                        {
                            continue;
                        }

                        ConfigInfoPanel ui_config_group = new ConfigInfoPanel(smbtn, jobj_config_root, work.Name);
                        ui_config_group.IsExpanded = true;
                        smbtn.child.Items.Add(ui_config_group);

                        JArray jarr_processes = jobj_server_menu.GetValue("processes") as JArray;
                        if (jarr_processes == null)
                        {
                            continue;
                        }
                        int i = 0;
                        foreach (var jprop_server_info in jarr_processes)
                        {
                            JObject jobj_process_info = jprop_server_info as JObject;
                            if (jobj_process_info == null)
                            {
                                continue;
                            }
                            string dir       = null;
                            string daemon_yn = null;
                            if (jobj_config_root.GetValue("type").ToString() == "file")
                            {
                                dir = (jobj_process_info.GetValue("enc_option") as JObject)?.GetValue("input_dir")?.ToString();
                            }
                            else
                            {
                                dir = (jobj_process_info.GetValue("comm_option") as JObject)?.GetValue("input_dir")?.ToString();
                            }
                            ui_config_group.Items.Add(new ConfigInfoPanel(smbtn, jobj_config_root, work.Name, i.ToString(), dir));

                            string daemon_keyword = "dir_monitoring_yn";
                            if (jobj_config_root.GetValue("type").ToString() == "tail")
                            {
                                daemon_keyword = "daemon_yn";
                            }

                            JToken jcur = jobj_process_info;
                            while (jcur != null &&
                                   daemon_yn == null)
                            {
                                daemon_yn = (jcur["comm_option"] as JObject)?.GetValue(daemon_keyword)?.ToString();
                                jcur      = jcur.Parent;
                                while (jcur != null &&
                                       jcur as JObject == null)
                                {
                                    jcur = jcur.Parent;
                                }
                            }

                            if (daemon_yn == "True")
                            {
                                LinuxTreeViewItem.ChangeColor(root, dir, jobj_config_root["type"] + "-" + work.Name + "-" + i);
                            }
                            i++;
                        }
                    }
                }
                return(servergrid);
            }
            catch (Exception e)
            {
                Log.PrintError(e.Message, "UserControls.ServerInfo.ConvertFromJson");
            }
            return(null);
        }
Esempio n. 10
0
 public ConfigMenu()
 {
     InitializeComponent();
     root = (DataContext as LinuxTreeViewItem);
     InitConfigTab();
 }