private void ApplyEmailSend(MyApplyDto apply, string recheckUserId)
        {
            try
            {
                MasterService mstService       = new MasterService();
                UserInfoDto   userinfo_Apply   = mstService.UserInfoSearchByUserId(apply.ApplyUserId).FirstOrDefault();
                UserInfoDto   userinfo_Recheck = mstService.UserInfoSearchByUserId(recheckUserId).FirstOrDefault();
                string[]      mailTo           = null;
                if (userinfo_Recheck == null)
                {
                }
                else
                {
                    mailTo = userinfo_Recheck.Email.Split(',');
                }
                string[] mailCC  = null;
                string   subject = userinfo_Apply.UserName + "的" + apply.ApplyTypeId + "申请";
                string   content = "您好,以下是" + userinfo_Apply.UserName + "的申请,请及时在系统进行处理" + "<br>";
                content += "申请Id:" + apply.ApplyId.ToString() + "<br>";
                content += "申请人:" + userinfo_Apply.UserName + "<br>";
                content += "申请类型:" + apply.ApplyTypeId + "<br>";
                content += "申请理由:" + apply.ApplyReason + "<br>";
                content += "项目全称:" + apply.ProjectName + "<br>";
                content += "项目简称:" + apply.ProjectShortName + "<br>";
                content += "供应商全称:" + apply.SupplierName + "<br>";

                List <string> attachPaths = new List <string>();

                //个人签名 图片形式
                string sign = "";
                if (!string.IsNullOrEmpty(userinfo_Apply.EmailFooter))
                {
                    string emailSignFile = Server.MapPath("~/EmailSign/" + userinfo_Apply.EmailFooter);
                    sign = emailSignFile;
                }
                //准备发送邮件对象
                ISendMail sendMail = new UseNetMail();
                sendMail.CreateHost(new ConfigHost()
                {
                    EnableSsl = false,
                    Username  = userinfo_Apply.Email,
                    Password  = userinfo_Apply.EmailPassword,
                });
                sendMail.CreateMultiMail(new ConfigMail()
                {
                    From        = userinfo_Apply.Email,
                    To          = mailTo,
                    CC          = mailCC,
                    Subject     = subject,
                    Body        = content,
                    Resources   = sign.Split(','),
                    Attachments = attachPaths.ToArray()
                });

                sendMail.SendMail();
            }
            catch (Exception)
            {
            }
        }
