Exemplo 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);
        }
Exemplo n.º 2
0
 public Compiler() {
     _compiler = new ScriptControlClass();
     _compiler.Timeout = -1;
     _compiler.Language = "VBScript";
     _compiler.UseSafeSubset = false;
     _compiler.AllowUI = true;
     _compiler.DScriptControlSource_Event_Error += OnError_Event;
 }
Exemplo 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());
        }
Exemplo n.º 4
0
 public Compiler()
 {
     _compiler               = new ScriptControlClass();
     _compiler.Timeout       = -1;
     _compiler.Language      = "VBScript";
     _compiler.UseSafeSubset = false;
     _compiler.AllowUI       = true;
     _compiler.DScriptControlSource_Event_Error += OnError_Event;
 }
Exemplo n.º 5
0
        public Plugin()
        {
            //set your default values here
            m_Name       = "VBScript Plugin (Beta)";
            m_Author     = "Snerf";
            m_Version    = "1.0";
            scriptObject = new ScriptControlClass();

            scriptObject.Language = "VBScript";
        }
Exemplo n.º 6
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());
        }
Exemplo n.º 7
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());
        }
Exemplo n.º 8
0
 private decimal Calculate(string CalculationInfo)
 {
     try
     {
         ScriptControl sc = new ScriptControlClass();
         sc.Language = "JavaScript";
         string str = sc.Eval(CalculationInfo).ToString();
         return(Convert.ToDecimal(str));
     }
     catch (Exception)
     {
         return(0);
     }
 }
Exemplo n.º 9
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());
        }
Exemplo n.º 10
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());
        }
Exemplo n.º 11
0
        /// <summary>
        /// 按数学公式计算数据
        /// </summary>
        /// <param name="x">单价</param>
        /// <param name="y">重量</param>
        /// <param name="z">运距</param>
        /// <param name="f">公式</param>
        /// <returns>计算结果</returns>
        public float compute(string x, string y, string z, string f)
        {
            if (f.IndexOf("x") > -1)
            {
                f = f.Replace("x", x);
            }
            if (f.IndexOf("y") > -1)
            {
                f = f.Replace("y", y);
            }
            if (f.IndexOf("z") > -1)
            {
                f = f.Replace("z", z);
            }
            ScriptControl sc = new ScriptControlClass();

            sc.Language = "Javascript";
            return(float.Parse(sc.Eval(f).ToString()));
        }
Exemplo n.º 12
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();
        }
Exemplo n.º 13
0
        ///需要添加引用COM:Microsoft Script Control 1.0
        /// <summary>
        /// 执行JS代码并返回结果
        /// </summary>
        /// <param name="sScript">JS代码</param>
        /// <param name="sName">JS函数名</param>
        /// <returns>结果</returns>
        private static string ExecJS(string sScript, string sName)
        {
            //string sInitUrl = "http://ipangu.baidu.com/ipangu-hint/hint/hintCustAdd_init.action";
            ScriptControlClass js     = new ScriptControlClass();//使用ScriptControlClass
            object             result = null;

            try
            {
                js.Language = "javascript";
                js.Reset();
                js.Eval(sScript);                //指向js脚本
                object[] obj = new object[] { };
                result = js.Run(sName, ref obj); //传入参数执行
            }
            catch (Exception ex)
            {
                result = ex.Message;
            }
            return(result.ToString());
        }
Exemplo n.º 14
0
    private void cs(object o)
    {
        int xx = 0;

        if (s == null)
        {
            s = new ScriptControlClass();
        }
        /* you should be able to see consistent memory usage after 30 iterations */
        while (xx < 30)
        {
            xx++;
            //Unsure why this is here but doesn't seem to affect the memory usage
            //  like the ScriptControlClass object.
            System.Xml.XmlDocument document = new System.Xml.XmlDocument();
            document.Load("ConsoleApplication6.exe.config");
            s.Language = "JScript";
            object res = s.Eval("1+2");
            Console.WriteLine("thread {0} execution {1}", o, xx);
            System.Threading.Thread.Sleep(5000);
        }
        s = null;
    }
        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;
            }
        }
Exemplo n.º 16
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;
 }
