예제 #1
0
        public string ProcessApprovedClaim(string host, Guid LoginID, Guid userApprovedID, Guid recordID, string type)
        {
            DataErrorCode status = DataErrorCode.Success;
            string stt = string.Empty;
            var Services = new BaseService();
            using (var context = new VnrHrmDataContext())
            {
                var services = new FIN_ClaimItemService();
                var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
                var repoClaim = new CustomBaseRepository<FIN_Claim>(unitOfWork);
                var claimEntity = repoClaim.FindBy(s => s.IsDelete == null && s.ID == recordID).FirstOrDefault();
                
                var claimServices = new FIN_ClaimService();
                var result = ApprovedClaim(recordID, LoginID,type);


                List<Guid> lstId = new List<Guid>();
                if (claimEntity != null)
                {
                    lstId.Add(claimEntity.ID);
                }
                if (result == "Success")
                {
                   services.ActionApprovedAll(lstId, "E_APPROVED", LoginID);
                }
                if (result == "Success")
                {
                    status = SendMaToNextApproved(host, recordID, userApprovedID);
                }

                return status.ToString();
            }
        }
예제 #2
0
 public ActionResult ActionApprovedClaimItemAll(List<Guid> selectedIds, string status, Guid userId)
 {
     //List<Guid> lstHoldSalaryIDs = selectedIds.Split(',').Select(x => Guid.Parse(x)).ToList();
     var services = new FIN_ClaimItemService();
     services.ActionApprovedAll(selectedIds, status, userId);
     return Json("");
 }
