Beispiel #1
0
        /// <summary>
        /// 自定义错误日志
        /// </summary>
        /// <param name="Type"></param>
        /// <param name="value"></param>
        public void AddMyErrorLog(string Type, string value)
        {
            Sys_Error_log ErrorLog = new Sys_Error_log();

            ErrorLog.ErrType = Type;
            ErrorLog.ErrMsg  = value;
            ErrorLog.Date    = DateTime.Now;
            new Sys_Error_logService().Insert(ErrorLog);
        }
Beispiel #2
0
        public void AddErrorLog(string Type, string Context)
        {
            Sys_Error_log Mod = new Sys_Error_log();

            Mod.ErrType = Type;
            Mod.ErrMsg  = Context;
            Mod.Date    = DateTime.Now;
            new Sys_Error_logService().Insert(Mod);
        }
        /// <summary>
        ///填写一条报错数据
        /// </summary>
        /// <param name="Type"></param>
        /// <param name="Context"></param>
        public static void AddErrorlog(string Type, string Context)
        {
            Sys_Error_logService LogService = new Sys_Error_logService();
            Sys_Error_log        ErrLog     = new Sys_Error_log();

            ErrLog.ErrType = Type;
            ErrLog.ErrMsg  = Context;
            ErrLog.Date    = DateTime.Now;
            LogService.Insert(ErrLog);
        }
Beispiel #4
0
        public static void Send(string server, string sender, string recipient, string subject,
                                string body, bool isBodyHtml, Encoding encoding, bool isAuthentication, params string[] files)
        {
            try
            {
                SmtpClient smtpClient = new SmtpClient(server);
                smtpClient.UseDefaultCredentials = true;
                MailMessage message = new MailMessage(sender, recipient);
                message.IsBodyHtml      = isBodyHtml;
                message.SubjectEncoding = encoding;
                message.BodyEncoding    = encoding;
                message.Subject         = subject;
                message.Body            = body;
                message.IsBodyHtml      = true;
                message.Attachments.Clear();
                if (files != null && files.Length != 0)
                {
                    for (int i = 0; i < files.Length; ++i)
                    {
                        Attachment attach = new Attachment(files[i]);
                        message.Attachments.Add(attach);
                    }
                }

                if (isAuthentication == true)
                {
                    smtpClient.Credentials = new NetworkCredential(SmtpConfig.Create().SmtpSetting.User, SmtpConfig.Create().SmtpSetting.Password);
                }
                //smtpClient.EnableSsl = true;

                //smtpClient.Timeout = 5;
                smtpClient.Send(message);
            }
            catch (Exception e)
            {
                Sys_Error_logService LogService = new Sys_Error_logService();
                Sys_Error_log        Errmod     = new Sys_Error_log();
                Errmod.Date    = DateTime.Now;
                Errmod.ErrMsg  = e.Message;
                Errmod.ErrType = "发送邮件";
                LogService.Insert(Errmod);
            }
        }