New Posts New Posts RSS Feed: how to do serverside logic using a stored proc.
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

how to do serverside logic using a stored proc.

 Post Reply Post Reply
Author
Dominique View Drop Down
Groupie
Groupie
Avatar

Joined: 28-Jun-2007
Location: Norway
Posts: 44
Post Options Post Options   Quote Dominique Quote  Post ReplyReply Direct Link To This Post Topic: how to do serverside logic using a stored proc.
    Posted: 29-Jun-2007 at 8:14am
Hi,

From my client applications(smart client) I need to fetch serienumbers from a serie hold in a database table.
I use a stored procedure to pull out the right number and do the updates to the series. I want to have extra logic on the server like sending an email to our support if the remaining numbers goes under a limit.

Ideally I would like to call from my client a function like:
GetserieNumber (serieType, quantity) as ResponseObject
ResponseObject being a structure with for example
.serietype
.quantity_asked as int32
.firstSerieNumber as Integer?
.IsOk as boolean
.message as string

the minimum would be to get back an integer or "nothing" (dbnull or vb nothing)
I could build a webservice or use remoting but when using a BOS it looks like I could let the BOS do the remoting part of the job maybe with RPC.
Is it possible to have the BOS calling such a function (in-process?)? or do you have any proposition of how to do that when using Devforce?
btw, I didn't find examples with the RPC stuff, could you give me a pointer to it? (page in the dev. manual or weblink)

Dominique



Edited by Dominique - 29-Jun-2007 at 8:15am
Back to Top
davidklitzke View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 14-Jun-2007
Posts: 715
Post Options Post Options   Quote davidklitzke Quote  Post ReplyReply Direct Link To This Post Posted: 29-Jun-2007 at 8:55am
Dominique,
 
This seems like an ideal opportunity to use RPC.  RPC allows you to have any type of return object (e.g., void, string, array), not just a list of Business Objects.
 
You can find this information (I agree it's sparse and hard to find) in Reference Help under ServerRpcDelegate Delegate
 
Here is an email example:
 
C#
// Sample showing invocation of server method 
PersistenceManager pm = PersistenceManager.DefaultManager; 
int orderId = 10250; 
bool mailSent = (bool) pm.InvokeServerMethod(Order.EmailOrderInfo, orderId); 
 
// sample method defined in Order class 
public class Order : OrderDataRow { 
//... 
  // ServerRpcDelegate method, called from client 
  [AllowRpc] 
  public static Object EmailOrderInfo(IPrincipal pPrincipal, DataSourceResolver pResolver, params Object[] pArgs) { 
    int orderId = Convert.ToInt32(pArgs[0]); 
 
    // build and send an email message  
    string from = "sales@mycompany.com"; 
    string to = "customer@yourcompany.com"; 
    System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage(from, to); 
    msg.Subject = "Order Information"; 
    msg.Body = string.Format("Order id = {0} has been shipped", orderId); 
 
    System.Net.Mail.SmtpClient mailClient = new System.Net.Mail.SmtpClient("localhost"); 
    try { 
      mailClient.Send(msg); 
    } catch (Exception e) { 
      TraceFns.WriteLine(e.Message); 
      return false; 
    } 
    return true; 
 } 
}
Back to Top
Dominique View Drop Down
Groupie
Groupie
Avatar

Joined: 28-Jun-2007
Location: Norway
Posts: 44
Post Options Post Options   Quote Dominique Quote  Post ReplyReply Direct Link To This Post Posted: 29-Jun-2007 at 9:07am
Thanks you for a quick reply :-)

Dominique
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down