云广

云广的blog
随笔 - 5, 评论 - 8 , 引用 - 15

2005年2月25日

在vb.net中使用webbrowser控件和mshtml以及流操作体会(vb.net内嵌IE,拆取 Web 页)

需求为:到某一网站抓取查询结果.环境为vb.net

从0开始,一开始具体需要用到.net里的具体什么东东都不清楚,于是就一顿瞎搜索.又是google,又是baidu,yisou......胡乱搜的内容有.net ie,拆分网页 .net,内嵌ie等等.没过多久能得知webbrowser这个控件.

其中对我有帮助比较大的文章是http://www.microsoft.com/china/msdn/Archives/workshop/scrape.asp

只是这里介绍的vb环境.到.net也没什么太大差别,别笑!我最开始找shdocvw.dllmshtml.dll添加引用时候都费了半天劲.因为大家都说webbrowser.而.net里写的是microsoft web 浏览器..

先按照上面的文章练一练!

不说废话了.

先做一个输入框,和一个按钮,供输入信息,和提交信息.

在按纽的click事件中写:

            Dim postdata As String() = {"searchText=" + Me.searchText.Text}
            Dim strUrl As String = "http://"
            Dim SessionHtml As String = PostDate(strUrl, postdata)
            '产生临时文件
            Dim sw As StreamWriter = New StreamWriter("D:\1.htm", False, Encoding.GetEncoding("GB2312"))
            sw.WriteLine(SessionHtml)
            sw.Close()
            Me.AxWebBrowserFill.Navigate("D:\1.htm")

 

PostDate函数如下:

Public Function PostDate(ByVal url As String, ByVal PostData() As String) As String

Dim Post As String = ""
            '拼接成传递变量
            For Each s As String In PostData
                Post += s + "&"
            Next
            Post = Post.Substring(0, Post.Length - 1)
            Dim html As String = ""

            Dim encoding As Encoding = encoding.GetEncoding("GB2312")
            Dim data As Byte() = encoding.GetBytes(Post)
            Dim myRequest As HttpWebRequest = CType(WebRequest.Create(url), HttpWebRequest)
            myRequest.Method = "post"
            myRequest.ContentType = "application/x-www-form-urlencoded"
            'myRequest.ContentType = "text/asp"
            myRequest.ContentLength = data.Length
            Dim newStream As Stream = myRequest.GetRequestStream()
            newStream.Write(data, 0, data.Length)
            newStream.Close()
            Dim resp As HttpWebResponse = CType(myRequest.GetResponse(), HttpWebResponse)
            Dim sr As StreamReader = New StreamReader(resp.GetResponseStream(), System.Text.Encoding.GetEncoding("GB2312"))
            '返回html代码的字符串
            html = sr.ReadToEnd()
            sr.Close()
            Return html

 End Function

这样就可以了.

至于直接把html显示在webbrowser控件中,而不通过临时文件,在网上搜到的都是delphi办法.而.net似乎没有完美的解决办法.

 

曾经试过:

'AxWebBrowserFill.Navigate(SessionHtml)
            'Me.AxWebBrowserFill.Document.write(SessionHtml + "<font size=5>haga</font>")
            'Me.axScriptLet.url = "about:blank" + SessionHtml
            'Me.AxWebBrowserFill.Document.write(SessionHtml)
            'doc = Me.AxWebBrowserFill.Document
            'doc.body.innerHTML = SessionHtml
            'doc.write(SessionHtml)

 

往往只是第一次成功,而且中间会涉及到html内双引号的问题.

也有网上说按如下方法:


            ''在WebBrowser中显示报告内容字段
            'Dim doc As IHTMLDocument2 = CType(AxWebBrowserFill.Document, IHTMLDocument2)
            'Dim bodyElement As IHTMLElement = CType(doc.body, IHTMLElement)
            ''bodyElement.innerHTML = SessionHtml + "<font size=5>haga</font>"

而这个方法我就没有奏效过!

 

posted @ 12:57 | Feedback (2)

