Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Partial Class VSFC_UserInfo
- Inherits System.Web.UI.Page
- Dim vdc As New VerizonDataContext
- Private StartWarehouseIDs As New List(Of Integer)
- Private FinishWarehouseIDs As New List(Of Integer)
- Enum Warehouses
- Awaiting_Receipt = 1
- Starting_Goods = 3
- In_Flashing = 4
- Finished_Flashing = 5
- In_Repair = 6
- Finished_Repair = 7
- In_Post_RF = 8
- Finished_Post_RF = 9
- In_QC = 10
- Failed_QC = 11
- In_FQA = 12
- Finished_Goods = 14
- Shipped = 15
- Open_Inspection = 16
- Finished_Receiving = 17
- Repair_AWP = 19
- In_UR_Validation = 20
- UR_Finished_Goods = 21
- Awaiting_Flashing = 22
- Awaiting_UR_Validation = 23
- Awaiting_Repair = 24
- Failed_FQA = 25
- Failed_RF = 26
- Finished_Alignment = 27
- In_Alignment = 28
- QCF_In_QC = 29
- In_Parts_Assessment = 30
- Finished_Parts_Assessment = 31
- RNR_Finished_Goods = 32
- Take_Phone_to_Supervisor = 33
- Manually_Removed = 34
- Manually_Shipped = 35
- Shipped_RTM = 36
- In_UR_Parts_Removal = 37
- Awaiting_UR_Parts_Removal = 38
- End Enum
- Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
- If Not IsPostBack Then
- Load_Grid()
- End If
- End Sub
- Protected Sub Load_Grid()
- If iMapVars.imap_enabled Then
- Try
- Dim username As String = Page.User.Identity.Name.Trim
- Dim ir As New iMap_Server.iMapResult
- Dim DBTime As Date = GetDBTime()
- If Not User Is Nothing Then
- Dim imap As New iMap_Server.iMap_Functions
- Dim startRepair As IEnumerable(Of WAREHOUSE_LOG)
- Dim endRepair As IEnumerable(Of WAREHOUSE_LOG)
- startRepair = GetStartTimes(username)
- endRepair = GetStopTimes(username)
- For Each stRow As WAREHOUSE_LOG In startRepair
- For Each etRow As WAREHOUSE_LOG In endRepair
- If stRow.user_name.Equals(etRow.user_name) Then
- If stRow.log_date < etRow.log_date Then 'user has scanned something in and is set as repairing
- lblCurrentIdleTime.Text = CType(DBTime - CType(etRow.log_date, Date), TimeSpan).Hours & _
- ":" & CType(DBTime - CType(etRow.log_date, Date), TimeSpan).Minutes.ToString.PadLeft(2, "0") & _
- ":" & CType(DBTime - CType(etRow.log_date, Date), TimeSpan).Seconds.ToString.PadLeft(2, "0")
- lblCurrentRepairTime.Text = "N/A"
- lblCurrentTotalTime.Text = lblCurrentIdleTime.Text
- ElseIf stRow.log_date > etRow.log_date Then
- lblCurrentIdleTime.Text = CType(CType(stRow.log_date, Date) - CType(etRow.log_date, Date), TimeSpan).Hours & _
- ":" & CType(CType(stRow.log_date, Date) - CType(etRow.log_date, Date), TimeSpan).Minutes.ToString.PadLeft(2, "0") & _
- ":" & CType(CType(stRow.log_date, Date) - CType(etRow.log_date, Date), TimeSpan).Seconds.ToString.PadLeft(2, "0")
- lblCurrentRepairTime.Text = CType(DBTime - CType(stRow.log_date, Date), TimeSpan).Hours & _
- ":" & CType(DBTime - CType(stRow.log_date, Date), TimeSpan).Minutes.ToString.PadLeft(2, "0") & _
- ":" & CType(DBTime - CType(stRow.log_date, Date), TimeSpan).Seconds.ToString.PadLeft(2, "0")
- lblCurrentTotalTime.Text = CType(DBTime - CType(etRow.log_date, Date), TimeSpan).Hours & _
- ":" & CType(DBTime - CType(etRow.log_date, Date), TimeSpan).Minutes.ToString.PadLeft(2, "0") & _
- ":" & CType(DBTime - CType(etRow.log_date, Date), TimeSpan).Seconds.ToString.PadLeft(2, "0")
- End If
- End If
- Next
- Next
- Dim dtBegin As Date = Date.Now.Subtract(New TimeSpan(Date.Now.Hour, Date.Now.Minute, Date.Now.Second))
- Dim dtEnd As Date = Date.Now.AddDays(1).Subtract(New TimeSpan(Date.Now.Hour, Date.Now.Minute, Date.Now.Second - 1))
- Dim Bench As String = imap.GetBenchAndBin(username).ReturnedString
- Dim Attachments As Integer = imap.GetAttachmentsByUser(username).ReturnedValue
- Dim BadPartLogs As Integer = imap.GetBadPartRateByUser(username).ReturnedValue
- Dim Consumptions As Integer = imap.GetConsumptionsByUser(username).ReturnedValue
- Dim Lockdowns As Integer = imap.GetLockdownsByUser(username).ReturnedValue
- Dim actionHistory As List(Of ActionHistory) = GetActionHistory(username).ToList
- Me.lblLockdownsToday.Text = Lockdowns
- 'Me.lblCurrentIdleTime.Text =
- Me.lblAttachmentsToday.Text = Attachments
- Me.lblBadPartsToday.Text = BadPartLogs
- Me.lblConsumptionsToday.Text = Consumptions
- Me.lblFPQ.Text = GetFPQ(username)
- If Me.lblFPQ.Text = "N/A" Then
- Me.lblPPH.Text = GetPPH(username).ToString("0.00")
- Else
- Me.lblPPH.Text = (GetPPH(username) * (Convert.ToDouble(Me.lblFPQ.Text) / 100)).ToString("0.00")
- End If
- Me.lblESNsWorkedToday.Text = GetNumberOfWorkedESNS(username)
- If Me.lblESNsWorkedToday.Text > 0 Then
- If Attachments > 0 Then
- Me.lblPPE.Text = (Attachments / Me.lblESNsWorkedToday.Text).ToString("0.00")
- Else
- If Consumptions > 0 Then
- Me.lblPPE.Text = (Consumptions / Me.lblESNsWorkedToday.Text).ToString("0.00")
- Else
- Me.lblPPE.Text = "N/A"
- End If
- End If
- Else
- Me.lblPPE.Text = "N/A"
- End If
- If isUserOnBreak(username) = True Then
- btnStartBreak.Enabled = False
- btnEndBreak.Enabled = True
- Else
- btnStartBreak.Enabled = True
- btnEndBreak.Enabled = False
- End If
- End If
- Catch ex As Exception
- End Try
- End If
- End Sub
- Public Function GetNumberOfWorkedESNS(ByVal UserName As String) As Integer
- Dim dtBegin As Date = Date.Now.Subtract(New TimeSpan(Date.Now.Hour, Date.Now.Minute, Date.Now.Second + 1))
- Dim dtEnd As Date = Date.Now.AddDays(1).Subtract(New TimeSpan(Date.Now.Hour, Date.Now.Minute, Date.Now.Second + 1))
- LoadFinishWarehouseIDs()
- Dim ESNSWorked As Integer = 0
- If rblLocation.SelectedValue.ToLower = "repair" Then
- ESNSWorked = (From a In vdc.REPAIRs _
- Where a.repair_date >= dtBegin And a.repair_date <= dtEnd And a.user_name.Equals(UserName) _
- And a.result_id = 1 _
- Select a.esn_id).Distinct.Count
- Else
- ESNSWorked = (From a In vdc.WAREHOUSE_LOGs _
- Where a.log_date >= dtBegin And a.log_date <= dtEnd And a.user_name.Equals(UserName) And FinishWarehouseIDs.Contains(a.warehouse_id) _
- Select a.esn_id).Distinct.Count
- End If
- Return ESNSWorked
- End Function
- Public Function GetPPH(ByVal UserName As String) As Decimal
- Dim DBTime As Date = GetDBTime()
- Dim dtBegin As Date = DBTime.Subtract(New TimeSpan(Date.Now.Hour, Date.Now.Minute, Date.Now.Second + 1))
- Dim dtEnd As Date = DBTime.AddDays(1).Subtract(New TimeSpan(Date.Now.Hour, Date.Now.Minute, Date.Now.Second + 1))
- Dim decPPH As Decimal = 0
- LoadFinishWarehouseIDs()
- Dim startTime As Date = (From a In vdc.WAREHOUSE_LOGs _
- Where a.log_date >= dtBegin And a.user_name.Equals(UserName) _
- Select a.log_date Order By log_date).FirstOrDefault
- If Not startTime = Nothing Then
- Dim NumPhones As Integer
- If rblLocation.SelectedValue.ToLower = "repair" Then
- NumPhones = (From a In vdc.REPAIRs _
- Where a.repair_date >= startTime And a.repair_date <= DBTime And a.user_name.Equals(UserName) _
- And a.result_id = 1 _
- Select a.esn_id).Distinct.Count 'Valid Repair, ignored UR/RNR etc.
- Else
- NumPhones = (From a In vdc.WAREHOUSE_LOGs _
- Where a.log_date >= startTime And a.log_date <= DBTime And a.user_name.Equals(UserName) And FinishWarehouseIDs.Contains(a.warehouse_id) _
- Select a.esn_id).Distinct.Count
- End If
- Dim NumHours As Decimal = DBTime.Subtract(startTime).TotalHours
- decPPH = NumPhones / NumHours
- End If
- Return decPPH
- End Function
- Public Function GetFPQ(ByVal username As String) As String
- Dim retVal As String = ""
- If rblLocation.SelectedValue.ToLower = "repair" Then
- Dim DBTime As Date = GetDBTime()
- Dim dtBegin As Date = DBTime.AddDays(-5)
- Dim qcResults As IEnumerable(Of QC_TEST) = (From a In vdc.QC_TESTs _
- Where a.REPAIR.user_name.ToLower.Equals(username.ToLower) _
- And a.REPAIR.repair_date >= dtBegin _
- And a.last_repair_id = a.REPAIR.repair_id _
- ).ToList
- Dim passCounter As Integer = 0
- Dim totalCount As Integer = 0
- totalCount = qcResults.Count
- If totalCount > 0 Then
- For Each test As QC_TEST In qcResults
- If test.pass = True Then
- passCounter += 1
- End If
- Next
- If passCounter > 0 Then
- retVal = ((passCounter / totalCount) * 100).ToString("00.0")
- Else
- retVal = "0.0" 'All have failed
- End If
- Else
- retVal = "N/A" 'No QC tests have been performed against this tech's repairs in the last week
- End If
- Else
- Return "N/A"
- End If
- Return retVal
- End Function
- Private Sub LoadFinishWarehouseIDs()
- FinishWarehouseIDs.Clear()
- Select Case rblLocation.SelectedValue
- Case "Other"
- FinishWarehouseIDs.Add(Warehouses.Finished_Flashing)
- FinishWarehouseIDs.Add(Warehouses.Finished_Post_RF)
- FinishWarehouseIDs.Add(Warehouses.Failed_RF)
- FinishWarehouseIDs.Add(Warehouses.Failed_FQA)
- FinishWarehouseIDs.Add(Warehouses.Finished_Goods)
- FinishWarehouseIDs.Add(Warehouses.UR_Finished_Goods)
- FinishWarehouseIDs.Add(Warehouses.RNR_Finished_Goods)
- FinishWarehouseIDs.Add(Warehouses.Failed_QC)
- FinishWarehouseIDs.Add(Warehouses.Finished_Goods)
- FinishWarehouseIDs.Add(Warehouses.UR_Finished_Goods)
- FinishWarehouseIDs.Add(Warehouses.RNR_Finished_Goods)
- FinishWarehouseIDs.Add(Warehouses.Finished_Alignment)
- FinishWarehouseIDs.Add(Warehouses.Finished_Parts_Assessment)
- Case "Repair"
- FinishWarehouseIDs.Add(Warehouses.Finished_Repair)
- FinishWarehouseIDs.Add(Warehouses.Repair_AWP)
- FinishWarehouseIDs.Add(Warehouses.Awaiting_UR_Parts_Removal)
- End Select
- End Sub
- Private Sub LoadStartWarehouseIDs()
- StartWarehouseIDs.Clear()
- Select Case rblLocation.SelectedValue
- Case "Other"
- StartWarehouseIDs.Add(Warehouses.In_Flashing)
- StartWarehouseIDs.Add(Warehouses.In_Post_RF)
- StartWarehouseIDs.Add(Warehouses.In_FQA)
- StartWarehouseIDs.Add(Warehouses.In_QC)
- StartWarehouseIDs.Add(Warehouses.In_Alignment)
- StartWarehouseIDs.Add(Warehouses.In_Parts_Assessment)
- Case "Repair"
- StartWarehouseIDs.Add(Warehouses.In_Repair)
- End Select
- End Sub
- Public Function GetStartTimes(ByVal UserName As String) As Object
- Dim DBTime As Date = GetDBTime()
- DBTime = DBTime.Subtract(New TimeSpan(8, 0, 0))
- Dim StartTimes
- LoadStartWarehouseIDs()
- If rblLocation.SelectedValue.ToLower = "repair" Then
- StartTimes = (From a In vdc.WAREHOUSE_LOGs _
- Where (From b In vdc.WAREHOUSE_LOGs _
- Where b.log_date >= DBTime And _
- StartWarehouseIDs.Contains(b.warehouse_id) _
- Group b By b.user_name Into LogMax = Max(b.log_id) _
- Select LogMax).Contains(a.log_id) And a.user_name = UserName _
- Order By a.user_name)
- Else
- StartTimes = (From a In vdc.WAREHOUSE_LOGs _
- Where (From b In vdc.WAREHOUSE_LOGs _
- Where b.log_date >= DBTime And StartWarehouseIDs.Contains(b.warehouse_id) _
- Group b By b.user_name Into LogMax = Max(b.log_id) _
- Select LogMax).Contains(a.log_id) And a.user_name = UserName _
- Order By a.user_name)
- End If
- Return StartTimes
- End Function
- Public Function GetStopTimes(ByVal UserName As String) As Object
- Dim DBTime As Date = GetDBTime()
- DBTime = DBTime.Subtract(New TimeSpan(8, 0, 0))
- LoadFinishWarehouseIDs()
- Dim StopTimes
- If rblLocation.SelectedValue.ToLower = "repair" Then
- StopTimes = (From a In vdc.WAREHOUSE_LOGs _
- Where (From b In vdc.WAREHOUSE_LOGs _
- Where b.log_date >= DBTime And _
- FinishWarehouseIDs.Contains(b.warehouse_id) _
- Group b By b.user_name Into LogMax = Max(b.log_id) _
- Select LogMax).Contains(a.log_id) And a.user_name = UserName _
- Order By a.user_name)
- Else
- StopTimes = (From a In vdc.WAREHOUSE_LOGs _
- Where (From b In vdc.WAREHOUSE_LOGs _
- Where b.log_date >= DBTime And FinishWarehouseIDs.Contains(b.warehouse_id) _
- Group b By b.user_name Into LogMax = Max(b.log_id) _
- Select LogMax).Contains(a.log_id) And a.user_name = UserName _
- Order By a.user_name)
- End If
- Return StopTimes
- End Function
- Public Function isUserOnBreak(ByVal UserName As String) As Boolean
- Dim WHHistory = (From a In vdc.WAREHOUSE_LOGs _
- Where a.user_name = UserName Order By a.log_date Descending).FirstOrDefault
- Dim BRKHistory = (From a In vdc.BREAK_LOGs _
- Where a.username = UserName Order By a.date_created Descending).FirstOrDefault
- If Not BRKHistory Is Nothing Then
- If BRKHistory.break_start = False Then 'The last log they had was a break finish entry
- Return False
- End If
- If BRKHistory.date_created > WHHistory.log_date Then
- 'if the date of the start of the break is greater than their last
- ' activity then they are on break
- Return True
- End If
- End If
- Return False
- 'If they have reached here then they started again without setting themselves as being back from break
- 'It is a big performance hit to piggy back onto the warehouse log writing to say "hey write that you are back from break"
- 'TODO: Figure out what to do in this case
- End Function
- Public Function GetActionHistory(ByVal UserName As String) As System.Collections.Generic.List(Of ActionHistory)
- Dim dtBegin As Date = Date.Now.Subtract(New TimeSpan(Date.Now.Hour, Date.Now.Minute, Date.Now.Second + 1))
- Dim dtEnd As Date = Date.Now.AddDays(1).Subtract(New TimeSpan(Date.Now.Hour, Date.Now.Minute, Date.Now.Second + 1))
- Dim RepairReworkInfo = (From a In vdc.REPAIRs _
- Where a.user_name = UserName And a.repair_date >= dtBegin And a.repair_date <= dtEnd _
- And a.trip_id > 1 _
- Select a.RMA_ESN.esn_id _
- ).ToList
- Dim WHHistory = (From a In vdc.WAREHOUSE_LOGs _
- Where a.user_name = UserName And a.log_date >= dtBegin And a.log_date <= dtEnd _
- Select a.esn_id, a.RMA_ESN.actual_hex, a.RMA_ESN.actual_dec, a.WAREHOUSE.warehouse_name, _
- a.log_date, a.user_name, a.RMA_ESN.RMA_LINE.DISPOSITION.disposition _
- Order By log_date Descending).ToList
- Dim ActionHistoryList As New List(Of ActionHistory)
- For Each Item In WHHistory
- Dim nwActionHistory As New ActionHistory
- nwActionHistory.Action = Item.warehouse_name
- nwActionHistory.ActionDate = Item.log_date.ToShortTimeString
- nwActionHistory.ESN = Item.actual_dec
- nwActionHistory.Disposition = Item.disposition
- nwActionHistory.Rework = False
- If RepairReworkInfo.Contains(Item.esn_id) Then
- nwActionHistory.Rework = True
- End If
- ActionHistoryList.Add(nwActionHistory)
- Next
- Return ActionHistoryList
- End Function
- Public Function GetDBTime() As Date
- SyncLock vdc
- Return vdc.ExecuteQuery(Of Date)(" Select getdate()").Single()
- End SyncLock
- End Function
- <Serializable()> Public Class ActionHistory
- Private _Action As String
- Private _ActionDate As String
- Private _ESN As String
- 'Private _Key As Integer
- Private _Disposition As String
- ' Private _recorded As Boolean = False
- Private _Rework As String
- Public Property Action() As String
- Get
- Return _Action
- End Get
- Set(ByVal value As String)
- _Action = value
- End Set
- End Property
- Public Property ActionDate() As String
- Get
- Return _ActionDate
- End Get
- Set(ByVal value As String)
- _ActionDate = value
- End Set
- End Property
- Public Property ESN() As String
- Get
- Return _ESN
- End Get
- Set(ByVal value As String)
- _ESN = value
- End Set
- End Property
- Public Property Rework() As Boolean
- Get
- Return _Rework
- End Get
- Set(ByVal value As Boolean)
- _Rework = value
- End Set
- End Property
- Public Property Disposition() As String
- Get
- Return _Disposition
- End Get
- Set(ByVal value As String)
- _Disposition = value
- End Set
- End Property
- End Class
- Protected Sub btnStartBreak_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnStartBreak.Click
- Dim brk As New BREAK_LOG
- With brk
- .break_start = True
- .date_created = Now
- .username = Page.User.Identity.Name.Trim
- End With
- vdc.BREAK_LOGs.InsertOnSubmit(brk)
- vdc.SubmitChanges()
- btnEndBreak.Enabled = True
- btnStartBreak.Enabled = False
- End Sub
- Protected Sub btnEndBreak_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnEndBreak.Click
- Dim brk As New BREAK_LOG
- With brk
- .break_start = False
- .date_created = Now
- .username = Page.User.Identity.Name.Trim
- End With
- vdc.BREAK_LOGs.InsertOnSubmit(brk)
- vdc.SubmitChanges()
- btnEndBreak.Enabled = False
- btnStartBreak.Enabled = True
- End Sub
- Protected Sub btnRefresh_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnRefresh.Click
- Load_Grid()
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement