Esempio n. 1
0
        public IActionResult Edit(WAMCustomJob job, string oldJobName)
        {
            try
            {
                if (job.ActionFile.Length > 0)
                {
                    // string filePath = $@"\\{localIP}\c$" + _folderPath;
                    string filePath = "C:\\WAM\\Uploads\\" + job.ActionFile.FileName;
                    using (var stream = new FileStream(filePath, FileMode.Create))
                    {
                        job.ActionFile.CopyToAsync(stream);
                        job.ActionFilePath = $@"\\{localIP}" + _folderPath + job.ActionFile.FileName;
                    }
                }
                //todo: make this async
                if (job.JobName != oldJobName)
                {
                    _cjm.CreateOrUpdateJob(job.JobName, job.ScriptType, job.ActionFilePath, job.TriggerString, oldJobName);
                }
                else
                {
                    _cjm.CreateOrUpdateJob(job.JobName, job.ScriptType, job.ActionFilePath, job.TriggerString);
                }
            }
            catch (Exception ex)
            {
                throw new Exception($"Failed to create custom job {job.JobName}. Error: {ex.Message}");
            }


            return(RedirectToAction("Index"));
        }
Esempio n. 2
0
        // GET: CustomJobs
        public async Task <IActionResult> Index()
        {
            List <CustomJobModel> jobs         = _cjm.GetJobs();
            List <WAMCustomJob>   jobsToReturn = new List <WAMCustomJob>();

            foreach (CustomJobModel job in jobs)
            {
                WAMCustomJob wcj = new WAMCustomJob(job.JobName, job.ScriptType, job.TriggerString, job.LastResult, job.ActionFilePath);
                jobsToReturn.Add(wcj);
            }
            return(View(jobsToReturn));
            //return View(await _context.WAMCustomJob.ToListAsync());
        }
Esempio n. 3
0
        // GET: CustomJobs/Details/5
        public IActionResult Details(string id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            //todo: make this async
            var job = _cjm.GetJob(id);

            if (job == null)
            {
                return(NotFound());
            }
            WAMCustomJob wcj = new WAMCustomJob(job.JobName, job.ScriptType, job.TriggerString, job.LastResult, job.ActionFilePath);

            return(View(wcj));
        }
Esempio n. 4
0
        public IActionResult Edit(string id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            try
            {
                //todo: make this async
                var job = _cjm.GetJob(id);

                if (job == null)
                {
                    return(NotFound());
                }
                WAMCustomJob wcj = new WAMCustomJob(job.JobName, job.ScriptType, job.TriggerString, job.LastResult, job.ActionFilePath);
                return(View(wcj));
            } catch (Exception ex)
            {
                throw new Exception($"Failed to update job: {id}. Error: {ex.Message}");
            }
        }