Ejemplo n.º 1
0
        public void RecordAdReward(string adInterface)
        {
            if (m_RecordMap == null)
            {
                m_RecordMap = new Dictionary <string, AdRecord>();
            }

            AdRecord record = null;

            if (!m_RecordMap.TryGetValue(adInterface, out record))
            {
                record = new AdRecord(adInterface);
                m_RecordMap.Add(adInterface, record);
            }

            record.AddRewardCount();
        }
Ejemplo n.º 2
0
		AdRecord[] LoadAdFile (string file)
		{
			Stream fStream;
			try {
				fStream = new FileStream (file, FileMode.Open, FileAccess.Read, FileShare.Read);
			} catch (Exception e) {
				throw new HttpException("AdRotator: Unable to open file", e);
			}

			ArrayList list = new ArrayList ();
			try {
				IDictionary hybridDict = null;
				XmlDocument document = new XmlDocument ();
				document.Load (fStream);

				XmlElement docElem = document.DocumentElement;

				if (docElem == null)
					throw new HttpException ("No advertisements found");

				if (docElem.LocalName != "Advertisements")
					throw new HttpException ("No advertisements found: invalid document element");

				XmlNode node = docElem.FirstChild;
				while (node != null) {
					if (node.LocalName == "Ad") {
						XmlNode innerNode = node.FirstChild;
						while (innerNode != null) {
							if (node.NodeType == XmlNodeType.Element) {
								if (hybridDict == null)
									hybridDict = new HybridDictionary ();

								hybridDict.Add (innerNode.LocalName, innerNode.InnerText);
							}
							innerNode = innerNode.NextSibling;
						}

						if (hybridDict != null) {
							list.Add (hybridDict);
							hybridDict = null;
						}
					}
					node = node.NextSibling;
				}

			} catch(Exception e) {
				throw new HttpException("Parse error:" + file, e);
			} finally {
				if (fStream != null)
					fStream.Close();
			}

			if (list.Count == 0)
				throw new HttpException ("No advertisements found");

			AdRecord [] adsArray = new AdRecord [list.Count];
			int count = list.Count;
			for (int i = 0; i < count; i++)
				adsArray [i] = new AdRecord ((IDictionary) list [i]);

			return adsArray;
		}
Ejemplo n.º 3
0
		private bool IsAdMatching (AdRecord currAd)
		{
			if (KeywordFilter != String.Empty)
				return (0 == String.Compare (currAd.Keyword, KeywordFilter, true));

			return true;
		}