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

Radscheduler export to pdf error

1 Answer 99 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Mandar
Top achievements
Rank 1
Mandar asked on 04 Aug 2016, 04:10 PM

Still in beginner phase of radscheduler use/knowledge

local testing opens the radscheduler as expected, but as I try the export to pdf  , using

  protected void RadButton1_Click(object sender, EventArgs e)
   {
            
            RadScheduler1.ExportToPdf();
   }

get this error on localhost

Server Error in '/' Application.

The remote certificate is invalid according to the validation procedure.Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Security.Authentication.AuthenticationException: The remote certificate is invalid according to the validation procedure.

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace: 

[AuthenticationException: The remote certificate is invalid according to the validation procedure.] System.Net.Security.SslState.StartSendAuthResetSignal(ProtocolToken message, AsyncProtocolRequest asyncRequest, Exception exception) +2247769 System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest) +77 System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest) +191 System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest) +77 System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest) +191 System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest) +77 System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest) +191 System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst, Byte[] buffer, AsyncProtocolRequest asyncRequest) +206 System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult) +148 System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) +350 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) +23 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) +82 System.Net.TlsStream.ProcessAuthentication(LazyAsyncResult result) +1132 System.Net.TlsStream.Write(Byte[] buffer, Int32 offset, Int32 size) +61 System.Net.ConnectStream.WriteHeaders(Boolean async) +475 [WebException: The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.] System.Net.HttpWebRequest.GetResponse() +1740 Telerik.Web.UI.Scheduler.SchedulerExporter.GetStyleSheet(String url) +115 Telerik.Web.UI.Scheduler.SchedulerExporter.GetStyleSheetFor(String controlName, Type controlType, Page page, String pathFormatString, String defaultPathFormatString) +342 Telerik.Web.UI.Scheduler.SchedulerExporter.GetStyleSheets(Page page) +91 Telerik.Web.UI.Scheduler.SchedulerExporter.RenderControl(Page page) +492 Telerik.Web.UI.Scheduler.SchedulerExporter.PdfExportRenderForm(HtmlTextWriter nullWriter, Control form) +76 System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +263 System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer) +131 System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer) +47 System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +80 System.Web.UI.HtmlControls.HtmlForm.RenderControl(HtmlTextWriter writer) +50 System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +263 System.Web.UI.Page.Render(HtmlTextWriter writer) +39 System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +80 Telerik.Web.UI.RadAjaxControl.RenderPageInAjaxMode(HtmlTextWriter writer, Control page) +1029 System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +263 System.Web.UI.Page.Render(HtmlTextWriter writer) +39 System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +80 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +8921

 

code behind 

 

