Пример #1
0
            public static Subheader UpdateFile(ServerUserInformation serverUser, ProjectFileInformation fileInfo)
            {
                MySqlCommand cmd;

                try
                {
                    cmd = new MySqlCommand("UPDATE Files SET file_data = @file_data, file_name = '" + fileInfo.file_name + "' WHERE file_id = '" + fileInfo.file_id + "';", con);
                    cmd.Parameters.Add("@file_data", MySqlDbType.Binary, fileInfo.file_data.Length).Value = fileInfo.file_data;
                }
                catch { return(Subheader.DBCON_ERROR); }

                try
                {
                    if (cmd.ExecuteNonQuery() <= 0)
                    {
                        return(Subheader.DBREG_ERROR);
                    }
                    return(Subheader.NULL);
                }
                catch (MySqlException e)
                {
                    if (e.Number == 2627)
                    {
                        return(Subheader.DBEXST_ERROR);
                    }
                    return(Subheader.DBQRY_ERROR);
                }
            }
Пример #2
0
            public static Subheader RemoveFile(ServerUserInformation serverUser, ProjectFileInformation fileInfo)
            {
                MySqlCommand cmd;

                try
                {
                    cmd = new MySqlCommand("DELETE FROM Files WHERE file_id = '" + fileInfo.file_id + "';", con);
                }
                catch (Exception) { return(Subheader.PROJ_ERROR); }

                try
                {
                    if (cmd.ExecuteNonQuery() <= 0)
                    {
                        return(Subheader.DBQRY_ERROR);
                    }

                    return(Subheader.NULL);
                }
                catch (MySqlException e)
                {
                    if (e.Number == 2627)
                    {
                        return(Subheader.DBEXST_ERROR);
                    }
                    return(Subheader.DBQRY_ERROR);
                }
            }
Пример #3
0
            public static Subheader CreateFile(ServerUserInformation serverUser, ProjectInformation projInfo, ProjectFileInformation fileInfo)
            {
                MySqlCommand cmd;

                try
                {
                    cmd = new MySqlCommand("INSERT INTO Users (file_id, file_data, file_name, project_id) " +
                                           "VALUES ('" + projInfo.project_id + "',@file_data,'" + fileInfo.file_name +
                                           "', '" + fileInfo.project_id + "');", con);
                    cmd.Parameters.Add("@file_data", MySqlDbType.Binary, fileInfo.file_data.Length).Value = fileInfo.file_data;
                }
                catch { return(Subheader.PROJ_ERROR); }

                try
                {
                    if (cmd.ExecuteNonQuery() <= 0)
                    {
                        return(Subheader.DBREG_ERROR);
                    }
                    return(Subheader.NULL);
                }
                catch (MySqlException e)
                {
                    if (e.Number == 2627)
                    {
                        return(Subheader.DBEXST_ERROR);
                    }
                    return(Subheader.DBQRY_ERROR);
                }
            }