Пример #1
0
        private void Start()
        {
            User user = UserLab.GetUser("1095204049");

            print(user.ReceiveTaskNum);
            print(user.AccomplishTaskNum);
            print(user.ReleaseTaskNum);
            print("1345");
        }
Пример #2
0
        private static void SaveImage()
        {
            MySqlConnection connection = UserLab.Connect();
            string          sql        = "UPDATE user SET user_avatar = @image where user_id = 4";
            string          textPath   = Application.dataPath + "/Image/avatar.jpg";
            FileStream      fs         = new FileStream(textPath, FileMode.Open);
            MySqlCommand    command    = new MySqlCommand(sql, connection);

            command.Parameters.Add("@image", MySqlDbType.Blob);
            byte[] fileData = new byte[fs.Length + 1];
            fs.Read(fileData, 0, (int)fs.Length);
            command.Parameters["@image"].Value = fileData;
            command.ExecuteNonQuery();
        }
Пример #3
0
        private static void ReadImage()
        {
            MySqlConnection connection = UserLab.Connect();
            string          sql        = "select user_avatar from user where user_id = 4";
            MySqlCommand    command    = new MySqlCommand(sql, connection);
            MySqlDataReader reader     = command.ExecuteReader();

            if (reader.Read())
            {
                long   len    = reader.GetBytes(0, 0, null, 0, 0);
                byte[] buffer = new byte[len];
                reader.GetBytes(1, 0, buffer, 0, (int)len);
                FileStream fileStream = new FileStream(
                    Application.dataPath + "/Image/avatar_read.jpg", FileMode.Create, FileAccess.Write);
                fileStream.Write(buffer, 0, buffer.Length);
                fileStream.Close();
            }
        }