public virtual JobRequestResult Process(JobRequest request) { #region Unaffected logic if (request.RequestedByDate.CompareTo(DateTime.Now) < 0) return new JobRequestResult {Accepted = false, Errors = new List<IJobRequestError> {new JobInThePastError()}}; #endregion Unaffected logic #region Altered Logic to support 3 days in the future limit for non-emergency requests if (request.RequestedByDate.CompareTo(DateTime.Now.AddDays(2)) <= 0) return new JobRequestResult {Accepted = false, Errors = new List<IJobRequestError> {new RequestedDateTooSoonError()}}; #endregion Altered Logic to support 2 days in the future limit for non-emergency requests #region Unaffected logic using (var ctx = new SharedDbContext()) { var matchingTasks = ctx.Job.Find(request.RequestedTask); if (matchingTasks == null) return new JobRequestResult {Accepted = false, Errors = new List<IJobRequestError> {new UnknownJobIdError()}}; var maximumNumberOfJobsAlreadyScheduled = (from job in ctx.ScheduledJob where job.ScheduledOn.Equals(request.RequestedByDate) select job).Count() > 3; if (maximumNumberOfJobsAlreadyScheduled) return new JobRequestResult {Accepted = false, Errors = new List<IJobRequestError> {new RequestedDateFullError()}}; var scheduledJob = ctx.ScheduledJob.Create(); scheduledJob.ScheduledOn = request.RequestedByDate; ctx.ScheduledJob.Add(scheduledJob); ctx.SaveChanges(); } return new JobRequestResult {Accepted = true, ScheduledToBeginOn = request.RequestedByDate}; #endregion Unaffected logic }
public async Task <JobStatusResponse> JobBulkUpsertAsync(string objectName, string externalKeyName, byte[] archive) { var jobRequest = new JobRequest(objectName, "CSV", "upsert", null, externalKeyName); var jobResponse = await CreateJobAsync(jobRequest); var response = await SchedulingJobAsync(jobResponse.Id, archive); return(response); }
public ActionResult Hire(int id, int[] TechId) { string mail = User.Identity.Name; using (ITExpertsContext db = new ITExpertsContext()) { User usr = db.Users.Find(id); Company cmp = db.Companies.First(x => x.Email.Equals(mail)); if (db.WorkingAts.Any(x => x.UserId == id && x.CompanyId == cmp.CompanyId && x.Until == null)) { TempData["Status"] = "The selected employee is already working at your company!"; return(RedirectToAction("SearchEmployees", "Account")); } if (usr.MadeUp == true) { foreach (int t in TechId) { WorkingAt job = new WorkingAt(); job.Since = DateTime.Now; job.Until = null; job.TechId = t; job.UserId = usr.UserId; job.CompanyId = cmp.CompanyId; job.CompanyName = cmp.CompanyName; job.Description = "Automatically generated description"; db.WorkingAts.Add(job); db.SaveChanges(); } } else { User cmp2 = db.Users.First(x => x.Email.Equals(mail)); JobRequest r = new JobRequest(); r.DateOfRequest = DateTime.Now; r.SenderId = cmp2.UserId; r.ReceiverId = usr.UserId; r.Status = "New"; string techs = ""; foreach (int t in TechId) { techs += t.ToString() + ","; } techs.Remove(techs.Length - 1, 1); r.Techs = techs; db.JobRequests.Add(r); db.SaveChanges(); SendMail(mail, 3, usr.Email); } SendMail(mail, 4, ""); } return(RedirectToAction("MyCompanyProfile", "Account")); }
public HttpResponseMessage Create(JobRequest req) { if (!ModelState.IsValid) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } var id = jobs.Create(req); return(Request.CreateResponse(HttpStatusCode.Created, id)); }
public void Submit(JobRequest jobRequest) { var driverFolder = PrepareDriverFolder(jobRequest); var submissionJobArgsFilePath = CreateBootstrapAvroJobConfig(jobRequest.JobParameters, driverFolder); var submissionAppArgsFilePath = CreateBootstrapAvroAppConfig(jobRequest.AppParameters, driverFolder); _javaClientLauncher.LaunchAsync(jobRequest.JavaLogLevel, JavaClassName, submissionJobArgsFilePath, submissionAppArgsFilePath) .GetAwaiter().GetResult(); Logger.Log(Level.Info, "Submitted the Driver for execution."); }
private ProcessingRequest CreateProcessingRequest(JobRequest request, IMessage message) { return(new ProcessingRequest { JobId = message.Id, Name = message.Label, JobRequest = request, QueueId = _queue.Id, QueueName = _queue.Name, }); }
// GET: JobRequest/Edit/5 public ActionResult EditR(int id) { JobRequestModels g = new JobRequestModels(); JobRequest JBO = JOR.GetById(id); g.JobRequest_Motivation = JBO.JobRequest_Motivation; g.Speciality = JBO.Speciality; return(View(g)); }
public ActionResult EditR(int id, JobRequestModels JBO) { JobRequest g = JOR.GetById(id); g.JobRequest_Motivation = JBO.JobRequest_Motivation; g.Speciality = JBO.Speciality; return(RedirectToAction("GetAllApp")); }
public ActionResult Edit([Bind(Include = "id,PhoneNumber,JobId,EmailAddress,FirstName,LastName,FilePath")] JobRequest jobrequest) { if (ModelState.IsValid) { db.Entry(jobrequest).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(jobrequest)); }
public IActionResult Create([FromBody] JobRequest model) { var clientId = User.FindFirstValue(ClaimTypes.NameIdentifier); var job = _mapper.Map <Job>(model); job.ClientId = long.Parse(clientId); var m = _jobService.Create(job); return(CreatedAtAction(nameof(Get), new { id = m.Id }, new DataResponse <Job>(m))); }
public async Task <JobItemResponse> Create(JobRequest request) { var job = _mapper.Map <JobRequest, Job>(request); await _jobRepository.SaveAsync(job); var response = _mapper.Map <Job, JobItemResponse>(job); return(response); }
public IActionResult RequestJobExample() { JobRequest jr = new JobRequest { QueueId = "QueueID", JobHandleTimeoutSeconds = 120, Timeout = 2 }; return(this.Json(jr)); }
private void UpdateButton() { if (SelectedJobRequest != null) { JobRequest temp = SelectedJobRequest; DataEntryAllowed = true; JobRequestListEnabled = false; SelectedJobRequest = temp; } }
public void Confirm() { var request = new JobRequest { DTO = Mapper.Map(Model, new JobDTO()) }; var response = Helper.Call(s => s.JobSet(request)); ServiceResponseHelper.CheckServiceResponse(response, "JobSet", request); SliderHelper.Close(); Messenger.Default.Send(Messages.Job.Refresh); }
//////////////////////////////////////////// public ActionResult DeleteRADMIN(int id) { JobRequest j = JOR.GetById(id); JobOffer jb = Svo.GetById(j.JobOfferId); JOR.Delete(JOR.GetById(id)); JOR.Commit(); return(RedirectToAction("GetAllAppAdmin")); }
public async Task <ActionResult <JobResponse> > Post(JobRequest jobRequest) { if (!JobExists(jobRequest.Name)) { var job = ConvertJobRequestToJob(jobRequest); await _service.AddAsync(job); return(CreatedAtAction(nameof(GetItem), new { id = job.Id }, ConvertJobToJobResponse(job))); } return(new ConflictObjectResult(new { message = $"Already exists a job with name {jobRequest.Name}" })); }
public static int DeleteFullJobRequest(JobRequest jobRequestToDelete) { string storedProcedureName = "usp_deleteFullJobRequest"; MySqlParameter[] parameterList = new MySqlParameter[] { new MySqlParameter("jobRequestIDIn", jobRequestToDelete.JobRequestID) }; return(ExecuteNonQuery(storedProcedureName, parameterList)); }
public IJobSubmissionResult SubmitAndGetJobStatus(JobRequest jobRequest) { string azureJobId = JobSubmitInternal(jobRequest); return(new AzureBatchJobSubmissionResult(this, _fileNames.DriverHttpEndpoint, azureJobId, _numberOfRetries, _retryInterval, _batchService)); }
public bool UpdateRequest(JobRequest Updated) { if (_Context.JobRequest.Where(r => r.Id == Updated.Id).ToList().Count > 0) { _Context.JobRequest.RemoveRange(_Context.JobRequest.Where(r => r.Id == Updated.Id).FirstOrDefault()); _Context.JobRequest.Add(Updated); } return(Save()); }
public async Task SendMessage(JobRequest jobRequest) { try { await GetHubConnection.InvokeAsync("SendJobNotificationToSpecific", jobRequest); } catch (Exception ex) { // send failed } }
public void JobRequest_Constructor_Queued() { // Arrange var jobRequests = BaseTests.LoadJson("Get-VSTeamJobRequest-PoolId1-AgentID111.json"); // Act var target = new JobRequest(jobRequests[1]); // Assert Assert.AreEqual("queued", target.Result, "Result"); }
public IObservable <IEnumerable <JobDescription> > GetJobs(JobRequest request) { return(Observable.Create <IEnumerable <JobDescription> >(observer => Scheduler.Schedule(scheduler: Scheduler.Default, action: async() => { var result = await _repository.GetJobs(request); observer.OnNext(result); observer.OnCompleted(); }))); }
public override JobResponse Process() { var toTouch = JobRequest.GetElementById(this.Id); var ptr = new PointerEventData(EventSystem.current); ptr.position = new Vector2(X, Y); ExecuteEvents.Execute(toTouch.gameObject, ptr, ExecuteEvents.pointerDownHandler); return(new Responses.StringResponse()); }
public JobResponse Post([FromBody] JobRequest request) { JobSettings settings = new JobSettings(request); Guid id = Models.SasJobsManager.Current.BeginJob(settings); return(new JobResponse { CorrelationId = id, Status = Messages.StatusCode.Running, PercentComplete = 0 }); }
public static int UnmarkRequestReady(JobRequest jobRequest) { string storedProcedureName = "usp_coordinatorUnmarkRequestReady"; MySqlParameter[] parameterList = new MySqlParameter[] { new MySqlParameter("jobRequestIDIn", jobRequest.JobRequestID) }; return(ExecuteNonQuery(storedProcedureName, parameterList)); }
public static int UpdateRequestHours(JobRequest jobRequest) { string storedProcedureName = "usp_coordinatorUpdateHours"; MySqlParameter[] parameterList = new MySqlParameter[] { new MySqlParameter("jobRequestIDIn", jobRequest.JobRequestID), new MySqlParameter("estimatedHoursIn", jobRequest.EstimatedHours) }; return(ExecuteNonQuery(storedProcedureName, parameterList)); }
public static int DeleteContractorAssignment(JobRequest jobRequest, AssignableContractor contractor) { string storedProcedureName = "usp_deleteContractorAssignment"; MySqlParameter[] parameterList = new MySqlParameter[] { new MySqlParameter("jobRequestIDIn", jobRequest.JobRequestID), new MySqlParameter("contractorIDIn", contractor.ContractorID), }; return(ExecuteNonQuery(storedProcedureName, parameterList)); }
/// <summary> /// Enqueues a new job to be executed. /// </summary> /// <param name="job">The <see cref="JobRequest"/> detailing the /// job.</param> /// <returns>An <see cref="IJobTicket"/> providing job monitoring and /// result-tracking capabilities.</returns> public IJobTicket EnqueueJob(JobRequest job) { IJobTicket ticket = _processor.Enqueue(job); _tickets.Add(ticket); if (_processor.IsProcessing == false) { _processor.StartProcessing(); } return(ticket); }
public async Task <JobItemResponse> Update(int id, [FromBody] JobRequest request) { var job = _mapper.Map <JobRequest, Job>(request); job.JobId = id; await _jobRepository.SaveAsync(job); var jobResponse = _mapper.Map <Job, JobItemResponse>(job); return(jobResponse); }
private string PrepareDriverFolder(JobRequest jobRequest) { // Prepare the job submission folder var jobFolder = CreateJobFolder(jobRequest.JobIdentifier); var driverFolder = Path.Combine(jobFolder, DriverFolderName); Logger.Log(Level.Verbose, "Preparing driver folder in " + driverFolder); _driverFolderPreparationHelper.PrepareDriverFolder(jobRequest.AppParameters, driverFolder); return(driverFolder); }
public static int DeleteRequiredSkill(JobRequest jobRequest, Skill skill) { string storedProcedureName = "usp_deleteRequiredSkill"; MySqlParameter[] parameterList = new MySqlParameter[] { new MySqlParameter("jobRequestIDIn", jobRequest.JobRequestID), new MySqlParameter("skillNameIn", skill.SkillName) }; return(ExecuteNonQuery(storedProcedureName, parameterList)); }
public void WriteLogForJobRequest(JobRequest oldInfo, JobRequest newInfo, ELogAction action) { try { if (newInfo == null) { return; } MasterLog objMasterLog = new MasterLog(); string logId = commonDao.UniqueId; switch (action) { case ELogAction.Insert: // Insert to Master Log commonDao.InsertMasterLog(logId, newInfo.CreatedBy, ELogTable.JobRequest.ToString(), action.ToString()); // Write Insert Log WriteInsertLogForJobRequest(newInfo, logId); break; case ELogAction.Update: // Insert to Master Log commonDao.InsertMasterLog(logId, newInfo.UpdatedBy, ELogTable.JobRequest.ToString(), action.ToString()); // Write Update Log bool isUpdated = WriteUpdateLogForJobRequest(newInfo, logId); if (!isUpdated) { commonDao.DeleteMasterLog(logId); } break; case ELogAction.Delete: // Insert to Master Log commonDao.InsertMasterLog(logId, newInfo.UpdatedBy, ELogTable.JobRequest.ToString(), action.ToString()); // Write Delete Log string key = newInfo.ID.ToString() + " [" + newInfo.UserAdmin.UserName + " (Requestor) ]"; commonDao.InsertLogDetail(logId, "ID", "Key for Delete", key, null); break; } } catch (Exception ex) { throw ex; } }
public Message ForwardTo(JobRequest objUI) { Message msg = null; try { JobRequest objDb = GetById(objUI.ID); if (objDb != null) { // Check valid update date if (IsValidUpdateDate(objUI, objDb, out msg)) { new JobRequestLogDao().WriteUpdateLogForRoleHR(objUI, ELogAction.Update); // Update info by objUI objDb.AssignID = objUI.AssignID; objDb.AssignRole = objUI.AssignRole; objDb.InvolveID = objUI.InvolveID; objDb.InvolveRole = objUI.InvolveRole; objDb.InvolveDate = objUI.InvolveDate; objDb.InvolveResolution = objUI.InvolveResolution; objDb.UpdateDate = DateTime.Now; objDb.UpdatedBy = objUI.UpdatedBy; // Submit changes to dbContext dbContext.SubmitChanges(); // Show success message msg = new Message(MessageConstants.I0001, MessageType.Info, "Job Request'" + Constants.JOB_REQUEST_PREFIX + objUI.ID + "'", "updated"); } } } catch { // Show system error msg = new Message(MessageConstants.E0007, MessageType.Error); } return msg; }
public override JobRequestResult Process(JobRequest request) { if(request.IsEmergency) { if (request.RequestedByDate.CompareTo(DateTime.Now) < 0) return new JobRequestResult {Accepted = false, Errors = new List<IJobRequestError> {new JobInThePastError()}}; using (var ctx = new SharedDbContext()) { var matchingTasks = ctx.Job.Find(request.RequestedTask); if (matchingTasks == null) return new JobRequestResult {Accepted = false, Errors = new List<IJobRequestError> {new UnknownJobIdError()}}; var scheduledJob = ctx.ScheduledJob.Create(); scheduledJob.ScheduledOn = request.RequestedByDate; ctx.ScheduledJob.Add(scheduledJob); ctx.SaveChanges(); } _messenger.Send(new EmergencyJobScheduled{ ScheduledDate = request.RequestedByDate}); return new JobRequestResult {Accepted = true, ScheduledToBeginOn = request.RequestedByDate}; } return base.Process(request); }
/// <summary> /// Write Update Log For When Role Manager /// </summary> /// <param name="newInfo"></param> /// <param name="logId"></param> /// <returns></returns> public void WriteUpdateLogForRoleManager(JobRequest newInfo,ELogAction action) { bool isUpdated = false; try { // Get old info string logId = commonDao.UniqueId; commonDao.InsertMasterLog(logId, newInfo.UpdatedBy, ELogTable.JobRequest.ToString(), action.ToString()); JobRequest oldInfo = new JobRequestDao().GetById(newInfo.ID); if ((oldInfo != null) && (newInfo != null) && (logId != null)) { if (newInfo.WFStatusID != oldInfo.WFStatusID) { commonDao.InsertLogDetail(logId, "WFStatusID", "Status", oldInfo.WFStatus.Name, new WFStatusDao().GetByID(newInfo.WFStatusID).Name); isUpdated = true; } if (newInfo.WFResolutionID != oldInfo.WFResolutionID) { WFResolution objRes = new ResolutionDao().GetByID(newInfo.WFResolutionID); if (objRes != null) { commonDao.InsertLogDetail(logId, "WFResolutionID", "Resolution", oldInfo.WFResolution.Name, objRes.Name); isUpdated = true; } } if (newInfo.AssignRole != oldInfo.AssignRole) { if (newInfo.AssignRole.HasValue) { WFRole obj = new RoleDao().GetByID(newInfo.AssignRole.Value); if (obj != null) { UserAdmin objUserAdmin = new UserAdminDao().GetById(newInfo.AssignID.Value); if (objUserAdmin != null) { commonDao.InsertLogDetail(logId, "AssignID", " Forward to", oldInfo.UserAdmin1.UserName + " (" + oldInfo.WFRole.Name + ")", objUserAdmin.UserName + " (" + obj.Name + ")"); isUpdated = true; } } } } if (isUpdated) { // Insert Key Name string key = Constants.JOB_REQUEST_PREFIX + oldInfo.ID.ToString(); commonDao.InsertLogDetail(logId, "EmployeeId", "Key for Update", key, null); } else { commonDao.DeleteMasterLog(logId); } } } catch (Exception ex) { throw ex; } }
/// <summary> /// Write Insert Log Job Request /// </summary> /// <param name="objInfo"></param> /// <param name="logId"></param> private void WriteInsertLogForJobRequest(JobRequest objInfo, string logId) { try { if ((objInfo != null) && (logId != null)) { // Insert to Log Detail commonDao.InsertLogDetail(logId, "ID", "Request", null, Constants.JOB_REQUEST_PREFIX + objInfo.ID.ToString()); commonDao.InsertLogDetail(logId, "WFStatusID", "Status", null, objInfo.WFStatus.Name); commonDao.InsertLogDetail(logId, "WFResolutionID", "Resolution", null, objInfo.WFResolution.Name); commonDao.InsertLogDetail(logId, "RequestorId", "Requestor", null, objInfo.UserAdmin.UserName + " (Requestor) "); commonDao.InsertLogDetail(logId, "RequestDate", "Request Date", null, objInfo.RequestDate.ToString(Constants.DATETIME_FORMAT_VIEW)); commonDao.InsertLogDetail(logId, "Department", "Department", null, deptDao.GetDepartmentNameBySub(objInfo.DepartmentId)); commonDao.InsertLogDetail(logId, "DepartmentId", "Sub Department", null, objInfo.Department.DepartmentName); //commonDao.InsertLogDetail(logId, "PositionFrom", "Position From", null, objInfo.JobTitleLevel.DisplayName); commonDao.InsertLogDetail(logId, "RequestTypeId", "Request Type", null, objInfo.RequestTypeId == Constants.JR_REQUEST_TYPE_NEW ? "New" : "Replace"); //if (objInfo.PositionTo.HasValue) //{ // commonDao.InsertLogDetail(logId, "PositionTo", "Position To", null, objInfo.JobTitleLevel1.DisplayName); //} if (objInfo.ExpectedStartDate.HasValue) { commonDao.InsertLogDetail(logId, "ExpectedStartDate", "Expected Start Date", null, objInfo.ExpectedStartDate.Value.ToString(Constants.DATETIME_FORMAT_VIEW)); } if (!string.IsNullOrEmpty(objInfo.SalarySuggestion)) { commonDao.InsertLogDetail(logId, "SalarySuggestion", "Salary Suggestion", null, objInfo.SalarySuggestion); } if (!string.IsNullOrEmpty(objInfo.CCList)) { commonDao.InsertLogDetail(logId, "CCList", "CC List", null, objInfo.CCList); } /*if (!string.IsNullOrEmpty(objInfo.Justification)) { commonDao.InsertLogDetail(logId, "Justification", "Justification", null, objInfo.Justification); }*/ if (objInfo.AssignID.HasValue) { if (objInfo.WFResolutionID != Constants.RESOLUTION_NEW_ID) { commonDao.InsertLogDetail(logId, "AssignID", "Forward to", null, objInfo.UserAdmin1.UserName + " (Manager) "); } } } } catch (Exception ex) { throw ex; } }
/// <summary> /// Write Update Log For Job Request /// </summary> /// <param name="newInfo"></param> /// <param name="logId"></param> /// <returns></returns> private bool WriteUpdateLogForJobRequest(JobRequest newInfo, string logId) { bool isUpdated = false; try { // Get old info JobRequest oldInfo = new JobRequestDao().GetById(newInfo.ID); if ((oldInfo != null) && (newInfo != null) && (logId != null)) { if (newInfo.WFStatusID != oldInfo.WFStatusID) { if (newInfo.WFStatusID != 0) { commonDao.InsertLogDetail(logId, "WFStatusID", "Status", oldInfo.WFStatus.Name, new WFStatusDao().GetByID(newInfo.WFStatusID).Name); isUpdated = true; } } if (newInfo.CCList != oldInfo.CCList) { commonDao.InsertLogDetail(logId, "CCList", "CC List", oldInfo.CCList, newInfo.CCList); isUpdated = true; } if (newInfo.RequestTypeId != oldInfo.RequestTypeId) { commonDao.InsertLogDetail(logId, "CCList", "CC List", oldInfo.RequestTypeId == Constants.JR_REQUEST_TYPE_NEW ? "New":"Replace", newInfo.RequestTypeId == Constants.JR_REQUEST_TYPE_NEW ? "New":"Replace"); isUpdated = true; } if (newInfo.WFResolutionID != oldInfo.WFResolutionID) { if (newInfo.WFResolutionID != 0) { WFResolution objRes = new ResolutionDao().GetByID(newInfo.WFResolutionID); if (objRes != null) { commonDao.InsertLogDetail(logId, "WFResolutionID", "Resolution", oldInfo.WFResolution.Name, objRes.Name); isUpdated = true; } } } if (newInfo.RequestDate != oldInfo.RequestDate) { commonDao.InsertLogDetail(logId, "RequestDate", "Request Date", oldInfo.RequestDate.ToString(Constants.DATETIME_FORMAT_VIEW), newInfo.RequestDate.ToString(Constants.DATETIME_FORMAT_VIEW)); isUpdated = true; } if (newInfo.DepartmentId != oldInfo.DepartmentId) { Department objDepart = new DepartmentDao().GetById(newInfo.DepartmentId); if (objDepart != null) { commonDao.InsertLogDetail(logId, "DepartmentId", "Sub Department", oldInfo.Department.DepartmentName, objDepart.DepartmentName); commonDao.InsertLogDetail(logId, "Department", "Department", deptDao.GetDepartmentNameBySub(oldInfo.DepartmentId), deptDao.GetDepartmentNameBySub(newInfo.DepartmentId)); isUpdated = true; } } //if (newInfo.PositionFrom != oldInfo.PositionFrom) //{ // JobTitleLevel objJobFrom = new JobTitleLevelDao().GetById(newInfo.PositionFrom); // if (objJobFrom != null) // { // commonDao.InsertLogDetail(logId, "PositionFrom", "Position From", oldInfo.JobTitleLevel.DisplayName, objJobFrom.DisplayName); // isUpdated = true; // } //} //if (newInfo.PositionTo != oldInfo.PositionTo) //{ // if (newInfo.PositionTo.HasValue) // { // JobTitleLevel objJobTo = new JobTitleLevelDao().GetById(newInfo.PositionTo.Value); // if (objJobTo != null) // { // commonDao.InsertLogDetail(logId, "PositionTo", "Position To", oldInfo.PositionTo.HasValue?oldInfo.JobTitleLevel1.DisplayName:"", objJobTo.DisplayName); // isUpdated = true; // } // } //} string oldSalarySuggestionValue = string.IsNullOrEmpty(oldInfo.SalarySuggestion) ? null : EncryptUtil.Decrypt(oldInfo.SalarySuggestion); if (newInfo.SalarySuggestion != oldSalarySuggestionValue) { if (!string.IsNullOrEmpty(newInfo.SalarySuggestion)) { commonDao.InsertLogDetail(logId, "SalarySuggestion", "Salary Suggestion", oldInfo.SalarySuggestion, EncryptUtil.Encrypt(newInfo.SalarySuggestion)); isUpdated = true; } else { commonDao.InsertLogDetail(logId, "SalarySuggestion", "Salary Suggestion", oldInfo.SalarySuggestion,newInfo.SalarySuggestion); isUpdated = true; } } if (newInfo.AssignRole != oldInfo.AssignRole || newInfo.AssignID != oldInfo.AssignID) { if (newInfo.AssignRole.HasValue) { WFRole obj = new RoleDao().GetByID(newInfo.AssignRole.Value); if (obj != null) { UserAdmin objUserAdmin = new UserAdminDao().GetById(newInfo.AssignID.Value); if (objUserAdmin != null) { commonDao.InsertLogDetail(logId, "AssignID", "Forward to", oldInfo.UserAdmin1.UserName + " ( " + oldInfo.WFRole.Name + " )", objUserAdmin.UserName + " ( " + obj.Name + " )"); isUpdated = true; } } } } if (isUpdated) { // Insert Key Name string key = Constants.JOB_REQUEST_PREFIX + oldInfo.ID.ToString(); commonDao.InsertLogDetail(logId, "EmployeeId", "Key for Update", key, null); } } } catch (Exception ex) { throw ex; } return isUpdated; }
public Message UpdateForApproval(JobRequest objUI, JobRequestComment objComment) { Message msg = null; DbTransaction trans = null; try { dbContext.Connection.Open(); trans = dbContext.Connection.BeginTransaction(); dbContext.Transaction = trans; if (objUI != null) { JobRequest objDb = GetById(objUI.ID); if (objDb != null) { #region Insert Comment if (objComment != null && !string.IsNullOrEmpty(objComment.Contents)) { JRCommentDao commentDao = new JRCommentDao(); commentDao.Insert(objComment); } #endregion // Check valid update date if (IsValidUpdateDate(objUI, objDb, out msg)) { new JobRequestLogDao().WriteUpdateLogForRoleManager(objUI, ELogAction.Update); objDb.WFResolutionID = objUI.WFResolutionID; //if (!string.IsNullOrEmpty(objUI.Approval)) //{ // objDb.Approval = objUI.Approval; //} objDb.WFResolution = objUI.WFResolution; objDb.AssignID = objUI.AssignID; objDb.AssignRole = objUI.AssignRole; objDb.InvolveID = objUI.InvolveID; objDb.InvolveRole = objUI.InvolveRole; objDb.InvolveDate = objUI.InvolveDate; objDb.UpdateDate = DateTime.Now; dbContext.SubmitChanges(); msg = new Message(MessageConstants.I0001, MessageType.Info, " Job Request '" + Constants.JOB_REQUEST_PREFIX + objUI.ID + "'", "updated"); trans.Commit(); } else { trans.Rollback(); } } } } catch { // Rollback transaction if (trans != null) { trans.Rollback(); } // Show system error msg = new Message(MessageConstants.E0007, MessageType.Error); } finally { if ((trans.Connection != null) && (trans.Connection.State == System.Data.ConnectionState.Open)) { trans.Connection.Close(); } } return msg; }
public bool hasUpdate(JobRequest objUI) { bool hasUpdate = false; if (objUI != null) { // Get current group in dbContext JobRequest objDb = GetById(objUI.ID); if (objDb != null) { if (objDb.WFStatusID != objUI.WFStatusID) { hasUpdate = true; } if (objDb.WFResolutionID != objUI.WFResolutionID) { hasUpdate = true; } if (objDb.RequestDate != objUI.RequestDate) { hasUpdate = true; } if (objDb.DepartmentId != objUI.DepartmentId) { hasUpdate = true; } if (objDb.PositionFrom != objUI.PositionFrom) { hasUpdate = true; } if (objDb.PositionTo != objUI.PositionTo) { hasUpdate = true; } if (objDb.ExpectedStartDate != objUI.ExpectedStartDate) { hasUpdate = true; } if (objDb.SalarySuggestion != objUI.SalarySuggestion) { hasUpdate = true; } /*if (objDb.ProbationMonths != objUI.ProbationMonths) { hasUpdate = true; }*/ if (objDb.Justification != objUI.Justification) { hasUpdate = true; } if (objDb.CCList != objUI.CCList) { hasUpdate = true; } if (objDb.AssignID != objUI.AssignID) { hasUpdate = true; } if (objDb.AssignRole != objUI.AssignRole) { hasUpdate = true; } } } return hasUpdate; }
/// <summary> /// Delete /// </summary> /// <param name="objUI"></param> private void Delete(JobRequest objUI) { if (objUI != null) { // Get current group in dbContext JobRequest objDb = GetById(objUI.ID); if (objDb != null) { new JobRequestLogDao().WriteLogForJobRequest(null, objUI, ELogAction.Delete); // Set delete info objDb.DeleteFlag = true; objDb.UpdateDate = DateTime.Now; objDb.UpdatedBy = objUI.UpdatedBy; // Submit changes to dbContext dbContext.SubmitChanges(); } } }
/// <summary> /// Write Update Log For When Approve or Reject /// </summary> /// <param name="newInfo"></param> /// <param name="logId"></param> /// <returns></returns> public void WriteUpdateLogForRoleHR(JobRequest newInfo, ELogAction action) { try { bool isUpdate = false; // Get old info string logId = commonDao.UniqueId; commonDao.InsertMasterLog(logId, newInfo.UpdatedBy, ELogTable.JobRequest.ToString(), action.ToString()); JobRequest oldInfo = new JobRequestDao().GetById(newInfo.ID); if ((oldInfo != null) && (newInfo != null) && (logId != null)) { if (oldInfo.AssignID != newInfo.AssignID) { string oldUser = ""; if (oldInfo.AssignID != null && oldInfo.AssignID.HasValue) { UserAdmin userAdmin = userAdmintDao.GetById(oldInfo.AssignID.Value); oldUser = userAdmin != null ? userAdmin.UserName : ""; } string newUser = ""; if (newInfo.AssignID != null && newInfo.AssignID.HasValue) { UserAdmin userAdmin = userAdmintDao.GetById(newInfo.AssignID.Value); newUser = userAdmin != null ? userAdmin.UserName : ""; } commonDao.InsertLogDetail(logId, "Forward To", "Forward To", oldUser, newUser); isUpdate = true; } /* if (oldInfo.AssignRole != newInfo.AssignRole) { string oldVal = oldInfo.AssignRole.HasValue ? oldInfo.AssignRole.ToString() : ""; string newVal = (newInfo.AssignRole != null && newInfo.AssignRole.HasValue) ? newInfo.AssignRole.ToString() : ""; commonDao.InsertLogDetail(logId, "AssignRole", "AssignRole", oldVal, newVal); isUpdate = true; } if (oldInfo.InvolveID != newInfo.InvolveID) { commonDao.InsertLogDetail(logId, "InvolveID", "InvolveID", oldInfo.InvolveID, newInfo.InvolveID); isUpdate = true; } if (oldInfo.InvolveRole != newInfo.InvolveRole) { commonDao.InsertLogDetail(logId, "InvolveRole", "InvolveRole", oldInfo.InvolveRole, newInfo.InvolveRole); isUpdate = true; } if (oldInfo.InvolveDate != newInfo.InvolveDate) { commonDao.InsertLogDetail(logId, "InvolveDate", "InvolveDate", oldInfo.InvolveDate, newInfo.InvolveDate); isUpdate = true; } if (oldInfo.InvolveResolution != newInfo.InvolveResolution) { commonDao.InsertLogDetail(logId, "InvolveResolution", "InvolveResolution", oldInfo.InvolveResolution, newInfo.InvolveResolution); isUpdate = true; }*/ if (isUpdate) { // Insert Key Name string key = Constants.JOB_REQUEST_PREFIX + oldInfo.ID.ToString(); commonDao.InsertLogDetail(logId, "EmployeeId", "Key for Update", key, null); } else { commonDao.DeleteMasterLog(logId); } } } catch (Exception ex) { throw ex; } }
/// <summary> /// Insert /// </summary> /// <param name="objUI"></param> /// <returns></returns> public Message Insert(JobRequest objUI) { Message msg = null; try { if (objUI != null) { // Set more info objUI.DeleteFlag = false; objUI.CreateDate = DateTime.Now; objUI.UpdateDate = DateTime.Now; objUI.SalarySuggestion = string.IsNullOrEmpty(objUI.SalarySuggestion) ? null : EncryptUtil.Encrypt(objUI.SalarySuggestion); dbContext.JobRequests.InsertOnSubmit(objUI); dbContext.SubmitChanges(); new JobRequestLogDao().WriteLogForJobRequest(null, objUI, ELogAction.Insert); // Show success message msg = new Message(MessageConstants.I0001, MessageType.Info, "Job Request '" + Constants.JOB_REQUEST_PREFIX + objUI.ID + "'", "added"); } } catch(Exception ex) { // Show system error msg = new Message(MessageConstants.E0033, MessageType.Error, ex.Message); //msg = new Message(MessageConstants.E0007, MessageType.Error); } return msg; }
/// <summary> /// Update /// </summary> /// <param name="objUI"></param> /// <returns></returns> public Message Update(JobRequest objUI) { Message msg = null; try { if (objUI != null) { // Get current group in dbContext JobRequest objDb = GetById(objUI.ID); if (objDb != null) { // Check valid update date if (IsValidUpdateDate(objUI, objDb, out msg)) { // Update info by objUI new JobRequestLogDao().WriteLogForJobRequest(null, objUI, ELogAction.Update); objDb.DepartmentId = objUI.DepartmentId; objDb.RequestDate = objUI.RequestDate; objDb.ExpectedStartDate = objUI.ExpectedStartDate; objDb.PositionFrom = objUI.PositionFrom; objDb.PositionTo = objUI.PositionTo; objDb.SalarySuggestion = string.IsNullOrEmpty(objUI.SalarySuggestion) ? null : EncryptUtil.Encrypt(objUI.SalarySuggestion); objDb.Justification = objUI.Justification; if (objDb.WFResolutionID != 0 && objUI.WFResolutionID != 0) objDb.WFResolutionID = objUI.WFResolutionID; if (objDb.WFStatusID != 0 && objUI.WFStatusID != 0) objDb.WFStatusID = objUI.WFStatusID; objDb.AssignID = objUI.AssignID; objDb.RequestTypeId = objUI.RequestTypeId; objDb.AssignRole = objUI.AssignRole; objDb.InvolveID = objUI.InvolveID; objDb.InvolveRole = objUI.InvolveRole; objDb.InvolveDate = objUI.InvolveDate; objDb.UpdateDate = DateTime.Now; objDb.UpdatedBy = objUI.UpdatedBy; objDb.InvolveResolution = objUI.InvolveResolution; objDb.CCList = objUI.CCList; objDb.Quantity = objUI.Quantity; // Submit changes to dbContext dbContext.SubmitChanges(); // Show success message msg = new Message(MessageConstants.I0001, MessageType.Info, "Job Request '" + Constants.JOB_REQUEST_PREFIX + objUI.ID + "'", "updated"); } } } } catch { // Show system error msg = new Message(MessageConstants.E0007, MessageType.Error); } return msg; }
/// <summary> /// Check update date whether is valid /// </summary> /// <param name="objUI"></param> /// <param name="msg"></param> /// <returns></returns> private bool IsValidUpdateDate(JobRequest objUI, JobRequest objDb, out Message msg) { bool isValid = false; msg = null; try { if ((objUI != null) && (objUI.UpdateDate != null) && (objDb != null)) { if (objDb.UpdateDate.ToString().Equals(objUI.UpdateDate.ToString())) { isValid = true; } else { msg = new Message(MessageConstants.E0025, MessageType.Error, "Job Request Id " + objDb.ID); } } } catch { throw; } return isValid; }