예제 #3
0
        public string ProcessSendMailForFirstApprove(string host, Guid userId, Guid recordID)
        {
            DataErrorCode status = DataErrorCode.Success;
            using (var context = new VnrHrmDataContext())
            {
                var Services = new BaseService();

                string statusMess = string.Empty;
                string type = ApproveType.E_FIN_CashAdvance.ToString();
              //  string typeApprover1 = FinApproverType.FIN_Claim_Profile.ToString();
                //string typeApprover2 = FinApproverType.FIN_Claim_Manufacture.ToString();
                var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
                var repoSys_UserApprove = new CustomBaseRepository<Sys_UserApprove>(unitOfWork);
                var UserLogin = string.Empty;
                var repoSys_UserInfo = new CustomBaseRepository<Sys_UserInfo>(unitOfWork);
                var lstUserInfo = repoSys_UserInfo.GetAll().Where(s => s.IsDelete == null).ToList();
                var userInfoEntity = lstUserInfo.Where(s => userId == s.ID).FirstOrDefault();

                var repoCashItem = new CustomBaseRepository<FIN_ClaimItem>(unitOfWork);
                var totalItem = repoCashItem.GetAll().Where(s => s.IsDelete == null && s.ClaimID != null && s.ClaimID.Value == recordID ).Sum(s => s.Amount);

                var repo_JobTitle = new CustomBaseRepository<Cat_JobTitle>(unitOfWork);
                var lstJobTitle = repo_JobTitle.GetAll().Where(s => s.IsDelete == null).ToList();
                var repoOrg = new CustomBaseRepository<Cat_OrgStructure>(unitOfWork);
                var lstOrg = repoOrg.GetAll().Where(s => s.IsDelete == null).ToList();
                var repoProfile = new CustomBaseRepository<Hre_Profile>(unitOfWork);
                var lstProfile = repoProfile.GetAll().Where(s => s.IsDelete == null).ToList();

                var repoFIN_TravelRequest = new CustomBaseRepository<FIN_Claim>(unitOfWork);
                var record = repoFIN_TravelRequest.FindBy(s => s.ID == recordID).FirstOrDefault();

                if (record != null)
                {
                    List<Guid> lstIds = new List<Guid>();
                var claimServices = new FIN_ClaimItemService();

                lstIds.Add(record.ID);

                    claimServices.ActionApprovedAll(lstIds, "E_REQUEST", userId);
                }

                var repoFin_Approver = new CustomBaseRepository<FIN_ApproverECLAIM>(unitOfWork);
                var lstApprover = repoFin_Approver.GetAll().Where(s => s.IsDelete == null).ToList();

                var repoSys_TemplateSendMail = new CustomBaseRepository<Sys_TemplateSendMail>(unitOfWork);

                string _typeTemplate = EnumDropDown.EmailType.E_REQUEST_CLAIM.ToString();
                var template = repoSys_TemplateSendMail.FindBy(s => s.Type == _typeTemplate).FirstOrDefault();

                if (userInfoEntity != null)
                {
                    var profileInfoEntity = lstProfile.Where(s => s.ID == userInfoEntity.ProfileID.Value).FirstOrDefault();
                    var jobTitleEntity = lstJobTitle.Where(s => profileInfoEntity.JobTitleID != null && s.ID == profileInfoEntity.JobTitleID.Value).FirstOrDefault();
                    var orgEntity = lstOrg.Where(s => profileInfoEntity.OrgStructureID != null && s.ID == profileInfoEntity.OrgStructureID.Value).FirstOrDefault();
                    var lstApproverByClaim = lstApprover.Where(s => record.Type != null &&  s.ProfileID == userInfoEntity.ProfileID && s.ApprovedType == record.Type && s.ApprovedID != null).OrderBy(s => s.OrderNo).ToList();
                    var approvedEntity = new FIN_ApproverECLAIM();


                    var firstApprover = lstApproverByClaim.FirstOrDefault();
                    foreach (var item in lstApproverByClaim)
                    {
                        if(firstApprover.OrderNo == item.OrderNo)
                        {
                            continue;
                        }
                        approvedEntity = item;
                        break;
                    }
                    var userIdSecondApprover = lstApprover.Where(s => s.ID == approvedEntity.ID).FirstOrDefault();
                    if (firstApprover != null)
                    {
                        var userEnityByProfileID = lstUserInfo.Where(s => s.ID == firstApprover.ApprovedID.Value).FirstOrDefault();
                        var profileEntity = GetData<Hre_ProfileEntity>(Common.DotNetToOracle(userEnityByProfileID.ProfileID.ToString()), ConstantSql.hrm_hr_sp_get_ProfileById, UserLogin, ref statusMess).FirstOrDefault();
                        if (profileEntity != null)
                        {
                            if (userIdSecondApprover != null)
                            {
                                if (template != null)
                                {
                                    string MailTo = profileEntity.Email;

                                    string urlClickHere = host + "#Hrm_Main_Web/Fin_ApprovedClaim/DetailClaim/" + recordID + "#NewTab";

                                    string linkcontent = string.Empty;
                                    string linkcontentReject = string.Empty;


                                    var temp = lstUserInfo.Where(s => s.ID == userIdSecondApprover.ApprovedID.Value).FirstOrDefault();
                                    var name = temp.UserInfoName != null ? temp.UserInfoName : temp.UserLogin;

                                    linkcontent += "Nhấn vào " + "<a href='" + host + "Fin_ApprovedClaim/ProcessApprovedPage"
                                   + "?loginID=" + firstApprover.ApprovedID
                                   + "&userApprovedID=" + userIdSecondApprover.ID
                                   + "&recordID=" + recordID
                                   + "'>đây" + "<a/>" + " để đồng ý.";

                                    linkcontentReject += "Nhấn vào " +  "<a href='" + host + "Fin_ApprovedClaim/ProcessRejectPage"
                                    + "?loginID=" + firstApprover.ApprovedID
                                    + "&userApprovedID=" + userIdSecondApprover.ID
                                    + "&recordID=" + recordID
                                    + "'>đây" + "<a/>" + " để từ chối.";

                                    #region magreData

                                    string[] strsParaKey = null;
                                    string[] strsParaValues = null;
                                    strsParaKey = new string[] 
                                    { 
                                        EnumDropDown.EmailType_APPROVED_CLAIM.E_PROFILENAME.ToString(), 
                                        EnumDropDown.EmailType_APPROVED_CLAIM.E_JOBTITLE.ToString(), 
                                        EnumDropDown.EmailType_APPROVED_CLAIM.E_AREA.ToString(), 

                                        EnumDropDown.EmailType_APPROVED_CLAIM.E_USERINFONAME.ToString(), 
                                        EnumDropDown.EmailType_APPROVED_CLAIM.E_CLAIMNAME.ToString(), 
                                        EnumDropDown.EmailType_APPROVED_CLAIM.E_CLAIMCODE.ToString(), 
                                        EnumDropDown.EmailType_APPROVED_CLAIM.E_TOTALCLAIM.ToString(), 

                                        EnumDropDown.EmailType_APPROVED_CLAIM.E_DENIES.ToString(), 
                                        EnumDropDown.EmailType_APPROVED_CLAIM.E_LINKCONTENT.ToString(), 
                                        EnumDropDown.EmailType_APPROVED_CLAIM.E_REJECTLINK.ToString(), 

                                    };
                                    strsParaValues = new string[] 
                                    { 
                                        profileEntity.ProfileName, 
                                        jobTitleEntity != null ? jobTitleEntity.JobTitleName : string.Empty,
                                        orgEntity != null ? orgEntity.OrgStructureName : string.Empty,
                                        userInfoEntity.UserInfoName, 
                                        record.ClaimName, 
                                        record.ClaimCode,
                                        totalItem.ToString(),
                                        "",
                                         linkcontent ,
                                       linkcontentReject
                                    };
                                    string body = LibraryService.ReplaceContentFile(template.Content, strsParaKey, strsParaValues);

                                    #endregion

                                    string titleMail = template.Subject;
                                    bool isSuccess = Services.SendMail(titleMail, MailTo, body, string.Empty);
                                }
                            }


                        }
                    }

                }

                return status.ToString();
            }
        }