Adding Custom source to a process
- Hai,
I am completely new to BizTalk RFID. I know how to add a custom source to the process through the wizard.
Now i want to know how can i achieve this through code. Pls give me some sample code or give me some reference links.
Thank u so much
Regards
Neelam
Answers
Hai Neelam,
Please go through ProcessManagerProxy class. It helps to create, control rfid process (start / stop/ pause) through code.
Different methods on ProcessManagerProxy like GetProcess, GetProcessStatus need to be used.
We need to stop the process before we modify its structure. Build the custom logical source and then add to logicalsourcelist of the primary logical source in the process Definition. GetProcess method on ProcessMangerProxy gets us the process definition.
const string rfidServerName = @"localhost";
ProcessManagerProxy pmp = new ProcessManagerProxy(rfidServerName);
const string processName = @"MyProcess";
RfidProcessStatus[] processesStatus = pmp.GetProcessStatus(new string[] {processName});
if( processesStatus.Count() == 1 &&
(
processesStatus[0].ExecutionState == ExecutionState.Starting ||
processesStatus[0].ExecutionState == ExecutionState.EventCollecting
)
)
{
pmp.StopProcess(processName,false);
}
//Gets the object of the defined process
RfidProcess myProcess = pmp.GetProcess(processName);
#region Defining custom logical source to be embedded
LogicalSource embeddedCustomSource = new LogicalSource();
embeddedCustomSource.LogicalSourceList = new Collection<LogicalSource>();
embeddedCustomSource.LogicalDeviceList = new Collection<LogicalDevice>();
embeddedCustomSource.ComponentList = new Collection<EventHandlerDefinition>();
//Adding Logical devices to embedded custom sources
embeddedCustomSource.LogicalDeviceList.Add(new LogicalDevice("SubLS_LD1", @"SubLogicalSrc's Device1"));
embeddedCustomSource.LogicalDeviceList.Add(new LogicalDevice("SubLS_LD2", @"SubLogicalSrc's Device2"));
//Adding only Sql Sink EH in the embedded Custom source.
embeddedCustomSource.ComponentList.Add(SqlServerSink.CreateDefaultEventHandlerDefinition());
#endregion
myProcess.LogicalSource.LogicalSourceList.Add(embeddedCustomSource);
pmp.SaveProcess(myProcess);
- Marked As Answer byNeelathamara Thursday, October 08, 2009 9:27 AM
All Replies
- Hai Neelam,
Pls go thru msdn link RFIDProcess(http://msdn.microsoft.com/en-us/library/microsoft.sensorservices.rfid.design.rfidprocess(BTS.10).aspx)
LogicalSource is a recursive structure and can have sub logical sources.
Sub logical Sources can be accessed through logicalSource.LogicalSourceList
Thanks,
Srujan. - hai Surjan,
i was asking about adding embedded custom source to a process. It can be done through wizard . It is explained in the following link
http://msdn.microsoft.com/en-us/library/dd352348(BTS.10).aspx
i wan to do the same through code . Please help me..
Regards.
Neelam - Hai Neelam,
Please go through the following code and process main LS structure. LS has two embedded logical sources subLS1,subLS2. subLS1 structure is also given for an idea.
LS
| LogicalDeviceList {LD1,LD2,LD3}
|
| LogicalSourceList {subLS1,subLS2}
|
| ComponentList {C1,C2}
subLS1
| LogicalDeviceList {subLSLD1,subLSLD2}
|
| LogicalSourceList
|
| ComponentList {C3}
The code just adds one embedded custom logical source. Similarly the embedded sources can embed another logical source.
RfidProcess process = new RfidProcess(); process.Name = "MyRfidProcess1";
// process.LogicalSource - Main Process Source LogicalSource embeddedCustomSource = new LogicalSource(); embeddedCustomSource.LogicalSourceList = new Collection<LogicalSource>(); embeddedCustomSource.LogicalDeviceList = new Collection<LogicalDevice>(); embeddedCustomSource.ComponentList = new Collection<EventHandlerDefinition>(); //Adding Logical devices to embedded custom sources embeddedCustomSource.LogicalDeviceList.Add(new LogicalDevice("SubLS_LD1",@"SubLogicalSrc's Device1")); embeddedCustomSource.LogicalDeviceList.Add(new LogicalDevice("SubLS_LD2", @"SubLogicalSrc's Device2")); //Adding only Sql Sink EH in the embedded Custom source. embeddedCustomSource.ComponentList.Add(SqlServerSink.CreateDefaultEventHandlerDefinition()); //Adding embedded custom source1 to process MainLogical Source. process.LogicalSource.LogicalSourceList.Add(embeddedCustomSource);
Hai Neelam,
Please go through ProcessManagerProxy class. It helps to create, control rfid process (start / stop/ pause) through code.
Different methods on ProcessManagerProxy like GetProcess, GetProcessStatus need to be used.
We need to stop the process before we modify its structure. Build the custom logical source and then add to logicalsourcelist of the primary logical source in the process Definition. GetProcess method on ProcessMangerProxy gets us the process definition.
const string rfidServerName = @"localhost";
ProcessManagerProxy pmp = new ProcessManagerProxy(rfidServerName);
const string processName = @"MyProcess";
RfidProcessStatus[] processesStatus = pmp.GetProcessStatus(new string[] {processName});
if( processesStatus.Count() == 1 &&
(
processesStatus[0].ExecutionState == ExecutionState.Starting ||
processesStatus[0].ExecutionState == ExecutionState.EventCollecting
)
)
{
pmp.StopProcess(processName,false);
}
//Gets the object of the defined process
RfidProcess myProcess = pmp.GetProcess(processName);
#region Defining custom logical source to be embedded
LogicalSource embeddedCustomSource = new LogicalSource();
embeddedCustomSource.LogicalSourceList = new Collection<LogicalSource>();
embeddedCustomSource.LogicalDeviceList = new Collection<LogicalDevice>();
embeddedCustomSource.ComponentList = new Collection<EventHandlerDefinition>();
//Adding Logical devices to embedded custom sources
embeddedCustomSource.LogicalDeviceList.Add(new LogicalDevice("SubLS_LD1", @"SubLogicalSrc's Device1"));
embeddedCustomSource.LogicalDeviceList.Add(new LogicalDevice("SubLS_LD2", @"SubLogicalSrc's Device2"));
//Adding only Sql Sink EH in the embedded Custom source.
embeddedCustomSource.ComponentList.Add(SqlServerSink.CreateDefaultEventHandlerDefinition());
#endregion
myProcess.LogicalSource.LogicalSourceList.Add(embeddedCustomSource);
pmp.SaveProcess(myProcess);
- Marked As Answer byNeelathamara Thursday, October 08, 2009 9:27 AM
- Hai Surjan,
Your reply was really helpful. Thank you so much ..
Your second reply itself is really encouraging .. Expecting your help in future also..
- Unmarked As Answer byNeelathamara Thursday, October 08, 2009 9:27 AM
- Marked As Answer byNeelathamara Thursday, October 08, 2009 9:16 AM
- hai Srujan,
I tired your reply and it is working now. I just want to ask you one doubt.
In defining the custom source the logical source list is added. Is that necessary?. I tried to define a custom source without adding a logicalsourcelist . It is woring fine . I don't know whether it will create some problem in future or not. I just want to know why we are adding the logical source list? Will u explain it .Please ..?
Regards ,
Neelam
embeddedCustomSource.LogicalSourceList = new Collection<LogicalSource>();
The above line in my code (2nd and 3rd replies) is not really necessary since there are no custom sources to be added for this source(embeddedCustomLogicalSource).
Even there are customsources, the above line is not required. Infact the following lines of code are unnecessary.
The initializations are part of LogicalSource constructor itself.
embeddedCustomSource.LogicalSourceList = new Collection<LogicalSource>();
embeddedCustomSource.LogicalDeviceList = new Collection<LogicalDevice>();
embeddedCustomSource.ComponentList = new Collection<EventHandlerDefinition>();
Sorry for the confusion.- Hai Surjan,
Thanks for your reply. I am totally new to this BizTalk that's why i asked the doubt. Now it is clear to me.
Thank you so much..
With the expectation of help in future also,
Neelam.

