I have a requirement of generating the rdl in runtime. so I converted the http://schemas.microsoft.com/sqlserver/reporting/2005/01/reportdefinition xsd to class and I need to create object for Report class with that it has lot of classes. I am struggling in the report generation using objects
I don't know how to assign values
[System.Xml.Serialization.XmlAnyElementAttribute()]
[System.Xml.Serialization.XmlElementAttribute("Author", typeof(string))]
[System.Xml.Serialization.XmlElementAttribute("AutoRefresh", typeof(uint))]
[System.Xml.Serialization.XmlElementAttribute("Body", typeof(BodyType))]
private ItemsChoiceType37[] itemsElementNameField;
Please help me.
It is something like
List<object> items = new List<object>();
List<ItemsChoiceType37> itemChoices = new List<ItemsChoiceType37>();
//Author
items.Add("Author name");
itemChoices.Add(ItemsChoiceType37.Author);
items.Add(description);
itemChoices.Add(ItemsChoiceType37.Description);
//Width
items.Add("11in");
itemChoices.Add(ItemsChoiceType37.Width);
.
.
.
Report report = new Report();
report.Items = items.ToArray();
report.ItemsElementName = itemChoices.ToArray();
I hope it may help you
Related
I'm trying to create an SSIS package dynamically using DTS Runtime classes.
I'm trying to create a foreach loop using "Foreach From Variable Enumerator", where my variable contains an ArrayList with the necessary collection.
I'm unable to find a way through which i can set the variable (under enumerator configuration, as seen in VS) which will hold the collection for looping.
I'm not finding any options in forEachLoop.ForEachEnumerator. Nor am I able to cast forEachEnumeratorHost.InnerObject to an enumerator I want. I found on MSDN a class Microsoft.SqlServer.Dts.Runtime.Enumerators.FromVar.ForEachFromVarEnumerator. But I'm not able to find the FromVar class in Enumerators. Am i missing something grave?
Has anyone else done this? I find it difficult to believe that something which can be done so easily through Visual Studio UI, cannot be done programmatically.
Below is the code I have now...
ForEachLoop forEachLoop = p.Executables.Add("STOCK:FOREACHLOOP") as
ForEachLoop;
// Create a VariableMappings and VariableMapping objects.
ForEachVariableMapping forEachVariableMapping =
forEachLoop.VariableMappings.Add();
// Create a mapping between the variable and its value.
forEachVariableMapping.VariableName = #"User::CurrentTableName";
forEachVariableMapping.ValueIndex = 0;
ForEachEnumeratorInfo forEachEnumeratorInfo =
runtimeApp.ForEachEnumeratorInfos["Foreach From Variable Enumerator"];
ForEachEnumeratorHost forEachEnumeratorHost =
forEachEnumeratorInfo.CreateNew();
You are almost there...I think you are forgetting to set the ForEachEnumerator property of the forEachLoop object.
ForEachLoop forEachLoop = p.Executables.Add("STOCK:FOREACHLOOP") as ForEachLoop;
ForEachEnumeratorInfo forEachEnumeratorInfo = runtimeApp.ForEachEnumeratorInfos["Foreach From Variable Enumerator"];
ForEachEnumeratorHost forEachEnumeratorHost = forEachEnumeratorInfo.CreateNew();
//forEachEnumeratorHost.CollectionEnumerator = false; // true or false; set accordingly.
// cast the inner object to ForEachFromVarEnumerator
ForEachFromVarEnumerator = forEachEnumeratorHost.InnerObject as ForEachFromVarEnumerator;
// Now that you have the ForEachFromVarEnumerator, set its properties.
// For variable name, do not forget the variable's name space and the variable name (separated by ::)
ForEachFromVarEnumerator.VariableName = "var_namespace" + "::" + "var_name";
// finally.....
forEachLoop.ForEachEnumerator = forEachEnumeratorHost; // DO NOT FORGET THIS. Here you are setting what the actual enumerator would be
You can do like this:
Script task
Make sure MyList variable is Writeable
ArrayList NewList = new ArrayList();
NewList.Add("Ost");
NewList.Add("Hest");
Dts.Variables["User::MyList"].Value = NewList;
Dts.TaskResult = (int)ScriptResults.Success;
The first step is
Add an assembly reference to Microsoft.SqlServer.ForEachFromVarEnumerator.dll and then one can get access to the Microsoft.SqlServer.Dts.Runtime.Enumerators.FromVar.ForEachFromVarEnumerator class.
And then the rest of the answer is exactly what #Sam has mentioned above.
How to use ItemBand in Subreport when coding it with Pentaho Reporting Engine?
I have defined my ItemBand as follow :
ItemBand rowBand = new ItemBand();
TextFieldElementFactory textFactory3 = new TextFieldElementFactory();
textFactory3.setFieldname("reportname");
Element element = textFactory3.createElement();
element.setDynamicContent(true);
rowBand.addElement(element);
itemBand2.addElement(rowBand);
Now how do I use the ItemBand in my subreport?
Tests for the project are usually helpfull in such cases https://github.com/pentaho/pentaho-reporting/blob/85b5bb6c1b970f1c2648a6bf06b7cf66b9fd0c0b/engine/core/test-src/org/pentaho/reporting/engine/classic/core/SubReportIT.java
Thanks,
I was able to do it by :
RelationalGroup subgroup = new RelationalGroup();
GroupDataBody subgroupData = new GroupDataBody();
ItemBand itemBand = new ItemBand();
itemBand.setVisible(true);
subgroupData.setItemBand(itemBand);
subgroup.setBody(subgroupData);
subReport.setRootGroup(subgroup);
ItemBand rowBand = new ItemBand();
rowBand.setLayout(BandStyleKeys.LAYOUT_ROW);
TextFieldElementFactory subtext = new TextFieldElementFactory();
subtext.setFieldname("reportname");
subtext.setX(new Float(12.0));
subtext.setMinimumWidth(new Float(100.0));
subtext.setHeight(new Float(20.0));
Element subelement = subtext.createElement();
subelement.setDynamicContent(true);
rowBand.addElement(subelement);
TextFieldElementFactory subtext2 = new TextFieldElementFactory();
subtext2.setFieldname("reportheader");
subtext2.setX(new Float(112.0));
subtext2.setMinimumWidth(new Float(100.0));
subtext2.setHeight(new Float(20.0));
Element subelement2 = subtext2.createElement();
subelement2.setDynamicContent(true);
rowBand.addElement(subelement2);
itemBand.addElement(rowBand);
report.getReportFooter().addSubReport(subReport);
I am facing some wierd issue with my RDLC file.
I have created some RDLC file for them which is throwing Microsoft.Reporting.WinForms.LocalReport.SetParameters(IEnumerable1 parameters)` error while calling.
I was using some parameters in a table and that table is associated to one dataset. When I remove the parameter from the table it's running fine.
Can't we use any parameters in a table in RDLC? The problem is if I am not putting this parameter inside the table it's very difficult to handle report layouts.
This is the code has been used to call the report.
LocalReport localReport = new LocalReport();
List<ReportParameter> reportParams = new List<ReportParameter>();
localReport.ReportPath = Path.Combine(reportPath, reportRequest.ReportName);
...
PMClientReportRequestDTO pmJUS = reportRequest as PMClientReportRequestDTO;
...
reportParams.Add(new ReportParameter("jusStoreAddress", storeAddress));
reportParams.Add(new ReportParameter("Culture", pmJUS.Culture));
localReport.ReportPath = Path.Combine(reportPath, pmJUS.ReportName + ".rdlc");
localReport.DataSources.Add(new ReportDataSource("PurchasedMetalItems", pmJUS.PurchaseItems));
....
localReport.SetParameters(reportParams);
I am transferring some data from one table to another using SSIS with EzAPI. How can I get the number of rows that were transferred?
My setup is as follows
EzPackage package = new EzPackage();
EzOleDbConnectionManager srcConn;
EzOleDbSource src;
EzOleDbConnectionManager destConn;
EzOleDbDestination dest;
EzDataFlow dataFlow;
destConn = new EzOleDbConnectionManager(package); //set connection string
srcConn = new EzOleDbConnectionManager(package);
dataFlow = new EzDataFlow(package);
src = Activator.CreateInstance(typeof(EzOleDbSource), new object[] { dataFlow }) as EzOleDbSource;
src.Connection = srcConn;
src.SqlCommand = odbcImport.Query;
dest = Activator.CreateInstance(typeof(EzOleDbDestination), new object[] { dataFlow }) as EzOleDbDestination;
dest.Connection = destConn;
dest.AttachTo(src, 0, 0);
dest.AccessMode = AccessMode.AM_OPENROWSET_FASTLOAD;
DTSExecResult result = package.Execute();
Where in this can I add something to get the number of rows? For all versions of SQL server 2008r2 and up
The quick answer is that the Row Count Transformation isn't included out of the box. I had a brief post about that: Row Count with EzAPI
I downloaded the source project from CodePlex and then edited EzComponents.cs (in EzAPI\src) and added the following code
[CompID("{150E6007-7C6A-4CC3-8FF3-FC73783A972E}")]
public class EzRowCountTransform : EzComponent
{
public EzRowCountTransform(EzDataFlow dataFlow) : base(dataFlow) { }
public EzRowCountTransform(EzDataFlow parent, IDTSComponentMetaData100 meta) : base(parent, meta) { }
public string VariableName
{
get { return (string)Meta.CustomPropertyCollection["VariableName"].Value; }
set { Comp.SetComponentProperty("VariableName", value); }
}
}
The component id above is only for 2008.
For 2012, it's going to be E26997D8C-70DA-42B2-8208-A19CE3A9FE41 I don't have a 2012 installation at the moment to confirm I didn't transpose a value there but drop a Row Count component onto a data flow, right click and look at the properties. The component/class id is what that value needs to be. Similar story if you're dealing with 2005.
So, once you have the ability to use EzRowCountTransform, you can simply patch it into your existing script.
// Create an instance of our transform
EzRowCountTransform newRC = null;
// Create a variable to use it
Variable newRCVariable = null;
newRCVariable = package.Variables.Add("RowCountNew", false, "User", 0);
// ...
src.SqlCommand = odbcImport.Query;
// New code here too
newRC = new EzRowCountTransform(dataFlow);
newRC.AttachTo(src);
newRC.Name = "RC New Rows";
newRC.VariableName = newRCVariable.QualifiedName;
// Continue old code
I have a presentation on various approaches I've used over time and what I like/don't like about them. Type more, click less: a programmatic approach to building SSIS. It contains sample code for creating the EzRowCountTransform and usage.
I am new to Linq and trying to get a handle on how to bind a drop down to a SQL user defined function.
//Populate the Pledge dropdown
var db = new App_Data.MyDBDataContext();
int? partnerID = Convert.ToInt32(Request.QueryString["PartnerID"]);
var pledges =
from p in db.ufn_AvailablePledgesByPartner(partnerID)
select new
{
PledgeAndPartnerName = p.PledgeAndPartnerName,
PledgeID = p.PledgeID
};
DropDownList ddlPledgeID = (DropDownList)DetailsViewContribution.FindControl("DropDownListPledgeID");
ddlPledgeID.DataSource = pledges;
ddlPledgeID.DataTextField = pledges.PledgeAndPartnerName;
ddlPledgeID.DataValueField = pledges.PledgeID;
The current problem is the last 2 lines where I'm trying to reference properties of the anonymous class. "'System.Linq.IQueryable' does not contain a definition for 'PledgeAndPartnerName' and no extension method..." I naively thought the compiler was supposed to figure this out, but obviously I'm assuming C# is now more dynamic than it really is.
Thanks for any input.
Try this:
ddlPledgeID.DataTextField = "PledgeAndPartnerName";
ddlPledgeID.DataValueField = "PledgeID";