api-defaultvalue: fix backup
This commit is contained in:
parent
4ba2223fa1
commit
e1f7b7365a
@ -171,8 +171,8 @@ namespace ASC.Data.Backup
|
||||
StorageType = response.StorageType,
|
||||
StorageParams = response.StorageParams.ToDictionary(r => r.Key, r => r.Value) ?? new Dictionary<string, string>(),
|
||||
CronParams = new CronParams(response.Cron),
|
||||
BackupMail = response.BackupMail,
|
||||
BackupsStored = response.NumberOfBackupsStored,
|
||||
BackupMail = response.BackupMail ? (bool?)true : null,
|
||||
BackupsStored = response.NumberOfBackupsStored == 0 ? null : (int?)response.NumberOfBackupsStored,
|
||||
LastBackupTime = response.LastBackupTime
|
||||
};
|
||||
|
||||
@ -197,9 +197,9 @@ namespace ASC.Data.Backup
|
||||
var Schedule = new CreateScheduleRequest
|
||||
{
|
||||
TenantId = TenantManager.GetCurrentTenant().TenantId,
|
||||
BackupMail = schedule.BackupMail,
|
||||
BackupMail = schedule.BackupMail == null ? false : (bool)schedule.BackupMail,
|
||||
Cron = schedule.CronParams.ToString(),
|
||||
NumberOfBackupsStored = schedule.BackupsStored,
|
||||
NumberOfBackupsStored = schedule.BackupsStored == null ? 0 : (int)schedule.BackupsStored,
|
||||
StorageType = schedule.StorageType,
|
||||
StorageParams = schedule.StorageParams
|
||||
};
|
||||
@ -344,8 +344,8 @@ namespace ASC.Data.Backup
|
||||
public BackupStorageType StorageType { get; set; }
|
||||
public Dictionary<string, string> StorageParams { get; set; }
|
||||
public CronParams CronParams { get; set; }
|
||||
public bool BackupMail { get; set; }
|
||||
public int BackupsStored { get; set; }
|
||||
public bool? BackupMail { get; set; }
|
||||
public int? BackupsStored { get; set; }
|
||||
public DateTime LastBackupTime { get; set; }
|
||||
}
|
||||
|
||||
|
@ -1,161 +1,161 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using ASC.Api.Core.Middleware;
|
||||
using ASC.Common;
|
||||
using ASC.Data.Backup.Contracts;
|
||||
using ASC.Data.Backup.Models;
|
||||
using ASC.Web.Api.Routing;
|
||||
using ASC.Api.Core.Middleware;
|
||||
using ASC.Common;
|
||||
using ASC.Data.Backup.Contracts;
|
||||
using ASC.Data.Backup.Models;
|
||||
using ASC.Web.Api.Routing;
|
||||
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace ASC.Data.Backup.Controllers
|
||||
{
|
||||
[DefaultRoute]
|
||||
[ApiController]
|
||||
public class BackupController
|
||||
{
|
||||
private BackupAjaxHandler BackupHandler { get; }
|
||||
public BackupController(BackupAjaxHandler backupAjaxHandler)
|
||||
{
|
||||
BackupHandler = backupAjaxHandler;
|
||||
}
|
||||
/// <summary>
|
||||
/// Returns the backup schedule of the current portal
|
||||
/// </summary>
|
||||
/// <category>Backup</category>
|
||||
/// <returns>Backup Schedule</returns>
|
||||
[Read("getbackupschedule")]
|
||||
public BackupAjaxHandler.Schedule GetBackupSchedule()
|
||||
{
|
||||
return BackupHandler.GetSchedule();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create the backup schedule of the current portal
|
||||
/// </summary>
|
||||
/// <param name="storageType">Storage type</param>
|
||||
/// <param name="storageParams">Storage parameters</param>
|
||||
/// <param name="backupsStored">Max of the backup's stored copies</param>
|
||||
/// <param name="cronParams">Cron parameters</param>
|
||||
/// <param name="backupMail">Include mail in the backup</param>
|
||||
/// <category>Backup</category>
|
||||
[Create("createbackupschedule")]
|
||||
public void CreateBackupSchedule(BackupStorageType storageType, [FromQuery] Dictionary<string, string> storageParams, int backupsStored, [FromBody] BackupAjaxHandler.CronParams cronParams, bool backupMail)
|
||||
{
|
||||
BackupHandler.CreateSchedule(storageType, storageParams, backupsStored, cronParams, backupMail);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Delete the backup schedule of the current portal
|
||||
/// </summary>
|
||||
/// <category>Backup</category>
|
||||
[Delete("deletebackupschedule")]
|
||||
public void DeleteBackupSchedule()
|
||||
{
|
||||
BackupHandler.DeleteSchedule();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Start a backup of the current portal
|
||||
/// </summary>
|
||||
/// <param name="storageType">Storage Type</param>
|
||||
/// <param name="storageParams">Storage Params</param>
|
||||
/// <param name="backupMail">Include mail in the backup</param>
|
||||
/// <category>Backup</category>
|
||||
/// <returns>Backup Progress</returns>
|
||||
[Create("startbackup")]
|
||||
public BackupProgress StartBackup(Models.Backup backup)
|
||||
{
|
||||
BackupHandler.StartBackup(backup.StorageType, backup.StorageParams ?? new Dictionary<string, string>(), backup.BackupMail);
|
||||
return BackupHandler.GetBackupProgress();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the progress of the started backup
|
||||
/// </summary>
|
||||
/// <category>Backup</category>
|
||||
/// <returns>Backup Progress</returns>
|
||||
[Read("getbackupprogress")]
|
||||
public BackupProgress GetBackupProgress()
|
||||
{
|
||||
return BackupHandler.GetBackupProgress();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the backup history of the started backup
|
||||
/// </summary>
|
||||
/// <category>Backup</category>
|
||||
/// <returns>Backup History</returns>
|
||||
[Read("getbackuphistory")]
|
||||
public List<BackupHistoryRecord> GetBackupHistory()
|
||||
{
|
||||
return BackupHandler.GetBackupHistory();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Delete the backup with the specified id
|
||||
/// </summary>
|
||||
/// <category>Backup</category>
|
||||
[Delete("deletebackup/{id}")]
|
||||
public void DeleteBackup(Guid id)
|
||||
{
|
||||
BackupHandler.DeleteBackup(id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Delete all backups of the current portal
|
||||
/// </summary>
|
||||
/// <category>Backup</category>
|
||||
/// <returns>Backup History</returns>
|
||||
[Delete("deletebackuphistory")]
|
||||
public void DeleteBackupHistory()
|
||||
{
|
||||
BackupHandler.DeleteAllBackups();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Start a data restore of the current portal
|
||||
/// </summary>
|
||||
/// <param name="backupId">Backup Id</param>
|
||||
/// <param name="storageType">Storage Type</param>
|
||||
/// <param name="storageParams">Storage Params</param>
|
||||
/// <param name="notify">Notify about backup to users</param>
|
||||
/// <category>Backup</category>
|
||||
/// <returns>Restore Progress</returns>
|
||||
[Create("startrestore")]
|
||||
public BackupProgress StartBackupRestore(BackupRestore backupRestore)
|
||||
{
|
||||
BackupHandler.StartRestore(backupRestore.BackupId, backupRestore.StorageType, backupRestore.StorageParams, backupRestore.Notify);
|
||||
return BackupHandler.GetBackupProgress();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the progress of the started restore
|
||||
/// </summary>
|
||||
/// <category>Backup</category>
|
||||
/// <returns>Restore Progress</returns>
|
||||
[Read("getrestoreprogress", true)] //NOTE: this method doesn't check payment!!!
|
||||
public BackupProgress GetRestoreProgress()
|
||||
{
|
||||
return BackupHandler.GetRestoreProgress();
|
||||
}
|
||||
|
||||
///<visible>false</visible>
|
||||
[Read("backuptmp")]
|
||||
public string GetTempPath()
|
||||
{
|
||||
return BackupHandler.GetTmpFolder();
|
||||
}
|
||||
}
|
||||
public static class BackupControllerExtension
|
||||
{
|
||||
public static DIHelper AddBackupController(this DIHelper services)
|
||||
{
|
||||
return services
|
||||
.AddBackupAjaxHandler()
|
||||
.AddIpSecurityFilter();
|
||||
}
|
||||
}
|
||||
}
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace ASC.Data.Backup.Controllers
|
||||
{
|
||||
[DefaultRoute]
|
||||
[ApiController]
|
||||
public class BackupController
|
||||
{
|
||||
private BackupAjaxHandler BackupHandler { get; }
|
||||
public BackupController(BackupAjaxHandler backupAjaxHandler)
|
||||
{
|
||||
BackupHandler = backupAjaxHandler;
|
||||
}
|
||||
/// <summary>
|
||||
/// Returns the backup schedule of the current portal
|
||||
/// </summary>
|
||||
/// <category>Backup</category>
|
||||
/// <returns>Backup Schedule</returns>
|
||||
[Read("getbackupschedule")]
|
||||
public BackupAjaxHandler.Schedule GetBackupSchedule()
|
||||
{
|
||||
return BackupHandler.GetSchedule();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create the backup schedule of the current portal
|
||||
/// </summary>
|
||||
/// <param name="storageType">Storage type</param>
|
||||
/// <param name="storageParams">Storage parameters</param>
|
||||
/// <param name="backupsStored">Max of the backup's stored copies</param>
|
||||
/// <param name="cronParams">Cron parameters</param>
|
||||
/// <param name="backupMail">Include mail in the backup</param>
|
||||
/// <category>Backup</category>
|
||||
[Create("createbackupschedule")]
|
||||
public void CreateBackupSchedule(BackupStorageType storageType, [FromQuery] Dictionary<string, string> storageParams, int backupsStored, [FromBody] BackupAjaxHandler.CronParams cronParams, bool backupMail)
|
||||
{
|
||||
BackupHandler.CreateSchedule(storageType, storageParams, backupsStored, cronParams, backupMail);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Delete the backup schedule of the current portal
|
||||
/// </summary>
|
||||
/// <category>Backup</category>
|
||||
[Delete("deletebackupschedule")]
|
||||
public void DeleteBackupSchedule()
|
||||
{
|
||||
BackupHandler.DeleteSchedule();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Start a backup of the current portal
|
||||
/// </summary>
|
||||
/// <param name="storageType">Storage Type</param>
|
||||
/// <param name="storageParams">Storage Params</param>
|
||||
/// <param name="backupMail">Include mail in the backup</param>
|
||||
/// <category>Backup</category>
|
||||
/// <returns>Backup Progress</returns>
|
||||
[Create("startbackup")]
|
||||
public BackupProgress StartBackup(Models.Backup backup)
|
||||
{
|
||||
BackupHandler.StartBackup(backup.StorageType, backup.StorageParams ?? new Dictionary<string, string>(), backup.BackupMail);
|
||||
return BackupHandler.GetBackupProgress();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the progress of the started backup
|
||||
/// </summary>
|
||||
/// <category>Backup</category>
|
||||
/// <returns>Backup Progress</returns>
|
||||
[Read("getbackupprogress")]
|
||||
public BackupProgress GetBackupProgress()
|
||||
{
|
||||
return BackupHandler.GetBackupProgress();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the backup history of the started backup
|
||||
/// </summary>
|
||||
/// <category>Backup</category>
|
||||
/// <returns>Backup History</returns>
|
||||
[Read("getbackuphistory")]
|
||||
public List<BackupHistoryRecord> GetBackupHistory()
|
||||
{
|
||||
return BackupHandler.GetBackupHistory();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Delete the backup with the specified id
|
||||
/// </summary>
|
||||
/// <category>Backup</category>
|
||||
[Delete("deletebackup/{id}")]
|
||||
public void DeleteBackup(Guid id)
|
||||
{
|
||||
BackupHandler.DeleteBackup(id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Delete all backups of the current portal
|
||||
/// </summary>
|
||||
/// <category>Backup</category>
|
||||
/// <returns>Backup History</returns>
|
||||
[Delete("deletebackuphistory")]
|
||||
public void DeleteBackupHistory()
|
||||
{
|
||||
BackupHandler.DeleteAllBackups();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Start a data restore of the current portal
|
||||
/// </summary>
|
||||
/// <param name="backupId">Backup Id</param>
|
||||
/// <param name="storageType">Storage Type</param>
|
||||
/// <param name="storageParams">Storage Params</param>
|
||||
/// <param name="notify">Notify about backup to users</param>
|
||||
/// <category>Backup</category>
|
||||
/// <returns>Restore Progress</returns>
|
||||
[Create("startrestore")]
|
||||
public BackupProgress StartBackupRestore(BackupRestore backupRestore)
|
||||
{
|
||||
BackupHandler.StartRestore(backupRestore.BackupId, backupRestore.StorageType, backupRestore.StorageParams, backupRestore.Notify);
|
||||
return BackupHandler.GetBackupProgress();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the progress of the started restore
|
||||
/// </summary>
|
||||
/// <category>Backup</category>
|
||||
/// <returns>Restore Progress</returns>
|
||||
[Read("getrestoreprogress", true)] //NOTE: this method doesn't check payment!!!
|
||||
public BackupProgress GetRestoreProgress()
|
||||
{
|
||||
return BackupHandler.GetRestoreProgress();
|
||||
}
|
||||
|
||||
///<visible>false</visible>
|
||||
[Read("backuptmp")]
|
||||
public string GetTempPath()
|
||||
{
|
||||
return BackupHandler.GetTmpFolder();
|
||||
}
|
||||
}
|
||||
public static class BackupControllerExtension
|
||||
{
|
||||
public static DIHelper AddBackupController(this DIHelper services)
|
||||
{
|
||||
return services
|
||||
.AddBackupAjaxHandler()
|
||||
.AddIpSecurityFilter();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user