Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How set limits on when a report can be run in CE9

Status
Not open for further replies.

beardenb

MIS
Jan 16, 2003
36
0
0
US
We have a series of reports in CE9 that we want to put limits on as to when the users can run them. I think I see a way to manage this as long as the reports are run via Schedule, but these reports are run on demand (i.e. via View, not Schedule). When running a report using View, my understanding is that the report executes outside the normal controls in that they do not hit any of the CE server jobs.

I was wondering if anyone has any ideas or has maybe faced this issue.

Thanks,
--Bearden
 
HI,
AFAIK, View On Demand means just that - Run it when requested..It the user only has 'View Latest Instance' and you schedule it to run when you want it to, the user will only see the saved results of that run..No Database hit needed.

[profile]
 
What do you propose will happen when they attempt to do so?

It says "wait until X time?" or you just want to make the server unavailable for viewing?

ePortfolio isn't designed to allow for timed levels of operation for viewing, you'd have to write code.

Another simplified approach might be to place a scheduled job to rewrite the available.csp page during those hours that you don't want and users using the VIEW option.

-k
 
Turkbear - The reports are running against an application where the data changes from minute to minute. Of the 10 reports they have the capability of running, 9 of them should only be run from say, 6am to 3pm, and after that they "should not" run any of these reports. However, there's one report that they need to be able to run at any time on demand and this time is variable based on other things happening in the system, like when a batch of orders have been posted as shipped. So we can't really pre-schedule this report and force them down the view-latest-instance route. Also, we tried getting them to use the schedule screen, but everyone hated it. With the ActiveX viewer, using the View command, you get the nice ActiveX prompt dialog boxes instead of the messy Schedule screen. It all works just fine except for the problem I'm trying to address here.

Synapsevampire - Up until I received the request to research a way to limit when certain reports can run, it was done on the honor system - "don't run these reports between 3 and 7pm". That worked OK for a while but people forget and some just don't care. So in answer to your question, we're not too concerned with what happens if they try to run a report they're not supposed to be running. That may be short-sighted, but for now my main concern is to keep them out. A better approach would be to display a message or as you point out, perhaps change the CSP to remove or disable the View option for those reports. The challenge there would be identifying a way to selectively disable View for only those reports that we want to block them from, and only during certain hours. I am not terribly adept at Javascript/VBScript which I think is what would be required to modify the .csp.
 
Since you're being selective about which reports will be limited, this will require administration over the system to keep track of which reports need to be blocked out.

Perhaps another table with this info linked to the APS database on the reportid.

Anyway, I'm not aware of a simple fix, this would likely require some coding.

Another thing that came to mind, which is purdy fugly would be to code into the record selection formula something like:

...
(
If hour(currentdatetime) in [15 to 19]
then
1=0
else
true
)

Now the reports themselves will run, but not for long ;)

We used to use this approach when building Union Queries for stripping dupes before Crystal built it in. The query should immediately return, and you could have a suppressed section which unsuppressed for hour(currentdatetime) in [15 to 19] that stated "Baaaaaaaad, report running person, it's between 3 and 7, we're telling the reports admin!"

-k
 
Other options (not necessarily better ones).

