Exemplo n.º 1
0
        public void OnDocumentComplete(object pDisp, ref object URL)
        {
            HTMLDocument document     = (HTMLDocument)webBrowser.Document;
            dynamic      window       = document.parentWindow;
            IExpando     ScriptObject = (IExpando)window;
            PropertyInfo btnEvent     = ScriptObject.GetProperty("toQt", BindingFlags.Default);

            if (btnEvent == null)
            {
                btnEvent = ScriptObject.AddProperty("toQt");
            }
            btnEvent.SetValue(ScriptObject, this, null);
            IHTMLElement head = (IHTMLElement)((IHTMLElementCollection)
                                               document.all.tags("head")).item(null, 0);
            IHTMLScriptElement scriptObject = (IHTMLScriptElement)document.createElement("script");

            scriptObject.type = @"text/javascript";
            //scriptObject.text = "alert('aa')";
            //scriptObject.text = "var myEles = document.getElementById('su'); if(myEles != undefined && myEles != null) {myEles.valuvalu";
            //scriptObject.text = "var data={'aa':document.getElementById('names')};$.ajax({type: 'POST',url: 'http://127.0.0.1:8000/opendata/test/',contentType: 'application/json;charset=utf-wind8',dataType: 'json',data: JSON.stringify(data),success: function (data) {  console.log(data);})";
            //scriptObject.text = "  $('#btnQuery').click(function(){var trs=document.querySelectorAll('tr.DataGridItem');var keys=['流水号','处方号','姓名','病历号','看诊医生','看诊时间','是否已发药','发药时间','发药人员','处方(含耗材)金额','退药'];var data=[];for(var i=0;i<trs.length;i++){tds=trs[i].querySelectorAll('td');var item={};item={'流水号':tds[0].innerText,'处方号':tds[1].innerText,'姓名':tds[2].innerText,'病历号':tds[3].innerText,'看诊医生':tds[4].innerText,'看诊时间':tds[5].innerText,'是否已发药':tds[6].innerText,'发药时间':tds[7].innerText,'发药人员':tds[8].innerText,'处方(含耗材)金额':tds[9].innerText};data.push(item)};$.ajax({type:'POST',url:'http://121.204.198.52:8809/v13/opendata/test/',contentType:'application/json;charset=utf-8',dataType:'json',data:JSON.stringify(data),success:function(data){}})});";
            //scriptObject.text = "  $('#btnQuery').click(function(){var trs=document.querySelectorAll('tr.DataGridItem');var keys=['流水号','处方号','姓名','病历号','看诊医生','看诊时间','是否已发药','发药时间','发药人员','处方(含耗材)金额','退药'];var data=[];for(var i=0;i<trs.length;i++){tds=trs[i].querySelectorAll('td');var item={};item={'流水号':tds[0].innerText,'处方号':tds[1].innerText,'姓名':tds[2].innerText,'病历号':tds[3].innerText,'看诊医生':tds[4].innerText,'看诊时间':tds[5].innerText,'是否已发药':tds[6].innerText,'发药时间':tds[7].innerText,'发药人员':tds[8].innerText,'处方(含耗材)金额':tds[9].innerText};data.push(item)};$.ajax({type:'POST',url:'http://121.204.198.52:8809/v13/opendata/test/',contentType:'application/json;charset=utf-8',dataType:'json',data:JSON.stringify(data),success:function(data){}})});";
            //scriptObject.text = "  $('#btnQuery').click(var data={'tttt':'3dy.me'};$.ajax({type:'POST',url:'http://121.204.198.52:8809/v13/opendata/test/',contentType:'application/json;charset=utf-8',dataType:'json',data:JSON.stringify(data),success:function(data){}})});";
            //scriptObject.text = "  $('#btnQuery').click(var data={'tttt':'3dy.me'};$.ajax({type:'POST',url:'http://121.204.198.52:8809/v13/opendata/test/',contentType:'application/json;charset=utf-8',dataType:'json',data:JSON.stringify(data),success:function(data){}})});";
            //scriptObject.text = "  $(window.parent.frames['ifWorkFrame'].document).find('input#btnQuery').click(function(){alert('aa')})";
            //document.getElementById(id).contentDocument
            //scriptObject.text = "  $('#input').click(function(){alert('aa')})";
            //通知栏所在区域,打开区域
            //window.parent.document.getElementsByTagName('frameset')[2].setAttribute('rows', '105,*')
            //病人取药的tables
            //window.frames[2].frames[0].document.getElementById("gvInfo").innerText
            //查询按钮
            //window.frames[2].frames[0].document.getElementById("btnQuery").value

            //发药按钮(详情页内)
            //btnFayao window.frames[2].frames[0].document.getElementById("btnFayao")
            //  病人信息,名字,性别,年龄
            //病人信息(详情页内)
            //var tab = window.frames[2].frames[0].document.getElementById("tbPatient").rows[0].cells[5].innerHTML.split(" ")[0];


            //table.row[1].cells[10].onmouseover = function(){ alert("ss")}
            //}
            //测试调用自定义的DLL window.toQt.ie_add(99,100)+''
            // scriptObject.text = "var myEles = document.getElementById('su'); var kw=document.getElementById('kw').value ; myEles.onclick=aaa(kw);function aaa(kw){alert(window.toQt.ie_add(99,100));}";
            //scriptObject.text = "var sub = window.frames[1].document.getElementById('td_left');";
            //scriptObject.text += "var card=document.createElement('div');card.style.height='200px';card.style.width='200px';card.style.backgroundColor='#007fbb';card.style.setAttribute('position','absolute');card.style.left='20px';card.style.top='30px';sub.appendChild(card);var title=document.createElement('div');title.style.setAttribute('position','absolute');title.style.left='5%';title.style.width='55%';title.style.height='50px';title.style.paddingLeft='35%';title.style.fontSize='36px';title.style.marginTop='30px';title.style.color='#fff';title.style.borderBottom='1px solid #fff';title.innerText='18';card.appendChild(title);var man=document.createElement('div');man.style.setAttribute('position','absolute');man.style.top='100px';man.style.left='5%';man.style.width='55%';man.style.height='50px';man.style.paddingLeft='18%';man.style.fontSize='36px';man.style.color='#fff';man.innerText='马若莉';card.appendChild(man);";
            //scriptObject.text += "var sub=document.createElement('div');sub.style.height='105px';sub.style.width='1000px';sub.style.backgroundColor='#ededed';document.getElementById('sub').appendChild(sub);var card=document.createElement('div');card.style.height='100px';card.style.width='120px';card.style.backgroundColor='#007fbb';card.style.setAttribute('position','absolute');card.style.left='20px';card.style.top='5px';sub.appendChild(card);var title=document.createElement('div');title.style.setAttribute('position','absolute');title.style.left='5%';title.style.width='55%';title.style.height='30px';title.style.paddingLeft='35%';title.style.fontSize='24px';title.style.color='#fff';title.style.borderBottom='1px solid #fff';title.innerText='18';card.appendChild(title);var man=document.createElement('div');man.style.setAttribute('position','absolute');man.style.top='50px';man.style.left='5%';man.style.width='55%';man.style.height='30px';man.style.paddingLeft='18%';man.style.fontSize='22px';man.style.color='#fff';man.innerText='马若莉';card.appendChild(man);";
            //window.frames[2].frames[0].document.getElementById('btnFayao')
            //scriptObject.text = "window.frames[2].frames[0].document.getElementById('btnQuery').onmouseover=function(){alert('hasssshhaa ')}";
            //document.getElementById('main').onmouseover=function(){alert('hasssshhaa ')}
            //scriptObject.text = "var sub = window.frames[1].document.getElementById('td_left');";
            //scriptObject.text += "var card=document.createElement('div');card.style.height='200px';card.style.width='200px';card.style.backgroundColor='#007fbb';card.style.setAttribute('position','absolute');card.style.left='20px';card.style.top='30px';sub.appendChild(card);var title=document.createElement('div');title.style.setAttribute('position','absolute');title.style.left='5%';title.style.width='55%';title.style.height='50px';title.style.paddingLeft='35%';title.style.fontSize='36px';title.style.marginTop='30px';title.style.color='#fff';title.style.borderBottom='1px solid #fff';title.innerText='18';card.appendChild(title);var man=document.createElement('div');man.style.setAttribute('position','absolute');man.style.top='100px';man.style.left='5%';man.style.width='55%';man.style.height='50px';man.style.paddingLeft='18%';man.style.fontSize='36px';man.style.color='#fff';man.innerText='马若莉';card.appendChild(man);";
            //scriptObject.text += "var sub=document.createElement('div');sub.style.height='105px';sub.style.width='1000px';sub.style.backgroundColor='#ededed';document.getElementById('sub').appendChild(sub);var card=document.createElement('div');card.style.height='100px';card.style.width='120px';card.style.backgroundColor='#007fbb';card.style.setAttribute('position','absolute');card.style.left='20px';card.style.top='5px';sub.appendChild(card);var title=document.createElement('div');title.style.setAttribute('position','absolute');title.style.left='5%';title.style.width='55%';title.style.height='30px';title.style.paddingLeft='35%';title.style.fontSize='24px';title.style.color='#fff';title.style.borderBottom='1px solid #fff';title.innerText='18';card.appendChild(title);var man=document.createElement('div');man.style.setAttribute('position','absolute');man.style.top='50px';man.style.left='5%';man.style.width='55%';man.style.height='30px';man.style.paddingLeft='18%';man.style.fontSize='22px';man.style.color='#fff';man.innerText='马若莉';card.appendChild(man);";
            //scriptObject.text="window.frames[2].frames[0].document.getElementById('btnQuery').onmouseover = function(){ var info = getMan(); window.toQt.sendPatientInfo(info)}; function getMan() { var table = window.frames[2].frames[0].document.getElementById('gvInfo'); var t = ''; for (var i = 1; i < table.rows.length; i++) { t += table.rows[i].cells[0].innerText + ';' + table.rows[i].cells[2].innerText + '*'} return t};";
            //scriptObject.text = "var old_info = ''; ftimer = setInterval(function () { var gvInfo = window.frames[2].frames[0].document.getElementById('gvInfo'); if (gvInfo != undefined && gvInfo!= null) { var info = getMan(); if (info == '') { } else { if (old_info == info) { } else { old_info = info; alert(info); } } } else { } }, 1000);";
            scriptObject.text = "var old_info = ''; function getMan() { var table = window.frames[2].frames[0].document.getElementById('gvInfo'); var t = ''; for (var i = 1; i < table.rows.length; i++) { t += table.rows[i].cells[0].innerText + ';' + table.rows[i].cells[2].innerText + '*' } return t }ftimer = setInterval(function() { var gvInfo = window.frames[2].frames[0].document.getElementById('gvInfo'); if (gvInfo != undefined && gvInfo != null) { var info = getMan(); if (info == '') { } else { if (old_info == info) { } else { old_info = info; alert(info);window.toQt.sendPatientInfo(info); } } } else { } }, 1000); ";
            //scriptObject.text = "alert('bcho2.exe')";
            ((HTMLHeadElement)head).appendChild((IHTMLDOMNode)scriptObject);
        }
