/// <summary> /// Execute the Check command /// </summary> /// <param name="e"></param> /// <returns></returns> public SpamAssassinCheckResult ExecuteCheck(SpamAssassinCheckArgs e) { string[] additionalLines; var result = new SpamAssassinCheckResult(); var responsePacket = SendMessageEx(SpamAssassinCommands.Check, PrepareCheckRequestMessage(e)); CheckThrowResponsePacket(responsePacket); InterpretCheckResponseMessage(responsePacket.Message, out additionalLines, result); return(result); }
/// <summary> /// Internal helper /// </summary> private void InterpretCheckResponseMessage(string responseMessage, out string[] additionalLines, SpamAssassinCheckResult result) { var lines = SplitLines(responseMessage); var firstLineColumns = lines[0].Split(' '); var spamdFlag = firstLineColumns[1]; var spamdScore = firstLineColumns[3]; var spamdThreshold = firstLineColumns[5]; result.IsSpam = String.Compare(spamdFlag, "True", true) == 0; result.Score = Convert.ToDouble(spamdScore, CultureInfo.InvariantCulture); result.Threshold = Convert.ToDouble(spamdThreshold, CultureInfo.InvariantCulture); var rawAdditionalLines = new ArrayList(); for (var index = 1; index < lines.Length; index++) rawAdditionalLines.Add(lines[index]); additionalLines = (string[])rawAdditionalLines.ToArray(typeof(string)); }
/// <summary> /// Execute the Check command /// </summary> /// <param name="e"></param> /// <returns></returns> public SpamAssassinCheckResult ExecuteCheck(SpamAssassinCheckArgs e) { string[] additionalLines; var result = new SpamAssassinCheckResult(); var responsePacket = SendMessageEx(SpamAssassinCommands.Check, PrepareCheckRequestMessage(e)); CheckThrowResponsePacket(responsePacket); InterpretCheckResponseMessage(responsePacket.Message, out additionalLines, result); return result; }
/// <summary> /// Internal helper /// </summary> private void InterpretCheckResponseMessage(string responseMessage, out string[] additionalLines, SpamAssassinCheckResult result) { var lines = SplitLines(responseMessage); var firstLineColumns = lines[0].Split(' '); var spamdFlag = firstLineColumns[1]; var spamdScore = firstLineColumns[3]; var spamdThreshold = firstLineColumns[5]; result.IsSpam = String.Compare(spamdFlag, "True", true) == 0; result.Score = Convert.ToDouble(spamdScore, CultureInfo.InvariantCulture); result.Threshold = Convert.ToDouble(spamdThreshold, CultureInfo.InvariantCulture); var rawAdditionalLines = new ArrayList(); for (var index = 1; index < lines.Length; index++) { rawAdditionalLines.Add(lines[index]); } additionalLines = (string[])rawAdditionalLines.ToArray(typeof(string)); }