public static int AddView(Guid userId, string ip, Guid campaignId, string type) { int viewAdded = 0; SqlConnectionHelper sqlConnection = new SqlConnectionHelper(); try { sqlConnection.Command.CommandType = CommandType.StoredProcedure; sqlConnection.Command.CommandText = "hisp_Filter_AdCampaigns_AddView"; sqlConnection.Command.Parameters.Add(new SqlParameter("@USR_ID", SqlDbType.UniqueIdentifier)); sqlConnection.Command.Parameters["@USR_ID"].Value = userId; sqlConnection.Command.Parameters.Add(new SqlParameter("@FAC_ID", SqlDbType.UniqueIdentifier)); sqlConnection.Command.Parameters["@FAC_ID"].Value = campaignId; sqlConnection.Command.Parameters.Add(new SqlParameter("@Type", SqlDbType.NVarChar)); sqlConnection.Command.Parameters["@Type"].Value = type; sqlConnection.Command.Parameters.Add(new SqlParameter("@UserTimeSpanSecond", SqlDbType.Int)); sqlConnection.Command.Parameters["@UserTimeSpanSecond"].Value = FilterEngine.GetFilterEngineConfig().UserViewTimeSpan == 0 ? 990000000 : FilterEngine.GetFilterEngineConfig().UserViewTimeSpan; sqlConnection.Command.Parameters.Add(new SqlParameter("@IPTimeSpanSecond", SqlDbType.Int)); sqlConnection.Command.Parameters["@IPTimeSpanSecond"].Value = FilterEngine.GetFilterEngineConfig().IPViewTimeSpan == 0 ? 990000000 : FilterEngine.GetFilterEngineConfig().IPViewTimeSpan; sqlConnection.Command.Parameters.Add(new SqlParameter("@IP", SqlDbType.Char)); sqlConnection.Command.Parameters["@IP"].Value = ip; sqlConnection.Command.Parameters.Add(new SqlParameter("@ViewAdded", SqlDbType.Bit)); sqlConnection.Command.Parameters["@ViewAdded"].Direction = ParameterDirection.ReturnValue; sqlConnection.Command.ExecuteNonQuery(); viewAdded = (int)sqlConnection.Command.Parameters["@ViewAdded"].Value; } finally { sqlConnection.Close(); } return(viewAdded); }
internal static void InformAdmin(BadWordFilterActions action, string value, string word, bool isExactMatch, Type type, FilterObjectTypes filterObjectType, Guid objectId, Guid userId) { try { string markedValue = Regex.Replace(value, @"(\w*" + word + @"\w*)(?=[^>]*?<)", "<u><font color=\"#AA0000\">$1</font></u>", RegexOptions.IgnoreCase); string exactValue = isExactMatch ? "Ja" : "Nein"; string userLink = FilterEngine.GetFilterEngineConfig().ObjectLinks["User"] + userId.ToString(); string objectLink = ""; switch (filterObjectType) { case FilterObjectTypes.DataObject: if (FilterEngine.GetFilterEngineConfig().ObjectLinks.ContainsKey(type.ToString())) { objectLink = FilterEngine.GetFilterEngineConfig().ObjectLinks[type.ToString()] + objectId.ToString(); } break; case FilterObjectTypes.Comment: if (FilterEngine.GetFilterEngineConfig().ObjectLinks.ContainsKey(type.ToString())) { objectLink = FilterEngine.GetFilterEngineConfig().ObjectLinks[type.ToString()] + objectId.ToString(); } break; case FilterObjectTypes.Profile: objectLink = FilterEngine.GetFilterEngineConfig().ObjectLinks["Profile"] + objectId.ToString(); break; } SmtpSection smtpSection = (SmtpSection)ConfigurationManager.GetSection("system.net/mailSettings/smtp"); MailMessage mailMessage = new MailMessage(); mailMessage.From = new MailAddress(smtpSection.From); foreach (KeyValuePair <string, string> adminEmail in FilterEngine.GetFilterEngineConfig().AdminEmailList) { mailMessage.To.Add(new MailAddress(adminEmail.Key, adminEmail.Value)); } mailMessage.Subject = "Bad Word Filter"; StringBuilder bodyString = new StringBuilder(1000); bodyString.Append("<table border=0>"); bodyString.Append(" <tr>"); bodyString.Append(" <td>Aktion(en):</td><td>" + GetActionsString(action) + "</td>"); bodyString.Append(" </tr><tr>"); bodyString.Append(" <td>Wort:</td><td>" + word + "<br/>"); bodyString.Append(" </tr><tr>"); bodyString.Append(" <td>Genau:</td><td>" + exactValue + "<br/>"); bodyString.Append(" </tr><tr>"); bodyString.Append(" <td valign=\"top\">Text:</td><td>" + markedValue + "<br/>"); bodyString.Append(" </tr><tr>"); bodyString.Append(" <td>Typ:</td><td>" + filterObjectType + "<br/>"); bodyString.Append(" </tr><tr>"); bodyString.Append(" <td>Object:</td><td><a href=\"" + objectLink + "\">" + objectId + "</a><br/>"); bodyString.Append(" </tr><tr>"); bodyString.Append(" <td>User:</td><td><a href=\"" + userLink + "\">" + userId + "</a><br/>"); bodyString.Append(" </tr>"); bodyString.Append("</table>"); mailMessage.Body = bodyString.ToString(); mailMessage.IsBodyHtml = true; SmtpClient smtpClient = new SmtpClient(); smtpClient.Send(mailMessage); } catch (Exception e) { new Exception("Error while sending bad word info mail", e); } }