Daniel Dudek`s Blog

.NET Dev

  Home  |   Contact  |   Syndication    |   Login
  9 Posts | 0 Stories | 5 Comments | 0 Trackbacks

News

Article Categories

Archives

Post Categories

.NET

Tuesday, October 27, 2009 #

I`ve found some time to explore brand new VS2010 Beta2.
One thing was that it still doesn`t implement Windows Mobile projects.

I tried to make some demo with Sync Services at VS2010 and I notice, that VS doesn`t add LacalDataCache.cs file into solution.

How it was int VS2008:


And how does it look now:

Problem is on that VS suppose add an new file "LocalDataCache.cs" to solution after right-click on LocalDataCache.sync and choose "View code", but it doesn`t. So, how we can play with Sync Framework in VS2010?

Double-click at LocalDataCache.Designer.cs and find this part of code:

private CustomersSyncTable _customersSyncTable;

        partial void OnInitialized();
       
        public LocalDataCacheSyncAgent() {
            this.InitializeSyncProviders();
            this.InitializeSyncTables();
            this.OnInitialized();
        }

And add your sync logic after partial void OnInitialized(); :

private CustomersSyncTable _customersSyncTable;

        partial void OnInitialized();

        partial void OnInitialized()
        {
            this._customersSyncTable.SyncDirection = Microsoft.Synchronization.Data.SyncDirection.Bidirectional;
        }
       
        public LocalDataCacheSyncAgent() {
            this.InitializeSyncProviders();
            this.InitializeSyncTables();
            this.OnInitialized();
        }

It`s not the cleanest way to play with sync, but it give ability to make some good software with Sync Services in VS2010.
Hope it will change in release.

Friday, October 02, 2009 #

17th October in Cracow will be cool event: CodeCamp (http://www.codecamp.pl).
List of speakers is really impressive:
  • Shawn Widermuth
  • Richard Campbell
  • Remi Caron
  • Chris Sells
  • Stephen Forte
  • Carl Franklin
  • Oliver Sturm
WOW!!!!! I`ll be there and it`s something cool after this event :D It`ll be an After Party ]:->


Monday, August 17, 2009 #

At Friday Software Developer`s Journal post my article about Windows Mobile programming.
http://www.sdjournal.org/prt/view/aktualnosci/issue/1060.html


Wednesday, July 29, 2009 #

It was cool to invite Glenn Block to Poland and be on his meeting in one of the cite. Glenn was also in Katowice in Silesian .NET UG. Fotos and more info about his tour in Poland you can find here: http://ms-groups.pl/glennblock/default.aspx

Our group:


From 29 to 30 September in Poland will be Microsoft Technology Summit 2009 the biggest Microsoft conference in Poland.
More info about this event you can find here: http://www.mts.pl .
Last year it was really cool and the best of all are meatings after conference in pubs, where you can meet many cool people and talk with them about brand new technology.


Saturday, May 02, 2009 #

Cracow .NET UG and Silesian .NET UG is making a cool event.

If you will be in Polen from 30 to 31 may, you should meet us on CodeCamp 2.0 ( http://codecamp.pl/en/Homepage.aspx ).

It is FREE .NET/SQL event and it will be nice to meet people from other countries.

Code Camp 2.0


Tuesday, April 21, 2009 #

Last week I have got a presentation about RDA on Silesian .NET User Group (http://ms-groups.pl/slaskagrupa/14.%20spotkanie/default.aspx).

Here are some pictures from my presentation:

  

If you have some cool presentation to show and you will be in Poland, please write to me and we can make international meeting with you ;)

 

Since last month I`m a leader of Silesian .NET User Group(http://ms-groups.pl/slaskagrupa/O%20spoecznoci/Liderzy.aspx).

I would like to introduce our friends from Cracow: http://ms-groups.pl/kgd.net/default.aspx


Saturday, March 28, 2009 #

Yesterday I have my second presentation on .NET group (http://ms-groups.pl/slaskagrupa/default.aspx). It was really cool and I like to make presentations.

My yesterday topic was about TDD in .NET (C#). In my daily work I always use Unit Tests and it was for me a big surprise, that so many developers doesn`t make tests.

In feature I`m planning to make something more practice instead just presentation.


Saturday, October 25, 2008 #

On the internet I found couple of articles about Sync Services and this part is really good described, but when I wont to implement conflicts in C# project I have some problems,  because the examples I found were in VB.NET but I`m not a VB geek.

So I decided to write this post to explain how to handle conflicts in C# when we synchronize our local database cache with SQL Server 2008.

After we make new local database cache and we set bidirectional sync we need to handle conflicts.

An example of situation, when we have a conflict:

Befor changes

After changes

As we can see in example, we made some changes and now we wont to sync our local cache with server, but if we make this without any change in sync code the column on server (in our example “Daniel on server”) will downloaded to the client app because this is the default setting, but what if we wont to upload data even there is a conflict?

I show how to solve this issue:

public partial class SyncTestSyncAgent {

        partial void OnInitialized(){

            this.Customers.SyncDirection = SyncDirection.Bidirectional;

        }

    }

This is the code, than we need to add to sync bidirectional, right behaind we need to add new partial class (SyncTest is name of my SyncTest.sync file, you need to change it on your project to name that you choosed):

    public partial class SyncTestServerSyncProvider

    {

        partial void OnInitialized()

        {

            // here we gone add code to handle conflicts

        }

    }

Add this code right behind:

public partial class SyncTestServerSyncProvider

{

      partial void OnInitialized()

     {

            this.ApplyChangeFailed += new System.EventHandler

<ApplyChangeFailedEventArgs>

            (SyncTestServerSyncProvider_ApplyChangeFailed);

      }

private void SyncTestServerSyncProvider_ApplyChangeFailed

(object sender, ApplyChangeFailedEventArgs e)

      {

// here we gone add code to check witch type of conflict we //wont to handle and how our app will make the changes on local //catch and server

}

}

At the end we can add an example code with show how to set client app to upload data even conflict type ClientUpdateServerUpdate (we have here couple of options:  ClientDeleteServerUpdate, ClientInsertServerInsert, ClientUpdateServerDelete, ClientUpdateServerUpdate, ErrorsOccurred, Unknown) and as ApplyAction we can use Continue, RetryApplyingRow, RetryWithForceWrite:

if (e.Conflict.ConflictType == ConflictType.ClientUpdateServerUpdate)

{

MessageBox.Show("ClientUpdateServerUpdate conflict", "Conflict", MessageBoxButtons.OK, MessageBoxIcon.Information );

      e.Action = ApplyAction.RetryWithForceWrite;

}

 

Our results before sync:

 

 And after sync:

 

That’s all you have to do to handle conflicts on your OCA app.

If you have any questions please write to me: dan.dudek[at]hotmail[dot]com