virtual public void ProcessView()
        {
            if (viewControl != null)
            {
                throw new InvalidOperationException();
            }
            if (viewProcessed)
            {
                throw new InvalidOperationException();
            }
            else
            {
                viewProcessed = true;
            }
            WebEntryInfo webEntryInfo = WebEntryInfo.GetWebEntryInfoFromObject(LinkedObject);

            if (viewType == ViewType.Simple)
            {
                viewControl = new SimpleViewControl();
            }
            else
            {
                throw new InvalidOperationException();
            }
            AddSpecialTask();
            viewControl.Dock = DockStyle.Fill;
            this.Controls.Add(viewControl);
            string cap = null;

            if (LinkedObject != null)
            {
                cap = ModelHelper.GetNameForObject(LinkedObject);
            }
            else if (FileFullPath != null)
            {
                cap = FileFullPath;
            }
            if (cap != null && cap.Length > 200)
            {
                cap = cap.Substring(0, 200) + "...";
            }
            if (cap != null)
            {
                SetNewCaption(cap);
            }
        }
Beispiel #2
0
 /// <summary>
 /// https://social.technet.microsoft.com/wiki/contents/articles/4487.access-remote-desktop-via-commandline.aspx
 /// </summary>
 /// <param name="w"></param>
 /// <returns></returns>
 public static string MakePathForCmd(WebEntryInfo w)
 {
     if (w.IsRDPAllowed)
     {
         StringBuilder str = new StringBuilder();
         str.Append("/v:");
         if (w.IsInInternalNetwork)
         {
             if (string.IsNullOrEmpty(w.InternalAddress))
             {
                 return(null);
             }
             str.Append(w.InternalAddress);
             if (string.IsNullOrEmpty(w.PortRDP) == false)
             {
                 str.Append(":");
                 str.Append(w.PortRDP);
             }
         }
         else
         {
             if (string.IsNullOrEmpty(w.ExternalAddress))
             {
                 return(null);
             }
             str.Append(w.ExternalAddress);
             if (string.IsNullOrEmpty(w.ExtPortRDP) == false)
             {
                 str.Append(":");
                 str.Append(w.ExtPortRDP);
             }
         }
         return(str.ToString());
     }
     else
     {
         return(null);
     }
 }
