예제 #1
0
 /// <summary>
 /// Constructs a user from the output of a datareader. Assumes that there is data
 /// ready to be read from the current record 14/12/15
 /// </summary>
 private static User readUser(OdbcDataReader dataReader)
 {
     return new User(dataReader.GetInt16(0), dataReader.GetString(1),
     dataReader.GetString(3), dataReader.GetString(4), dataReader.GetString(5),
     dataReader.GetBoolean(6), dataReader.GetDateTime(7), dataReader.GetInt16(8),
     dataReader.GetInt16(9), dataReader.GetBoolean(10), dataReader.GetBoolean(11),
     dataReader.GetInt16(13));
 }
예제 #2
0
 /// <summary>
 /// Constructs an achievement from the output of a datareader. Assumes that there
 /// is data ready to be read from the current record 14/12/15
 /// </summary>
 private static Achievement readAchievement(OdbcDataReader dataReader)
 {
     return new Achievement(dataReader.GetInt16(0), dataReader.GetString(1),
     dataReader.GetString(2), dataReader.GetString(3), dataReader.GetString(4),
     dataReader.GetInt16(5), dataReader.GetDateTime(6), dataReader.GetBoolean(7));
 }
        //
        // GetUserFromReader
        //    A helper function that takes the current row from the OdbcDataReader
        // and hydrates a MembershiUser from the values. Called by the
        // MembershipUser.GetUser implementation.
        //
        private MembershipUser GetUserFromReader(OdbcDataReader reader)
        {
            object providerUserKey = reader.GetValue(0);
            string username = reader.GetString(1);
            string email = reader.GetString(2);

            string passwordQuestion = "";
            if (reader.GetValue(3) != DBNull.Value)
                passwordQuestion = reader.GetString(3);

            string comment = "";
            if (reader.GetValue(4) != DBNull.Value)
                comment = reader.GetString(4);

            bool isApproved = reader.GetBoolean(5);
            bool isLockedOut = reader.GetBoolean(6);
            DateTime creationDate = reader.GetDateTime(7);

            DateTime lastLoginDate = new DateTime();
            if (reader.GetValue(8) != DBNull.Value)
                lastLoginDate = reader.GetDateTime(8);

            DateTime lastActivityDate = reader.GetDateTime(9);
            DateTime lastPasswordChangedDate = reader.GetDateTime(10);

            DateTime lastLockedOutDate = new DateTime();
            if (reader.GetValue(11) != DBNull.Value)
                lastLockedOutDate = reader.GetDateTime(11);

            MembershipUser u = new MembershipUser((this.Name == null) ? "SimpleMysqlMembershipProvider" : this.Name,
                                                  username,
                                                  providerUserKey,
                                                  email,
                                                  passwordQuestion,
                                                  comment,
                                                  isApproved,
                                                  isLockedOut,
                                                  creationDate,
                                                  lastLoginDate,
                                                  lastActivityDate,
                                                  lastPasswordChangedDate,
                                                  lastLockedOutDate);

            return u;
        }
        private OpenIdMembershipUser GetUserFromReader(OdbcDataReader reader)
        {
            string username = reader.GetString(0);

            string openId = reader.IsDBNull(1) ? string.Empty : reader.GetString(1);
            string email = reader.IsDBNull(2) ? string.Empty : reader.GetString(2);
            string passwordQuestion = "";
            if (reader.GetValue(3) != DBNull.Value)
                passwordQuestion = reader.GetString(3);

            string comment = "";
            if (reader.GetValue(4) != DBNull.Value)
                comment = reader.GetString(4);

            bool isApproved = reader.GetBoolean(5);

            DateTime creationDate = reader.GetDateTime(6);

            DateTime lastLoginDate = new DateTime();
            if (reader.GetValue(7) != DBNull.Value)
                lastLoginDate = reader.GetDateTime(7);

            DateTime lastActivityDate = reader.GetDateTime(8);

            DateTime lastPasswordChangedDate = reader.GetDateTime(9);

            object providerUserKey = reader.GetValue(10);

            bool isLockedOut = reader.GetBoolean(11);

            DateTime lastLockedOutDate = new DateTime();
            if (reader.GetValue(12) != DBNull.Value)
                lastLockedOutDate = reader.GetDateTime(12);

            OpenIdMembershipUser u = new OpenIdMembershipUser(
                                                  this.Name,
                                                  openId,
                                                  username,
                                                  providerUserKey,
                                                  email,
                                                  passwordQuestion,
                                                  comment,
                                                  isApproved,
                                                  isLockedOut,
                                                  creationDate,
                                                  lastLoginDate,
                                                  lastActivityDate,
                                                  lastPasswordChangedDate,
                                                  lastLockedOutDate);

            return u;
        }