using Scheduler.Examples.BindToList;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Drawing.Printing;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;
using Telerik.Web.UI.Scheduler;

 
public partial class AMGR_RadSchedulerTest : System.Web.UI.Page
    {
        private const string AppointmentsKey = "Telerik.Web.Examples.Scheduler.BindToList.CS.Apts";
       
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);

        

           // RadScheduler1.ExportSettings.Pdf.PaperOrientation = (SchedulerPaperOrientation)Enum.Parse(typeof(SchedulerPaperOrientation), PaperOrientation.SelectedValue);
          

            RadScheduler1.ExportSettings.FileName = "Talisman";
            RadScheduler1.ExportSettings.Pdf.PageTitle = "hello";
            RadScheduler1.ExportSettings.Pdf.Author = "Mandar";
            RadScheduler1.ExportSettings.Pdf.Creator = "Mandar";
            RadScheduler1.ExportSettings.Pdf.Title = "test pdf";
            RadScheduler1.ExportSettings.OpenInNewWindow = true;

            RadScheduler1.ExportSettings.Pdf.AllowPaging = true;

           
            RadScheduler1.RowHeight = Unit.Pixel(60);
        }
         
         
        private List<AppointmentInfo> Appointments
        {
            get
            {
                List<AppointmentInfo> sessApts = Session[AppointmentsKey] as List<AppointmentInfo>;
                if (sessApts == null)
                {
                    sessApts = new List<AppointmentInfo>();
                    Session[AppointmentsKey] = sessApts;
                }
 
                return sessApts;
            }
        }
 
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
 
            if (!IsPostBack)
            {
                Session.Remove(AppointmentsKey);
 
                InitializeResources();
                InitializeAppointments();
            }
 
            this.RadScheduler1.DataSource = Appointments;
        }
 
        protected void RadScheduler1_AppointmentInsert(object sender, SchedulerCancelEventArgs e)
        {
            Appointments.Add(new AppointmentInfo(e.Appointment));
        }
 
        protected void RadScheduler1_AppointmentUpdate(object sender, AppointmentUpdateEventArgs e)
        {
            AppointmentInfo ai = FindById(e.ModifiedAppointment.ID);
 
 
            RecurrenceRule rrule;
 
            if (RecurrenceRule.TryParse(e.ModifiedAppointment.RecurrenceRule, out rrule))
            {
                rrule.Range.Start = e.ModifiedAppointment.Start;
                rrule.Range.EventDuration = e.ModifiedAppointment.End - e.ModifiedAppointment.Start;
                TimeSpan startTimeChange = e.ModifiedAppointment.Start - e.Appointment.Start;
                for (int i = 0; i < rrule.Exceptions.Count; i++)
                {
                    rrule.Exceptions[i] = rrule.Exceptions[i].Add(startTimeChange);
                }
                e.ModifiedAppointment.RecurrenceRule = rrule.ToString();
            }
 
            ai.CopyInfo(e.ModifiedAppointment);
        }
 
        protected void RadScheduler1_AppointmentDelete(object sender, SchedulerCancelEventArgs e)
        {
            Appointments.Remove(FindById(e.Appointment.ID));
        }
 
        private void InitializeResources()
        {
            ResourceType resType = new ResourceType("User");
            resType.ForeignKeyField = "UserID";
 
            RadScheduler1.ResourceTypes.Add(resType);
            RadScheduler1.Resources.Add(new Resource("User", 1, "Alex"));
            RadScheduler1.Resources.Add(new Resource("User", 2, "Bob"));
            RadScheduler1.Resources.Add(new Resource("User", 3, "Charlie"));
        }
 
        private void InitializeAppointments()
        {
            DateTime start = DateTime.UtcNow.Date;
            start = start.AddHours(6);
       //     Appointments.Add(new AppointmentInfo("Take the car to the service", start, start.AddHours(1), string.Empty, null, new Reminder(30).ToString(), 1));
            Appointments.Add(new AppointmentInfo("Meeting with Alexa", start.AddHours(2), start.AddHours(3), string.Empty, null, string.Empty, 1));
           
            Appointments.Add(new AppointmentInfo("Meeting with Sam", start.AddHours(2), start.AddHours(3), string.Empty, null, string.Empty, 1));
            Appointments.Add(new AppointmentInfo("Meeting with Gopal", start.AddHours(2), start.AddHours(3), string.Empty, null, string.Empty, 2));
            Appointments.Add(new AppointmentInfo("Meeting with Ram", start.AddHours(2), start.AddHours(3), string.Empty, null, string.Empty, 3));
            Appointments.Add(new AppointmentInfo("Meeting with Mohammad", start.AddHours(2), start.AddHours(3), string.Empty, null, string.Empty, 3));
            Appointments.Add(new AppointmentInfo("Meeting with David", start.AddHours(2), start.AddHours(3), string.Empty, null, string.Empty, 3));
            //Appointments.Add(new AppointmentInfo("Meeting with Ashley", start.AddHours(2), start.AddHours(3), string.Empty, null, string.Empty, 2));
            //Appointments.Add(new AppointmentInfo("Meeting with Teresa", start.AddHours(2), start.AddHours(3), string.Empty, null, string.Empty, 2));
            //Appointments.Add(new AppointmentInfo("Meeting with Meg", start.AddHours(2), start.AddHours(3), string.Empty, null, string.Empty, 2));
            //Appointments.Add(new AppointmentInfo("Meeting with Kravitz", start.AddHours(2), start.AddHours(3), string.Empty, null, string.Empty, 2));
            //Appointments.Add(new AppointmentInfo("Meeting with Leonard", start.AddHours(2), start.AddHours(3), string.Empty, null, string.Empty, 2));
            //Appointments.Add(new AppointmentInfo("Meeting with Sam", start.AddHours(2), start.AddHours(3), string.Empty, null, string.Empty, 2));
            //Appointments.Add(new AppointmentInfo("Meeting with Gopal", start.AddHours(2), start.AddHours(3), string.Empty, null, string.Empty, 2));
            //Appointments.Add(new AppointmentInfo("Meeting with Ram", start.AddHours(2), start.AddHours(3), string.Empty, null, string.Empty, 2));
            //Appointments.Add(new AppointmentInfo("Meeting with Mohammad", start.AddHours(2), start.AddHours(3), string.Empty, null, string.Empty, 2));
            //Appointments.Add(new AppointmentInfo("Meeting with David", start.AddHours(2), start.AddHours(3), string.Empty, null, string.Empty, 2));
            //Appointments.Add(new AppointmentInfo("Meeting with Ashley", start.AddHours(2), start.AddHours(3), string.Empty, null, string.Empty, 2));
            //Appointments.Add(new AppointmentInfo("Meeting with Teresa", start.AddHours(2), start.AddHours(3), string.Empty, null, string.Empty, 2));
            //Appointments.Add(new AppointmentInfo("Meeting with Meg", start.AddHours(2), start.AddHours(3), string.Empty, null, string.Empty, 2));
            //Appointments.Add(new AppointmentInfo("Meeting with Kravitz", start.AddHours(2), start.AddHours(3), string.Empty, null, string.Empty, 2));
            //Appointments.Add(new AppointmentInfo("Meeting with Leonard", start.AddHours(2), start.AddHours(3), string.Empty, null, string.Empty, 2));
            //Appointments.Add(new AppointmentInfo("Meeting with Sam", start.AddHours(2), start.AddHours(3), string.Empty, null, string.Empty, 2));
      
      
       
 
            start = start.AddDays(-1);
            DateTime dayStart = RadScheduler1.UtcDayStart(start);
            Appointments.Add(new AppointmentInfo("Bob's Birthday", dayStart, dayStart.AddDays(1), string.Empty, null, string.Empty, 1));
            Appointments.Add(new AppointmentInfo("Call Charlie about the Project", start.AddHours(2), start.AddHours(3), string.Empty, null, string.Empty, 2));
 
            start = start.AddDays(2);
            Appointments.Add(new AppointmentInfo("Get the car from the service", start.AddHours(2), start.AddHours(3), string.Empty, null, string.Empty, 1));
        }
 
        private AppointmentInfo FindById(object ID)
        {
            foreach (AppointmentInfo ai in Appointments)
            {
                if (ai.ID.Equals(ID))
                {
                    return ai;
                }
            }
 
            return null;
        }

        private Hashtable processedDateWraps = new Hashtable(); 
        protected void RadScheduler1_AppointmentCreated(object sender, AppointmentCreatedEventArgs e)
        {
            //if (RadScheduler1.SelectedView == SchedulerViewType.MonthView)
            //{
            //    Control dayWrap = GetDateWrap(e.Container);

            //    if (!processedDateWraps.ContainsKey(dayWrap))
            //    {
            //        // Only do the count once per day cell. 
            //        processedDateWraps.Add(dayWrap, null);

            //        // We will use the appointment start time to determine the date for the current cell. 
            //        // Appointments that span multiple days are a special case. 
            //        // They are rendered in parts and by using the part index, we can still calculate the correct day. 
            //        // For example part 1 will rendered on the start date, part 2 on the start date + 1 day and so on. 
            //        Control aptControl = GetAppointmentControl(e.Container);
            //        int partIndex = Convert.ToInt32(aptControl.ID.Split('_')[1]);
            //        DateTime aptStart = e.Appointment.Start.AddDays(partIndex);

            //        // Calculate the day start and end time and count the appointments in it. 
            //        DateTime dayStart = RadScheduler1.UtcDayStart(aptStart);
            //        DateTime dayEnd = dayStart.AddDays(1);
            //        int appointmentsCount = RadScheduler1.Appointments.GetAppointmentsInRange(dayStart, dayEnd).Count;

            //        // Add a literal control with the count. 
            //        string label = string.Format(" ({0} total)", appointmentsCount);
            //        dayWrap.Controls.Add(new LiteralControl(label));
            //    }
            //} 
        }


        private Control GetDateWrap(Control aptContainer)
        {
            Control cell = GetParentByCssClass(aptContainer, "rsCell");
            return cell.Controls[0]; // rsDateWrap 
        }

        private Control GetAppointmentControl(Control aptContainer)
        {
            Control aptWrap = GetParentByCssClass(aptContainer, "rsAptWrap");
            return aptWrap.Parent;
        }


        protected void RadButton1_Click(object sender, EventArgs e)
        {
            
            RadScheduler1.ExportToPdf();
        }


        private Control GetParentByCssClass(Control container, string cssClass)
        {
            Control parent = container;
            while (parent != Page)
            {
                WebControl candidate = parent as WebControl;

                if (candidate != null)
                {
                    string[] allClassses = candidate.CssClass.Split(' ');
                    if (Array.IndexOf(allClassses, cssClass) != -1)
                    {
                        return candidate;
                    }
                }

                parent = parent.Parent;
            }

            return null;
        }


        protected void RadScheduler1_AppointmentCommand(object sender, AppointmentCommandEventArgs e)
        {
            if (e.CommandName == "Export")
            {
                WriteCalendar(RadScheduler.ExportToICalendar(e.Container.Appointment));
            }
        }

        private void WriteCalendar(string data)
        {
            HttpResponse response = Page.Response;

            response.Clear();
            response.Buffer = true;

            response.ContentType = "text/calendar";
            response.ContentEncoding = Encoding.UTF8;
            response.Charset = "utf-8";

            response.AddHeader("Content-Disposition", "attachment;filename=\"RadSchedulerExport.ics\"");

            response.Write(data);
            response.End();
        }

        protected void ImgBtn1_Click(object sender, EventArgs e)
        {
            WriteCalendar(RadScheduler.ExportToICalendar(RadScheduler1.Appointments));
        }

        protected void RadScheduler1_NavigationCommand(object sender, SchedulerNavigationCommandEventArgs e)
        {
            //if (e.Command == SchedulerNavigationCommand.SwitchToSelectedDay && RadScheduler1.SelectedView == SchedulerViewType.DayView)
            //    e.Cancel = true;

            Response.Redirect("RadGridCalList.aspx");
        }


        protected void RadScheduler1_AppointmentDataBound(object sender, SchedulerEventArgs e)
        {
            e.Appointment.Visible = false;
            FilterAppointment(e.Appointment, AlexCheckBox, 1);
            FilterAppointment(e.Appointment, BobCheckBox, 2);
            FilterAppointment(e.Appointment, CharlieCheckBox, 3);
        }

        private static void FilterAppointment(Appointment appointment, ICheckBoxControl checkBox, int resourceId)
        {
            if (appointment.Resources.GetResource("User", resourceId) != null && checkBox.Checked)
            {
                appointment.Visible = true;
            }
        }

        protected void btnToggle_Click(object sender, EventArgs e)
        {
            RadScheduler1.Rebind();
        }
       
}

 
namespace Scheduler.Examples.BindToList
{
    public class AppointmentInfo
    {
        private readonly string _id;
        private string _subject;
        private DateTime _start;
        private DateTime _end;
        private string _recurrenceRule;
        private string _recurrenceParentId;
        private string _reminder;
        private int? _userID;
 
