示例#1
0
        public void AssertCollectionsEqual(IPivotCollectionSource expected, IPivotCollectionSource actual)
        {
            if (actual == null || expected == null)
            {
                Fail("Neither parameter to AssertCollectionsEqual can be null");
            }

            AssertEqual(expected.Name, actual.Name);
            AssertEqual(expected.AdditionalSearchText, actual.AdditionalSearchText);

            AssertPivotImagesEqual(expected.BrandImage, actual.BrandImage);
            AssertPivotImagesEqual(expected.Icon, actual.Icon);
            AssertLinksEqual(expected.Copyright, actual.Copyright);

            AssertFacetCategoriesEqual(expected.FacetCategories, actual.FacetCategories);

            PivotItem[] expectedItems = expected.Items.ToArray <PivotItem>();
            PivotItem[] actualItems   = actual.Items.ToArray <PivotItem>();

            for (int i = 0; i < actualItems.Count(); i++)
            {
                AssertItemsEqual(expectedItems[i], actualItems[i]);
            }

            AssertEqual(expectedItems.Length, actualItems.Length);
        }
        private void WriteFacetCategoriesTable(IPivotCollectionSource source, OleDbConnection connection)
        {
            String       insertScript = this.GenerateInsertQuery(this.GetFacetCategoriesTableName(), 8);
            OleDbCommand command      = new OleDbCommand(insertScript, connection);

            foreach (String column in OleDbSchemaConstants.FacetCategory.AllColumns)
            {
                command.Parameters.Add(column, OleDbType.VarChar);
            }

            foreach (PivotFacetCategory facetCategory in source.FacetCategories)
            {
                int index = 0;
                command.Parameters[index++].Value = facetCategory.Name;
                command.Parameters[index++].Value = facetCategory.Type.ToString();
                command.Parameters[index++].Value = facetCategory.Format;
                command.Parameters[index++].Value = facetCategory.IsFilterVisible.ToString().ToLowerInvariant();
                command.Parameters[index++].Value = facetCategory.IsMetaDataVisible.ToString().ToLowerInvariant();
                command.Parameters[index++].Value = facetCategory.IsWordWheelVisible.ToString().ToLowerInvariant();
                command.Parameters[index++].Value =
                    (facetCategory.SortOrder == null) ? null : facetCategory.SortOrder.Name;
                command.Parameters[index++].Value = this.GenerateSortValuesString(facetCategory);

                this.AssignNulls(command, index);
                command.ExecuteNonQuery();
            }
        }
        /// <summary>
        /// Copies the collection sources images (as determined by the <see cref="OnlyCopyCollectionImages"/> property),
        /// and then writes the collection to the delegate collection target.
        /// </summary>
        /// <remarks>
        /// Once the image files are copied, the appropriate changes are also made to the collection (and images, if
        /// appropriate) to refer to the new image files instead of those specified in the collection source.
        /// </remarks>
        /// <param name="source">the collection source to be written</param>
        public override void Write(IPivotCollectionSource source)
        {
            SourceImageCopySourceFilter sourceFilter = new SourceImageCopySourceFilter(source, this.GetLocalTarget());

            sourceFilter.OnlyCopyCollectionImages = this.OnlyCopyCollectionImages;
            base.Write(sourceFilter);
        }