Exemplo n.º 17
0
        public MainScreen()
        {
            /*
             * string[] args = Environment.GetCommandLineArgs();
             * if ( args.Length > 1 )
             * {
             * MessageBox.Show(args[1]);
             * this.Close();
             * return;
             * }
             * */



            this.displayQue = new List <IDisplayItem>();

            m_autoConnecting = false;
            m_pauseMsgs      = false;
            m_clipBoardData  = "";

            Device.Instance.BluetoothConnectEvent    += new BluetoothConnectEventHandler(OnBlackBerryConnectEvent);
            Device.Instance.BluetoothDisconnectEvent += new BluetoothDisconnectEventHandler(OnBlackBerryDisconnectEvent);
            Device.Instance.MsgArrivedEvent          += new MsgArrivedEventHandler(Instance_MsgArrivedEvent);

            m_toolbar = new Toolbar();
            Boolean toolBarVisable = ApplicationSettings.Instance.ToolBar.Visable;

            m_toolbar.showToolbar();
            if (!toolBarVisable)
            {
                m_toolbar.hideToolbar();
            }
            m_scriptControl = null;

            if (ApplicationSettings.Instance.EnableScript)
            {
                try
                {
                    m_scriptControl = new ScriptControlClass();
                    if (m_scriptControl != null)
                    {
                        m_scriptControl.Language = ApplicationSettings.Instance.ScriptLanguage;
                        m_scriptControl.AddObject("AlertWindow", this, true);
                        m_scriptControl.AddObject("BlackBerry", Device.Instance, true);
                    }
                    else
                    {
                        MessageBox.Show("Microsoft Scripting control is not installed.", "Blurts", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                catch (Exception)
                {
                    MessageBox.Show("Microsoft Scripting control is not installed.", "Blurts", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

            // setup file extension support

            /*
             * Registry.ClassesRoot.CreateSubKey(".blurts").SetValue("", "Blurts", Microsoft.Win32.RegistryValueKind.String);
             * Registry.ClassesRoot.CreateSubKey(@"Blurts\shell\open\command").SetValue("", Application.ExecutablePath + " \"%l\" ", Microsoft.Win32.RegistryValueKind.String);
             */



            if (!Directory.Exists(ApplicationSettings.Instance.LocalDataPath + @"\SMS"))
            {
                Directory.CreateDirectory(ApplicationSettings.Instance.LocalDataPath + @"\SMS");
            }

            HotKeysManager.Instance.SetHotKeys();



            InitializeComponent();


            //
            // signal
            //
            this.signal           = new SignalLevelCtrl();
            this.signal.BackColor = System.Drawing.Color.Transparent;
            this.signal.Location  = new System.Drawing.Point(440, 14);
            this.signal.Name      = "signal";
            this.signal.Size      = new System.Drawing.Size(35, 14);
            this.signal.TabIndex  = 9;
            this.signal.TabStop   = false;
            this.Controls.Add(this.signal);

            //
            // battery
            //
            this.battery           = new BatteryLevelCtrl();
            this.battery.BackColor = System.Drawing.Color.Transparent;
            this.battery.Location  = new System.Drawing.Point(436, 34);
            this.battery.Name      = "battery";
            this.battery.Size      = new System.Drawing.Size(43, 14);
            this.battery.TabIndex  = 8;
            this.battery.TabStop   = false;
            this.Controls.Add(this.battery);

            MainScreen_Resize(null, null);


            notifyIcon.Text = Application.ProductName + " - MLH Software";
        }
Exemplo n.º 18
0
        public Plugin()
        {
            //set your default values here
            m_Name = "VBScript Plugin (Beta)";
            m_Author = "Snerf";
            m_Version = "1.0";
            scriptObject = new ScriptControlClass();

            scriptObject.Language = "VBScript";
        }
Exemplo n.º 19
0
 public string Hash(string qq, string ptwebqq)
 {
     const string url = "http://0.web.qstatic.com/webqqpic/pubapps/0/50/eqq.all.js";
     //获取hash 函数代码所在JS文件
     var jsContent = HttpHelper.Get(url);
     var index = jsContent.IndexOf("P=function(", StringComparison.Ordinal);
     var end = jsContent.IndexOf(",b=function(b){c.out", StringComparison.Ordinal) - 1;
     var hashJs = jsContent.Substring(index, end - index + 1);
     var js = new ScriptControlClass { Language = "javascript" };//使用ScriptControlClass  
     js.Reset();
     js.Eval(hashJs);
     return js.Run("P", new object[] { qq, ptwebqq }).ToString();
 }
Exemplo n.º 20
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();
 }