Beispiel #3
0
        override protected void OpenOtherTools(WebEntryInfo webEntryInfo, List <ToolStripItem> subs)
        {
            ToolStripMenuItem menuItem = null;
            //Открыть в Kitty
            string kittyPath = FrwConfig.Instance.GetPropertyValueAsString(AppLocator.SETTING_KittyPortablePath, null);

            if (string.IsNullOrEmpty(kittyPath) == false && File.Exists(kittyPath))
            {
                string pathForCmd = KittyUtils.MakeKittyPathForCmd(webEntryInfo);
                if (pathForCmd != null)
                {
                    menuItem        = new ToolStripMenuItem();
                    menuItem.Text   = "Открыть в Kitty";
                    menuItem.Click += (s, em) =>
                    {
                        try
                        {
                            //AppManager.Instance.CurrentWebEntryInfo = webEntryInfo;

                            if (CheckIfWeNeedVPN(webEntryInfo) == false)
                            {
                                return;
                            }
                            ProcessUtils.ExecuteProgram(kittyPath, pathForCmd);
                        }
                        catch (Exception ex)
                        {
                            Log.ShowError(ex);
                        }
                    };
                    subs.Add(menuItem);
                }
            }
            string puttyPath = FrwConfig.Instance.GetPropertyValueAsString(AppLocator.SETTING_PuttyPortablePath, null);

            if (string.IsNullOrEmpty(puttyPath) == false && File.Exists(puttyPath))
            {
                string puttyPathForCmd = KittyUtils.MakePuttyPathForCmd(webEntryInfo);
                if (puttyPathForCmd != null)
                {
                    menuItem        = new ToolStripMenuItem();
                    menuItem.Text   = "Открыть в Putty";
                    menuItem.Click += (s, em) =>
                    {
                        try
                        {
                            //AppManager.Instance.CurrentWebEntryInfo = webEntryInfo;

                            if (CheckIfWeNeedVPN(webEntryInfo) == false)
                            {
                                return;
                            }
                            ProcessUtils.ExecuteProgram(puttyPath, puttyPathForCmd);
                        }
                        catch (Exception ex)
                        {
                            Log.ShowError(ex);
                        }
                    };
                    subs.Add(menuItem);
                }
            }
            //Открыть в WinSCP
            if (AppLocator.WinSCPPath != null)
            {
                string pathForCmd = WinSCPUtils.MakePathForCmd(webEntryInfo);
                if (pathForCmd != null)
                {
                    menuItem      = new ToolStripMenuItem();
                    menuItem.Text = "Открыть в WinSCP";
                    //if (recоmendedViewType == ViewType.WORD) menuItem.Font = new Font(menuItem.Font, FontStyle.Bold);
                    menuItem.Click += (s, em) =>
                    {
                        try
                        {
                            if (CheckIfWeNeedVPN(webEntryInfo) == false)
                            {
                                return;
                            }
                            //AppManager.Instance.CurrentWebEntryInfo = webEntryInfo;
                            ProcessUtils.ExecuteProgram(AppLocator.WinSCPPath, pathForCmd);
                        }
                        catch (Exception ex)
                        {
                            Log.ShowError(ex);
                        }
                    };
                    subs.Add(menuItem);
                }
            }
            //Открыть в RDP
            if (AppLocator.RDPPath != null)
            {
                string pathForCmd = RDPUtils.MakePathForCmd(webEntryInfo);
                if (pathForCmd != null)
                {
                    menuItem        = new ToolStripMenuItem();
                    menuItem.Text   = "RDP";
                    menuItem.Click += (s, em) =>
                    {
                        try
                        {
                            if (CheckIfWeNeedVPN(webEntryInfo) == false)
                            {
                                return;
                            }
                            AppManager.Instance.CurrentWebEntryInfo = webEntryInfo;
                            ProcessUtils.ExecuteProgram(AppLocator.RDPPath, pathForCmd);
                        }
                        catch (Exception ex)
                        {
                            Log.ShowError(ex);
                        }
                    };
                    subs.Add(menuItem);
                }
            }
        }
Beispiel #4
0
        /// <summary>
        /// https://winscp.net/eng/docs/commandline
        /// https://winscp.net/eng/docs/scriptcommand_open
        /// </summary>
        /// <param name="w"></param>
        /// <returns></returns>
        public static string MakePathForCmd(WebEntryInfo w)
        {
            if (w.Url == null)
            {
                return(null);
            }

            StringBuilder str = new StringBuilder();

            str.Append("sftp://");
            if (w.Login != null)
            {
                str.Append(w.Login);
                if (w.Password != null)
                {
                    str.Append(":");
                    str.Append(w.Password);
                }
                str.Append("@");
            }
            if (w.IsInInternalNetwork)
            {
                if (string.IsNullOrEmpty(w.InternalAddress))
                {
                    return(null);
                }
                str.Append(w.InternalAddress);
                if (string.IsNullOrEmpty(w.PortSSH) == false)
                {
                    str.Append(":");
                    str.Append(w.PortSSH);
                }
            }
            else
            {
                if (string.IsNullOrEmpty(w.ExternalAddress))
                {
                    return(null);
                }
                str.Append(w.ExternalAddress);
                if (string.IsNullOrEmpty(w.ExtPortSSH) == false)
                {
                    str.Append(":");
                    str.Append(w.ExtPortSSH);
                }
            }
            if (w.Path != null)
            {
                if (w.Path.StartsWith("/") == false)
                {
                    str.Append("/");
                }
                str.Append(w.Path);
                if (w.Path.EndsWith("/") == false)
                {
                    str.Append("/");
                }
            }
            else
            {
                str.Append("/");
            }
            return(str.ToString());
        }