Пример #1
0
		private Facts PrepareFacts( Flickr.Photo[] photos, string uriFormat )
		{
			Facts facts = new Facts();

			foreach ( Flickr.Photo photo in photos )
			{
				if ( !string.IsNullOrEmpty( photo.Title )
					&& !string.IsNullOrEmpty( photo.OwnerName ) )
				{
					string title = photo.Title;
					string owner = photo.OwnerName[ 0 ].ToString();
					DateTime date = new DateTime( photo.DateTaken.Year, 1, 1 );

					Facts.WhatRow what = facts.What.FindByID( title );
					Facts.WhereRow where = facts.Where.FindByID( owner );
					Facts.WhenRow when = facts.When.FindByID( date );

					if ( ( what != null || facts.What.Count < maxSize )
						&& ( where != null || facts.Where.Count < maxSize )
						&& ( when != null || facts.When.Count < maxSize ) )
					{
						if ( what == null ) what = facts.What.AddWhatRow( title );
						if ( where == null ) where = facts.Where.AddWhereRow( owner );
						if ( when == null ) when = facts.When.AddWhenRow( date );

						string uri = string.Format( uriFormat,
							Uri.EscapeDataString( Convert.ToBase64String( Encoding.UTF8.GetBytes( photo.ThumbnailUrl ) ) ) );

						if ( facts.Fact.FindByWhatWhereWhen( what.ID, where.ID, when.ID ) == null )
						{
							facts.Fact.AddFactRow( what, where, when, uri );
						}
					}
				}
			}

			return facts;
		}
Пример #2
0
 public static System.Xml.Schema.XmlSchemaComplexType GetTypedTableSchema(System.Xml.Schema.XmlSchemaSet xs) {
     System.Xml.Schema.XmlSchemaComplexType type = new System.Xml.Schema.XmlSchemaComplexType();
     System.Xml.Schema.XmlSchemaSequence sequence = new System.Xml.Schema.XmlSchemaSequence();
     Facts ds = new Facts();
     xs.Add(ds.GetSchemaSerializable());
     System.Xml.Schema.XmlSchemaAny any1 = new System.Xml.Schema.XmlSchemaAny();
     any1.Namespace = "http://www.w3.org/2001/XMLSchema";
     any1.MinOccurs = new decimal(0);
     any1.MaxOccurs = decimal.MaxValue;
     any1.ProcessContents = System.Xml.Schema.XmlSchemaContentProcessing.Lax;
     sequence.Items.Add(any1);
     System.Xml.Schema.XmlSchemaAny any2 = new System.Xml.Schema.XmlSchemaAny();
     any2.Namespace = "urn:schemas-microsoft-com:xml-diffgram-v1";
     any2.MinOccurs = new decimal(1);
     any2.ProcessContents = System.Xml.Schema.XmlSchemaContentProcessing.Lax;
     sequence.Items.Add(any2);
     System.Xml.Schema.XmlSchemaAttribute attribute1 = new System.Xml.Schema.XmlSchemaAttribute();
     attribute1.Name = "namespace";
     attribute1.FixedValue = ds.Namespace;
     type.Attributes.Add(attribute1);
     System.Xml.Schema.XmlSchemaAttribute attribute2 = new System.Xml.Schema.XmlSchemaAttribute();
     attribute2.Name = "tableTypeName";
     attribute2.FixedValue = "WhereDataTable";
     type.Attributes.Add(attribute2);
     type.Particle = sequence;
     return type;
 }
Пример #3
0
 public static System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(System.Xml.Schema.XmlSchemaSet xs) {
     Facts ds = new Facts();
     System.Xml.Schema.XmlSchemaComplexType type = new System.Xml.Schema.XmlSchemaComplexType();
     System.Xml.Schema.XmlSchemaSequence sequence = new System.Xml.Schema.XmlSchemaSequence();
     xs.Add(ds.GetSchemaSerializable());
     System.Xml.Schema.XmlSchemaAny any = new System.Xml.Schema.XmlSchemaAny();
     any.Namespace = ds.Namespace;
     sequence.Items.Add(any);
     type.Particle = sequence;
     return type;
 }