1. Lock user account(s) on database.
2. Add similar "No data" logic to stored procedure (if you're using SP) rather than having to change reports.
3. Create CE server group, add Page/Job/RAS to group then Stop/Start services using NET STOP "<service name>" via scheduled batch process.

Kingfisher [CECP]
 
Synapsevampire, I think you're right -- it's going to take some coding and maybe a couple of tables in the APS database. I do like the idea of a condescending message though!

Kingfisher, we've tried #1. When we set up a report, we use a specific account to connect to the database, so this seemed like a viable option for the 9 reports we want to restrict them from using. However, when you try to run a report using View and the saved account is disabled, the ActiveX viewer simply pops up a login box for the user to supply their account info. And they have individual accounts that we can't disable (that would get kind of messy anyway). That's actually a nice feature, but it defeats our objective which is a bummer.

Regarding #2, we're not using a SP. Regarding #3, I don't think on-demand report running (View) uses any server jobs. Please correct me if I'm wrong on that.

Thanks for all your input, folks.
--Bearden
 
Kingfisher: They want to turn off only some reports View capabilities, those will prevent users from doing anything (except number 2, but that presumes always using SPs and that here's no reusability across the SPs.

-k
 
Synapse: Couldn't they create a new Pageserver( and a group for it) and restrict those limited reports to using that server group only so that stopping that service only affects those reports?


[profile]
 
Try this code in available.csp.
At line 1907:
Code:
if(!actionMap[actionItem.Name]) 
{
[b]	var timeCheck = true;
	var timeNow = new Date().getHours();
	if ( actionItem.ID == -10000 ) // View on Demand
	if ( timeNow >= 3 && timeNow < 7 ) // Restricted hours
	if ( obj.title == "PayrollSplits.rpt" || // Controlled reports
		 obj.title == "PayrollSplitsPeriodOrgEmployee.rpt" )
		timeCheck = false;
	if ( timeCheck)
	{[/b]
		actionMenu += ",[\"" + actionItem.Name + "\", \"javascript:SetPreviewVars("+GetID(obj) + ",'" + realObj.Properties.Item("SI_PROGID") + "','" + Server.HTMLEncode(JSEncode(JSEncode(obj.Title))) + "'," + IsShortCut(obj) + "," + instId + "); handleAction(" + realObj.ID + " ,'" + actionItem.ID + "');\",1,0,0]";
		bNoActions = false;
[b]	}[/b]
}
}
}
}
actionMenu += tmpActionMenu;

And at line 2161:
Code:
if(!actionMap[actionItem.Name])
{
[b]	var timeCheck = true;
	var timeNow = new Date().getHours();
	if ( actionItem.ID == -10000 ) // View on Demand
	if ( timeNow >= 3 && timeNow < 7 ) // Restricted hours
	if ( obj.title == "PayrollSplits.rpt" || // Controlled reports
	     obj.title == "PayrollSplitsPeriodOrgEmployee.rpt" )
		timeCheck = false;
	if ( timeCheck)
	{[/b]
		if(!bFirst)
			Response.Write("<span class='list'> | </span>");
	    else
			bFirst = false;

		Response.Write("<a class='list' href=\"javascript:SetPreviewVars(" + GetID(obj) + ",'" + realObj.Properties.Item("SI_PROGID")+"','" + strJSReportTitle + "'," + IsShortCut(obj) + "," + instId+");handleAction(" + GetID(obj) + ",'" + actionItem.ID + "');\">" + actionItem.Name + "</a>");
[b]	}[/b]
}
}
}
}
for(var k in gActionArray)

I've included the closing braces and the first line that follows to provide context for the addition. (I also added some spaces to the long lines so they will display better here. Do not add the spaces to the existing code.)
 
Turk: An interesting idea, sounds like it would work, although they wouldn't receive a very gentle reminder ;)

Mwyer's solution looks promising...

-k
 
Thanks folks. I'm reading... just haven't been able to take any action on this due some other things going on. But from what I read in Turk's last post is that View does use the page server which kind of makes sense. And I've got a vague concept (and manuals) of how to set up additional server jobs and point reports to them.

Also Mwyer's post looks interesting. I'll have to work on setting up at least one table to hold the report names and possibly another to store the start and stop time for the reports to be disabled. But what mwyer posted takes care of most of the hard thinking, and thanks for that!

I'll add a post when I've had a chance to work on this -- next week.
 
If you like the idea of displaying a message to the user - it's a good training tool - you could slightly modify my code and put it at line 34 of actionscript.js. Display your message with something like: alert("You can't use this action between 3 and 7pm.");

I don't like the idea of hard-coding the report names either, so if you can identify them somehow, that would be better. A database table can be read with csp, but it's not straightforward. An OS file can be read too, and it's a bit easier. You can even use a #include to read the OS file without fancy javascript commands.

Also, be aware that these two csp solutions will not convert directly to CE10. The coding of Actions is substantially different in 10, but I am thinking the available.csp code is more transferrable than the actionscript.js approach. I am still copying my v9 customizations into 10, though, and have not even begun reconciling those areas of significant revision in Crystal's code. The whole 9-to-10 migration is a very low priority at this time.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top