        public string ID
        {
            get
            {
                return _id;
            }
        }
 
        public string Subject
        {
            get
            {
                return _subject;
            }
            set
            {
                _subject = value;
            }
        }
 
        public DateTime Start
        {
            get
            {
                return _start;
            }
            set
            {
                _start = value;
            }
        }
 
        public DateTime End
        {
            get
            {
                return _end;
            }
            set
            {
                _end = value;
            }
        }
 
        public string RecurrenceRule
        {
            get
            {
                return _recurrenceRule;
            }
            set
            {
                _recurrenceRule = value;
            }
        }
 
        public string RecurrenceParentID
        {
            get
            {
                return _recurrenceParentId;
            }
            set
            {
                _recurrenceParentId = value;
            }
        }
 
        public int? UserID
        {
            get
            {
                return _userID;
            }
            set
            {
                _userID = value;
            }
        }
 
        public string Reminder
        {
            get
            {
                return _reminder;
            }
            set
            {
                _reminder = value;
            }
        }
 
        private AppointmentInfo()
        {
            _id = Guid.NewGuid().ToString();
        }
 
        public AppointmentInfo(string subject, DateTime start, DateTime end,
            string recurrenceRule, string recurrenceParentID, string reminder, int? userID) : this()
        {
            _subject = subject;
            _start = start;
            _end = end;
            _recurrenceRule = recurrenceRule;
            _recurrenceParentId = recurrenceParentID;
            _reminder = reminder;
            _userID = userID;
        }
 
        public AppointmentInfo(Appointment source) : this()
        {
            CopyInfo(source);
        }
 
        public void CopyInfo(Appointment source)
        {
            Subject = source.Subject;
            Start = source.Start;
            End = source.End;
            RecurrenceRule = source.RecurrenceRule;
            if (source.RecurrenceParentID != null)
            {
                RecurrenceParentID = source.RecurrenceParentID.ToString();
            }
 
            if (!String.IsNullOrEmpty(Reminder))
            {
                Reminder = source.Reminders[0].ToString();
            }
 
            Resource user = source.Resources.GetResourceByType("User");
            if (user != null)
            {
                UserID = (int?)user.Key;
            }
            else
            {
                UserID = null;
            }
        }
    }
}

1 Answer, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 09 Aug 2016, 07:19 AM
Hi,

Please refer to this forum thread where the certificate issue has been discussed.

Regards,
Dimitar
Telerik by Progress
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Tags
Scheduler
Asked by
Mandar
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Share this question
or