How to know the value of record and field in an app package when running app engine? - peoplesoft

So I have this Application Engine that calls on this Application Package, this application package has a CreateSql(Select...) statement, and some of the records and fields are dynamic.
My question is -- how can i possibly know what value does these dynamic records and fields holds?
I tried doing a MessageBox on the application package but it does not show in the message logs in the Application Engine.
Any idea how to do this?

If you use MessageBox in an Application Engine, the message should appear in the stdout file. This file is formatted as follows:
AE_(appEngine name)_(process instance).stdout
This file should be visible via Process Monitor > Details > View Log/Trace. The messages in this file also get sent to Process Monitor > Details > Message Log. The only reason it doesn't appear there, is if you explicitly change the Output destination via ProcessRequest/SCHED_INFO/ReportDefn class. If not, your configuration is messed up.
If you can't get this to work, an option would be to setup your own logging:
Local string &sFileLoc = "C:\TEMP"; /* File location */
Local File &fileLog = GetFile(&sFileLoc , "A", %Exec_Synchronous + %FilePath_Absolute);
Local SQL &oSQL = CreateSQL("Select ...");
&fileLog.WriteLine("LOG FOR SQL STRING: " | &oSQL.Value);
While &oSQL.Fetch(&oOut)
/* Handle row returned by &oSQL */
&fileLog.WriteLine("...");
End-While;
&fileLog.WriteLine();
&fileLog.Close();

Related

Cannot open database requested by the login .Login failed for user

I have few aspx pages and and few tables in database. Each page connects to respective table. The purpose of each page is the same, only some condition are different. When I develop I use different database for testing data and called it "Database_DEV1" to be easy to remember. Now a problem is that only one page connects to the database (Database_DEV1) with same connection string. Other pages throws error with message:
Cannot open database "Database" requested by the login. The login failed.
Login failed for user 'xxx'
Why does it connect to "Database" if I provided connection string that refers to Database_DEV1?
Is it possible that this kind of error may appear at all? Do I miss something? I checked connection string I provided.
It looks like page "remembers" something different for some reason. I tried simple SqlConnection class and it works, but dbml file not.
update
Problem is that that Context refers to folder:
// C:\Users\xxx\AppData\Local\Temp\Temporary ASP.NET Files\root\0f053840_shadow\2edebf24\5576\App_Code.whnwybua.dll
At first, application connects using context that is declared in dbml. But when I do some actions it tries to connect using context which refers to dll file I described above. Why is that?

Permission for event log used in SSRS custom extension

we are have written one custom input language translator SSRS extension which gets input and convert it into another language and send back. In this extension we have written a code to write error messages using event logger. When we running our SSRS reports they are showing message error!. But we are not getting any error in event logger only in SSRS trace log it returns "Data not found at parameter 5".
Following is sample asp.net code. Please do let us know permissions needed on extension so that we can write event log. We are getting error at Eventlog.SourceExists in below code.
System.Diagnostics.EventLogPermission pEventLog = new EventLogPermission(System.Security.Permissions.PermissionState.Unrestricted);
pEventLog.Assert();
if (!EventLog.SourceExists("Report Server"))
{
myLog = new EventLog();
myLog.Source = "Report Server";
}
According to Microsoft, you will not be able to acquire EventLogPermission unless the process is running with Administrator permissions.
https://msdn.microsoft.com/en-us/library/system.diagnostics.eventlogpermission(v=vs.110).aspx
This sounds pretty risky to me. You might want to use a different logging mechanism (like Log4Net, etc).

Reporting in ASP.NET

