Exemplo n.º 1
0
        public void SendMailSchedule()
        {
            log.Info("SendMailSchedule start !!" + DateTime.Now);
            List <SYS_MESSAGE> lst         = getTask();
            EMailService       mailservice = new EMailService();

            foreach (SYS_MESSAGE m in lst)
            {
                using (var context = new TopmepEntities())
                {
                    try
                    {
                        log.Info("send msg=" + m.MSG_ID);
                        if (mailservice.SendMailByGmail(m.FROM_ADDRESS, m.DISPLAY_NAME, m.MAIL_LIST, m.BCC_MAIL_LIST, m.SUBJECT, m.MSG_BODY, null))
                        {
                            SYS_MESSAGE doneM = context.SYS_MESSAGE.Find(m.MSG_ID);
                            doneM.STATUS = "DONE";
                            context.SaveChanges();
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error(ex.Message + ":" + ex.StackTrace);
                    }
                }
                return;
            }
        }
Exemplo n.º 2
0
        public List <SYS_MESSAGE> ReadMsg(string MsgId)
        {
            SYS_MESSAGE msg = null;

            List <SYS_MESSAGE> result = null;

            using (ORMHandler orm = Zxl.Data.DatabaseManager.ORMHandler)
            {
                msg       = orm.Init <SYS_MESSAGE>("where ID=" + MsgId);
                msg.STATE = 1;
                orm.Save(msg);

                result = GetNoReadMsgs(msg.RECVUSERID + "");
            }
            return(result);
        }
Exemplo n.º 3
0
        public void createPOMessage(SYS_USER u, PLAN_PURCHASE_REQUISITION pr)
        {
            //mail to 業管
            // System.Web.Script.Serialization.JavaScriptSerializer objSerializer = new System.Web.Script.Serialization.JavaScriptSerializer();
            //  string userJson = objSerializer.Serialize(u);
            // log.Debug("sender :" + userJson);

            //定義Email 樣板
            StringBuilder strTemp     = new StringBuilder("{1} 申購單已完成採購!!");
            StringBuilder strTempBody = new StringBuilder("{1} 申購單已完成採購{2}。 <br/> 系統發出,請勿回覆!!");
            //
            SYS_MESSAGE m = new SYS_MESSAGE();

            m.FROM_ADDRESS = u.EMAIL;
            m.DISPLAY_NAME = u.USER_NAME;
            UserService s = new UserService();
            //TODO:加入通知申請人
            List <SYS_USER> lstTarget = s.getProjectUser(pr.PROJECT_ID, "工地主任");

            strTemp.Replace("{1}", pr.PROJECT_ID);

            m.MAIL_LIST = getMailList(lstTarget);
            if (m.MAIL_LIST == "")
            {
                log.Error(pr.PR_ID + " Have no mail list!!");
                return;
            }
            m.SUBJECT = strTemp.ToString();

            strTempBody.Replace("{1}", pr.PROJECT_ID);
            strTempBody.Replace("{2}", "採購單號為:<a href='" + system_url + "'>" + pr.PR_ID + "</a>");
            m.MSG_BODY = strTempBody.ToString();
            log.Debug("email body:" + m.MSG_BODY);
            m.CREATE_ID   = u.USER_ID;
            m.CREATE_DATE = DateTime.Now;
            //決定發送時間
            m.SEND_TIME = DateTime.Now;
            int i = 0;

            using (var context = new topmepEntities())
            {
                context.SYS_MESSAGE.Add(m);
                i = context.SaveChanges();
            }
        }