示例#4
0
        /// <summary>
        /// Writes the given collection to the set of CSV files specified by this collection target.
        /// </summary>
        /// <remarks>
        /// This method will first delete any existing CSV files, and then will write out the new collection data.
        /// </remarks>
        /// <param name="source">the collection source to write</param>
        public override void Write(IPivotCollectionSource source)
        {
            base.Write(source);

            String schemaFile = Path.Combine(this.BaseDirectory, "schema.ini");

            if (File.Exists(schemaFile))
            {
                File.Delete(schemaFile);
            }
        }
 /// <summary>
 /// Writes the given collection to the underlying OLE DB data source.
 /// </summary>
 /// <remarks>
 /// This method will first drop the target tables and re-create them. Then, it will write out the give
 /// collection source's data.
 /// </remarks>
 /// <param name="source">the collection source to write</param>
 public virtual void Write(IPivotCollectionSource source)
 {
     using (OleDbConnection connection = new OleDbConnection(this.GetConnectionString()))
     {
         connection.Open();
         this.DropExistingTables(connection);
         this.CreateSchema(source, connection);
         this.WriteCollectionTable(source, connection);
         this.WriteFacetCategoriesTable(source, connection);
         this.WriteItemsTable(source, connection);
     }
 }
        public DeepZoomSourceFilter(IPivotCollectionSource source, String targetBasePath)
            : base(source)
        {
            String basePath = Directory.GetParent(targetBasePath).FullName;
            String baseFileName = Path.GetFileNameWithoutExtension(targetBasePath);
            String deepZoomDirectoryName = String.Format(DeepZoomDirectoryTemplate, baseFileName);
            m_dzcRelativePath = Path.Combine(deepZoomDirectoryName,
                String.Format(DzcFileNameTemplate, baseFileName));
            String dzcPath = Path.Combine(basePath, m_dzcRelativePath);

            m_imageCreator = new ParallelDeepZoomCreator(dzcPath);
        }
示例#7
0
        public DeepZoomSourceFilter(IPivotCollectionSource source, String targetBasePath)
            : base(source)
        {
            String basePath              = Directory.GetParent(targetBasePath).FullName;
            String baseFileName          = Path.GetFileNameWithoutExtension(targetBasePath);
            String deepZoomDirectoryName = String.Format(DeepZoomDirectoryTemplate, baseFileName);

            m_dzcRelativePath = Path.Combine(deepZoomDirectoryName,
                                             String.Format(DzcFileNameTemplate, baseFileName));
            String dzcPath = Path.Combine(basePath, m_dzcRelativePath);

            m_imageCreator = new ParallelDeepZoomCreator(dzcPath);
        }
示例#8
0
        /// <summary>
        /// Overwrites the collection currently contained by this buffer with the collection in the given collection
        /// source.
        /// </summary>
        /// <param name="source">the collection source to copy into this buffer</param>
        public void Write(IPivotCollectionSource source)
        {
            this.Collection = new PivotCollection();

            this.Collection.Name                 = source.Name;
            this.Collection.Icon                 = source.Icon;
            this.Collection.BrandImage           = source.BrandImage;
            this.Collection.AdditionalSearchText = source.AdditionalSearchText;
            this.Collection.SchemaVersion        = source.SchemaVersion;
            this.Collection.Copyright            = source.Copyright;
            this.Collection.ImageBase            = source.ImageBase;
            this.Collection.FacetCategories.AddRange(source.FacetCategories);
            this.Collection.Items.AddRange(source.Items);
            this.Collection.BasePath = source.BasePath;
        }
        private void WriteItemsTable(IPivotCollectionSource source, OleDbConnection connection)
        {
            List <PivotFacetCategory> facetCategories = new List <PivotFacetCategory>(source.FacetCategories);
            String insertScript = this.GenerateInsertQuery(this.GetItemsTableName(),
                                                           OleDbSchemaConstants.Item.AllColumns.Length + facetCategories.Count);
            OleDbCommand command = new OleDbCommand(insertScript, connection);

            foreach (String column in OleDbSchemaConstants.Item.AllColumns)
            {
                command.Parameters.Add(column, OleDbType.VarChar);
            }
            foreach (PivotFacetCategory facetCategory in facetCategories)
            {
                command.Parameters.Add(facetCategory.Name, OleDbType.VarChar);
            }

            foreach (PivotItem item in source.Items)
            {
                int index = 0;
                command.Parameters[index++].Value = item.Name;
                command.Parameters[index++].Value = (item.Image == null) ? null : item.Image.SourcePath;
                command.Parameters[index++].Value = item.Description;
                command.Parameters[index++].Value = item.Href;
                command.Parameters[index++].Value = this.GenerateRelatedLinksValue(item);
                foreach (PivotFacetCategory facetCategory in facetCategories)
                {
                    if (item.FacetCategories.Contains(facetCategory.Name))
                    {
                        command.Parameters[index].Value = item.GetAllFacetValuesAsString(
                            facetCategory.Name, OleDbSchemaConstants.FacetValueDelimiter);
                    }
                    else
                    {
                        command.Parameters[index].Value = null;
                    }
                    index++;
                }

                this.AssignNulls(command, index);
                command.ExecuteNonQuery();
            }
        }