I have an SQL Database and an ASP.NET website built to put data into the database.
One of the project requirements is to build a system that would let the user upload a Crystal Report to the server and run it as needed. This way, the user could create a customized report (for then turning into management, customers) that wouldn't force them to go through a developer.
I'm looking for suggestions on how to accomplish this goal.
Currently, I'm looking for a way to redirect the database connection in the Crystal Report from the database it was developed with to the database it will eventually run on. However, There doesn't seem to be a simple way to do this.
I'm also investigating the ReportViewer object. However, all the code I have seen involves specifying the query for the report in the code, which isn't acceptable.
One option (which I don't like at all) is to let them write their own queries so they can copy the results into Excel. This would mean a blank textbox and information about the structure of the database. Not a good idea for multiple reasons.
Another option is to create one report for each table (and maybe a few extras), let the user copy the data they want into Excel, and go on their merry way.
tl;dr How do I build a flexible reporting system?
=========================================
Continuation: 08/20/2012
I have decided to go the route of b.pell's extension methods. So far, it has gotten me closer than anything else. My code to bind to the CrystalReportViewer is below:
CrystalReportSource rs = new CrystalReportSource();
rs.Report.FileName = Server.MapPath("ReportFiles/") + Request["reportname"];
string connstring = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["myConnectionString"].ConnectionString;
rs.ReportDocument.ApplyCredentialsFromConnectionString(connstring);
rs.ReportDocument.ApplyNewDatabaseName("myDBName", "mySchemaName");
rs.ReportDocument.Refresh();
CrystalReportViewer1.ReportSource = rs;
This comes very close to working. It works fine on my dev machine, but when I run the code on the server, it gives the following error:
Logon failed.Error in File CrystalReport2 {5D2E82E5-783E-4DFD-A770-C8AE72A51E4E}.rpt:
Unable to connect: incorrect log on parameters. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Runtime.InteropServices.COMException: Logon failed.Error in File CrystalReport2 {5D2E82E5-783E-4DFD-A770-C8AE72A51E4E}.rpt: Unable to connect: incorrect log on parameters. Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
The error is in this line in the code:
crTable.Location = String.Format("{0}{1}", prefix, crTable.Location.Substring(crTable.Location.LastIndexOf(".") + 1))
When I remove the call to ApplyNewDatabaseName, I am asked to enter the Server Name, the Database name, the Username and the Password or to select Integrated Security. I can't enter the Database Name or the Server Name (those fields are disabled).
Any thoughts?
I think what you're looking for is the Reporting Services, part of Business Intelligence
Or maybe you can setup a UI that let the users pick the tables and columns they need for the report (this way you can limit the information they can access) an write a Dinamic Query Builder Function or something like that.
I answer the changing Crystal Reports connection question a lot (it's something I'd think Crystal would make easier, but I wonder if they don't because that's what their server product does). :D Anyway, you can set the database credentials at runtime. Crystal is very particular in the order it's done, but I have some code that I turned into extension methods that do the trick. This code will go through the main report and all sub reports and change the connection information. This assumes that all sub reports connect to the same database that the main report does (if not, you'll need to modify it to handle multiple connections, but this rarely comes up at least with what I do).
Extension methods to change connection info: http://www.blakepell.com/2012-05-22-crystal-reports-extension-methods
It would be used something like this (although, you're binding to a viewer probably and not exporting, so you could ignore that, this is just for example).
Using rd As New ReportDocument
rd.Load("C:\Temp\CrystalReports\InternalAccountReport.rpt")
rd.ApplyNewServer("serverName or DSN", "databaseUsername", "databasePassword")
rd.ApplyParameters("AccountNumber=038PQRX922;", True)
rd.ExportToDisk(ExportFormatType.PortableDocFormat, "c:\temp\test.pdf")
rd.Close()
End Using
System.Diagnostics.Process.Start("c:\temp\test.pdf")
You could use the Crystal Viewer at this point to deliver the reports and store the report in a database or on the file system (with a db meta data table) and have some predefined connections the user could select from that would be applied when it is run.
You also have the option to write your own front end. In this scenario a user would select a report from your meta data (you could put whatever security on it you wanted, I use AD). Then you can read the report parameters in and lay them out on the web form. When the user fills them in, you then sanatize them and pass them to the report via these extensions and you can output Excel, PDF, Word Doc, RTF, etc. A little more overhead and not the nice preview view, but can work well (I've done something like this in the past). Hope this helps.
About "...let them write their own queries" part of your question.
The solution can be to use some query builder component with friendly user interface which hides from users the complexity of your database and avoid any possible SQL injections.
There are few such products on the market. One of them is called EasyQuery, another one is build by Aspose if I'm not wrong. Try to search in Google for "query bulider for asp.net" or ".net query builder component".

I can logon only to SQL>

All the time when I'm trying login myself to sqlplus I log on to SQL> but I don`t know what I have to do to got Main user account for example [oracle#host01~] ?
The SQL> prompt is the default in SQLPlus. You can change it on the commnadline, once logged in, to a custom string. try:
set sqlprompt "_USER'#'_CONNECT_IDENTIFIER > "
to show your user and the DB you are connected to.
from this page, we can see the following default keywords that you can use:
_CONNECT_IDENTIFIER Connection identifier used to make connection, where available.
_DATE Current date, or a user defined fixed string.
_EDITOR Specifies the editor used by the EDIT command.
_O_RELEASE Full release number of the installed Oracle Database.
_O_VERSION Current version of the installed Oracle Database.
_PRIVILEGE Privilege level of the current connection.
_SQLPLUS_RELEASE Full release number of installed SQL*Plus component.
_USER User name used to make connection.

How to change data source in reportviewer control

I have a reportviewer (Microsoft.ReportViewer.WebForms) control on my page. All my reports use one data source. I want to be able to let my reports run on a different database when started from my UAT enviroment. So the location of the reports is the same, but the data comes from a different db. I cannot seem to find how this is done, is it even possible?
EDIT: They are server reports on SQL Server . I know you can set the dataset programmaticaly but I just want the reports to point to a different db and leave the rest of the report intact.
2005
TIA,
John
Did you want to pass a full connection string to the report as a parameter? You can do it but sometimes SSRS gets funny and make sure you delete the report off the server before you deploy a new copy when doing this...
1. Make a parameter - let's call ours connectionStr. Make it not null, not blank, single select and text as the data type. Eventually, you will want to hide this parameter but for testing please leave it visible.
2. So the value you will be using as the connection string... (for testing I set this as the default for the parameter, with nothing put under the available values section) Data Source=MySQLServerName;Initial Catalog=MyDatabaseName;Persist Security Info=True;User ID=MyUserNameForTheServer;Password=MyPasswordForTheServer;MultipleActiveResultSets=True
3. You need an unattended execution account on your report server or you get this: unattended execution account is not specified. (rsInvalidDataSourceCredentialSetting). http://msdn.microsoft.com/en-us/library/ms156302.aspx I can't provide more details because my boss had to do this part for me.
4. Under your datasource properties in SSRS... check Embedded Connection, select the type (mine is just a normal MS SQL Server), for the connection string, open the expression box and put: =Parameters!connectionStr.value and then click credentials and make sure the last option for no credentials is selected.
5. Your datasets for that datasource will no longer be happy when you try to edit them in design view but you can switch the datasource connection properties back to how they were, not using the parameter based connection string, for editing them.
My reports are on different servers, with different instances of the Report Server, too. On some servers, they need to get their data from various databases depending on whatever, stuff. This way, with the connection string as a parameter, I can use the same reports everywhere and just deploy them to the different servers. If you are having to pass this connection string around your app or to a report viewer, I suggest using encryption.
Like I said... SSRS get's funny when you start doing this, though. Your reports should always work in preview mode after doing this, if they don't even when provided with the correct connection strings, then you have an issue that won't be solved by just deploying to the server. Trouble shooting problems with this once they are on the server but not working include checking permissions, making sure the report receives the correct connection string and making all your stored procedures and functions within the SQL database are all the same.
If you want to just pass the database name and everything else is the same (server name, username, password) then just set the connection string parameter equal to your database name and for the datasource expression value use
="Data Source=MySQLServerName;Initial Catalog=" + Parameters!connectionString.value + ";Persist Security Info=True;User ID=MyUserNameForTheServer;Password=MyPasswordForTheServer;MultipleActiveResultSets=True"
I needed to pass the whole thing in, and you can play around with the credential settings - you might be able to save the server username/password info in there for each report so that the unattended execution account is not needed.

Resources