Hello.
I have built a very simple web page (Default.aspx) with the RadScheduler component:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %> <%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <telerik:RadScheduler ID="RadScheduler1" runat="server"> <WebServiceSettings Path="/App_Code/Service1.svc" ResourcePopulationMode="ServerSide" /> </telerik:RadScheduler> </div> </form> </body> </html>and I have tried to integrate it with an AJAX-enabled web service (Service1.svc.cs):
using System; using System.Runtime.Serialization; using System.ServiceModel; using System.ServiceModel.Activation; using System.ServiceModel.Web; using System.Data.Common; using Telerik.Web.UI; using System.Collections.Generic; using System.Data.SqlClient; using System.Configuration; namespace WebApplication1 { [ServiceContract(Namespace = "")] [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] [ServiceBehavior(IncludeExceptionDetailInFaults = true)] public class Service1 { private WebServiceAppointmentController _controller; private MyProvider _provider; private MyProvider Provider { get { if (_provider == null) { var connString = ConfigurationManager.ConnectionStrings["BossDB"].ConnectionString; var factory = DbProviderFactories.GetFactory("System.Data.SqlClient"); _provider = new MyProvider() { ConnectionString = connString, DbFactory = factory, PersistChanges = true }; } return _provider; } } private WebServiceAppointmentController Controller { get { if (_controller == null) { _controller = new WebServiceAppointmentController(Provider); } return _controller; } } [OperationContract] public IEnumerable<AppointmentData> GetAppointments(SchedulerInfo schedulerInfo) { return Controller.GetAppointments(schedulerInfo); } [OperationContract] public IEnumerable<AppointmentData> InsertAppointment(SchedulerInfo schedulerInfo, AppointmentData appointmentData) { return Controller.InsertAppointment(schedulerInfo, appointmentData); } [OperationContract] public IEnumerable<AppointmentData> UpdateAppointment(SchedulerInfo schedulerInfo, AppointmentData appointmentData) { return Controller.UpdateAppointment(schedulerInfo, appointmentData); } [OperationContract] public IEnumerable<AppointmentData> DeleteAppointment(SchedulerInfo schedulerInfo, AppointmentData appointmentData, bool deleteSeries) { return Controller.DeleteAppointment(schedulerInfo, appointmentData, deleteSeries); } [OperationContract] public IEnumerable<AppointmentData> CreateRecurrenceException(SchedulerInfo schedulerInfo, AppointmentData recurrenceExceptionData) { return Controller.CreateRecurrenceException(schedulerInfo, recurrenceExceptionData); } [OperationContract] public IEnumerable<AppointmentData> RemoveRecurrenceExceptions(SchedulerInfo schedulerInfo, AppointmentData masterAppointmentData) { return Controller.RemoveRecurrenceExceptions(schedulerInfo, masterAppointmentData); } } }The web service references the data provider implemented in MyProvider.cs:
using System; using System.Collections.Generic; using System.Data.Common; using System.Data.SqlClient; using System.Configuration; using System.Transactions; using Telerik.Web.UI; public class MyProvider : DbSchedulerProviderBase { private SqlConnection m_connection; private SqlCommand m_cmdReservationListSelect; public MyProvider() { m_connection = new SqlConnection(ConfigurationManager.ConnectionStrings["BossDB"].ConnectionString); m_cmdReservationListSelect = new SqlCommand("procReservationListSelect"); m_cmdReservationListSelect.CommandType = System.Data.CommandType.StoredProcedure; m_cmdReservationListSelect.Connection = m_connection; m_cmdReservationListSelect.Parameters.Add(new SqlParameter("@ClubId", System.Data.SqlDbType.SmallInt)); m_cmdReservationListSelect.Parameters.Add(new SqlParameter("@ResourceType", System.Data.SqlDbType.Char, 15)); m_cmdReservationListSelect.Parameters.Add(new SqlParameter("@ReservationDate", System.Data.SqlDbType.Char, 10)); m_cmdReservationListSelect.Parameters.Add(new SqlParameter("@ReservationType", System.Data.SqlDbType.Char, 1)); m_cmdReservationListSelect.Parameters.Add(new SqlParameter("@MembershipNbr", System.Data.SqlDbType.Char, 10)); } public override IEnumerable<Appointment> GetAppointments(ISchedulerInfo shedulerInfo) { Int16 clubId = 201; String resourceType = "PERS TRAINING"; String reservationDate = "04/01/2011"; String reservationType = "L"; String membershipNbr = ""; List<Appointment> appointments = new List<Appointment>(); using (TransactionScope scope = new TransactionScope()) { m_cmdReservationListSelect.Parameters["@ClubId"].Value = clubId; m_cmdReservationListSelect.Parameters["@ResourceType"].Value = resourceType; m_cmdReservationListSelect.Parameters["@ReservationDate"].Value = reservationDate; m_cmdReservationListSelect.Parameters["@ReservationType"].Value = reservationType; m_cmdReservationListSelect.Parameters["@MembershipNbr"].Value = membershipNbr; m_connection.Open(); using (SqlDataReader reader = m_cmdReservationListSelect.ExecuteReader()) { if (reader.HasRows) { int resource = reader.GetOrdinal("resource"); int reservation = reader.GetOrdinal("reservation"); int qoh = reader.GetOrdinal("qoh"); int limit = reader.GetOrdinal("limit"); int start_time = reader.GetOrdinal("start_time"); int res_units = reader.GetOrdinal("res_units"); int invtr_desc = reader.GetOrdinal("invtr_desc"); int trainer_cust_code = reader.GetOrdinal("trainer_cust_code"); int remaining_sessions = reader.GetOrdinal("remaining_sessions"); int recurring = reader.GetOrdinal("recurring"); while (reader.Read()) { Appointment apt = new Appointment(); apt.ID = (!reader.IsDBNull(reservation) ? reader.GetInt32(reservation) : 0); apt.Subject = (!reader.IsDBNull(invtr_desc) ? reader.GetString(invtr_desc) : ""); apt.Start = Convert.ToDateTime("04/01/2011 " + reader.GetString(start_time)); apt.End = Convert.ToDateTime("04/01/2011 " + reader.GetString(start_time)).AddHours(reader.GetInt16(res_units)); apt.RecurrenceRule = ""; apt.RecurrenceParentID = null; appointments.Add(apt); } } } m_connection.Close(); scope.Complete(); return appointments; } } public override void Insert(ISchedulerInfo shedulerInfo, Appointment appointmentToInsert) { if (!PersistChanges) { return; } } public override void Update(ISchedulerInfo shedulerInfo, Appointment appointmentToUpdate) { if (!PersistChanges) { return; } } public override void Delete(ISchedulerInfo shedulerInfo, Appointment appointmentToDelete) { if (!PersistChanges) { return; } } }When I build the project in Visual Studio 2008, no errors are reported.
However, at runtime, the following error is displayed:
Server Error in '/' Application. -------------------------------------------------------------------------------- Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. Compiler Error Message: CS0234: The type or namespace name 'Transactions' does not exist in the namespace 'System' (are you missing an assembly reference?) Source Error: Line 4: using System.Data.SqlClient; Line 5: using System.Configuration; Line 6: using System.Transactions; Line 7: using Telerik.Web.UI; Line 8:Line 6 is highlighted, indicating an error in statement "using System.Transactions;".
In order to compile file MyProvider.cs, System.Transactions needs to be referenced not only in the source code, but also as part of the project, under "References".
Is there another place where System.Transactions need to be referenced?
I would appreciate whether someone could assist me in solving this problem.
Thank you in advance.
Paulo