Exemplo n.º 2
0
        private static PropertyInfo GetOrCreateProperty(IExpando expando, string name)
        {
            PropertyInfo property = expando.GetProperty(name, BindingFlags.Instance);
            if (property == null)
                property = expando.AddProperty(name);

            return property;
        }
Exemplo n.º 3
0
        private static PropertyInfo GetOrCreateProperty(IExpando expando, string name)
        {
            PropertyInfo property = expando.GetProperty(name, BindingFlags.Instance);

            if (property == null)
            {
                property = expando.AddProperty(name);
            }

            return(property);
        }
Exemplo n.º 4
0
        public override void SetProperty(string name, object[] args)
        {
            VerifyNotDisposed();

            engine.ScriptInvoke(() =>
            {
                var marshaledArgs = engine.MarshalToScript(args);
                try
                {
                    try
                    {
                        target.InvokeMember(name, BindingFlags.SetProperty, null, target, marshaledArgs, null, CultureInfo.InvariantCulture, null);
                    }
                    catch (COMException primaryException)
                    {
                        // VBScript objects can be finicky about property-put dispatch flags

                        if (primaryException.ErrorCode == RawCOMHelpers.HResult.DISP_E_MEMBERNOTFOUND)
                        {
                            try
                            {
                                target.InvokeMember(name, BindingFlags.SetProperty | BindingFlags.PutDispProperty, null, target, marshaledArgs, null, CultureInfo.InvariantCulture, null);
                            }
                            catch (COMException secondaryException)
                            {
                                if (secondaryException.ErrorCode == RawCOMHelpers.HResult.DISP_E_MEMBERNOTFOUND)
                                {
                                    target.InvokeMember(name, BindingFlags.SetProperty | BindingFlags.PutRefDispProperty, null, target, marshaledArgs, null, CultureInfo.InvariantCulture, null);
                                }
                                else
                                {
                                    throw;
                                }
                            }
                        }
                        else
                        {
                            throw;
                        }
                    }
                }
                catch (MissingMemberException)
                {
                    target.AddProperty(name);
                    target.InvokeMember(name, BindingFlags.SetProperty, null, target, marshaledArgs, null, CultureInfo.InvariantCulture, null);
                }
            });
        }
