コード例 #1
0
 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
 }
コード例 #2
0
        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);
        }
コード例 #3
0
        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"));
        }
コード例 #4
0
        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));
        }
コード例 #5
0
ファイル: LocalClient.cs プロジェクト: wwjiang007/reef
        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.");
        }
コード例 #6
0
ファイル: JobQueue.cs プロジェクト: awesomedotnetcore/AnyQ
 private ProcessingRequest CreateProcessingRequest(JobRequest request, IMessage message)
 {
     return(new ProcessingRequest {
         JobId = message.Id,
         Name = message.Label,
         JobRequest = request,
         QueueId = _queue.Id,
         QueueName = _queue.Name,
     });
 }
コード例 #7
0
        // 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));
        }
コード例 #8
0
        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"));
        }
コード例 #9
0
 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));
 }
コード例 #10
0
        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)));
        }
コード例 #11
0
        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);
        }
コード例 #12
0
        public IActionResult RequestJobExample()
        {
            JobRequest jr = new JobRequest {
                QueueId = "QueueID",
                JobHandleTimeoutSeconds = 120,
                Timeout = 2
            };

            return(this.Json(jr));
        }
コード例 #13
0
 private void UpdateButton()
 {
     if (SelectedJobRequest != null)
     {
         JobRequest temp = SelectedJobRequest;
         DataEntryAllowed      = true;
         JobRequestListEnabled = false;
         SelectedJobRequest    = temp;
     }
 }
コード例 #14
0
        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);
        }
コード例 #15
0
        ////////////////////////////////////////////

        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"));
        }
コード例 #16
0
        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}" }));
        }
コード例 #17
0
ファイル: DAL.cs プロジェクト: ulramite/BIT-Services
        public static int DeleteFullJobRequest(JobRequest jobRequestToDelete)
        {
            string storedProcedureName = "usp_deleteFullJobRequest";

            MySqlParameter[] parameterList = new MySqlParameter[]
            {
                new MySqlParameter("jobRequestIDIn", jobRequestToDelete.JobRequestID)
            };

            return(ExecuteNonQuery(storedProcedureName, parameterList));
        }
コード例 #18
0
        public IJobSubmissionResult SubmitAndGetJobStatus(JobRequest jobRequest)
        {
            string azureJobId = JobSubmitInternal(jobRequest);

            return(new AzureBatchJobSubmissionResult(this,
                                                     _fileNames.DriverHttpEndpoint,
                                                     azureJobId,
                                                     _numberOfRetries,
                                                     _retryInterval,
                                                     _batchService));
        }
コード例 #19
0
        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());
        }
コード例 #20
0
 public async Task SendMessage(JobRequest jobRequest)
 {
     try
     {
         await GetHubConnection.InvokeAsync("SendJobNotificationToSpecific", jobRequest);
     }
     catch (Exception ex)
     {
         // send failed
     }
 }
コード例 #21
0
ファイル: JobRequestTests.cs プロジェクト: staker4/vsteam
        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");
        }
コード例 #22
0
 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();
     })));
 }
コード例 #23
0
        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());
        }
コード例 #24
0
        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
            });
        }
コード例 #25
0
ファイル: DAL.cs プロジェクト: ulramite/BIT-Services
        public static int UnmarkRequestReady(JobRequest jobRequest)
        {
            string storedProcedureName = "usp_coordinatorUnmarkRequestReady";

            MySqlParameter[] parameterList = new MySqlParameter[]
            {
                new MySqlParameter("jobRequestIDIn", jobRequest.JobRequestID)
            };

            return(ExecuteNonQuery(storedProcedureName, parameterList));
        }
コード例 #26
0
ファイル: DAL.cs プロジェクト: ulramite/BIT-Services
        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));
        }
コード例 #27
0
ファイル: DAL.cs プロジェクト: ulramite/BIT-Services
        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));
        }
コード例 #28
0
        /// <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);
        }
コード例 #29
0
        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);
        }
コード例 #30
0
ファイル: LocalClient.cs プロジェクト: wwjiang007/reef
        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);
        }
コード例 #31
0
ファイル: DAL.cs プロジェクト: ulramite/BIT-Services
        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));
        }
コード例 #32
0
        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;
            }
        }
コード例 #33
0
ファイル: JobRequestDao.cs プロジェクト: vuchannguyen/lg-py
        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;
        }
コード例 #34
0
 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);
 }
コード例 #35
0
        /// <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;
            }
        }
コード例 #36
0
 /// <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;
     }
 }
コード例 #37
0
        /// <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;
        }
コード例 #38
0
ファイル: JobRequestDao.cs プロジェクト: vuchannguyen/lg-py
        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;
        }
コード例 #39
0
ファイル: JobRequestDao.cs プロジェクト: vuchannguyen/lg-py
        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;
        }
コード例 #40
0
ファイル: JobRequestDao.cs プロジェクト: vuchannguyen/lg-py
        /// <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();
                }
            }
        }
コード例 #41
0
        /// <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;
            }
        }
コード例 #42
0
ファイル: JobRequestDao.cs プロジェクト: vuchannguyen/lg-py
        /// <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;
        }
コード例 #43
0
ファイル: JobRequestDao.cs プロジェクト: vuchannguyen/lg-py
        /// <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;
        }
コード例 #44
0
ファイル: JobRequestDao.cs プロジェクト: vuchannguyen/lg-py
        /// <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;
        }