I try to use FastReport open source to build reports from data I'll provide to the report.
I've found what I want in the demos (https://github.com/FastReports/FastReport/tree/master/Demos/OpenSource/DataFromBusinessObject/DataFromBusinessObject)
In this demo, I see in the report file that a BusinessObjectDataSourceis used, which seems to be what I want to use.
However, I don't see a way to add this kind of source in the community designer. Do I need to add all of this manually ? Or is there a way to generate the needed markup ? I can't find the solution on their site.
I found a way by making the needed xml by hand like this:
<BusinessObjectDataSource Name="Invoices" ReferenceName="Invoices" Enabled="true">
<Column Name="Reference" DataType="System.String"/>
<Column Name="Date" DataType="System.String"/>
<Column Name="CompanyName" DataType="System.String"/>
<Column Name="InvoiceEmail" DataType="System.String"/>
<Column Name="VAT" DataType="System.String"/>
<Column Name="Street" DataType="System.String"/>
<Column Name="Number" DataType="System.String"/>
<Column Name="City" DataType="System.String"/>
<Column Name="ZipCode" DataType="System.String"/>
<Column Name="Country" DataType="System.String"/>
<Column Name="TotalPrice" DataType="System.Decimal"/>
<Column Name="VATValue" DataType="System.Decimal"/>
<Column Name="VATPercentage" DataType="System.Decimal"/>
<Column Name="VATComment" DataType="System.String"/>
</BusinessObjectDataSource>
The only drawback is that I need to update this if my object changes (but at least is is working !)
I found a way to generate an empty report with the fields generated from a business object.
You only have to create an empty report object, call "RegisterBusinessObject()" on its Dictionary property, and then save the report itself:
var report = new Report();
report.Dictionary.RegisterBusinessObject(
new List<Invoice>(), // a (empty) list of objects
"Invoices", // name of dataset
2, // depth of navigation into properties
true // enable data source
);
report.save(#"invoiceReport.frx");
You still need to update the report description if your object changes, but at least you don't have to code it by hand!
I have changed the logging in PingFederate to log to the database. Not only have I done this for the four log files that have the configuration prepared (audit, provisioner, provisioner_audit & server) I have also added appenders for all other log files with the exception of init.log. They are all logging to the database but there is missing data in most of the logs. My root section looks like the following:
<Root level="INFO" includeLocation="false">
<AppenderRef ref="ServerLogToSQLServerDB-FAILOVER" />
<AppenderRef ref="ProvisionerLogToSQLServerDB-FAILOVER" />
<AppenderRef ref="OutboundProvisionerEventToSQLServerDB-FAILOVER" />
<AppenderRef ref="SecurityAuditToSQLServerDB-FAILOVER" />
<AppenderRef ref="AdminLogToSQLServerDB-FAILOVER" />
<AppenderRef ref="AdminApiLogToSQLServerDB-FAILOVER" />
<AppenderRef ref="RuntimeApiLogToSQLServerDB-FAILOVER" />
<AppenderRef ref="TransactionLogToSQLServerDB-FAILOVER" />
<AppenderRef ref="AdminEventDetailLogToSQLServerDB-FAILOVER" />
</Root>
and my log4j2.db.properties file is also populated (obviously or I wouldn't have anything). I have also turned on the admin-event-detail log and that is logging too. I will use the audit log as an example and the JDBC Appender looks like this:
<JDBC name="SecurityAuditToSQLServerDB" tableName="log_audit" ignoreExceptions="false">
<ConnectionFactory class="com.pingidentity.log4j.LoggingDBConnectionPoolFactory" method="getSQLServerDatabaseConnection" />
<Column name="dtime" isEventTimestamp="true" />
<Column name="event" pattern="%X{event}" />
<Column name="username" pattern="%X{subject}" />
<Column name="ip" pattern="%X{ip}" />
<Column name="app" pattern="%X{app}" />
<Column name="host" pattern="%X{host}" />
<Column name="protocol" pattern="%X{protocol}" />
<Column name="role" pattern="%X{role}" />
<Column name="partnerid" pattern="%X{connectionid}" />
<Column name="status" pattern="%X{status}" />
<Column name="adapterid" pattern="%X{adapterid}" />
<Column name="description" pattern="%X{description}" />
<Column name="responsetime" pattern="%X{responsetime}" />
<Column name="trackingid" pattern="%X{trackingid}" />
</JDBC>
<RollingFile name="SecurityAuditToSQLServerDB-FILE" fileName="${sys:pf.log.dir}/audit-sqlserver-failover.log"
filePattern="${sys:pf.log.dir}/audit-sqlserver-failover.%d{yyyy-MM-dd}.log" >
<PatternLayout>
<pattern>%d | %X{event} | %X{subject} | %X{ip} | %X{app}| %X{host}| %X{protocol} | %X{role} | %X{connectionid} | %X{status}| %X{adapterid} | %X{description}| %X{responsetime} | %X{trackingid}| %n</pattern>
</PatternLayout>
<Policies>
<TimeBasedTriggeringPolicy />
</Policies>
</RollingFile>
<PingFailover name="SecurityAuditToSQLServerDB-FAILOVER" primary="SecurityAuditToSQLServerDB" retryIntervalSeconds="60">
<Failovers>
<AppenderRef ref="SecurityAuditToSQLServerDB-FILE" />
</Failovers>
</PingFailover>
When I check the two different logs (by switching back & forth from the original config file) the database does not have as much data as the file did.
File:
2017-12-14 09:27:23,803| tid:_IJBevZYwaRBmmMzfZ1SZ1VdKtM| AUTHN_ATTEMPT| | 0:0:0:0:0:0:0:1 | | | | <Host name removed>| IdP| inprogress| LoginFormAdapter| | 505
DB:
1 2017-12-14 10:22:10.663 0
I don't know if it is relevant but I have also written a class to override the Jetty logs and they are also logging to the database and seem fine except for the user-agent field.
I suspect that I have interrupted some flow with what I have done but I have no idea what. Does anyone know why or where I am losing this data.
Instead of putting all those AppenderRef's in your Root section, try changing the appropriate Logger section for each type of logger (like IdpAuditLogger, SpAuditLogger, etc.). You may be running into a conflict there with multiple appenders loaded, as per the comment in the file:
Each must be the only appender referenced in the logger org.sourceid.websso.profiles.idp.IdpAuditLogger. If one of these appenders is added, remove the existing reference to "SecurityAudit2File".
And mentioned in the documentation here: https://support.pingidentity.com/s/document-item?bundleId=pingfederate-93&topicId=coj1564002980835.html
Important: As indicated in the IMPORTANT comments for the loggers, you must also remove some of the existing appender references.
Trying to persist an object results in this exception being thrown. It complains about an incorrect type but then expects that same type. The exception started appearing after renaming the project from dbd2012_p2 to dbd2012_p3 (it's a continuation from the previous assignment).
I have found no information on Google about this exception. I've gone through the metadata files making sure there are no instances of dbd2012_p2 left behind and I am now stumped.
Our database is basically a many-to-many relationship: Prova with Tag. Mesura models the relationship with a few extra attributes (activity, datetime, x, y and z coords).
Exception
javax.jdo.JDOUserException: The owner field prova of element class dbd2012_p3.Mesura has an incorrect type "dbd2012_p3.Prova". Should be "dbd2012_p3.Prova"
javax.jdo.JDOUserException: The owner field prova of element class dbd2012_p3.Mesura has an incorrect type "dbd2012_p3.Prova". Should be "dbd2012_p3.Prova"
at org.datanucleus.api.jdo.NucleusJDOHelper.getJDOExceptionForNucleusException(NucleusJDOHelper.java:519)
at org.datanucleus.api.jdo.JDOPersistenceManager.jdoMakePersistent(JDOPersistenceManager.java:736)
at org.datanucleus.api.jdo.JDOPersistenceManager.makePersistent(JDOPersistenceManager.java:756)
...
at dbd2012_p3.dbd2012_p3.main(dbd2012_p3.java:28)
Code
for (String name : names) {
for (String seq : seqs) {
Prova prova = new Prova(name, seq);
pm.makePersistent(prova); // Exception thrown here
}
}
Prova.java
#PersistenceCapable
public class Prova {
#PrimaryKey //OJO
private String nom_persona = null;
#PrimaryKey
private String num_seq = null;
private Set tagRelations = new HashSet();
public Prova(String nou_nom_persona, String nou_num_seq) {
nom_persona = nou_nom_persona;
num_seq = nou_num_seq;
}
public Prova(){}
package-mysql.orm
This is how we have our tables defined:
<?xml version="1.0"?>
<!DOCTYPE orm SYSTEM "file:/javax/jdo/orm.dtd">
<orm>
<package name="dbd2012_p3">
<class name="Prova" type="application" table="prova">
<field name="nom_persona" primary-key="true">
<column name="nom_persona" length="45" jdbc-type="VARCHAR"/>
</field>
<field name="num_seq" primary-key="true">
<column name="num_seq" length="45" jdbc-type="VARCHAR"/>
</field>
<field name="tagRelations" persistence-modifier="persistent" mapped-by="prova">
<collection element-type="Mesura" />
</field>
</class>
<class name="Tag" type="application" table="tag">
<field name="codi" primary-key="true">
<column name="codi" length="45" jdbc-type="VARCHAR" />
</field>
<field name="nom">
<column name="nom" length="45" jdbc-type="VARCHAR" />
</field>
<field name="provaRelations" persistence-modifier="persistent" mapped-by="tag">
<collection element-type="Mesura" />
</field>
</class>
<class name="Mesura" type="datastore" table="mesura">
<field name="datetime" column="datetime"/>
<field name="prova" />
<field name="tag" />
<field name="activitat" />
<field name="x">
<column name="x" jdbc-type="DECIMAL" length="3" scale="1" />
</field>
<field name="y">
<column name="y" jdbc-type="DECIMAL" length="3" scale="1" />
</field>
<field name="z">
<column name="z" jdbc-type="DECIMAL" length="3" scale="1" />
</field>
</class>
</package>
</orm>
Note: I haven't tagged this as homework because the assignment is about applying data mining techniques to the data we add into the database. I can just rename the project back to its old name and it works again, but the exception is really bugging me.
Iam using LINQ To SQL with POCO's and XML mapping. I am getting the following error when I try to run the application: Cannot find type 'MyProject.DataTransfer.User' from mapping.
Below is the mapping:
<Table Name="Users" Member="User">
<Type Name= "MyProject.DataTrasnfer.User">
<Column Name="UserID" Member="UserID" DbType="Int NOT NULL IDENTITY" IsDbGenerated="true"
IsPrimaryKey="true"/>
<Column Name="UserName" Member="UserName" DbType="nvarchar(100) NOT NULL" />
<Column Name="Password" Member="Password" DbType="nvarchar(32)"/>
<Column Name="IsActive" Member="IsActive" DbType="bit NOT NULL"/>
<Column Name="InsertedBy" Member="InsertedBy" DbType="Int NOT NULL" />
<Column Name="InsertedDate" Member="InsertedDate" DbType="DateTime NOT NULL" />
<Column Name="UpdatedBy" Member="UpdatedBy" DbType="Int NOT NULL" />
<Column Name="UpdatedDate" Member="UpdatedDate" DbType="DateTime NOT NULL" />
<Column Name="Version" Member="Version" DbType="rowversion NOT NULL" IsDbGenerated="true"
IsVersion="true" AutoSync="Always"/>
</Type>
</Table>
But 'MyProject.DataTransfer.User' exists in the solution. What could be the possible reasons for this error?
Typo: MyProject.DataTrasnfer.User. You have transposed the s and the n.
I suppose that you have a class MyProject.DataTraSNfer.User in mapping and MyProject.DataTraNSfer.User in code. Misprint in post or in code?
I have two tables in a one to many relationship. (products and qty break pricing). At the database level I cannot create a relationship between the two tables. I brought those two tables into LINQ and created the association manually.
I need to do a big LINQ query and have the tables be joined. My problem is it's not using a join to get the data. LINQ is using 1 select on the main table, then 1 select for each row in that main table.
Dim db As New LSSStyleDataContext(connString)
Dim options As New DataLoadOptions()
options.LoadWith(Function(c As commerce_product) c.commerce_qty_breaks)
db.LoadOptions = options
Dim dbProducts = (From prods In db.commerce_products).ToList
Any thoughts on why this might be? Thanks!
Paul
EDIT: here are the two tables:
CREATE TABLE [dbo].[commerce_product](
[pf_id] [int] NOT NULL,
[name] [varchar](500) COLLATE SQL_Latin1_General_CP1_CI_AS
[description] [text] COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[restricted] [varchar](5) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
CONSTRAINT [PK_commerce_product_1] PRIMARY KEY NONCLUSTERED
(
[pf_id] ASC
) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
And the other table:
CREATE TABLE [dbo].[commerce_qty_break](
[pf_id] [int] NOT NULL,
[sku] [varchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[qty] [int] NOT NULL,
[list_price] [int] NOT NULL,
[break_id] [int] NOT NULL,
CONSTRAINT [PK_commerce_qty_break] PRIMARY KEY CLUSTERED
(
[pf_id] ASC,
[qty] ASC,
[break_id] ASC
) ON [PRIMARY]
) ON [PRIMARY]
The DBML is straight forward with only the two tables. I created an association between the two tables, "commerce_product" being the parent and "commerce_qty_break" being the child joined by "PF_ID".
I can write something like this:
Dim dbproducts = From prods In db.commerce_products _
Join qtys In db.commerce_qty_breaks On prods.pf_id Equals qtys.pf_id _
Select prods
And i see that it joins on the table in the query, but as soon as i try and spin through the "qty_breaks" it starts executing selects to get that info.
I'm totally stumped.
Edit 2: Here is the DBML:
<?xml version="1.0" encoding="utf-8"?>
<Database Name="LSScommerceDB_DevB" Class="LSSStyleDataContext" xmlns="http://schemas.microsoft.com/linqtosql/dbml/2007">
<Connection Mode="AppSettings" ConnectionString="***" SettingsObjectName="HSLPriceUpdate.My.MySettings" SettingsPropertyName="LSScommerceDB_DevBConnectionString" Provider="System.Data.SqlClient" />
<Table Name="dbo.commerce_product" Member="commerce_products">
<Type Name="commerce_product">
<Column Name="pf_id" Type="System.Int32" DbType="Int NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
<Column Name="name" Type="System.String" DbType="VarChar(500)" CanBeNull="true" />
<Column Name="description" Type="System.String" DbType="Text" CanBeNull="true" UpdateCheck="Never" />
<Column Name="list_price" Type="System.Int32" DbType="Int" CanBeNull="true" />
<Column Name="image_file" Type="System.String" DbType="VarChar(255)" CanBeNull="true" />
<Column Name="image_width" Type="System.Int32" DbType="Int" CanBeNull="true" />
<Column Name="image_height" Type="System.Int32" DbType="Int" CanBeNull="true" />
<Column Name="sale_price" Type="System.Int32" DbType="Int" CanBeNull="true" />
<Column Name="sale_start" Type="System.DateTime" DbType="DateTime" CanBeNull="true" />
<Column Name="sale_end" Type="System.DateTime" DbType="DateTime" CanBeNull="true" />
<Column Name="attr_label1" Type="System.String" DbType="VarChar(100)" CanBeNull="true" />
<Column Name="attr_label2" Type="System.String" DbType="VarChar(100)" CanBeNull="true" />
<Column Name="attr_label3" Type="System.String" DbType="VarChar(100)" CanBeNull="true" />
<Column Name="attr_label4" Type="System.String" DbType="VarChar(100)" CanBeNull="true" />
<Column Name="attr_label5" Type="System.String" DbType="VarChar(100)" CanBeNull="true" />
<Column Name="sku" Type="System.String" DbType="VarChar(100)" CanBeNull="true" />
<Column Name="UOM" Type="System.String" DbType="VarChar(50)" CanBeNull="true" />
<Column Name="Sell_Pack" Type="System.String" DbType="VarChar(50)" CanBeNull="true" />
<Column Name="mfg_model_number" Type="System.String" DbType="VarChar(50)" CanBeNull="true" />
<Column Name="mfg_id" Type="System.Int32" DbType="Int" CanBeNull="true" />
<Column Name="logo_file" Type="System.String" DbType="VarChar(255)" CanBeNull="true" />
<Column Name="drop_ship" Type="System.String" DbType="VarChar(50)" CanBeNull="true" />
<Column Name="lead_time" Type="System.Int32" DbType="Int" CanBeNull="true" />
<Column Name="hazard_flag" Type="System.String" DbType="VarChar(50)" CanBeNull="true" />
<Column Name="publish_date" Type="System.DateTime" DbType="DateTime" CanBeNull="true" />
<Column Name="restricted" Type="System.String" DbType="VarChar(5)" CanBeNull="true" />
<Association Name="commerce_product_commerce_qty_break" Member="commerce_qty_breaks" ThisKey="pf_id" OtherKey="pf_id" Type="commerce_qty_break" />
</Type>
</Table>
<Table Name="dbo.commerce_qty_break" Member="commerce_qty_breaks">
<Type Name="commerce_qty_break">
<Column Name="pf_id" Type="System.Int32" DbType="Int NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
<Column Name="sku" Type="System.String" DbType="VarChar(100) NOT NULL" CanBeNull="false" />
<Column Name="qty" Type="System.Int32" DbType="Int NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
<Column Name="list_price" Type="System.Int32" DbType="Int NOT NULL" CanBeNull="false" />
<Column Name="sale_price" Type="System.Int32" DbType="Int" CanBeNull="true" />
<Column Name="sale_start" Type="System.DateTime" DbType="DateTime NOT NULL" CanBeNull="false" />
<Column Name="sale_end" Type="System.DateTime" DbType="DateTime" CanBeNull="true" />
<Column Name="break_id" Type="System.Int32" DbType="Int NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
<Association Name="commerce_product_commerce_qty_break" Member="commerce_product" ThisKey="pf_id" OtherKey="pf_id" Type="commerce_product" IsForeignKey="true" />
</Type>
</Table>
</Database>
EDIT 3: Apparently this is only an issue in SQL 2000. SQL 2008 works fine. I have other tables that do eager loading in SQL 2000 and i can't figure out what the difference is between these two tables.
I created a VB console app and created the schema as you have it here.
Also - the relationship is PK -> PK so does this mean it's supposed to be a one-to-one relationship?
I populated the tables with a row each (see below) and ran the code you've listed above. I ran SQL Profiler and it only queried once:
SELECT [t0].[pf_id], [t0].[name], [t0].[description], [t0].[restricted],
[t1].[pf_id] AS [pf_id2], [t1].[sku], [t1].[qty], [t1].[list_price],
[t1].[break_id], (
SELECT COUNT(*)
FROM [dbo].[commerce_qty_break] AS [t2]
WHERE [t2].[pf_id] = [t0].[pf_id]
) AS [value]
FROM [dbo].[commerce_product] AS [t0]
LEFT OUTER JOIN [dbo].[commerce_qty_break] AS [t1] ON [t1].[pf_id] = [t0].[pf_id]
ORDER BY [t0].[pf_id], [t1].[qty], [t1].[break_id]
I wanted to make sure that the Data Options was forcing a deep load, so I added some extra code - here's the full code I used (and only the single query as above was traced):
Dim options As New DataLoadOptions()
options.LoadWith(Function(c As commerce_product) c.commerce_qty_breaks)
db.LoadOptions = options
Dim dbProducts = (From prods In db.commerce_products).ToList
Dim dbProduct = dbProducts.First().commerce_qty_breaks
Dim x = dbProduct.First().list_price
Here's the test data:
INSERT INTO [Test].[dbo].[commerce_product] ([pf_id],[name],[description],[restricted]) VALUES (1,'Test','Test','Test')
GO
INSERT INTO [Test].[dbo].[commerce_qty_break] ([pf_id],[sku],[qty],[list_price],[break_id]) VALUES (1,'22',1,1,1)
GO
hey, not sure i completely understood your question, but here's some info,
By default LINQ to SQL adopts lazy binding, meaning it won't query the database until it needs to. That's why you're getting multiple queries.
There are few things you can do to avoid multiple hits on the DB:
You can turn off lazy binding globally in the LINQ to SQL designer. But then you'll always perform JOINS if your tables have any relationships.
You do the JOIN manually in the LINQ query. If you do this, you'll have to specify which "fields" you want to return in your LINQ query to get back the JOINED data. And if you do this, then you'll be returning an Anonymous type
NOTE: LINQ to SQL doesn't support LEFT JOINS. If you google LINQ to SQL Left Joins you'll see plenty of info on this particular subject
cheers, and good luck!
Go grab LINQPad. It's great for playing with stuff like this.
Did you try something like this?
Dim dbproducts = From prods In db.commerce_products _
Join qtys In db.commerce_qty_breaks On prods.pf_id Equals qtys.pf_id _
Select new {prods, qtys}
I ended up using the entity framework and all is well.