This is a migrated thread and some comments may be shown as answers.

RadScheduler, MS Exchange, and GetResource

4 Answers 92 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Brian
Top achievements
Rank 1
Brian asked on 30 Aug 2011, 06:08 PM

Hello,

I think I am in need of some basics.

I am looking over this demo and within the example code, I don't understand what the arguments represent within the GetResource method:

    protected void RadScheduler1_AppointmentInsert(object sender, SchedulerCancelEventArgs e) {
        if (e.Appointment.Resources.Count < 1)
            e.Appointment.Resources.Add(RadScheduler1.Resources.GetResource("Calendar", "1"));
    }

When I look at the DefaultCS.aspx included with the demo, I see where there is a title for a <div> set to "Calendar". That's the only object I see named as "Calendar". That being the case, I don't understand what GetResource is referring, and I don't understand what the second argument ("1") means either. Therefore, I don't know how to translate this demo into what I am trying to do.

What I want to do is add appointments to MSExchange. Right now, my page containing a RadScheduler is capable of displaying appointments that were already added to Exchange via Outlook. What I want to do is add the appointments via the scheduler control, instead of thru Outlook. But on my page, when I try to execute the command-line containing the GetResource method, I encounter a Null exception as follows:

System.ArgumentNullException was unhandled by user code
Message=Value cannot be null.
Parameter name: value
Source=System.Web
ParamName=value
StackTrace:
at System.Web.UI.StateManagedCollection.OnValidate(Object value)
at System.Web.UI.StateManagedCollection.System.Collections.IList.Add(Object value)
at Telerik.Web.StronglyTypedStateManagedCollection`1.Add(ItemType item)
at _Schedule.radScheduler_AppointmentInsert(Object sender, SchedulerCancelEventArgs e)
at Telerik.Web.UI.RadScheduler.OnAppointmentInsert(AppointmentInsertEventArgs args)
at Telerik.Web.UI.RadScheduler.ProcessPostBackCommand(SchedulerPostBackEvent postBack)
at Telerik.Web.UI.RadScheduler.RaisePostBackEvent(String eventArgument)
at Telerik.Web.UI.RadScheduler.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
InnerException:

I believe the Add method is what actually fails, since GetResource is returning a Null. But I don't know what to plug in as valid arguments for GetResource(). I've tried what I think would be logical values, all of which have resulted in the same Null exception. Here is my latest event method:

    protected void radScheduler_AppointmentInsert(object sender, SchedulerCancelEventArgs e) {
        GenericCollection<ExchangeAPI.Calendar> calAppts = ExchangeAPI.Calendar.GetAll(this.txtUsername.Text,
                                                                                       this.radScheduler.VisibleRangeStart,
                                                                                       this.radScheduler.VisibleRangeEnd);
        radScheduler.DataSource = calAppts;
        radScheduler.DataBind();

        if (e.Appointment.Subject == String.Empty) {
            e.Cancel = true;
        }
        else {
            //this.radScheduler.InsertAppointment(e.Appointment);

            if (e.Appointment.Resources.Count < 1)
                //e.Appointment.Resources.Add(radScheduler.Resources.GetResource("Calendar", "1"));
                e.Appointment.Resources.Add(radScheduler.Resources.GetResource(radScheduler.DataSourceID, "1"));
        }

The error always occurs on the last command-line that you see above. BTW, I use practically the same code (as above) to display the existing appointments in the RadScheduler. The only thing I am doing differently in the above event is that I am including the command to insert a new appointment, and that is the command that fails.

I am sure that I am mis-understanding some basics here. Can someone please help?

Thanks,
Steven

4 Answers, 1 is accepted

Sort by
0
Brian
Top achievements
Rank 1
answered on 31 Aug 2011, 04:24 PM
When I am in Outlook and I right-click on any user's calendar and click Properties, it looks like the default name assigned to each is literally "Calendar". Is this why the first argument for GetResource method references "Calendar"?

What does the second argument ("1") represent?
0
Plamen
Telerik team
answered on 02 Sep 2011, 03:34 PM
Hi Steven,

I've already answered your support ticket regarding the same issue. Here is my answer:

'The code that you are asking for is the one that is setting the default selected resource value so the appointments can be colored in different color. "Calendar" is the name of the type of the resource from the  code below:

<telerik:ResourceStyleMapping Type="Calendar" Text="Development" ApplyCssClass="rsCategoryPattern" BorderColor="#B0CC9B" />
<telerik:ResourceStyleMapping Type="Calendar" Text="Marketing" ApplyCssClass="rsCategoryRed" />
<telerik:ResourceStyleMapping Type="Calendar" Text="Work" BackColor="#edd5b7" BorderColor="#cdb597" />

The value "1" is the index of the combobox which have to be set if it is not set.'

Hope this information will be helpful.

Best wishes,
Plamen Zdravkov
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
BRIAN
Top achievements
Rank 1
answered on 02 Sep 2011, 04:04 PM
so why does the AppointmentInsert encounter a null exception when we switch this demo example from an XML provider to an Exchange provider???

We are using your demo as-is, which btw, does not actually store any appointments in the XML file. When you add a new appointment and click [Save], it appears to have stored the new appointment, cuz when you click on some other calendar day, and then go back to the day that you were on, your new appointment is displayed. But if you close and reopen the page, the new appointment is not there. Scanning the XML file shows that the new appointment was not actually saved to the file. But I'm not really interested in t-shooting this issue.

What I want to know is why the null exception occurs with an Exchange provider, but not with the XML provider. When taking this same demo, and switching it from an XML provider to an Exchange provider (based on this resource), the AppointmentInsert encounters a null exception. The only thing we have changed was the switch from XML to Exchange provider. The Exchange provider *does* display our appointments within the scheduler, so it appears to be working (initially). But when trying to save a new appointment, AppointmentInsert encounters the null exception. That's my real issue and that's what I need to resolve.

Can you help?
0
Plamen
Telerik team
answered on 07 Sep 2011, 11:57 AM
Hi Brian,

In the demo that you are using as a sample is used session on purpose so the changes in the XML provider are deliberately reset when the page is refreshed.

You can refer with this forum post about the exchange provider.

If you still have problem you can isolate the problem in sample running project and send it to us via support ticket so we could  research it locally and provide you with the most appropriate solution.

All the best,
Plamen Zdravkov
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Tags
Scheduler
Asked by
Brian
Top achievements
Rank 1
Answers by
Brian
Top achievements
Rank 1
Plamen
Telerik team
BRIAN
Top achievements
Rank 1
Share this question
or