示例#10
0
        private void CreateSchema(IPivotCollectionSource source, OleDbConnection connection)
        {
            List <String> columns = new List <String>();
            OleDbCommand  command = new OleDbCommand();

            command.Connection = connection;

            columns.AddRange(OleDbSchemaConstants.Collection.AllColumns);
            command.CommandText = this.GenerateCreateTableStatement(this.GetCollectionTableName(), columns);
            command.ExecuteNonQuery();

            columns.Clear();
            columns.AddRange(OleDbSchemaConstants.FacetCategory.AllColumns);
            command.CommandText = this.GenerateCreateTableStatement(this.GetFacetCategoriesTableName(), columns);
            command.ExecuteNonQuery();

            columns.Clear();
            columns.AddRange(OleDbSchemaConstants.Item.AllColumns);
            columns.AddRange(source.FacetCategories.Select(facetCategory => facetCategory.Name));
            command.CommandText = this.GenerateCreateTableStatement(this.GetItemsTableName(), columns);
            command.ExecuteNonQuery();
        }
示例#11
0
        private void WriteCollectionTable(IPivotCollectionSource source, OleDbConnection connection)
        {
            String       insertScript = this.GenerateInsertQuery(this.GetCollectionTableName(), 6);
            OleDbCommand command      = new OleDbCommand(insertScript, connection);

            foreach (String column in OleDbSchemaConstants.Collection.AllColumns)
            {
                command.Parameters.Add(column, OleDbType.VarChar);
            }

            int index = 0;

            command.Parameters[index++].Value = source.Name;
            command.Parameters[index++].Value = (source.Icon != null) ? source.Icon.SourcePath : null;
            command.Parameters[index++].Value = (source.BrandImage != null) ? source.BrandImage.SourcePath : null;
            command.Parameters[index++].Value = source.AdditionalSearchText;
            command.Parameters[index++].Value = (source.Copyright == null) ? null : source.Copyright.Title;
            command.Parameters[index++].Value = (source.Copyright == null) ? null : source.Copyright.Url;

            this.AssignNulls(command, index);
            command.ExecuteNonQuery();
        }
 private void WriteCollectionAttributes(XmlWriter xmlWriter, IPivotCollectionSource source)
 {
     if (source.Name != null)
     {
         xmlWriter.WriteAttributeString("Name", source.Name);
     }
     if (source.Icon != null)
     {
         xmlWriter.WriteAttributeString("Icon", PivotNamespace, source.Icon.SourcePath);
     }
     if (source.BrandImage != null)
     {
         xmlWriter.WriteAttributeString("BrandImage", PivotNamespace, source.BrandImage.SourcePath);
     }
     if (source.AdditionalSearchText != null)
     {
         xmlWriter.WriteAttributeString("AdditionalSearchText", PivotNamespace, source.AdditionalSearchText);
     }
     if (source.SchemaVersion != null)
     {
         xmlWriter.WriteAttributeString("SchemaVersion", source.SchemaVersion);
     }
 }
        /// <summary>
        /// Writes the given collection to disk as a CXML file.
        /// </summary>
        /// <param name="source">the collection source to write</param>
        public void Write(IPivotCollectionSource source)
        {
            Log.Message("Writing Pivot collection to {0}", this.BasePath);
            using (FileStream fileStream = new FileStream(this.BasePath, FileMode.Create))
            {
                XmlWriterSettings xmlWriterSettings = new XmlWriterSettings();
                xmlWriterSettings.Indent      = this.Indented;
                xmlWriterSettings.IndentChars = IndentChars;

                using (XmlWriter xmlWriter = XmlWriter.Create(fileStream, xmlWriterSettings))
                {
                    Log.Message("Writing header information");
                    xmlWriter.WriteProcessingInstruction("xml",
                                                         "version=\"1.0\" encoding=\"" + xmlWriter.Settings.Encoding.BodyName + "\"");
                    if (this.Stylesheet != null)
                    {
                        xmlWriter.WriteProcessingInstruction("xml-stylesheet",
                                                             "type=\"text/xsl\" href=\"" + this.Stylesheet + "\"");
                    }

                    xmlWriter.WriteStartElement("Collection", CollectionNamespace);
                    xmlWriter.WriteAttributeString("xmlns", "xsi", null, XmlSchemaInstanceNamespace);
                    xmlWriter.WriteAttributeString("xmlns", "xsd", null, XmlSchemaNamespace);
                    xmlWriter.WriteAttributeString("xmlns", "p", null, PivotNamespace);
                    this.WriteCollectionAttributes(xmlWriter, source);

                    if (source.FacetCategories.Count() > 0)
                    {
                        xmlWriter.WriteStartElement("FacetCategories");
                        foreach (PivotFacetCategory facetCategory in source.FacetCategories)
                        {
                            this.WriteFacetCategory(xmlWriter, facetCategory);
                        }
                        xmlWriter.WriteEndElement(); // FacetCategories
                    }

                    Log.Message("Writing items");
                    xmlWriter.WriteStartElement("Items");
                    if (source.ImageBase != null)
                    {
                        xmlWriter.WriteAttributeString("ImgBase", source.ImageBase);
                    }

                    int count = 0;
                    foreach (PivotItem item in source.Items)
                    {
                        if ((count > 0) && ((count % 10) == 0))
                        {
                            Log.Progress("Finished {0} items", count);
                        }
                        this.WriteItem(xmlWriter, item);
                        count++;
                    }
                    xmlWriter.WriteEndElement(); // Items

                    Log.Message("Writing footer");
                    if (source.Copyright != null)
                    {
                        xmlWriter.WriteStartElement("Extension");
                        xmlWriter.WriteStartElement("Copyright", PivotNamespace);
                        xmlWriter.WriteAttributeString("Name", source.Copyright.Title ?? "Copyright");
                        xmlWriter.WriteAttributeString("Href", source.Copyright.Url ?? "about:none");
                        xmlWriter.WriteEndElement(); // Extension
                        xmlWriter.WriteEndElement(); // Copyright
                    }
                    xmlWriter.WriteEndElement();     // Collection
                }
            }
        }
 /// <summary>
 /// Writes a given collection source to the delegate collection target.
 /// </summary>
 /// <remarks>
 /// Subclasses should override this method to make whatever transformations are needed, and then write the
 /// collection through to the delegate collection target.
 /// </remarks>
 /// <param name="source">the source collection to be written</param>
 public virtual void Write(IPivotCollectionSource source)
 {
     this.Target.Write(source);
 }
        private void CreateSchema(IPivotCollectionSource source, OleDbConnection connection)
        {
            List<String> columns = new List<String>();
            OleDbCommand command = new OleDbCommand();
            command.Connection = connection;

            columns.AddRange(OleDbSchemaConstants.Collection.AllColumns);
            command.CommandText = this.GenerateCreateTableStatement(this.GetCollectionTableName(), columns);
            command.ExecuteNonQuery();

            columns.Clear();
            columns.AddRange(OleDbSchemaConstants.FacetCategory.AllColumns);
            command.CommandText = this.GenerateCreateTableStatement(this.GetFacetCategoriesTableName(), columns);
            command.ExecuteNonQuery();

            columns.Clear();
            columns.AddRange(OleDbSchemaConstants.Item.AllColumns);
            columns.AddRange(source.FacetCategories.Select(facetCategory => facetCategory.Name));
            command.CommandText = this.GenerateCreateTableStatement(this.GetItemsTableName(), columns);
            command.ExecuteNonQuery();
        }
