分手快乐 发表于 2015-1-16 22:28:00

ASP网站制作之制造我们本人的Ebay(拍卖体系)(7)

减少客户内IT专业人才缺乏带来的影响。ASP的客户员工利用浏览器进入相关的应用软件,简单易用,无需专业技术支持。ChrisPayne

September11,2000

Well,nowyourauctioncanrunforanindefinitetime.Peoplecankeepplacingbidsuntilyoudecideto
stopthem(goodfortheseller,butmakesbidderskindofunhappy,tosaytheleast).Letsdiscussthe
mechanismsforstoppinganauction.

Therearetwoeasywaystodoit.Thefirst,andeasiesttoperform,thoughrequiringmoremanual
interventioninthelongrun,istosimplybuildinan"Active"bitfieldintoyourtblAuctionstable.
Whenyoudecidetostoptheauction,flipthebit,andtheauctionisover.(Youllalsohavetoaddsome
codetomakesurethattheDoBidsandResolveBidsfunctionsdontoperateonclosedauctions.)Thensimply
querythedatabase,findoutthewinner(s),andletthemandthesellerknow.Easyaspie.

Thesecondmethodistogobytheenddatethesellerspecifies(betterbusiness,believeme).Todothis,
youcanmanuallystoptheauction(viatheprocessabove)whentheappropriatedatecomes,oryoucan
scheduleatasktoturnanauctionoffattheappropriatetimes.Thereareafewwaystodothis,viayour
databaseprogramandtheWindowsNTTaskScheduler,soIwontgothrougheachone.Youcouldsimplyset
thescripttoruneverymidnightorsotostoptheauctionanddeterminethewinners.

Ifyouletthesellerspecifyanexacttimefortheauctiontoend,thenyoureintroducingawholenew
setofcomplications.Onewaytohandlethisistoprogrammaticallysetascheduledtaskassoonasthe
sellersubmitstheauction,fortheenddateoftheauction.Thisrequiresminimumintervention,but
requiresyoutoknowhowtodothat(fordocumentationontheTaskScheduler,readthisMSDNarticle).
Anothermethodistocreateyourownspecificversionoftaskscheduler;createasmallprogramthatwill
runinthebackgroundandwatchthetimesonauctions.Whenanauctionenddatepasses,flipthebit.

Okay,sotheauctionisover.Nowwhat?

Assumingthatyouwouldlikeminimalmanualintervention,andyoudontreallycarewhowins(likethe
headguysatEbaycarewhowinseverysingleauction),thenyoucouldcreateafunctiontosendalertsto
thewinner(s)andsellerthatwillkickoffwhentheauctionisover.Thisfunctioncouldalsointurn
kickoffsometypeofpaymentsystem,butthatisbeyondthescopeofthisarticle.Letslookatthe
function:



FunctionSelectWinners(AuctionID,itemID)


Setvariablesandcreateobjects
dimtotItems,intAvailable
totItems=0
strConnectionString="DSN=MyAuction;UID=username;PWD=password;Database=MyAuctionDB"
setrst=Server.CreateObject("ADODB.Recordset")


Findthenumberofitemsavailable
strSQL="SELECTAvailableFROMtblAuctionItemsWHERE"&_
"IID="&ItemID
rst.openstrSQL,strConnectionString
intAvailable=rst(1)
rst.close


findthewinners
Iftwocustomersbidthesameamount,thecustomerrequesting
moreitemswillwin.Ifstilltied,thecustomerplacingthe
earliestbidwillwin
strSQL="SELECTUID,WinPrice,WinItemsFROMtblAuctionBids"&_
"WHEREIID="&itemID&"ORDERBYWinItemsDESC,Time"


rst.openstrSQL,strConnectionString
ifnotrst.eofthen
dountilrst.eofORtotItems>=intAvailable
Keeparunningtallyofitemsdistributed
totItems=totItems+rst(2)
IftotItems<=intAvailablethenThisbuyerwon
Sendanemailalertingthisbuyer
callSendWinningEmail(rst(0))
Endif
rst.movenext
loop
endif


EndFunction


Thisisaprettysimplefunction.Simplyloopthroughthebidsinthecorrectorder(bynumberofitems
wonfirst,andthenbydate),andalertthebuyersthattheyvewon.Oncethenumberofitemsbidforgets
higherthanthenumberofitemsavailable,everyoneelseloses,andyoucanstoptheloop.Iwontgo
intotheSendWinningEmail()function,butallitdoesissendtheuserspecifiedbyrst(0)anemailthat
saystheyvewonandforhowmuchandhowmany.(Foranexampleusingemail,checkoutthisWDVLarticle.)
ASP脚本是采用明文(plaintext)方式来编写的。

金色的骷髅 发表于 2015-1-19 13:35:44

作为IE上广为流传的动态网页开发技术,ASP以它简单易学博得了广大WEB程序爱好这的青睐,而且它对运行环境和开发品台的不挑剔,以及有大量有效的参考手册,极大的推广了它的发展。

分手快乐 发表于 2015-1-26 22:19:25

如何学好ASP,以前也有人问过,把回答给你转过来看看能否对你有帮助:

再现理想 发表于 2015-2-4 21:37:24

以HTML语言整合(HTML负责界面上,ASP则负责功能上)形成一个B/S(浏览器/服务器)模式的网页程序。

谁可相欹 发表于 2015-2-10 17:12:16

以上是语言本身的弱点,在功能方面ASP同样存在问题,第一是功能太弱,一些底层操作只能通过组件来完成,在这点上是远远比不上PHP/JSP,其次就是缺乏完善的纠错/调试功能,这点上ASP/PHP/JSP差不多。

小妖女 发表于 2015-3-1 13:37:43

我认为比较好的方法是找一些比较经典的例子,每个例子比较集中一种编程思想而设计的。

深爱那片海 发表于 2015-3-10 17:52:50

ASP的语言不仅仅只是命令格式差不多,而是包含在<%%>之内的命令完全就是VB语法。虽然ASP也是做为单独的一个技术来提出的,但他就是完全继承了VB所有的功能。

冷月葬花魂 发表于 2015-3-17 09:10:29

它可通过内置的组件实现更强大的功能,如使用A-DO可以轻松地访问数据库。

不帅 发表于 2015-3-24 05:18:32

哪些内置对象是可以跳过的,或者哪些属性和方法是用不到的?
页: [1]
查看完整版本: ASP网站制作之制造我们本人的Ebay(拍卖体系)(7)