|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
对用户来说可预见费用、节约费用,可以做到花少钱办大事。由于省去了购买软件和硬件等的前期费用,用户可以租用较高级的应用软件。ASP的收费是根据软件的类型、客制化程度、用户数量、服务期限来定的,对客户来说这笔费用是可以预见的。方便于客户应用软件的升级。ResolvingBids-Page6
ChrisPayne
September11,2000
FunctionResolveBids(ItemID)
Setvariablesandcreateobjects
dimmonIncrement,monHighPrice,intAvailable,intTotItems,flgQuit
dimblnResolved
Assumebidsareresolved
blnResolved=True
strConnectionString="DSN=MyAuction;UID=username;PWD=password;Database=MyAuctionDB"
setrst=Server.CreateObject("ADODB.Recordset")
Getinformationfromitemstable
strSQL="SELECTIncrement,AvailableFROMtblAuctionItemsWHERE"&_
"IID="&ItemID
rst.openstrSQL,strConnectionString
monIncrement=rst(0)
intAvailable=rst(1)
rst.close
Findthehighestbidandtotalnumberitemsbidfor
strSQL="SELECTmax(WinPrice)ASWinPrice,sum(WinItems)as"&_
"WinItemsFROMtblAuctionBidsWHERE"&_
"ItemID="&ItemID
rst.openstrSQL,strConnectionString
monHighPrice=rst(0)
intTotItems=rst(1)
rst.close
Ifauserwithahighermaxbidexists,then
updatetheirbidifandonlyifavailableitemsisexceeded
strSQL="SELECTMaxBid,UID,BidItems,WinPriceFROM"&_
"tblAuctionBidsWHEREItemID="&ItemID
rst.openstrSQL,strConnectionString
ifnotrst.eofthen
dountilrst.eof
if(rst(0)>monHighPrice+monIncrement)AND(intTotItems>intAvailable)&_
AND(rst(3)monHighPrice)then
monHighPrice=monHighPrice+monIncrement
callDoBids(ItemID,rst(1),monHighPrice)
blnResolved=False
endif
rst.MoveNext
Ifwereattheendoftherecordset
andthebidsarenotyetresolved,gobacktothebeginning
ifnotblnResolvedANDrst.eofthen
rst.MoveFirst
blnResolved=True
endif
loop
endif
rst.close
EndFunction
Themainpartoftheabovecodeisthelastdo...loopsection.Theprocessisasfollows:
Enterausersbid(usingtheDoBids()function)
Findthehighestbidfortheitem,andtotalnumberofitemsbidfor
Loopthroughdatabaseand:
IFthecurrentbiddersmaximumbidishigherthanthehighestwinningbid,
ANDthetotalnumberofitemsbidforisgreaterthanthenumberofitemsavailable,
ANDthecurrentbiddersbidisnotthehighestbid,
THENincrementthecurrentbiddersbidbytheincrementvalue.
Ifwereachtheendoftherecordset,andthebidsarestillnotresolved,thestartover.
Thisprocesswillautomaticallyupdateallbidsappropriately,andweedoutthosewhosemaxbidsarenot
highenough.Thereasonwechecktomakesurethetotalnumberofitemsbidforisgreaterthanthenumber
oftotalitemsavailableinstep4isbecauseifallbidsareplacedanditemsclaimed,andthereare
stilllotsavailable,theneveryonewinsandbidsdonotneedtobeincremented.
Forexample,imaginethereare10lotsavailable,andthereare3bidders.IfbidderAwants3lotsat$3,
bidderBwants3lotsat$2,andbidderCwants3lotsat$1,everyonewillwinbecausethereisenough
lotstogoaround,andthensome.Thedoloopabovewillonlyhavetogothroughonce.
However,supposebidderCnowwants5items.Sincetherearenotenoughitemstogoaround,someonewill
havetoloseout.Theloopinthecodeaboveweedsthispersonoutbycheckingmaxbidsandupdatingthe
winningbids.Ifeveryonesmaxbidsinthisscenariowas$20,andtheincrementwas$2,thenbidderCand
whicheverofbidderAandBplacedthefirstbidwouldwin(rememberthatbidpriorityisplacedonmost
lotsbidfor,followedbybidtime).
</p>缺点:安全性不是太差了,还行,只要你充分利用系统自带的工具;唯一缺点就是执行效率慢,如何进行网站优化以后,效果会比较好。 |
|