Exemplo n.º 5
0
        public void OnDocumentComplete(object pDisp, ref object URL)
        {
            document = webBrowser.Document as HTMLDocument;
            window   = document.parentWindow as IHTMLWindow2;

            // In the next few lines, we're going to add a callable
            // object to the "window" namespace exposed to the
            // JavaScript in the browser.
            winExpando = window as IExpando;
            IScriptableObject so = new ScriptableObject(webBrowser);

            // Adding our custom namespace to JavaScript land.
            PropertyInfo myProp = winExpando.AddProperty("ice");

            myProp.SetValue(winExpando, so, null);
        }
Exemplo n.º 6
0
        public override void SetProperty(string name, object value)
        {
            VerifyNotDisposed();

            engine.ScriptInvoke(() =>
            {
                var marshaledArgs = new[] { engine.MarshalToScript(value) };
                try
                {
                    target.InvokeMember(name, BindingFlags.SetProperty, null, target, marshaledArgs, null, CultureInfo.InvariantCulture, null);
                }
                catch (MissingMemberException)
                {
                    target.AddProperty(name);
                    target.InvokeMember(name, BindingFlags.SetProperty, null, target, marshaledArgs, null, CultureInfo.InvariantCulture, null);
                }
            });
        }
Exemplo n.º 7
0
        PropertyInfo GetPropertyInfo(string name, bool create)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }

            var result = jsObject.GetProperty(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

            if (result == null && create)
            {
                result = jsObject.AddProperty(name);

                Activated(this);
            }

            return(result);
        }
    private static object Invoke(IExpando instance, string functionName, InvokeFlags flags, object[] args)
    {
        try
        {
            args = args.Select(arg => DynamicNode.Unwrap(arg)).ToArray();
            switch (flags)
            {
            case InvokeFlags.DISPATCH_METHOD:
                var method = instance.GetMethod(functionName, DefaultFlags);
                return(method.Invoke(instance, args));

            case InvokeFlags.DISPATCH_PROPERTYGET:
                var getProp = instance.GetProperty(functionName, DefaultFlags);
                return(getProp.GetValue(instance, null));

            case InvokeFlags.DISPATCH_PROPERTYPUT:
            case InvokeFlags.DISPATCH_PROPERTYPUTREF:
                var setProp = instance.GetProperty(functionName, DefaultFlags);
                if (setProp == null)
                {
                    setProp = instance.AddProperty(functionName);
                }
                setProp.SetValue(instance, args[0], null);
                return(null);

            default:
                throw new NotSupportedException();
            }
        }
        catch (COMException comex)
        {
            switch ((uint)comex.ErrorCode)
            {
            // Unexpected script error. This will be handled by the IProcess.UnhandledException event
            case 0x80020101:
                return(null);

            default:
                throw;
            }
        }
    }
