/// <summary> /// 全屏点赞 /// </summary> public void Praise() { QqProvider.Instance.UpdateRunStatus(Id, RunStatus.Init); if (RunStatus != RunStatus.Sucess && CodeStatus != CodeStatus.NotNeedCode) { Check(); } else { try { _miniBrowser.DownloadString(IndexPage, Praise); } catch (Exception ex) { RunStatus = RunStatus.Fail; QqProvider.Instance.UpdateRunStatus(Id, RunStatus.Fail); CodeStatus = CodeStatus.NeedCode; QqProvider.Instance.UpdateCodeStatus(Id, CodeStatus.NeedCode); Log4Logger.Error(UserName + " Login失败!\r\n" + ex.Message, ex); MailLogger.LogError(UserName + " Login失败!\r\n" + ex.Message, ex); QqMsgLogger.LogError(UserName + " Login失败!", ex); } } }
public Tekla(INotifyProgress notify) { logger = LogManager.GetCurrentClassLogger(); maillogger = new MailLogger(); request = new Request(); this.notify = notify; }
///<summary>This method creates an instance of the MailLogger class.</summary> ///<returns>Returns an instance of the MailLogger class.</returns> public static MailLogger GetMailLogger() { MailLogger log; try { MailSettings settings = _Config.MailSettings; if (settings != null) { Sender sender = settings.Sender; Receiver receiver = settings.Receiver; if (sender != null && receiver != null) { log = new MailLogger(settings); } else { throw new Exception("The parameters for sending emails were not found."); } } else { throw new Exception("Invalid scheme -> MailSettings not found."); } } catch (Exception e) { throw new Exception(e.Message); } return(log); }
public Server() { logger = LogManager.GetCurrentClassLogger(); maillogger = new MailLogger(); }
private MailLogger ReadMailLoggerSection(XmlNode xmlNode) { MailLogger logger = new MailLogger(); //Read optional enabled attribute XmlAttribute attribute = xmlNode.Attributes["enabled"]; logger.Enabled = attribute == null ? true : Boolean.Parse(attribute.Value); //Read server section XmlNode innerNode = xmlNode.SelectSingleNode("./server"); if (innerNode == null) { throw new ArgumentNullException("server", "mailLogger is not configuried!"); } //Read host attribute attribute = innerNode.Attributes["host"]; if (attribute == null) { throw new ArgumentNullException("host", "mailLogger is not configuried!"); } logger.ServerName = attribute.Value; //Read port attribute attribute = innerNode.Attributes["port"]; logger.Port = attribute == null ? 25 : Int32.Parse(attribute.Value); //Read optional userName attribute attribute = innerNode.Attributes["userName"]; if (attribute != null) { logger.UserName = attribute.Value; } //Read optional password attribute attribute = innerNode.Attributes["password"]; if (attribute != null) { logger.Password = attribute.Value; } //Read optional useSSL attribute attribute = innerNode.Attributes["useSSL"]; if (attribute != null) { logger.UseSSL = Boolean.Parse(attribute.Value); } //Read message section innerNode = xmlNode.SelectSingleNode("./message"); if (innerNode == null) { throw new ArgumentNullException("message", "mailLogger is not configuried!"); } //Read from attribute attribute = innerNode.Attributes["from"]; if (attribute == null) { throw new ArgumentNullException("from", "mailLogger is not configuried!"); } //Read senderName attribute XmlAttribute senderNameAttribute = innerNode.Attributes["senderName"]; logger.From = senderNameAttribute != null ? new MailAddress(attribute.Value, senderNameAttribute.Value) : new MailAddress(attribute.Value); //Read header attribute attribute = innerNode.Attributes["header"]; if (attribute == null) { throw new ArgumentNullException("header", "mailLogger is not configuried!"); } logger.Subject = attribute.Value; //Read optional subjectEncoding attribute attribute = innerNode.Attributes["subjectEncoding"]; logger.SubjectEncoding = attribute == null ? Encoding.UTF8 : Encoding.GetEncoding(attribute.Value); //Read optional bodyEncoding attribute attribute = innerNode.Attributes["bodyEncoding"]; logger.BodyEncoding = attribute == null ? Encoding.UTF8 : Encoding.GetEncoding(attribute.Value); //Read optional isBodyHtml attribute attribute = innerNode.Attributes["isBodyHtml"]; if (attribute != null) { logger.IsBodyHtml = Boolean.Parse(attribute.Value); } //Read TO section innerNode = xmlNode.SelectSingleNode("./to"); if (innerNode == null) { throw new ArgumentNullException("to", "mailLogger is not configuried!"); } logger.To = ReadMailAddressesSection(innerNode); //Read CC section innerNode = xmlNode.SelectSingleNode("./cc"); logger.CC = innerNode == null ? new MailAddressCollection() : ReadMailAddressesSection(innerNode); return(logger); }
public object Create(object parent, object configContext, XmlNode section) { IList <ILogger> _loggers = new List <ILogger>(); //If section stores in another file. XmlAttribute configPath = section.Attributes["configPath"]; XmlAttribute sectionPath = section.Attributes["sectionPath"]; if (configPath != null && sectionPath != null) { XmlDocument document = new XmlDocument(); document.Load(configPath.Value); section = document.SelectSingleNode(sectionPath.Value); } //Read optional fileLogger section XmlNodeList xmlNodes = section.SelectNodes("./fileLogger"); if (xmlNodes != null) { foreach (XmlNode xmlNode in xmlNodes) { FileLogger fileLogger = ReadFileLoggerSection(xmlNode); _loggers.Add(fileLogger); } } //Read optional eventLogLogger section xmlNodes = section.SelectNodes("./eventLogLogger"); if (xmlNodes != null) { foreach (XmlNode xmlNode in xmlNodes) { EventLogLogger eventLogLogger = ReadEventLogLoggerSection(xmlNode); _loggers.Add(eventLogLogger); } } //Read optional mailLogger section xmlNodes = section.SelectNodes("./mailLogger"); if (xmlNodes != null) { foreach (XmlNode xmlNode in xmlNodes) { MailLogger mailLogger = ReadMailLoggerSection(xmlNode); _loggers.Add(mailLogger); } } //Read optional consoleLogger section xmlNodes = section.SelectNodes("./consoleLogger"); if (xmlNodes != null) { foreach (XmlNode xmlNode in xmlNodes) { ConsoleLogger consoleLogger = ReadConsoleLoggerSection(xmlNode); _loggers.Add(consoleLogger); } } return(_loggers); }
public Checked21_1() { logger = LogManager.GetCurrentClassLogger(); maillogger = new MailLogger(); }
public void SendMail() { MailLogger.LogInfo("fds"); }
public void Run(QqContext context) { var miniBrowser = (ScrapingBrowser)context["miniBrowser"]; var userName = context["userName"].ToString(); var postForm = new NameValueCollection(); postForm["uin"] = userName; postForm["appid"] = Constants.QqAppId; postForm["js_ver"] = "10095"; postForm["js_type"] = "0"; postForm["u1"] = "http://w.qq.com/proxy.html&r=0.6158497643191367"; postForm["r"] = "0.6158497643191367"; var htmlStr = miniBrowser.NavigateTo(new Uri(Constants.QqMsgCheckUrl), HttpVerb.Get, postForm); //将验证码信息的三部分存入数组 int checkCodePosition = htmlStr.IndexOf("(", StringComparison.Ordinal) + 1; var checkCode = htmlStr.Substring(checkCodePosition, htmlStr.LastIndexOf(")", StringComparison.Ordinal) - checkCodePosition); var checkArray = checkCode.Replace("'", "").Split(','); //验证码数组 context["qq16"] = checkArray[2]; if (checkArray[0] == "0") { context["code"] = checkArray[1]; context.QqMsgCodeStatus = QqMsgCodeStatus.NotNeedCode; } else if (checkArray[0] == "1") { //必要的参数 var url = string.Format(Constants.QqMsgCodeImageTemplate, Constants.QqAppId, "0.8478438374586403", userName); var param = new Dictionary <object, object> { { "username", context["ruokuaiUser"] }, { "password", context["ruokuaiPwd"] }, { "typeid", context["ruokuaiTypeid"] }, { "timeout", "90" }, { "softid", context["ruokuaiSoftid"] }, { "softkey", context["ruokuaiSoftkey"] } }; var wr = miniBrowser.DownloadWebResource(new Uri(url)); try { string httpResult = RuoKuaiHttp.Post("http://api.ruokuai.com/create.xml", param, wr.Content.ToArray()); var xmlDoc = new XmlDocument(); xmlDoc.LoadXml(httpResult); XmlNode idNode = xmlDoc.SelectSingleNode("Root/Id"); XmlNode resultNode = xmlDoc.SelectSingleNode("Root/Result"); //XmlNode errorNode = xmlDoc.SelectSingleNode("Root/Error"); if (resultNode != null && idNode != null) { //var topidid = idNode.InnerText; var result = resultNode.InnerText; context["code"] = result; context.QqMsgCodeStatus = QqMsgCodeStatus.NotNeedCode; //停顿下,否则qq会认为是在攻击它 Thread.Sleep(2000); } } catch (Exception ex) { Log4Logger.Error(ex.Message, ex); } if (string.IsNullOrWhiteSpace((context["code"] ?? "").ToString())) { var baseStartupPath = AppDomain.CurrentDomain.BaseDirectory; if (!Directory.Exists(baseStartupPath + "\\CodeImages")) { Directory.CreateDirectory(baseStartupPath + "\\CodeImages"); } File.WriteAllBytes(baseStartupPath + "\\CodeImages\\qqmsg_" + userName + ".jpg", wr.Content.ToArray()); context.QqMsgCodeStatus = QqMsgCodeStatus.NeedCode; if ((bool)context["needSendMail"]) { Log4Logger.Info("QQMsgLogger需要验证码,请尽快输入验证码!"); MailLogger.LogInfo("QQMsgLogger需要验证码,请尽快输入验证码!<a href='http://123.57.83.216:8001/QQMsgLogger/Check'>进入</a>"); } } } else { context.QqMsgStatus = QqMsgStatus.Fail; } context["verifysession"] = miniBrowser.GetCookie(new Uri(Constants.QqMsgCheckUrl), "verifysession").Value; }