示例#16
0
        public void ParseArgs(List<List<String>> args)
        {
            foreach (List<String> argGroup in args)
            {
                String argName = argGroup[0];

                if ((argName == "help") || (argName == "?"))
                {
                    this.PrintHelp();
                }
                else if (argName == "debug")
                {
                    if (Debugger.IsAttached == false) Debugger.Launch();
                }
                else if (argName == "source")
                {
                    if (argGroup.Count != 3) this.Fail("Expected 2 arguments for /source");

                    String name = argGroup[1] + "-source";
                    if (this.AniseEngine.ContainsObject(name) == false) this.Fail("Unknown source type: " + argGroup[1]);

                    m_currentSource = this.AniseEngine.GetObject<IPivotCollectionSource>(name);
                }
                else if (argName == "target")
                {
                    if (argGroup.Count != 3) this.Fail("Expected 2 arguments for /target");

                    String name = argGroup[1] + "-target";
                    if (this.AniseEngine.ContainsObject(name) == false) this.Fail("Unknown target type: " + argGroup[1]);

                    m_currentTarget = this.AniseEngine.GetObject<IPivotCollectionTarget>(name);
                }
                else
                {
                    String objectName = argName + "-filter";
                    if (this.AniseEngine.ContainsObject(objectName) == false)
                    {
                        Log.Error("Unsupported argument: " + argName);
                        this.Exit(false);
                    }

                    PivotCollectionSourceFilter filter =
                        this.AniseEngine.GetObject<PivotCollectionSourceFilter>(objectName);
                    filter.Source = m_currentSource;
                    m_currentSource = filter;
                }
            }
        }
 public SourceImageCopySourceFilter(IPivotCollectionSource source, ILocalCollectionTarget localTarget)
     : base(source)
 {
     m_localTarget = localTarget;
     m_onlyCopyCollectionImages = false;
 }
        private void WriteCollectionTable(IPivotCollectionSource source, OleDbConnection connection)
        {
            String insertScript = this.GenerateInsertQuery(this.GetCollectionTableName(), 6);
            OleDbCommand command = new OleDbCommand(insertScript, connection);
            foreach (String column in OleDbSchemaConstants.Collection.AllColumns)
            {
                command.Parameters.Add(column, OleDbType.VarChar);
            }

            int index = 0;
            command.Parameters[index++].Value = source.Name;
            command.Parameters[index++].Value = (source.Icon != null) ? source.Icon.SourcePath : null;
            command.Parameters[index++].Value = (source.BrandImage != null) ? source.BrandImage.SourcePath : null;
            command.Parameters[index++].Value = source.AdditionalSearchText;
            command.Parameters[index++].Value = (source.Copyright == null) ? null : source.Copyright.Title;
            command.Parameters[index++].Value = (source.Copyright == null) ? null : source.Copyright.Url;

            this.AssignNulls(command, index);
            command.ExecuteNonQuery();
        }
 /// <summary>
 /// Creates an HTML image creation source filter with a given collection source delegate.
 /// </summary>
 /// <param name="source">the collection source from which this filter's data will be drawn</param>
 public HtmlImageCreationSourceFilter(IPivotCollectionSource source)
     : base(source)
 {
     m_imageCreator = new HtmlImageCreator();
 }
        private void WriteFacetCategoriesTable(IPivotCollectionSource source, OleDbConnection connection)
        {
            String insertScript = this.GenerateInsertQuery(this.GetFacetCategoriesTableName(), 8);
            OleDbCommand command = new OleDbCommand(insertScript, connection);
            foreach (String column in OleDbSchemaConstants.FacetCategory.AllColumns)
            {
                command.Parameters.Add(column, OleDbType.VarChar);
            }

            foreach (PivotFacetCategory facetCategory in source.FacetCategories)
            {
                int index = 0;
                command.Parameters[index++].Value = facetCategory.Name;
                command.Parameters[index++].Value = facetCategory.Type.ToString();
                command.Parameters[index++].Value = facetCategory.Format;
                command.Parameters[index++].Value = facetCategory.IsFilterVisible.ToString().ToLowerInvariant();
                command.Parameters[index++].Value = facetCategory.IsMetaDataVisible.ToString().ToLowerInvariant();
                command.Parameters[index++].Value = facetCategory.IsWordWheelVisible.ToString().ToLowerInvariant();
                command.Parameters[index++].Value =
                    (facetCategory.SortOrder == null) ? null : facetCategory.SortOrder.Name;
                command.Parameters[index++].Value = this.GenerateSortValuesString(facetCategory);

                this.AssignNulls(command, index);
                command.ExecuteNonQuery();
            }
        }
