예제 #1
0
        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();
            });
        }
예제 #2
0
        //public static double RateProcessed = 0;
        public static bool SendNRecvCofileCommand(IEnumerable <Object> selected_list, bool isEncrypt)
        {
            string env_co_home      = LoadEnvCoHome();
            string remote_directory = env_co_home + add_path_config_upload + ServerList.selected_serverinfo_textblock.serverinfo.id + "/";

            string path_sel         = Cofile.current.Selected_config_file_path;
            string path_root        = ConfigJsonTree.cur_root_path;
            string remote_file_path = remote_directory;

            if (path_sel.Length > path_root.Length &&
                path_sel.Substring(0, path_root.Length) == ConfigJsonTree.cur_root_path)
            {
                remote_file_path += path_sel.Substring(path_root.Length).Replace('\\', '/');
                if (!sftp.Exists(remote_file_path))
                {
                    return(false);
                }
            }
            else
            {
                string[] split = path_sel.Split('\\');
                remote_file_path = remote_directory + split[split.Length - 1];
                if (!sftp.Exists(remote_file_path))
                {
                    return(false);
                }
            }


            //string remote_file_path = UploadFile(Cofile.current.Selected_config_file_path, remote_directory);
            //if(remote_file_path == null)
            //	return false;

            List <LinuxTreeViewItem> parents = new List <LinuxTreeViewItem>();
            var enumerator = selected_list.GetEnumerator();

            for (int i = 0; enumerator.MoveNext(); i++)
            {
                //RateProcessed = ((double)(i * 100)) / count;
                //WindowMain.current.progressBar.Value = RateProcessed;
                ////WindowMain.current.UpdateLayout();
                //WindowMain.current.InvalidateVisual();

                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;
                }

                //string str = LinuxTreeViewItem.selected_list[i].Path.Substring(env_co_home.Length);

                string send_cmd = MakeCommandRunCofile(env_co_home + add_path_run_cofile, selected_type, isEncrypt, ltvi.Path, remote_file_path, ltvi.IsDirectory);
                //SendCommandOnce(send_cmd);
                sendCommand(send_cmd);
                //string ret = readMessageBlocking(send_cmd);
                string ret     = readCofileMessageBlocking();
                string caption = isEncrypt ? "Encrypt" : "Decrypt";
                Log.ViewMessage(ret, caption, Status.current.richTextBox_status);

                LinuxTreeViewItem parent = ltvi.Parent;
                if (parent != null && parents.IndexOf(parent) < 0)
                {
                    parents.Add(parent);
                }
            }
            WindowMain.current.progressBar.Value = 0;
            for (int i = 0; i < parents.Count; i++)
            {
                parents[i].RefreshChild();
            }
            Cofile.current.RefreshListView(Cofile.cur_LinuxTreeViewItem);
            return(true);
        }