Results 1 to 5 of 5

Thread: Code Consolidation Architecture

  1. #1

    Thread Starter
    Frenzied Member KGComputers's Avatar
    Join Date
    Dec 2005
    Location
    Cebu, PH
    Posts
    2,020

    Code Consolidation Architecture

    Hello,

    Our team recently discussed to consolidate code so that multiple consumers can easily utilize the same code base since our projects are growing in numbers. At present we have 40+ schedule task service projects running on a server for different contracts/clients. But the numbers may increase soon.

    The goal for the architecture is the code can be consumed by non windows and mobile application and easy to maintain. These include models and functions per contract written in .NET C#.

    Now, we have three options:
    1. dll via nuget
    2. WCF hosted in IIS
    3. ASPX or asmx Service

    Are there any alternative solutions available aside from the aformentioned above? Let me know also the pro(s) and con(s) based from your experiences on these.

    Regards,

    kgc
    CodeBank: VB.NET & C#.NET | ASP.NET
    Programming: C# | VB.NET
    Blogs: Personal | Programming
    Projects: GitHub | jsFiddle
    ___________________________________________________________________________________

    Rating someone's post is a way of saying Thanks...

  2. #2
    PowerPoster PlausiblyDamp's Avatar
    Join Date
    Dec 2016
    Location
    Pontypool, Wales
    Posts
    2,458

    Re: Code Consolidation Architecture

    Without knowing any of the specifics, if you are looking for a way of hosting a service then you might want to also consider a WebAPI based app (more of a json / RESTful approach) as an alternative to WCF or a Webservice.

    A nuget packaged Dll would really only be useful to other .Net languages and would not really be suitable for a cross platform solution unless you were also using something like Xamarin as a mobile technology.

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: Code Consolidation Architecture

    ASP.NET Web API is basically MVC without an actual V, i.e. you just serve data rather than views. Particularly if you already use MVC, Web API is a no-brainer.

  4. #4

    Thread Starter
    Frenzied Member KGComputers's Avatar
    Join Date
    Dec 2005
    Location
    Cebu, PH
    Posts
    2,020

    Re: Code Consolidation Architecture

    Thanks. will definitely do some research on Web API.

    - kgc
    CodeBank: VB.NET & C#.NET | ASP.NET
    Programming: C# | VB.NET
    Blogs: Personal | Programming
    Projects: GitHub | jsFiddle
    ___________________________________________________________________________________

    Rating someone's post is a way of saying Thanks...

  5. #5
    Superbly Moderated NeedSomeAnswers's Avatar
    Join Date
    Jun 2002
    Location
    Manchester uk
    Posts
    2,660

    Re: Code Consolidation Architecture

    Thanks. will definitely do some research on Web API.
    Web API Is Really easy to use, here is a simple example of a method we use in one of our apps in C# ( I have removed our custom error-handling)

    Something to note if you've used MVC you will be familiar with but if not the _userRepository interface has been injected into the class

    Code:
    [Route("GetUser/{tenantId:int}/{tenantName}/{userName}")]
            [HttpGet]
            public Result<User> GetUser(int tenantId, string tenantName, string userName)
            {
                Result<User> result = new Result<User>();
    
                try
                {
                    result = _userRepository.GetUser(tenantId, tenantName, userName);
                }
                catch (Exception ex)
                {
                    
                }
                return result;
            }
    In this particular app we are using Entity framework so the data call looks like this -

    Code:
    public Result<User> GetUser(int tenantId, string tenantName, string userName)
            {
                var result = new Result<User>();
    
                try
                {
                    using (WebBundleDbEntities webBundleContext = Common.GetConnection(tenantId))
                    {
                        var userDetails = webBundleContext.csp_web_GetUserFromSystemName(userName).FirstOrDefault();
    
                        if (userDetails != null)
                        {
                            var data = new User()
                            {
                                Id = userDetails.ID,
                                Name = userDetails.Name,
                                SystemName = userDetails.System_Name,
                                TenantId = tenantId,
                                TenantName = tenantName
                            };
    
                            result.Data = data;
                            result.IsSuccess = true;
                        }
                        else
                            result.Message = Resource.msgUserDoesNotExist;
                    }
                }
                catch (Exception ex)
                {
                   
                }
    
                return result;
            }
    We are using a Model called User which is just a class with properties in it and then a class called Result which encapsulates all our return objects and allows us to return some other information alongside the data such as if the call was successful and any error messages

    Code:
    public class Result<TEntity>
        {
            public Result()
            {
                IsSuccess = false;
                Message = string.Empty;
                Count = 0;
            }
    
            public bool IsSuccess { get; set; }
    
            public string Message { get; set; }
    
            public TEntity Data { get; set; }
    
            public int Count { get; set; }
    
            public Exception Exception { get; set; }
        }
    Please Mark your Thread "Resolved", if the query is solved & Rate those who have helped you



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width