批次扩展后的拍卖计时器问题 [英] Auction timer issue after extension in lot

查看:80
本文介绍了批次扩展后的拍卖计时器问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在asp.net的拍卖网站上工作。当我们点击每个批次的增量出价按钮时,如果计时器中的时间少于3分钟,那么批次时间会延长3分钟,但每个批次的计时器会在几秒钟内失配,而我的客户不希望这样。 />
这是调用JS函数来延长批次的时间:



I am working on auction site in asp.net. When we click on increment bid button of each lot , If time in timer is less than 3 minutes then lot time gets extended for 3 minutes but timers of each lot get mismatched by couple of seconds and my client don't want that.
This is calling of JS function to extend timing for lot:

eval('timer' + auctionLotId).cdtime('timer' + auctionLotId + "', '" + auctioncurrtime + "', '" + auctionendtimer + "', " + auctionLotId);







这是用于更新计时器的JS文件:




This is JS file for updating timer :

function cdtime(container, currentTime, targetdate, AuctionLotID) {
if (!document.getElementById || !document.getElementById(container))
return;
this.container = document.getElementById(container);
this.auctionLotID = AuctionLotID;
var now = new Date();
//this.currentTime = new Date(now.getFullYear(), now.getMonth(), now.getDate(), now.getHours(), now.getMinutes(), now.getSeconds());
//this.currentTime = new Date(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate(), now.getUTCHours(), now.getUTCMinutes(), now.getUTCSeconds());
this.currentTime = new Date(currentTime);
this.targetdate = new Date(targetdate);
this.currentTime.setSeconds(this.currentTime.getSeconds() - 1);
//alert('currentTime: ' + this.currentTime);
//this.targetdate = new Date(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate(), now.getUTCHours(), now.getUTCMinutes(), now.getUTCSeconds());
this.timesup = false;
this.updateTime();
}
cdtime.prototype.resetTimer = function (newdate) {
var thisobj = this;
this.targetdate = new Date(newdate);
this.extended = 1;
this.timesup = false;
//this.updateTime(); //by yogesh
}
cdtime.prototype.updateTime = function () {
//alert(this.currentTime);
var thisobj = this;
this.currentTime.setSeconds(this.currentTime.getSeconds() + 1);
this.tim = setTimeout(function () { thisobj.updateTime() }, 1000); //update time every second
//timer = setTimeout(updatetimer, 1000);
}

推荐答案

Wes说的是正确的。 .net中没有写入时钟设施。你可以很容易地制作自己的。



你可以用计时器轮询时钟但不要指望它是100%正确的,除非你每毫秒轮询一次(不要这样做,顺便说一句。



最好的方法是在大约合适的时间更新信息屏幕(到最近的秒;所以每秒轮询一次)如果拍卖即将到期)但确保交易有真实时间。



您可以随时在代码中检查当前服务器时间以确保事务发生在正确的threadhold中。如果要进行拍卖,则在交易级别应用此逻辑,以便在需要时始终保持准确。

------------- -------------------------------------------------- -----------------------

.net中没有时钟是痛苦的,但是一旦你知道那里你是不是习惯了基于时间的交易方法。



我希望有所帮助。如果您需要任何澄清,那么只需评论



祝你好运^ _ ^

Andy
What Wes said is correct. There is no "clock" facility written into .net. You can make your own quite easily.

You can 'poll' the clock with a timer but never expect it to be 100% correct, unless you poll every millisecond (don't do that, btw).

The best method is to have the info screen update at about the right time (to the nearest second; so poll every second if an auction is about to expire) but ensure that transactions have a "true" time.

You can check the current server time at any time in the code to ensure that a transaction occurs in the correct threadhold. If the auction is to be extended then apply this logic at the transaction level so that they will always be accurate as and when it is needed.
--------------------------------------------------------------------------------------
It is a pain that there is no clock in .net, but once you know that there isn't you get used to the methods of time based transactions.

I hope that helps. If you need any clarification then just comment

Good luck ^_^
Andy


这篇关于批次扩展后的拍卖计时器问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