示例#21
0
 /// <summary>
 /// Transforms the given collection to use DeepZoom artifacts for its images, and then writes the resulting
 /// collection to the underlying collection target delegate.
 /// </summary>
 /// <remarks>
 /// All of the DeepZoom artifacts will be written into a directory named "foo_deepzoom" where "foo" is the file
 /// name (without extension) of the collection target delegate's base path.
 /// </remarks>
 /// <param name="source">the collection source to write</param>
 public override void Write(IPivotCollectionSource source)
 {
     m_sourceFilter.Source = source;
     this.Target.Write(m_sourceFilter);
 }
        private void WriteItemsTable(IPivotCollectionSource source, OleDbConnection connection)
        {
            List<PivotFacetCategory> facetCategories = new List<PivotFacetCategory>(source.FacetCategories);
            String insertScript = this.GenerateInsertQuery(this.GetItemsTableName(),
                OleDbSchemaConstants.Item.AllColumns.Length + facetCategories.Count);
            OleDbCommand command = new OleDbCommand(insertScript, connection);
            foreach (String column in OleDbSchemaConstants.Item.AllColumns)
            {
                command.Parameters.Add(column, OleDbType.VarChar);
            }
            foreach (PivotFacetCategory facetCategory in facetCategories)
            {
                command.Parameters.Add(facetCategory.Name, OleDbType.VarChar);
            }

            foreach (PivotItem item in source.Items)
            {
                int index = 0;
                command.Parameters[index++].Value = item.Name;
                command.Parameters[index++].Value = (item.Image == null) ? null : item.Image.SourcePath;
                command.Parameters[index++].Value = item.Description;
                command.Parameters[index++].Value = item.Href;
                command.Parameters[index++].Value = this.GenerateRelatedLinksValue(item);
                foreach (PivotFacetCategory facetCategory in facetCategories)
                {
                    if (item.FacetCategories.Contains(facetCategory.Name))
                    {
                        command.Parameters[index].Value = item.GetAllFacetValuesAsString(
                            facetCategory.Name, OleDbSchemaConstants.FacetValueDelimiter);
                    }
                    else
                    {
                        command.Parameters[index].Value = null;
                    }
                    index++;
                }

                this.AssignNulls(command, index);
                command.ExecuteNonQuery();
            }
        }
 /// <summary>
 /// Creates a new collection source filter with the given collection source delegate.
 /// </summary>
 /// <param name="source">the collection source from which this filter should draw its data</param>
 public PivotCollectionSourceFilter(IPivotCollectionSource source)
 {
     this.Source = source;
 }
 /// <summary>
 /// Copies the collection sources images (as determined by the <see cref="OnlyCopyCollectionImages"/> property),
 /// and then writes the collection to the delegate collection target.
 /// </summary>
 /// <remarks>
 /// Once the image files are copied, the appropriate changes are also made to the collection (and images, if
 /// appropriate) to refer to the new image files instead of those specified in the collection source.
 /// </remarks>
 /// <param name="source">the collection source to be written</param>
 public override void Write(IPivotCollectionSource source)
 {
     SourceImageCopySourceFilter sourceFilter = new SourceImageCopySourceFilter(source, this.GetLocalTarget());
     sourceFilter.OnlyCopyCollectionImages = this.OnlyCopyCollectionImages;
     base.Write(sourceFilter);
 }
