Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 4 Website Programming Problem Design Solution section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old April 6th, 2011, 12:53 AM
Registered User
 
Join Date: Apr 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Code for Call timer

I hardly understood this code, but what this essentially does is; In the code behind it calculates the timespan in milliseconds, and In the asp page, we call getSecs() function on load, which will calculate the call timer. (They want to capture, how much time a customer care associate is spending on the call, in HH:MM:SS format). When the application page loads it should be 00:00:00 and it should increment the timer as the time progress. We doesn't want to refresh the time, when we refresh the page or when we browse thru other tabs / windows. We do reset the time when we hit "New Trip" or "Close without Save" or "Clone trip" buttons, and after saving the trip. To rest the trip we use 3 lines in below if condition. This code doesn't seem to be working all the time, we get some negative hours, and incorrect minutes at times, not sure what is the issue.. can you please look into it, when you get some time.. if you could rewrite the code or point me to right direction, that would be really helpful.

In the code behind we are using this code

if (Session["calltimer"] == null)
{
TimeSpan t = (DateTime.Now - new DateTime(1970, 01, 01).AddMilliseconds(0));
Session["calltimer"] = (Int64)(t.TotalMilliseconds + 0.5);
txtstarttimeforcurrentcall.Text = Session["calltimer"].ToString();
}
else
{
txtstarttimeforcurrentcall.Text = Session["calltimer"].ToString();
}

Onload we are using this code....

function getSecs() {
var myTime1 = new Date();
var numCurrTimer = document.getElementById('txtstarttimeforcurrentcal l').value;
//alert(txtValue);
strSS = (Math.round((myTime1.getTime() - numCurrTimer) / 1000)) % 60;
strMin = Math.round((Math.round((myTime1.getTime() - numCurrTimer) / 1000) - 30) / 60) % 60;
strHR = Math.ceil(((Math.round((myTime1.getTime() - numCurrTimer) / 1000)) / 60) / 60) - 9;
if (strHR == -1) strHR = 0;
strHR = "0" + strHR;
strMin = strMin + "";
strSS = strSS + "";
if ((strMin.length) == 1) strMin = "0" + strMin;
if ((strSS.length) == 1) strSS = "0" + strSS;
document.getElementById("txtCurrentCall").value = strHR + ":" + strMin + ":" + strSS;
window.setTimeout('getSecs()', 1000);
}


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to call ASP application from a .Net code Nishapd ASP.NET 3.5 Basics 1 April 13th, 2009 05:19 PM
Button code to call URL Zozozo BOOK: Beginning ASP 3.0 0 June 11th, 2007 08:06 AM
call activex from jsp code missneg JSP Basics 1 January 24th, 2007 03:07 AM
call activex from jsp code missneg Pro JSP 0 May 3rd, 2006 03:27 AM
Call code from page mushu Excel VBA 0 September 21st, 2004 10:04 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.