New Posts New Posts RSS Feed: Remote Service Method Call (RSMC) Methods
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Remote Service Method Call (RSMC) Methods

 Post Reply Post Reply
Author
joão View Drop Down
Newbie
Newbie
Avatar

Joined: 28-Sep-2010
Location: Portugal
Posts: 5
Post Options Post Options   Quote joão Quote  Post ReplyReply Direct Link To This Post Topic: Remote Service Method Call (RSMC) Methods
    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;

        }

   }

 

Back to Top
sbelini View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 13-Aug-2010
Location: Oakland
Posts: 786
Post Options Post Options   Quote sbelini Quote  Post ReplyReply Direct Link To This Post 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.
 
Back to Top
joão View Drop Down
Newbie
Newbie
Avatar

Joined: 28-Sep-2010
Location: Portugal
Posts: 5
Post Options Post Options   Quote joão Quote  Post ReplyReply Direct Link To This Post Posted: 06-Oct-2010 at 1:29am
Hi Sbelini,
 
 
Thank you
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down