示例#25
0
 /// <summary>
 /// Abstains from writing the given collection source anywhere.
 /// </summary>
 /// <param name="source">the source which will not be written anywhere</param>
 public void Write(IPivotCollectionSource source)
 {
     // Do nothing.
 }
 /// <summary>
 /// Writes the given collection to the underlying OLE DB data source.
 /// </summary>
 /// <remarks>
 /// This method will first drop the target tables and re-create them. Then, it will write out the give
 /// collection source's data.
 /// </remarks>
 /// <param name="source">the collection source to write</param>
 public virtual void Write(IPivotCollectionSource source)
 {
     using (OleDbConnection connection = new OleDbConnection(this.GetConnectionString()))
     {
         connection.Open();
         this.DropExistingTables(connection);
         this.CreateSchema(source, connection);
         this.WriteCollectionTable(source, connection);
         this.WriteFacetCategoriesTable(source, connection);
         this.WriteItemsTable(source, connection);
     }
 }
示例#27
0
 /// <summary>
 /// Applies this adapter's source filter and writes the resulting collection stream into the delegate collection
 /// target.
 /// </summary>
 /// <param name="source">the collection to be written</param>
 public override void Write(IPivotCollectionSource source)
 {
     this.SourceFilter.Source = source;
     this.Target.Write(this.SourceFilter);
 }
        /// <summary>
        /// Overwrites the collection currently contained by this buffer with the collection in the given collection
        /// source.
        /// </summary>
        /// <param name="source">the collection source to copy into this buffer</param>
        public void Write(IPivotCollectionSource source)
        {
            this.Collection = new PivotCollection();

            this.Collection.Name = source.Name;
            this.Collection.Icon = source.Icon;
            this.Collection.BrandImage = source.BrandImage;
            this.Collection.AdditionalSearchText = source.AdditionalSearchText;
            this.Collection.SchemaVersion = source.SchemaVersion;
            this.Collection.Copyright = source.Copyright;
            this.Collection.ImageBase = source.ImageBase;
            this.Collection.FacetCategories.AddRange(source.FacetCategories);
            this.Collection.Items.AddRange(source.Items);
            this.Collection.BasePath = source.BasePath;
        }
 /// <summary>
 /// Creates a new un-DeepZoom source filter with a given delegate collection source.
 /// </summary>
 /// <param name="source">the collection source from which the collection data should be read</param>
 public UnDeepZoomSourceFilter(IPivotCollectionSource source)
     : base(source)
 {
     m_imageCreator = new UnDeepZoomImageCreator();
 }
        /// <summary>
        /// Writes the given collection to disk as a CXML file.
        /// </summary>
        /// <param name="source">the collection source to write</param>
        public void Write(IPivotCollectionSource source)
        {
            Log.Message("Writing Pivot collection to {0}", this.BasePath);
            using (FileStream fileStream = new FileStream(this.BasePath, FileMode.Create))
            {
                XmlWriterSettings xmlWriterSettings = new XmlWriterSettings();
                xmlWriterSettings.Indent = this.Indented;
                xmlWriterSettings.IndentChars = IndentChars;

                using (XmlWriter xmlWriter = XmlWriter.Create(fileStream, xmlWriterSettings))
                {
                    Log.Message("Writing header information");
                    xmlWriter.WriteProcessingInstruction("xml",
                        "version=\"1.0\" encoding=\"" + xmlWriter.Settings.Encoding.BodyName + "\"");
                    if (this.Stylesheet != null)
                    {
                        xmlWriter.WriteProcessingInstruction("xml-stylesheet",
                            "type=\"text/xsl\" href=\"" + this.Stylesheet + "\"");
                    }

                    xmlWriter.WriteStartElement("Collection", CollectionNamespace);
                    xmlWriter.WriteAttributeString("xmlns", "xsi", null, XmlSchemaInstanceNamespace);
                    xmlWriter.WriteAttributeString("xmlns", "xsd", null, XmlSchemaNamespace);
                    xmlWriter.WriteAttributeString("xmlns", "p", null, PivotNamespace);
                    this.WriteCollectionAttributes(xmlWriter, source);

                    if (source.FacetCategories.Count() > 0)
                    {
                        xmlWriter.WriteStartElement("FacetCategories");
                        foreach (PivotFacetCategory facetCategory in source.FacetCategories)
                        {
                            this.WriteFacetCategory(xmlWriter, facetCategory);
                        }
                        xmlWriter.WriteEndElement(); // FacetCategories
                    }

                    Log.Message("Writing items");
                    xmlWriter.WriteStartElement("Items");
                    if (source.ImageBase != null)
                    {
                        xmlWriter.WriteAttributeString("ImgBase", source.ImageBase);
                    }

                    int count = 0;
                    foreach (PivotItem item in source.Items)
                    {
                        if ((count > 0) && ((count % 10) == 0)) Log.Progress("Finished {0} items", count);
                        this.WriteItem(xmlWriter, item);
                        count++;
                    }
                    xmlWriter.WriteEndElement(); // Items

                    Log.Message("Writing footer");
                    if (source.Copyright != null)
                    {
                        xmlWriter.WriteStartElement("Extension");
                        xmlWriter.WriteStartElement("Copyright", PivotNamespace);
                        xmlWriter.WriteAttributeString("Name", source.Copyright.Title ?? "Copyright");
                        xmlWriter.WriteAttributeString("Href", source.Copyright.Url ?? "about:none");
                        xmlWriter.WriteEndElement(); // Extension
                        xmlWriter.WriteEndElement(); // Copyright
                    }
                    xmlWriter.WriteEndElement(); // Collection
                }
            }
        }
 /// <summary>
 /// Creates an HTML image creation source filter with a given collection source delegate.
 /// </summary>
 /// <param name="source">the collection source from which this filter's data will be drawn</param>
 public HtmlImageCreationSourceFilter(IPivotCollectionSource source)
     : base(source)
 {
     m_imageCreator = new HtmlImageCreator();
 }
 private void WriteCollectionAttributes(XmlWriter xmlWriter, IPivotCollectionSource source)
 {
     if (source.Name != null)
     {
         xmlWriter.WriteAttributeString("Name", source.Name);
     }
     if (source.Icon != null)
     {
         xmlWriter.WriteAttributeString("Icon", PivotNamespace, source.Icon.SourcePath);
     }
     if (source.BrandImage != null)
     {
         xmlWriter.WriteAttributeString("BrandImage", PivotNamespace, source.BrandImage.SourcePath);
     }
     if (source.AdditionalSearchText != null)
     {
         xmlWriter.WriteAttributeString("AdditionalSearchText", PivotNamespace, source.AdditionalSearchText);
     }
     if (source.SchemaVersion != null)
     {
         xmlWriter.WriteAttributeString("SchemaVersion", source.SchemaVersion);
     }
 }
