anyone use it?

Page 1 of 1

0 Replies - 7191 Views - Last Post: 19 November 2010 - 07:41 AM

#1 MrReclusive  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 32
  • Joined: 17-November 09


Posted 19 November 2010 - 07:41 AM

Don't know if anyone here has used ScheduleGeneral or could recommend a better one but I have been working with is thing for probably 8 hours now trying to do something as simple as display all employees calenders for the week.(with exchange)
I am close except for a couple of issues.

Posted Image

I need it to start at the beginning of the day and end at the end of the day, right now its starting at end and ending at beginning.

I need to get ride of the first half of the day, i have the timescaleinterval set to 1440 so its only showing 2 "hours"
and it starts at 00:00:00 and ends at 23:59:59.
if you look at the pic it says like 15 15 16 16 etc
i need to get ride of the first 15, the first 16, etc.
so I only have 1 part to the day not 2.

or if I can just completely hide the time scale but keep the separatedateheader that would work to.

here is the entire page code.
<%@ Page Language="VB" %> 
<%@ Register Assembly="schedule" Namespace="rw" TagPrefix="rw" %>
<%@ import Namespace="System.Net" %>
<%@ import Namespace="System.IO" %>
<%@ import Namespace="System.XML" %>
<%@ import Namespace="System.Data" %>
<%@ Register assembly="System.Web.Extensions, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35" namespace="System.Web.UI.WebControls" tagprefix="asp" %>
<script runat="server">

    Const errorLevel As Integer = 2  ' 2 = verbose, 1 = concise

    Sub Page_Load(ByVal Sender As Object, ByVal E As EventArgs)
        If (IsPostBack) Then Return
        Dim ChosenDate As String = Request.QueryString("date")
        If (ChosenDate = "") Then
            Dim wdate As Date = Date.Now
            Do While wdate.DayOfWeek <> DayOfWeek.Monday
                wdate = wdate.AddDays(-1)
            Calendar1.SelectedDate = wdate
            Calendar1.SelectedDate = DateTime.Parse(ChosenDate)
        End If
        Dim dt As New DataTable()
        dt.Columns.Add("StartTime", System.Type.GetType("System.DateTime"))
        dt.Columns.Add("EndTime", System.Type.GetType("System.DateTime"))
        dt.Columns.Add("Name", System.Type.GetType("System.String"))
        dt.Columns.Add("Location", System.Type.GetType("System.String"))
        dt.Columns.Add("Subject", System.Type.GetType("System.String"))
        dt.Columns.Add("Status", System.Type.GetType("System.String"))
        dt.Columns.Add("Type", System.Type.GetType("System.String"))

        Dim strUsers As String = ConfigurationSettings.AppSettings("Usernames")
        Dim arrUsers() As String = strUsers.Split(",")
        Dim strUser As String
        For Each strUser In arrUsers
            LookUpCalendar(strUser, Calendar1.SelectedDate, dt)
        ScheduleGeneral1.DataSource = dt
    End Sub

    Sub LookUpCalendar(ByVal Name As String, ByVal dDate As DateTime, ByRef dt As DataTable)

        Dim strURL As String = "http://" & ConfigurationSettings.AppSettings("ServerName") & "/exchange/" & Name & "/calendar/"

        Dim strRequest As String = "<?xml version=""1.0""?>" & _
                  "<g:searchrequest xmlns:g=""DAV:"">" & _
                  "<g:sql>SELECT ""urn:schemas:calendar:location"", ""urn:schemas:httpmail:subject"", " & _
                  """urn:schemas:calendar:dtstart"", ""urn:schemas:calendar:dtend"", " & _
                  """urn:schemas:calendar:busystatus"", ""urn:schemas:calendar:instancetype"" " & _
                  "FROM Scope('SHALLOW TRAVERSAL OF """ & strURL & """') " & _
                  "WHERE NOT ""urn:schemas:calendar:instancetype"" = 1 " & _
                  "AND ""DAV:contentclass"" = 'urn:content-classes:appointment' " & _
                  "AND ""urn:schemas:calendar:dtstart"" > '" & _
                  String.Format("{0:yyyy/MM/dd}", dDate) & " 00:00:00' " & _
                  "AND ""urn:schemas:calendar:dtend"" &lt; '" & _
                  String.Format("{0:yyyy/MM/dd}", dDate.AddDays(5)) & " 00:00:00' " & _
                  "ORDER BY ""urn:schemas:calendar:dtstart"" ASC" & _

        Dim strStatusText As String = ""
        Dim Status As Integer
        Dim ResponseXmlDoc As XmlDocument = SendRequest("SEARCH", strURL, strRequest, strStatusText, Status)
        AddToSchedule(ResponseXmlDoc, Name, dt)

        'Display the results.
        If (Status >= 200 And Status < 300) Then
            AddInfo("<br>Success!   " & "Result = " & Status & ": " & strStatusText, 2)
        ElseIf Status = 401 Then
            AddInfo("<br><font color='red'>Permission denied!</font>", 1)
            AddInfo("<br><font color='red'>Check your permissions for this item.</font>", 2)
            AddInfo("<br><font color='red'>Request failed.</font>", 1)
            AddInfo("<br><font color='red'>Result = " & Status & _
                ": " & strStatusText & "</font>", 2)
        End If

    End Sub

    Sub AddToSchedule(ByVal ResponseXmlDoc As System.Xml.XmlDocument, ByVal Name As String, ByRef dt As DataTable)
        ' Build a list of the DAV:href XML nodes, corresponding to the folders
        ' in the mailbox.  The DAV: namespace is typically assigned the a: prefix in the XML response body.
        If (ResponseXmlDoc Is Nothing) Then Return

        Dim HrefNodes As System.Xml.XmlNodeList = ResponseXmlDoc.GetElementsByTagName("a:href")

        ' Build a list of the urn:schemas:httpmail:subject XML nodes,
        ' corresponding to the calendar item subjects returned in the search request.
        ' The urn:schemas:httpmail: namespace is typically assigned the e: prefix in the XML response body.
        Dim SubjectNodeList As System.Xml.XmlNodeList = ResponseXmlDoc.GetElementsByTagName("e:subject")

        ' Build a list of the urn:schemas:calendar:location XML nodes,
        ' corresponding to the calendar item locations returned in the search request.
        ' The urn:schemas:calendar: namespace is typically assigned the d: prefix in the XML response body.
        Dim LocationNodeList As System.Xml.XmlNodeList = ResponseXmlDoc.GetElementsByTagName("d:location")

        ' Build a list of the urn:schemas:calendar:dtstart XML nodes,
        ' corresponding to the calendar item locations returned in the search request.
        Dim StartTimeNodeList As System.Xml.XmlNodeList = ResponseXmlDoc.GetElementsByTagName("d:dtstart")

        ' Build a list of the urn:schemas:calendar:dtend XML nodes,
        ' corresponding to the calendar item locations returned in the search request.
        Dim EndTimeNodeList As System.Xml.XmlNodeList = ResponseXmlDoc.GetElementsByTagName("d:dtend")

        ' Build a list of the urn:schemas:calendar:busystatus XML nodes,
        ' corresponding to the calendar item locations returned in the search request.
        Dim BusyStatusNodeList As System.Xml.XmlNodeList = ResponseXmlDoc.GetElementsByTagName("d:busystatus")

        ' Build a list of the urn:schemas:calendar:instancetype XML nodes,
        ' corresponding to the calendar item locations returned in the search request.
        Dim InstanceTypeNodeList As System.Xml.XmlNodeList = ResponseXmlDoc.GetElementsByTagName("d:instancetype")

        ' Loop through the returned items (if any).
        If SubjectNodeList.Count > 0 Then

            Dim i As Integer
            For i = 0 To SubjectNodeList.Count - 1
                Dim dr As DataRow = dt.NewRow()
                dr("Subject") = SubjectNodeList(i).InnerText
                dr("StartTime") = DateTime.Parse(StartTimeNodeList(i).InnerText)
                dr("EndTime") = DateTime.Parse(EndTimeNodeList(i).InnerText)
                dr("Status") = BusyStatusNodeList(i).InnerText
                dr("Name") = Name
                dr("Type") = InstanceTypeNodeList(i).InnerText
                '0 = "  Instance type: 0-Single appointment<br>"
                '1 = "  Instance type: 1-Master recurring appointment<br>"
                '2 = "  Instance type: 2-Single instance, recurring appointment<br>"
                '3 = "  Instance type: 3-Exception to a recurring appointment<br>"
            AddInfo2("No calendar items found ...<br>")
        End If
    End Sub

    Sub AddInfo(ByVal info As String, ByVal level As Integer)
        If (level <= errorLevel) Then lblInfo.Text &= info
    End Sub

    Sub AddInfo2(ByVal info As String)
        AddInfo(info, 2)
    End Sub

    Function SendRequest(ByVal strCommand As String, ByVal strURL As String, ByVal strBody As String, _
        ByRef strStatusText As String, ByRef iStatCode As Integer) As XmlDocument

            ' Create a new CredentialCache object and fill it with the network credentials required to access the server.
            Dim Username As String = ConfigurationSettings.AppSettings("UserForReadingCalendars")
            Dim Password As String = ConfigurationSettings.AppSettings("PwdForReadingCalendars")
            Dim strDomain As String = ConfigurationSettings.AppSettings("WindowsDomain")
            Dim myCred As New NetworkCredential(Username, Password, strDomain)
            Dim myUri As System.Uri = New System.Uri(strURL)
            Dim MyCredentialCache As New CredentialCache
            MyCredentialCache.Add(myUri, "NTLM", myCred)

            ' Create the HttpWebRequest object.
            Dim objRequest As HttpWebRequest = CType(WebRequest.Create(strURL), HttpWebRequest)

            ' Add the network credentials to the request.
            objRequest.Credentials = MyCredentialCache

            ' Specify the method.
            objRequest.Method = strCommand

            ' Set Headers
            objRequest.KeepAlive = True
            objRequest.Headers.Set("Pragma", "no-cache")
            objRequest.ContentType = "text/xml"

            'Set the request timeout to 5 minutes
            objRequest.Timeout = 300000

            If (strBody.Length > 0) Then
                ' Store the data in a byte array
                Dim ByteQuery() As Byte = System.Text.Encoding.ASCII.GetBytes(strBody)
                objRequest.ContentLength = ByteQuery.Length
                Dim QueryStream As Stream = objRequest.GetRequestStream()
                ' Write the data to be posted to the Request Stream
                QueryStream.Write(ByteQuery, 0, ByteQuery.Length)
            End If

            ' Send the method request and get the response from the server.
            Dim objResponse As HttpWebResponse = CType(objRequest.GetResponse(), HttpWebResponse)

            ' Get the Status code
            iStatCode = objResponse.StatusCode
            strStatusText = objResponse.StatusDescription

            ' Get the XML response stream.
            Dim ResponseStream As System.IO.Stream = objResponse.GetResponseStream()

            ' Create the XmlDocument object from the XML response stream.
            Dim ResponseXmlDoc As New System.Xml.XmlDocument

            ' Clean up.
            Return ResponseXmlDoc

        Catch ex As Exception

            ' Catch any exceptions. Any error codes from the method requests on the server will be caught here, also.
            AddInfo("<br><font color='red'>" & ex.ToString & "</font>", 2)

        End Try
        Return Nothing

    End Function

    Protected Sub Calendar1_Selectionchanged(ByVal sender As Object, ByVal e As System.EventArgs)
        Response.Redirect(Request.FilePath & "?date=" & Calendar1.SelectedDate.ToShortDateString())
    End Sub

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "">
<html xmlns="">
<head runat="server">
    <link href="css/styles.css" type="text/css" rel="stylesheet" />
    <link href="css/global.css" type="text/css" rel="Stylesheet" />
    <style type="text/css">
            border: 1px solid #00FFFF;
            background-color: #FFFFFF;
    <form id="form1" runat="server">
        <asp:Calendar id="Calendar1" runat="server" 
            onselectionchanged="Calendar1_Selectionchanged" Visible="False"></asp:Calendar>
        <rw:ScheduleGeneral id="ScheduleGeneral1" runat="server" CellSpacing="0" TitleField="Location"  
            StartOfTimeScale="00:00:00" RangeDataFormatString="{0:dd}" Layout="Horizontal" 
            HorizontalAlign="Center" GridLines="None" EndOfTimeScale="23:59:59" 
            DataRangeStartField="StartTime" DataRangeEndField="EndTime" 
            ItemStyleField="" TimeScaleInterval="1440"  
            DateHeaderDataFormatString="{0:dddd}" SeparateDateHeader="True" 
                <table cellpadding="0" width="150px" cellspacing="0" class="style1">
                        <td style=" border: 1px solid #7498BF; background-color: #C5D2E3; text-align: center; color: #002252; font-variant: small-caps;">
                           <b><%#Container.DataItem("Name")%> </b> </td>
                        <td style="text-align:center;" >
                            <%#Convert.ToString(Eval("Subject")).ToString().Substring(0, Math.Min(20, Eval("Subject").Length))%>
               <br />
                <span style=" color:Red; font-weight:bold;"> <%#DataBinder.Eval(Container.DataItem, "StartTime", "{0:HH:mm}")%> - 
                <%#DataBinder.Eval(Container.DataItem, "EndTime", "{0:HH:mm}")%></span>
            <ItemStyle width="100px"  BackColor="White" VerticalAlign="Top" Wrap="True" />
            <BackgroundStyle BackColor="White" />
            <AlternatingItemStyle BackColor="White" 
                BorderStyle="None" BorderWidth="1px" />
            <RangeHeaderStyle cssclass="headerstyle2" BorderStyle="None" />
            <TitleStyle  Width="0px" Height="0px" BorderStyle="None" />
        <br />

        <asp:Label id="lblInfo" runat="server" cssclass="infolabel" Visible="False"></asp:Label>


Is This A Good Question/Topic? 0
  • +

Page 1 of 1