public int BackupItem(string tempFolder, XmlWriter writer, ServiceProviderItem item, ResourceGroupInfo group)
        {
            if (item is SqlDatabase)
            {
                // backup database
                DatabaseServer sql = GetDatabaseServer(item.ServiceId);

                string backupName       = String.Format("DatabaseBackup_{0}.zip", item.Id);
                string remoteBackupFile = sql.BackupDatabase(item.Name, backupName, true);

                // download remote backup
                string localBackupPath = Path.Combine(tempFolder, backupName);

                byte[]     buffer = null;
                FileStream stream = new FileStream(localBackupPath, FileMode.Create, FileAccess.Write);

                int  offset = 0;
                long length = 0;
                do
                {
                    // read remote content
                    buffer = sql.GetTempFileBinaryChunk(remoteBackupFile, offset, FILE_BUFFER_LENGTH);

                    // write remote content
                    stream.Write(buffer, 0, buffer.Length);

                    length += buffer.Length;
                    offset += FILE_BUFFER_LENGTH;
                }while (buffer.Length == FILE_BUFFER_LENGTH);
                stream.Close();

                // add file pointer

                BackupController.WriteFileElement(writer, "DatabaseBackup", backupName, length);

                // store meta item
                SqlDatabase   database   = sql.GetDatabase(item.Name);
                XmlSerializer serializer = new XmlSerializer(typeof(SqlDatabase));
                serializer.Serialize(writer, database);
            }
            else if (item is SqlUser)
            {
                // backup user
                DatabaseServer sql = GetDatabaseServer(item.ServiceId);

                SqlUser userItem = item as SqlUser;

                // store user info
                SqlUser user = sql.GetUser(item.Name, GetSqlDatabasesArray(item.PackageId, item.GroupName));
                user.Password = userItem.Password;

                XmlSerializer serializer = new XmlSerializer(typeof(SqlUser));
                serializer.Serialize(writer, user);
            }

            return(0);
        }
        public static SqlUser GetSqlUser(int itemId)
        {
            // load meta item
            SqlUser item = (SqlUser)PackageController.GetPackageItem(itemId);

            // load service item
            DatabaseServer sql  = GetDatabaseServer(item.ServiceId);
            SqlUser        user = sql.GetUser(item.Name, GetSqlDatabasesArray(item.PackageId, item.GroupName));

            // add common properties
            user.Id        = item.Id;
            user.PackageId = item.PackageId;
            user.ServiceId = item.ServiceId;
            user.Password  = CryptoUtils.Decrypt(item.Password);
            user.GroupName = item.GroupName;

            return(user);
        }