Exemplo n.º 9
0
        /// <summary>
        /// Sets a value to variable
        /// </summary>
        /// <param name="variableName">Name of variable</param>
        /// <param name="value">Value of variable</param>
        private void InnerSetVariableValue(string variableName, object value)
        {
            object[] args = { value };

            try
            {
                _dispatch.InvokeMember(variableName, BindingFlags.SetProperty, null, _dispatch,
                                       args, null, CultureInfo.InvariantCulture, null);
            }
            catch (MissingMemberException)
            {
                _dispatch.AddProperty(variableName);
                _dispatch.InvokeMember(variableName, BindingFlags.SetProperty, null, _dispatch,
                                       args, null, CultureInfo.InvariantCulture, null);
            }
            catch
            {
                ThrowError();
                throw;
            }
        }
        /// <summary>
        /// Sets a value to global object property
        /// </summary>
        /// <param name="propertyName">Name of property</param>
        /// <param name="value">Value of property</param>
        public void SetProperty(string propertyName, object value)
        {
            var marshaledArgs = new[] { value };

            try
            {
                _dispatch.InvokeMember(propertyName, BindingFlags.SetProperty, null, _dispatch,
                                       marshaledArgs, null, CultureInfo.InvariantCulture, null);
            }
            catch (MissingMemberException)
            {
                _dispatch.AddProperty(propertyName);
                _dispatch.InvokeMember(propertyName, BindingFlags.SetProperty, null, _dispatch,
                                       marshaledArgs, null, CultureInfo.InvariantCulture, null);
            }
            catch
            {
                ThrowError();
                throw;
            }
        }
Exemplo n.º 11
0
        public void OnDocumentComplete(object pDisp, ref object URL)
        {
            HTMLDocument document = (HTMLDocument)webBrowser.Document;

            dynamic      window       = document.parentWindow;
            IExpando     ScriptObject = (IExpando)window;
            PropertyInfo btnEvent     = ScriptObject.GetProperty("toQt", BindingFlags.Default);

            if (btnEvent == null)
            {
                btnEvent = ScriptObject.AddProperty("toQt");
            }
            btnEvent.SetValue(ScriptObject, this, null);

            IHTMLElement head = (IHTMLElement)((IHTMLElementCollection)
                                               document.all.tags("head")).item(null, 0);

            IHTMLScriptElement scriptObject =
                (IHTMLScriptElement)document.createElement("script");

            scriptObject.type = @"text/javascript";
            scriptObject.text = "var myEles = document.getElementById('su'); if(myEles != undefined && myEles != null) {myEles.onmouseup=aaa;function aaa(){window.toQt.sendMsgToQt('hahaha')}}";
            ((HTMLHeadElement)head).appendChild((IHTMLDOMNode)scriptObject);
        }
Exemplo n.º 12
0
        private static PropertyInfo CreateOrGetProperty(IExpando expando, string name)
        {
            var currentProperty = expando.GetProperty(name, BindingFlags.GetProperty);

            return(currentProperty ?? expando.AddProperty(name));
        }
