Exemplo n.º 1
0
        public static void GetMsgListByPage(int page, out List<Message> msgs)
        {
            List<Message> buff = new List<Message>();            
            MariaDBHelper.ExecuteReader(
                "GetMessageByPage",
                CommandType.StoredProcedure,
                (MySqlDataReader dataReader) =>
                {
                    while (dataReader.Read())
                    {
                        long id = Convert.ToInt64(MariaDBHelper.GetData(dataReader, "Id"));
                        string composer = MariaDBHelper.GetData(dataReader, "Composer");
                        string content = MariaDBHelper.GetData(dataReader, "Content");
                        DateTime post_time = Convert.ToDateTime(MariaDBHelper.GetData(dataReader, "PostTime"));
                        int support = Convert.ToInt32(MariaDBHelper.GetData(dataReader, "Support"));
                        int oppose = Convert.ToInt32(MariaDBHelper.GetData(dataReader, "Oppose"));
                        int reply_num = Convert.ToInt32(MariaDBHelper.GetData(dataReader, "ReplyNum"));
                        int report = Convert.ToInt32(MariaDBHelper.GetData(dataReader, "Report"));
                        long reply_msgid = Convert.ToInt32(MariaDBHelper.GetData(dataReader, "ReplyMsgID"));

                        buff.Add(new Message(id, composer, content, post_time, support, oppose, reply_num, report, reply_msgid));
                    }
                },
                new MySqlParameter("@Page", page)
            );

            msgs = new List<Message>(buff.ToArray());
        }
Exemplo n.º 2
0
        public static List <int> GetListByResourceAndPage(int id, int page)
        {
            List <int> list = new List <int>();

            MariaDBHelper.ExecuteReader(
                "GetCommentsByResourceID",
                CommandType.StoredProcedure,
                (MySqlDataReader dataReader) =>
            {
                while (dataReader.Read())
                {
                    list.Add(Convert.ToInt32(MariaDBHelper.GetData(dataReader, "ID")));
                }
            },
                new MySqlParameter("ResourceID", id)
                );
            return(list);
        }
Exemplo n.º 3
0
        public List <int> GetChildren()
        {
            List <int> children = new List <int>();

            MariaDBHelper.ExecuteReader(
                "GetResourceChildren",
                CommandType.StoredProcedure,
                (MySqlDataReader dataReader) =>
            {
                while (dataReader.Read())
                {
                    children.Add(Convert.ToInt32(MariaDBHelper.GetData(dataReader, "Id")));
                }
            },
                new MySqlParameter("@Id", m_id)
                );
            return(children);
        }
Exemplo n.º 4
0
        public int LoginByWeibo(string code)
        {
            int loginStatus = 0;
            int uid         = 0;// new Weibo(code).Login();

            MariaDBHelper.ExecuteReader(
                "GetUserByWeibo",
                CommandType.StoredProcedure,
                (MySqlDataReader dataReader) =>
            {
                if (dataReader.Read())
                {
                    m_username  = MariaDBHelper.GetData(dataReader, "Username");
                    m_role      = MariaDBHelper.GetData(dataReader, "UserRole");
                    loginStatus = 1;
                }
            },
                new MySqlParameter("@WeiboUserId", uid)
                );
            return(loginStatus);
        }
Exemplo n.º 5
0
        public int Login()
        {
            string salt = string.Empty, passwordHash = string.Empty;

            MariaDBHelper.ExecuteReader(
                "GetUserByUsername",
                CommandType.StoredProcedure,
                (MySqlDataReader dataReader) =>
            {
                if (dataReader.Read())
                {
                    salt         = MariaDBHelper.GetData(dataReader, "Salt");
                    passwordHash = MariaDBHelper.GetData(dataReader, "PasswordHash");
                }
            },
                new MySqlParameter("UserName", m_username)
                );
            if (m_username.Length <= Variable.MinLength.UserName &&
                m_password.Length <= Variable.MinLength.Password)
            {
                return(-1);
            }
            else if (MariaDBHelper.GetHashCode(m_password + salt) == passwordHash)
            {
                object loginId = MariaDBHelper.ExecuteScalar(
                    "LoginUser",
                    CommandType.StoredProcedure,
                    new MySqlParameter("Ticket", m_ticket),
                    new MySqlParameter("UserName", m_username),
                    new MySqlParameter("LoginIP", m_loginIp),
                    new MySqlParameter("LoginTime", DateTime.Now),
                    new MySqlParameter("Status", Variable.State.Login.valid)
                    );
                return(Convert.ToInt32(loginId));
            }
            else
            {
                return(0);
            }
        }
