示例#1
0
        public ActionResult SubmitForm(LeaveEntity leaveEntity, string keyValue)
        {
            string[] Ids = keyValue.Split(',');
            foreach (var Id in Ids)
            {
                var leave = leaveApp.GetForm(Id);
                if (leave.F_IsCheck == null && leave.F_LeaveStatus == (int)LeaveStatusEnum.UnChecked)//未审核
                {
                    leave.F_IsCheck      = leaveEntity.F_IsCheck != null ? leaveEntity.F_IsCheck : null;
                    leave.F_CheckOpinion = leaveEntity.F_CheckOpinion != "" ? leaveEntity.F_CheckOpinion : "";
                    if (leave.F_IsCheck.HasValue && leave.F_IsCheck == true)
                    {
                        leave.F_LeaveStatus = (int)LeaveStatusEnum.UnApproved;      //状态改为未批准
                        if (leave.F_CheckLeaderId.Equals(leave.F_ApprovalLeaderId)) //审核人和批准人一样
                        {
                            leave.F_IsApproval   = true;
                            leave.F_LeaveStatus  = (int)LeaveStatusEnum.Success;//状态改为审批通过
                            leave.F_ApprovalTime = DateTime.Now;
                        }
                        else
                        {
                            var ApprovalLeader = userApp.GetForm(leave.F_ApprovalLeaderId);
                            var user           = userApp.GetForm(leave.F_UserId);
                            if (!string.IsNullOrEmpty(ApprovalLeader.F_Email))
                            {
                                mHelper.MailServer = "10.110.120.2";
                                mHelper.Send(ApprovalLeader.F_Email, "OA请假单", "你好," + user.F_RealName + "有请假单需要你登录OA去做批准,请点击链接<a>http://10.110.120.6:8090/</a>");
                            }
                        }
                    }
                    else
                    {
                        leave.F_LeaveStatus  = (int)LeaveStatusEnum.Fail;//状态改为审核失败
                        leave.F_ApprovalTime = DateTime.Now;
                    }
                }
                else
                {
                    if (leave.F_IsApproval == null && leave.F_LeaveStatus == (int)LeaveStatusEnum.UnApproved)//未批准
                    {
                        leave.F_IsApproval      = leaveEntity.F_IsApproval != null ? leaveEntity.F_IsApproval : null;
                        leave.F_ApprovalOpinion = leaveEntity.F_ApprovalOpinion != "" ? leaveEntity.F_ApprovalOpinion : "";
                        if (leave.F_IsApproval.HasValue && leave.F_IsApproval == true)
                        {
                            leave.F_LeaveStatus  = (int)LeaveStatusEnum.Success;//状态改为审核通过
                            leave.F_ApprovalTime = DateTime.Now;
                        }
                        else
                        {
                            leave.F_LeaveStatus  = (int)LeaveStatusEnum.Fail;//状态改为审核通过
                            leave.F_ApprovalTime = DateTime.Now;
                        }
                    }
                }

                leaveApp.SubmitForm(leave, Id);
            }
            return(Success("操作成功。"));
        }
        public ActionResult SubmitForm(LeaveEntity leaveEntity, string keyValue)
        {
            if (Request.Files.Count > 0)
            {
                var file = Request.Files[0];
                if (!string.IsNullOrEmpty(file.FileName))
                {
                    Guid FileID   = Guid.NewGuid();
                    var  fileName = file.FileName;
                    foreach (char invalidChar in Path.GetInvalidFileNameChars())
                    {
                        fileName = fileName.Replace(invalidChar.ToString(), "_");
                    }
                    fileName = fileName.Replace(" ", "");
                    var filePath = Path.Combine(HttpContext.Server.MapPath("/Uploads/"), fileName);
                    file.SaveAs(filePath);
                    leaveEntity.F_FileId     = FileID;
                    leaveEntity.F_FileName   = file.FileName;
                    leaveEntity.F_SuffixName = Path.GetExtension(file.FileName);
                }
            }
            var man = userApp.GetForm(leaveEntity.F_UserId);

            leaveEntity.F_UserName = man.F_RealName;
            leaveEntity.F_Account  = man.F_Account;
            leaveEntity.F_Sex      = man.F_Gender != null ? (man.F_Gender == true ? "男" : "女") : null;
            var depart = organizeApp.GetForm(man.F_DepartmentId);
            var duty   = roleApp.GetForm(man.F_DutyId);

            leaveEntity.F_Department = depart.F_FullName;
            leaveEntity.F_Duty       = duty.F_FullName;
            var checkUser    = userApp.GetForm(leaveEntity.F_CheckLeaderId);
            var approvalUser = userApp.GetForm(leaveEntity.F_ApprovalLeaderId);

            leaveEntity.F_CheckUserName    = checkUser.F_RealName;
            leaveEntity.F_ApprovalUserName = approvalUser.F_RealName;
            leaveApp.SubmitForm(leaveEntity, keyValue);
            if (!string.IsNullOrEmpty(checkUser.F_Email))
            {
                mHelper.MailServer = "10.110.120.2";
                mHelper.Send(checkUser.F_Email, "OA请假单", "你好," + man.F_RealName + "有请假单需要你登录OA去做审核,请点击链接<a>http://10.110.120.6:8090/</a>");
            }
            return(Success("操作成功。"));
        }