home *** CD-ROM | disk | FTP | other *** search
/ 66.142.0.142 / 66.142.0.142.tar / 66.142.0.142 / iPhone / unshift.aspx.vb < prev   
Text File  |  2014-11-01  |  7KB  |  135 lines

  1. ∩╗┐Imports System.Data.OleDb
  2. Imports System.Web
  3. Imports System.Net.Mail
  4. Imports Microsoft.Exchange.WebServices.Data
  5. Imports System.Net
  6. Imports System.Net.Security
  7. Imports System.Security.Cryptography.X509Certificates
  8. Imports Microsoft.Exchange.WebServices.Autodiscover
  9.  
  10. Partial Class iPhoneNet_Default
  11.     Inherits AspNetMaker7_tfpssnet
  12.  
  13.     Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  14.         srcLocations.ConnectionString = EW_DB_CONNECTION_STRING
  15.         srcPositions.ConnectionString = EW_DB_CONNECTION_STRING
  16.         ddlLocation.SelectedValue = 38
  17.         ddlPosition.SelectedValue = 62
  18.     End Sub
  19.  
  20.  
  21.     Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
  22.         'Dim service As New ExchangeService(requestedServerVersion:=ExchangeVersion.Exchange2010)
  23.         Dim service As New ExchangeService(ExchangeVersion.Exchange2010_SP1)
  24.  
  25.         Dim tmpSchDate As String, tmpEventName As String, tmpEmployeeName As String, tmpEmpID As Integer, tmpPartName As String, tmpCallTime As String, tmpStartTime As String
  26.         Dim tmpLocationID As Integer, tmpPositionId As Integer, tmpTypeName As String, tmpReason As String, tmpActualStartTime As String, tmpStatus As String, tmpDateCreated As String
  27.         Dim sSql As String
  28.  
  29.         tmpSchDate = Request.Form("eventdate")
  30.         tmpEventName = Request.Form("eventname")
  31.         tmpEmployeeName = Session("TFProduction_Status_UserID")
  32.         tmpEmpID = Session("TFProduction_Status_EmpID")
  33.         tmpPartName = Request.Form("partname")
  34.         'tmpCallTime=request.form("calltime")
  35.         tmpCallTime = Now()
  36.         'tmpStartTime=request.form("starttime")
  37.         tmpStartTime = Now()
  38.         'tmpLocationID = Request.Form("LocationName")
  39.         'tmpPositionId = Request.Form("PositionName")
  40.         tmpLocationID = ddlLocation.SelectedItem.Value
  41.         tmpPositionId = ddlPosition.SelectedItem.Value
  42.         tmpTypeName = Request.Form("typename")
  43.         tmpReason = Request.Form("reason")
  44.         'tmpActualStartTime=request.form("actualstarttime")
  45.         tmpActualStartTime = Now()
  46.         tmpStatus = Request.Form("status")
  47.         tmpDateCreated = tmpSchDate
  48.  
  49.         sSql = "INSERT INTO tblSchedule (schDate, schDayOfWeek, schEmpID, schEvtID, schPartsID, schCallTime, schStartTime, schLocID, schPosID, schTypID, schNotes, schActualStart, schStatus, schDateCreated, schRate) " _
  50. & "VALUES ("
  51.         sSql += "#" & ew_FormatDateTime(tmpSchDate, 2) & "#"
  52.         sSql += ", " & Weekday(tmpSchDate)
  53.         sSql += ", " & tmpEmpID
  54.         sSql += ", 40"
  55.         sSql += ", 61"
  56.         sSql += ", #" & ew_FormatDateTime(tmpSchDate, 2) & " " & ew_FormatDateTime(tmpCallTime, 14) & "#"
  57.         sSql += ", #" & ew_FormatDateTime(tmpSchDate, 2) & " " & ew_FormatDateTime(tmpStartTime, 14) & "#"
  58.         sSql += ", " & tmpLocationID
  59.         sSql += ", " & tmpPositionId
  60.         '        sSql += ", 10"
  61.         sSql += ", 2"
  62.         sSql += ", '" & tmpReason.Replace("'", "''") & "'"
  63.         sSql += ", #" & ew_FormatDateTime(tmpSchDate, 2) & " " & ew_FormatDateTime(tmpActualStartTime, 14) & "#"
  64.         sSql += ", 1"
  65.         sSql += ", #" & ew_FormatDateTime(tmpDateCreated, 2) & "#"
  66.         sSql += ", " & tlcGetEmployeeRate(tmpEmpID)
  67.         sSql += ")"
  68.         If ew_Execute(sSql) <> 1 Then
  69.             Session("tmpErrorMessage") = "Error adding unscheduled shift.  Shift was not added."
  70.             Response.Redirect("unshift_error.aspx")
  71.         End If
  72.  
  73.         Dim tmpMessage As String
  74.         tmpMessage = "<b>Employee:</b> " & tmpEmployeeName & "<br>"
  75.         tmpMessage += "<b>Schedule Date:</b> " & ew_FormatDateTime(tmpSchDate, 2) & "<br>"
  76.         tmpMessage += "<b>Event Name:</b> " & tmpEventName & "<br>"
  77.         tmpMessage += "<b>Part Name:</b> " & tmpPartName & "<br>"
  78.         tmpMessage += "<b>Start Time:</b> " & ew_FormatDateTime(tmpStartTime, 14) & "<br>"
  79.         tmpMessage += "<b>Call Time:</b> " & ew_FormatDateTime(tmpCallTime, 14) & "<br>"
  80.         tmpMessage += "<b>Location:</b> " & tlcGetLocationName(tmpLocationID) & "<br>"
  81.         tmpMessage += "<b>Employee Name:</b> " & tmpEmployeeName & "<br>"
  82.         tmpMessage += "<b>Position:</b> " & tlcGetPositionName(tmpPositionId) & "<br>"
  83.         tmpMessage += "<b>Type Name:</b> " & tmpTypeName & "<br>"
  84.         tmpMessage += "<b>Reason for Unscheduled Shift:</b> " & tmpReason & "<br>"
  85.         tmpMessage += "<b>Actual Start:</b> " & ew_FormatDateTime(tmpActualStartTime, 14) & "<br>"
  86.         tmpMessage += "<b>Status:</b> Confirmed<br>"
  87.         tmpMessage += "<b>Date Created:</b> " & ew_FormatDateTime(tmpDateCreated, 2) & "<br>"
  88.         tmpMessage += "sent from PSS iPhone/unshift."
  89.         '        ew_SendEmail("prodservices@tfchurch.org", "kirkmanton@tfchurch.org", "", "", "PSS Unscheduled Shift Clocked In for " & tmpEmployeeName, tmpMessage, "html")
  90.         'Add a valid EWS service end point here or user Autodiscover
  91.         'service.Url = New Uri("https://server14/ews/exchange.asmx")
  92.         service.Url = New Uri("https://outlook.office365.com/EWS/Exchange.asmx")
  93.         'Add a valid user credentials
  94.         'service.Credentials = New WebCredentials("prodservices", "production88", "Business")
  95.         service.Credentials = New WebCredentials("productionservices@tfc.org", "production88")
  96.         service.AutodiscoverUrl("productionservices@tfc.org", AddressOf RedirectionUrlValaditionCallback)
  97.         'To address the SSL challenge
  98.         ServicePointManager.ServerCertificateValidationCallback = New RemoteCertificateValidationCallback(AddressOf ValidateCertificate)
  99.  
  100.         Try
  101.             'Create new message object and set properties required to send a mail
  102.             Dim msg As EmailMessage = New EmailMessage(service)
  103.             msg.Subject = "PSS Unscheduled Shift Clocked In for " & ew_Session("TFProduction_Status_UserName")
  104.             msg.Body = tmpMessage
  105.             'msg.ToRecipients.Add("tony.clayton@suddenlink.net")
  106.             'msg.ToRecipients.Add("tonyc@tfchurch.org")
  107.             msg.ToRecipients.Add("kirkmanton@tfc.org")
  108.             msg.From = "productionservices@tfc.org"
  109.             msg.SendAndSaveCopy()
  110.             '                                            Message = "Email sent."
  111.         Catch ex As Exception
  112.             '                        Message = ex.Message
  113.             ew_Session("iPhoneMessage") = ex.Message
  114.         End Try
  115.  
  116.  
  117.         Response.Redirect("clockinout.aspx")
  118.     End Sub
  119.  
  120.     Private Shared Function RedirectionUrlValaditionCallback(ByVal redirectionUrl As String) As Boolean
  121.         Dim result As Boolean = False
  122.         Dim redirectionuri As New Uri(redirectionUrl)
  123.         If redirectionuri.Scheme = "https" Then
  124.             result = True
  125.         End If
  126.         Return result
  127.     End Function
  128.  
  129.     Private Function ValidateCertificate(ByVal sender As Object, ByVal certificate As X509Certificate, ByVal chain As X509Chain, ByVal sslPolicyErrors As SslPolicyErrors) As Boolean
  130.         'Return True to force the certificate to be accepted.
  131.         Return True
  132.     End Function
  133.  
  134. End Class
  135.