Webservice, SQL DataBase and Recurrence

13 posts, 1 answers
  1. Daniel Mettler
    Daniel Mettler avatar
    20 posts
    Member since:
    Apr 2003

    Posted 29 Apr 2009 Link to this post

    Hi

    Im trying to update my scheduler with a webservice an get the data from a sql database. I changed the GetAppointments Method in the Webservice:

    Something like this:
    [WebMethod]  
        public IEnumerable<AppointmentData> GetAppointments(chedulerInfo schedulerInfo)  
        {  
            List<AppointmentData> lstAppointments = new List<AppointmentData>();  
              
            foreach (object AppointmentInformations in ObjectCollection)  
            {  
                Appointment NewAppointment = new Appointment();  
                
                Appointment.Recurrence = "..........";
                Appointment.... 
                // Fill the NewAppointment with stuff from database  
     
                AppointmentData AppData = new AppointmentData();  
                AppData.CopyFrom(NewAppointment);  
                lstAppointments.Add(AppData);  
            }  
              
            return lstAppointments;  
        } 

    In the database, there is a string field which contains the recurrence string, how can i handle this. The recurring appointments are not visible in the scheduler.

    Do you have a code example or something?

    Thx for help
  2. Answer
    Peter
    Admin
    Peter avatar
    6637 posts

    Posted 30 Apr 2009 Link to this post

    Hi Daniel,

    You should not modify the GetAppointments method in the web service class. Instead, you should use a provider and set the WebServiceAppointmentController to use this provider.

    I have prepared a demo project which uses Web Services with MyDbSchedulerProvider.cs. MyDbSchedulerProvider on its part uses Telerik.mdf -> [DbProvider_Classes] data table. The provider is configured in the web.config and the controller's constructor uses the provider name string:

    * * *  
     
    _controller = new WebServiceAppointmentController("MyDBSchedulerProvider");   
     
    * * * 

    The web.config settings related to the provider are as follows:
     <sectionGroup name="telerik.web.ui">  
          <section name="radScheduler" type="Telerik.Web.UI.RadSchedulerConfigurationSection, Telerik.Web.UI" allowDefinition="MachineToApplication" requirePermission="false"/>  
        </sectionGroup> 
     
    * * *   
     
        <connectionStrings> 
      <add name="TelerikConnectionString1" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Telerik.mdf;Integrated Security=True;User Instance=True" 
       providerName="System.Data.SqlClient" /> 
     </connectionStrings> 
     
    * * *  
     
     <telerik.web.ui> 
        <radScheduler defaultAppointmentProvider="Integrated">  
          <appointmentProviders> 
            <add name="MyDBSchedulerProvider" type="MyDbSchedulerProvider" connectionStringName="TelerikConnectionString1" persistChanges="true"/>  
          </appointmentProviders> 
        </radScheduler> 
      </telerik.web.ui> 

    Let me know if you have further questions.


    Best wishes,
    Peter
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Michael
    Michael avatar
    21 posts
    Member since:
    Aug 2008

    Posted 06 May 2009 Link to this post

    Peter,

    When I attempt to run the same application attached, I get the following error when accessing the web service. 

    Cannot serialize interface System.Collections.Generic.IEnumerable`1[[Telerik.Web.UI.AppointmentData, Telerik.Web.UI, Version=2009.1.402.35, Culture=neutral, PublicKeyToken=121fae78165ba3d4]].

    I copied all of the files to a new virtual directory and attempted to call both default.aspx and schedulerwebservice.asmx.  Both return the same error.  Any ideas what I am missing?  Thank you.

    Michael
  5. Jan
    Jan avatar
    20 posts
    Member since:
    Aug 2008

    Posted 23 Jul 2009 Link to this post

    Hello,

    I have the same issue - Cannot serialize interface System.Collections.Generic.IEnumerable`1[[Telerik.Web.UI.AppointmentData, Telerik.Web.UI, Version=2009.2.701.20, Culture=neutral, PublicKeyToken=121fae78165ba3d4]].

    Do You any idea how to solve it?

    Thank You Jan
  6. Sergio
    Sergio avatar
    2 posts
    Member since:
    May 2009

    Posted 27 Jul 2009 Link to this post

    Same here.

    Thanks
  7. T. Tsonev
    Admin
    T. Tsonev avatar
    2771 posts

    Posted 29 Jul 2009 Link to this post

    Hi,

    I guess that you're getting this error when you're trying to open the web service handler directly in the browser?

    The automatically generated test page doesn't support script services and it tries to access the service using SOAP. Which in turn doesn't support IEnumerable and generates the error in question.

    The service will work fine when invoked by RadScheduler with the correct transport type (JSON).

    Kind regards,
    Tsvetomir Tsonev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  8. Yeroon
    Yeroon avatar
    87 posts
    Member since:
    Oct 2012

    Posted 20 Aug 2009 Link to this post

    Hi,

    I got the sample to work. Now I was wondering if I can work with filtered datasets in the webmethods. I don't want to retrieve all appointments, but just limited sets. E.g. fltered by employee and date.

    How can I achieve this?

    I would like to be able to call something like this:

     [WebMethod]  
        public IEnumerable<AppointmentData> GetAppointments(SchedulerInfo schedulerInfo, DateTime day, long EmployeeID)  
        {  
            return Controller.GetAppointments(schedulerInfo, day, EmployeeID);  
        } 

    Which would then be used in the underlying query in the provider:

    cmd.CommandText = "SELECT [ClassID], [Subject], [Start], [End], [RecurrenceRule], [RecurrenceParentId] FROM [DbProvider_Classes] WHERE Start=" + day + " AND TeachID =" + EmployeeID ; 

    Any way of achieving this? I will be getting thousands of entries in the appointments table and can't afford to retrieve them all everytime.

    Thx for any help

    Yeroon
  9. peter brandt
    peter brandt avatar
    2 posts
    Member since:
    Oct 2009

    Posted 07 Oct 2009 Link to this post

    Hi

    If i want to set a Webreference to the Webservice with the SchedulerWebservice Webmethods it always says:

    "Cannot serialize interface System.Collections.Generic.IEnumerable`1[[Telerik.Web.UI.AppointmentData, Telerik.Web.UI, Version=2009.1.402.35, Culture=neutral, PublicKeyToken=121fae78165ba3d4]]."

    like by the other people here.
    Now i dont know what to do with your "correct transport type (JSON)"...

    I have all my Webservices already done, but only the RadScheduler Webservice doesnt work...
    What can i do now?
    How to transfer by JSON?


    Peter

  10. T. Tsonev
    Admin
    T. Tsonev avatar
    2771 posts

    Posted 09 Oct 2009 Link to this post

    Hi,

    Do you get this error when you try to access the Web Service handler in your browser? This is normal, as ASP.NET tries to generate an user-friendly test page, but fails as it can only do so for a SOAP-based services and not for JSON ones.

    You can proceed and add the reference to RadScheduler and it'll work.

    Best wishes,
    Tsvetomir Tsonev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  11. PAUL HAY
    PAUL HAY avatar
    1 posts
    Member since:
    Aug 2005

    Posted 17 Oct 2013 Link to this post

    How do you add the reference when visual studio reports the Cannot serialize interface System.Collections.Generic.IEnumerable error in the add web reference dialogue and won't let you continue.
  12. Piyushkumar
    Piyushkumar avatar
    25 posts
    Member since:
    Nov 2010

    Posted 27 Jan 2014 Link to this post

    Hi Admin (T. Tsonev),

    With regard to your following comment: ===>
       "The automatically generated test page doesn't support script services and it tries to access the service using SOAP.
         Which in turn doesn't support IEnumerable and generates the error in question.

        The service will work fine when invoked by RadScheduler with the correct transport type (JSON)." <===

    It should have been mentioned in the help document under "Implementing Provider".
    It took me 3-4 days to figure out the issue and still struggling with it.

    Frustrating.




  13. Boyan Dimitrov
    Admin
    Boyan Dimitrov avatar
    1746 posts

    Posted 30 Jan 2014 Link to this post

    Hello,

    Thank you for the provided information.

    I would like to assure you that we will investigate this question thoroughly and update the documentation if need.

    Thank you for your cooperation.

    Regards,
    Boyan Dimitrov
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the UI for ASP.NET AJAX, subscribe to the blog feed now.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017