Login | Register
Home
Products>
Order
Community>
Support>
Downloads
About>
Forums
 
Welcome Guest Search | Active Topics |

Tag as favorite
Integrating with WCF RIA Services
elitovsky
#1 Posted : Tuesday, February 02, 2010 10:31:18 PM
Rank: Newbie

Medals:

Groups: Registered
Joined: 1/21/2010
Posts: 8
Points: 24

Thanks: 0 times
Was thanked: 0 time(s) in 0 post(s)
How do I use the RIA Helper classes to more smoothly integrate with my domain data context?
silberfab
#2 Posted : Tuesday, March 30, 2010 5:14:42 AM
Rank: Member

Medals:

Groups: Registered
Joined: 1/25/2010
Posts: 15
Points: 45

Thanks: 0 times
Was thanked: 0 time(s) in 0 post(s)
Hello, I'm actually testing Ria Services on the scheduler and there's only a thing which is not working correctly (the principal), it's to bind directly my resources into the scheduler.

What I want to do ==>
Code:

<cg:MultiScheduler x:Name="scheduler"
                   ResourceItemsSource="{Binding ListeResources}">
</cg:MultiScheduler>


I continu testing and we keep in touch.

"Excuse me for my english i'm a french guy ^^"
admin
#3 Posted : Thursday, April 01, 2010 7:24:49 AM
Rank: Administration

Medals:

Groups: Administrators
Joined: 1/12/2010
Posts: 39
Points: 117

Thanks: 0 times
Was thanked: 7 time(s) in 7 post(s)
At this point it is a little more than just doing that. We will mike it much simplier in a future release but currently you have to do it in code: Here's how you can load both appointments and resources via WCF RIA Services:

This example uses bloggers as resources and blogger's articles as appointments:

Code:

     private void LoadScheduler()
        {
   
            BlogManagerContext bmc = new BlogManagerContext();

            //-- Map the minimal fields of the appointment class and create appointment DataAdapter.
            //-- If the source field names are the same, there is no need to map them.
            DataMapper mapperAppointment = new DataMapper();
            mapperAppointment.Mapping.Add("Uid", "ArticleUid");
            mapperAppointment.Mapping.Add("Start", "ArticleDate");
            mapperAppointment.Mapping.Add("Finish", "ArticleDate");
            mapperAppointment.Mapping.Add("ResourceUid", "BloggerUid");
            mapperAppointment.Mapping.Add("Subject", "Headline");
            multiScheduler.AppointmentDataAdapter = new RiaDataAdapter(bmc,bmc.FeaturedBloggerArticles,"GetFeaturedBloggerArticlesQuery",mapperAppointment);
           
            //--Map the minimal fields of the resource class and create resource DataAdapter
            //-- Note - If the source field names are the same, there is no need to map them.
            DataMapper mapperResources = new DataMapper();
            mapperResources.Mapping.Add("Uid", "BloggerUid");
            multiScheduler.ResourceDataAdapter = new RiaDataAdapter(bmc, bmc.FeaturedBloggers, "GetFeaturedBloggersQuery", mapperResources);

            //-- Load the data - Load the appointments then the resources after the appointments are fully loaded.
            multiScheduler.AppointmentDataAdapter.DataLoaded += new EventHandler<EventArgs>(AppointmentDataAdapter_DataLoaded);
            multiScheduler.AppointmentDataAdapter.LoadData();
        }




    void AppointmentDataAdapter_DataLoaded(object sender, EventArgs e)
        {
            multiScheduler.ResourceDataAdapter.LoadData();
        }


silberfab
#4 Posted : Tuesday, April 06, 2010 7:08:46 AM
Rank: Member

Medals:

Groups: Registered
Joined: 1/25/2010
Posts: 15
Points: 45

Thanks: 0 times
Was thanked: 0 time(s) in 0 post(s)
I manage to do what I want before you post your reply but i'll show you what i do. I actually use MVVM pattern with silverlight so this is what i do for my binding :

1) In my view model : (where contexte is my domaincontext whith ria services)
Code:

public PlanningViewModel(Plan vue)
        {
            this.View = vue;
            this.ListeResources = new ResourceItems();

            //Load resources
            contexte.Load(contexte.GetUserQuery(), GetPlanning_userCompleted, null);

        }

public void GetPlanning_userCompleted(LoadOperation lo)
        {
            //Init resources
            foreach (Utilisateur user in contexte.Utilisateurs)
            {
                Ressource tmp = new Ressource();
                tmp.Uid = user.Id;
                tmp.DisplayName = user.Nom;
                tmp.ResourceName = user.Nom;
                this.ListeResources.Add(tmp);
            }

            this.View.refresh_resourcesView();
        }


2) In my control plan.xaml.cs :

Code:

public void refresh_resourcesView()
        {
            this.scheduler.ResourceView = new CollectionItemsView<ResourceItem>(this.viewModel.ListeResources as IEnumerable<ResourceItem>, this.scheduler.ViewItems);
        }


3) And eventually in my control Plan.xaml :

Code:

ResourceItemsSource="{Binding ListeResources}"

admin
#5 Posted : Tuesday, April 06, 2010 8:51:09 PM
Rank: Administration

Medals:

Groups: Administrators
Joined: 1/12/2010
Posts: 39
Points: 117

Thanks: 0 times
Was thanked: 7 time(s) in 7 post(s)
Thanks for sharing. Your method should work fine too. It also gives you full control over your DomainContext. The example I gave is more integrated into the framework and all the CRUD work is done for you.
silberfab
#6 Posted : Wednesday, April 07, 2010 12:26:19 AM
Rank: Member

Medals:

Groups: Registered
Joined: 1/25/2010
Posts: 15
Points: 45

Thanks: 0 times
Was thanked: 0 time(s) in 0 post(s)
Ok i'm a newbee on Ria Services and just to try, i tryed tour method...

And it's just more powerfull et faster than mine so thank you very much.

But could I have more information about the mapper ?

1) I want to have the color of my appointment in database (but in string format) is it possible ??

2) I have a information which is an object (ex : MyProject) in my custom appointment and I would like mapp MYproject.Name to my DB.

3) When my DB is empty for my appointments, the editor doesn't want to open...

4) Finally, Is there a way to define a default value for some mapps

Thanks for your help
admin
#7 Posted : Thursday, April 08, 2010 9:53:48 AM
Rank: Administration

Medals:

Groups: Administrators
Joined: 1/12/2010
Posts: 39
Points: 117

Thanks: 0 times
Was thanked: 7 time(s) in 7 post(s)
1) Map and set the Appointment.ColorHex

2) You can set a scheduler.AppointmentDataAdapter.ItemSaving event handler and run your code there to save directly to your data source.

3) Requires further research.

4) The default value is going to be whatever is currently in your database when the data is loaded from the server.
sleepermedia
#8 Posted : Monday, May 24, 2010 9:57:48 AM
Rank: Newbie

Medals:

Groups: Registered
Joined: 3/21/2010
Posts: 2
Points: 6

Thanks: 0 times
Was thanked: 0 time(s) in 0 post(s)
Hi,

I'm a newbie both to C# and RIA, and was wondering if any of you had a sample app or sample project that's running off a sql db.

Trying to connect the myscheduler to a sql db instead of isolated storage.
Users browsing this topic
Guest
Tag as favorite
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

 
Copyright 2010 ComponentGizmos, LLC.  All rights reserved.