示例#33
0
 /// <summary>
 /// Writes a given collection source to the delegate collection target.
 /// </summary>
 /// <remarks>
 /// Subclasses should override this method to make whatever transformations are needed, and then write the
 /// collection through to the delegate collection target.
 /// </remarks>
 /// <param name="source">the source collection to be written</param>
 public virtual void Write(IPivotCollectionSource source)
 {
     this.Target.Write(source);
 }
示例#34
0
 /// <summary>
 /// Creates a new un-DeepZoom source filter with a given delegate collection source.
 /// </summary>
 /// <param name="source">the collection source from which the collection data should be read</param>
 public UnDeepZoomSourceFilter(IPivotCollectionSource source)
     : base(source)
 {
     m_imageCreator = new UnDeepZoomImageCreator();
 }
 public SourceImageCopySourceFilter(IPivotCollectionSource source, ILocalCollectionTarget localTarget)
     : base(source)
 {
     m_localTarget = localTarget;
     m_onlyCopyCollectionImages = false;
 }
示例#36
0
 /// <summary>
 /// Creates a new collection source filter with the given collection source delegate.
 /// </summary>
 /// <param name="source">the collection source from which this filter should draw its data</param>
 public PivotCollectionSourceFilter(IPivotCollectionSource source)
 {
     this.Source = source;
 }