%@ Page Language="VB" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%
'Get all calendar config settings
Dim calendar_root_path As String = Server.MapPath(".\")
Dim calendar_db_path As String = ADXCalendar.AdminFunctions.GetProperty(ADXCalendar.AdminFunctions.CalendarProperty.DataConn_ConnectionString, calendar_root_path)
Dim calendar_root_url As String = ADXCalendar.AdminFunctions.ReturnBaseCalendarURL(Request.Url)
Dim private_calendar_key As String = ADXCalendar.AdminFunctions.GetConfiguration("PrivateCalendarKeytext", calendar_db_path, ADXCalendar.ConfigurationType.All)
Dim ADX_ADP_STYLE As New ADXCalendar.ADXADPStyle(calendar_db_path, calendar_root_path, calendar_root_url)
'See if a template should be applied to this syndication or not
Dim adpStyleSyndication As Boolean = False
If IsNumeric(Request.QueryString.Item("adpid")) Then
If ADX_ADP_STYLE.ADPTemplateExists(CInt(Request.QueryString.Item("adpid"))) Then
adpStyleSyndication = True
End If
End If
'Log the Syndication page viwe
Dim objLog As New ADXCalendar.ADXTrafficStats(calendar_db_path)
objLog.LogPageView(ADXCalendar.ADXTrafficStats.PageNameEnum.EventListSyndicator, DateTime.Now())
objLog.DisposeADXTrafficStatsClass()
objLog = Nothing
'Forces category searching to include its subcategories
Dim inclusivecategorysearch As String = Request.QueryString.Item("ics")
If inclusivecategorysearch Is Nothing Then inclusivecategorysearch = ""
'Date Variables that control the search range of events returned.
Dim EndDate As Date
Dim StartDate As Date
'These are the date range searched on
If Not IsNothing(Request.QueryString.Item("starting")) Then
'This is left in for legacy syndication scripts
StartDate = Request.QueryString.Item("starting")
EndDate = Request.QueryString.Item("ending")
Else
'This is always the default syndication date range, the next 180 days
StartDate = DateTime.Now
EndDate = StartDate.AddDays(180).ToShortDateString
End If
If Not IsNothing(Request.QueryString.Item("today")) Then
'THIS IS THE LEGACY WAY TO SYNDICATE TODAYS EVENTS
'THIS WAS CHANGED TO USE THE RANGE OPTION IN 340
StartDate = DateTime.Now.ToShortDateString
EndDate = DateTime.Now.ToShortDateString
End If
If Not IsNothing(Request.QueryString.Item("range")) Then
'This syndication request is for a range
ADXCalendar.AdminFunctions.GetDatesForRangeOption(Request.QueryString.Item("range").ToLower, StartDate, EndDate)
End If
If IsNumeric(Request.QueryString.Item("numdays")) Then
'This syndication request is for num of days from current date
StartDate = DateTime.Now.ToShortDateString
EndDate = DateTime.Now.AddDays(CInt(Request.QueryString.Item("numdays"))).Date
End If
If Not IsNothing(Request.QueryString.Item("currentrange")) Then
StartDate = DateTime.Now.ToShortDateString
If Date.TryParse(Request.QueryString.Item("currentrange"), EndDate) = False Then
EndDate = StartDate.AddDays(180).Date
End If
End If
If adpStyleSyndication = True Then
'These are all the adp syndication parameters
Dim tmpMaxNumberOfEvents As String = Request.QueryString.Item("number")
Dim MaxNumberOfEvents As Integer = 5
Dim Highlight As String = Request.QueryString.Item("highlight")
Dim Location As String = Request.QueryString.Item("location")
Dim Category As String = Request.QueryString.Item("category")
Dim Department As String = Request.QueryString.Item("department")
Dim CalType As String = Request.QueryString.Item("type")
Dim StartTime As String = Request.QueryString.Item("starttime")
Dim EndTime As String = Request.QueryString.Item("endtime")
Dim nem As String = Request.QueryString.Item("nem")
If IsNumeric(tmpMaxNumberOfEvents) Then
'This is the number of events to show, by default the number is 5
MaxNumberOfEvents = Integer.Parse(tmpMaxNumberOfEvents)
End If
'This is a new parameter for syndication, this will apply an adp template to the output
Dim adptemplate_id As String = Request.QueryString.Item("adpid")
'This is used to get the syndicated events text based off a format selected by the user
Dim html As String = ADX_ADP_STYLE.ADPSyndicateEventData(adptemplate_id, private_calendar_key, MaxNumberOfEvents, StartDate, EndDate, Category, Location, Highlight, CalType, StartTime, EndTime, inclusivecategorysearch, Department)
'if no events are returned show a message here as well
If html = "" Then
nem = Request.QueryString.Item("nem")
Response.Write(("document.write (""" & nem & "
"");"))
'Response.Write("document.write (" & nem & ");")
Else
'This removes all tabs, line feeds, controls...
html = System.Text.RegularExpressions.Regex.Replace(html, "[\t\r\n\v\f]", "")
'This escapes a double quote for javascripting purposes
html = html.Replace("""", "\""")
'This is the quick tip file that gets sent down with syndication code for quick tip enabled codes.
Dim qt As String = ""
qt = qt.Replace("""", "\""")
'Response.write a document.write
Response.Write("document.write(""" & qt & """);") 'The quicktip.js file
Response.Write("document.write(""" & html & """);") 'The syndication code
End If
'Clean up the adp object
adptemplate_id = Nothing
Else
Dim SQL As String 'SQL Query String variable
Dim event_counter As Integer
Dim returnString As String
Dim privateflg As String
Dim number As Integer
'Date variables that control event date display
Dim ESD As Date 'Event Start Date
Dim EED As Date 'Event End Date
'This is how all the events are searched in calendar
Dim search_obj As New ADXCalendar.EventSearchObj(calendar_db_path)
'Start building the SQL query string for the events in question.
SQL = "SELECT DISTINCT Event_Information.information_id, Event_Master.event_idn, Event_Details.event_name, Event_Information.event_start_date, Event_Information.event_end_date, Event_Information.all_day, Event_Information.private_flg "
SQL &= " FROM Event_Master"
SQL &= " INNER JOIN Event_Information ON Event_Master.event_idn = Event_Information.event_idn"
SQL &= " INNER JOIN Event_Occurrence_Category ON Event_Information.information_id = Event_Occurrence_Category.information_id"
SQL &= " INNER JOIN Event_Details ON Event_Information.details_id = Event_Details.details_id WHERE"
'This is the date range filter : ALWAYS SET BY THIS POINT
SQL &= " " & search_obj.EventDateTimeFilter(StartDate, EndDate)
'Get the actual time elements passed in the querystring
Dim starttime As String = Request.QueryString.Item("starttime")
Dim endtime As String = Request.QueryString.Item("endtime")
If Not IsNothing(starttime) And Not IsNothing(endtime) Then
'Get date objects with the time elements appended on
Dim sd As DateTime = DateTime.Parse("1/1/2007 " & starttime.Insert(2, ":"))
Dim ed As DateTime = DateTime.Parse("1/1/2007 " & endtime.Insert(2, ":"))
'Append on the SQL to the syndication
SQL &= " AND " & search_obj.EventTimeFilter(sd, ed)
End If
'This is to remove default information and cancelled events
SQL &= " AND Event_Information.information_status NOT IN ('G', 'C') "
'This is to remove saved events
SQL &= " AND Event_Information.saved_status IS NULL "
'This is approved on this category
SQL &= " AND Event_Occurrence_Category.approved_by NOT IN ('', '**DENIED**') "
If Not IsNothing(Request.QueryString.Item("highlight")) Then
'The event IS highlighted
SQL = SQL & " AND Event_Information.highlight = 'Y'"
End If
Dim locSTR As String = Request.QueryString.Item("location")
If Not IsNothing(locSTR) Then
'The event IS at the locations passed
' SQL &= " AND " & search_obj.LocationBuildingFilter(locSTR.Split(","))
SQL &= " AND " & search_obj.LocationBuildingRoomFilter(locSTR.Split(","))
End If
Dim ctgrySTR As String = Request.QueryString.Item("category")
If Not IsNothing(ctgrySTR) Then
If ADXCalendar.AdminFunctions.IsNewCategoryList(ctgrySTR.Split(",")) = False Then
'This is an single old style category, trasform the categories passed
Dim tmpSTR As String = ADXCalendar.AdminFunctions.GetCategoryIdListFromCategoryNamesList(ctgrySTR, calendar_db_path)
ctgrySTR = tmpSTR
End If
'This allows for inclusive searching
Dim inclusiveSearch As Boolean = False
If inclusivecategorysearch = "Y" Then
inclusiveSearch = True
End If
If ctgrySTR <> "" Then
'The event IS on the category calendar passed
SQL &= " AND " & search_obj.EventOccurrenceCategorySubcategoryFilter(ctgrySTR.Split(","), inclusiveSearch)
End If
End If
Dim deptSTR As String = Request.QueryString.Item("department")
If Not IsNothing(deptSTR) AndAlso deptSTR <> "" Then
'Add the filter returned to the event list SQL
SQL &= " AND " & search_obj.DepartmentFilter(deptSTR.Split(","))
End If
If Not IsNothing(Request.QueryString.Item("type")) Then
privateflg = Trim(Request.QueryString.Item("type"))
If privateflg = "N" Then
'The event IS Public
SQL &= " AND " & search_obj.PublicPrivateFilter("N")
ElseIf privateflg = "Y" Then
'The event IS Private
SQL &= " AND " & search_obj.PublicPrivateFilter("Y")
ElseIf privateflg = "B" Then
'The event IS any type
SQL &= " AND " & search_obj.PublicPrivateFilter("B")
End If
Else
'The event IS Public
SQL &= " AND " & search_obj.PublicPrivateFilter("N")
End If
search_obj.DisposeEventSearchClass()
Dim ApprovalLeveltext As String = ADXCalendar.AdminFunctions.GetConfiguration("ApprovalLeveltext", calendar_db_path, ADXCalendar.ConfigurationType.NotSet)
If ApprovalLeveltext = "Category" Then
'Do not show events if they are still pending on a locked category
' if category workflow is enabled in calendar
SQL &= " AND (Event_Information.information_id NOT IN (SELECT DISTINCT information_id FROM Event_Occurrence_Category WHERE category_id IN (SELECT category_id FROM Category WHERE active_flg='L') AND approved_by IN ('', '**DENIED**')))"
End If
'Order the sql record set that will be returned.
SQL = SQL & " ORDER BY Event_Information.event_start_date, Event_Details.event_name "
'Init the database connection variables
Dim DataConn As New SqlConnection(calendar_db_path)
Dim rsevntlst As SqlDataReader
Dim cmd As New SqlCommand(SQL, DataConn)
'Open a connection and get back events to syndicate
DataConn.Open()
rsevntlst = cmd.ExecuteReader(CommandBehavior.CloseConnection)
If Not rsevntlst.HasRows() Then
Dim nem As String = Request.QueryString.Item("nem")
If Not nem Is Nothing AndAlso nem.Trim <> "" Then
returnString = "'
" & Request.QueryString("nem") & "
'" Else returnString = "'No events are available that match your request.
'" End If Response.Write(("document.write (" & returnString & ");")) End If 'Number of events to show. number = Request.QueryString.Item("number") If Not IsNothing(number) Then If number <= 0 Then number = 5 End If Else number = 5 End If 'This is the number of events that have been "syndicated" event_counter = 1 'PrivateCalendarKeytext Dim PrivateCalendarKey As String = ADXCalendar.AdminFunctions.GetConfiguration("PrivateCalendarKeytext", calendar_db_path) While rsevntlst.Read() 'Reset the returnString for this event returnString = "" 'Set the dates for this recurance of event ESD = rsevntlst.Item("event_start_date") EED = rsevntlst.Item("event_end_date") Dim priv_string As String = "" Select Case (rsevntlst.Item("private_flg")) Case "Y" If PrivateCalendarKey = "##ODD##" Then priv_string = "&type=3" Else priv_string = "&type=" & Server.UrlEncode(PrivateCalendarKey) End If Case "N", "B" priv_string = "&type=" Case Else priv_string = "&type=" End Select returnString = "" returnString &= server.HtmlEncode(Trim(rsevntlst.Item("event_name"))) 'If the recuring start date is the same as the recuring end date then don't print a spanning range If DateTime.Compare(ESD.ToShortDateString, EED.ToShortDateString) <> 0 Then returnString &= " (" & ESD.ToShortDateString & " - " & EED.ToShortDateString & ")" Else returnString &= " (" & ESD.ToShortDateString & ")" End If returnString &= "" Response.Write("document.write(""" & returnString.Replace("""", "\""") & "