|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
SQLServer是基于服务器端的中型的数据库,可以适合大容量数据的应用,在功能上管理上也要比Access要强得多。在处理海量数据的效率,后台开发的灵活性,可扩展性等方面强大。objectInPart1welookedattheCountersobjectandwhatpurposeitserves;wealsoexamineditsfourmethods.InthispartweregoingtolookattheCountersobjectinabitmoredepthandlookatsomecodetotrackthepopularityofvarioussearchtermsandcodetodisplaythevaluesofallofthecounters!
PersistingCounterData:
TheCountersobjectpersistsitsvariouscountersinformation.Thatis,eveniftheWebserverisrebootedthevalueinthesecounterswillnotberesetbacktozero.Thisispossiblebecausethedataforeachcounterisstoredinatextfile,counters.txt.ThisfilewillmostlikelybelocatedinWINNTsystem32orWINNTsystem32inetsrvData.Thefilesstructureisprettystraightfoward.Eachcounterthatyoucreatehasitsownlineinthetextfile.Oneachlinethenameofthecountercomesfirst,followedbyacolon,followedbythevalueofthecounter.Forexample:
HomePage:1935
SomeOtherPage:234
ProductQueries:45
AdvertisementDisplays:35221
Therefore,ifwewantedtodisplaythevaluesofallofourcountersinanASPpagewecouldusesomeverysimpleFileSystemObjectcodetoopenthisfileandreadthecontentsofeachline,displayingthenameofthecounteranditsvalue.Thefunctionpresentedbelowcanbecutandpastedintoyourapplicationtolistthecontentsofeachcounter.
FunctionDisplayCounters()
Thefullphysicalfilenameofthecounterstextfile
ConststrFileName="C:WINNTsystem32inetsrvDatacounters.txt"
DimobjFSO,objTS
SetobjFSO=Server.CreateObject("Scripting.FileSystemObject")
SetobjTS=objFSO.OpenTextFile(strFileName)
Readinthelinesoneatatime
DimstrLine
DoWhileNotobjTS.AtEndOfStream
Readinthelinefromthefile
strLine=objTS.ReadLine()
Displaythecounternameandvalue
Response.Writesplit(strLine,":")(0)&"-"&_
FormatNumber(split(strLine,":")(1),0)&"<br>"
Loop
Cleanup...
objTS.Close
SetobjTS=Nothing
SetobjFSO=Nothing
EndFunction
Withalittlemoreworkyoucouldreadthesevaluesintoatwo-dimensionalarrayandthensortthearrayindescendingorderbythecountervalues.Thenyoucouldselectivelydisplay,say,thetoptencountersorwhatnot.Ifthisinterestsyoubesuretocheckout:SortingaTwo-DimensionalArraywithBubbleSort.
TrackingthePopularityofVariousSearchTerms:
OneveryusefulapplicationfortheCountersobjectwouldbetotrackthepopularityofvarioussearchtermsenteredbyyourusers.Forexample,ifyouhaveasearchengineonyoursite(likethesearchenginehereat4Guys)youmaybecuriouswhatsearchkeywordsarethemostpopular.Totrackthismetric,allyouwouldneedtodoisaddthefollowingcodetothesearchpage:
...
Thisassumesthattheuserssearchtermwaspassedthroughthe
querystringas"SearchTerm"
DimstrSearchTerm
strSearchTerm=Request.QueryString("SearchTerm")
Iftheuserenteredasearchtermthanincrementthecounter
IfLen(strSearchTerm)>0then
objCounter.Increment(strSearchTerm)
EndIf
...
Then,insomereportingscreen,youcanusetheDisplayCounters()functiontolistthevarioussearchtermsandtheirassociatedpopularity.
Conclusion:
ThiswrapsupourexaminationoftheCountersobject.TheCountersobjectisamorepowerfulversionofthePageCounterobject,capableofprovidingmultiplecountersacrossyourentireWebsite.</p>楼上说交互性不好,太牵强了吧。在微软提供的一套框架中,利用asp做网站,开发效率高,使用人数少,减少不必要的开销。交互性是互动方式,是有开发人员决定的。 |
|