none
Converting a DataSet to collection

    Question

  • Hi all, 

    i am a new intern and i am having some trouble creating a JIT pivotviewer. Right now i have a dataset filled with data but i cannot figure out how to get the dataset to work with the foreach to add the data to different facets. I am using just a sql string with oraclecommand. I will post my code here:


    namespace PivotServerTools
    {
        public class CollectionFactoryBase
        {
            private OracleConnection conn = new OracleConnection();
            private OracleCommand cmd;
            private OracleDataAdapter da;
            private OracleCommandBuilder cb;
            private DataSet ds;
            
                public override Collection MakeCollection(CollectionRequestContext context)
               {
            
                    conn.ConnectionString = "User Id=a501300;Password=;Data Source=SAQ1C;";
                    try
                    {
                        const int maxItems_c = 150;
                       conn.Open();
                        string sql = "select insert_id, sai_id, Long_name, Short_name from sa_instrument_basic where rownum <50";
                        conn.Close();
                        Collection collection = new Collection();
                        collection.Name = "learnDB collection";
                        cmd = new OracleCommand(sql, conn);
                        cmd.CommandType = CommandType.Text;
                        da.TableMappings.Add("Table","sa_instrument_basic");
                        da = new OracleDataAdapter(cmd);
                        cb = new OracleCommandBuilder(da);
                        ds = new DataSet();
                        da.Fill(ds);
                       
                    }
                    catch (OracleException ex)
                    {
                        throw(ex);
                    }
                   
                    
                    
                   
                }
            
        } 
    }  


    namespace PivotServerTools

    {

        public class CollectionFactoryBase

        {

            private OracleConnection conn = new OracleConnection();

            private OracleCommand cmd;

            private OracleDataAdapter da;

            private OracleCommandBuilder cb;

            private DataSet ds;

            

                public override Collection MakeCollection(CollectionRequestContext context)

               {

            

                    conn.ConnectionString = "connection"

                    try

                    {

                        const int maxItems_c = 150;


                       conn.Open();

                        string sql = "QueryCode";

                        conn.Close();

                        Collection collection = new Collection();

                        collection.Name = "learnDB collection";


                        cmd = new OracleCommand(sql, conn);

                        cmd.CommandType = CommandType.Text;

                        da.TableMappings.Add("Table"," table");

                        da = new OracleDataAdapter(cmd);

                        cb = new OracleCommandBuilder(da);

                        ds = new DataSet();

                        da.Fill(ds);

                          }

                    catch (OracleException ex)

                    {

                        throw(ex);

                    }

                }

        } 

    }  



    i need to take the data in the dataset and convert it into something that the collection.additem can use. 

    any suggestions are helpfull. thank you in advance - will


    Monday, July 11, 2011 2:19 PM

Answers

  • You could do something like this instead:


       function EDBDatabase.GetLastTransmitList( optionSetID : Int32 ): List<LastTransmit>;
          var
             newList    : List<LastTransmit>;
             connection : OracleConnection;
             command    : OracleCommand;
             rdr        : OracleDataReader;
             aLastTransmit : LastTransmit;
    
          begin
          newList := new List<LastTransmit>;
    
          Open( var connection );
          try
    
             command := connection.CreateCommand;
             command.BindByName  := True;
             command.CommandText :=  'SELECT ' +
                 [your sql here]

    command.ExecuteNonQuery; rdr := command.ExecuteReader; while rdr.Read do begin aLastTransmit := new LastTransmit( &Order := RatmOrder( rdr, 0 ), SerialNumber := NullOrString( rdr, 1 ), Location := NullOrString( rdr, 2 ), TransmitTime := NullOrDateTime( rdr, 3 ), Rate := NullOrDouble( rdr, 4 ), RateAlarmStatus := NullOrString( rdr, 5 ), DeviceType := NullOrString( rdr, 6 ) ); newList.Add( aLastTransmit ); end; finally Close( connection ); result := newList; end; end;


    The functions used with the reader are just little functions like:


       function NullOrString( rdr : OracleDataReader; index : integer ) : String;
          begin
          if rdr[index] = DBNull.Value 
             then exit nil
             else exit rdr.GetString( index );
          end;
    


    Note: Code is Delphi Prism not C#.  I like it better...  ;-)


    And my open and close are:

       procedure EDBDatabase.Open( var connection : OracleConnection );
          begin
          try
             connection := New OracleConnection( DataConnectionString.ToString );
             connection.Open;
          except
             raise new Exception( 'Unable to open database connection.' );
             end;
          end;
    
       procedure EDBDatabase.Close( connection : OracleConnection );
          begin
          connection.Close;
          connection.Dispose;
          end;
    


    Monday, July 11, 2011 2:27 PM

