Пример #1
0
        public void LoadFrom(IEnumerable <XElement> elements, int tenant, string[] configs, IDataReadOperator dataOperator)
        {
            InvokeProgressChanged("Restoring files...", 0);

            var    config  = GetWebConfig(configs);
            var    files   = elements.Where(e => e.Name == "file");
            double current = 0;

            foreach (var file in files)
            {
                var backupInfo = new FileBackupInfo(file);
                if (allowedModules.Contains(backupInfo.Module))
                {
                    using (var entry = dataOperator.GetEntry(GetBackupPath(backupInfo)))
                    {
                        var storage = StorageFactory.GetStorage(config, tenant.ToString(), backupInfo.Module, null);
                        try
                        {
                            storage.Save(backupInfo.Domain, backupInfo.Path, entry);
                        }
                        catch (Exception error)
                        {
                            log.ErrorFormat("Can not restore file {0}: {1}", file, error);
                        }
                    }
                    InvokeProgressChanged("Restoring file " + backupInfo.Path, current++ / files.Count() * 100);
                }
            }
        }
Пример #2
0
 public bool Equals(FileBackupInfo other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(Equals(other.Module, Module) && Equals(other.Domain, Domain) && Equals(other.Path, Path));
 }
Пример #3
0
        public void GetLoadFileBackup()
        {
            var filters     = new[] { "bak" };
            var files       = GetFilesFrom(Application.StartupPath + "\\backup\\", filters, true).ToList();
            var backupInfos = new List <FileBackupInfo>();

            foreach (var file in files)
            {
                FileInfo f              = new FileInfo(file);
                long     s1             = f.Length;
                var      obj            = FileVersionInfo.GetVersionInfo(file);
                var      fileBackupInfo = new FileBackupInfo();
                fileBackupInfo.FileName    = Path.GetFileName(obj.FileName);
                fileBackupInfo.Size        = ToPrettySize(s1);
                fileBackupInfo.DateFile    = File.GetLastWriteTime(file);
                fileBackupInfo.Description = obj.FileName;
                backupInfos.Add(fileBackupInfo);
            }
            dgv_backup.DataSource = backupInfos;
        }
Пример #4
0
        public void LoadFrom(IEnumerable <XElement> elements, int tenant, string[] configs, IDataReadOperator dataOperator)
        {
            InvokeProgressChanged("Restoring files started", -1);

            var config = GetWebConfig(configs);

            AppDomain.CurrentDomain.SetData(Constants.CustomDataDirectory, Path.GetDirectoryName(config));
            var    files   = elements.Where(e => e.Name == "file");
            double current = 0;

            foreach (var file in files)
            {
                var backupInfo = new FileBackupInfo(file);
                var entry      = dataOperator.GetEntry(GetBackupPath(backupInfo));
                var storage    = StorageFactory.GetStorage(config, tenant.ToString(), backupInfo.Module, null, null);
                storage.Save(backupInfo.Domain, backupInfo.Path, entry);

                InvokeProgressChanged("Restoring files", current / files.Count() * 100);
                current++;
            }

            InvokeProgressChanged("OK", 100);
        }
Пример #5
0
 private string GetBackupPath(FileBackupInfo backupInfo)
 {
     return(Path.Combine(backupInfo.Module, Path.Combine(backupInfo.Domain, backupInfo.Path.Replace('/', '\\'))));
 }
 public bool Equals(FileBackupInfo other)
 {
     if (ReferenceEquals(null, other)) return false;
     if (ReferenceEquals(this, other)) return true;
     return Equals(other.Module, Module) && Equals(other.Domain, Domain) && Equals(other.Path, Path);
 }
        public void LoadFrom(IEnumerable<XElement> elements, int tenant, string[] configs, IDataReadOperator dataOperator)
        {
            InvokeProgressChanged("Restoring files...", 0);

            var config = GetWebConfig(configs);
            AppDomain.CurrentDomain.SetData(Constants.CustomDataDirectory, Path.GetDirectoryName(config));
            var files = elements.Where(e => e.Name == "file");
            double current = 0;
            foreach (var file in files)
            {
                var backupInfo = new FileBackupInfo(file);
                if (allowedModules.Contains(backupInfo.Module))
                {
                    var entry = dataOperator.GetEntry(GetBackupPath(backupInfo));
                    var storage = StorageFactory.GetStorage(config, tenant.ToString(), backupInfo.Module, null, null);
                    try
                    {
                        storage.Save(backupInfo.Domain, backupInfo.Path, entry);
                    }
                    catch (Exception error)
                    {
                        log.ErrorFormat("Can not restore file {0}: {1}", file, error);
                    }

                    InvokeProgressChanged("Restoring file " + backupInfo.Path, current++ / files.Count() * 100);
                }
            }
        }
 private string GetBackupPath(FileBackupInfo backupInfo)
 {
     return Path.Combine(backupInfo.Module, Path.Combine(backupInfo.Domain, backupInfo.Path.Replace('/', '\\')));
 }
Пример #9
0
 private string GetBackupPath(FileBackupInfo backupInfo)
 {
     return(CrossPlatform.PathCombine(backupInfo.Module, CrossPlatform.PathCombine(backupInfo.Domain, backupInfo.Path.Replace('/', '\\'))));
 }