Zooflow: CheckInOut

This commit is contained in:
Jonathan Jenne
2022-03-28 16:42:47 +02:00
parent c833f486ac
commit ea8b4242ae
20 changed files with 696 additions and 98 deletions

View File

@@ -6,7 +6,6 @@ Imports DevExpress.Utils
Imports DevExpress.XtraBars
Imports DevExpress.XtraEditors
Imports DevExpress.XtraGrid
Imports DevExpress.XtraGrid.Columns
Imports DevExpress.XtraGrid.Views.BandedGrid
Imports DevExpress.XtraGrid.Views.Base
Imports DevExpress.XtraGrid.Views.Grid
@@ -21,6 +20,7 @@ Imports DigitalData.Modules.ZooFlow.Constants
Imports DigitalData.Modules.Base.IDB.FileStore
Imports DigitalData.Controls.MessageBoxEx
Imports DigitalData.GUIs.Common.Base
Imports DigitalData.GUIs.Common.DocumentResultList
Public Class frmDocumentResultList
Implements IResultForm, IBaseForm
@@ -39,6 +39,7 @@ Public Class frmDocumentResultList
Private Client As Client
Private Documentloader As DocumentResultList.Loader
Private ControlManager As AttributeControls
Private CheckoutManager As CheckInOut
Private ReadOnly Config As ConfigManager(Of DocumentResultList.Config)
Private ReadOnly Environment As Environment
@@ -63,6 +64,7 @@ Public Class frmDocumentResultList
Private ReadOnly ColumnFilename As String = "Filename"
Private ReadOnly ColumnDocumentId As String = "DocID"
Private ReadOnly ColumnIcon As String = "ICON"
Private ReadOnly ColumnCheckedOut As String = "CHECKED_OUT"
Private Property _ActiveGrid As GridControl = Nothing
Private Property _ActiveGridBand As GridBand = Nothing
@@ -98,15 +100,15 @@ Public Class frmDocumentResultList
Params = pParams
ResultLists = pParams.Results
Config = New ConfigManager(Of DocumentResultList.Config)(pLogConfig, oConfigPath, oConfigPath)
Config = New ConfigManager(Of Config)(pLogConfig, oConfigPath, oConfigPath)
Helpers = New DocumentResultList.Helpers(pLogConfig)
Filesystem = New Modules.Filesystem.File(pLogConfig)
GridBuilder = New GridBuilder(New List(Of GridView) From {GridView1, GridView2, GridView3})
FileEx = New Modules.Windows.File(pLogConfig)
Watcher = New DocumentResultList.Watcher(pLogConfig)
LayoutManager = New DocumentResultList.Layout(pLogConfig, Config, New List(Of GridView) From {GridView1, GridView2, GridView3})
Watcher = New Watcher(pLogConfig)
LayoutManager = New Layout(pLogConfig, Config, New List(Of GridView) From {GridView1, GridView2, GridView3})
UserLanguage = Utils.NotNull(Me.Environment.User.Language, State.UserState.LANG_EN_US)
UserLanguage = Utils.NotNull(Environment.User.Language, State.UserState.LANG_EN_US)
End Sub
Private Function GetOperationMode() As OperationMode
@@ -254,6 +256,15 @@ Public Class frmDocumentResultList
'End If
Await CtrlObjectPropertyDialog.LoadObject(oObjectId)
Dim oCheckoutState = Await CheckOutManager.GetCheckoutState(oObjectId)
If oCheckoutState IsNot Nothing Then
txtCheckedOutWho.EditValue = oCheckoutState.CheckedOutWho
dateCheckedOutWhen.EditValue = oCheckoutState.CheckedOutWhen
Else
txtCheckedOutWho.EditValue = Nothing
dateCheckedOutWhen.EditValue = Nothing
End If
End If
Else
RibbonPageCategoryFile.Visible = False
@@ -381,6 +392,7 @@ Public Class frmDocumentResultList
Client = New Client(LogConfig, oAddress, oPort)
ControlManager = New AttributeControls(LogConfig, Environment, Client)
CheckoutManager = New CheckInOut(LogConfig, Client)
If Not Client.Connect() Then
Logger.Warn("Client could not connect to Service at [{0}]", Environment.Service.Address)
@@ -540,7 +552,7 @@ Public Class frmDocumentResultList
Private Sub CreateDocumentGrid(GridView As BandedGridView, Result As DocumentResultList.DocumentResult)
Try
If IsNothing(GridView.Columns(ColumnIcon)) Then
If GridView.Columns.Item(ColumnIcon) Is Nothing Then
Dim oIconColumn = GridView.Columns.AddVisible(ColumnIcon, ColumnIcon)
With oIconColumn
.OptionsColumn.AllowSort = False
@@ -557,7 +569,6 @@ Public Class frmDocumentResultList
oFirstBand.Columns.MoveTo(0, oIconColumn)
End If
Dim oColumnsToHide As New List(Of String) From {
ColumnDocumentId,
ColumnFilepath,
@@ -632,40 +643,43 @@ Public Class frmDocumentResultList
'Private Sub GridView1_CustomDrawCell(sender As Object, e As RowCellCustomDrawEventArgs) Handles GridView1.CustomDrawCell
' If e.RowHandle <> GridControl.NewItemRowHandle AndAlso e.Column.FieldName = COLUMN_ICON Then
' Dim oRow As DataRow = TryCast(sender, GridView)?.GetDataRow(e.RowHandle)
' Dim oValue = oRow.Item(COLUMN_FILENAME)
Private Sub GridView1_CustomDrawCell(sender As Object, e As RowCellCustomDrawEventArgs) Handles GridView1.CustomDrawCell
' If oValue.ToString.EndsWith(".pdf") Then
' Dim oIcon = My.Resources.pdf
' e.Cache.DrawImage(oIcon, e.Bounds.X + 0, e.Bounds.Y + 0, 18, 18)
' End If
' End If
' 'Try
' ' If e.RowHandle < 0 Then
' ' Exit Sub
' ' End If
' ' e.DefaultDraw()
'If e.RowHandle <> GridControl.NewItemRowHandle AndAlso e.Column.FieldName = ColumnIcon Then
' Dim oRow As DataRow = TryCast(sender, GridView)?.GetDataRow(e.RowHandle)
' Dim oValue = oRow.Item(COLUMN_FILENAME)
' ' Dim oView As GridView = TryCast(sender, GridView)
' ' Dim oCellInfo As GridCellInfo = TryCast(e.Cell, GridCellInfo)
' ' Dim oRow As DataRow = oView.GetDataRow(e.RowHandle)
' ' Dim oValue = oRow.Item(COLUMN_FILENAME)
' If oValue.ToString.EndsWith(".pdf") Then
' Dim oIcon = My.Resources.pdf
' e.Cache.DrawImage(oIcon, e.Bounds.X + 0, e.Bounds.Y + 0, 18, 18)
' End If
'End If
' ' If e.Column.FieldName = COLUMN_ICON Then
' ' Dim oIcon = Helpers.GetIconByExtension(oValue)
' ' Dim offsetX = 0
' ' Dim offsetY = 0
'Try
' If e.RowHandle < 0 Then
' Exit Sub
' End If
' ' e.Cache.DrawImage(oIcon, e.Bounds.X + offsetX, e.Bounds.Y + offsetY, 18, 18)
' ' End If
' 'Catch ex As Exception
' ' Logger.Error(ex)
' 'End Try
'End Sub
' e.DefaultDraw()
' Dim oView As GridView = TryCast(sender, GridView)
' Dim oCellInfo As GridCellInfo = TryCast(e.Cell, GridCellInfo)
' Dim oRow As DataRow = oView.GetDataRow(e.RowHandle)
' Dim oValue = oRow.Item(COLUMN_FILENAME)
' If e.Column.FieldName = COLUMN_ICON Then
' Dim oIcon = Helpers.GetIconByExtension(oValue)
' Dim offsetX = 0
' Dim offsetY = 0
' e.Cache.DrawImage(oIcon, e.Bounds.X + offsetX, e.Bounds.Y + offsetY, 18, 18)
' End If
'Catch ex As Exception
' Logger.Error(ex)
'End Try
End Sub
Private Sub BarButtonItemExportGrid1_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItemExportGrid1.ItemClick
Dim oActiveGrid = GetActiveGridControl()
@@ -856,6 +870,43 @@ Public Class frmDocumentResultList
Process.Start(oInfo)
End Sub
Private Async Sub MenuItemCheckOutFile_ItemClick(sender As Object, e As ItemClickEventArgs) Handles MenuItemCheckOutFile.ItemClick
Dim oObjectId = _CurrentDocument?.Id
Dim oResultComment As String = ShowCheckInOutCommentForm()
If IsNothing(oResultComment) Then
Exit Sub
End If
Await Client.CheckOutFile(oObjectId, oResultComment)
End Sub
Private Sub MenuItemCheckInFile_ItemClick(sender As Object, e As ItemClickEventArgs) Handles MenuItemCheckInFile.ItemClick
Dim oObjectId = _CurrentDocument?.Id
Client.CheckInFile(oObjectId)
End Sub
Private Function ShowCheckInOutCommentForm()
Dim editor As New MemoEdit()
Dim args As New XtraInputBoxArgs With {
.Caption = "Checkout/in Kommentar",
.Prompt = "Kommentar",
.DefaultButtonIndex = 0,
.Editor = editor,
.DefaultResponse = ""
}
args.ContentPadding = args.ButtonPadding
AddHandler args.Showing, AddressOf Args_Showing
Dim result = XtraInputBox.Show(args).ToString()
Return result
End Function
Private Sub Args_Showing(ByVal sender As Object, ByVal e As XtraMessageShowingArgs)
e.Form.Icon = Me.Icon
End Sub
#End Region
#Region "Drag to Export"
@@ -974,4 +1025,13 @@ Public Class frmDocumentResultList
Private Sub CtrlObjectPropertyDialog_Leave(sender As Object, e As EventArgs) Handles CtrlObjectPropertyDialog.Leave
RibbonPageCategoryAttribute.Visible = False
End Sub
Private Sub GridView1_RowStyle(sender As Object, e As RowStyleEventArgs) Handles GridView1.RowStyle
Dim oGridView As BandedGridView = sender
Dim oRow As DataRowView = oGridView.GetRow(e.RowHandle)
If oRow IsNot Nothing AndAlso oRow.Row.Item(ColumnCheckedOut) IsNot Nothing AndAlso oRow.Row.Item(ColumnCheckedOut) = True Then
e.Appearance.BackColor = Color.LightSalmon
End If
End Sub
End Class