locked
Transfer data to and from Smart Client Application RRS feed

  • Question

  • I have created a Smart Client Application which fetches data from web service, modifies the data and sends it back via web service. The web service calls stored procedure to fetch/update data in HO database.

    For now, I have used dataset for sending and receiving data. This work perfectly fine. but i am not sure whether it is the best approach to transfer use datasets due to performance constraints.

    I have tried using custom object model, all my classes are inherited from Entity class the collection class are inherited from EntityCollection class which itself inherits System.Collection.CollectionBase

    I have tried using serialize and deserialize, but the call fails with error on the following line

    XmlSerializer s = new XmlSerializer(this.GetType());

    +  TypeHandle 'this.GetType().TypeHandle' threw an exception of type 'System.NotSupportedException' System.RuntimeTypeHandle {System.NotSupportedException}

    Below given is the class i have created.

    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Xml.Serialization;
    using System.IO;


    namespace PF.FS.VCS.Entities
    {
        /// </summary>
        [System.Xml.Serialization.XmlInclude(typeof(Lookups))]
        [System.Xml.Serialization.XmlInclude(typeof(LookupDetails))]
        [System.Xml.Serialization.XmlInclude(typeof(Employees))]
        [System.Xml.Serialization.XmlInclude(typeof(Visits))]
        [System.Xml.Serialization.XmlInclude(typeof(VisitResults))]
        [System.Xml.Serialization.XmlInclude(typeof(VisitResultReasons))]
        [System.Xml.Serialization.XmlInclude(typeof(VisitResultCompliances))]
        [Serializable()]
        public class EntityTranslation
        {
            private Lookups lookups = new Lookups();
            private LookupDetails lookupdetails = new LookupDetails();
            private Employees employees = new Employees();
            private Visits visits = new Visits();
            private VisitResults visitresults = new VisitResults();
            private VisitResultReasons visitresultreasons = new VisitResultReasons();
            private VisitResultCompliances visitresultcompliances = new VisitResultCompliances();

            #region Properties

            public Lookups LookupCollection
            {
                get { return lookups; }
                set { lookups = value; }
            }

            public LookupDetails LookupDetailCollection
            {
                get { return lookupdetails; }
                set { lookupdetails = value; }
            }

            public Employees EmployeeCollection
            {
                get { return employees; }
                set { employees = value; }
            }

            public Visits VisitCollection
            {
                get { return visits; }
                set { visits = value; }
            }

            public VisitResults VisitResultCollection
            {
                get { return visitresults; }
                set { visitresults = value; }
            }
            public VisitResultReasons VisitResultReasonCollection
            {
                get { return visitresultreasons; }
                set { visitresultreasons = value; }
            }
            public VisitResultCompliances VisitResultComplianceCollection
            {
                get { return visitresultcompliances; }
                set { visitresultcompliances = value; }
            }
            #endregion

            public EntityTranslation()
            {
            }

            public string Seralize()
            {
                String strOutput = string.Empty;
                XmlSerializer s = new XmlSerializer(this.GetType());
                StringWriter strWriter = new StringWriter();

                try
                {
                    s.Serialize(strWriter, this);
                    strOutput = strWriter.ToString();
                }
                finally
                {
                    strWriter.Close();
                }
                return strOutput;
            }

            public static EntityTranslation Deseralize(string xmlString)
            {
                EntityTranslation etObj = new EntityTranslation();
                StringReader strReader = new StringReader(xmlString);
                XmlSerializer serializer = new XmlSerializer(etObj.GetType());
                try
                {
                    etObj = (EntityTranslation)serializer.Deserialize(strReader);
                }
                finally
                {
                    strReader.Close();
                }
                return etObj;
            }
        }
    }

    Please let me know the best way to transfer data from web service to PDA and back to Web service.

     

    Tuesday, September 26, 2006 2:15 PM

Answers