Esempio n. 1
0
        /// <summary>
        /// 提交命令
        /// </summary>
        /// <param name="data">shellstruct数据</param>
        /// <param name="funcNameXpath">xpath表示的方法名(/cmder/readfile)</param>
        /// <param name="param"></param>
        /// <returns></returns>
        private byte[] SubmitCommand(ShellStruct data, string funcNameXpath, string[] param)
        {
            CustomShellType             shellType         = CustomShellTypeProvider.GetShellType(data.ShellType);
            CustomCommandCode           customCommandCode = new CustomCommandCode(shellType, data.ShellPwd);
            Dictionary <string, string> commandCode       = customCommandCode.GetCode(funcNameXpath, param);
            HttpClient httpClient = new HttpClient();

            return(httpClient.SubmitCommandByPost(data.ShellUrl, commandCode));
        }
Esempio n. 2
0
 public static string GetCustomShellTypeServerCode(string shellTypeName)
 {
     if (CustomShellTypeProvider.ShellTypeStyleContainer.ContainsKey(shellTypeName))
     {
         CustomShellType shelltype = CustomShellTypeProvider.ShellTypeStyleContainer[shellTypeName];
         return(shelltype.BasicSetting.ServiceExample);
     }
     return(null);
 }
Esempio n. 3
0
        /// <summary>
        /// 提交命令
        /// </summary>
        /// <param name="data">shellstruct数据</param>
        /// <param name="funcNameXpath">xpath表示的方法名(/cmder/readfile)</param>
        /// <param name="param"></param>
        public byte[] SubmitCommand(Shell data, string funcNameXpath, string[] param)
        {
            CustomShellType             shellType         = CustomShellTypeProvider.GetShellType(data.ShellType);
            CustomCommandCode           customCommandCode = new CustomCommandCode(shellType, data.ShellPwd);
            Dictionary <string, string> commandCode       = customCommandCode.GetCode(funcNameXpath, param);

            ShellExtra shellExtra = new ShellExtra(data.ShellExtraString);
            HttpClient httpClient = new HttpClient(shellExtra.HttpHeader);

            return(httpClient.SubmitCommandByPost(data.ShellUrl, commandCode));
        }
Esempio n. 4
0
        /// <summary>
        /// 获取CustomShellType子节点的名字列表
        /// </summary>
        /// <param name="shellTypeName"></param>
        /// <returns></returns>
        public static string[] GetDbNodeFuncCodeNameList(string shellTypeName)
        {
            List <string> funcCodeNameList = new List <string>();

            if (CustomShellTypeProvider.ShellTypeStyleContainer.ContainsKey(shellTypeName))
            {
                CustomShellType shelltype = CustomShellTypeProvider.ShellTypeStyleContainer[shellTypeName];
                FuncTreeNode    dbNode    = shelltype.FuncTreeRoot.FindNodes("/DbManager");
                foreach (var child in dbNode.Nodes)
                {
                    funcCodeNameList.Add(child.Value.Info);
                }
            }
            return(funcCodeNameList.ToArray());
        }
Esempio n. 5
0
        public static string[] GetDbNodeInfoList(string shellTypeName)
        {
            var funcCodeNameList = new List <string>();

            if (CustomShellTypeProvider.ShellTypeStyleContainer.ContainsKey(shellTypeName))
            {
                CustomShellType shelltype = CustomShellTypeProvider.ShellTypeStyleContainer[shellTypeName];
                FuncTreeNode    dbNode    = shelltype.FuncTreeRoot.FindNodes("/DbManager");
                if (dbNode != null)
                {
                    funcCodeNameList.AddRange(dbNode.Nodes.Select(child => child.Value.Info));
                }
            }
            return(funcCodeNameList.ToArray());
        }
