Re: Biztalk 2004: How to pass database facts from C# code?
- From: "Matt Milner" <matt.milner@m3technologypartners dot com>
- Date: Fri, 23 Jun 2006 09:08:46 -0500
Right before your typedxmldocument line, add this (making the appropriate
replacements for the strings):
DataConnection dc = new DataConnection("mydatabasename", "mytablename", new
SqlConnection("myconnectionstring"));
then, make your short term facts array have a length of two so you can add
this line right after you add your typed xml document.
shortTermFacts[1] = dc;
Matt
"Pankaj" <Pankaj@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:B5E90851-D1FC-46AF-8FC2-230F7C399064@xxxxxxxxxxxxxxxx
Thanks for the response Matt. Do you have any code sample links for doing
this? That would really help me.
"Matt Milner" wrote:
You can fill up a datatable and then wrap that in a TypedDataTable and
pass
it as a fact. Or, you can create a SQL connection and wrap it in the
DataConnection class. The one you choose will depend on how your rule
properties are configured. By default, they will expect the connection.
Highlight the database fact in the business rule editor and check the
properties to be sure. Be sure the string parameters you use to create
the
typeddatatable or the dataconnection match those in your rules.
Matt
"Pankaj" <Pankaj@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:FC4CDFAE-7A86-41F5-A155-167FDC818C02@xxxxxxxxxxxxxxxx
Hi
Tools: C#, .NET 1.1 and Biztalk 2004
I want to execute a policy rule which gets fired based on some input
xml
and
database facts. I am able to pass the input xml facts but how to I pass
the
database facts information before executing policy. Basically, by
passing
"Role" information, I want to get "Salary" values which are stored in a
database table.
Following is the code snippet:
--------------------------------------------------------------
Input XML:
<ns0:EmpInfo xmlns:ns0="http://EmployeeInfo.EmpInfo">
<Emp>
<Salary></Salary>
<Role>Manager</Role>
</Emp>
<Emp>
<Salary></Salary>
<Role>CIO</Role>
</Emp>
</ns0:EmpInfo>
--------------------------------------------------------------
----------------------------
public string Execute(string sRequestXML, out string sResponseXML, out
string sErrorMsg)
{
sResponseXML = string.Empty;
sErrorMsg = string.Empty;
DebugTrackingInterceptor dti = new
DebugTrackingInterceptor(@"C:\Biztalk\projects\EmployeeInfo\XSDs\jit.txt");
//create an instance of the XML object
XmlDocument xd1 = new XmlDocument();
xd1.Load(@"C:\Biztalk\projects\EmployeeInfo\XSDs\Copy of
EmpInfo_output.xml");
TypedXmlDocument doc1 = new TypedXmlDocument("EmpInfo",xd1);
// create the array of short-term facts
object[] shortTermFacts = new object[1];
shortTermFacts[0] = doc1;
Policy policy = null;
// now execute to see what happens
try
{
//Console.WriteLine("Grabbing the policy ...");
policy = new Policy("EmpInfo");
policy.Execute(shortTermFacts, dti);
FileInfo finfo = new
FileInfo(@"C:\Biztalk\projects\EmployeeInfo\XSDs\ProcessedRFP.xml");
StreamWriter writer = finfo.CreateText();
writer.Write(doc1.Document.OuterXml);
writer.Close();
}
catch (Exception ex)
{
FileInfo finfoError = new
FileInfo(@"C:\Biztalk\projects\EmployeeInfo\XSDs\Error.xml");
StreamWriter writerError = finfoError.CreateText();
writerError.Write(ex.Message);
writerError.Close();
}
dti.CloseTraceFile ();
policy = null;
return "PASS";
}
.
- Follow-Ups:
- References:
- Biztalk 2004: How to pass database facts from C# code?
- From: Pankaj
- Re: Biztalk 2004: How to pass database facts from C# code?
- From: Matt Milner
- Re: Biztalk 2004: How to pass database facts from C# code?
- From: Pankaj
- Biztalk 2004: How to pass database facts from C# code?
- Prev by Date: Re: Biztalk Rules composer
- Next by Date: Re: Passing XML data type to a SQL Server 2005 procedure (BizTalk 2006)
- Previous by thread: Re: Biztalk 2004: How to pass database facts from C# code?
- Next by thread: Re: Biztalk 2004: How to pass database facts from C# code?
- Index(es):
Relevant Pages
|