EnVisageOnline/Main/Source/EnVisage/Controllers/MongoDBBackupController.cs

58 lines
1.7 KiB
C#

using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.Mvc;
using EnVisage;
using EnVisage.Code;
using EnVisage.Code.BLL;
using EnVisage.Code.HtmlHelpers;
using EnVisage.Models;
using jQuery.DataTables.Mvc;
using EnVisage.App_Start;
using Microsoft.AspNet.Identity;
using System.Collections.ObjectModel;
using System.IO;
using FileHelpers;
using System.Web.Script.Serialization;
using EnVisage.Code.Cache;
using System.Net.Http;
namespace EnVisage.Controllers
{
public class MongoDBBackupController : BaseController
{
[Authorize]
[HttpGet]
public ActionResult LoadProcessBackupSetList()
{
MongoDBBackupManager manager = new MongoDBBackupManager(DbContext);
IDictionary<string, DateTime> ids = manager.GetAllBackupDates();
return Json(ids, JsonRequestBehavior.AllowGet);
}
[Authorize]
public void CreateBackupSet(DateTime key)
{
string userid = HttpContext.User.Identity.GetUserId();
MongoDBBackupManager manager = new MongoDBBackupManager(DbContext);
manager.DoBackup(userid, key);
DbContext.SaveChanges();
}
public void RestoreBackupSet(DateTime key)
{
MongoDBBackupManager manager = new MongoDBBackupManager(DbContext);
manager.RestoreMongo(key,null);
}
public void RestoreCollectionBackup(DateTime key,string CollectionName)
{
MongoDBBackupManager manager = new MongoDBBackupManager(DbContext);
manager.RestoreMongo(key, CollectionName);
}
}
}