예제 #1
0
        public Task CheckHttp(Models.Job job, int mintue)
        {
            return(Task.Run(() =>
            {
                if (job.HttpStatus == 0)
                {
                    return;
                }

                var CkHttp = _accessor.CheckHttp(job, mintue);

                if (!CkHttp.Ok)
                {
                    EmailHelper.Send(job.Emails, "预警触发通知", $@"  

                          <br>
                          <b>【请求错误】触发预警 </b> 

                          <p>命中率预警值:{job.HttpRate * 100 + "%"}  当前值:{CkHttp.Value.ToDouble() * 100 + "%"} </p>   

                          <p>任务标题:{job.Title}</p>

                          <p>监控节点:{job.Servers}</p>

                          <p>监控频率:{ParseJobCronString(job.CronLike)}</p>

                          <p>设定Http状态码:{job.HttpCodes}</p>

                          <p>时间段:{CkHttp.Time}</p>

                    ");
                }
            }));
        }
예제 #2
0
        public Task CheckIP(Models.Job job, int mintue)
        {
            return(Task.Run(() =>
            {
                if (job.IPStatus == 0)
                {
                    return;
                }

                var CkIP = _accessor.CheckIP(job, mintue);

                if (!CkIP.Ok)
                {
                    EmailHelper.Send(job.Emails, "预警触发通知", $@"  

                          <br>
                          <b>【IP异常】触发预警 </b> 

                          <p>IP重复率预警值:{job.IPRate * 100 + "%"}  当前值:{CkIP.Value.ToDouble() * 100 + "%"} </p>   

                          <p>任务标题:{job.Title}</p>

                          <p>监控节点:{job.Servers}</p>

                          <p>监控频率:{ParseJobCronString(job.CronLike)}</p>

                          <p>IP白名单:{job.IPWhiteList}</p>

                          <p>时间段:{CkIP.Time}</p>

                    ");
                }
            }));
        }
예제 #3
0
        public Task CheckRt(Models.Job job, int mintue)
        {
            return(Task.Run(() =>
            {
                if (job.RtStatus == 0)
                {
                    return;
                }

                var CkRt = _accessor.CheckRt(job, mintue);

                if (!CkRt.Ok)
                {
                    EmailHelper.Send(job.Emails, "预警触发通知", $@"  

                          <br>
                          <b>【响应超时】触发预警 </b> 

                          <p>超时率预警值:{job.RtRate * 100 + "%"}  当前值:{CkRt.Value.ToDouble() * 100 + "%"} </p>   

                          <p>任务标题:{job.Title}</p>

                          <p>监控节点:{job.Servers}</p>

                          <p>监控频率:{ParseJobCronString(job.CronLike)}</p>

                          <p>设定超时时间:{job.RtTime}ms</p>

                          <p>时间段:{CkRt.Time}</p>

                    ");
                }
            }));
        }
예제 #4
0
        public Task CheckRequestCount(Models.Job job, int mintue)
        {
            return(Task.Run(() =>
            {
                if (job.RequestStatus == 0)
                {
                    return;
                }

                var CkCount = _accessor.CheckRequestCount(job, mintue);

                if (!CkCount.Ok)
                {
                    EmailHelper.Send(job.Emails, "预警触发通知", $@"  

                          <br>
                          <b>【请求量监控】触发预警 </b> 

                          <p>请求量最大预警值:{job.RequestCount}  当前值:{CkCount.Value} </p>   

                          <p>任务标题:{job.Title}</p>

                          <p>监控节点:{job.Servers}</p>

                          <p>监控频率:{ParseJobCronString(job.CronLike)}</p>  

                          <p>时间段:{CkCount.Time}</p>

                    ");
                }
            }));
        }
        public CheckModel CheckRequestCount(Models.Job job, int minute)
        {
            using (var con = new SqlConnection(conn.ConnectionString))
            {
                string where = " where 1=1 ";

                where = BuildWhereByTime(where, minute);
                where = BuildWhereByNode(where, job.Servers);
                string Time = DateTime.Now.AddMinutes(-minute).ToString("yyyy-MM-dd HH:mm:ss") + "-" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");

                var now = con.QueryFirstOrDefault <int>($" Select Count(1) From RequestInfo {where} ");

                if (now < job.RequestCount || now == 0)
                {
                    return(new CheckModel());
                }
                else
                {
                    return(new CheckModel()
                    {
                        Ok = false,
                        Value = now.ToString(),
                        Time = Time
                    });
                }
            }
        }
 public ActionResult Add(UI.Models.Job jobdata)
 {
     UI.Models.Job job = new Models.Job();
     jobdata.PayRate = jobdata.PayRate + "-" + jobdata.payratemax;
     job.InsertJobDetials(jobdata);
     return RedirectToAction("index", "jobs", null);
 }
예제 #7
0
        public IActionResult New(NewJobViewModel newJobViewModel)
        {
            // TODO #6 - Validate the ViewModel and if valid, create a
            // new Job and add it to the JobData data store. Then
            // redirect to the Job detail (Index) action/view for the new Job.

            int value = newJobViewModel.EmployerID;

            //string employer = Enum.GetName(typeof(Employer), value);



            if (ModelState.IsValid)
            {
                Job newJob = new Models.Job
                {
                    Name           = newJobViewModel.Name,
                    Employer       = jobData.Employers.Find(newJobViewModel.EmployerID),
                    Location       = jobData.Locations.Find(newJobViewModel.LocationID),
                    CoreCompetency = jobData.CoreCompetencies.Find(newJobViewModel.CoreCompetencyID),
                    PositionType   = jobData.PositionTypes.Find(newJobViewModel.PositionTypeID)
                };
                jobData.Jobs.Add(newJob);

                string url = "/Job?id=" + newJob.ID.ToString();

                //return View("index", newJob);
                return(Redirect(url));
            }
            else
            {
                return(View(newJobViewModel));
            }
        }
예제 #8
0
        public async Task <ActionResult> DeleteJob(ViewModels.EditJobs updateJob)
        {
            if (updateJob != null)
            {
                var currentUser = await db.Users.Where(x => x.UserName == User.Identity.Name)
                                  .SingleOrDefaultAsync();

                if (currentUser != null)
                {
                    var Job = new Models.Job
                    {
                        IsDeleted = true,
                        DeletedBy = currentUser,
                        Deleted   = DateTimeOffset.UtcNow
                    };
                    try
                    {
                        db.Entry(Job).State = EntityState.Modified;
                        var result = await db.SaveChangesAsync();

                        if (result > 0)
                        {
                            return(RedirectToAction("Job", "VillageHead"));
                        }
                    }
                    catch (Exception ex)
                    {
                        Trace.TraceError(ex.Message);
                        Trace.TraceError(ex.StackTrace);
                    }
                }
            }
            return(View("Error"));
        }
        public override async Task <IActionResult> Create([FromBody] DreamDaemon model, CancellationToken cancellationToken)
        {
            //alias for launching DD
            var instance = instanceManager.GetInstance(Instance);

            if (instance.Watchdog.Running)
            {
                return(StatusCode((int)HttpStatusCode.Gone));
            }

            var job = new Models.Job
            {
                Description      = "Launch DreamDaemon",
                CancelRight      = (ulong)DreamDaemonRights.Shutdown,
                CancelRightsType = RightsType.DreamDaemon,
                Instance         = Instance,
                StartedBy        = AuthenticationContext.User
            };
            await jobManager.RegisterOperation(job,
                                               async (paramJob, serviceProvider, progressHandler, innerCt) =>
            {
                var result = await instance.Watchdog.Launch(innerCt).ConfigureAwait(false);
                if (result == null)
                {
                    throw new InvalidOperationException("Watchdog already running!");
                }
            },
                                               cancellationToken).ConfigureAwait(false);

            return(Accepted(job.ToApi()));
        }
 public ActionResult Add(UI.Models.Job jobdata)
 {
     UI.Models.Job job = new Models.Job();
     jobdata.PayRate = jobdata.PayRate + "-" + jobdata.payratemax;
     job.InsertJobDetials(jobdata);
     return(RedirectToAction("index", "jobs", null));
 }
예제 #11
0
 public IActionResult New(NewJobViewModel newJobViewModel)
 {
     // TODO #6 - Validate the ViewModel and if valid, create a
     // new Job and add it to the JobData data store. Then
     // redirect to the Job detail (Index) action/view for the new Job.
     if (ModelState.IsValid)
     {
         Models.Job newJob = new Models.Job()
         {
             Name           = newJobViewModel.Name,
             Employer       = jobData.Employers.Find(newJobViewModel.EmployerID),
             Location       = jobData.Locations.Find(newJobViewModel.LocationID),
             CoreCompetency = jobData.CoreCompetencies.Find(newJobViewModel.CoreCompetencyID),
             PositionType   = jobData.PositionTypes.Find(newJobViewModel.PositionID),
         };
         jobData.Jobs.Add(newJob);
         SearchJobsViewModel jobById = new SearchJobsViewModel();
         jobById.Jobs = new List <Job>();
         jobById.Jobs.Add(newJob);
         return(View("Index", jobById));
     }
     else
     {
         return(View(newJobViewModel));
     }
 }
예제 #12
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var emptyJob = new Models.Job();

            var userId = User.FindFirst(ClaimTypes.NameIdentifier).Value;

            emptyJob.ApplicationUserId = userId;

            if (await TryUpdateModelAsync(
                    emptyJob,
                    "job",
                    j => j.Name, j => j.Number, j => j.EmployerId, j => j.Description
                    ))
            {
                _context.Job.Add(emptyJob);
                await _context.SaveChangesAsync();

                return(RedirectToPage("./Index"));
            }

            //Select Employer's Id if TryUpdateModelAsync fails.
            PopulateEmployersDropDownList(_context, emptyJob.EmployerId);
            return(Page());
        }
예제 #13
0
        public IActionResult New(NewJobViewModel newJobViewModel)
        {
            //  #6 - Validate the ViewModel and if valid, create a
            // new Job and add it to the JobData data store. Then
            // redirect to the Job detail (Index) action/view for the new Job.
            if (newJobViewModel != null && newJobViewModel.Name != null && newJobViewModel.Name.Trim().Length != 0)
            {
                Models.Employer       employer       = jobData.Employers.Find(newJobViewModel.EmployerID);
                Models.Location       location       = jobData.Locations.Find(newJobViewModel.LocationID);
                Models.PositionType   positionType   = jobData.PositionTypes.Find(newJobViewModel.PositionTypeID);
                Models.CoreCompetency coreCompetency = jobData.CoreCompetencies.Find(newJobViewModel.CoreCompetencyID);

                Models.Job newJob = new Models.Job
                {
                    Name           = newJobViewModel.Name,
                    Employer       = employer,
                    Location       = location,
                    PositionType   = positionType,
                    CoreCompetency = coreCompetency
                };
                jobData.Jobs.Add(newJob);

                return(View("Index", newJob));
            }

            return(View(newJobViewModel));
        }
예제 #14
0
        public async Task <IActionResult> Delete(CancellationToken cancellationToken)
        {
            var currentModel = await DatabaseContext.RepositorySettings.Where(x => x.InstanceId == Instance.Id).FirstOrDefaultAsync(cancellationToken).ConfigureAwait(false);

            if (currentModel == default)
            {
                return(StatusCode((int)HttpStatusCode.Gone));
            }

            currentModel.AccessToken = null;
            currentModel.AccessUser  = null;

            await DatabaseContext.Save(cancellationToken).ConfigureAwait(false);

            Logger.LogInformation("Instance {0} repository delete initiated by user {1}", Instance.Id, AuthenticationContext.User.Id);

            var job = new Models.Job
            {
                Description = "Delete repository",
                StartedBy   = AuthenticationContext.User,
                Instance    = Instance
            };
            var api = currentModel.ToApi();
            await jobManager.RegisterOperation(job, (paramJob, databaseContext, progressReporter, ct) => instanceManager.GetInstance(Instance).RepositoryManager.DeleteRepository(cancellationToken), cancellationToken).ConfigureAwait(false);

            api.ActiveJob = job.ToApi();
            return(Accepted(api));
        }
예제 #15
0
        public IActionResult New(NewJobViewModel newJobViewModel)
        {
            // TODO #6 - Validate the ViewModel and if valid, create a
            // new Job and add it to the JobData data store. Then
            // redirect to the Job detail (Index) action/view for the new Job.
            if (newJobViewModel.Name != null)
            {
                Models.Job newJob = new Models.Job
                {
                    Name           = newJobViewModel.Name,
                    Employer       = jobData.Employers.Find(newJobViewModel.EmployerID),
                    Location       = jobData.Locations.Find(newJobViewModel.LocationID),
                    CoreCompetency = jobData.CoreCompetencies.Find(newJobViewModel.CoreCompetencyID),
                    PositionType   = jobData.PositionTypes.Find(newJobViewModel.PositionTypeID)
                };
                int newJobid = newJob.ID;
                jobData.Jobs.Add(newJob);
                //return View("Index", newJob);
                //return RedirectToAction("", new { id = newJobid });
                return(Redirect(string.Format("/Job?id={0}", newJobid.ToString())));
            }
            ;


            return(View(newJobViewModel));
        }
        //Update statement
        public void Update(Models.Job job)
        {
            string query = "UPDATE jobs SET " +
                           "freelancerID=" + "\"" + job.freelancerID + "\", " +
                           "clientID=" + "\"" + job.clientID + "\", " +
                           "jobTitle=" + "\"" + job.jobTitle + "\", " +
                           "jobBudget=" + "\"" + job.jobBudget + "\", " +
                           "jobType=" + "\"" + job.jobType + "\", " +
                           "jobDescription=" + "\"" + job.jobDescription + "\", " +
                           "jobAVGRate=" + "\"" + job.jobAVGRate + "\", " +
                           "jobStatus=" + "\"" + job.jobStatus + "\", " +
                           "jobAdminAcceptance=" + "\"" + job.jobAdminAcceptance + "\", " +
                           "propCount=" + "\"" + job.propCount + "\"" +
                           "WHERE jobID=" + "\"" + job.jobID + "\"";

            //Open connection
            if (this.OpenConnection() == true)
            {
                //create mysql command
                MySqlCommand cmd = new MySqlCommand();
                //Assign the query using CommandText
                cmd.CommandText = query;
                //Assign the connection using Connection
                cmd.Connection = connection;

                //Execute query
                cmd.ExecuteNonQuery();

                //close connection
                this.CloseConnection();
            }
        }
예제 #17
0
        public Models.Job ParseJobRequest(JobRequest request)
        {
            Models.Job job = new Models.Job();

            job.Id            = request.Id;
            job.Title         = request.Title;
            job.CronLike      = ParseJobRate(request.Rate);
            job.Emails        = request.Email.Trim().Replace(",", ",");
            job.Mobiles       = request.Mobiles.Trim().Replace(",", ",");
            job.Status        = request.Status;
            job.Servers       = request.Node.Trim();
            job.RtStatus      = request.RtStatus;
            job.RtTime        = request.RtTime.Trim().ToInt();
            job.RtRate        = Math.Round(request.RtRate.Replace("%", "").ToDouble(), 2) * 0.01;
            job.HttpStatus    = request.HttpStatus;
            job.HttpCodes     = request.HttpCodes.Replace(",", ",").Trim();
            job.HttpRate      = Math.Round(request.HttpRate.Replace("%", "").ToDouble(), 2) * 0.01;
            job.IPStatus      = request.IPStatus;
            job.IPWhiteList   = request.IPWhiteList.Replace(",", ",").Trim();
            job.IPRate        = Math.Round(request.IPRate.Replace("%", "").ToDouble(), 2) * 0.01;
            job.RequestStatus = request.RequestStatus;
            job.RequestCount  = request.RequestCount.ToInt();
            job.CreateTime    = DateTime.Now;

            return(job);
        }
예제 #18
0
        public void ZapisJobInformaciDoDatabaze(Models.Job JobData)
        {
            using (AlitaDatabase db = VytvorInstanci())
            {
                SetOnline(db);
                Job jobDataDatabaze = new Job();
                JobModelToJobEntity(JobData, ref jobDataDatabaze);
                if (JobData.CasDokonceni != DateTime.MinValue)
                {
                    jobDataDatabaze.Finnished = JobData.CasDokonceni;
                }
                var serverZDatabaze = db.RobotServer.Single(x => x.Device_Id == JobData.Server.Device_ID);
                jobDataDatabaze.Server_Id = JobData.Server.Device_ID;
                serverZDatabaze.Job.Add(jobDataDatabaze);
                jobDataDatabaze.RobotServer = serverZDatabaze;
                jobDataDatabaze.Id          = VolneJobId();
                db.Job.Add(jobDataDatabaze);
                try
                {
                    db.SaveChanges();
                }
                catch (DbEntityValidationException ex)
                {
                    db.Job.Remove(jobDataDatabaze);
                    jobDataDatabaze.Id++;
                    db.Job.Add(jobDataDatabaze);
                    db.SaveChanges();
                }

                SetOffline(db);
            }
        }
        //删除职位方法
        public ActionResult DeleteById(Guid gid)
        {
            Models.Job obj = DB.Job.FirstOrDefault(o => o.Id.Equals(gid));
            DB.Job.Remove(obj);
            int rs = DB.SaveChanges();

            return(Content(rs > 0 ? "T" : "F"));
        }
예제 #20
0
        // The detail display for a given Job at URLs like /Job?id=17
        public IActionResult Index(int id)
        {
            // TODO #1 - get the Job with the given ID and pass it into the view
            //liklely not working
            Models.Job selectedJob = jobData.Find(id);

            return(View(selectedJob));
        }
예제 #21
0
        // The detail display for a given Job at URLs like /Job?id=17
        public IActionResult Index(int id)
        {
            // TODO #1 - get the Job with the given ID and pass it into the view
            var job = JobData.GetInstance();

            Models.Job jobView = job.Find(id);
            return(View(jobView));
        }
예제 #22
0
 public DetailsModel(ExoneracionProject.Data.RecruitContext context,
                     Microsoft.AspNetCore.Identity.UserManager <IdentityUser> userManager)
 {
     _context         = context;
     this.userManager = userManager;
     NewCandidato     = new Models.Candidato();
     NewJob           = new Models.Job();
 }
예제 #23
0
        // The detail display for a given Job at URLs like /Job?id=17
        public IActionResult Index(int id)
        {
            // TODO #1 - get the Job with the given ID and pass it into the view

            Models.Job someJob = jobData.Find(id);

            return(View(someJob));
        }
        //修改职位方法
        public ActionResult UpdateAction(Models.Job obj)
        {
            Models.Job newValue = DB.Job.FirstOrDefault(o => o.Id.Equals(obj.Id));
            newValue.UpdateTime = DateTime.Now;
            UpdateModel(newValue);
            int rs = DB.SaveChanges();

            return(Content(rs > 0 ? "T" : "F"));
        }
예제 #25
0
        public ActionResult JobCreate()
        {
            Recruiter r = db.Recruiters.FirstOrDefault(m => m.AspNetUser.UserName == User.Identity.Name);

            ViewBag.RecruiterId = r.Id;
            Job j = new Models.Job();

            return(View(j));
        }
예제 #26
0
 public Job GetEntity(Models.Job job)
 {
     return(new Job()
     {
         JobId = Guid.NewGuid(),
         Jurisdiction = job.JurisdictionId,
         Name = job.Name
     });
 }
예제 #27
0
 private void JobModelToJobEntity(Models.Job JobModel, ref Job JobEntity)
 {
     JobEntity.IdOnServer = JobModel.ID;
     JobEntity.SourceGoal = JobModel.PocatecniGoal;
     JobEntity.TargetGoal = JobModel.KoncovyGoal;
     JobEntity.Queued     = JobModel.CasVzniku;
     if (JobModel.CasDokonceni != DateTime.MinValue)
     {
         JobEntity.Finnished = JobModel.CasDokonceni;
     }
 }
        [HttpPost]//请求添加方法
        public ActionResult AddJobInfo(Models.Job job)
        {
            job.Id         = Guid.NewGuid();
            job.CreateTime = DateTime.Now;
            job.UpdateTime = DateTime.Now;
            job.IsDel      = false;
            DB.Job.Add(job);
            int rs = DB.SaveChanges();

            return(Content(rs > 0 ? "T" : "F"));
        }
예제 #29
0
        public void ScheduleJob(ScheduleService scheduleService, Models.Job k)
        {
            var job = JobBuilder.Create <BackendJob>().
                      WithIdentity("T" + k.Id, "HttpReports")
                      .SetJobData(new JobDataMap {
                { "job", k }
            }).Build();

            var trigger = TriggerBuilder.Create().WithCronSchedule(k.CronLike).Build();

            scheduleService.scheduler.ScheduleJob(job, trigger);
        }
        public ActionResult Delete(string id, FormCollection form)
        {
            try
            {
                Models.Job job = new Models.Job(id);
                job.Delete();

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
예제 #31
0
        public override async Task <IActionResult> Create([FromBody] DreamMaker model, CancellationToken cancellationToken)
        {
            var job = new Models.Job
            {
                Description      = "Compile active repository code",
                StartedBy        = AuthenticationContext.User,
                CancelRightsType = RightsType.DreamMaker,
                CancelRight      = (ulong)DreamMakerRights.CancelCompile,
                Instance         = Instance
            };
            await jobManager.RegisterOperation(job, instanceManager.GetInstance(Instance).CompileProcess, cancellationToken).ConfigureAwait(false);

            return(Accepted(job.ToApi()));
        }
        public override async Task <IActionResult> Update([FromBody] Api.Models.Byond model, CancellationToken cancellationToken)
        {
            if (model == null)
            {
                throw new ArgumentNullException(nameof(model));
            }

            if (model.Version == null)
            {
                return(BadRequest(new ErrorMessage {
                    Message = "Missing version!"
                }));
            }

            var byondManager = instanceManager.GetInstance(Instance).ByondManager;

            // remove cruff fields
            var installingVersion = new Version(model.Version.Major, model.Version.Minor);

            var result = new Api.Models.Byond();

            if (byondManager.InstalledVersions.Any(x => x == model.Version))
            {
                Logger.LogInformation("User ID {0} changing instance ID {1} BYOND version to {2}", AuthenticationContext.User.Id, Instance.Id, installingVersion);
                await byondManager.ChangeVersion(model.Version, cancellationToken).ConfigureAwait(false);
            }
            else
            {
                Logger.LogInformation("User ID {0} installing BYOND version to {2} on instance ID {1}", AuthenticationContext.User.Id, Instance.Id, installingVersion);

                // run the install through the job manager
                var job = new Models.Job
                {
                    Description      = String.Format(CultureInfo.InvariantCulture, "Install BYOND version {0}", installingVersion),
                    StartedBy        = AuthenticationContext.User,
                    CancelRightsType = RightsType.Byond,
                    CancelRight      = (ulong)ByondRights.CancelInstall,
                    Instance         = Instance
                };
                await jobManager.RegisterOperation(job, (paramJob, databaseContext, progressHandler, ct) => byondManager.ChangeVersion(installingVersion, ct), cancellationToken).ConfigureAwait(false);

                result.InstallJob = job.ToApi();
            }

            if ((AuthenticationContext.GetRight(RightsType.Byond) & (ulong)ByondRights.ReadActive) != 0)
            {
                result.Version = byondManager.ActiveVersion;
            }
            return(result.InstallJob != null ? (IActionResult)Accepted(result) : Json(result));
        }
        public ActionResult Create(FormCollection form)
        {
            ValidateModel(form);

            try
            {
                Models.Job job = new Models.Job();
                UpdateModel(job);

                // Test this here rather than further up so we get the errors from update model even
                // if the manual validation fails
                if (!ModelState.IsValid)
                    throw new InvalidOperationException("Input failed model validation");

                job.Save();

                return RedirectToAction("Index");
            }
            catch
            {
                ViewData["ClientList"] = new SelectList(Models.Client.SelectAll(), "ClientId", "Name");
                return View();
            }
        }
 public ActionResult Multiadd(UI.Models.Job jobdata)
 {
     UI.Models.Job job = new Models.Job();
     job.InsertJobDetials(jobdata);
     return View();
 }
        public ActionResult Edit(string id, FormCollection form)
        {
            ValidateModel(form);

            try
            {
                Models.Job job = new Models.Job(id);

                if (id != form["JobId"]) // Primary key updated
                {
                    // Cheesey cascade update
                    Models.Job newJob = new Models.Job();
                    UpdateModel(newJob);

                    if (!ModelState.IsValid)
                        throw new InvalidOperationException("Input failed model validation");

                    newJob.Save();

                    foreach (Models.TimeBlock timeBlock in Models.TimeBlock.SelectByJobId(id))
                    {
                        timeBlock.JobId = newJob.JobId;
                        timeBlock.Save();
                    }

                    job.Delete();
                }
                else
                {
                    UpdateModel<Models.Job>(job);
                    if (!ModelState.IsValid)
                        throw new InvalidOperationException("Input failed model validation");
                    job.Save();
                }

                return RedirectToAction("Index");
            }
            catch
            {
                ViewData["ClientList"] = new SelectList(Models.Client.SelectAll(), "ClientId", "Name");
                return View();
            }
        }
예제 #36
0
 public ActionResult PostJob(string username)
 {
     //String username = TempData["Username"] as String;
     Models.User user = UserHelper.Instance.GetUser(username);
     Models.Job job = new Models.Job();
     Models.RecruiterJobSeeker.JobUserSkillModel jsm = new Models.RecruiterJobSeeker.JobUserSkillModel(user, job);
     TempData["Model"] = jsm;
     TempData["Username"] = username;
     return View(jsm);
 }
예제 #37
0
 public ActionResult PostNewJob()
 {
     var dataContext = new Models.LinqModelHelperDataContext();
     Models.Job j = new Models.Job();
     j.JobID = Guid.NewGuid();
     j.Employer = Request.Form["Employer"];
     j.Description = Request.Form["Description"];
     j.Title = Request.Form["Title"];
     j.UserID = new Guid(Request.Form["UserID"]);
     j.PostDate = DateTime.Now;
     j.Status = 1;
     dataContext.Jobs.InsertOnSubmit(j);
     dataContext.SubmitChanges();
     for (int i = 1; i <= Int32.Parse(Request.Form["skillIndex"]); i++)
     {
         string skill = Request.Form["Skill" + i.ToString()];
         string year = Request.Form["Year" + i.ToString()];
         if (skill != String.Empty && year != string.Empty)
         {
             Models.JobSkill jobskill = new Models.JobSkill();
             jobskill.JobSkillID = Guid.NewGuid();
             jobskill.JobID = j.JobID;
             jobskill.Skill = skill;
             jobskill.Year = (short)Int32.Parse(year);
             dataContext.JobSkills.InsertOnSubmit(jobskill);
         }
     }
     dataContext.SubmitChanges();
     TempData["Username"] = Request.Form["username"];
     return RedirectToAction("Index", "Recruiter1", new { username = Request.Form["username"] });
 }
예제 #38
0
        public void SaveBoard(string boardID, List<BoardData> board)
        {
            if (board != null)
            {
                var dataContext = new Models.LinqModelHelperDataContext();
                var dbboardOwnerID = from b in dataContext.RecruiterBoards
                                     where b.BoardID.ToString() == boardID
                                     select b;
                string boardOwnerID = dbboardOwnerID.First().OwnerID.ToString();

                // First set all the applied jobs with the columns to null
                //var dbappliedjobs = from aj in dataContext.UserAppliedJobs
                //                    join bc in dataContext.BoardColumns on aj.Stage equals bc.BoardID
                //                    select aj;

                //foreach (Models.UserAppliedJob aj in dbappliedjobs)
                //{
                //    aj.Stage = Guid.Empty;
                //}

                // Then delete all columns of the particular board
                var bcolumns = dataContext.BoardColumns.Where(c => c.BoardID.ToString() == boardID);
                dataContext.BoardColumns.DeleteAllOnSubmit(bcolumns);

                ArrayList columnIDs = new ArrayList();
                var boardcolumns = from r in board
                                   where r.row == 0
                                   orderby r.col
                                   select r;
                // Save columns
                foreach (BoardData bdata in boardcolumns)
                {
                    Models.BoardColumn boardColumn = new Models.BoardColumn();
                    boardColumn.BoardID = new Guid(boardID);
                    boardColumn.ColumnIndex = bdata.col;
                    boardColumn.ID = Guid.NewGuid();
                    boardColumn.Name = bdata.value;
                    dataContext.BoardColumns.InsertOnSubmit(boardColumn);
                    columnIDs.Add(boardColumn.BoardID);
                }

                // Now remove all values of a board
                ArrayList clientIDs = new ArrayList();
                ArrayList jobIDs = new ArrayList();
                int rowindex = -1;
                var boardelements = from r in board
                                    where r.row > 0
                                    select r;
                boardelements.OrderBy(r => new { r.col }).GroupBy(r => new { r.row });
                bool isRowUpdate = true;
                Guid currClientID = Guid.Empty;
                Guid currJobID = Guid.Empty;
                Guid currRowID = Guid.Empty;
                Models.User newclient = null;
                bool waitForJob = false;
                foreach (BoardData cell in boardelements)
                {
                    if (cell.row != rowindex)
                    {
                        // The first column of the row contains the rowid
                        isRowUpdate = String.IsNullOrEmpty(cell.rowid) ? false : true;
                        // Save the row
                        if (isRowUpdate)
                        {
                            // Find the row
                            var dbrow = from row in dataContext.JobBoardRows
                                        where row.RowID.ToString() == cell.rowid
                                        select row;
                            Models.JobBoardRow boardrow = dbrow.First();
                            boardrow.RowIndex = cell.row;
                            currRowID = boardrow.RowID;

                            waitForJob = false;
                        }
                        // TODO: what if the user adds a new row?
                        // TODO: we might want to ask the user to select from a client/position
                        // TODO: user should not be allowed to type arbitrarily in the new row
                        else
                        {
                            // TODO search for a user
                            newclient = new Models.User();
                            newclient.UserID = Guid.NewGuid();
                            newclient.FirstName = newclient.LastName = newclient.Login = cell.value;
                            dataContext.Users.InsertOnSubmit(newclient);

                            // Next cell should be the position info
                            waitForJob = true;
                        }
                        rowindex = cell.row;
                    }

                    else if (waitForJob)
                    {
                        Models.Job newjob = new Models.Job();
                        newjob.JobID = Guid.NewGuid();
                        newjob.ClientID = newclient.UserID;
                        newjob.Title = cell.value;
                        newjob.PostDate = DateTime.UtcNow;
                        newjob.UserID = new Guid(boardOwnerID);
                        dataContext.Jobs.InsertOnSubmit(newjob);

                        Models.JobBoardRow newrow = new Models.JobBoardRow();
                        newrow.RowID = Guid.NewGuid();
                        newrow.RowIndex = cell.row;
                        newrow.ClientID = newclient.UserID;
                        newrow.BoardID = new Guid(boardID);
                        newrow.JobID = newjob.JobID;
                        dataContext.JobBoardRows.InsertOnSubmit(newrow);
                        currRowID = newrow.RowID;
                        currJobID = newjob.JobID;

                        Models.BoardContent bc = new Models.BoardContent();
                        bc.RowID = currRowID;
                        bc.ColumnIndex = 0;
                        bc.CellID = Guid.NewGuid();
                        bc.Value = newclient.FirstName;
                        dataContext.BoardContents.InsertOnSubmit(bc);

                        Models.BoardContent bc1 = new Models.BoardContent();
                        bc1.RowID = currRowID;
                        bc1.ColumnIndex = 1;
                        bc1.CellID = Guid.NewGuid();
                        bc1.Value = newjob.Title;
                        dataContext.BoardContents.InsertOnSubmit(bc1);
                        waitForJob = false;
                    }
                    else
                    {
                        if (String.IsNullOrEmpty(cell.value))
                            cell.value = "";
                        else
                        {
                            cell.value = cell.value.Replace("\n", "");
                            cell.value = cell.value.Trim();
                        }
                        if (!String.IsNullOrEmpty(cell.cellid))
                        {
                            // Existing cell, update it
                            string[] fields = cell.cellid.Split('_');
                            if (fields != null)
                            {
                                var dbcell = from c in dataContext.BoardContents
                                                where c.CellID.ToString() == cell.cellid
                                                select c;
                                Models.BoardContent bc = dbcell.First();
                                bc.ColumnIndex = cell.col;
                                bc.RowID = currRowID;
                                bc.Value = cell.value;
                            }

                            /*if (fields[0].Equals("Client", StringComparison.OrdinalIgnoreCase))
                            {
                                // The ID of this cell indicates the client ID
                                if (isUpdate)
                                {
                                    var client = from u in dataContext.Users
                                                    where u.UserID.ToString() == fields[2]
                                                    select u;
                                    Models.User user = client.First();
                                    user.FirstName = cell.value;
                                    user.LastName = cell.value;
                                    currClientID = user.UserID;
                                }
                                else
                                {
                                    Models.User user = new Models.User();
                                    user.UserID = Guid.NewGuid();
                                    user.FirstName = user.LastName = cell.value;
                                    dataContext.Users.InsertOnSubmit(user);
                                    currClientID = user.UserID;
                                }
                            }
                            else if (fields[0].Equals("Job", StringComparison.OrdinalIgnoreCase))
                            {
                                // The ID of this cell indicates the Job ID
                                if (isUpdate)
                                {
                                    var dbposition = from j in dataContext.Jobs
                                                        where j.JobID.ToString() == fields[2]
                                                        select j;
                                    Models.Job job = dbposition.First();
                                    job.Title = cell.value;
                                    currJobID = job.JobID;
                                }
                                else
                                {
                                    Models.Job job = new Models.Job();
                                    job.JobID = Guid.NewGuid();
                                    currJobID = job.JobID;
                                    job.Title = cell.value;
                                    job.PostDate = DateTime.UtcNow;
                                    job.UserID = new Guid(boardOwnerID);
                                    dataContext.Jobs.InsertOnSubmit(job);
                                }
                            } */
                        }
                        else
                        {
                            Models.BoardContent bc = new Models.BoardContent();
                            bc.RowID = currRowID;
                            bc.CellID = Guid.NewGuid();
                            bc.ColumnIndex = cell.col;
                            bc.Value = cell.value;
                            dataContext.BoardContents.InsertOnSubmit(bc);
                        }

                            //else
                            //{
                            //    // These cells are applicants
                            //    Guid columnID = (Guid)columnIDs[cell.col];
                            //    if (isUpdate)
                            //    {
                            //        var dbapj = from j in dataContext.UserAppliedJobs
                            //                where j.JobID == currJobID
                            //                select j;

                            //    }
                            //    else
                            //    {
                            //        Models.UserAppliedJob uaj = new Models.UserAppliedJob();
                            //    }
                            //}
                    }

                }
                dataContext.SubmitChanges();
            }
        }
 public ActionResult Edit(string id)
 {
     Models.Job job = new Models.Job(id);
     ViewData["ClientList"] = new SelectList(Models.Client.SelectAll().OrderBy(o => o.Name), "ClientId", "Name", job.ClientId);
     return View(job);
 }
        //
        // GET: /Jobs/
        public ActionResult Index()
        {
            UI.Models.Job jobmodel = new Models.Job();
            List<SelectListItem> mailinglistitems = new List<SelectListItem>();

            Business.ApplicationService.AppServiceClient appclient = new Business.ApplicationService.AppServiceClient();
            Business.ApplicationService.maillist[] maillists = appclient.jsonMailinglists(Session["companyid"].ToString(), Session["usertoken"].ToString());

            foreach (Business.ApplicationService.maillist maillist in maillists)
            {
                mailinglistitems.Add(new SelectListItem { Text = maillist.Title, Value = maillist.Id });
            }
            ViewBag.MailListCollection = mailinglistitems;

            return View(jobmodel.getAllInhouseorPublishActiveorInactiveJobsList());
        }
 public ActionResult Details(string id)
 {
     Models.Job job = new Models.Job(id);
     return View(job);
 }