Esempio n. 6
0
        private byte[] SubmitCommand(ShellStruct data,
                                     string funcNameXpath, string[] param,
                                     bool isBindUploadProgressChangedEvent,
                                     bool isBindDownloadProgressChangedEvent)
        {
            CustomShellType             shellType         = CustomShellTypeProvider.GetShellType(data.ShellType);
            CustomCommandCode           customCommandCode = new CustomCommandCode(shellType, data.ShellPwd);
            Dictionary <string, string> commandCode       = customCommandCode.GetCode(funcNameXpath, param);
            HttpClient httpClient = new HttpClient();

            //if (isBindUploadProgressChangedEvent)
            //    httpClient.UploadFileProgressChangedToDo += httpClient_UploadFileProgressChangedToDo;
            //if (isBindDownloadProgressChangedEvent)
            //    httpClient.DownloadFileProgressChangedToDo += httpClient_DownloadFileProgressChangedToDo;
            return(httpClient.SubmitCommandByPost(data.ShellUrl, commandCode));
        }
Esempio n. 7
0
        /// <summary>
        /// 注册CustomShellType
        /// </summary>
        public static void RegisterCustomShellType(string customShellTypePath)
        {
            //清空CustomShellTypeProvider
            CustomShellTypeProvider.Clear();

            //读取shelltype列表(.type)
            List <string> typeList = XmlHelper.LoadXMlList(customShellTypePath, "type");

            //1.注册CustomShellType
            foreach (string c in typeList)
            {
                var basicSetting    = new CustomShellType.Basic();
                var mainCodeSetting = new CustomShellType.MainCode();

                //读取basicSetting,mainCodeSetting
                CustomShellTypeXmlHandle.ReadXml(c, customShellTypePath, ref basicSetting, ref mainCodeSetting);
                //生成customShellType
                var customShellType = new CustomShellType(basicSetting, mainCodeSetting);
                //将CustomShellType注册到全局
                CustomShellTypeProvider.AddShellType(customShellType);
            }

            //读取funcTree定义列表(.tree)
            List <string> funcTreeList = XmlHelper.LoadXMlList(customShellTypePath, "tree");

            //2.初始化funcTree方法树
            foreach (string c in funcTreeList)
            {
                var treeInfoList = new List <CustomShellType.TreeInfo>();

                //读取funcCodeList
                CustomShellTypeXmlHandle.ReadXml(c, customShellTypePath, ref treeInfoList);
                //将func注册到CustomShellType
                foreach (CustomShellType.TreeInfo info in treeInfoList)
                {
                    /***
                     * 获取节点的类型
                     * 允许多个类型,以英文逗号分隔,如"aspx,aspx1"
                     */
                    string[] types = info.Type.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                    foreach (string type in types)
                    {
                        CustomShellType shellType = CustomShellTypeProvider.GetShellType(type);
                        FuncTreeNode    node      = shellType.AddFuncTreeNode(info.Path);
                        node.Info = info.Info;
                    }
                }
            }

            //读取funcCode列表(.func)
            List <string> funcList = XmlHelper.LoadXMlList(customShellTypePath, "func");

            //3.注册funcCode到functree
            foreach (string c in funcList)
            {
                var funcCodeList = new List <CustomShellType.FuncCode>();

                //读取funcCodeList
                CustomShellTypeXmlHandle.ReadXml(c, customShellTypePath, ref funcCodeList);
                //将func注册到CustomShellType
                foreach (CustomShellType.FuncCode func in funcCodeList)
                {
                    /***
                     * 获取func的类型
                     * type允许多个类型,以英文逗号分隔,如"aspx,aspx1"
                     */
                    string[] types = func.Type.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                    foreach (string type in types)
                    {
                        CustomShellType shellType = CustomShellTypeProvider.GetShellType(type);
                        //获取映射节点
                        //path为xpath形式,如"/cmder",
                        //允许多个,以英文逗号分隔,如"/cmder,/cmder1"
                        string[] xpaths = func.Path.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                        foreach (string xpath in xpaths)
                        {
                            shellType.AddFuncCode(xpath, func);
                        }
                    }
                }
            }
        }