示例#1
0
        public Demographics GetDemographics(string accountId)
        {
            Demographics demo = null;

            if (!String.IsNullOrEmpty(accountId) || !String.IsNullOrEmpty(this.AccountID))
            {
                string records = string.Empty;

                try
                {
                    records = _indivoClient.Accounts_X_RecordsGet(accountId, null, new KeyValuePair<string, object>());
                }
                catch {}

                if (!String.IsNullOrEmpty(records))
                {
                    List<Record> recordList = SerializationHelper.DeserializeObject<List<Record>>(records);

                    if (recordList != null)
                    {
                        foreach (Record record in recordList)
                        {
                            // do something
                            string demoId = record.demographics.document_id;

                            if (!String.IsNullOrEmpty(demoId))
                            {
                                string demographicResult = _indivoClient.Records_X_Documents_X_Get(record.id, demoId, new KeyValuePair<string, object>());
                                demo = SerializationHelper.DeserializeObject<Demographics>(demographicResult);

                                break;
                            }
                        }
                    }
                }
            }

            //if demographic data can't be retrieved, dummy up some data for the prototype
            if (demo == null)
            {
                demo = new Demographics();
                demo.dateOfBirth = new DateTime(1953, 7, 24);
                demo.gender = "Female";

                if (!String.IsNullOrEmpty(ConfigurationManager.AppSettings["avatarGender"]))
                    demo.gender = ConfigurationManager.AppSettings["avatarGender"];
            }

            Console.WriteLine(demo.dateOfBirth.ToString());
            return demo;
        }
 public static bool LoadFromFile(string fileName, out Demographics obj)
 {
     System.Exception exception = null;
     return LoadFromFile(fileName, out obj, out exception);
 }
 public static bool LoadFromFile(string fileName, out Demographics obj, out System.Exception exception)
 {
     return LoadFromFile(fileName, Encoding.UTF8, out obj, out exception);
 }
 /// <summary>
 /// Deserializes xml markup from file into an Demographics object
 /// </summary>
 /// <param name="fileName">string xml file to load and deserialize</param>
 /// <param name="obj">Output Demographics object</param>
 /// <param name="exception">output Exception value if deserialize failed</param>
 /// <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns>
 public static bool LoadFromFile(string fileName, System.Text.Encoding encoding, out Demographics obj, out System.Exception exception)
 {
     exception = null;
     obj = default(Demographics);
     try
     {
         obj = LoadFromFile(fileName, encoding);
         return true;
     }
     catch (System.Exception ex)
     {
         exception = ex;
         return false;
     }
 }
 public static bool Deserialize(string xml, out Demographics obj)
 {
     System.Exception exception = null;
     return Deserialize(xml, out obj, out exception);
 }
 /// <summary>
 /// Deserializes workflow markup into an Demographics object
 /// </summary>
 /// <param name="xml">string workflow markup to deserialize</param>
 /// <param name="obj">Output Demographics object</param>
 /// <param name="exception">output Exception value if deserialize failed</param>
 /// <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns>
 public static bool Deserialize(string xml, out Demographics obj, out System.Exception exception)
 {
     exception = null;
     obj = default(Demographics);
     try
     {
         obj = Deserialize(xml);
         return true;
     }
     catch (System.Exception ex)
     {
         exception = ex;
         return false;
     }
 }