Exemplo n.º 1
0
        private TabViewItem CreateNewTab(CWebShellInfo info, string Plugin)
        {
            TabViewItem newItem = new TabViewItem();

            newItem.Header = info.Url;

            switch (Plugin)
            {
            case "FileManager":
                newItem.IconSource = new Microsoft.UI.Xaml.Controls.SymbolIconSource()
                {
                    Symbol = Symbol.Folder
                };
                var page = new Plugins.FileManagerPage();
                page.SetInfo(info).ConfigureAwait(false);
                newItem.Content = page;
                break;

            case "RemoteShell":
                newItem.IconSource = new Microsoft.UI.Xaml.Controls.SymbolIconSource()
                {
                    Symbol = Symbol.PostUpdate
                };
                newItem.Content = new Plugins.TerminalPage();
                break;
            }


            // The content of the tab is often a frame that contains a page, though it could be any UIElement.


            return(newItem);
        }
Exemplo n.º 2
0
        public static async Task ModifyWebShellAsync(CWebShellInfo info)
        {
            SqliteConnection sqliteConnection = null;
            SqliteCommand    sqliteCommand    = null;
            string           strDatabasePath  = ApplicationData.Current.LocalFolder.Path + "\\" + m_DatabasePath + "\\" + m_DatabaseFile;

            try
            {
                sqliteConnection = new SqliteConnection(string.Format("Filename={0}", strDatabasePath));
                await sqliteConnection.OpenAsync();

                //插入数据
                string strInsert = string.Format("update WebShell set URL=\'{0}\',PASSWORD=\'{1}\',TYPE=\'{2}\',REMARK=\'{3}\',ENCODING=\'{4}\' where GUID=\'{5}\'",
                                                 info.Url, info.Password, info.Type.ToString(), info.Remark, info.Encoding, info.Guid.ToString());
                sqliteCommand = new SqliteCommand(strInsert, sqliteConnection);
                sqliteCommand.ExecuteReader();
            }
            catch (Exception e)
            {
                throw;
            }
            finally
            {
                sqliteConnection?.Dispose();
                sqliteCommand?.Dispose();
            }
        }
Exemplo n.º 3
0
        private async Task DeleteWebShell(CWebShellInfo info)
        {
            await DataBaseManager.DeleteWebShellAsync(info.Guid);

            var deleteItem = (from item in m_pShellListModeView where item.Guid == info.Guid select item).FirstOrDefault();

            m_pShellListModeView.Remove(deleteItem);
        }
Exemplo n.º 4
0
        public static async Task AddWebShellAsync(CWebShellInfo info)
        {
            try
            {
                //判断文件夹在不在
                var items = await ApplicationData.Current.LocalFolder.GetFolderAsync("Database");
            }
            catch (Exception e)
            {
                if ((uint)e.HResult == 0x80070002)
                {
                    await ApplicationData.Current.LocalFolder.CreateFolderAsync("Database");
                }
                else
                {
                    throw;
                }
            }


            SqliteConnection sqliteConnection = null;
            SqliteCommand    sqliteCommand    = null;
            string           strDatabasePath  = ApplicationData.Current.LocalFolder.Path + "\\" + m_DatabasePath + "\\" + m_DatabaseFile;

            try
            {
                sqliteConnection = new SqliteConnection(string.Format("Filename={0}", strDatabasePath));
                sqliteConnection.Open();

                //表初始化
                string strWebShellDataInit = "create table if not exists WebShell(GUID CHAR(38) PRIMARY KEY, URL VARCHAR(2048), PASSWORD VARCHAR(2048), TYPE VARCHAR(32), REMARK VARCHAR(4096),ENCODING VARCHAR(32),CREATETIME INTEGER)";
                sqliteCommand = new SqliteCommand(strWebShellDataInit, sqliteConnection);
                sqliteCommand.ExecuteReader();
                sqliteCommand.Dispose();

                //插入数据
                string strInsert = string.Format("insert into WebShell(GUID,URL,PASSWORD,TYPE,REMARK,ENCODING,CREATETIME) VALUES (\'{0}\',\'{1}\',\'{2}\',\'{3}\',\'{4}\',\'{5}\',{6})",
                                                 info.Guid.ToString(), info.Url, info.Password, info.Type.ToString(), info.Remark, info.Encoding, info.CreateTime);
                sqliteCommand = new SqliteCommand(strInsert, sqliteConnection);
                sqliteCommand.ExecuteReader();
            }
            catch (Exception e)
            {
                throw;
            }
            finally
            {
                sqliteConnection?.Dispose();
                sqliteCommand?.Dispose();
            }
        }
Exemplo n.º 5
0
        private async Task ModifyWebShell(CWebShellInfo info)
        {
            WebShellConfigDialog dlg = new WebShellConfigDialog();

            dlg.SetWebShellConfig(info);
            var result = await dlg.ShowAsync();

            if (result == ContentDialogResult.Primary)
            {
                info = dlg.GetWebShellConfig();
                //更新数据库
                await DataBaseManager.ModifyWebShellAsync(info);

                //更新界面数据
                var modifyItem = (from item in m_pShellListModeView where item.Guid == info.Guid select item).FirstOrDefault();
                modifyItem.SetFromData(info);
            }

            //RefreshWebShell();
        }
 public void SetWebShellConfig(CWebShellInfo info)
 {
     m_pModeView.SetInfo(info);
 }