예제 #1
0
        // GET: SQLJobs/Details/5
        public async Task <IActionResult> Details(Guid id, [FromQuery] string server)
        {
            //SqlServerManager ssm = new SqlServerManager();
            var    j   = _ssm.FindJobByID(id, server);
            SQLJob job = new SQLJob();

            //TODO move this to a constructor
            job.JobID             = j.JobID;
            job.Name              = j.Name;
            job.Description       = j.Description;
            job.OriginatingServer = j.OriginatingServer;
            job.Schedule          = j.JobSchedules;
            job.Steps             = j.JobSteps;
            job.CurrentRunStatus  = j.CurrentRunStatus;
            job.CurrentRunStep    = j.CurrentRunStep;
            job.DateCreated       = j.DateCreated;
            job.DateModified      = j.DateLastModified;
            job.LastRunDate       = j.LastRunDate;
            job.NextRunDate       = j.NextRunDate;
//            var sQLJob = await _context.SQLJobs
//                .FirstOrDefaultAsync(m => m.JobID == id);
//            if (sQLJob == null)
//            {
//                return NotFound();
//            }

            return(View(job));
        }
예제 #2
0
        public async Task <IActionResult> Edit(Guid id, [Bind("JobID,Name,Description,OriginatingServer,DateCreated,DateModified,LastRunDate,NextRunDate")] SQLJob sQLJob)
        {
            if (id != sQLJob.JobID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(sQLJob);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SQLJobExists(sQLJob.JobID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(sQLJob));
        }
예제 #3
0
        public async Task <IActionResult> Create([Bind("JobID,Name,Description,OriginatingServer,DateCreated,DateModified,LastRunDate,NextRunDate")] SQLJob sQLJob)
        {
            if (ModelState.IsValid)
            {
                sQLJob.JobID = Guid.NewGuid();
                _context.Add(sQLJob);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(sQLJob));
        }
예제 #4
0
        // GET: SQLJobs
        public async Task <IActionResult> Index()
        {
            //AM_SqlServer.SqlServerManager ssm = new AM_SqlServer.SqlServerManager();
            //TODO: use AppSettings to pull this, set value through a settings/config menu
            List <Job>    localJobs = _ssm.GetAllSqlAgentJobs();
            List <SQLJob> sqlJobs   = new List <SQLJob>();

            foreach (Job j in localJobs)
            {
                SQLJob job = new SQLJob();
                job.JobID             = j.JobID;
                job.Name              = j.Name;
                job.Description       = j.Description;
                job.OriginatingServer = j.OriginatingServer;
                job.Schedule          = j.JobSchedules;
                job.Steps             = j.JobSteps;
                job.CurrentRunStatus  = j.CurrentRunStatus;
                job.CurrentRunStep    = j.CurrentRunStep;
                job.DateCreated       = j.DateCreated;
                job.DateModified      = j.DateLastModified;
                job.LastRunDate       = j.LastRunDate;
                job.NextRunDate       = j.NextRunDate;
                sqlJobs.Add(job);
            }

            //TODO remove this and have code loop through the list of WAMSqlConnectionObjects and pull jobs for each
            List <Job> remoteJobs = _ssm.GetAllSqlAgentJobs("sa", "password", "SERVER02");

            foreach (Job j in remoteJobs)
            {
                SQLJob job = new SQLJob();
                //TODO move this to a constructor
                job.JobID             = j.JobID;
                job.Name              = j.Name;
                job.Description       = j.Description;
                job.OriginatingServer = j.OriginatingServer;
                job.Schedule          = j.JobSchedules;
                job.Steps             = j.JobSteps;
                job.CurrentRunStatus  = j.CurrentRunStatus;
                job.CurrentRunStep    = j.CurrentRunStep;
                job.DateCreated       = j.DateCreated;
                job.DateModified      = j.DateLastModified;
                job.LastRunDate       = j.LastRunDate;
                job.NextRunDate       = j.NextRunDate;
                sqlJobs.Add(job);
            }
            return(View(sqlJobs));
            // return View(await _context.SQLJobs.ToListAsync());
        }