public Transfer(BackupJob job) { Job = job; Running = false; TransferSource = Path.GetDirectoryName(job.Source); }
public void Listen(BackupJob job) { if (job == null || job.Id == 0) throw new ApplicationException("Invalid backup job"); if (_transfers.ContainsKey(job.Id)) throw new ApplicationException("Transfer already configured"); _log.InfoFormat("Adding job #{0} to transfers list", job.Id); var transfer = new Transfer(job); transfer.Init(); _transfers.Add(job.Id, transfer); _log.InfoFormat("Job #{0} was added to transfers list", job.Id); }
public void AddJob(BackupJob job) { if (job == null) throw new ArgumentNullException("job"); _log.InfoFormat("Adding new job to db for folder {0}", job.Source); var countSimilar = _db.BackupJob.Where(x => x.Source == job.Source && x.Destination == job.Destination && x.Protocol == job.Protocol ).Count(); if (countSimilar > 0) throw new ApplicationException("Already exists a similar job"); job.Running = false; job.RunningSince = null; job.LastRun = null; _db.BackupJob.Add(job); _db.Commit(); _log.DebugFormat("Job was added to db for folder {0}", job.Source); }
public void Init(BackupJob job, bool isNew) { _job = job; _isNew = isNew; }
public void Init(BackupJob job) { Init(job, false); }
public JobViewModel(BackupJob job, bool isNew) { _job = job; _isNew = isNew; _events = IoC.Get<IEventAggregator>(); }
public JobViewModel(BackupJob job) : this(job, false) { }
public void SaveJob(BackupJob job) { if (job == null) throw new ArgumentNullException("job"); if (job.Id == 0) throw new ArgumentException("This job is probably a new one. Please consider adding it (call AddJob()) instead of saving it"); _log.DebugFormat("Saving job #{0} to db", job.Id); var jobAux = GetJob(job.Id); if (jobAux == null) throw new ArgumentException("Job unknown"); if (jobAux.Running) throw new ApplicationException("Job is running"); jobAux.Source = job.Source; jobAux.Destination = job.Destination; jobAux.Protocol = job.Protocol; jobAux.Host = job.Host; jobAux.HostKeyFingerprint = job.HostKeyFingerprint; jobAux.HostPassword = job.HostPassword; jobAux.HostUsername = job.HostUsername; jobAux.RemoveFiles = job.RemoveFiles; jobAux.SyncMode = job.SyncMode; _db.Commit(); _log.DebugFormat("Job #{0} was saved to db", job.Id); }