Exemplo n.º 1
0
        /**************************************************************************************************/
        public override void BackgroundLoadWork()
        {
            using (SqlConnection connection = new SqlConnection(BCDB2.Instance.getConnectionString()))
            {
                connection.Open();
                SqlCommand cmdProcedure = new SqlCommand("sp_3_LoadFollowupCohort", connection);
                cmdProcedure.CommandType = CommandType.StoredProcedure;

                try
                {
                    SqlDataReader reader = cmdProcedure.ExecuteReader(CommandBehavior.CloseConnection);

                    if (reader != null)
                    {
                        while (reader.Read())
                        {

                            FollowupCohortEntry hrbqe = new FollowupCohortEntry();
                            for (int i = 0; i < reader.FieldCount; i++)
                            {
                                if (reader.IsDBNull(i) == false)
                                {
                                    foreach (FieldInfo fi in hrbqe.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public))
                                    {
                                        string name = fi.Name;
                                        if (name == reader.GetName(i))
                                        {
                                            fi.SetValue(hrbqe, reader.GetValue(i));
                                        }
                                    }
                                }
                            }
                            FollowupCohortPeople.Add(hrbqe);

                        }
                        reader.Close();
                    }
                }
                catch (Exception e)
                {
                    Logger.Instance.WriteToLog(e.ToString());
                }
            }
        }
Exemplo n.º 2
0
        /**************************************************************************************************/
        public override void BackgroundLoadWork()
        {
            using (SqlConnection connection = new SqlConnection(BCDB2.Instance.getConnectionString()))
            {
                connection.Open();
                SqlCommand cmdProcedure = new SqlCommand("sp_3_LoadFollowupCohort", connection);
                cmdProcedure.CommandType = CommandType.StoredProcedure;

                try
                {
                    SqlDataReader reader = cmdProcedure.ExecuteReader(CommandBehavior.CloseConnection);

                    if (reader != null)
                    {
                        while (reader.Read())
                        {
                            FollowupCohortEntry hrbqe = new FollowupCohortEntry();
                            for (int i = 0; i < reader.FieldCount; i++)
                            {
                                if (reader.IsDBNull(i) == false)
                                {
                                    foreach (FieldInfo fi in hrbqe.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public))
                                    {
                                        string name = fi.Name;
                                        if (name == reader.GetName(i))
                                        {
                                            fi.SetValue(hrbqe, reader.GetValue(i));
                                        }
                                    }
                                }
                            }
                            FollowupCohortPeople.Add(hrbqe);
                        }
                        reader.Close();
                    }
                }
                catch (Exception e)
                {
                    Logger.Instance.WriteToLog(e.ToString());
                }
            }
        }