Ejemplo n.º 2
0
        public ActionResult ApplyCommit(string recheckUserId, Apply apply, string projectId, string applyIdexists, string seqNO, string attachArray)
        {
            ApplyService applayService = new ApplyService();

            apply.InDateTime  = DateTime.Now;
            apply.ApplyUserId = UserInfo.UserId;
            apply.ApplyTypeId = ApplyType.立项.ToString();
            apply.ProjectId   = Convert.ToInt32(projectId);
            int applyId = 0;

            if (Convert.ToInt32(applyIdexists) == 0)
            {
                applyId = applayService.ApplyCommit(apply, recheckUserId);
            }
            else
            {
                ApplyRecheckStatus status = new ApplyRecheckStatus();
                status.ApplyId           = Convert.ToInt32(applyIdexists);
                status.RecheckUserId     = ((Mst_UserInfo)Session["LoginUser"]).UserId;
                status.RecheckStatusCode = "申请";
                status.RecheckReason     = apply.ApplyReason == null ? "" : apply.ApplyReason;
                status.SeqNO             = Convert.ToInt32(seqNO);
                status.InDateTime        = DateTime.Now;
                applayService.ApplyRecheckStatusUpdate(status, recheckUserId);
                applyId = Convert.ToInt32(applyIdexists);
            }
            MyApplyDto applyInfo = applayService.ApplySearchById(applyId.ToString()).FirstOrDefault();

            ApplyEmailSend(applyInfo, recheckUserId);

            //保存附件
            List <string> attachList = JsonConvert.DeserializeObject <List <string> >(attachArray);
            int           fileSeqNO  = 1;

            attachList.ForEach((string attach) =>
            {
                db.ApplyFile.Add(new ApplyFile()
                {
                    ApplyId    = applyId,
                    FileName   = attach,
                    InDateTime = DateTime.Now,
                    InUserId   = UserInfo.UserId,
                    SeqNO      = fileSeqNO++
                });
            });
            db.SaveChanges();

            return(Json(applyId, JsonRequestBehavior.AllowGet));
        }
        public ActionResult RecheckCommit(ApplyRecheckStatus applyStatus, string nextRecheckUserId)
        {
            ApplyService applayService = new ApplyService();
            // 查询当前提交审核的申请,审核人的审核信息
            RecheckStatusDtlDto recheckStatus = applayService.RecheckDtlSearch(applyStatus.ApplyId.ToString()).Where(x => x.SeqNO == applyStatus.SeqNO.ToString()).FirstOrDefault();

            // 只有当审核人还没有审核的时候执行下面的操作,如果审核人已经审核过的话,不需要再执行
            //正常情况下不会出现这样的数据,为了解决特定网络情况下导致的重复数据,所以添加了这个判断
            if (string.IsNullOrEmpty(recheckStatus.RecheckStatusCode))
            {
                MyApplyDto applyInfo = applayService.ApplySearchById(applyStatus.ApplyId.ToString()).FirstOrDefault();
                if (applyStatus.RecheckStatusCode == "拒绝")
                {
                    nextRecheckUserId = applayService.PreRecheckUserSearch(applyStatus.ApplyId.ToString(), UserInfo.UserId);
                }
                applyStatus.RecheckUserId = UserInfo.UserId;
                applyStatus.InDateTime    = DateTime.Now;
                if (nextRecheckUserId == null)
                {
                    nextRecheckUserId = "";
                }
                applayService.ApplyRecheckStatusUpdate(applyStatus, nextRecheckUserId);
                if (applyStatus.RecheckStatusCode == "拒绝")
                {
                    ApplyEmailSend(applyInfo, nextRecheckUserId, "拒绝");
                }
                else
                {
                    ApplyEmailSend(applyInfo, nextRecheckUserId, "");
                }
                // 状态更新后再查询一遍,如果是完成的话则发送邮件给申请人,邮件通知已经审核完成
                MyApplyDto afterUpdate = applayService.ApplySearchById(applyStatus.ApplyId.ToString()).FirstOrDefault();
                if (afterUpdate.ApplyStatusCode == "完成")
                {
                    ApplyEmailSend(applyInfo, nextRecheckUserId, "完成");
                }
            }

            return(Json(""));
        }
        public ActionResult RecheckListCommit(string applyStatusList, string recheckReason, string nextRecheckUserId)
        {
            ApplyService applayService = new ApplyService();

            string[] applyList = new string[] { };
            if (applyStatusList.Length > 0)
            {
                applyList = applyStatusList.Split(';');
            }
            foreach (string item in applyList)
            {
                // 查询当前提交审核的申请,审核人的审核信息
                RecheckStatusDtlDto recheckStatus = applayService.RecheckDtlSearch(item.Split(',')[0].ToString()).Where(x => x.SeqNO == item.Split(',')[1].ToString()).FirstOrDefault();
                // 只有当审核人还没有审核的时候执行下面的操作,如果审核人已经审核过的话,不需要再执行
                //正常情况下不会出现这样的数据,为了解决特定网络情况下导致的重复数据,所以添加了这个判断
                if (string.IsNullOrEmpty(recheckStatus.RecheckStatusCode))
                {
                    ApplyRecheckStatus applyStatus = new ApplyRecheckStatus();
                    applyStatus.RecheckUserId     = UserInfo.UserId;
                    applyStatus.InDateTime        = DateTime.Now;
                    applyStatus.ApplyId           = Convert.ToInt32(item.Split(',')[0]);
                    applyStatus.SeqNO             = Convert.ToInt32(item.Split(',')[1]);
                    applyStatus.RecheckStatusCode = "同意";
                    applyStatus.RecheckReason     = recheckReason;
                    applayService.ApplyRecheckStatusUpdate(applyStatus, nextRecheckUserId);
                    MyApplyDto applyInfo = applayService.ApplySearchById(applyStatus.ApplyId.ToString()).FirstOrDefault();
                    ApplyEmailSend(applyInfo, nextRecheckUserId, "");
                    // 状态更新后再查询一遍,如果是完成的话则发送邮件给申请人,邮件通知已经审核完成
                    MyApplyDto afterUpdate = applayService.ApplySearchById(applyStatus.ApplyId.ToString()).FirstOrDefault();
                    if (afterUpdate.ApplyStatusCode == "完成")
                    {
                        ApplyEmailSend(applyInfo, nextRecheckUserId, "完成");
                    }
                }
            }
            return(Json(""));
        }