예제 #5
0
        protected bool LogMessageOnDatabase(OdbcDataReader toSend)
        {
            try
             {
            string query = "INSERT INTO SMS_Log (MobilePhone, SMS_Day, SMS_Hour, SMS_Text, DateTimeSent, ID_Group, SMS_Sent) VALUES ('" +
                           toSend["MobilePhone"].ToString() + "', '" + toSend["SMS_Day"].ToString() + "', '" + ((DateTime)toSend.GetDateTime(toSend.GetOrdinal("SMS_Hour"))).ToString("hh:mm:ss") + "', '" +
                           toSend["SMS_Text"].ToString() + "', '" + DateTime.Now + "', '" + toSend["ID_Group"].ToString() + "', '" +
                           DateTime.Now + "')";

            int r = database.ExecuteCommand(query);

            if (r < 1)
               return false;

            return true;
             }
             catch (Exception ex)
             {
            if (Debug)
               Console.WriteLine("Engine.LogMessageOnDatabase Exception: {0}", ex.Message);

            return false;
             }
        }
예제 #6
0
 public static DateTime? GetNullableDatetime(OdbcDataReader reader, string columnName)
 {
     int x = reader.GetOrdinal(columnName);
     return reader.IsDBNull(x) ? (DateTime?)null : reader.GetDateTime(x);
 }
        //
        // GetProfileInfoFromReader
        //  Takes the current row from the OdbcDataReader
        // and populates a ProfileInfo object from the values.
        //
        private ProfileInfo GetProfileInfoFromReader(OdbcDataReader reader)
        {
            string username = reader.GetString(0);

            DateTime lastActivityDate = new DateTime();
            if (reader.GetValue(1) != DBNull.Value)
                lastActivityDate = reader.GetDateTime(1);

            DateTime lastUpdatedDate = new DateTime();
            if (reader.GetValue(2) != DBNull.Value)
                lastUpdatedDate = reader.GetDateTime(2);

            bool isAnonymous = reader.GetBoolean(3);

            // ProfileInfo.Size not currently implemented.
            ProfileInfo p = new ProfileInfo(username,
                isAnonymous, lastActivityDate, lastUpdatedDate, 0);

            return p;
        }
