Ejemplo n.º 1
0
        /// <summary>
        /// 使用系统邮件模块配置的信息,异步发送邮件(信息配置错误可能导致VS报错)
        /// </summary>
        public static MailState Send(MailInfo mailInfo)
        {
            MailConfig  cfg    = SiteConfig.MailConfig;
            SendHandler sender = null;

            if (cfg.Port == 25)
            {
                sender = SendEmail;
            }
            else if (cfg.Port == 465)
            {
                sender = SendSSLEmail;
            }
            else
            {
                throw new Exception("邮件端口[" + cfg.Port + "]配置不正确");
            }
            if (string.IsNullOrEmpty(cfg.MailServerUserName))
            {
                throw new Exception("未配置发送邮箱,取消发送");
            }
            if (string.IsNullOrEmpty(cfg.MailServerPassWord))
            {
                throw new Exception("未配置发送邮箱密码,取消发送");
            }
            sender.BeginInvoke(cfg.MailServerUserName, cfg.MailServerPassWord, cfg.MailServer, mailInfo, "".Split(','), SendCallBack, null);
            return(MailState.Ok);
        }
Ejemplo n.º 2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (ddlProjects.SelectedValue == "")
            {
                ShowFailMessageToClient("Please select project.");
                return;
            }
            if (txtName.Text.Trim() == string.Empty)
            {
                ShowFailMessageToClient("Please enter title.");
                return;
            }
            EventsView eventModel = ConstructEventsView();
            List <EventInviteEntity> inviteList = BuilderInvite(eventModel);
            List <EventEntity>       eventList;

            //当开始日期和结束日期不是同一天且Repeat为None时,需要处理成Repeat为Every Day、且End为On date,EndDate为选择的结束日期
            if (eventModel.ToDay.Date > eventModel.FromDay.Date && eventModel.Repeat == RepeatType.None)
            {
                eventModel.Repeat  = RepeatType.Every_Day;
                eventModel.End     = EndType.on_date;
                eventModel.EndDate = eventModel.ToDay;
            }
            if (new EventsApplication().AddEvents(eventModel, inviteList, out eventList))
            {
                SendHandler handler = new SendHandler(SendEamil);
                handler.BeginInvoke(inviteList, eventList, null, null);
                SendEmail();
                Redirect(Request.RawUrl, false, true);
            }
            else
            {
                ShowFailMessageToClient("Add event Fail.");
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// save : 1:save ; 2:draft ;3 save and new
        /// </summary>
        /// <param name="save"></param>
        private void SaveTicket(int save)
        {
            ProjectsEntity projectsEntity = new ProjectApplication().Get(int.Parse(ddlProject.SelectedValue));

            //判断当前日期是否大于Project的End Date
            if (!projectApplication.CheckIfEstimated(projectsEntity))
            {
                ShowMessageToClient("This project is closed, if you need to submit new tickets for this project, please contact us at [email protected].",
                                    2, false, false);
                return;
            }

            TicketsEntity ticketsEntity = GetEntity(save, projectsEntity.ProjectID, projectsEntity.CompanyID);

            int result = new TicketsApplication().AddTickets(ticketsEntity);

            if (result > 0)
            {
                AddTicketUsers(projectsEntity, ticketsEntity, result);
                AddIniHistroy(ticketsEntity);

                if (!ticketsEntity.IsInternal)
                {
                    SendHandler handler = new SendHandler(SendEamil);
                    handler.BeginInvoke(ticketsEntity, UserInfo, null, null);
                }

                string fileName = hidUploadFile.Value;

                if (fileName.Trim() != string.Empty)
                {
                    string[] files = fileName.Split('|');
                    foreach (string str in files)
                    {
                        InsertFile(str, ticketsEntity.ProjectID, result, ticketsEntity.CompanyID);
                    }
                }

                switch (save)
                {
                case 1:
                    Redirect("/Ticket/Ongoing.aspx", true);
                    break;

                case 2:
                    Redirect("/Ticket/Draft.aspx", true);
                    break;

                case 3:
                    // ShowSuccessMessageToClient("The ticket has been added.", false, false);
                    Redirect("/Ticket/New.aspx?project=" + ddlProject.SelectedValue, true);
                    break;
                }
            }
            else
            {
                ShowFailMessageToClient();
            }
        }
Ejemplo n.º 4
0
        public static void SendWebHttpRequestFullAsync(String url, String verb, String requestJson, AsyncCallback callBack)
        {
            WebRequest wr = WebRequest.Create(url);

            wr.ContentType = "text/plain";
            wr.Method      = verb;
            wr.Timeout     = 10000;
            SendHandler handler = new SendHandler(SendRequest);

            handler.BeginInvoke(wr, requestJson, callBack, wr);
        }
Ejemplo n.º 5
0
        protected void btn_Click(object sender, EventArgs e)
        {
            SendHandler handler = new SendHandler(SendEamil);

            handler.BeginInvoke(null, null);
            Response.Redirect("/SunnetTicket/MyTicket.aspx");

            Izl zl = new B();

            zl.start();
            Ipb pb = zl as Ipb;

            pb.jasu();
        }
Ejemplo n.º 6
0
        public IAsyncResult BeginSend(string subject, string body, string from, List <string> attachmentList, List <string> toList, List <string> ccList, List <string> bccList)
        {
            SendHandler  handler     = new SendHandler(Send);
            IAsyncResult asyncResult = null;

            try
            {
                asyncResult = handler.BeginInvoke(subject, body, from, attachmentList, toList, ccList, bccList, EndSend, handler);
            }
            catch (Exception exception)
            {
                logger.Error("Mail Send Exception:", exception);
            }
            return(asyncResult);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 异步发送邮件,并将发送记录备份
        /// </summary>
        /// <param name="model">邮件信息模型</param>
        /// <param name="dataDT">不为空则对每个模板格式化后再发送</param>
        public static void SendAsync(M_EMail_Item model)
        {
            B_EMail_Item itemBll = new B_EMail_Item();
            MailConfig   cfg     = SiteConfig.MailConfig;
            SendHandler  sender  = null;

            try
            {
                if (string.IsNullOrEmpty(model.FromEmail))
                {
                    model.FromEmail = cfg.MailServerUserName;
                }
                if (string.IsNullOrEmpty(model.FromName))
                {
                    model.FromName = SiteConfig.SiteInfo.Webmaster;
                }
                if (cfg.Port == 25)
                {
                    sender = SendEmail;
                }
                else if (cfg.Port == 465)
                {
                    sender = SendSSLEmail;
                }
                else
                {
                    throw new Exception("邮件端口[" + cfg.Port + "]配置不正确");
                }
                if (string.IsNullOrEmpty(cfg.MailServerUserName))
                {
                    throw new Exception("未配置发送邮箱,取消发送");
                }
                if (string.IsNullOrEmpty(cfg.MailServerPassWord))
                {
                    throw new Exception("未配置发送邮箱密码,取消发送");
                }
                model.Result = 1; model.Error = "";
            }
            catch (Exception ex) { model.Result = -1; model.Error = ex.Message; return; }
            model.ID = itemBll.Insert(model);
            //----------------发送邮件(单个发送)
            string[] emails   = model.ToAddress.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
            string   mailBody = model.MailBody;

            for (int i = 0; i < emails.Length; i++)
            {
                M_EMail_Item mailMod = new M_EMail_Item()
                {
                    ID         = model.ID,
                    ToAddress  = emails[i],
                    Subject    = model.Subject,
                    MailBody   = mailBody,
                    FromName   = model.FromName,
                    FromEmail  = model.FromEmail,
                    Attachment = model.Attachment
                };
                //如果不需要每次循环时编译,应该在上层处理好再传入
                if (mailMod.C_NeedTranslate)
                {
                    DataRow dr = null;
                    if (model.C_DataDT != null && model.C_DataDT.Rows.Count > i)
                    {
                        dr = model.C_DataDT.Rows[i];
                    }
                    mailMod.MailBody = TlpDeal(mailBody, dr);
                }
                sender.BeginInvoke(cfg.MailServerUserName, cfg.MailServerPassWord, cfg.MailServer
                                   , mailMod, SendCallBack, null);
            }
        }
Ejemplo n.º 8
0
 public static void SendWebHttpRequestFullAsync(String url, String verb, String requestJson, AsyncCallback callBack)
 {
     WebRequest wr = WebRequest.Create(url);
     wr.ContentType = "text/plain";
     wr.Method = verb;
     wr.Timeout = 10000;
     SendHandler handler = new SendHandler(SendRequest);
     handler.BeginInvoke(wr, requestJson, callBack, wr);
 }