public static void FTPBackup() { var temp = Api_Helper.Temp_Get().Result; foreach (var item in temp) { string Filename = @"/asd/"; string server = "ftp://endora.endora.cz"; string username = "******"; string Password = "******"; FtpClient ftpClient = new FtpClient(server, new NetworkCredential(username, Password)); ftpClient.Connect(); ftpClient.UploadDirectory(item.Source, Filename); } //FtpWebRequest request = (FtpWebRequest)WebRequest.Create(new Uri(string.Format("{0}/{1}", server, Filename))); //request.Method = WebRequestMethods.Ftp.UploadFile; //request.Credentials = new NetworkCredential(username, Password); //StreamReader sourceStream = new StreamReader(temp); //byte[] fileContents = Encoding.UTF8.GetBytes(sourceStream.ReadToEnd()); //sourceStream.Close(); //Stream requestStream = request.GetRequestStream(); //requestStream.Write(fileContents, 0, fileContents.Length); //requestStream.Close(); //FtpWebRequest request = (FtpWebRequest)WebRequest.Create(new Uri(string.Format("{0}/{1}", server, Filename))); //request.Method = WebRequestMethods.Ftp.UploadFile; //request.Credentials = new NetworkCredential(username, Password); //Stream FTPstream = request.GetRequestStream(); //FileStream fs = File.OpenRead(Fullname); }
public Task Execute(IJobExecutionContext context) { if (Properties.Settings.Default.Id == 0) { Api_Helper.Info_Register(); } else { Api_Helper.Info_Get(); } Console.WriteLine("ID: " + Properties.Settings.Default.Id); return(Task.CompletedTask); }
public void JobSet() { IJobDetail InfoJob = JobBuilder.Create(typeof(LoadInfoJob)).Build(); ITrigger InfoTrigger = TriggerBuilder.Create().StartNow().WithSimpleSchedule(x => x.WithIntervalInSeconds(5).RepeatForever()).Build(); scheduler.ScheduleJob(InfoJob, InfoTrigger).GetAwaiter().GetResult(); foreach (var item in Api_Helper.Temp_Get().Result) { IJobDetail job = JobBuilder.Create(typeof(BacJob)).Build(); ITrigger trigger = TriggerBuilder.Create().StartNow().WithCronSchedule(item.Schedule).Build(); job.JobDataMap.Add("ID", item.id); scheduler.ScheduleJob(job, trigger).GetAwaiter().GetResult(); } }
public static void Update() { var templates = Api_Helper.Temp_Get().Result; foreach (var item in templates) { Dictionary[item.id] = item; } List <Template> temp = Dictionary.Values.Except(templates).ToList(); foreach (var item in temp) { Dictionary.Remove(item.id); } Save(); }
public Task Execute(IJobExecutionContext context) { int ID = (int)context.MergedJobDataMap.Get("ID"); Template Temp = Api_Helper.Temp_Get().Result.First(x => x.id == ID); string Type = Temp.Type_Of_Backup.ToUpper(); if (Type == "FULL") { var FullBackup = new FullBackup(Temp.Source, Temp.Destination, Temp.Save_Options); } else if (Type == "DIFF") { var DiffBackup = new DifferentialBackup(Temp.Source, Temp.Destination, Temp.Save_Options); } else if (Type == "INC") { var IncBackup = new IncrementalBackup(Temp.Source, Temp.Destination, Temp.Save_Options); } else if (Type == "UNCFULL") { using (UNCAccessWithCredentials.UNCAccessWithCredentials unc = new UNCAccessWithCredentials.UNCAccessWithCredentials()) { if (unc.NetUseWithCredentials(@"\\kacenka.litv.sssvt.cz\StudentiPrenosne\PerinaRadek", "perinaradek", "litv", "okmujm987")) { var FullBackup = new FullBackup(Temp.Source, Temp.Destination, Temp.Save_Options); } else { throw new Exception("Neplatné přihlašovací údaje"); } } } else if (Type == "UNCINC") { using (UNCAccessWithCredentials.UNCAccessWithCredentials unc = new UNCAccessWithCredentials.UNCAccessWithCredentials()) { if (unc.NetUseWithCredentials(@"\\kacenka.litv.sssvt.cz\StudentiPrenosne\PerinaRadek", "perinaradek", "litv", "okmujm987")) { var IncBackup = new IncrementalBackup(Temp.Source, Temp.Destination, Temp.Save_Options); } else { throw new Exception("Neplatné přihlašovací údaje"); } } } else if (Type == "UNCDIFF") { using (UNCAccessWithCredentials.UNCAccessWithCredentials unc = new UNCAccessWithCredentials.UNCAccessWithCredentials()) { if (unc.NetUseWithCredentials(@"\\kacenka.litv.sssvt.cz\StudentiPrenosne\PerinaRadek", "perinaradek", "litv", "okmujm987")) { var DiffBackup = new DifferentialBackup(Temp.Source, Temp.Destination, Temp.Save_Options); } else { throw new Exception("Neplatné přihlašovací údaje"); } } } else { Task.WaitAll(Api_Helper.Bac_Post(new Backup { Made = DateTime.Now, Name = Type + " " + DateTime.Now, Job = 30, Size = Temp.Destination, Succesful = false })); throw new Exception("Unexpected type of backup :/"); } Console.WriteLine("BACKUP DONE"); Console.WriteLine("ID: " + Temp.id); Console.WriteLine("Type: " + Temp.Type_Of_Backup); Task.WaitAll(Api_Helper.Bac_Post(new Backup { Made = DateTime.Now, Name = Type + " " + DateTime.Now, Job = 30, Size = Temp.Destination, Succesful = true })); return(Task.CompletedTask); }