CodeSmith Community
Your Code. Your Way. Faster!

Call to Service layer from Windows application

Latest post 07-22-2008 8:49 AM by vbandrade. 3 replies.
  • 07-04-2008 8:29 AM

    Call to Service layer from Windows application

    Hi,

    We have a cut-down web version of our application for our clients which uses the very excellent .NetTiers library. In this one we use a Service layer.

    We are now creating a more detailed Windows version of the application for in-house use (data entry) and so use the DAL.WebServiceClient that is generated from the .NetTiers template. As per the sample code I have seen we reference this from the Windows front-end and make calls to the .Nettiers objects using something like;

    DataRepository.EmployeeProvider.GetByEmployeeID(_employeeID);

    On closer investigation I note that this data access method goes directly to the data layer, bypassing the service layer altogether. We do have quite a bit of custom code in the service layer... some where we have added various classes that inherit from the ProcessorBase for performing tasks, custom code that is specific the the entity that the service is linked to (e.g. our "Part" service calculates a price based on the customer and the quantity required, and we were planning on adding Workflow into the service layer.

    SO... if we wish to continue to make use of the Service layer I am thinking that in the Windows application the service layer should be accessed directly from the Front-End... and to standardise the application we should probably make all calls to access data through the Service Layer, which would, in-turn call the DAL.WebServiceClient, which would then access the DAL through the web service on the server?

    I must admit that it did seem strange that the DataRepository is usually accessed directly from the front-end in most of the sample code I have seen, but then I guess having a Service Layer (or Domain) is optional.

    In terms of actual system components and the physical layering for a Windows application I assume we would be looking at; Windows Front-End, Service Layer, DAL.WebServiceClient and Entities on the client PC AND on the server we would have Web Service, DAL, DAL.SQLClient and Entities?

    Thanks in advance for any help with my understanding of this. I guess I just need confirmation that I am on the right track in terms of the overall architecture and it usage.

    Andrew

     

     

     

    • Post Points: 35
  • 07-04-2008 10:08 AM In reply to

    • vbandrade
    • Top 25 Contributor
    • Joined on 09-27-2007
    • Brasil
    • Posts 213
    • Points 5,305

    Re: Call to Service layer from Windows application

    Hello there

    This is one of those loooong dicussions. (;

    The Service Layer is optional since not everyone likes to expose all CRUD methods (I hate it, acctually) In my code, I create my own service layer, and I create Module Services, not Entities Services, like .netTiers generates. Anyway, you should always have the Service Layer make the call to DAL.

    Do your windows application really needs to add data through webservices? your database is in a remote location? why dont you use a regular DAL?

    • Post Points: 35
  • 07-22-2008 6:14 AM In reply to

    Re: Call to Service layer from Windows application

    Thanks for the response. Pretty much confirmed what I thought, although I must admit to getting so hung up on architectural detail and best practise that it hadn't occurred to me that I didn't actually need the web service at all. Kind of like not seeing the wood for the trees ;-)

    Anyway, removing the web service from the architecture has improved performance heaps. Thanks.

    • Post Points: 35
  • 07-22-2008 8:49 AM In reply to

    • vbandrade
    • Top 25 Contributor
    • Joined on 09-27-2007
    • Brasil
    • Posts 213
    • Points 5,305

    Re: Call to Service layer from Windows application

    Reply |Contact |Answer

    Hows your architecture now, then?? Are you using .netTiers services or decided to create your own?

    Just please, don't tell me you're doing something like this (even if you are):

    void ButtonUpdatePassword_onClick(Event args...){

    User usr = DataRepository.UserProvider.GetByLong(tbLogin.Text);
    usr.Password = EncryptPassword(tbPassword.Text);
    DataRepository.UserProvider.Save(usr);

    }

    string EncryptPassword(string Password)
    {
        MD5CryptoServiceProvider MD5 = new MD5CryptoServiceProvider();
        UTF8Encoding UTF8 = new UTF8Encoding();

        byte[] encryptedPassword = MD5.ComputeHash(UTF8.GetBytes(Password));

        return Convert.ToBase64String(encryptedPassword);
    }

    If you're doing that you gonna have a lot of trouble mantaining your application.

    • Post Points: 5
Page 1 of 1 (4 items) | RSS
Copyright © 2008 CodeSmith Tools, LLC
Powered by Community Server (Commercial Edition), by Telligent Systems