Solved

Display percent complete on a query???

Posted on 2004-03-30
6
248 Views
Last Modified: 2013-12-24
Hello Experts,

I have looked around on this forum don't haven't found exactly what I am looking for...

I am querying a database and creating a flat file.  This will take from 1 minute to 3 minutes depending on the query parameters and congestion.

Here is the code:

<!--- run your query --->
  <cfquery name="daschedule" datasource="#db#" dbtype="ODBC">
      SELECT CLASS
     FROM COURSE_LIST
  </cfquery>


<cfset outputfile = "#GetDirectoryFromPath(GetCurrentTemplatePath())#schedfile.txt">
<cfset linesperwrite = 1000>
<cfset crlf = Chr(13) & Chr(10)>
<cffile action="write" file="#outputfile#" output="" addnewline="no">
<cfset x = "">
<cfset linecount = 0>

<cfoutput query="daschedule">
   <cfif (left(#CLASS_IND#, 8) EQ '#yt#714' OR
        left(#CLASS_IND#, 8) EQ '#yt#887' OR
            left(#CLASS_IND#, 8) EQ '#yt#843' OR
            left(#CLASS_IND#, 8) EQ '#yt#833' OR
            left(#CLASS_IND#, 8) EQ '#yt#734' OR
            left(#CLASS_IND#, 8) EQ '#yt#721' OR
            left(#CLASS_IND#, 8) EQ '#yt#722' OR
            left(#CLASS_IND#, 8) EQ '#yt#797' OR
            left(#CLASS_IND#, 8) EQ '#yt#723' OR
            left(#CLASS_IND#, 8) EQ '#yt#725' OR
            left(#CLASS_IND#, 8) EQ '#yt#726' OR
            left(#CLASS_IND#, 8) EQ '#yt#728' OR
            left(#CLASS_IND#, 8) EQ '#yt#733' OR
            left(#CLASS_IND#, 8) EQ '#yt#735' OR
            left(#CLASS_IND#, 8) EQ '#yt#739' OR
            left(#CLASS_IND#, 8) EQ '#yt#852' OR
            left(#CLASS_IND#, 8) EQ '#yt#774' OR
            left(#CLASS_IND#, 8) EQ '#yt#790') >

       <cfset data =  #daschedule.CLASS_IND#>
        
         <cfset site = mid(#daschedule.CLASS#, 6, 3)>
         <cfset course = mid(#daschedule.CLASS#, 9, 9)>
                   
       <cfset x = x & "#site#,#course#,#lineNumber#" & crlf>
       <cfset linecount = linecount + 1>
       <cfif linecount gte linesperwrite>
       <cffile action="append" file="#outputfile#" output="#x#" addnewline="no">
       <cfset x = "">
       <cfset linecount = 0>
       </cfif>
         <cfset lineNumber = lineNumber + 1>
       </cfif>
 </cfoutput>
 <!--- Don't forget to dump any remaining lines to the file --->
<cffile action="append" file="#outputfile#" output="#x#" addnewline="no">
 

This process works great but it takes awhile.  Basic study in Human Factors will tell you that any wait longer than 30 seconds requires some sort of progress indcator for the user.  While this process is running I would like to display a percent complete or progress bar indicating how much time is left.

I am using ColdFusion 4.5 ( will be upgrading to MX soon but this needs to work in 4.5 for now - say this because CFFLUSH doesn't seem to work in 4.5).

Any suggestions would be helpful.
0
Comment
Question by:shogun5
6 Comments
 
LVL 35

Accepted Solution

by:
mrichmon earned 250 total points
Comment Utility
I am not sure that you can do this in CF 4.5 since from what I understand there is really no way to communicate between the page and the DB server in CF 4.5  So that means that there would be no way to show any progress.  If you know about how long it takes then what you could do is fake a progress indicator in javascript that really isn't tied to the query, but that accounts for worst case scenario and then is replaced by the results when they actually get pulled.  It would often finish sooner if you have a 1-3 minute window and you base the progress bar on the 3 minutes, but people never mind if things finish faster.  :o)
0
 
LVL 5

Expert Comment

by:Seth_Bienek
Comment Utility
Hi shogun5,

Without being able to use cfflush, this gets complicated.

The only thing I can think of would be to pop up a 'please wait' window on the page before your processing page, then keep it in front until the processing page is finished, and have the processing page close the popup.

How soon will you be upgrading to MX?  Maybe this is a good opportunity to put that move on the fast track. :)

Lemme know if you need some code samples for this approach.

Regards,

Seth
0
 

Author Comment

by:shogun5
Comment Utility

Okay, well I kind of figured that.  

Thanks, both of your, for your inputs.  I'll just wait until our company installs ColdFusion MX.

-mike
0
 
LVL 6

Expert Comment

by:PE_CF_DEV
Comment Utility
You could put this in a frame,  and do as mrichmon suggested and put a 'worse case' countdown on it. this frame will load immediately while the other frame waits to complete.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now