Ejemplo n.º 1
0
 protected void OnBtnBatchActivateClicked(object sender, EventArgs e)
 {
     GridItemCollection col = gridJobs.SelectedItems;
     JobRepository repo = new JobRepository();
     bool updated = false;
     foreach (GridDataItem item in col)
     {
         TableCell cell = item["JobID"];
         if (!string.IsNullOrEmpty(cell.Text))
         {
             int jobId = int.Parse(cell.Text);
             Job job = repo.FindOne(new Job(jobId));
             if (job != null)
             {
                 job.IsActive = true;
                 repo.Update(job);
                 updated = true;
             }
         }
     }
     if (updated)
     {
         //calExpiredDate.SelectedDate = null;
         //calRemindDate.SelectedDate = null;
         gridJobs.Rebind();
     }
 }
Ejemplo n.º 2
0
    private Neos.Data.Job SaveJobInfo()
    {
        UserMessageRepository messageRepo = new UserMessageRepository();
        JobRepository jobRepo = new JobRepository();
        Neos.Data.Job job = new Neos.Data.Job();

        if (!string.IsNullOrEmpty(Request.QueryString["JobId"])) //edit
        {
            job = jobRepo.FindOne(new Job(Int32.Parse(Request.QueryString["JobId"])));
            if (job != null)
            {
                string responsibleUser = job.CareerManager;
                job = SetInfoForJob(job);
                jobRepo.Update(job);

                if (responsibleUser != ddlResponsible.SelectedValue) // in case select another responsible user
                {
                    if (job.RemindDate.HasValue && job.ExpiredDate.HasValue)
                    {
                        UserMessage message = messageRepo.FindMessagesByRef(job.JobID.ToString());
                        if (message != null)
                        {
                            message.UserID = job.CareerManager;
                            messageRepo.Update(message);
                        }
                    }
                }
            }
        }
        else //edit
        {
            job = SetInfoForJob(job);
            job.CreatedDate = DateTime.Now;
            jobRepo.Insert(job);
            //insert a notification message
            if (job.RemindDate.HasValue && job.ExpiredDate.HasValue)
            {
                UserMessage message = new UserMessage();
                message.UserID = ddlResponsible.SelectedValue;
                message.Type = UserMessageType.JobResponsibility;
                message.Subject = ResourceManager.GetString("message.JobReminderSubject");
                message.MessageContent = string.Format(ResourceManager.GetString("message.JobReminderContent"), job.ExpiredDate.Value.ToString("dd/MM/yyyy hh:mm tt"), "JobProfile.aspx?JobId=" + job.JobID);
                message.RemindDate = job.RemindDate;
                message.CreatedDate = DateTime.Now;
                message.IsUnread = true;
                message.RefID = job.JobID.ToString();
                messageRepo.Insert(message);
            }
        }
        return job;
    }