Пример #1
0
        public static bool Write(string logContent, string classUrl, string funcName)
        {
            StringBuilder stringBuilder = new StringBuilder();

            if (!string.IsNullOrEmpty(classUrl))
            {
                stringBuilder.Append(classUrl);
            }
            if (!string.IsNullOrEmpty(funcName))
            {
                stringBuilder.Append("/");
                stringBuilder.Append(funcName);
            }
            if (!string.IsNullOrEmpty(logContent))
            {
                if (TextLogger.WRITE_APP_LOG)
                {
                    stringBuilder.Append("<br />");
                }
                else
                {
                    stringBuilder.Append("\r\n\t");
                }
                stringBuilder.Append(logContent);
            }
            return(TextLogger.Write(stringBuilder.ToString(), "AppDebug"));
        }
Пример #2
0
        public static bool DeleteFile(string path)
        {
            bool result = false;

            try
            {
                new FileInfo(path).Delete();
                result = true;
            }
            catch (Exception ex)
            {
                TextLogger.Write(ex.ToString());
            }
            return(result);
        }
Пример #3
0
        public bool Send()
        {
            MailMessage message             = new MailMessage();
            Encoding    displayNameEncoding = Encoding.GetEncoding("utf-8");

            message.From = new MailAddress(this.From, this.Subject, displayNameEncoding);
            message.To.Add(this.m_recipient);
            message.Subject      = this.Subject;
            message.IsBodyHtml   = true;
            message.Body         = this.Body;
            message.Priority     = MailPriority.Normal;
            message.BodyEncoding = Encoding.GetEncoding("utf-8");
            SmtpClient client = new SmtpClient {
                Host        = this.MailDomain,
                Port        = this.MailDomainPort,
                Credentials = new NetworkCredential(this.MailServerUserName, this.MailServerPassWord)
            };

            if (this.MailDomainPort != 0x19)
            {
                client.EnableSsl = true;
            }
            try
            {
                if (this.IsAsync)
                {
                    string userToken = "userToken";
                    client.SendAsync(message, userToken);
                }
                else
                {
                    client.Send(message);
                    message.Dispose();
                }
            }
            catch (SmtpException exception)
            {
                string str2 = exception.Message;
                TextLogger.Write(exception.ToString());
                return(false);
            }
            return(true);
        }
Пример #4
0
 public static bool Write(Type cType, string funcName, string text)
 {
     return(TextLogger.Write(cType.Namespace + cType.Name, funcName, text));
 }
Пример #5
0
 public static bool Write(string logContent)
 {
     return(TextLogger.Write(logContent, "AppError"));
 }