UarrMain[0] := AsMainType(edLayer,myStr,'Layer','结构层名称');
UarrMain[1] := AsMainType(edKind,'Kind','稳定剂种类');
.......
UArrSub[0] := AsSubType(myInt,True,'seqnum','序号');
UArrSub[1] := AsSubType(myStr,False,'BoxNumber','试验盒号');
UArrSub[2] := AsSubType(myFloat,'BoxWeigth','盒的质量');
.....
我现在需要提取第三个,第四个参数。
放上来,下次电脑坏就不用重新写了。工作当中用到的,可以减轻工作量。
- packagemain
- import
- (
- "io"
- "fmt"
- "regexp"
- "strings"
- "net/http"
- )
- const(
- sql="EXECsys.sp_addextendedproperty@name=N'MS_Description',@value=N'AAAA',@level0type=N'SCHEMA',@level0name=N'dbo',@level1type=N'TABLE',@level1name=N'CCCC',@level2type=N'COLUMN',@level2name=N'BBBB'"
- sql2="EXECsys.sp_addextendedproperty@name=N'MS_Description',@level1name=N'CCCC'"
- html=
- `<html>
- <head><title>提取<a/title></head>
- <body><formmethod='post'>
- TableName:<inputtype="text"name="tablename"></input>qs_Table中的TableName,比如TestRecordC21<br></br>
- 表格名称:<inputtype="text"name="tablename2"></input>比如石料试验记录<br></br>
- <textarearows="20"cols="120"name="target"></textarea><br></br>
- <inputtype="submit"value="Submit"></input>
- %s
- </form>
- </body>
- </html>`
- )
- funcmySearch(strstring)(resultstring){
- result=""
- regSub:=regexp.MustCompile(`(?i)AsSubType\s*\(\w+\s*\,\s*(True|False)\s*\,\s*\'\s*(\w+)\s*\'\s*\,\s*\'\s*(.*?)\s*\'`)
- regMain:=regexp.MustCompile(`(?i)AsMainType\s*\(\w+\s*\,\s*(\w+)\s*\,\s*\'\s*(.*?)\s*\'`)
- resultSub:=regSub.FindAllStringSubmatch(str,-1)
- resultMain:=regMain.FindAllStringSubmatch(str,-1)
- for_,V:=rangeresultSub{
- result=result+strings.Replace(strings.Replace(sql,"AAAA",V[3],-1),"BBBB",V[2],-1)+
- "<br></br>"+"GO"+"<br></br>"
- }
- for_,V:=rangeresultMain{
- result=result+strings.Replace(strings.Replace(sql,-1)+
- "<br></br>"+"GO"+"<br></br>"
- }
- return
- }
- funcAnalyze(whttp.ResponseWriter,r*http.Request){
- ifr.Method=="GET"{
- io.WriteString(w,strings.Replace(html,"%s","",-1))
- return
- }
- ifr.Method=="POST"{
- str:=r.FormValue("target")
- tablename:=r.FormValue("tablename")
- tablename2:=r.FormValue("tablename2")
- iftablename==""{
- io.WriteString(w,"<divborder='1'>"+
- "TableName没有填写"+"</div>",-1))
- return
- }
- iftablename2==""{
- io.WriteString(w,"<divborder='1'>"+
- "表格名称没有填写"+"</div>",-1))
- return
- }
- ifstr==""{
- io.WriteString(w,"<divborder='1'>"+
- "查找内容没有填写"+"</div>",-1))
- return
- }
- sqlCMD:=strings.Replace(html,"<divborder='1'>"+
- strings.Replace(mySearch(str),"CCCC",tablename,-1)+"</div>",-1)
- sqlCMD=sqlCMD+strings.Replace(strings.Replace(sql2,tablename2,"CCCC",-1)
- io.WriteString(w,sqlCMD)
- }
- }
- funcmain(){
- fmt.Println("Openhttp://localhost:8888/extract")
- http.HandleFunc("/extract",Analyze)
- err:=http.ListenAndServe(":8888",nil)
- iferr!=nil{
- fmt.Println(err.Error())
- }
- }