2004年12月19日

英文面试准备

假设问题1:自我介绍

My name is yun guang and I came from LiaoNing province.

I graduated from nwpu in 2003(two thousand three), accompanied with a bachelor degree of science.

During the past three years, I took several part time jobs, mainly in charge of website design and maintenance. Moreover, I have worked for shanxi's tsinghua science park's website.

Now, I am studying in Software School of Peking University and major in E_Business. Until now i have finished all the required courses. It is the very time for me to prepare the practice, which will last about one year.

I regard myself as an open-minded person, who can communicate with other people very well. What’s more, I had been the group leader in project team for several times. I can not only complete the work of my share alone, but also lead or participate other team members to finish the project perfectly. I think my greatest strongpoint is that I always keep a higher passion for software technology; I am always learning its new disciplines and criterions in order to keep pace with modern IT development.

假设问题2:请简单描述你最满意的项目

 

The project which I was most satisfied with is the development of website of JuFeng financial corporation in Shan’xi province in 2002. Their website now is http://www.jfinfo.com.  I took a part-time job there, and during these days, the most significant job I finished was JuFeng English edition and an integrated OA system. Here I want to give some description about this OA System------JuFeng consulting room. It involved many fundamental functions such as BBS, chatting room, user archive management, expert consulting, article management, user service, instant messaging, etc. They mainly applied such technologies---asp, javascript, xhtml, js-----to this project, and the database they chose was SQL server2000. I have been the team leader and also have done some work of coding, document compiling, testing and system maintenance.

假设问题3:学校课程中最满意项目

 

This project require us to use at least ten design patterns to develop a rent-car system using language of java. This system should have functions of choosing car online, renting car, modifying and deleting orders. I mainly served as the leader and the coordinator of my group. The work I did was drawing class diagram using UML technique, instructing UI design, and implement the system by JSP, JavaBean and Servlet.

假设问题4:描述自己的家乡与家

 

假设问题5:请说出自己的3个优点和3个缺点

已准备

假设问题6:请说明自己未来的目标

 

Now I want to find a company first, which is appropriate for me to work as an intern. And during the following 5 years I will do my best to complete every job assigned to me. I will start with software technique fields first and enrich my basic skills constantly. Then after five years, I would like to change my profession from developer to IT manager. And if it is possible, I wish one day I could become a famous person in software industry, and give my utmost devotion to the prosperity of IT industry.

假设问题7:是否和人发生过口角

 

It is true that I have ever quarreled with somebody else, but I didn’t mean to that. I think no one like going out of his way to look for trouble. My own manner to handle public relationship is that I will treat everybody around me tenderly and honestly. I will try to make clear the misunderstanding and conflict between us and eliminate them quickly. So past things would have no chance to disturb my present emotion.

假设问题8:高兴和不高兴的事

答:针对现在,各举一例,高兴的事如当程序由调不通到正常运做,那种小小成就感能让我高兴欣慰。不高兴的事情是自己认为不够努力,需要自己更加勤奋。以适应现在的IT的快速发展。

There is something that will make me very happy, when a program could work normally after my debugging. This will give a certain of identity, and that is one of the things I am busily engaged in seeking. On the other hand, there is also something that makes me unhappy. Because it is seems to me that I was not as hardworking as I regard myself before. The urgent thing now for me is to become more diligent; otherwise I will be unable to catch up with the pace of IT industry and be washed out at last.

假设问题9:技术领域问题

这个没办法只有自己准备了

假设问题10Two question:

1、  When will I receive the info about the interview result, if I passed, and when I come here to practice?

2、  Can you offer me a career path?

 

posted @ 18:08 | Feedback (11)

2004年12月18日

创建一个自动增量序列生成器

在oracle中

 

CREATE SEQUENCE

Emp_sequence

 

INCREMENT BY 1

 

START WITH 1

 

NOMAXVALUE

 

NOCYCLE

 

CACHE 10;

然后在插入数据时候可以通过如下代码实现:

insert into users (U_Id,u_username,u_password,u_level)

values

(Emp_sequence.NEXTVAL,'yunguang','haha','0')

 

其中U_Id为表users的主键。

这样就可以实现在U_Id上产生自动增量效果!

 

 

具体的可视化操作还没有找到,晕!!!

posted @ 16:27 | Feedback (4)

使用TreeView实现无限级扩展节点

功能实现要求:

操作环境vb.net和oracle9i

 

由于数据量很大,所以不能利用rs结果集一次读出,在往treeview节点上填充。

需要填充树型节点的字段内数据形式为以"."分割

如:01   01.01 01.02 01.01.01 02 02.01 02.01 ............................

利用oracle自身instr函数,可以按"."数分割。并返回所需要的结果集,初始化加载读取不带"."字段,第一次读取带一个"."…………

至于sqlserver数据库与oracle的函数书写略有不同,可以到google,csdn等地方去查找。

sql语句的大致写法如下:

If pDotCount = 0 Then
                    sqlString = "select t.需要分割的字段,t.cname from 表名 t where Instr(t.icsn, '.', 1, 1)=0"
                Else
                    sqlString = "select t.需要分割的字段,t.cname from 表名 t where Instr(t.icsn, '.', 1," & pDotCount & ")>0 and Instr(t.icsn, '.', 1, " & (pDotCount + 1) & ")=0 and Instr(t.icsn,'" & pParent & "',1,1)=1"
                End If

pDotCount为需要读取的字段中"."的个数

然后通过双击事件获得父节点(即为选中节点),sql语句中pParent,返回属于该父节点的子节点,这样一级一级双击即可实现无限扩展,直至走到数据最后一层为止

检索定位任一节点

主要是在于初始选择节点的定位。此处略去,如有兴趣,可以直接和我联系,互相学习。

 

MSN:yun15291li@hotmail.com

Email:ygyunguang@yahoo.com.cn

posted @ 2:16 | Feedback (3)

根据部门判断进入版块的权限

Segment表中,有三个字段,segmentIdsegmentNamesegmentRight

分别表示权限序号(从1开始),模块名,访问权值。其中segmentRight=2segmentId-1次方,

  

     segmentId=1segmentRight=1 (对应二进制1

     segmentId=2segmentRight=2(对应二进制10

     segmentId=3segmentRight=4(对应二进制100

     segmentId=4segmentRight=8

     segmentId=5segmentRight=16

 

     ......

     相当于 segmentRight 的第0位代表segmentId=1的模块访问权限,

            segmentRight 的第1位代表segmentId=2的模块访问权限,

            segmentRight 的第2位代表segmentId=3的模块访问权限,

            segmentRight 的第3位代表segmentId=4的模块访问权限,

            ......

     而在部门表里的Segment=上面segmentRight之和,比如,Segment=7,其二进制为0111

则表示该部门对segmentId123的模块具有访问权。换句话说,测试部门表里的Segment

字段的各个二进制位,即可知该部门是否具有对某模块的访问权。

 

    Segment表进行单独管理,增、删、改操作。

 

    对部门表的管理,增加权限的设置,即显示已有的可操作模块,操作者进行选择,然后

将选中的各模块的 segmentRight 值加起来,赋予部门表里的Segment字段。

 

    访问模块的权限判断流程如下:

 

    用户点击某模块-->Segment表中通过segmentName(模块名)取出该模块的segmentRight值,

                     同时从部门表中取出该部门的segment

                  -->segment值和segmentRight值进行“位与”操作,即 segment & segmentRight,

                  -->如果“位与”的结果等于segmentRight,则该部门具有操作该模块的权限,

                     使用户进入该模块的操作。

                  -->如果“位与”的结果等于0,则拒绝该用户进入该模块的操作。

相关代码以及讨论者请按如下方式联系:

MSN:yun15291li@hotmail.com

Email:ygyunguang@yahoo.com.cn

posted @ 2:00 | Feedback (3)

京ICP备 05050892号