예제 #8
0
        public static bool CreateForm(OdbcDataReader reader, Registration reg)
        {
            int fCount = reader.FieldCount;
            for (int i = 0; i < fCount; i++)
            {
                string name = reader.GetName(i);

                // Map to DB field. Need to change if db changed
                switch (name) {
                    case "regis_id": reg._regisID = reader.GetInt32(i);
                                      break;
                    case "transaction_id": reg._transactionID = reader.GetInt32(i);
                                      break;
                    case "transaction_code": reg._transactionCode = reader.GetString(i);
                                      break;
                    case "regis_date": reg._regisdate = new DateTime(reader.GetDateTime(i).Ticks);
                                      break;
                    case "student_id": reg._studentID = reader.GetInt32(i);
                                      break;
                    case "promotion_id": reg._promotionID = reader.GetInt32(i);
                                      break;
                    case "course_id": reg._courseID = reader.GetInt32(i);
                                      break;
                    case "branch_id": reg._branchID = reader.GetInt32(i);
                                      break;

                    case "full_cost": reg._fullCost = reader.GetInt32(i);
                                      break;
                    case "discounted_cost": reg._discountedCost = reader.GetInt32(i);
                                      break;
                    case "seat_no": reg._seatNo = reader.GetString(i);
                                      break;
                    case "note": reg._note = reader.GetString(i);
                                      break;
                    case "paid_method": reg._paidMethod = reader.GetInt32(i);
                                      break;
                    case "paid_round": reg._paidRound = reader.GetInt32(i);
                                      break;
                    case "paid_date": reg._paiddate = new DateTime(reader.GetDateTime(i).Ticks);
                                      break;
                    case "username": reg._username = reader.GetString(i);
                                      break;
                    case "status": reg._status = reader.GetInt32(i);
                                      break;
                    case "is_paid": reg._isPaid = reader.GetInt32(i) > 0 ? true : false;
                                      break;

                    // helper info
                    case "bts_course_id":
                                      reg._btsCourseID = reader.GetString(i);
                                      break;
                    case "student_firstname":
                                      reg._studentFirstname = reader.GetString(i);
                                      break;
                    case "student_surname":
                                      reg._studentSurname = reader.GetString(i);
                                      break;
                    case "student_school":
                                      reg._studentSchool = reader.GetString(i);
                                      break;
                    case "student_level":
                                      reg._studentLevel = reader.GetInt32(i);
                                      break;
                    case "course_name":
                                      reg._courseName = reader.GetString(i);
                                      break;
                    case "course_type":
                                      reg._courseType = reader.GetString(i);
                                      break;
                    case "course_category":
                                      reg._courseCategotry = reader.GetString(i);
                                      break;
                    case "start_date": reg._courseStart = new DateTime(reader.GetDateTime(i).Ticks);
                                      break;
                    case "end_date": reg._courseEnd = new DateTime(reader.GetDateTime(i).Ticks);
                                      break;

                    case "course_short_name":
                                      reg._courseShortName = reader.GetString(i);
                                      break;
                    case "branch_code":
                                      reg._branchCode = reader.GetString(i);
                                      break;

                }
            }
            return reader.HasRows;
        }
예제 #9
0
        public static bool CreateForm(OdbcDataReader reader, PaymentHistory paymentHistory)
        {
            int fCount = reader.FieldCount;
            for (int i = 0; i < fCount; i++)
            {
                string name = reader.GetName(i);

                // Map to DB field. Need to change if db changed
                switch (name)
                {
                    case "payment_id": paymentHistory._paymentID = reader.GetInt32(i);
                        break;
                    case "course_id": paymentHistory._courseID = reader.GetInt32(i);
                        break;
                    case "paid_cost": paymentHistory._paidCost = reader.GetInt32(i);
                        break;
                    case "paid_date": paymentHistory._paidDate = new DateTime(reader.GetDateTime(i).Ticks);
                        break;
                    case "sum_all_cost": paymentHistory._sumAllCost = reader.GetInt32(i);
                        break;
                    case "sum_max_payable": paymentHistory._sumMaxPayable = reader.GetInt32(i);
                        break;
                    case "sum_paid_cost": paymentHistory._sumPaidCost = reader.GetInt32(i);
                        break;
                    case "cost_info": paymentHistory._costInfo = reader.GetString(i);
                        break;
                    case "paid_round": paymentHistory._paidRound = reader.GetInt32(i);
                        break;
                    case "receiver_teacher_id": paymentHistory._receiverTeacherID = reader.GetInt32(i);
                        break;
                    case "username": paymentHistory._username = reader.GetString(i);
                        break;
                    case "branch_id": paymentHistory._branchID = reader.GetInt32(i);
                        break;

                    // helper info
                }
            }
            return reader.HasRows;
        }