Ejemplo n.º 5
0
        public ActionResult ApplyCommit(string recheckUserId, Apply apply, string projectId, string groupId, string applyIdexists, string seqNO, string attachArray)
        {
            ApplyService applayService = new ApplyService();

            apply.InDateTime  = DateTime.Now;
            apply.ApplyUserId = UserInfo.UserId;
            apply.ApplyTypeId = ApplyType.结算单.ToString();
            apply.ProjectId   = Convert.ToInt32(groupId);// 结算单申请时ProjectId 保存为groupId
            int applyId = 0;

            if (Convert.ToInt32(applyIdexists) == 0)
            {
                applyId = applayService.ApplyCommit(apply, recheckUserId);
            }
            else
            {
                applyId = Convert.ToInt32(applyIdexists);
                ApplyRecheckStatus status = new ApplyRecheckStatus();
                status.ApplyId           = Convert.ToInt32(applyIdexists);
                status.RecheckUserId     = ((Mst_UserInfo)Session["LoginUser"]).UserId;
                status.RecheckStatusCode = "申请";
                status.RecheckReason     = apply.ApplyReason == null ? "" : apply.ApplyReason;
                status.SeqNO             = Convert.ToInt32(seqNO);
                status.InDateTime        = DateTime.Now;
                applayService.ApplyRecheckStatusUpdate(status, recheckUserId);
            }
            applayService.ApplyDtlDelete(new ApplyDtl {
                ApplyId = applyId, ApplyTypeId = "结算单"
            });
            List <SettlementGroupDtlDto> list = service.SettlementMstSearchByGroupId(projectId, groupId.ToString()).Where(x => x.SelectedChk == true).ToList();

            foreach (SettlementGroupDtlDto item in list)
            {
                ApplyDtl applyDtl = new ApplyDtl()
                {
                    ApplyId        = applyId,
                    ApplyContentId = Convert.ToInt32(item.SettlementId),
                    ApplyTypeId    = ApplyType.结算单.ToString(),
                    InDateTime     = DateTime.Now,
                    InUserId       = UserInfo.UserId
                };
                // applayService.ApplyDtlSave(applyDtl);
                applyService.ApplyDtlSave_Settlement(applyDtl);
            }
            MyApplyDto applyInfo = applayService.ApplySearchById(applyId.ToString()).FirstOrDefault();

            ApplyEmailSend(applyInfo, recheckUserId);

            //保存附件
            List <string> attachList = JsonConvert.DeserializeObject <List <string> >(attachArray);
            int           fileSeqNO  = 1;

            attachList.ForEach((string attach) =>
            {
                db.ApplyFile.Add(new ApplyFile()
                {
                    ApplyId    = applyId,
                    FileName   = attach,
                    InDateTime = DateTime.Now,
                    InUserId   = UserInfo.UserId,
                    SeqNO      = fileSeqNO++
                });
            });
            db.SaveChanges();

            return(Json(applyId, JsonRequestBehavior.AllowGet));
        }