<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-640976698041632518</id><updated>2011-07-31T00:05:31.639-07:00</updated><category term='COM+'/><category term='ViewFlow'/><category term='K2Server'/><category term='Silverlight 3'/><category term='data'/><category term='K2 [blackpearl]'/><category term='RIA'/><category term='Transaction'/><category term='K2ServerLog'/><title type='text'>Black Bobo</title><subtitle type='html'>A place where to share thoughts around technology with a special focus on the technology I'm working on at the moment I'm posting :)</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://blackbobo.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/640976698041632518/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://blackbobo.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Cesare</name><uri>http://www.blogger.com/profile/09170901787297484597</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_vOt5iwsXmGM/Snbcua3zPbI/AAAAAAAAAAg/OewoQlxpF9g/S220/Cesi.JPG'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>3</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-640976698041632518.post-3879295639913717382</id><published>2009-08-06T14:43:00.001-07:00</published><updated>2009-08-06T14:57:36.367-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='data'/><category scheme='http://www.blogger.com/atom/ns#' term='K2Server'/><category scheme='http://www.blogger.com/atom/ns#' term='K2 [blackpearl]'/><category scheme='http://www.blogger.com/atom/ns#' term='K2ServerLog'/><title type='text'>How to move K2 [blackpearl] data from one farm to another</title><content type='html'>&lt;p align="justify"&gt;Sometimes it can be useful to recreate the same situation that you have in a K2 farm elsewhere:&lt;br /&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;if you got some troubles in a production environment and you want to investigate on them without corrupting the environment further&lt;br /&gt;&lt;/li&gt;&lt;li&gt;if you want to test an hotfix or upgrade and you want to do that having exactly the same situation that you will find in your final environment&lt;br /&gt;&lt;/li&gt;&lt;li&gt;if you want to stress test a clone of your production environment without interrupting the service&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p align="justify"&gt;K2 [blackpearl] comes with 14 databases. As far as it concerns processes data, however, only two databases have the main impact:&lt;br /&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;K2Server: it is the transactional database used for workflow execution and tasklist retrieval&lt;br /&gt;&lt;/li&gt;&lt;li&gt;K2ServerLog: it is the logging database used for reporting data, smart object and viewflow&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p align="justify"&gt;While the server is running some dedicated threads move data that's no more needed for execution from the K2Server to the K2ServerLog database.&lt;br /&gt;&lt;/p&gt;&lt;p align="justify"&gt;In order to move data from one farm to another it is sufficient to replace these two databases in the destination farm with the ones from the source farm (either via detach/attach or backup/restore).&lt;br /&gt;&lt;/p&gt;&lt;p align="justify"&gt;At that point it is enough to run the following T-SQL script in the K2Server database of the destination farm before restarting the K2 server service:&lt;br /&gt;&lt;/p&gt;&lt;p&gt;USE [K2Server]&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;-- Setting K2 Server and removing extra entries&lt;br /&gt;&lt;/p&gt;&lt;p&gt;DECLARE @HOSTNAME NVARCHAR(20)&lt;br /&gt;&lt;/p&gt;&lt;p&gt;DECLARE @LICENSE NVARCHAR(20)&lt;br /&gt;&lt;/p&gt;&lt;p&gt;SELECT @LICENSE = [LicenseKey], @HOSTNAME=[HostName] FROM [HostServer].[dbo].[LicenseKeys] WHERE [HostName] = '&lt;span style="color:orange;"&gt;dest farm hostname&lt;/span&gt;'&lt;br /&gt;&lt;/p&gt;&lt;p&gt;UPDATE [_Server] set [Name]=@HOSTNAME, [LicenseKey]=@LICENSE WHERE [ID] = 1&lt;br /&gt;&lt;/p&gt;&lt;p&gt;DELETE FROM [_Server] WHERE ID &amp;gt; 1&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;-- Update Server Users&lt;br /&gt;&lt;/p&gt;&lt;p&gt;DELETE FROM [_ServerUser]&lt;br /&gt;&lt;/p&gt;&lt;p&gt;INSERT INTO [_ServerUser] VALUES ('&lt;span style="color:orange;"&gt;K2:DENALLIX\Administrator&lt;/span&gt;', 1,1,1)&lt;br /&gt;&lt;/p&gt;&lt;p&gt;INSERT INTO [_ServerUser] VALUES ('&lt;span style="color:orange;"&gt;'K2:DENALLIX\K2Admin&lt;/span&gt;', 1,1,1)&lt;br /&gt;&lt;/p&gt;&lt;p&gt;INSERT INTO [_ServerUser] VALUES ('&lt;span style="color:orange;"&gt;'K2:DENALLIX\K2App&lt;/span&gt;', 1,1,1)&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;-- Update Settings…&lt;br /&gt;&lt;/p&gt;&lt;p&gt;UPDATE [_Setting] SET [Value] = 'Integrated=True;IsPrimaryLogin=True;Authenticate=True;EncryptedPassword=False;Host=' + @HOSTNAME + ';Port=5555' WHERE [Name] = 'UMData'&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;--Update String Tables&lt;br /&gt;&lt;/p&gt;&lt;p&gt;UPDATE [_StringTable] SET [Value] = @HOSTNAME&lt;br /&gt;&lt;/p&gt;&lt;p&gt;WHERE [Root] = 'Production' AND [Name] = 'Mail Server'&lt;br /&gt;&lt;/p&gt;&lt;p&gt;UPDATE [_StringTable] SET [Value] = 'Integrated=True;IsPrimaryLogin=True;Authenticate=True;EncryptedPassword=False;Host=' + @HOSTNAME + ';Port=5555'&lt;br /&gt;&lt;/p&gt;&lt;p&gt;WHERE [Root] = 'Production' AND [Name] = 'SmartObject Server'&lt;br /&gt;&lt;/p&gt;&lt;p&gt;UPDATE [_StringTable] SET [Value] = 'Integrated=True;IsPrimaryLogin=True;Authenticate=True;EncryptedPassword=False;Host=' + @HOSTNAME + ';Port=5555'&lt;br /&gt;&lt;/p&gt;&lt;p&gt;WHERE [Root] = 'Production' AND [Name] = 'ServiceObject Server'&lt;br /&gt;&lt;/p&gt;&lt;p&gt;UPDATE [_StringTable] SET [Value] = 'Integrated=True;IsPrimaryLogin=True;Authenticate=True;EncryptedPassword=False;Host=' + @HOSTNAME + ';Port=5555'&lt;br /&gt;&lt;/p&gt;&lt;p&gt;WHERE [Root] = 'Production' AND [Name] = 'Category Server'&lt;br /&gt;&lt;/p&gt;&lt;p&gt;UPDATE [_StringTable] SET [Value] = 'http://' + @HOSTNAME + ':8081'&lt;br /&gt;&lt;/p&gt;&lt;p&gt;WHERE [Root] = 'Production' AND [Name] = 'Web Service URL'&lt;br /&gt;&lt;/p&gt;&lt;p&gt;UPDATE [_StringTable] SET [Value] = 'Integrated=True;IsPrimaryLogin=True;Authenticate=True;EncryptedPassword=False;Host=' + @HOSTNAME + ';Port=5252'&lt;br /&gt;&lt;/p&gt;&lt;p&gt;WHERE [Root] = 'Production' AND [Name] = 'Workflow Server'&lt;br /&gt;&lt;/p&gt;&lt;p&gt;UPDATE [_StringTable] SET [Value] = 'Integrated=True;IsPrimaryLogin=True;Authenticate=True;EncryptedPassword=False;Host=' + @HOSTNAME + ';Port=5555'&lt;br /&gt;&lt;/p&gt;&lt;p&gt;WHERE [Root] = 'Production' AND [Name] = 'Workflow Management Server'&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;-- ** NOTE - The Actioners might need to be updated with new labels??&lt;br /&gt;&lt;/p&gt;&lt;p&gt;--select * from _Actioners&lt;br /&gt;&lt;/p&gt;&lt;p align="justify"&gt;The script updates all the relevant tables… it is only needed to change the hostname and the server users (highlighted) accordingly.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/640976698041632518-3879295639913717382?l=blackbobo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blackbobo.blogspot.com/feeds/3879295639913717382/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blackbobo.blogspot.com/2009/08/how-to-move-k2-blackpearl-data-from.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/640976698041632518/posts/default/3879295639913717382'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/640976698041632518/posts/default/3879295639913717382'/><link rel='alternate' type='text/html' href='http://blackbobo.blogspot.com/2009/08/how-to-move-k2-blackpearl-data-from.html' title='How to move K2 [blackpearl] data from one farm to another'/><author><name>Cesare</name><uri>http://www.blogger.com/profile/09170901787297484597</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_vOt5iwsXmGM/Snbcua3zPbI/AAAAAAAAAAg/OewoQlxpF9g/S220/Cesi.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-640976698041632518.post-8771129029333723020</id><published>2009-08-03T13:12:00.001-07:00</published><updated>2009-08-06T13:49:10.143-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Silverlight 3'/><category scheme='http://www.blogger.com/atom/ns#' term='RIA'/><category scheme='http://www.blogger.com/atom/ns#' term='K2 [blackpearl]'/><category scheme='http://www.blogger.com/atom/ns#' term='ViewFlow'/><title type='text'>Silverlight 3 &amp; RIA Services based K2 View Flow</title><content type='html'>&lt;div align="justify"&gt;The customer I'm currently working for asked me to realize a POC of a custom view flow for K2 [blackpearl]. The reason for that was because they wanted to make data provided natively by K2 together with custom data coming from external sources to be exposed as a whole in a graphical business process view flow. In order to do that they needed to understand how easy and fast would have been to write an application that pulls data down from the process engine and shows that data in a graphical format on the web.&lt;br /&gt;For what is concerning the UI I had no choice, they wanted the view flow to be exposed via web so Silverlight was definitively the right answer.&lt;br /&gt;As far as is concerning the K2 flow data access instead, I knew that I had 2 choices:&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;&lt;div align="left"&gt;To use the &lt;strong&gt;ViewProcessInstance&lt;/strong&gt; method of &lt;strong&gt;SourceCode.Workflow.Client.Connection &lt;/strong&gt;to retrieve an xml representation of the process instance flow (it is essentially what the OOB ViewFlow does under the hood)&lt;/div&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;div align="left"&gt;To access directly the K2ServerLog database in order to extract the information I needed &lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;Even if the first choice should have been the right one for many reasons:&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;&lt;div align="left"&gt;Coding over data provided from a documented API should be faster than reading the same data from a partially documented database&lt;/div&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;div align="left"&gt;What would happen at my code if K2ServerLog changed due to a K2 hotfix?&lt;/div&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;div align="left"&gt;Why do not follow the same path that SourceCode itself followed? &lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;I finally decided for the second one because:&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;&lt;div align="left"&gt;I saw that accessing K2ServerLog directly performs better than calling K2 server to retrieve the same data&lt;/div&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;div align="left"&gt;Accessing K2ServerLog directly instead of calling K2 server doesn't load K2 server&lt;/div&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;div align="left"&gt;The K2ServerLog schema is not changed frequently… the actual one has pretty much the same structure it had in K2.NET 2003&lt;/div&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;div align="left"&gt;K2ServerLog tables and schemas are documented in the K2 [blackpearl] official documentation&lt;/div&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;div align="left"&gt;K2ServerLog is the logging - not transactional – database, thus accessing it should not disrupt K2 Server execution performances&lt;/div&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;div align="left"&gt;I had few time to realize my POC and I knew well the structure of K2ServerLog because I already studied it before for other purposes&lt;/div&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;div align="left"&gt;I wanted to try RIA Services in a real scenario… &lt;span style="font-family:Wingdings;"&gt;J&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;p align="justify"&gt;I started defining constraints (keys, foreign keys, relationships…) on a copy of K2ServerLog database (K2ServerLog itself comes with no constraints). This would have helped LINQ to SQL to create entities and associations in the appropriate manner. Obviously constraints were only needed for development and were not meant to be used at runtime. What I obtained finally is the following (I extracted below only the part that is relevant for my View Flow): &lt;/p&gt;&lt;br /&gt;&lt;p align="justify"&gt;&lt;br /&gt;&lt;a href="http://4.bp.blogspot.com/_vOt5iwsXmGM/SnhzPRp8qJI/AAAAAAAAACo/oELnBY5UUjk/s1600-h/1.jpg"&gt;&lt;img style="WIDTH: 320px; HEIGHT: 246px; CURSOR: hand" id="BLOGGER_PHOTO_ID_5366165662286522514" border="0" alt="" src="http://4.bp.blogspot.com/_vOt5iwsXmGM/SnhzPRp8qJI/AAAAAAAAACo/oELnBY5UUjk/s320/1.jpg" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;After that I created a new Silverlight Application and I enabled .NET RIA Services integration:&lt;/p&gt;&lt;br /&gt;&lt;p align="justify"&gt;&lt;br /&gt;&lt;a href="http://2.bp.blogspot.com/_vOt5iwsXmGM/Snh2r3ds3mI/AAAAAAAAACw/sH2JTRKnlYw/s1600-h/2.jpg"&gt;&lt;img style="WIDTH: 320px; HEIGHT: 285px; CURSOR: hand" id="BLOGGER_PHOTO_ID_5366169452006923874" border="0" alt="" src="http://2.bp.blogspot.com/_vOt5iwsXmGM/Snh2r3ds3mI/AAAAAAAAACw/sH2JTRKnlYw/s320/2.jpg" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div align="justify"&gt;I added a new &lt;strong&gt;LINQ to SQL Classes&lt;/strong&gt; item and I followed the wizard to make it pointing to my modified K2ServerLog database and to include the desired tables.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;I finally obtained the ERM for the K2ServerLog database:&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://3.bp.blogspot.com/_vOt5iwsXmGM/Snh3rxmNAeI/AAAAAAAAADA/y9dKDwN7dAY/s1600-h/3.jpg"&gt;&lt;img style="WIDTH: 320px; HEIGHT: 214px; CURSOR: hand" id="BLOGGER_PHOTO_ID_5366170549943599586" border="0" alt="" src="http://3.bp.blogspot.com/_vOt5iwsXmGM/Snh3rxmNAeI/AAAAAAAAADA/y9dKDwN7dAY/s320/3.jpg" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div align="justify"&gt;I added a new &lt;strong&gt;Domain Service Class&lt;/strong&gt; item (including metadata classes). I added a custom method to the domain service in order to get a process instance and all the related entities given its id:&lt;/div&gt;&lt;br /&gt;&lt;div align="justify"&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;_ProcInst&lt;/span&gt; Get_ProcInstById(&lt;span style="color:#2b91af;"&gt;Int32&lt;/span&gt; procInstId) &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Courier New;"&gt;{ &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="color:#2b91af;"&gt;DataLoadOptions&lt;/span&gt; loadOptions = &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;DataLoadOptions&lt;/span&gt;(); &lt;/span&gt;&lt;span style="font-family:Courier New;"&gt;&lt;br /&gt;&lt;span style="color:green;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="color:green;"&gt;// ProcInst &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Courier New;"&gt;loadOptions.LoadWith&amp;lt;&lt;span style="color:#2b91af;"&gt;_ProcInst&lt;/span&gt;&amp;gt;(p =&amp;gt; p._Proc);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Courier New;"&gt;loadOptions.LoadWith&amp;lt;&lt;span style="color:#2b91af;"&gt;_ProcInst&lt;/span&gt;&amp;gt;(p =&amp;gt; p._ActInsts); &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="color:green;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="color:green;"&gt;// Proc &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Courier New;"&gt;loadOptions.LoadWith&amp;lt;&lt;span style="color:#2b91af;"&gt;_Proc&lt;/span&gt;&amp;gt;(p =&amp;gt; p._Acts); &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Courier New;"&gt;loadOptions.LoadWith&amp;lt;&lt;span style="color:#2b91af;"&gt;_Proc&lt;/span&gt;&amp;gt;(p =&amp;gt; p._Lines); &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="color:green;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="color:green;"&gt;// Act &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Courier New;"&gt;loadOptions.LoadWith&amp;lt;&lt;span style="color:#2b91af;"&gt;_Act&lt;/span&gt;&amp;gt;(a =&amp;gt; a._Events); &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="color:green;"&gt;// Line &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Courier New;"&gt;loadOptions.LoadWith&amp;lt;&lt;span style="color:#2b91af;"&gt;_Line&lt;/span&gt;&amp;gt;(l =&amp;gt; l._Act); &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Courier New;"&gt;loadOptions.LoadWith&amp;lt;&lt;span style="color:#2b91af;"&gt;_Line&lt;/span&gt;&amp;gt;(l =&amp;gt; l._Act1); &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Courier New;"&gt;loadOptions.LoadWith&amp;lt;&lt;span style="color:#2b91af;"&gt;_Line&lt;/span&gt;&amp;gt;(l =&amp;gt; l._LineInsts); &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="color:blue;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="color:blue;"&gt;this&lt;/span&gt;.Context.LoadOptions = loadOptions; &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="color:#2b91af;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="color:#2b91af;"&gt;_ProcInst&lt;/span&gt; procInst = (&lt;span style="color:blue;"&gt;from&lt;/span&gt; o &lt;span style="color:blue;"&gt;in&lt;/span&gt; Context._ProcInsts &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="color:blue;"&gt;where&lt;/span&gt; o.ID == procInstId &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="color:blue;"&gt;select&lt;/span&gt; o).First(); &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="color:blue;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="color:blue;"&gt;return&lt;/span&gt; procInst; &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Courier New;"&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;I decorated with the &lt;span style="font-family:Courier New;color:#2b91af;"&gt;Include&lt;/span&gt; attribute the same properties in the appropriate metadata classes:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="color:blue;"&gt;internal&lt;/span&gt; &lt;span style="color:blue;"&gt;sealed&lt;/span&gt; &lt;span style="color:blue;"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;_LineMetadata&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;"&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="color:green;"&gt;// Metadata classes are not meant to be instantiated.&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="color:blue;"&gt;private&lt;/span&gt; _LineMetadata()&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;"&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;"&gt;}&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Courier New;"&gt;[&lt;span style="color:#2b91af;"&gt;Include&lt;/span&gt;]&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;_Act&lt;/span&gt; _Act;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Courier New;"&gt;[&lt;span style="color:#2b91af;"&gt;Include&lt;/span&gt;]&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;_Act&lt;/span&gt; _Act1;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Courier New;"&gt;[&lt;span style="color:#2b91af;"&gt;Include&lt;/span&gt;]&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;EntitySet&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af;"&gt;_LineInst&lt;/span&gt;&amp;gt; _LineInsts;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;And that's it; I was ready to code in Silverlight!!!&lt;br /&gt;&lt;br /&gt;And that's the result… I know it's still not too rich but I haven't spent too much time playing with effects:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://3.bp.blogspot.com/_vOt5iwsXmGM/Snh4kI3kZoI/AAAAAAAAADI/Sh_7k_8QqmQ/s1600-h/5.jpg"&gt;&lt;img style="WIDTH: 320px; HEIGHT: 316px; CURSOR: hand" id="BLOGGER_PHOTO_ID_5366171518263125634" border="0" alt="" src="http://3.bp.blogspot.com/_vOt5iwsXmGM/Snh4kI3kZoI/AAAAAAAAADI/Sh_7k_8QqmQ/s320/5.jpg" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/640976698041632518-8771129029333723020?l=blackbobo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blackbobo.blogspot.com/feeds/8771129029333723020/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blackbobo.blogspot.com/2009/08/silverlight-3-ria-services-based-k2.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/640976698041632518/posts/default/8771129029333723020'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/640976698041632518/posts/default/8771129029333723020'/><link rel='alternate' type='text/html' href='http://blackbobo.blogspot.com/2009/08/silverlight-3-ria-services-based-k2.html' title='Silverlight 3 &amp;amp; RIA Services based K2 View Flow'/><author><name>Cesare</name><uri>http://www.blogger.com/profile/09170901787297484597</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_vOt5iwsXmGM/Snbcua3zPbI/AAAAAAAAAAg/OewoQlxpF9g/S220/Cesi.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_vOt5iwsXmGM/SnhzPRp8qJI/AAAAAAAAACo/oELnBY5UUjk/s72-c/1.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-640976698041632518.post-5971071026218468192</id><published>2009-08-03T09:07:00.001-07:00</published><updated>2009-08-06T13:44:21.079-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='COM+'/><category scheme='http://www.blogger.com/atom/ns#' term='K2 [blackpearl]'/><category scheme='http://www.blogger.com/atom/ns#' term='Transaction'/><title type='text'>K2 [blackpearl] Transactional Model</title><content type='html'>&lt;div align="justify"&gt;&lt;br /&gt;      &lt;span&gt;&lt;br /&gt;        Being inspired by K2.NET 2003 documentation (see &lt;a href="http://kb.k2workflow.com/Articles/KB000066.aspx"&gt;KB000066&lt;/a&gt; for more details) and led by a direct experience I decided to put down this post about the transactional model that lies behind K2 [blackpearl].&lt;br /&gt;      &lt;/span&gt;&lt;br /&gt;    &lt;/div&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span style="font-size:90%;"&gt;&lt;br /&gt;      &lt;strong&gt;Transaction Processing&lt;/strong&gt;&lt;br /&gt;    &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;div align="justify"&gt;&lt;br /&gt;      &lt;span&gt;When you purchase an item from an online store, you exchange money (in the form of credit) for the item. If your credit is good, a series of related operations ensures that you get the item and the store gets your money. However, if a single operation in the series fails during the exchange, the entire exchange fails. You do not get the item and the store does not get your money. &lt;/span&gt;&lt;br /&gt;    &lt;/div&gt;&lt;br /&gt;    &lt;div align="justify"&gt;&lt;br /&gt;      &lt;span&gt;&lt;br /&gt;        The technology responsible for making the exchange balanced and predictable is called transaction processing. Transactions ensure that data-oriented resources are not permanently updated unless all operations within the transactional unit complete successfully. By combining a set of related operations into a unit that either completely succeeds or completely fails, you can simplify error recovery and make your application more reliable.&lt;br /&gt;        A transaction is a set of related tasks that either succeed or fail as a unit. In transaction processing terminology, the transaction either commits or aborts. For a transaction to commit, all participants must guarantee that any change to data will be permanent. Changes must persist despite system crashes or other unforeseen events. If even a single participant fails to make this guarantee, the entire transaction fails. All changes to data within the scope of the transaction are rolled back to a specific set point.&lt;br /&gt;&lt;br /&gt;        Automatic transaction processing is a service provided by COM+ that enables you to configure a class at design time to participate in a transaction at run time. To use this service, the class must derive directly or indirectly from the &lt;strong&gt;System.EnterpriseServices.ServicedComponent &lt;/strong&gt;class.&lt;br /&gt;      &lt;/span&gt;&lt;br /&gt;    &lt;/div&gt;&lt;br /&gt;    &lt;span style="font-size:90%;"&gt;&lt;br /&gt;      &lt;strong&gt;Writing Serviced Components &lt;/strong&gt;&lt;br /&gt;    &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;div align="justify"&gt;&lt;br /&gt;      &lt;span&gt;&lt;br /&gt;        A serviced component is the mechanism that enables COM+ services to be available to .NET Framework classes. You can modify any Common Language Specification (CLS)–compliant class to use COM+ services. The &lt;strong&gt;System.EnterpriseServices&lt;/strong&gt; namespace provides custom attributes and classes for accessing these services from managed code.&lt;br /&gt;        If you are new to writing serviced components take a look &lt;a href="http://msdn.microsoft.com/en-us/library/3x7357ez(VS.80).aspx"&gt;here&lt;/a&gt;.&lt;br /&gt;        If you are new to transaction isolation level in COM+ take a look &lt;a href="http://msdn.microsoft.com/en-us/library/system.transactions.isolationlevel.aspx"&gt;here&lt;/a&gt;.&lt;br /&gt;      &lt;/span&gt;&lt;br /&gt;    &lt;/div&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span style="font-size:90%;"&gt;&lt;br /&gt;      &lt;strong&gt;Enable Root Transactions in K2 [blackpearl] Server Events&lt;/strong&gt;&lt;br /&gt;    &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;div align="justify"&gt;&lt;br /&gt;      In order to make a K2 Server Event working in a transactional manner you need to configure this behaviour both at the Activity and Event level. It is as simple as checking two check boxes in the General Properties Wizard for the Activity and one of the contained Server Events:&lt;br /&gt;      &lt;a href="http://1.bp.blogspot.com/_vOt5iwsXmGM/SncOgFbrovI/AAAAAAAAABw/Sz3cHU8Ka_k/s1600-h/1.png"&gt;&lt;br /&gt;        &lt;img style="MARGIN: 0px 10px 10px 0px; WIDTH: 320px; FLOAT: left; HEIGHT: 211px; CURSOR: hand" id="BLOGGER_PHOTO_ID_5365773425412121330" border="0" alt="" src="http://1.bp.blogspot.com/_vOt5iwsXmGM/SncOgFbrovI/AAAAAAAAABw/Sz3cHU8Ka_k/s320/1.png" /&gt;&lt;br /&gt;      &lt;/a&gt;&lt;br /&gt;    &lt;/div&gt;&lt;br /&gt;    &lt;div align="justify"&gt;&lt;br /&gt;      &lt;a href="http://1.bp.blogspot.com/_vOt5iwsXmGM/SncSkumdl5I/AAAAAAAAACI/_0m9i9MiW7Q/s1600-h/3.png"&gt;&lt;br /&gt;        &lt;img style="WIDTH: 320px; HEIGHT: 246px; CURSOR: hand" id="BLOGGER_PHOTO_ID_5365777903229179794" border="0" alt="" src="http://1.bp.blogspot.com/_vOt5iwsXmGM/SncSkumdl5I/AAAAAAAAACI/_0m9i9MiW7Q/s320/3.png" /&gt;&lt;br /&gt;      &lt;/a&gt;&lt;br /&gt;      &lt;a href="http://3.bp.blogspot.com/_vOt5iwsXmGM/SncPYMCR_jI/AAAAAAAAACA/VYtmlDmz-dE/s1600-h/2.png"&gt;&lt;br /&gt;        &lt;img style="MARGIN: 0px 10px 10px 0px; WIDTH: 320px; FLOAT: left; HEIGHT: 263px; CURSOR: hand" id="BLOGGER_PHOTO_ID_5365774389257305650" border="0" alt="" src="http://3.bp.blogspot.com/_vOt5iwsXmGM/SncPYMCR_jI/AAAAAAAAACA/VYtmlDmz-dE/s320/2.png" /&gt;&lt;br /&gt;      &lt;/a&gt;&lt;br /&gt;    &lt;/div&gt;&lt;br /&gt;    &lt;div align="justify"&gt;&lt;br /&gt;      &lt;a href="http://2.bp.blogspot.com/_vOt5iwsXmGM/SncSsJ60jtI/AAAAAAAAACY/q7txPjIkbnQ/s1600-h/5.png"&gt;&lt;br /&gt;        &lt;img style="WIDTH: 295px; HEIGHT: 320px; CURSOR: hand" id="BLOGGER_PHOTO_ID_5365778030821412562" border="0" alt="" src="http://2.bp.blogspot.com/_vOt5iwsXmGM/SncSsJ60jtI/AAAAAAAAACY/q7txPjIkbnQ/s320/5.png" /&gt;&lt;br /&gt;      &lt;/a&gt;&lt;br /&gt;    &lt;/div&gt;&lt;br /&gt;    &lt;p align="justify"&gt;&lt;br /&gt;      There is only a rule to bear in mind: &lt;span style="TEXT-DECORATION: underline"&gt;a transactional Activity can contain only a single Server Event marked as transactional&lt;/span&gt;. This basically means that the transaction context does not flow across different Server Events within the same Activity. Missing this requirement may result in unexpected behaviour (like the process halting in running state indefinitely).&lt;br /&gt;      What happens behind is that K2 [blackpearl] registers on the fly a transactional serviced component (&lt;strong&gt;K2STXH&lt;/strong&gt;). This component is used this component as the root of the transaction when executing via reflection the code contained within the transactional Server Event.&lt;br /&gt;      The aforementioned K2 transactional server component presents the following characteristics:&lt;br /&gt;    &lt;/p&gt;&lt;br /&gt;    &lt;ul&gt;&lt;br /&gt;      &lt;li&gt;&lt;strong&gt;TransactionOption&lt;/strong&gt; is &lt;strong&gt;RequiredNew&lt;/strong&gt;: it means that a new transaction is created (the component is the root of the transaction)&lt;/li&gt;&lt;br /&gt;      &lt;li&gt;&lt;strong&gt;IsolationLevel&lt;/strong&gt; is &lt;strong&gt;ReadCommitted&lt;/strong&gt;&lt;/li&gt;&lt;br /&gt;    &lt;/ul&gt;&lt;br /&gt;    &lt;p align="justify"&gt;&lt;br /&gt;      &lt;span style="font-size:90%;"&gt;&lt;br /&gt;        &lt;strong&gt;Writing Serviced Components for K2 [blackpearl]&lt;/strong&gt;&lt;br /&gt;      &lt;/span&gt;&lt;br /&gt;    &lt;/p&gt;&lt;br /&gt;    &lt;p align="justify"&gt;&lt;br /&gt;      You can write transactional serviced components and enlist them in a transaction originated from the K2 Server Event.&lt;br /&gt;      In order to allow your serviced components to be enlisted in a transaction started from a K2 [blackpearl] Server Event you have to:&lt;br /&gt;    &lt;/p&gt;&lt;br /&gt;    &lt;ul&gt;&lt;br /&gt;      &lt;li&gt;Configure the TransactionOption as &lt;strong&gt;Required&lt;/strong&gt; or, at least, &lt;strong&gt;Supported&lt;/strong&gt;. This is because the serviced component that K2 uses as the root of the transaction has its transaction option configured as &lt;strong&gt;RequiredNew&lt;/strong&gt;.Marking your serviced components as &lt;strong&gt;RequiredNew&lt;/strong&gt; will generate a new transaction while marking them as &lt;strong&gt;NotSupported&lt;/strong&gt; will make them not to take part to the transaction&lt;/li&gt;&lt;br /&gt;      &lt;li&gt;You cannot configure them with a transaction isolation level higher than &lt;strong&gt;ReadCommitted&lt;/strong&gt;. This is because the serviced component that K2 uses as the root of the transaction has its isolation level configured as &lt;strong&gt;ReadCommitted&lt;/strong&gt;&lt;/li&gt;&lt;br /&gt;    &lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/640976698041632518-5971071026218468192?l=blackbobo.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blackbobo.blogspot.com/feeds/5971071026218468192/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blackbobo.blogspot.com/2009/08/k2-blackpearl-transactional-model.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/640976698041632518/posts/default/5971071026218468192'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/640976698041632518/posts/default/5971071026218468192'/><link rel='alternate' type='text/html' href='http://blackbobo.blogspot.com/2009/08/k2-blackpearl-transactional-model.html' title='K2 [blackpearl] Transactional Model'/><author><name>Cesare</name><uri>http://www.blogger.com/profile/09170901787297484597</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_vOt5iwsXmGM/Snbcua3zPbI/AAAAAAAAAAg/OewoQlxpF9g/S220/Cesi.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_vOt5iwsXmGM/SncOgFbrovI/AAAAAAAAABw/Sz3cHU8Ka_k/s72-c/1.png' height='72' width='72'/><thr:total>0</thr:total></entry></feed>
