Print Page | Close Window

Remote Service Method Call (RSMC) Methods

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=2199
Printed Date: 05-Feb-2026 at 10:37am


Topic: Remote Service Method Call (RSMC) Methods
Posted By: joão
Subject: Remote Service Method Call (RSMC) Methods
Date Posted: 28-Sep-2010 at 7:59am

Hi everybody

 
I want to write a method to run in the server to generate, in batch, a set of entities from a "given base entity" as Pattern.
Basically i Have a given entity an through a cycle i create a set o new entities changing the key field.

From the client side I invoke the server method passing the “pattern entity”, de first number, last number and de Step.

the server creates new entities, adds them to the entimanager and calls the Savechanges method.

It Works well(the new entities are created in my sql server database), but , I

 

don’t know why the server method is called twice!!!
The SilverLight only calls it once!!!


Any tips would be apreciated

Thanks in advance

 

 

//--. Silver light  Side

 

private void DoConfirmCommand(object iView)

{

Alojamento _alojamento;

_alojamento = Alojamento.Create(0);

_mgr.AddEntity(_alojamento);

string typeName = "Alojamentos.Models.RemoteServiceMethods, AlojamentosWeb";

string methodName = "GenerateAlojamentos";

Guid myInvokeGuid = System.Guid.NewGuid();

DoAsyncAction(() => { _mgr.InvokeServerMethodAsync(typeName, methodName, GotData, myInvokeGuid, _alojamento, InicialRecord, FinalRecord, Step); });

}

 

protected void DoAsyncAction(Action a)

{

a();

}

 

void GotData(InvokeServerMethodOperation e)

{

if (!e.Cancelled)

{

bool gerou = (bool)e.Result;

}

}

 

// ---- Server Side Method -------------------------

 

using System;

using System.Linq;

using IbEm = IdeaBlade.EntityModel;

using IdeaBlade.Core;

using IdeaBlade.EntityModel;

using System.Security.Principal;

using System.Collections.Generic;

 

 

 

namespace Alojamentos.Models

{

    public class RemoteServiceMethods

    {

 

        [AllowRpc]

        public static Object GenerateaAlojamentos(IPrincipal principal, EntityManager mgr, params Object[] args)

        {

            // Cast EntityManager to its more specialized type for this app     

           

            EntidadesAlojamentos DomainMgr = (EntidadesAlojamentos)mgr;

            Alojamento alojamento = args[0] as Alojamento;

            for (int i = (int)args[1]; i <= (int)args[2]; i += (int)args[3])

            {

                Alojamento newaloj = (Alojamento)((ICloneable)alojamento).Clone();

                newaloj.intNumero = i;

                DomainMgr.AddEntity(newaloj);

            }

            SaveResult result = DomainMgr.SaveChanges();

            return result;

        }

   }

 




Replies:
Posted By: sbelini
Date Posted: 30-Sep-2010 at 4:24pm
Hi Joao,
 
You are returning an object of SaveResult. SaveResult is not serializable, therefore you can't send it over the wire.
Trying to do so will cause a CommunicationException and we do a retry upon this exception.
 


Posted By: joão
Date Posted: 06-Oct-2010 at 1:29am
Hi Sbelini,
 
 
Thank you



Print Page | Close Window