in

CodeSmith Community

Your Code. Your Way. Faster!

WebService Wrapper for Business Service Layer

Last post 02-08-2008 11:05 PM by mrizaullah. 16 replies.
Page 1 of 2 (17 items) 1 2 Next >
Sort Posts: Previous Next
  • 07-22-2006 8:50 PM

    WebService Wrapper for Business Service Layer

    Currenlty the DAL is wrapped in WebService.

    It would be nice if the Business Service layer is wrapped in WebService. It is already done? Any plans?

    • Post Points: 35
  • 07-23-2006 8:19 PM In reply to

    Re: WebService Wrapper for Business Service Layer

    It would be great, but this would definately be a post release feature.  Unless it community contributed of course!  Wink [;)]

    Robert Hinojosa

    -------------------------------------
    Member of the Codesmith Tools, .netTiers, teams

    http://www.nettiers.com
    -------------------------------------
    • Post Points: 35
  • 07-23-2006 11:00 PM In reply to

    Re: WebService Wrapper for Business Service Layer

    I can work on this. I will post it as soon as I'm done.
    • Post Points: 35
  • 07-26-2006 6:17 PM In reply to

    • mcquiggd
    • Top 25 Contributor
    • Joined on 07-11-2006
    • Amsterdam
    • Posts 174
    • Points 4,375

    Re: WebService Wrapper for Business Service Layer

    Hi,

    If you would like any help, let me know - PM me. I also have an interest in this....

    DavidM

    David

    (Could people PLEASE click the 'Mark As Answer' button on the message that solved their problems - it will help others with similar questions and could potentially be included in an FAQ to save time for all of us)
    • Post Points: 35
  • 08-14-2006 11:21 PM In reply to

    Re: WebService Wrapper for Business Service Layer

    Thanks for you offer David. I do appreciate it.

    Sorry for my belated response. I was not able to work on this.

    Here is my first pass on this. It generates good code (error free) which passed all of my test cases.

    I will continue to work on this to enhance it. Or you can now actually help do this. :).

    To make it work, you may replace the "WebService.cst" with the attached one.

    Do remember to set the property in "NetTiers.cst" @ line number 1863

    this.GetTemplate("WebService.cst").SetProperty("ComponentsNameSpace", ComponentsNameSpace);

    Robert,

    Could you add this to SVN? I know it will take some work if you want to keep this in parallel to DAL webservice.

    Thanks

    Fixed Custom Method bugs.

    • Post Points: 35
  • 08-16-2006 12:01 AM In reply to

    Re: WebService Wrapper for Business Service Layer

    Will look at this tomorrow!! Can't wait to see it!

    Robert Hinojosa

    -------------------------------------
    Member of the Codesmith Tools, .netTiers, teams

    http://www.nettiers.com
    -------------------------------------
    • Post Points: 35
  • 08-18-2006 12:16 PM In reply to

    Re: WebService Wrapper for Business Service Layer

    Fixed Custom Method bug and added a readme.txt.

    Updated the download (zip) file.

    • Post Points: 35
  • 08-19-2006 12:08 AM In reply to

    Re: WebService Wrapper for Business Service Layer

    Hi,

    I posted this patch to SVN Rev301.

    Great work! 

    There are a few things we'll have to work out, like making a proxy layer for access to the webservices on the client.  Other than that, wonderful work!

    Robert Hinojosa

    -------------------------------------
    Member of the Codesmith Tools, .netTiers, teams

    http://www.nettiers.com
    -------------------------------------
    • Post Points: 35
  • 08-19-2006 11:15 PM In reply to

    Re: WebService Wrapper for Business Service Layer

    Thanks again.

    Another thing I forgot to mention that DomainUtil class should include helper functions (to convert return results into Datset or datareader etc. These functions are just copied from the Util class from DataAccessLayer.

            #region Helper Methods
            /// <summary>
            /// Get a default value for a given data type
            /// </summary>
            /// <param name="dataType">Data type for which to get the default value</param>
            /// <returns>An object of the default value.</returns>
            public static Object GetDefaultByType(DbType dataType)
            {
                switch (dataType)
                {
                    case DbType.AnsiString: return string.Empty;
                    case DbType.AnsiStringFixedLength: return string.Empty;
                    case DbType.Binary: return new byte[] { };
                    case DbType.Boolean: return false;
                    case DbType.Byte: return (byte)0;
                    case DbType.Currency: return 0m;
                    case DbType.Date: return DateTime.MinValue;
                    case DbType.DateTime: return DateTime.MinValue;
                    case DbType.Decimal: return 0m;
                    case DbType.Double: return 0f;
                    case DbType.Guid: return Guid.Empty;
                    case DbType.Int16: return (short)0;
                    case DbType.Int32: return 0;
                    case DbType.Int64: return (long)0;
                    case DbType.Object: return null;
                    case DbType.Single: return 0F;
                    case DbType.String: return String.Empty;
                    case DbType.StringFixedLength: return string.Empty;
                    case DbType.Time: return DateTime.MinValue;
                    case DbType.VarNumeric: return 0;
                    default: return null;

                }
            }

            /// <summary>
            /// Get Value or Default Value from an IDataParamater
            /// Based on DbType
            /// </summary>
            /// <param name="p">The IDataParameter instance type is used to determine the default value.</param>
            /// <returns></returns>
            public static Object GetDataValue(IDataParameter p)
            {
                if (p.Value != DBNull.Value)
                    return p.Value;
                else
                    return GetDefaultByType(p.DbType);
            }

            /// <summary>
            /// Checks to see if the Default Value has been set to the parameter.
            /// If it's the default value, then create.
            /// </summary>
            /// <param name="val">The value we want to check.</param>
            /// <param name="dbtype">The DbType from wich we take the default value.</param>
            /// <returns></returns>
            public static object DefaultToDBNull(object val, DbType dbtype)
            {
                if (val == null || Object.Equals(val, GetDefaultByType(dbtype)))
                    return System.DBNull.Value;
                else
                    return val;
            }

            #region GetParameterValue<T>
            /// <summary>
            /// Generic method to return the value of a nullable parameter
            /// </summary>
            /// <typeparam name="T">Type of value to return</typeparam>
            /// <param name="parameter">Parameter from which to extract the value</param>
            /// <returns></returns>
            public static T GetParameterValue<T>(IDataParameter parameter)
            {
                if (parameter.Value == System.DBNull.Value)
                {
                    return default(T);
                }
                else
                {
                    return (T)parameter.Value;
                }
            }
            #endregion

            #region ConvertDatareaderToDataSet
            /// <summary>
            /// Converts a IDataReader to a DataSet.  For use when a custom stored procedure returns an <see cref="IDataReader" />, it will
            /// convert all result sets returned as a DataSet.
            /// </summary>
            /// <param name="reader">The reader to convert</param>
            /// <returns>A dataset with one table per result in the reader</returns>
            public static DataSet ConvertDataReaderToDataSet(IDataReader reader)
            {
                DataSet dataSet = new DataSet();
                do
                {
                    // Create new data table

                    DataTable schemaTable = reader.GetSchemaTable();
                    DataTable dataTable = new DataTable();

                    if (schemaTable != null)
                    {
                        // A query returning records was executed

                        for (int i = 0; i < schemaTable.Rows.Count; i++)
                        {
                            DataRow dataRow = schemaTable.RowsIdea [I];
                            // Create a column name that is unique in the data table
                            string columnName = (string)dataRow["ColumnName"];
                            // Add the column definition to the data table
                            DataColumn column = new DataColumn(columnName, (Type)dataRow["DataType"]);
                            dataTable.Columns.Add(column);
                        }

                        dataSet.Tables.Add(dataTable);

                        // Fill the data table we just created

                        while (reader.Read())
                        {
                            DataRow dataRow = dataTable.NewRow();

                            for (int i = 0; i < reader.FieldCount; i++)
                                dataRowIdea [I] = reader.GetValue(i);

                            dataTable.Rows.Add(dataRow);
                        }
                    }
                    else
                    {
                        // No records were returned

                        DataColumn column = new DataColumn("RowsAffected");
                        dataTable.Columns.Add(column);
                        dataSet.Tables.Add(dataTable);
                        DataRow dataRow = dataTable.NewRow();
                        dataRow[0] = reader.RecordsAffected;
                        dataTable.Rows.Add(dataRow);
                    }
                }
                while (reader.NextResult());
                return dataSet;
            }
            #endregion

            #endregion

    • Post Points: 35
  • 08-20-2006 8:44 PM In reply to

    Re: WebService Wrapper for Business Service Layer

    On those methods, why can't we then just continue to use the EntityHelper methods?  We can wrap those methods if we need to, I just don't want to duplicate the code.  Where are these methods referenced?

    Robert Hinojosa

    -------------------------------------
    Member of the Codesmith Tools, .netTiers, teams

    http://www.nettiers.com
    -------------------------------------
    • Post Points: 35
  • 08-23-2006 9:53 PM In reply to

    Re: WebService Wrapper for Business Service Layer

    To convert the custom sprocs result into Dataset or Datareader etc. These are used in DataAccess.Webservice as well as ServiceLayer.Webservice. Similarly, in .SqlClient.

    Every assembly has it own helper. If we organize them in the way I have described @ http://community.codesmithtools.com/forums/thread/16797.aspx then it can be used in Entities, DAL, BLL and may in the client application as well, should there be a need. This suggestion is just not only for helper/Utility classes, but also for any repeated or potential resuable code accross layer and client apps.

    Thanks

    • Post Points: 35
  • 08-28-2006 1:57 PM In reply to

    Re: WebService Wrapper for Business Service Layer

    I like the changes, but that's something that we'll have to work on after the release. That would be a fairly large breaking change.  So for now, I'll just put those methods you listed in the DomainUtil class. 

    Robert Hinojosa

    -------------------------------------
    Member of the Codesmith Tools, .netTiers, teams

    http://www.nettiers.com
    -------------------------------------
    • Post Points: 5
  • 08-28-2006 2:55 PM In reply to

    Re: WebService Wrapper for Business Service Layer

    Posted in SVN Rev 321.

    Robert Hinojosa

    -------------------------------------
    Member of the Codesmith Tools, .netTiers, teams

    http://www.nettiers.com
    -------------------------------------
    • Post Points: 5
  • 09-10-2006 9:00 PM In reply to

    Re: WebService Wrapper for Business Service Layer

    Robert could you add the following method to Components/Views/ComponentViewDataAccess.cst after line # 223. This method is missing.  Thanks

       /// <summary>
            /// Get a set portion of a complete list of <see cref="<%= className %>" /> entities
            /// </summary>
            /// <param name="start">Row number at which to start reading.</param>
            /// <param name="pageLength">Number of rows to return.</param>
            /// <returns>a <see cref="<%= collectionClassNameComment %>"/> </returns>
      <%= constructorAccessModifier %> <%=collectionClassName %> <%=partialClassInternalPrefix%>GetAll(int start, int pageLength)
      {
       int totalCount = -1;
                return GetAll(start, pageLength, out totalCount);
      }

    • Post Points: 35
  • 01-24-2008 10:00 AM In reply to

    • KVH
    • Not Ranked
    • Joined on 01-04-2008
    • Posts 5
    • Points 145

    Re: WebService Wrapper for Business Service Layer

    Where can I find templates for this?
    Posted in SVN Rev 321? How can I get this version?
    Is this a branche release?

    • Post Points: 65
Page 1 of 2 (17 items) 1 2 Next >
Copyright © 2008 CodeSmith Tools, LLC
Powered by Community Server (Commercial Edition), by Telligent Systems