Exemplo n.º 13
0
        public void OnDocumentComplete(object pDisp, ref object URL)
        {
            HTMLDocument document     = (HTMLDocument)webBrowser.Document;
            dynamic      window       = document.parentWindow;
            IExpando     ScriptObject = (IExpando)window;
            PropertyInfo btnEvent     = ScriptObject.GetProperty("toQt", BindingFlags.Default);

            if (btnEvent == null)
            {
                btnEvent = ScriptObject.AddProperty("toQt");
            }
            btnEvent.SetValue(ScriptObject, this, null);
            IHTMLElement head = (IHTMLElement)((IHTMLElementCollection)
                                               document.all.tags("head")).item(null, 0);
            IHTMLScriptElement scriptObject = (IHTMLScriptElement)document.createElement("script");

            scriptObject.type = @"text/javascript";
            //scriptObject.text = "alert('aa')";
            //scriptObject.text = "var myEles = document.getElementById('su'); if(myEles != undefined && myEles != null) {myEles.valuvalu";
            //scriptObject.text = "var data={'aa':document.getElementById('names')};$.ajax({type: 'POST',url: 'http://127.0.0.1:8000/opendata/test/',contentType: 'application/json;charset=utf-wind8',dataType: 'json',data: JSON.stringify(data),success: function (data) {  //console.log(data);})";
            //scriptObject.text = "  $('#btnQuery').click(function(){var trs=document.querySelectorAll('tr.DataGridItem');var keys=['流水号','处方号','姓名','病历号','看诊医生','看诊时间','是否已发药','发药时间','发药人员','处方(含耗材)金额','退药'];var data=[];for(var i=0;i<trs.length;i++){tds=trs[i].querySelectorAll('td');var item={};item={'流水号':tds[0].innerText,'处方号':tds[1].innerText,'姓名':tds[2].innerText,'病历号':tds[3].innerText,'看诊医生':tds[4].innerText,'看诊时间':tds[5].innerText,'是否已发药':tds[6].innerText,'发药时间':tds[7].innerText,'发药人员':tds[8].innerText,'处方(含耗材)金额':tds[9].innerText};data.push(item)};$.ajax({type:'POST',url:'http://121.204.198.52:8809/v13/opendata/test/',contentType:'application/json;charset=utf-8',dataType:'json',data:JSON.stringify(data),success:function(data){}})});";
            //scriptObject.text = "  $('#btnQuery').click(function(){var trs=document.querySelectorAll('tr.DataGridItem');var keys=['流水号','处方号','姓名','病历号','看诊医生','看诊时间','是否已发药','发药时间','发药人员','处方(含耗材)金额','退药'];var data=[];for(var i=0;i<trs.length;i++){tds=trs[i].querySelectorAll('td');var item={};item={'流水号':tds[0].innerText,'处方号':tds[1].innerText,'姓名':tds[2].innerText,'病历号':tds[3].innerText,'看诊医生':tds[4].innerText,'看诊时间':tds[5].innerText,'是否已发药':tds[6].innerText,'发药时间':tds[7].innerText,'发药人员':tds[8].innerText,'处方(含耗材)金额':tds[9].innerText};data.push(item)};$.ajax({type:'POST',url:'http://121.204.198.52:8809/v13/opendata/test/',contentType:'application/json;charset=utf-8',dataType:'json',data:JSON.stringify(data),success:function(data){}})});";
            //scriptObject.text = "  $('#btnQuery').click(var data={'tttt':'3dy.me'};$.ajax({type:'POST',url:'http://121.204.198.52:8809/v13/opendata/test/',contentType:'application/json;charset=utf-8',dataType:'json',data:JSON.stringify(data),success:function(data){}})});";
            //scriptObject.text = "  $('#btnQuery').click(var data={'tttt':'3dy.me'};$.ajax({type:'POST',url:'http://121.204.198.52:8809/v13/opendata/test/',contentType:'application/json;charset=utf-8',dataType:'json',data:JSON.stringify(data),success:function(data){}})});";
            //scriptObject.text = "  $(window.parent.frames['ifWorkFrame'].document).find('input#btnQuery').click(function(){alert('aa')})";
            //document.getElementById(id).contentDocument
            //scriptObject.text = "  $('#input').click(function(){alert('aa')})";
            //通知栏所在区域,打开区域
            //window.parent.document.getElementsByTagName('frameset')[2].setAttribute('rows', '105,*')
            //病人取药的tables
            //window.frames[2].frames[0].document.getElementById("gvInfo").innerText
            //查询按钮
            //window.frames[2].frames[0].document.getElementById("btnQuery").value

            //发药按钮(详情页内)
            //btnFayao window.frames[2].frames[0].document.getElementById("btnFayao")
            //  病人信息,名字,性别,年龄
            //病人信息(详情页内)
            //var tab = window.frames[2].frames[0].document.getElementById("tbPatient").rows[0].cells[5].innerHTML.split(" ")[0];


            //table.row[1].cells[10].onmouseover = function(){ alert("ss")}
            //}
            //测试调用自定义的DLL window.toQt.ie_add(99,100)+''
            // scriptObject.text = "var myEles = document.getElementById('su'); var kw=document.getElementById('kw').value ; myEles.onclick=aaa(kw);function aaa(kw){alert(window.toQt.ie_add(99,100));}";
            //scriptObject.text = "var sub = window.frames[1].document.getElementById('td_left');";
            //scriptObject.text += "var card=document.createElement('div');card.style.height='200px';card.style.width='200px';card.style.backgroundColor='#007fbb';card.style.setAttribute('position','absolute');card.style.left='20px';card.style.top='30px';sub.appendChild(card);var title=document.createElement('div');title.style.setAttribute('position','absolute');title.style.left='5%';title.style.width='55%';title.style.height='50px';title.style.paddingLeft='35%';title.style.fontSize='36px';title.style.marginTop='30px';title.style.color='#fff';title.style.borderBottom='1px solid #fff';title.innerText='18';card.appendChild(title);var man=document.createElement('div');man.style.setAttribute('position','absolute');man.style.top='100px';man.style.left='5%';man.style.width='55%';man.style.height='50px';man.style.paddingLeft='18%';man.style.fontSize='36px';man.style.color='#fff';man.innerText='马若莉';card.appendChild(man);";
            //scriptObject.text += "var sub=document.createElement('div');sub.style.height='105px';sub.style.width='1000px';sub.style.backgroundColor='#ededed';document.getElementById('sub').appendChild(sub);var card=document.createElement('div');card.style.height='100px';card.style.width='120px';card.style.backgroundColor='#007fbb';card.style.setAttribute('position','absolute');card.style.left='20px';card.style.top='5px';sub.appendChild(card);var title=document.createElement('div');title.style.setAttribute('position','absolute');title.style.left='5%';title.style.width='55%';title.style.height='30px';title.style.paddingLeft='35%';title.style.fontSize='24px';title.style.color='#fff';title.style.borderBottom='1px solid #fff';title.innerText='18';card.appendChild(title);var man=document.createElement('div');man.style.setAttribute('position','absolute');man.style.top='50px';man.style.left='5%';man.style.width='55%';man.style.height='30px';man.style.paddingLeft='18%';man.style.fontSize='22px';man.style.color='#fff';man.innerText='马若莉';card.appendChild(man);";
            //window.frames[2].frames[0].document.getElementById('btnFayao')
            //scriptObject.text = "window.frames[2].frames[0].document.getElementById('btnQuery').onmouseover=function(){alert('hasssshhaa ')}";
            //document.getElementById('main').onmouseover=function(){alert('hasssshhaa ')}
            //scriptObject.text = "var sub = window.frames[1].document.getElementById('td_left');";
            //scriptObject.text += "var card=document.createElement('div');card.style.height='200px';card.style.width='200px';card.style.backgroundColor='#007fbb';card.style.setAttribute('position','absolute');card.style.left='20px';card.style.top='30px';sub.appendChild(card);var title=document.createElement('div');title.style.setAttribute('position','absolute');title.style.left='5%';title.style.width='55%';title.style.height='50px';title.style.paddingLeft='35%';title.style.fontSize='36px';title.style.marginTop='30px';title.style.color='#fff';title.style.borderBottom='1px solid #fff';title.innerText='18';card.appendChild(title);var man=document.createElement('div');man.style.setAttribute('position','absolute');man.style.top='100px';man.style.left='5%';man.style.width='55%';man.style.height='50px';man.style.paddingLeft='18%';man.style.fontSize='36px';man.style.color='#fff';man.innerText='马若莉';card.appendChild(man);";
            //scriptObject.text += "var sub=document.createElement('div');sub.style.height='105px';sub.style.width='1000px';sub.style.backgroundColor='#ededed';document.getElementById('sub').appendChild(sub);var card=document.createElement('div');card.style.height='100px';card.style.width='120px';card.style.backgroundColor='#007fbb';card.style.setAttribute('position','absolute');card.style.left='20px';card.style.top='5px';sub.appendChild(card);var title=document.createElement('div');title.style.setAttribute('position','absolute');title.style.left='5%';title.style.width='55%';title.style.height='30px';title.style.paddingLeft='35%';title.style.fontSize='24px';title.style.color='#fff';title.style.borderBottom='1px solid #fff';title.innerText='18';card.appendChild(title);var man=document.createElement('div');man.style.setAttribute('position','absolute');man.style.top='50px';man.style.left='5%';man.style.width='55%';man.style.height='30px';man.style.paddingLeft='18%';man.style.fontSize='22px';man.style.color='#fff';man.innerText='马若莉';card.appendChild(man);";
            //scriptObject.text="window.frames[2].frames[0].document.getElementById('btnQuery').onmouseover = function(){ var info = getMan(); window.toQt.sendPatientInfo(info)}; function getMan() { var table = window.frames[2].frames[0].document.getElementById('gvInfo'); var t = ''; for (var i = 1; i < table.rows.length; i++) { t += table.rows[i].cells[0].innerText + ';' + table.rows[i].cells[2].innerText + '*'} return t};";
            //scriptObject.text = "var old_info = ''; ftimer = setInterval(function () { var gvInfo = window.frames[2].frames[0].document.getElementById('gvInfo'); if (gvInfo != undefined && gvInfo!= null) { var info = getMan(); if (info == '') { } else { if (old_info == info) { } else { old_info = info; alert(info); } } } else { } }, 1000);";
            //正确版本
            //scriptObject.text = "var old_info = ''; function getMan() { var table = window.frames[2].frames[0].document.getElementById('gvInfo'); var t = ''; for (var i = 1; i < table.rows.length; i++) { t += table.rows[i].cells[0].innerText + ';' + table.rows[i].cells[2].innerText + '*' } return t }ftimer = setInterval(function() { var gvInfo = window.frames[2].frames[0].document.getElementById('gvInfo'); if (gvInfo != undefined && gvInfo != null) { var info = getMan(); if (info == '') { } else { if (old_info == info) { } else { old_info = info; window.toQt.sendPatientInfo(info);alert('bug--->'+info); } } } else { } }, 1000); ";
            //scriptObject.text = "function createXMLHttpRequest(){if(window.XMLHttpRequest){xmlHttp=new XMLHttpRequest()}else{if(window.ActiveXObject){xmlHttp=new ActiveXObject('Microsoft.XMLHTTP')}}return xmlHttp;} ";
            //scriptObject.text  = scriptObject.text+ "var old_info = ''; function getMan() { var table = window.frames[2].frames[0].document.getElementById('gvInfo'); var t = ''; for (var i = 1; i < table.rows.length; i++) { t += table.rows[i].cells[0].innerText + ';' + table.rows[i].cells[2].innerText + '*' } return t }ftimer = setInterval(function() { var gvInfo = window.frames[2].frames[0].document.getElementById('gvInfo'); if (gvInfo != undefined && gvInfo != null) { var info = getMan(); if (info == '') { } else { if (old_info == info) { } else { old_info = info; alert('22bug'+info); var xmlHttp=createXMLHttpRequest();xmlHttp.onreadystatechange=function(){};xmlHttp.open('POST','http://121.204.198.52:8809/v13/opendata/test/',true);xmlHttp.setRequestHeader('Content-Type','application/json');xmlHttp.send(JSON.stringify({'A':333}));             } } } else { } }, 1000); ";
            //scriptObject.text="function ajax(options) { options = options ||{ }; optoins.type = (options.type || 'GET').toUpperCase(); options.dataType = options.dataType || 'json';params= formatParams(options.data); var xhr; if (window.XMLHttpRequest) { xhr = new XMLHttpRequest()} else { xhr = ActiveXObject('Microsoft.XMLHTTP')} xhr.onreadystatechange = function(){ if (xhr.readyState == 4) { var status = xhr.status; if (status >= 200 && status < 300) { options.success && options.success(xhr.responseText, xhr.responseXML)} else { options.error && options.error(status)} } } if (options.type == 'GET') { xhr.open('GET', options.url + '?' +params, true); xhr.send(null)} else if (options.type == 'POST') { xhr.open('POST', options.url, true); xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xhr.send(params)} }  function formatParams(data) { var arr =[];for(var name in data) { arr.push(encodeURIComponent(name) + '=' + encodeURIComponent(data[name]))} arr.push(('v='Math.random()).replace('.', '')); return arr.join('&')} ajax({ url: 'http://121.204.198.52:8809/v13/opendata/test/',type: 'POST',dataType: 'json',data: { name: '马各马它',age: 18},success: function(response, xml){ },error: function(status){ } });";
            //string aa = "hello";
            scriptObject.text = @" var old_name = '';

function get_name() {
    var patient = window.mrightFrame.workFrame.document.getElementById('tbPatient');
    return patient.rows[0].cells[5].innerText.split(' ')[0];
}

function check() {
    var name = get_name();
    if (name != old_name) {
        old_name = name;
        window.toQt.sendPatientInfo(name)
        //alert(name);
    }
}

var times = setInterval(function () {
    var first = window.mrightFrame;
    if (first != undefined && first != null) {
        try {
            var second = first.workFrame;
            if (second != undefined && second != null) {
                try {
                    var d = window.mrightFrame.workFrame.document;

                    if (d != undefined && d != null) {
                        var disabled = window.mrightFrame.workFrame.document.getElementById('btnFayao').disabled;
                        if (disabled == false)
                            check();
                      
                    }
                } catch (err) {
                   
                }
            }
        } catch (err) {
           
        }
    }
}, 2000);




var old_lblname = '';

function get_lblname() {

    var patient = window.mrightFrame.workFrame.document.getElementById('lblname');
    return patient.innerText;
}

function check2() {
    var name = get_lblname();
    if (name != old_lblname) {
        old_lblname = name;
        window.toQt.sendPatientInfo(name)
        //alert(name);
    }
}
var times2 = setInterval(function () {
    var first = window.mrightFrame;
    if (first != undefined && first != null) {
        try {
            var second = first.workFrame;
            if (second != undefined && second != null) {
                try {
                    var patient = window.mrightFrame.workFrame.document;
                    if (patient != undefined && patient != null) {
                        check2();
                    } 
                } catch (err) {
                   
                }
            }
        } catch (err) {
            
        }
    }
}, 2000);
            ";
            ((HTMLHeadElement)head).appendChild((IHTMLDOMNode)scriptObject);
        }
