Facts can be asserted to the BRE from .NET code simply by passing them as an argument to the policy’s execute method which takes a variable number of parameters. For example,
Microsoft.RuleEngine.Policy policy = new Microsoft.RuleEngine.Policy(“PolicyName”);
Policy.Execute(Object1, Object2,…);
There are three types of facts used by the BRE: An xml document, a Database table, and a .NET class. The latter two have a couple peculiarities about them which require further explanation.
Asserting a Database Table
When using a database table, the BRE expects an object of type Microsoft.RuleEngine.DataConnection to be asserted, which tells the BRE where to find the table. This is achieved with the below code.
//Create the DataConnection
System.Data.SqlClient.SqlConnection connection = new System.Data.SqlClient.SqlConnection(“connectionstring”);
Microsoft.RuleEngine.DataConnection dconn = new Microsoft.RuleEngine.DataConnection(connection);
//Create the policy and assert the DataConnection
Microsoft.RuleEngine.Policy policy = new Microsoft.RuleEngine.Policy(“PolicyName”);
Policy.Execute(dconn);
Static .NET Methods
Calling a static .NET method from the BRE can be achieved without asserting an instance of the class by setting the the StaticSupport (DWORD value) registry key located under HKEY_LOCAL_MACHINE\Software\Microsoft\BusinessRules\3.0 to a value of 1. Without this registry entry, static method calls within the BRE will require asserting instances of the class that contain the method.
With Microsoft SQL Server 2005, paging on the database side is simple. There is a built-in ROW_NUMBER function designed specifically for this task. However, versions of SQL Server prior to 2005 do not have this capability. Below is one way to implement similar functionality in pre-2005 versions.
SELECT TOP X * FROM RECORDS WHERE RecordID NOT IN (SELECT TOP Y RecordID FROM RECORDS)
You must replace X and Y with actual integer values, Unfortuantly, due to sql sytanx, you can’t use varaibles. The records returned from the above query will follow
Y + 1 = Beginning record
X + Y + 1 = Ending Record
So 10 and 20 plugged in to X and Y respectively would return records 21 thorugh 31.
Figuring out the credentials passed by an ASP.NET application hosted on an IIS server to a remote resource is a common question in the community forums. Typical errors associated with this type of enquiry are “Acces to the path ‘C:\YourFolder’ is denied” or “Login failed for user ‘username’. Reason: Not associated with a trusted SQL Server connection”. The context under which a thread accessing a remote resource is running under is a function of two settings, the identity element of the web.config file and the authentication settings in IIS. With the combination of these options, one can arrive at any of the below security contexts.
Temporarily Impersonating
For security reasons, you may have a scenario where you want to impersonate only for a limited section of code and then return back to the application pool identity. To achieve this, Anonymous access must be disabled, else you will get the error “An anonymous identity cannot perform impersonation”. Next, impersonation must not be enabled in your web.config since we are impersonating programmatically. With these two conditions met, your code should look like this
//Code executed here will run under context of the app pool
System.Security.Principal.WindowsImpersonationContext context;
Context = ((System.Security.Principal.WindowsIdentity)User.Identity).Impersonate();
//Code executed here will run under the context of the client account
Context.Undo(); Read the rest of this entry »
The Silverlight platform from Microsoft has just benefited from an updated array of developer tools, which will allow third-party firms to make apps for the software giant’s next mobile operating system.
The recent Microsoft Mix 10 conference was used as a platform to introduce developers to the updated edition of Silverlight and attendees were told that it would be an integral component in Windows Phone 7 Series.
The XNA gaming framework will be used in tandem with Silverlight for the next-gen platform and Microsoft hopes that cross-platform software will be developed as a result of using these common development tools.
Microsoft’s Scott Guthrie said: “By extending our familiar platform technologies and tools to phones, Microsoft is delivering the premier application development experience across a variety of devices and form factors.”
Microsoft announced that it would be making a download service comparable to Apple’s App Store for use with future smartphones based on its technology.
Developers will be encouraged to create apps and send them in to Microsoft for approval, before they become a permanent feature of the Marketplace.
Advertising may be used to support certain titles, although Microsoft also said that it would offer subscription-based payments where necessary.