Example #1
0
        public UncHelper(SettingService settings,
                         ILogger <UncHelper> logger)
        {
            logger.LogInformation("[UncHelper] NetUseWithCredentials");
            var targetPath = settings["UniflowService:TaskTargetPath"];

            if (targetPath.StartsWith(@"\\"))
            {
                logger.LogInformation("Unc initialize: " + targetPath);
                unc = new UNC();
                var user   = settings["UniflowService:UncUser"];
                var domain = settings["UniflowService:UncDomain"];
                var pwd    = settings["UniflowService:UncPassword"];
                var result = unc.NetUseWithCredentials(targetPath, user, domain, pwd);
                logger.LogInformation("[UncHelper] NetUseWithCredentials Result:" + result);
            }
        }
Example #2
0
        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);
        }