internal static bool getHealthVaultModelData()
        {
            string connectionString = string.Empty;
            connectionString = @"Data Source=dev05\sql2k8;Initial Catalog=TSGPK_Healthvault;Integrated Security=True;Asynchronous Processing=true";
            Database dbGetHealthVaultModules = new SqlDatabase(connectionString);
            Database dbGetHealthVaultTypes = new SqlDatabase(connectionString);
            Database dbGetHealthTypeMapping = new SqlDatabase(connectionString);
            Database dbGetHealthVaultModuleTypeMapping = new SqlDatabase(connectionString);
            DbCommand cmdHealthVaultModules = dbGetHealthVaultModules.GetStoredProcCommand("TSG_HV_GetHealthVaultModules");
            DbCommand cmdHealthVaultTypes = dbGetHealthVaultTypes.GetStoredProcCommand("TSG_HV_GetHealthVaultTypes");
            DbCommand cmdHealthTypeMapping = dbGetHealthTypeMapping.GetStoredProcCommand("TSG_HV_GetHealthTypeMapping");
            DbCommand cmdHealthVaultModuleTypeMapping = dbGetHealthVaultModuleTypeMapping.GetStoredProcCommand("TSG_HV_GetHealthVaultModuleTypeMapping");

            try
            {

                IAsyncResult HealthVaultModules = dbGetHealthVaultModules.BeginExecuteReader(cmdHealthVaultModules, (res1) =>
                 {
                     Database db1 = (Database)res1.AsyncState;
                     using (IDataReader reader = db1.EndExecuteReader(res1))
                     {
                       while (reader.Read())
                         {
                             Console.WriteLine("HealthvaultModule");
                             var _healthvaultType = new HealthVaultType();
                             _healthvaultType.ID = Convert.ToInt32(reader["Id"]);
                             _healthvaultType.TypeName = Convert.ToString(reader["TypeName"]);
                             _healthvaultType.ModuleID = new Guid(reader["ModuleID"].ToString());
                             _healthvaultType.TypeIDs = Convert.ToString(reader["TypeIDs"]);
                             _healthvaultType.ClassName = Convert.ToString(reader["ClassName"]);
                             _healthvaultType.keyColumn = Convert.ToString(reader["KeyColumn"]);
                             _healthvaultType.keyColumnValue = Convert.ToString(reader["KeyColumnValue"]);
                             _healthvaultTypes.Add(_healthvaultType);
                         }
                         Interlocked.Increment(ref counter);
                         reader.Close();
                     }
                 }, dbGetHealthVaultModules);

                IAsyncResult HealthVaultFields = dbGetHealthVaultTypes.BeginExecuteReader(cmdHealthVaultTypes, (res2) =>
                {
                    Database db2 = (Database)res2.AsyncState;
                    using (IDataReader reader = db2.EndExecuteReader(res2))
                    {
                        while (reader.Read())
                        {
                            Console.WriteLine("HealthvaultModuleField");
                            var _field = new HealthVaultFields();
                            _field.FieldID = Convert.ToInt32(reader["DetailId"]);
                            _field.FieldName = Convert.ToString(reader["Name"]);
                            _field.FieldType = (Convert.ToBoolean(reader["isLookUp"])) ? "Codable" : "noncodable";
                            _field.isPremitive = Convert.ToBoolean(reader["isPremitiveType"]);
                            _field.PremitiveType = Convert.ToString(reader["PremitiveType"]);
                            _fields.Add(_field);
                        }
                        Interlocked.Increment(ref counter);
                        reader.Close();
                    }

                }, dbGetHealthVaultTypes);

                IAsyncResult HealthVaultModuleTypeMapping = dbGetHealthTypeMapping.BeginExecuteReader(cmdHealthTypeMapping, (res3) =>
                {
                    Database db3 = (Database)res3.AsyncState;
                    using (IDataReader reader = db3.EndExecuteReader(res3))
                    {
                        while (reader.Read())
                        {
                            Console.WriteLine("HealthvaultModuleTypeMapping");
                            var _subfield = new HealthVaultFieldsMapping();

                            _subfield.MappingID = Convert.ToInt32(reader["MappingID"]);
                            _subfield.MasterFieldID = Convert.ToInt32(reader["MasterTypeID"]);
                            _subfield.SubFieldID = Convert.ToInt32(reader["SubTypeID"]);
                            _subfield.isRequired = Convert.ToBoolean(reader["isRequired"]);
                            _mappings.Add(_subfield);
                        }
                        Interlocked.Increment(ref counter);
                        reader.Close();
                    }

                }, dbGetHealthTypeMapping);

                  IAsyncResult HealthTypeMapping = dbGetHealthVaultModuleTypeMapping.BeginExecuteReader(cmdHealthVaultModuleTypeMapping, (res4) =>
                {
                    Database db4 = (Database)res4.AsyncState;
                    using (IDataReader reader = db4.EndExecuteReader(res4))
                    {
                        while (reader.Read())
                        {
                            Console.WriteLine("HealthvaultModuleFieldeMapping");
                            var _typemapping = new HealthVaultTypeFieldMapping();

                            _typemapping.MappingID = Convert.ToInt32(reader["ID"]);
                            _typemapping.ModuleID = Convert.ToInt32(reader["ModuleID"]);
                            _typemapping.MasterTypeID = Convert.ToInt32(reader["MasterTypeID"]);
                            _typemapping.FieldID = Convert.ToInt32(reader["isRequired"]);
                            _typemappings.Add(_typemapping);
                        }
                      Interlocked.Increment(ref counter);
                      reader.Close();
                    }
                }, dbGetHealthVaultModuleTypeMapping);

                  while (counter < 4)
                  {
                      System.Threading.Thread.Sleep(10);
                  }
                  List<HealthModel> a = gethealthVaultModelStructure();
                  ConsoleApplication3.GenerateDynamicCode module = new ConsoleApplication3.GenerateDynamicCode();
                  module.createScriptForHalthVaultModuleItem(a, true);
                return true;

            }
            catch (Exception ex)
            {
                return false;
            }
        }