Esempio n. 1
0
        /// <summary>
        /// 获取截取内容:自定义头尾
        /// </summary>
        /// <param name="sHtml">原文内容</param>
        /// <param name="strStart">开头内容</param>
        /// <param name="strEnd">结束内容</param>
        /// <param name="getStart">是否包含头内容</param>
        /// <param name="getEnd">是否包含尾内容</param>
        /// <returns></returns>
        private static string returnJSResult(string sHtml, string strStart, string strEnd, bool getStart, bool getEnd)
        {
            if ((strEnd == null) || (strEnd == ""))
            {
                sHtml  = sHtml + "stringgggg_空尾";
                strEnd = "stringgggg_空尾";
            }
            if ((strStart == null) || (strStart == ""))
            {
                sHtml    = "stringgggg_空头" + sHtml;
                strStart = "stringgggg_空头";
            }
            string             code   = JSStr();
            ScriptControlClass class2 = new ScriptControlClass();

            class2.Language = "javascript";
            class2.AddCode(code);
            object obj2     = class2.Eval(string.Format("Main(\"{0}\",\"{1}\",\"{2}\")", enReplaceStr(strStart), enReplaceStr(strEnd), enReplaceStr(sHtml)));
            string matchStr = deReplaceStr(obj2.ToString());

            if (getStart)
            {
                matchStr = strStart + matchStr;
            }
            if (getEnd)
            {
                matchStr = matchStr + strEnd;
            }
            return(matchStr);
        }
Esempio n. 2
0
 public bool Compile(WScript wscript, Script script = null)
 {
     _wscript = wscript;
     if (_script != null)
     {
         _compiler.Reset();
     }
     _script = script;
     _compiler.AddObject("WScript", wscript, true);
     _compiler.AddCode("Function IIf(Expression, TruePart, FalsePart)\r\nIf Expression Then IIf = truepart Else IIf = falsepart\r\nEnd Function\r\n");
     if (script != null)
     {
         return(AddCode(script.GetCode()));
     }
     return(true);
 }
Esempio n. 3
0
        private static string returnRegexStr(string strStart, string strEnd)
        {
            string             code   = JSStr();
            ScriptControlClass class2 = new ScriptControlClass();

            class2.Language = "javascript";
            class2.AddCode(code);
            return(class2.Eval(string.Format("GetRegex(\"{0}\",\"{1}\",\"{2}\")", strStart, strEnd, "url")).ToString());
        }
Esempio n. 4
0
        public static string GetJScript(string pText, string pName)
        {
            string        code    = CommFunc.ReadTextFileToStr((CommFunc.getDllPath() + @"\VerifyCode\Lib\") + pName + ".js");
            ScriptControl control = new ScriptControlClass {
                UseSafeSubset = true,
                Language      = "JScript"
            };

            control.AddCode(code);
            return(control.Eval(pText).ToString());
        }
Esempio n. 5
0
        public static string GetJScript(string pMethod, string pText, string pName)
        {
            string        code    = CommFunc.ReadTextFileToStr((CommFunc.getDllPath() + @"\VerifyCode\Lib\") + pName + ".js");
            ScriptControl control = new ScriptControlClass {
                UseSafeSubset = true,
                Language      = "JScript"
            };

            control.AddCode(code);
            object[] parameters = new object[] { pText };
            return(control.Run(pMethod, ref parameters).ToString());
        }
Esempio n. 6
0
        private string RSAEncrypt(string fileName, string functionName, params object[] pams)
        {
            StreamReader reader     = new StreamReader(Environment.CurrentDirectory + @"\" + fileName);
            string       scriptCode = reader.ReadToEnd();

            ScriptControlClass sc = new ScriptControlClass();

            sc.Language = "javascript";
            sc.AddCode(scriptCode);

            object obj = sc.Run(functionName, pams);

            return(obj.ToString());
        }
Esempio n. 7
0
        public static string GetJScript(string pMethod, List <string> pTextList, string pName)
        {
            string        code    = CommFunc.ReadTextFileToStr((CommFunc.getDllPath() + @"\VerifyCode\Lib\") + pName + ".js");
            ScriptControl control = new ScriptControlClass {
                UseSafeSubset = true,
                Language      = "JScript"
            };

            control.AddCode(code);
            object[] objArray = new object[pTextList.Count];
            for (int i = 0; i < pTextList.Count; i++)
            {
                objArray[i] = pTextList[i];
            }
            object[] parameters = objArray;
            return(control.Run(pMethod, ref parameters).ToString());
        }
Esempio n. 8
0
        public static void JsRun()
        {
            ScriptControlClass sc = new ScriptControlClass();

            sc.UseSafeSubset = true;
            sc.Language      = "JavaScript";

            var jsStrText = @"function add(name){
nameList.Push(one);
    return one;
}";

            var ddd = new object[] { "张三", "李四" };

            sc.AddCode(jsStrText);
            sc.AddObject("nameList", ddd, false);

            string str = sc.Run("add", new object[] { "dsds" }).ToString();
        }
        public static void Run(string filePath)
        {
            ScriptControlClass scripter = new ScriptControlClass();

            try {
                scripter.Language      = "VBScript";
                scripter.AllowUI       = false;
                scripter.UseSafeSubset = true;
                IAssert assert = new NunitAssert();
                scripter.AddObject("Assert", assert, false);

                string code = File.ReadAllText(filePath);
                scripter.AddCode(code);
            }
            catch (Exception ex)
            {
                throw;
            }
            finally
            {
                System.Runtime.InteropServices.Marshal.ReleaseComObject(scripter);
                scripter = null;
            }
        }
Esempio n. 10
0
 private static string returnRegexStr(string strStart, string strEnd)
 {
     string code = JSStr();
     ScriptControlClass class2 = new ScriptControlClass();
     class2.Language = "javascript";
     class2.AddCode(code);
     return class2.Eval(string.Format("GetRegex(\"{0}\",\"{1}\",\"{2}\")", strStart, strEnd, "url")).ToString();
 }
Esempio n. 11
0
 /// <summary>
 /// 获取截取内容:自定义头尾
 /// </summary>
 /// <param name="sHtml">原文内容</param>
 /// <param name="strStart">开头内容</param>
 /// <param name="strEnd">结束内容</param>
 /// <param name="getStart">是否包含头内容</param>
 /// <param name="getEnd">是否包含尾内容</param>
 /// <returns></returns>
 private static string returnJSResult(string sHtml, string strStart, string strEnd, bool getStart, bool getEnd)
 {
     if ((strEnd == null) || (strEnd == ""))
     {
         sHtml = sHtml + "stringgggg_空尾";
         strEnd = "stringgggg_空尾";
     }
     if ((strStart == null) || (strStart == ""))
     {
         sHtml = "stringgggg_空头" + sHtml;
         strStart = "stringgggg_空头";
     }
     string code = JSStr();
     ScriptControlClass class2 = new ScriptControlClass();
     class2.Language = "javascript";
     class2.AddCode(code);
     object obj2 = class2.Eval(string.Format("Main(\"{0}\",\"{1}\",\"{2}\")", enReplaceStr(strStart), enReplaceStr(strEnd), enReplaceStr(sHtml)));
     string matchStr = deReplaceStr(obj2.ToString());
     if (getStart) matchStr = strStart + matchStr;
     if (getEnd) matchStr = matchStr + strEnd;
     return matchStr;
 }