📄 reports.asmx.vb
字号:
Imports System.Web.Services
<System.Web.Services.WebService( _
Namespace:="http://tempuri.org/TimeSheetsWS/Reports", _
Description:="This Web Service produces manager timesheet " & _
"reports for the Time Tracker application.")> _
Public Class Reports
Inherits System.Web.Services.WebService
#Region " Web Services Designer Generated Code "
Public Sub New()
MyBase.New()
'This call is required by the Web Services Designer.
InitializeComponent()
'Add your own initialization code after the InitializeComponent() call
End Sub
'Required by the Web Services Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Web Services Designer
'It can be modified using the Web Services Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
components = New System.ComponentModel.Container
End Sub
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
'CODEGEN: This procedure is required by the Web Services Designer
'Do not modify it using the code editor.
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
#End Region
Private strCompany As String = "Wrox"
Private strApplication As String = "Time Tracker"
Private objTimeSheets As WroxBusinessLogic.WBLTimeSheets
Private objTimeSheetDS As DataSet
Private Sub GenerateHeaderDataSet(ByVal ReportName As String, _
ByVal ManagerID As Guid, ByVal ReportDate As Date)
'Initialize a new instance of the business logic component
objTimeSheets = New WroxBusinessLogic.WBLTimeSheets( _
strCompany, strApplication)
'Get all timesheets that have been submitted for the current year
Dim strManagerName As String = objTimeSheets.GetManagerName(ManagerID)
'Cleanup
objTimeSheets.Dispose()
objTimeSheets = Nothing
'Declare a new DataTable
Dim objDataTable As New DataTable("ReportHeader")
'Declare a DataColumn
Dim objDataColumn As DataColumn
'Create the Title column
objDataColumn = New DataColumn
objDataColumn.DataType = System.Type.GetType("System.String")
objDataColumn.ColumnName = "Title"
'Add the column to the DataTable
objDataTable.Columns.Add(objDataColumn)
'Create the ManagerName column
objDataColumn = New DataColumn
objDataColumn.DataType = System.Type.GetType("System.String")
objDataColumn.ColumnName = "ManagerName"
'Add the column to the DataTable
objDataTable.Columns.Add(objDataColumn)
'Create the Date column
objDataColumn = New DataColumn
objDataColumn.DataType = System.Type.GetType("System.DateTime")
objDataColumn.ColumnName = "Date"
'Add the column to the DataTable
objDataTable.Columns.Add(objDataColumn)
'Create a new DataRow
Dim objDataRow As DataRow = objDataTable.NewRow
'Set the values in the columns
objDataRow.Item("Title") = ReportName
objDataRow.Item("ManagerName") = strManagerName
objDataRow.Item("Date") = ReportDate
'Add the row to the DataSet
objDataTable.Rows.Add(objDataRow)
'Add the DataTable to the DataSet
objTimeSheetDS.Tables.Add(objDataTable)
End Sub
<WebMethod(Description:="Timesheets Due report for the " & _
"employees of a specified manager and week ending date.")> _
Public Function TimeSheetsDue(ByVal ManagerID As Guid, _
ByVal WeekEndingDate As Date) As DataSet
'Initialize a new instance of the business logic component
objTimeSheets = New WroxBusinessLogic.WBLTimeSheets( _
strCompany, strApplication)
'Get all timesheets that are due
objTimeSheetDS = objTimeSheets.TimeSheetsDue(ManagerID, WeekEndingDate)
'Cleanup
objTimeSheets.Dispose()
objTimeSheets = Nothing
'Generate the report header
Call GenerateHeaderDataSet("Timesheets Due", ManagerID, WeekEndingDate)
'Return the TimeSheet DataSet
Return objTimeSheetDS
End Function
<WebMethod(Description:="Timesheets Submitted report for the " & _
"employees of a specified manager and week ending date.")> _
Public Function TimeSheetsSubmitted(ByVal ManagerID As Guid, _
ByVal WeekEndingDate As Date) As DataSet
'Initialize a new instance of the business logic component
objTimeSheets = New WroxBusinessLogic.WBLTimeSheets( _
strCompany, strApplication)
'Get all timesheets that have been submitted
objTimeSheetDS = objTimeSheets.TimeSheetsSubmitted( _
ManagerID, WeekEndingDate)
'Cleanup
objTimeSheets.Dispose()
objTimeSheets = Nothing
'Generate the report header
Call GenerateHeaderDataSet("Timesheets Submitted", _
ManagerID, WeekEndingDate)
'Return the TimeSheet DataSet
Return objTimeSheetDS
End Function
<WebMethod(Description:="Timesheets Month-to-Date report for " & _
"the employees of a specified manager.")> _
Public Function TimeSheetsMTD(ByVal ManagerID As Guid) As DataSet
'Initialize a new instance of the business logic component
objTimeSheets = New WroxBusinessLogic.WBLTimeSheets( _
strCompany, strApplication)
'Get all timesheets that have been submitted for the current month
objTimeSheetDS = objTimeSheets.TimeSheetsMTD(ManagerID)
'Cleanup
objTimeSheets.Dispose()
objTimeSheets = Nothing
'Generate the report header
Call GenerateHeaderDataSet("Timesheets Month-to-Date", ManagerID, Now)
'Return the TimeSheet DataSet
Return objTimeSheetDS
End Function
<WebMethod(Description:="Timesheets Quarter-to-Date report for " & _
"the employees of a specified manager.")> _
Public Function TimeSheetsQTD(ByVal ManagerID As Guid) As DataSet
'Initialize a new instance of the business logic component
objTimeSheets = New WroxBusinessLogic.WBLTimeSheets( _
strCompany, strApplication)
'Get all timesheets that have been submitted for the current quarter
objTimeSheetDS = objTimeSheets.TimeSheetsQTD(ManagerID)
'Cleanup
objTimeSheets.Dispose()
objTimeSheets = Nothing
'Generate the report header
Call GenerateHeaderDataSet("Timesheets Quarter-to-Date", ManagerID, Now)
'Return the TimeSheet DataSet
Return objTimeSheetDS
End Function
<WebMethod(Description:="Timesheets Year-to-Date report for " & _
"the employees of a specified manager.")> _
Public Function TimeSheetsYTD(ByVal ManagerID As Guid) As DataSet
'Initialize a new instance of the business logic component
objTimeSheets = New WroxBusinessLogic.WBLTimeSheets( _
strCompany, strApplication)
'Get all timesheets that have been submitted for the current year
objTimeSheetDS = objTimeSheets.TimeSheetsYTD(ManagerID)
'Cleanup
objTimeSheets.Dispose()
objTimeSheets = Nothing
'Generate the report header
Call GenerateHeaderDataSet("Timesheets Year-to-Date", ManagerID, Now)
'Return the TimeSheet DataSet
Return objTimeSheetDS
End Function
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -