Skip to content

Commit 1778d28

Browse files
committed
fix doc
1 parent d33dbf7 commit 1778d28

File tree

2 files changed

+56
-102
lines changed
  • Tracking-and-Troubleshooting-BizTalk-Applications

2 files changed

+56
-102
lines changed

Tracking-and-Troubleshooting-BizTalk-Applications/Moving-Event-Source-To-Different-Event-Log/README.md

+53-79
Original file line numberDiff line numberDiff line change
@@ -1,95 +1,69 @@
1-
# BizTalk Mapper: How to create a custom If-Then-Else Functoid
1+
# Moving Event Source To Different Event Log (Administration)
22

33
# Introduction
4-
Sometimes I ask myself: Why is so hard to make a simple If-Then-Else Functoid, or even so painful to do an If-Then-Else operation, using BizTalk mapper?
4+
Many time in BizTalk developers like to write informations that will help them tracking and debuging there orchestrations like:
5+
* Message received
6+
* Message successfully Transformed
7+
* Message sent to external system
58

6-
I don't mean to say that it is complicated, quite the opposite, is quite easy to make If…Then…Else statements using the Mapper. You can use **If...Then...Else** statements, to be completely correct, you can use something related to an **If...Then...Else** statements, to execute blocks of statements depending on the **Boolean** value of a condition by, normally, using:
7-
* One **Logical Functoid** (Logical Existence, Logical String, Logical Numeric, Equal, Greater Than, Less Than and so on) to determine:
8-
* whether the Record, Field Element, or Field Attribute node that is linked to it exists or have a valid value in a particular input instance message
9-
* or if a condition match.
10-
* One **Logical NOT Functoid** to negate the Logical Functoid
11-
* And two **Value Mapping Functoids** to returns the value that we want to linked based on the result of the condition
9+
And for that they normally use the following code:
10+
11+
System.Diagnostics.EventLog.WriteEntry("AnnoyingTord3",
12+
"Just an update Tord! Message successfully Transformed");
13+
1214

13-
However, if you want to create a custom If-Then-Else Functoid, you will find that, out-of-the-box, it is impossible to create a custom functoid based on a Logical Functoid and the reason why this is true is that, all Logical Functoids available out-of-the-box with BizTalk only accept the following outputs connection types:
14-
* ConnectionType.Element
15-
* ConnectionType.FunctoidAssert
16-
* ConnectionType.FunctoidNilValue
17-
* ConnectionType.FunctoidKeyMatch
18-
* ConnectionType.FunctoidTableLooping
19-
* ConnectionType.FunctoidValueMapping
20-
* ConnectionType.FunctoidScripter
21-
* ConnectionType.FunctoidLogical
22-
* ConnectionType.FunctoidString is not allowed in all the existing Logical Functoids. And that is the reason why you will find impossible to create a custom functoid based on a Logical functoid (don’t know the reason why Microsoft decide to implement this limitation)
15+
The problem using this code is that by default in the Application Log. Application event log is used to application installed in your server/machine like BizTalk Server to log the exceptions or problems and you should keep it clean. in other to proper monitor and find problems with your environment.
16+
17+
And also this are unnecessary information that is being logged in the Application Log in that don't provide any additional information to BizTalk Administrators.
2318

2419
# Building the Sample
25-
What I want to archive is create a custom functoid that accepts 3 inputs:
26-
* A Boolean - the result of a previous Logical Functoid (Logical Existence, Logical String, Logical Numeric, Equal, Greater Than, Less Than and so on)
27-
* And two inputs
20+
In this sample you will find a simple orchestration that will receive any XML message and will log some traditional tracking information that developers normally do in their orchestrations… I call this trying to annoying Tord Glad Nordahl (my friend and one of the best BizTalk Administrator that I know) and that is always complaining about developer doing this.
21+
22+
![Moving Event Source To Different Event Log](media/Annoying-Tord.png)
2823

29-
Were the custom Functoid will return a value from one of two input parameters based on a condition.
30-
* If the condition (first input) is True, then the value of the second input parameter is returned;
31-
* Otherwise the Third input is returned.
24+
## What is that the Admin does normally?
25+
They ask the developer to change is code, that already is deployed in all the environments, to not write in the application log
3226

33-
![custom If-Then-Else Functoid](media/BizTalk-custom-if-then-else-condition.png)
27+
However change is hard - Getting others to change can be impossible or a big challenge
3428

35-
# Functoid Code
29+
## What is that the Admin should do?
30+
Let the developer by happy by writing in the Event Viewer...
31+
32+
But take back the control of your environment by easily creating or using PowerShell script
3633

3734

38-
namespace BizTalk.CustomAdvanced.Functoids
39-
{
40-
[Serializable]
41-
public class IfThenElse : BaseFunctoid
42-
{
43-
public IfThenElse()
44-
: base()
45-
{
46-
//ID for this functoid
47-
this.ID = 10900;
48-
49-
// resource assembly must be ProjectName.ResourceName if building with VS.Net
50-
SetupResourceAssembly("BizTalk.Logical.Functoids.LogicalResources", Assembly.GetExecutingAssembly());
51-
52-
//Setup the Name, ToolTip, Help Description, and the Bitmap for this functoid
53-
SetName("IDS_IFELSEFUNCTOID_NAME");
54-
SetTooltip("IDS_IFELSEFUNCTOID_TOOLTIP");
55-
SetDescription("IDS_IFELSEFUNCTOID_DESCRIPTION");
56-
SetBitmap("IDS_IFELSEFUNCTOID_BITMAP");
57-
58-
//category for this functoid. This functoid goes under the String Functoid Tab in the
59-
this.Category = FunctoidCategory.String;
60-
61-
// Set the limits for the number of input parameters. This example: 1 parameter
62-
this.SetMinParams(3);
63-
this.SetMaxParams(3);
64-
65-
// Add one line of code as set out below for each input param. For multiple input params, each line would be identical.
66-
this.AddInputConnectionType(ConnectionType.AllExceptRecord); //first input
67-
this.AddInputConnectionType(ConnectionType.AllExceptRecord); //Second input
68-
this.AddInputConnectionType(ConnectionType.AllExceptRecord); //Third input
69-
70-
// The functoid output can go to any node type.
71-
this.OutputConnectionType = ConnectionType.AllExceptRecord;
72-
73-
SetScriptBuffer(ScriptType.CSharp, this.GetCSharpBuffer());
74-
HasSideEffects = false;
75-
}
76-
77-
private string GetCSharpBuffer()
78-
{
79-
StringBuilder builder = new StringBuilder();
80-
builder.Append("public string IfThenElseOperation(string condition, string trueValue, string falseValue)\n");
81-
builder.Append("{\n");
82-
builder.Append("\tif (System.Convert.ToBoolean(condition))\n");
83-
builder.Append("\t\treturn trueValue;\n");
84-
builder.Append("\treturn falseValue;\n");
85-
builder.Append("}\n");
86-
return builder.ToString();
87-
}
88-
}
35+
foreach ($LogSource in $LogSources) {
36+
Remove-EventLog -Source $LogSource
37+
}
38+
39+
$logFileExists = Get-EventLog -list | Where-Object {$_.logdisplayname -eq $LogName}
40+
if (! $logFileExists) {
41+
$LogSources | %{
42+
New-EventLog -LogName $LogName -Source $_
43+
}
44+
45+
# Compose Key:
46+
$LogPath = 'HKLM:\SYSTEM\CurrentControlSet\services\eventlog\'+$LogName;
47+
if(Test-Path $LogPath)
48+
{
49+
$acl = Get-Acl $LogPath
50+
$GpOrUsers | %{
51+
$ace = New-Object System.Security.AccessControl.RegistryAccessRule $_,'WriteKey, ReadKey','allow'
52+
$acl.AddAccessRule($ace)
53+
#Set-Acl $LogPath $acl
54+
}
55+
}else{Write-Error "Cannot acesss log $LogName"}
56+
}
57+
else {
58+
$LogSources | %{
59+
New-EventLog -LogName $LogName -Source $_
60+
}
8961
}
90-
62+
63+
64+
You can find the entired PowerShell script here: [BizTalk DevOps: Moving an Event Source To a Different/Custom Windows Event Log](https://gallery.technet.microsoft.com/scriptcenter/BizTalk-DevOps-Moving-an-e4c23236)
9165

92-
# How did I solve (or I overcame) this challenger? Read more about it
66+
# Read more about it
9367
You can read more about this topic here: [Why is so hard to make a simple If-Then-Else Functoid? … well, not anymore!
9468
](https://blog.sandro-pereira.com/2016/02/10/why-is-so-hard-to-make-a-simple-if-then-else-functoid-well-not-anymore/)
9569

Tracking-and-Troubleshooting-BizTalk-Applications/README.md

+3-23
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,7 @@
1-
# Working with Maps
1+
# Tracking and Troubleshooting BizTalk Applications
22

3-
## Muenchian Grouping and Sorting in BizTalk Maps without losing Map functionalities
4-
Project explaining how to use Muenchian Method to handle grouping and sorting in BizTalk Maps without losing Map functionalities. The Muenchian Method is a method developed by Steve Muench for performing grouping and sorting functionalities in a more efficient way using keys.
5-
6-
## How to create a Global Inline C# Function
7-
The Scripting functoid enables you to use Inline Custom Script (C# .NET, JScript .NET, Visual Basic .NET, Extensible Stylesheet Language Transformations (XSLT) or XSLT Call Template) or call code from an external assembly at run time to perform operation otherwise not available
8-
9-
## How To Reuse Scripting Functoids with Inline C#
10-
Inline scripts are convenient for custom code that you are unlikely to use elsewhere in your application or other maps. In addition to being convenient for one-time scripts, inline scripts are also useful for declaring global variables for use among a number of scripts and to use
11-
12-
## How to create a custom If-Then-Else Functoid
13-
Sometimes I ask myself: Why is so hard to make a simple If-Then-Else Functoid, or even so painful to do an If-Then-Else operation, using BizTalk mapper?I don't mean to say that it is complicated, quite the opposite, is quite easy to make If…Then…Else statements using the Mapper.
14-
15-
## How to use Database Lookup Functoid
16-
We can use the Database Lookup functoid to extract information from a database and store it as a Microsoft® ActiveX® Data Objects (ADO) recordset. This functoid requires four input parameters in the following order:
17-
* Parameter 1: A value for which to search in the specified database, table, and column.
18-
* Parameter 2: The full connection string for the database with a provider, machine name, database and authentication (an ActiveX Data Objects .NET (ADO.NET) connection string)
19-
* Parameter 3: The name of the table in the database in which to search.
20-
* Parameter 4: The name of the column in the table in which to search.
21-
22-
The functoid is actually quite simple to use, however, the main problem that developers face when they use it refers to the second parameter: the connection string.
23-
24-
in this sample we will address this issue and how can you handle.
3+
## BizTalk Server: Moving Event Source To Different Event Log (Administration)
4+
Simple source sample on how to write to Event Viewer inside BizTalk Server solutions.
255

266
# About Me
277
**Sandro Pereira** | [DevScope](http://www.devscope.net/) | MVP & MCTS BizTalk Server 2010 | [https://blog.sandro-pereira.com/](https://blog.sandro-pereira.com/) | [@sandro_asp](https://twitter.com/sandro_asp)

0 commit comments

Comments
 (0)