コード例 #1
0
        public void CountUserLogin(string userid)
        {
            LoginCounts countLogin = this.GetLoginCountById(userid);

            if (countLogin != null)
            {
                countLogin.UserId = userid;
                if (string.IsNullOrEmpty(countLogin.NumberOfTimes.ToString()))
                {
                    countLogin.NumberOfTimes = 1;
                }
                else
                {
                    countLogin.NumberOfTimes = countLogin.NumberOfTimes + 1;
                }
                countLogin.LastLoggedInDate = DateTime.Parse(GenericHelpers.Date());
                this.Update(countLogin);
            }
            else
            {
                LoginCounts newcountLogin = new LoginCounts();
                newcountLogin.UserId = userid;
                if (string.IsNullOrEmpty(newcountLogin.NumberOfTimes.ToString()))
                {
                    newcountLogin.NumberOfTimes = 1;
                }
                else
                {
                    newcountLogin.NumberOfTimes = countLogin.NumberOfTimes + 1;
                }
                newcountLogin.LastLoggedInDate = DateTime.Parse(GenericHelpers.Date());
                this.Insert(newcountLogin);
            }
        }
コード例 #2
0
        public int Update(LoginCounts lc)
        {
            string commandText = "UPDATE " + fullTableName + " set " +
                                 FieldUserId.Quoted() + " = @UserId, " +
                                 FieldNumberOfTimes.Quoted() + " = @NumberOfTimes, " +
                                 FieldLastLoggedInDate.Quoted() + " =  @LastLoggedInDate " +
                                 " where " + FieldUserId.Quoted() + " = @UserId";

            Dictionary <string, object> parameters = new Dictionary <string, object>();

            parameters.Add("@UserId", lc.UserId);
            parameters.Add("@NumberOfTimes", lc.NumberOfTimes);
            parameters.Add("@LastLoggedInDate", lc.LastLoggedInDate);

            return(_database.Execute(commandText, parameters));
        }
コード例 #3
0
        public int Insert(LoginCounts lc)
        {
            //var lowerCaseEmail = user.Email == null ? null : user.Email.ToLower();

            string commandText = "insert into " + fullTableName +
                                 "(" + FieldUserId.Quoted() + ", " +
                                 FieldNumberOfTimes.Quoted() + ", " +
                                 FieldLastLoggedInDate.Quoted() + ")" +
                                 " VALUES (@UserId, @NumberOfTimes, @LastLoggedInDate);";
            Dictionary <string, object> parameters = new Dictionary <string, object>();

            parameters.Add("@UserId", lc.UserId);
            parameters.Add("@NumberOfTimes", lc.NumberOfTimes);
            parameters.Add("@LastLoggedInDate", lc.LastLoggedInDate);

            return(_database.Execute(commandText, parameters));
        }
コード例 #4
0
        internal static LoginCounts loadLoginCount(Dictionary <string, string> row)
        {
            if (row == null)
            {
                return(null);
            }
            if (row.Count == 0)
            {
                return(null);
            }
            LoginCounts LC = null;

            LC                  = (LoginCounts)Activator.CreateInstance(typeof(LoginCounts));
            LC.UserId           = row[FieldUserId];
            LC.NumberOfTimes    = string.IsNullOrEmpty(row[FieldNumberOfTimes]) ? 0 : long.Parse(row[FieldNumberOfTimes]);
            LC.LastLoggedInDate = string.IsNullOrEmpty(row[FieldLastLoggedInDate]) ? DateTime.Now : DateTime.Parse(row[FieldLastLoggedInDate]);

            return(LC);
        }