Exemplo n.º 6
0
 public void GetUserInfo()
 {
     MariaDBHelper.ExecuteReader(
         "GetUserByUsername",
         CommandType.StoredProcedure,
         (MySqlDataReader dataReader) =>
     {
         if (dataReader.Read())
         {
             m_id           = Convert.ToInt32(MariaDBHelper.GetData(dataReader, "Id"));
             m_salt         = Convert.ToString(MariaDBHelper.GetData(dataReader, "Salt"));
             m_status       = Convert.ToString(MariaDBHelper.GetData(dataReader, "Status"));
             m_gender       = Convert.ToString(MariaDBHelper.GetData(dataReader, "Gender"));
             m_realName     = Convert.ToString(MariaDBHelper.GetData(dataReader, "RealName"));
             m_phoneNumber  = Convert.ToString(MariaDBHelper.GetData(dataReader, "PhoneNumber"));
             m_role         = Convert.ToString(MariaDBHelper.GetData(dataReader, "UserRole"));
             m_registerTime = Convert.ToString(MariaDBHelper.GetData(dataReader, "RegisterTime"));
             m_email        = Convert.ToString(MariaDBHelper.GetData(dataReader, "Email"));
         }
     },
         new MySqlParameter("@UserName", m_username)
         );
 }
Exemplo n.º 7
0
 public ResourceEntity(int id)
 {
     MariaDBHelper.ExecuteReader(
         "GetResourceById",
         CommandType.StoredProcedure,
         (MySqlDataReader dataReader) =>
     {
         if (dataReader.Read())
         {
             m_id           = id;
             m_parentFolder = Convert.ToInt32(MariaDBHelper.GetData(dataReader, "ParentFolder"));
             m_name         = MariaDBHelper.GetData(dataReader, "Name");
             m_uri          = MariaDBHelper.GetData(dataReader, "Uri");
             m_cover        = MariaDBHelper.GetData(dataReader, "Cover");
             m_type         = MariaDBHelper.GetData(dataReader, "Type");
             m_format       = MariaDBHelper.GetData(dataReader, "Format");
             m_composer     = MariaDBHelper.GetData(dataReader, "Composer");
             m_description  = MariaDBHelper.GetData(dataReader, "Description");
         }
     },
         new MySqlParameter("@Id", id)
         );
 }
Exemplo n.º 8
0
 public CommentEntity(int id)
 {
     MariaDBHelper.ExecuteReader(
         "GetCommentByID",
         CommandType.StoredProcedure,
         (MySqlDataReader dataReader) =>
     {
         if (dataReader.Read())
         {
             m_id         = id;
             m_resourceId = Convert.ToInt32(MariaDBHelper.GetData(dataReader, "ResourceId"));
             m_composer   = MariaDBHelper.GetData(dataReader, "Composer");
             m_content    = MariaDBHelper.GetData(dataReader, "Content");
             m_postTime   = Convert.ToDateTime(MariaDBHelper.GetData(dataReader, "PostTime"));
             m_support    = Convert.ToInt32(MariaDBHelper.GetData(dataReader, "Support"));
             m_oppose     = Convert.ToInt32(MariaDBHelper.GetData(dataReader, "Oppose"));
             m_replyNum   = Convert.ToInt32(MariaDBHelper.GetData(dataReader, "ReplyNum"));
             m_report     = Convert.ToInt32(MariaDBHelper.GetData(dataReader, "Report"));
             m_replyMsgID = Convert.ToInt32(MariaDBHelper.GetData(dataReader, "ReplyMsgID"));
         }
     },
         new MySqlParameter("@Id", id)
         );
 }