Пример #1
0
 public bool JobChangeStatus(out string message)
 {
     message = "error";
     try
     {
         TMSDbContext DbContext = new TMSDbContext();
         DbContext.Database.CommandTimeout = Common.Constants.CommonConstants.TimeExcuteSql;
         DbContext.Database.ExecuteSqlCommand(Common.Constants.AbnormalQuery.ExcuteCheckTimeOut);
         var explanationRequest = _explanationRequestRepository.GetMulti(x => x.StatusRequestId == 1 || x.StatusRequestId == 5).ToList();
         foreach (var item in explanationRequest)
         {
             if (_commonService.GetDateExRequestInPast(item.CreatedDate.Value) < DateTime.Now.Date)
             {
                 item.StatusRequestId = 2;
                 _explanationRequestRepository.Update(item);
                 _explanationRequestService.Save();
             }
         }
         log.Info("Job Change Status Run Success :" + DateTime.Now.ToString("dd'/'MM'/'yyyy HH:mm:ss"));
         message = "Success";
         return(true);
     }
     catch (Exception ex)
     {
         message = "Error:" + ex.Message;
         return(false);
     }
 }
Пример #2
0
        //Change status explanation request by delegate config, when set delegate config in menu group
        public void ChangeStatusExplanationRequestConfigDelegate(string assignTo, List <ExplanationRequest> lstExplanationRequest)
        {
            var status = _statusRequestRepository.GetMulti(x => x.Name.Contains(CommonConstants.StatusDelegation)).FirstOrDefault();

            if (lstExplanationRequest.Count() > 0)
            {
                foreach (var itemExplanation in lstExplanationRequest)
                {
                    if (itemExplanation.StatusRequest.Name.Equals(CommonConstants.StatusDelegation))
                    {
                        itemExplanation.DelegateId = assignTo;
                        _explanationRequestRepository.Update(itemExplanation);
                    }
                    else
                    {
                        itemExplanation.StatusRequestId = status.ID;
                        itemExplanation.DelegateId      = assignTo;
                        _explanationRequestRepository.Update(itemExplanation);
                    }
                }
                SaveChange();
            }
        }
        /// <summary>
        /// chech request status
        /// </summary>
        /// <param name="delegationRequestID">ID of Request</param>
        /// <param name="action"></param>
        /// <returns>obejct request</returns>
        private ExplanationRequest CheckStatus(int DelegationRequestID, string action, string changeStatusBy)
        {
            var model         = GetIdRequest(DelegationRequestID);
            var statusRequest = _statusRequestRepository.GetMulti(x => x.Name.Equals(action)).FirstOrDefault();

            if (model.StatusRequest.Name == CommonConstants.StatusDelegation)
            {
                model.UpdatedBy       = changeStatusBy;
                model.DelegateId      = null;
                model.UpdatedDate     = DateTime.Now;
                model.StatusRequestId = statusRequest.ID;
                _explanationRequestRepository.Update(model);
                Save();
                return(model);
            }
            else
            {
                return(model);
            }
        }