Sending extra info to the web service

26 posts, 0 answers
  1. broctune
    broctune avatar
    6 posts
    Member since:
    Feb 2007

    Posted 31 Mar 2009 Link to this post

    I'm using The Q1 2009 Scheduler control with a Web Service data source.  I would like to pass some extra information to the GetAppointments web method that will determine which types of appointments are returned.  The only parameter of this method is of type SchedulerInfo and that object only has 2 properties: ViewStart and ViewEnd.  Is there a way to pass any additional information?  I would like to use the OnClientAppointmentsPopulating event to add more data to the Scheduler Info object.

    Any ideas?

    Thanks,
    Dave
  2. T. Tsonev
    Admin
    T. Tsonev avatar
    2784 posts

    Posted 03 Apr 2009 Link to this post

    Hello,

    Thank you for the excellent question. You're on the right track - the populating event is exactly what you need. You can add your custom fields like this:

    function aptsPopulating(sender, eventArgs)
    {
        var info = eventArgs.get_schedulerInfo();
        info.MyCustomInfo = "Test";
    }


    In order to read this on the server you need to inherit the SchedulerInfo class:

    public class MySchedulerInfo : SchedulerInfo
    {
        private string _myCustomInfo;

        public string MyCustomInfo
        {
            get
            {
                return _myCustomInfo;
            }

            set
            {
                _myCustomInfo = value;
            }
        }
    }

    [WebMethod]
    public IEnumerable<AppointmentData> GetAppointments(MySchedulerInfo schedulerInfo)
    {
        string info = schedulerInfo.MyCustomInfo;
        // ...
    }

    Serialization shouldn't be an issue with most types. Dates are a bit trickier as you need to compensate for the client browser time zone offset, as they are serialized as ticks. We do this in RadScheduler, but for simplicity I recommend you to pass them as strings in a well known format.

    Regards,
    Tsvetomir Tsonev
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
  3. Raj Nemani
    Raj Nemani avatar
    20 posts
    Member since:
    Sep 2007

    Posted 21 Apr 2009 Link to this post

    Hi,

    As a follow up, I was wondering if you can answer this question

    I have the following WebserviceappointmentController classs, shown partially here

     

    public class SchedulerService : ISchedulerService

     

    {

     

    private WebServiceAppointmentController _controller;

     

     

    private WebServiceAppointmentController Controller

     

    {

     

    get

     

    {

     

    if (_controller == null)

     

    {

    _controller =

     

    new WebServiceAppointmentController(new SchedulerServiceProvider());

     

    }

     

    return _controller;

     

    }

    }

     

    public IEnumerable<AppointmentData> GetAppointments(MySchedulerInfo schedulerInfo)

     

    {

     

    return Controller.GetAppointments(schedulerInfo);

     

    }

    .....
    .....

    When GetAppointment is called, the call to Controller.GetAppointments correctly takes me to the GetAppointments method of ScheduleServiceProvider which inherits SchedulerProviderBase class.  But with in the GetAppointments method of this ScheudleService provider,I cannot see a way to get  bavck to MySchedulerInfo and the my custom data in there.  If I cannot get to it then I cannot do much becasue all the backend stuff to get appointment data happens in ScehduleService provider based on the MySchedulerInfo data. 

    I hope you will be able to throw some light on this. 

    Thanks
    Raj

     

  4. T. Tsonev
    Admin
    T. Tsonev avatar
    2784 posts

    Posted 24 Apr 2009 Link to this post

    Hi,

    Thank you for the excellent question. It's true that the existing SchedulerProvider interface limits us in our options to pass information to the provider. We are considering improving it, but for the moment there are two options:

    1. Use the session to pass parameters:
    [WebMethod(EnableSession = true)]
    public IEnumerable<AppointmentData> GetAppointments(MySchedulerInfo schedulerInfo)
    {
        Session["Data"] = schedulerInfo.Data;
        return Controller.GetAppointments(schedulerInfo);
    }

    // Provider code:
    int Data = (int) HttpContext.Current.Session["Data"];

    2. Instantiate the provider per request and use its public properties to pass parameters.

    I hope this helps.

    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.
  5. Paige Cook
    Paige Cook avatar
    57 posts
    Member since:
    Sep 2007

    Posted 14 Aug 2009 Link to this post

    Hi,

    I wanted to see if there had been any improvements to the SchedulerProvider to allow for sending additional information to the provider. I am looking at implementing the WCF services, if that makes any difference. 

    I saw that there is now GetAppointmentsMethod property of the WebServices attribute and wondered if that could be leveraged in this way. if so, could you provide a code sample?

    Also, I really like the addition of the SchedulerOperationResult class that can be used to pass extra data back along with the appointments. I think that will be very useful.

    Thanks,
    Paige


    Thanks.
  6. T. Tsonev
    Admin
    T. Tsonev avatar
    2784 posts

    Posted 19 Aug 2009 Link to this post

    Hi,

    We still haven't implemented the improvements to the SchedulerProvider abstract base class. The Session and directly referencing the provider instance remain the only two options for passing additional information to the provider.

    The GetAppointmentsMethod property only specifies the Web Service method name to be used for retrieving appointments and has no other uses.

    Sincerely yours,
    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.
  7. Paige Cook
    Paige Cook avatar
    57 posts
    Member since:
    Sep 2007

    Posted 20 Aug 2009 Link to this post

    Hi Tesvetomir,

    Thank you for the update, I appreciate it. Do you know if there is a targeted release yet for making improvements to the SchedulerProvider abstract base to accommodate passing additional information?


    Thank You,
    Paige
  8. T. Tsonev
    Admin
    T. Tsonev avatar
    2784 posts

    Posted 26 Aug 2009 Link to this post

    Hi,

    I'm not sure if time will allow us to complete these improvements for the Q3 release, as we already have a lot of work in the pipeline. We'll be working on a prototype meanwhile, but for now our primary objective is to get feedback from the community.

    Sincerely yours,
    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.
  9. Michael
    Michael avatar
    27 posts
    Member since:
    Feb 2008

    Posted 28 Oct 2009 Link to this post

    Do you have an example of how to do option 2:

    2. Instantiate the provider per request and use its public properties to pass parameters.
  10. T. Tsonev
    Admin
    T. Tsonev avatar
    2784 posts

    Posted 03 Nov 2009 Link to this post

    Hi Michael,

    This is what I had in mind:

    [WebMethod]
    public IEnumerable<AppointmentData> GetAppointments(MySchedulerInfo schedulerInfo)
    {
        MySchedulerProvider provider = new MySchedulerProvider(...);
     
        provider.Property = MySchedulerInfo.Property;
     
        WebServiceAppointmentController controller = new WebServiceAppointmentController(provider);
     
        return controller.GetAppointments(schedulerInfo);
    }

    You can use your implementation of ISchedulerInfo to pass additional data as described earlier. Then you set a property on the provider to let it know about the additional data.

    The drawback is that the provider must be instantiated on each request, while its normally shared between requests.

    All the best,
    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. towpse
    towpse avatar
    224 posts
    Member since:
    Mar 2008

    Posted 23 Nov 2009 Link to this post

    All that's been discussed makes sense for the populating method since you can get at a scheduler info
    function AppointmentsPopulating(sender, eventArgs) { 
        var info = eventArgs.get_schedulerInfo(); 
        info.ObjectId = "BEE39F67-3737-4A05-9AA3-DD61D9CCEE77"; //TODO get Object ID from UI

    What about on Insert, update, delete methods? How do I accomplish this when all I have access to in this case is the appointment object which as far as I can tell right now does not expose a scheduler info? Is that right?
    function AppointmentWebServiceInserting(sender, eventArgs) { 
        //get object Id from UI and pass it along to the scheduler info so I can get at the object Id from the web service

    I will then need to obtain the object Id in the web service
            [WebMethod] 
            public IEnumerable<AppointmentData> InsertAppointment(OutputControlSchedulerInfo schedulerInfo, AppointmentData appointmentData) 
            { 
                if (!string.IsNullOrEmpty(appointmentData.RecurrenceRule)) 
                { 
                    appointmentData.RecurrenceState = RecurrenceState.Master; 
                } 
                MyScheduleProvider provider = new MyScheduleProvider(); 
                provider.ObjectId = schedulerInfo.ObjectId; 
                WebServiceAppointmentController controller = new WebServiceAppointmentController(provider); 
                return controller.InsertAppointment(schedulerInfo, appointmentData); 
            } 

    Does this make sense at all?

    EDIT What event gets fired on the client-side when the save button is clicked on the Advanced Form?
    Where do I handle that event and pass an object ID to the web service so it can pass that Id onto the provider?

    EDIT yeah it seems i do have the scheduler info on the web service insert! very nice.

    thanks
  12. Peter
    Admin
    Peter avatar
    6637 posts

    Posted 24 Nov 2009 Link to this post

    Hello towps,

    Thank you for posting these questions and thus enriching the discussion. It seems you were able to find the answers yourself, but feel free to contact us if you have further questions or concerns.


    All the best,
    Peter
    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.
  13. towpse
    towpse avatar
    224 posts
    Member since:
    Mar 2008

    Posted 26 Nov 2009 Link to this post

    What is the purpose of using this web service appointment controller object in the following code?

        MySchedulerProvider provider = new MySchedulerProvider(...);  
       
        provider.Property = MySchedulerInfo.Property;  
       
        WebServiceAppointmentController controller = new WebServiceAppointmentController(provider);  
       
        return controller.GetAppointments(schedulerInfo); 

    When in this case I coould just as easily call provider.GetAppointments?
    What does this technique buy?
  14. T. Tsonev
    Admin
    T. Tsonev avatar
    2784 posts

    Posted 01 Dec 2009 Link to this post

    Hello,

    The WebServiceAppointmentController.GetAppointments method takes care of filtering only the visible appointments and for expanding recurring series.

    It's meant to be a bridge between the provider and the control instance and to encapsulate the logic that links them together.

    I hope this helps.

    Greetings,
    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.
  15. Jimmy Jou
    Jimmy Jou avatar
    3 posts
    Member since:
    Jul 2009

    Posted 04 Dec 2009 Link to this post

    While we are on the subject of passing extra data from Scheduler to web service using custom scheduler provider, I like to ask if there is a way to pass the hosting web site URL to custom scheulder provider? I saw RadScheduler has data member Site, Page, and Parent. But they are all null when reaching web service side.

    Is session the only way to pass back the web page URL that hosts the Scheduler? By the way, I am working in SharePoint environment and the hosting site URL is the most popular parameter to hold on.
  16. T. Tsonev
    Admin
    T. Tsonev avatar
    2784 posts

    Posted 08 Dec 2009 Link to this post

    Hello Jimmy,

    I can confirm that at the moment the two options for passing information to the provider are:

    1. Transfer information via the Session
    2. Instantiate the provider per request and use its public properties to pass parameters

    Those are described in the forum thread and we can provide samples if necessary.

    We have plans to improve this by updating the RadScheduler provider interface, but it's unlikely that we'll be able to complete these changes in time for the next release.

    All the best,
    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.
  17. Ryan Eaves
    Ryan Eaves avatar
    4 posts
    Member since:
    Mar 2006

    Posted 01 Sep 2010 Link to this post

    I just wanted to add something to this thread for others who are reading it and can't see how to use your custom fields during Web Services Update/Insert/Delete. Two helpful things that are not documented:

    1) The OnClientAppointmentsPopulating event gets fired even when the Scheduler is doing a WebServices Update/Insert/Delete. So if you are using the same values in each operation, then you can just add the values to the SchedulerInfo object in this event and they will be present during all operations.

    2) Even though it's not currently listed in the documentation, you can access the SchedulerInfo in the Web Services Update/Insert/Delete client-side events like this: eventArgs.get_schedulerInfo(). So, if you have different values you want to add for each operation, you can do so in the appropriate client-side event.

    -Ryan
  18. T. Tsonev
    Admin
    T. Tsonev avatar
    2784 posts

    Posted 25 Oct 2010 Link to this post

    Hi,

    I'd like to announce that we've made improvements to the provider interface of RadScheduler that make sending extra data much easier. Read more here: http://blogs.telerik.com/tsvetomirtsonev/posts/10-10-25/radscheduler_for_asp_net_ajax_-_improvements_to_provider_interface_in_q3_2010.aspx

    Please feel free to try the Q3 2010 Beta and let us know if you have any comments.

    Ryan, thanks for sharing the hints - we're updating the documentation right now and we'll try to make these possibilities clear.

    Greetings,
    Tsvetomir Tsonev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  19. towpse
    towpse avatar
    224 posts
    Member since:
    Mar 2008

    Posted 26 Oct 2010 Link to this post

    Did you folks attack the issue of rendering many appointments on the UI in IE?
    When the scheduler needs to render many daily appointments in month view, even though it only displays 2 per day, the total number of appointments can be quite large and unfortunately the scheduler returns and iterates through all though it really needs to only worry about 2 per day.
    This causes IE to be unresponsive. Not sure if anyone on your end has started looking at that issue yet.

    cheers
  20. T. Tsonev
    Admin
    T. Tsonev avatar
    2784 posts

    Posted 27 Oct 2010 Link to this post

    Hi Matt,

    Yes, we're working on this problem as well. The official release will be a bit smarter about the extra appointments and will trim them before leaving the web service.

    I hope this helps.

    Greetings,
    Tsvetomir Tsonev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  21. Matthew
    Matthew avatar
    16 posts
    Member since:
    Dec 2010

    Posted 01 Jun 2011 Link to this post

    Hi there,

    I've been looking at this thread, and this section in the online documentation:

    http://www.telerik.com/help/aspnet-ajax/scheduler-sending-additional-information-to-the-web-service.html


    But I'm struggling to make my radscheduler populate from my web service at the moment.

    I've got the following in my sheduler control
    <WebServiceSettings Path="~/Services/Calendar_Service.asmx" />
    

    And have a javascript function being called with the 'OnClientAppointmentsPopulating', which sets my accountid property :
    eventArgs.get_schedulerInfo().AccountID
    

    I've my own SchedulerInfo class:

    public class MySchedulerInfo : SchedulerInfo
    {
        public int AccountID { get; set; }
        public MySchedulerInfo(ISchedulerInfo baseInfo, int accountid)
            : base(baseInfo)
        {
            AccountID = accountid;
        }
    }

    My web service takes an object of this class as a param:

    [WebMethod]
    public IEnumerable<AppointmentData> GetAppointments(MySchedulerInfo schedulerInfo)
    {
        return Controller.GetAppointments(schedulerInfo);
    }

    And I have my own custom provider that takes an ISchedulerInfo param with it's 'GetAppointments' method.


    However, when I run this, I just get a javascript alert with the following error (twice):

    "No parameterless constructor defined for type of 'Classes.MySchedulerInfo'"


    I've tried to do this as per the instructions, what am I missing?
  22. Veronica
    Admin
    Veronica avatar
    1213 posts

    Posted 01 Jun 2011 Link to this post

    Hi Ryan Eaves,

    This error is self-descriptive:  you don't have parameterless constructor in the MySchedulerInfo class. Please add the following constructor and everything will work OK:

    public class MySchedulerInfo : SchedulerInfo
    {
        public int AccountID { get; set; }
        public MySchedulerInfo(ISchedulerInfo baseInfo, int accountid)
            : base(baseInfo)
        {
            AccountID = accountid;
        }
          
        public MySchedulerInfo()
        {
      
        }
    }


    All the best,
    Veronica Milcheva
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  23. Matthew
    Matthew avatar
    16 posts
    Member since:
    Dec 2010

    Posted 01 Jun 2011 Link to this post

    That's far too obvious! That worked, thanks for that. It might be worth updating your documentation, as I just copied and pasted the class from there:

    http://www.telerik.com/help/aspnet-ajax/scheduler-sending-additional-information-to-the-web-service.html
  24. Veronica
    Admin
    Veronica avatar
    1213 posts

    Posted 01 Jun 2011 Link to this post

    Hello Ryan Eaves,

    You are definitely right that the documentation needs improvement. Thank you!

    Best wishes,
    Veronica Milcheva
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  25. Kuldeep
    Kuldeep avatar
    25 posts
    Member since:
    May 2013

    Posted 20 May 2013 Link to this post

    How I will access the scheduler info in wcf ??

  26. Plamen
    Admin
    Plamen avatar
    2790 posts

    Posted 22 May 2013 Link to this post

    Hi,

     You can refer to this Code Library where are provided all the steps to sent more information to the service. The steps are exactly the same in scenario with WCF service.

    Hope this will be helpful.

    Regards,
    Plamen
    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 RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top