All replies

  • You could do something like this instead:


       function EDBDatabase.GetLastTransmitList( optionSetID : Int32 ): List<LastTransmit>;
          var
             newList    : List<LastTransmit>;
             connection : OracleConnection;
             command    : OracleCommand;
             rdr        : OracleDataReader;
             aLastTransmit : LastTransmit;
    
          begin
          newList := new List<LastTransmit>;
    
          Open( var connection );
          try
    
             command := connection.CreateCommand;
             command.BindByName  := True;
             command.CommandText :=  'SELECT ' +
                 [your sql here]

    command.ExecuteNonQuery; rdr := command.ExecuteReader; while rdr.Read do begin aLastTransmit := new LastTransmit( &Order := RatmOrder( rdr, 0 ), SerialNumber := NullOrString( rdr, 1 ), Location := NullOrString( rdr, 2 ), TransmitTime := NullOrDateTime( rdr, 3 ), Rate := NullOrDouble( rdr, 4 ), RateAlarmStatus := NullOrString( rdr, 5 ), DeviceType := NullOrString( rdr, 6 ) ); newList.Add( aLastTransmit ); end; finally Close( connection ); result := newList; end; end;


    The functions used with the reader are just little functions like:


       function NullOrString( rdr : OracleDataReader; index : integer ) : String;
          begin
          if rdr[index] = DBNull.Value 
             then exit nil
             else exit rdr.GetString( index );
          end;
    


    Note: Code is Delphi Prism not C#.  I like it better...  ;-)


    And my open and close are:

       procedure EDBDatabase.Open( var connection : OracleConnection );
          begin
          try
             connection := New OracleConnection( DataConnectionString.ToString );
             connection.Open;
          except
             raise new Exception( 'Unable to open database connection.' );
             end;
          end;
    
       procedure EDBDatabase.Close( connection : OracleConnection );
          begin
          connection.Close;
          connection.Dispose;
          end;
    


    Monday, July 11, 2011 2:27 PM
  • You dont have to convert it into a list. You can do something like this to generate items to add it to the collection.

    Dim ds as DataSet

    Dim c

    For each row as DataRow in ds.rows


    End


    Monday, July 11, 2011 2:34 PM
  • Sorry, accidently pressed post.

    here it is.

    Dim ds as new Dataset

    Dim c as new Collection

    For each row as datarow in ds.rows

    dim myfacet1 as new Facet()

    dim myfacet2 as new Facet()

    c.additem("Name","URL","Description","Image",myfacet1,myfacet2)

    end

    ''if you want to display your facet

    c.setfacetdisplay("FacetName","","","")

    this is good enough to add every row in the dataset to the collection viewer.

    Monday, July 11, 2011 2:39 PM
  • I have tried to do what you described silverkali, but i get an error that says:

    "Foreach statement cannot operate on variable of type'System.Data.Dataset' becaue 'System.Data.Dataset' does not contain a public definition for 'GetEnumerator' "

    this is why i tought covnerting it into soemthing else first would solve the problem 

    Monday, July 11, 2011 2:53 PM
  • Ok, here's another solution for that.

    if the no of columns in your dataset are less. create a class with all the column names as properties.

    Now create a new list(Of newlycreatedclass)

    For Each row As DataRow In ds.Rows

    Dim myClass

    End

    Monday, July 11, 2011 2:57 PM
  • Ok, here's another solution for that.

    if the no of columns in your dataset are less. create a class with all the column names as properties.

    Now create a new list(Of newlycreatedclass)

    For Each row As DataRow In ds.Rows

         Dim myClass as new (newlycreated class)

         Dim propInfo() As PropertyInfo = myclass.GetType.GetProperties()

             For Each p As PropertyInfo In propInfo

                     If ds.Columns.Contains(p.Name) Then

                             Dim value = row.Item(p.Name)

                             If Not value Is DBNull.Value Then
                                  p.SetValue(myclass, value, Nothing)
                             End If

                     End If

             End

    End


    Your dataset is converted to a list now.

    Monday, July 11, 2011 3:00 PM
  • foreach doesnt work on dataset. it works on the datatable inside dataset. Try that.

    Dim dt ds.tables(0)

    Monday, July 11, 2011 3:01 PM
  • foreach doesnt work on dataset. it works on the datatable inside dataset. Try that.

    Dim dt as DataTable =  ds.tables(0)

    Monday, July 11, 2011 3:02 PM
  • I used dataView instead of datatable because it was not there. This corrects the foreach! but i have some trouble with the additem. i guess it is because it cannot find the string value that im putting in as string. here is my code again with the values pointed out that is returning an error.

    conn.ConnectionString = "User Id=a501300;Password=;Data Source=SApdg;";
                    try
                    {
                        const int maxItems_c = 150;
                       conn.Open();
                        string sql = "select insert_id, sai_id, Long_name, Short_name from sa_instrument_basic where rownum <50";
                        
                        Collection collection = new Collection();
                        collection.Name = "learnDB collection";
                        cmd = new OracleCommand(sql, conn);
                        cmd.CommandType = CommandType.Text;
                        da.TableMappings.Add("Table","sa_instrument_basic");
                       
                        da = new OracleDataAdapter(cmd);
                        cb = new OracleCommandBuilder(da);
                        ds = new DataSet();
                        da.Fill(ds);
                        //the dataset cannot be used in a foreach statement so the data is put into the dataView
                        DataView dView = ds.Tables[0].DefaultView;
                        
                        foreach(var sa_instruemtn_basic in dView)
                        {
                            ItemImage image = null;
                            collection.AddItem(sa_instruemtn_basic.SAI_ID, null, null, image, new Facet("Long Name", sa_instruemtn_basic.Long_name));
                                
                        }
                        return collection;

    conn.ConnectionString = ";";

                    try

                    {

                        const int maxItems_c = 150;

                       conn.Open();

                        string sql = "<50";

                        

                        Collection collection = new Collection();

                        collection.Name = "learnDB collection";

                        cmd = new OracleCommand(sql, conn);

                        cmd.CommandType = CommandType.Text;

                        da.TableMappings.Add("Table","");

                       

                        da = new OracleDataAdapter(cmd);

                        cb = new OracleCommandBuilder(da);

                        ds = new DataSet();

                        da.Fill(ds);

                        //the dataset cannot be used in a foreach statement so the data is put into the dataView

                        DataView dView = ds.Tables[0].DefaultView;

                        

                        foreach(var sa_instruemtn_basic in dView)

                        {

                            ItemImage image = null;

                            collection.AddItem(, null, null, image, new Facet("Long Name", .Long_name));

                                

                        }

                        return collection

    is the table and  is a column name

    basically in the add.items i need to reference the table and column names in order to return the facet correct?

    Monday, July 11, 2011 3:44 PM
  • use the .tostring method.

    Can you post the error that you are getting.

    Use the AddItem intellisense to see what item you are supposed to pass into it. i believe everything except the image and facets are strings.

    Monday, July 11, 2011 3:50 PM
  • YOU have to create the objects that you add to the collection, as *I* did when I create "new LastTransmit" that were then added to the list.  And I set the properties of the new object in that line also.

    Monday, July 11, 2011 4:00 PM
  • Ahh okay that makes more sense. i will crunch this sometime soon. thank you for all of the help.

    Monday, July 11, 2011 5:02 PM
  • Okay so i have the data going into a list like we have said above but i need to turn that list into a collection so that it can return a colelction to the pivotviewer colelction control.


    any thoughts?

    Tuesday, July 12, 2011 10:05 AM
  • Yikes, I may have led you astray.  I didn't notice the PivotViewer reference before.  I haven't done these.  But there are links on the web that can probably help.  Here is one:

    http://www.codeproject.com/KB/grid/PivotViewer.aspx

    or maybe this one:

    http://timheuer.com/blog/archive/2010/07/09/data-visualization-with-silverlight-and-pivot-viewer-quickstart.aspx

    Google or Bing for more.

    I suspect there may be a video in the Learn tab about PivotViewer too. 

    I was going down the path of ObservableCollections, for instance, but I think for PivotViewer a collection may be an entirely different beast.

    Tuesday, July 12, 2011 10:23 AM
  • Lol not a problem, I learned a lot from trying these different things. And yes, the appropriate explanation for a pivot viewer collection is beast.

    It seems as if creating JIT Pivotviewer applications is a select crowd... i have read just about every article i can find on creating it but every one differs slightly from what i am using.

    Tuesday, July 12, 2011 11:02 AM
  • I would look at Tim's post first.  He usually does a good job.  Don't know if Mike Taulty has done a pivotviewer, but if he has, he has probably got a good example too.

    Here's a start for Mike's:

    http://mtaulty.com/CommunityServer/blogs/mike_taultys_blog/archive/2010/08/19/pivotviewer-collections-and-the-silverlight-control.aspx

    Tuesday, July 12, 2011 11:21 AM
  • You have to download the pivotservertools project and add that to your solution. add the pivotservertools reference to your project. 

    Now create a class say Test Which inherits CollectionFactoryBase. This class should have your logic for fetching data. Now You have to override the MakeCollection function from the base class. inside it follow the procedure from my previous reply on creating a collection from a dataset.

    http://forums.silverlight.net/forums/t/233950.aspx#575054

    it should look like 

    Public Overrides Function MakeCollection(ByVal context As PivotServerTools.CollectionRequestContext) As PivotServerTools.Collection
    
    Dim c As New Collection    
    
    c.Name = "Test"    
    c.EnableInfoPaneBingSearch = True    
    c.Culture = CultureInfo.GetCultureInfo("en-us")
    
    For Each row As DataRow In myDT.Rows
    
          Dim myName As String = "Test"
    
          Dim myUrl As String = "http:www.google.com"
    
          Dim myDescription As String = String.Empty
    
    
          Dim myFacet As Facet = New Facet("Facet1",    FacetType.Number, 1)
    
          Dim myImage = Nothing
    
          c.AddItem(myName, myUrl, myDescription, myImage, myFacet)               
    
    End
    
    Return c
    
    End Function
    

    Thats it.
    The PivotServertools collection factory picks all classes that inherit from collectionfactorybase. 

    Once you get to this, you are supposed to include handlers in your config file. 
    This piece of code below allows you to view the .cxml file when you run it from visula studio. 
    Replace App.Web with your web project name.

    <httpHandlers>
                <add path="*.cxml" verb="GET" type="App.Web.CxmlHandler"/>
                <add path="*.dzc" verb="GET" type="App.Web.DzcHandler"/>
                <add path="*.dzi" verb="GET" type="App.Web.DziHandler"/>
                <add path="*/dzi/*_files/*/*_*.jpg" verb="GET" type="App.Web.DeepZoomImageHandler"/>
                <add path="*_files/*/*_*.jpg" verb="GET" type="App.Web.ImageTileHandler"/>
    </httpHandlers>

    For it to work when you deploy it to IIS
    <system.webServer>
    <handlers>
    
    <add name="CXML" path="*.cxml" verb="GET" type="App.Web.CxmlHandler"/>
    			<!-- Deep Zoom Collection and Deep Zoom Image XML and image handlers -->
    			<add name="DZC" path="*.dzc" verb="GET" type="App.Web.DzcHandler"/>
    			<add name="DZI" path="*.dzi" verb="GET" type="App.Web.DziHandler"/>
    			<add name="DeepZoomImage" path="*/dzi/*_files/*/*_*.jpg" verb="GET" type="App.Web.DeepZoomImageHandler"/>
    			<add name="ImageTile" path="*_files/*/*_*.jpg" verb="GET" type="App.Web.ImageTileHandler"/>
    		</handlers>
    		
        <staticContent>
            <mimeMap fileExtension=".cxml" mimeType="text/cxml" />
            <mimeMap fileExtension=".dzc" mimeType="text/xml" />
            <mimeMap fileExtension=".dzi" mimeType="text/xml" />
        </staticContent>
    

    and i think iis MIME type are also supposed to be added.
    Finally Your Web Project should have a httphandler. name: HttpHandler.vb

    ' Copyright (c) Microsoft Corporation. All rights reserved.
    
    Imports System
    Imports System.Web
    Imports PivotServerTools
    
    
    ''' <summary>
    ''' Handle a request for any CXML file. See the associated entry in web.config
    ''' This handler finds all implementations of CollectionFactoryBase in any assembly in the bin folder.
    ''' To add your own collection using this method, add a class that implements CollectionFactoryBase
    '''  into the CollectionFactories assembly.
    ''' </summary>
    Public Class CxmlHandler
        Implements IHttpHandler
    
        Public Sub ProcessRequest(ByVal context As HttpContext) Implements System.Web.IHttpHandler.ProcessRequest
            PivotHttpHandlers.ServeCxml(context)
        End Sub
    
        Public ReadOnly Property IsReusable() As Boolean Implements System.Web.IHttpHandler.IsReusable
            Get
                Return True
            End Get
        End Property
        
    End Class
    
    '
    '        //You may use the steps above to create your own collections using the provided generic
    '        // CXML handler. Alternatively, if you want to directly implement your own specific CXML
    '        // handler, uncomment this sample implementation and add a corresponding entry in the
    '        // handlers section of web.config to use this handler. E.g.
    '        //  <add name="MyCXML" verb="GET" path="my.cxml" type="PivotServer.MyCxmlHandler"/>
    '        public class MyCxmlHandler : IHttpHandler
    '        {
    '            public void ProcessRequest(HttpContext context)
    '            {
    '                Collection collection = new Collection();
    '                collection.Name = "My specific collection";
    '                for (int i = 0; i < 10; ++i)
    '                {
    '                    collection.AddItem(i.ToString(), null, null, null);
    '                }
    '
    '                PivotHttpHandlers.ServeCxml(context, collection);
    '            }
    '
    '            public bool IsReusable
    '            {
    '                get { return true; }
    '            }
    '        }
    '    
    
    
    
    Public Class DzcHandler
        Implements IHttpHandler
        Public Sub ProcessRequest(ByVal context As HttpContext) Implements System.Web.IHttpHandler.ProcessRequest
            PivotHttpHandlers.ServeDzc(context)
        End Sub
    
        Public ReadOnly Property IsReusable() As Boolean Implements System.Web.IHttpHandler.IsReusable
            Get
                Return True
            End Get
        End Property
    End Class
    
    
    Public Class ImageTileHandler
        Implements IHttpHandler
        Public Sub ProcessRequest(ByVal context As HttpContext) Implements System.Web.IHttpHandler.ProcessRequest
            PivotHttpHandlers.ServeImageTile(context)
        End Sub
    
        Public ReadOnly Property IsReusable() As Boolean Implements System.Web.IHttpHandler.IsReusable
            Get
                Return True
            End Get
        End Property
    End Class
    
    
    Public Class DziHandler
        Implements IHttpHandler
        Public Sub ProcessRequest(ByVal context As HttpContext) Implements System.Web.IHttpHandler.ProcessRequest
            PivotHttpHandlers.ServeDzi(context)
        End Sub
    
        Public ReadOnly Property IsReusable() As Boolean Implements System.Web.IHttpHandler.IsReusable
            Get
                Return True
            End Get
        End Property
    End Class
    
    
    Public Class DeepZoomImageHandler
        Implements IHttpHandler
        Public Sub ProcessRequest(ByVal context As HttpContext) Implements System.Web.IHttpHandler.ProcessRequest
            PivotHttpHandlers.ServeDeepZoomImage(context)
        End Sub
    
        Public ReadOnly Property IsReusable() As Boolean Implements System.Web.IHttpHandler.IsReusable
            Get
                Return True
            End Get
        End Property
    End Class
    

    The published collection should be in localhost:portnum/publish/Text.cxml
    Once you follow the above and run your project browse to that location if you can see an xml file displayed. Everything will work. 
    Let me know if u find any difficulty.



    Thursday, July 14, 2011 1:04 PM
  • I browse to that location and an xml shows up but it only has 9 items in it. would that mean that my data isnt going through? also if i set the pivot to load the collection directly from localhost/publish/collectionname i get an error

    "Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information."

    any thoughts?

    Thursday, July 14, 2011 3:16 PM
  • If you can browse to the location and see an xml list being displayed. Your collection was published successfully. 

    Now 9 items mean you are adding only 9 items to the collection or the datatable only has 9 rows. if not check that function again.

    finally in the xaml throw a pivotviewer control. in the codebehind 

    in the constructor use

    PivotViewer1.LoadCollection("http://localhost/Publish/Test.cxml", Nothing)

    It should display the collection. 

    watever location you are displaying the xml that location should be fed to the pivotviewer.

    Also if you want to edit the image being displayed play with the DynamicImage.cs file from the servertools. 

    Thursday, July 14, 2011 3:58 PM
  • I continually get the error

    ReflectionTypeLoadException was unhandled by user code:

    "Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information."

    when i try to load the cxml that is being created.

    thanks for all of your help already

    Friday, July 15, 2011 9:42 AM
  • Can you paste your code?, maybe we can figure out wat's goin on.

    Friday, July 15, 2011 12:32 PM

  • Here is my collection factory:
    namespace DBpivot1.web
    {
        partial class sa_isntrument_basic
        {
        }
        public class Learncollectionfactory : CollectionFactoryBase
       
        {            public Learncollectionfactory()
                {this.Name = "learn";
                }
            private OracleConnection conn = new OracleConnection();
            private OracleCommand cmd;
            private OracleDataAdapter da;
            private OracleCommandBuilder cb;
            private DataSet ds;
            private DataTable dt;
            //private OracleDataReader rdr;
           
            public override Collection MakeCollection(CollectionRequestContext context)
               {
    
                    conn.ConnectionString = "private";
                   
                    try
                    {conn.Open();
                        //const int maxItems_c = 150;
                        
                        Collection collection = new Collection();
                        collection.Name = "learnDBcollection";
                       
                     string sql = "Query";
                      cmd = new OracleCommand(sql, conn);
                      cmd.CommandType = CommandType.Text;
                      //da.TableMappings.Add("Table","Instruments");
                      da = new OracleDataAdapter(cmd);
                      cb = new OracleCommandBuilder(da);
                      ds = new DataSet();
                      dt = new DataTable();
                      da.Fill(ds);
                        da.Fill(dt);
                        conn.Close();
    
                      /*   IEnumerable<DataRow> instrumentresults
                            = from row in ds.Tables[0].AsEnumerable()
                              where row.Field<double>("SAI_ID") == 20000003707
                              select row ;
                        foreach (DataRow row in instrumentresults)
                        {ItemImage image = null;
                        collection.AddItem(row.Field<string>("LONG_NAME"), null, null, image, new Facet("long name", row.Field<string>("LONG_NAME")));
                        } */foreach (DataRow row in dt.Rows)
                        {
                            var cname = "learnDBcollection";
                            var curl = "http://www.Fidelity.com/";
                            var cdescr = string.Empty;
                            ItemImage image = null;
                            Facet myfacet = new Facet("sai_id", FacetType.Number, 1);
                           collection.AddItem(cname, curl, cdescr, image, myfacet);
                        }
                        collection.SetFacetDisplay("sai_id", true, true, true);
    
                    
                        return collection;
                        
                        } 
                    catch (Exception ex)
    
                    {
                        return ErrorCollection.FromException(ex);
    
                    }
                   
               
              }
            //DataClasses1DataContext i_datacontext = new DataClasses1DataContext();
        } 
    }  
    here is my handler:
        
    namespace DBpivot1.Web
    {
       public class CxmlHandler : IHttpHandler
        {
            public void ProcessRequest(HttpContext context)
            {
                PivotHttpHandlers.ServeCxml(context);
            }
    
            public bool IsReusable
            {
                get { return true; }
            }
        } 
            //You may use the steps above to create your own collections using the provided generic
            // CXML handler. Alternatively, if you want to directly implement your own specific CXML
            // handler, uncomment this sample implementation and add a corresponding entry in the
            // handlers section of web.config to use this handler. E.g.
            //  <add name="MyCXML" verb="GET" path="my.cxml" type="PivotServer.MyCxmlHandler"/>
          /*  public class CxmlHandler : IHttpHandler
            {
                public void ProcessRequest(HttpContext context)
                {
                    Collection collection = new Collection();
                    collection.Name = "My specific collection";
                    for (int i = 0; i < 10; ++i)
                    {
                        collection.AddItem(i.ToString(), null, null, null);
                    }
    
                    PivotHttpHandlers.ServeCxml(context, collection);
                }
    
                public bool IsReusable
                {
                    get { return true; }
                }
            }*/
        
    
    
        public class DzcHandler : IHttpHandler
        {
            public void ProcessRequest(HttpContext context)
            {
                PivotHttpHandlers.ServeDzc(context);
            }
    
            public bool IsReusable
            {
                get { return true; }
            }
        }
    
    
        public class ImageTileHandler : IHttpHandler
        {
            public void ProcessRequest(HttpContext context)
            {
                PivotHttpHandlers.ServeImageTile(context);
            }
    
            public bool IsReusable
            {
                get { return true; }
            }
        }
    
    
        public class DziHandler : IHttpHandler
        {
            public void ProcessRequest(HttpContext context)
            {
                PivotHttpHandlers.ServeDzi(context);
            }
    
            public bool IsReusable
            {
                get { return true; }
            }
        }
    
    
        public class DeepZoomImageHandler : IHttpHandler
        {
            public void ProcessRequest(HttpContext context)
            {
                PivotHttpHandlers.ServeDeepZoomImage(context);
            }
    
            public bool IsReusable
            {
                get { return true; }
            }
        }

    and the error im getting is on this page
    namespace PivotServerTools.Internal
    {
        using System;
        using System.Collections.Generic;
        using System.IO;
        using System.Reflection;
    
    
        /// <summary>
        /// Methods to locate assemblies and classes that implementat CollectionFactoryBase
        /// </summary>
        internal static class FactoryClassFinder
        {
            // Public Methods
            //======================================================================
    
            /// <summary>
            /// Return new instances of all classes deriving from CollectionFactoryBase
            /// from all assemblies in the given folder.
            /// </summary>
            public static IEnumerable<CollectionFactoryBase> Find(string folderPath)
            {
                List<CollectionFactoryBase> factories = new List<CollectionFactoryBase>();
    
                foreach (Type t in EnumerateTypesInAssemblies(folderPath))
                {
                    if (t.IsSubclassOf(typeof(CollectionFactoryBase)))
                    {
                        CollectionFactoryBase factory = (CollectionFactoryBase)Activator.CreateInstance(t);
                        if (string.IsNullOrEmpty(factory.Name))
                        {
                            factory.Name = t.Name;
                        }
    
                        factories.Add(factory);
                    }
                }
                return factories;
            }
    
    
            // Private Methods
            //======================================================================
    
            private static IEnumerable<Assembly> EnumerateAssemblies(string folderPath)
            {
                string[] dllFilePaths = Directory.GetFiles(folderPath, "*.dll");
                foreach (string filePath in dllFilePaths)
                {
                    Assembly assembly = Assembly.LoadFrom(filePath);
                    yield return assembly;
                }
            }
    
            private static IEnumerable<Type> EnumerateTypesInAssemblies(string folderPath)
            {
                Assembly thisAssembly = Assembly.GetExecutingAssembly();
    
                foreach (Assembly assembly in EnumerateAssemblies(folderPath))
                {
                    if (assembly != thisAssembly) //Ignore types in this PivotServerTools assembly.
                    {
                        Type[] types = assembly.GetTypes();
                        foreach (Type t in types)
                        {
                            yield return t;
                        }
                    }
                }
            }
        }
    
    }
    


    The error on this is happening with the "type[] types = assembly.GetTypes();" line in the third codeblock  When i change the path the pivot refers too to something arbitrary the app runs fine (but with no collection). but when it is pointed to a the collection i get the error i was saying before. so i am assuming it has something to do with the collection factory page.

    any help would be great. Thanks

    Friday, July 15, 2011 1:13 PM
  • Try changing this from Facet myfacet = new Facet("sai_id", FacetType.Number, 1);

    Facet myfacet = new Facet("sai_id", FacetType.Number, "1");

    if still it doesnt work, as far as i know there is something erroring out in this function. debug it through each step. see if you can find something.

    Friday, July 15, 2011 2:04 PM
  • Did it work? 

    Thursday, July 21, 2011 2:30 PM
  • It is working great now. thank you for all of your help

    once i got past this problem everything fell into place.

    Thursday, July 21, 2011 4:14 PM
  • mark my post as answered please. appreciate it.

    So What was the error?, maybe it can help others.

    Thursday, July 21, 2011 4:29 PM