Exemplo n.º 14
0
        public void OnDocumentComplete(object pDisp, ref object URL)
        {
            /*
             *
             * HTMLDocument document = (HTMLDocument)webBrowser.Document;
             *
             * dynamic window = document.parentWindow;
             * IExpando ScriptObject = (IExpando)window;
             * PropertyInfo btnEvent = ScriptObject.GetProperty("toQt", BindingFlags.Default);
             * if (btnEvent == null) btnEvent = ScriptObject.AddProperty("toQt");
             * btnEvent.SetValue(ScriptObject, this, null);
             *
             * IHTMLElement head = (IHTMLElement)((IHTMLElementCollection)
             *                      document.all.tags("head")).item(null, 0);
             *
             * IHTMLScriptElement scriptObject =
             *  (IHTMLScriptElement)document.createElement("script");
             * scriptObject.type = @"text/javascript";
             * //scriptObject.text = "var myEles = document.getElementById('su'); var kw=document.getElementById('kw').value; if(myEles != undefined && myEles != null) {myEles.onmouseup=aaa(kw);function aaa(kw){window.toQt.sendMsgToQt('www.3dy.com ; '+kw)}}";
             * scriptObject.text = "var myEles = document.getElementById('su'); if(myEles != undefined && myEles != null) {myEles.onmouseup=aaa;function aaa(){window.toQt.sendMsgToQt('hahaha')}}";
             *
             * ((HTMLHeadElement)head).appendChild((IHTMLDOMNode)scriptObject);
             */
            HTMLDocument document = (HTMLDocument)webBrowser.Document;

            dynamic      window       = document.parentWindow;
            IExpando     ScriptObject = (IExpando)window;
            PropertyInfo btnEvent     = ScriptObject.GetProperty("toQt", BindingFlags.Default);

            if (btnEvent == null)
            {
                btnEvent = ScriptObject.AddProperty("toQt");
            }
            btnEvent.SetValue(ScriptObject, this, null);

            IHTMLElement head = (IHTMLElement)((IHTMLElementCollection)
                                               document.all.tags("head")).item(null, 0);

            IHTMLScriptElement scriptObject =
                (IHTMLScriptElement)document.createElement("script");

            scriptObject.type = @"text/javascript";
            //scriptObject.text = "var myEles = document.getElementById('su'); var kw=document.getElementById('kw').value; if(myEles != undefined && myEles != null) {myEles.onmouseup=aaa(kw);function aaa(kw){window.toQt.sendMsgToQt('www.3dy.com ; '+kw)}}";
            //scriptObject.text = "var myEles = document.getElementById('su'); if(myEles != undefined && myEles != null) {myEles.valuvalu";
            //scriptObject.text = "var data={'aa':document.getElementById('names')};$.ajax({type: 'POST',url: 'http://127.0.0.1:8000/opendata/test/',contentType: 'application/json;charset=utf-8',dataType: 'json',data: JSON.stringify(data),success: function (data) {  console.log(data);})";
            //scriptObject.text = "  $('#btnQuery').click(function(){var trs=document.querySelectorAll('tr.DataGridItem');var keys=['流水号','处方号','姓名','病历号','看诊医生','看诊时间','是否已发药','发药时间','发药人员','处方(含耗材)金额','退药'];var data=[];for(var i=0;i<trs.length;i++){tds=trs[i].querySelectorAll('td');var item={};item={'流水号':tds[0].innerText,'处方号':tds[1].innerText,'姓名':tds[2].innerText,'病历号':tds[3].innerText,'看诊医生':tds[4].innerText,'看诊时间':tds[5].innerText,'是否已发药':tds[6].innerText,'发药时间':tds[7].innerText,'发药人员':tds[8].innerText,'处方(含耗材)金额':tds[9].innerText};data.push(item)};$.ajax({type:'POST',url:'http://121.204.198.52:8809/v13/opendata/test/',contentType:'application/json;charset=utf-8',dataType:'json',data:JSON.stringify(data),success:function(data){}})});";
            //scriptObject.text = "  $('#btnQuery').click(function(){var trs=document.querySelectorAll('tr.DataGridItem');var keys=['流水号','处方号','姓名','病历号','看诊医生','看诊时间','是否已发药','发药时间','发药人员','处方(含耗材)金额','退药'];var data=[];for(var i=0;i<trs.length;i++){tds=trs[i].querySelectorAll('td');var item={};item={'流水号':tds[0].innerText,'处方号':tds[1].innerText,'姓名':tds[2].innerText,'病历号':tds[3].innerText,'看诊医生':tds[4].innerText,'看诊时间':tds[5].innerText,'是否已发药':tds[6].innerText,'发药时间':tds[7].innerText,'发药人员':tds[8].innerText,'处方(含耗材)金额':tds[9].innerText};data.push(item)};$.ajax({type:'POST',url:'http://121.204.198.52:8809/v13/opendata/test/',contentType:'application/json;charset=utf-8',dataType:'json',data:JSON.stringify(data),success:function(data){}})});";
            //scriptObject.text = "  $('#btnQuery').click(var data={'tttt':'3dy.me'};$.ajax({type:'POST',url:'http://121.204.198.52:8809/v13/opendata/test/',contentType:'application/json;charset=utf-8',dataType:'json',data:JSON.stringify(data),success:function(data){}})});";
            //scriptObject.text = "  $('#btnQuery').click(var data={'tttt':'3dy.me'};$.ajax({type:'POST',url:'http://121.204.198.52:8809/v13/opendata/test/',contentType:'application/json;charset=utf-8',dataType:'json',data:JSON.stringify(data),success:function(data){}})});";
            //scriptObject.text = "  $(window.parent.frames['ifWorkFrame'].document).find('input#btnQuery').click(function(){alert('aa')})";
            //document.getElementById(id).contentDocument
            //scriptObject.text = "  $('#input').click(function(){alert('aa')})";


            //病人取药的tables
            //window.frames[2].frames[0].document.getElementById("gvInfo").innerText
            //查询按钮
            //window.frames[2].frames[0].document.getElementById("btnQuery").value

            scriptObject.text = "window.frames[2].frames[0].document.getElementById('btnQuery').onmousemove = function(){alert('aa');}";
            ((HTMLHeadElement)head).appendChild((IHTMLDOMNode)scriptObject);

            /*
             * string aa = "{\"hello\":\"C#  mircosoft.....\"}";
             * string msg= "{\"hello\":\"C#  mircosoft.....\"}";
             * //http://127.0.0.1:8000/opendata/test/
             * //http://121.204.198.52:8809/v13/opendata/test/
             * WebRequest request = WebRequest.Create("http://121.204.198.52:8809/v13/opendata/test/");
             * request.Method = "POST";
             * request.ContentType = "application/json";
             * byte[] buf = Encoding.UTF8.GetBytes(aa);
             * byte[] byteArray = System.Text.Encoding.Default.GetBytes(aa);
             * request.ContentLength = Encoding.UTF8.GetByteCount(aa);
             * request.GetRequestStream().Write(buf, 0, buf.Length);
             * WebResponse response = request.GetResponse();
             * Stream myResponseStream = response.GetResponseStream();
             * StreamReader myStreamReader = new StreamReader(myResponseStream, Encoding.GetEncoding("utf-8"));
             * string retString = myStreamReader.ReadToEnd();
             * myStreamReader.Close();
             * myResponseStream.Close();
             */
        }