예제 #1
0
        internal static bool CreditsLeft(Guid campaignId, AdWordFilterActions action)
        {
            float availableCredits      = 0;
            float costPerLinkClick      = 0;
            float costPerPopupLinkClick = 0;

            List <string>       campaignObjectIds = new List <string>();
            SqlConnectionHelper sqlConnection     = new SqlConnectionHelper();

            System.Data.SqlClient.SqlDataReader sqlDataReader = null;
            try
            {
                sqlConnection.Command.CommandType = CommandType.StoredProcedure;
                sqlConnection.Command.CommandText = "hisp_Filter_AdCampaigns_LoadById";
                sqlConnection.Command.Parameters.Add(new SqlParameter("@CampaignId", SqlDbType.UniqueIdentifier));
                sqlConnection.Command.Parameters["@CampaignId"].Value = campaignId;
                sqlDataReader = sqlConnection.Command.ExecuteReader(CommandBehavior.CloseConnection);
                if (sqlDataReader.Read())
                {
                    availableCredits      = float.Parse(sqlDataReader["FAC_Credits"].ToString()) - float.Parse(sqlDataReader["FAC_CreditsUsed"].ToString());
                    costPerLinkClick      = float.Parse(sqlDataReader["FAC_CostPerLinkClick"].ToString());
                    costPerPopupLinkClick = float.Parse(sqlDataReader["FAC_CostPerPopupLinkClick"].ToString());
                }
                sqlDataReader.Close();
            }
            finally
            {
                sqlConnection.Close();
            }

            if (action == AdWordFilterActions.Link && availableCredits > 0)
            {
                return(true);
            }
            else if (action == AdWordFilterActions.Popup && availableCredits > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #2
0
        internal AdWordFilter(string word, bool isExactMatch, AdWordFilterActions action, Guid campaignId)
        {
            this.word       = word;
            this.action     = action;
            this.campaignId = campaignId;

            linkMatchEvaluator  = new MatchEvaluator(LinkMatchEvaluator);
            popupMatchEvaluator = new MatchEvaluator(PopupMatchEvaluator);

            if (isExactMatch)
            {
                wordPattern = @"(?<=\W)(" + word + @")(?=\W[^>]*?<)";
            }
            else
            {
                wordPattern = @"(\w*" + word + @"\w*)(?=[^>]*?<)";
            }

            regex = new Regex(wordPattern, RegexOptions.IgnoreCase | RegexOptions.Compiled);
        }