private void openFileOrFolder(bool openAsFolder)
 {
     try
     {
         if (listView.SelectedObjects != null && listView.SelectedObjects.Count > 1)
         {
             MessageBox.Show(FrwCRUDRes.List_Selected_More_Than_On_record);
         }
         else if (listView.SelectedObjects == null || listView.SelectedObjects.Count == 0)
         {
             MessageBox.Show(FrwCRUDRes.List_No_Selected_Records);
         }
         else
         {
             JAttachment selectedObject = null;
             if (listView.SelectedIndex > -1)
             {
                 selectedObject = listView.GetItem(listView.SelectedIndex).RowObject as JAttachment;
             }
             string path = Dm.Instance.GetRealPath(selectedObject.Path, SourceObject);
             if (openAsFolder)
             {
                 if (Directory.Exists(path) == false)
                 {
                     FileInfo fi = new FileInfo(path);
                     path = fi.Directory.FullName;
                 }
             }
             ProcessUtils.OpenFile(path);
         }
     }
     catch (Exception ex)
     {
         Log.ShowError(ex);
     }
 }
示例#2
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);
                }
            }
        }