Example #1
0
        private void AddEventsToDay(ref cDay calDay, DateTime calDate)
        {
            int        intNumBlanks = NumberEventsToDisplayPerDay;
            HtmlAnchor aMore;
            //strHtmlEvents was used to store the html string that was displayed in the new window created by the javascript function ShowDay
            //the javascript function was the cause of Issue #7
            //when the variable strHtmlEvents exceeds a limited size, the function doesn't work so,
            //this javascript is not used anymore, it is replaced by a web page "ShowMore.aspx" in LgUtilities
            //string strHtmlEvents;

            int currEventIndex = 0;

            Appointments.AppointmentRow temp_evRow;

            //loop on all appointments in the current selected month,
            //compare the date of the current day (calDate) to the begin and end dates of each appointment
            //if the current date is found within the begin and end dates, add it to the day cell
            foreach (Appointments.AppointmentRow evRow in dvEvents.Table.Rows)
            {
                DateTime beginDate = evRow.BeginDate.ToLocalTime();
                DateTime endDate;
                try
                {
                    endDate = evRow.EndDate.ToLocalTime();
                }
                catch (System.Data.StrongTypingException)
                {
                    //if endDate = null, set its value to 30 minutes after BeginDate
                    endDate = evRow.BeginDate.ToLocalTime().AddMinutes(30);
                }

                //compare the date of the current day (calDate) to the begin and end dates of each appointment, and
                //if the event EndDate equals the current day, check the time of the event EndDate
                //if it is 00:00:00 (i.e. before the first sec of the day), then don't add it to the current day
                //example:
                //"Event"	StartDate = 1/3/2006 12:00:00 AM, EndDate = 2/3/2006 12:00:00 AM
                //this means that "Event" is a one day event - just on 1/3/2006
                //so, it is addded only to 1/3/2006
                if ((beginDate.Date <= calDate.ToLocalTime().Date) && (calDate.ToLocalTime().Date <= endDate.Date) && !((endDate.TimeOfDay.Hours == 0 && endDate.TimeOfDay.Minutes == 0 && endDate.TimeOfDay.Seconds == 0) && (calDate.Day == endDate.Day && calDate.Month == endDate.Month && calDate.Year == endDate.Year) && !(evRow.Source.ToString() == "ClassServerAssignment")) && !((evRow.Source.ToString() == "SPSEvents") && evRow.Recurrent && (beginDate.Date != calDate.ToLocalTime().Date)))
                {
                    currEventIndex++;
                    intNumBlanks--;
                    //If this would be the last need to see if a more button is required
                    if (intNumBlanks == 0)
                    {
                        #region more
                        //if its the last one, then add it anyway and break
                        if (currEventIndex >= dvEvents.Count)
                        {
                            if (evRow.Source.ToString() == "ClassServerAssignment")
                            {
                                calDay.Controls.Add(new Event(evRow.Title, evRow.URL, CssAppointment + " " + evRow.Source, evRow.BeginDate.ToLocalTime().ToShortTimeString() + " - " + evRow.Title, true));
                            }
                            else
                            {
                                calDay.Controls.Add(new Event(evRow.Title, evRow.URL, CssAppointment + " " + evRow.Source, evRow.BeginDate.ToLocalTime().ToShortTimeString() + " - " + evRow.Title, false));
                            }

                            break;
                        }

                        //						//if its the last one for this day then add it and break
                        //						temp_evRow = (Appointments.AppointmentRow) dvEvents[currEventIndex].Row;
                        //						beginDate = temp_evRow.BeginDate.ToLocalTime().Date;
                        //						try
                        //						{
                        //							endDate = temp_evRow.EndDate.ToLocalTime().Date;
                        //						}
                        //						catch
                        //						{
                        //							//if endDate = null, set its value to BeginDate
                        //							endDate = temp_evRow.BeginDate.ToLocalTime().Date;
                        //						}
                        //						if(beginDate != calDate.Day)
                        //						{
                        //							temp_evRow = (Appointments.AppointmentRow) dvEvents[currEventIndex-1].Row;
                        //							calDay.Controls.Add(new Event(evRow.Title, evRow.URL,CssAppointment + " " + evRow.Source,evRow.BeginDate.ToLocalTime().ToShortTimeString() + " - " + evRow.Title));
                        //							break;
                        //						}

                        //Guess not,
                        //need to construct html string for new window.

                        //						strHtmlEvents = "<table class=&quot;" + CssClass + "&quot;><tr class=&quot;" + CssHeadClass + "&quot;><td>" + calDate.ToLongDateString() + "</td></tr><tr><td><BR>";

                        //////////////////////////////////////////////////////////////////////////
                        System.Text.StringBuilder tmp = new System.Text.StringBuilder(dvEvents.Count);
                        //object[] tmp=new object[dvEvents.Count];
                        for (int i = 0; i < dvEvents.Count; i++)
                        {
                            temp_evRow = (Appointments.AppointmentRow)dvEvents[i].Row;
                            //							if(temp_evRow.BeginDate.ToLocalTime().Day == calDate.Day)
                            //							{
                            //								//Contstruct string of appts
                            //								strHtmlEvents += "<a href=&quot;" + temp_evRow.URL + "&quot; class=&quot;" + CssAppointment + " " + temp_evRow.Source +"&quot; title=&quot;" + temp_evRow.BeginDate.ToLocalTime().ToShortTimeString() + " - " + temp_evRow.Title + "&quot;>" + temp_evRow.BeginDate.ToLocalTime().ToShortTimeString() + " - " + temp_evRow.Title + "</A><BR>";
                            //							}
                            tmp.Append(temp_evRow.URL);
                            tmp.Append(",");
                        }
                        // ((this.SharePointCalendarIdsList.Length > 0) ? this.SharePointCalendarIdsList : string.Empty)
                        //////////////////////////////////////////////////////////////////////////
                        //						strHtmlEvents += "</td></tr></table>";
                        aMore           = new HtmlAnchor();
                        aMore.InnerText = "more...";
                        string data = Page.Server.HtmlEncode(tmp.ToString().TrimEnd(new char[] { ',' }));
                        //aMore.HRef="javascript:ShowDay('"+ calDate.ToLongDateString() +"','" + strHtmlEvents + "'); void(0)";
                        string tmpuserid = userid;
                        tmpuserid = userid.Replace(@"\", @"\\");
                        string query_string = "?date=" + calDate.Date.ToShortDateString() + "&showslk=" + this.ShowSLK + "&showExchange=" + this.ShowPersonalExchnage + ((this.SharePointCalendarIdsList.Length > 0) ? "&selectedCalendars=" + this.SharePointCalendarIdsList : "&selectedCalendars=") + ((this.ExchangeCalendarIdsList.Length > 0) ? "&selectedCalendarsE=" + this.ExchangeCalendarIdsList : "&selectedCalendarsE=") + "&userid=" + tmpuserid + "&enableoverridedomain=" + EnableOverrideDomain + "&exurl=" + ExURL + "&domain=" + Domain + "&siteColUrl=" + siteCollectionURL + "&slkMode=" + slkMode + "&spsurl=" + SPSURL + "&spstitles=" + SPSTitles + "&DnsName=" + this.DNSName + "&CssClass=" + CssClass + "&CssShowMoreClass=" + CssShowMoreClass + "&CssAppointment=" + CssAppointment + "&showerrors=" + ShowErrors + "', 'Event', '500',  '700', 'status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes'); void(0)";
                        query_string = System.Web.HttpUtility.HtmlEncode(query_string);
                        aMore.HRef   = "JavaScript:launchCenter('" + "/_layouts/1033/LGUtilities/ShowMore.aspx" + query_string;
                        aMore.Attributes.Add("class", CssAppointment);
                        aMore.Title = "All events on this day";
                        calDay.Controls.Add(aMore);

                        #endregion      // end of more

                        //all appointments added to the new window
                        break;
                    }
                    else
                    {
                        if (evRow.Source.ToString() == "ClassServerAssignment")
                        {
                            calDay.Controls.Add(new Event(evRow.Title, evRow.URL, CssAppointment + " " + evRow.Source, evRow.BeginDate.ToLocalTime().ToShortTimeString() + " - " + evRow.Title, true));
                        }
                        else
                        {
                            calDay.Controls.Add(new Event(evRow.Title, evRow.URL, CssAppointment + " " + evRow.Source, evRow.BeginDate.ToLocalTime().ToShortTimeString() + " - " + evRow.Title, false));
                        }
                    }
                }
            }

            //Add blank lines
            for (int i = 0; i < intNumBlanks; i++)
            {
                calDay.Controls.Add(new System.Web.UI.LiteralControl("<BR>"));
            }
        }
Example #2
0
        public override void DataBind()
        {
            cDay          dayCell;
            cWeek         weekRow;
            cDayHeading   dayHeading;
            cWeekHeading  weekHeading;
            HtmlTableRow  footerRow;
            HtmlTableCell footerCell;

            prevMonth.CssClass           = CssHeadClass;
            nextMonth.CssClass           = CssHeadClass;
            prevMonth.CommandArgument    = StartDate.AddMonths(-1).ToString();
            nextMonth.CommandArgument    = StartDate.AddMonths(1).ToString();
            reloadButton.CommandArgument = StartDate.ToString();
            monthName.Text     = StartDate.ToString("y").Replace(",", "");
            monthName.CssClass = "ms-calheader";
            footerRow          = new HtmlTableRow();
            footerCell         = new HtmlTableCell("td");
            footerCell.ColSpan = 7;
            footerCell.Attributes.Add("class", "ms-cal-nodataBtm2");
            footerRow.Cells.Add(footerCell);

            //this.Rows.Add(GetMyPlannerToolbar());

            //Create all the calendar cells here...
            if (CssHeadClass.Length > 0)
            {
                headRow.Attributes.Add("class", CssHeadClass);
            }

            //Draw the toolbar

            //Draw Day headings
            this.Rows.Add(GetDayHeadings());

            System.DateTime currDate;
            currDate = StartDate.AddDays((double)StartDate.DayOfWeek * -1);
            while (currDate <= EndDate)
            {
                weekRow     = new cWeek();
                weekHeading = new cWeekHeading();
                for (int i = 1; i <= 7; i++)
                {
                    if (currDate.Month != StartDate.Month)
                    {
                        dayCell              = new cDay(CssDayOtherMonthClass);
                        dayHeading           = new cDayHeading("ms-cal-topday");
                        dayHeading.DayNumber = 0;
                        //dayCell.DayNumber = 0;
                    }
                    else
                    {
                        if (currDate == DateTime.Today)
                        {
                            dayCell    = new cDay(CssCurrDayClass);
                            dayHeading = new cDayHeading("ms-cal-topday-today");
                        }
                        else
                        {
                            dayCell    = new cDay(CssDayClass);
                            dayHeading = new cDayHeading("ms-cal-topday");
                        }
                        //dayCell.DayNumber = currDate.Day;
                        dayHeading.DayNumber = currDate.Day;
                        AddEventsToDay(ref dayCell, currDate);
                    }

                    weekHeading.Cells.Add(dayHeading);
                    weekRow.Cells.Add(dayCell);
                    currDate = currDate.AddDays(1);
                }
                this.Rows.Add(weekHeading);
                this.Rows.Add(weekRow);
            }
            //Add Events to cells
            //AddEventsToDays();
            this.Rows.Add(footerRow);
        }