WIP: Streaming files from service to client

This commit is contained in:
Jonathan Jenne
2020-04-14 16:25:16 +02:00
parent 52a6d103e6
commit a20c0eb4b0
19 changed files with 211 additions and 49 deletions

View File

@@ -29,9 +29,12 @@ Partial Class Form1
Me.ButtonImportFiles = New DevExpress.XtraBars.BarButtonItem()
Me.buttonClearLog = New DevExpress.XtraBars.BarButtonItem()
Me.buttonClearFiles = New DevExpress.XtraBars.BarButtonItem()
Me.TextboxObejctId = New DevExpress.XtraBars.BarEditItem()
Me.RepositoryItemTextEdit1 = New DevExpress.XtraEditors.Repository.RepositoryItemTextEdit()
Me.ButtonLoadFile = New DevExpress.XtraBars.BarButtonItem()
Me.RibbonPage1 = New DevExpress.XtraBars.Ribbon.RibbonPage()
Me.RibbonPageGroup1 = New DevExpress.XtraBars.Ribbon.RibbonPageGroup()
Me.RibbonPageGroup2 = New DevExpress.XtraBars.Ribbon.RibbonPageGroup()
Me.RibbonPageGroup4 = New DevExpress.XtraBars.Ribbon.RibbonPageGroup()
Me.RibbonPageGroup3 = New DevExpress.XtraBars.Ribbon.RibbonPageGroup()
Me.RibbonStatusBar1 = New DevExpress.XtraBars.Ribbon.RibbonStatusBar()
Me.RibbonPage2 = New DevExpress.XtraBars.Ribbon.RibbonPage()
@@ -40,9 +43,10 @@ Partial Class Form1
Me.XtraTabControl1 = New DevExpress.XtraTab.XtraTabControl()
Me.XtraTabPage1 = New DevExpress.XtraTab.XtraTabPage()
Me.XtraTabPage2 = New DevExpress.XtraTab.XtraTabPage()
Me.listboxFileids = New DevExpress.XtraEditors.ListBoxControl()
Me.DocumentViewer1 = New DigitalData.Controls.DocumentViewer.DocumentViewer()
CType(Me.listboxFiles, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.RibbonControl1, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.RepositoryItemTextEdit1, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.SplitContainerControl1, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SplitContainerControl1.SuspendLayout()
CType(Me.listboxLog, System.ComponentModel.ISupportInitialize).BeginInit()
@@ -50,7 +54,6 @@ Partial Class Form1
Me.XtraTabControl1.SuspendLayout()
Me.XtraTabPage1.SuspendLayout()
Me.XtraTabPage2.SuspendLayout()
CType(Me.listboxFileids, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'listboxFiles
@@ -64,11 +67,12 @@ Partial Class Form1
'RibbonControl1
'
Me.RibbonControl1.ExpandCollapseItem.Id = 0
Me.RibbonControl1.Items.AddRange(New DevExpress.XtraBars.BarItem() {Me.RibbonControl1.ExpandCollapseItem, Me.RibbonControl1.SearchEditItem, Me.ButtonSelectFiles, Me.ButtonImportFiles, Me.buttonClearLog, Me.buttonClearFiles})
Me.RibbonControl1.Items.AddRange(New DevExpress.XtraBars.BarItem() {Me.RibbonControl1.ExpandCollapseItem, Me.RibbonControl1.SearchEditItem, Me.ButtonSelectFiles, Me.ButtonImportFiles, Me.buttonClearLog, Me.buttonClearFiles, Me.TextboxObejctId, Me.ButtonLoadFile})
Me.RibbonControl1.Location = New System.Drawing.Point(0, 0)
Me.RibbonControl1.MaxItemId = 5
Me.RibbonControl1.MaxItemId = 7
Me.RibbonControl1.Name = "RibbonControl1"
Me.RibbonControl1.Pages.AddRange(New DevExpress.XtraBars.Ribbon.RibbonPage() {Me.RibbonPage1})
Me.RibbonControl1.RepositoryItems.AddRange(New DevExpress.XtraEditors.Repository.RepositoryItem() {Me.RepositoryItemTextEdit1})
Me.RibbonControl1.Size = New System.Drawing.Size(1145, 158)
Me.RibbonControl1.StatusBar = Me.RibbonStatusBar1
'
@@ -100,30 +104,51 @@ Partial Class Form1
Me.buttonClearFiles.ImageOptions.SvgImage = CType(resources.GetObject("buttonClearFiles.ImageOptions.SvgImage"), DevExpress.Utils.Svg.SvgImage)
Me.buttonClearFiles.Name = "buttonClearFiles"
'
'TextboxObejctId
'
Me.TextboxObejctId.Caption = "Document Id"
Me.TextboxObejctId.Edit = Me.RepositoryItemTextEdit1
Me.TextboxObejctId.EditWidth = 100
Me.TextboxObejctId.Id = 5
Me.TextboxObejctId.Name = "TextboxObejctId"
'
'RepositoryItemTextEdit1
'
Me.RepositoryItemTextEdit1.AutoHeight = False
Me.RepositoryItemTextEdit1.Name = "RepositoryItemTextEdit1"
'
'ButtonLoadFile
'
Me.ButtonLoadFile.Caption = "Load File"
Me.ButtonLoadFile.Id = 6
Me.ButtonLoadFile.Name = "ButtonLoadFile"
'
'RibbonPage1
'
Me.RibbonPage1.Groups.AddRange(New DevExpress.XtraBars.Ribbon.RibbonPageGroup() {Me.RibbonPageGroup1, Me.RibbonPageGroup2, Me.RibbonPageGroup3})
Me.RibbonPage1.Groups.AddRange(New DevExpress.XtraBars.Ribbon.RibbonPageGroup() {Me.RibbonPageGroup1, Me.RibbonPageGroup4, Me.RibbonPageGroup3})
Me.RibbonPage1.Name = "RibbonPage1"
Me.RibbonPage1.Text = "Import Files"
Me.RibbonPage1.Text = "Start"
'
'RibbonPageGroup1
'
Me.RibbonPageGroup1.ItemLinks.Add(Me.ButtonSelectFiles)
Me.RibbonPageGroup1.ItemLinks.Add(Me.ButtonImportFiles)
Me.RibbonPageGroup1.Name = "RibbonPageGroup1"
Me.RibbonPageGroup1.Text = "RibbonPageGroup1"
Me.RibbonPageGroup1.Text = "Import"
'
'RibbonPageGroup2
'RibbonPageGroup4
'
Me.RibbonPageGroup2.ItemLinks.Add(Me.ButtonImportFiles)
Me.RibbonPageGroup2.Name = "RibbonPageGroup2"
Me.RibbonPageGroup2.Text = "RibbonPageGroup2"
Me.RibbonPageGroup4.ItemLinks.Add(Me.TextboxObejctId)
Me.RibbonPageGroup4.ItemLinks.Add(Me.ButtonLoadFile)
Me.RibbonPageGroup4.Name = "RibbonPageGroup4"
Me.RibbonPageGroup4.Text = "Retrieve"
'
'RibbonPageGroup3
'
Me.RibbonPageGroup3.ItemLinks.Add(Me.buttonClearLog)
Me.RibbonPageGroup3.ItemLinks.Add(Me.buttonClearLog, True)
Me.RibbonPageGroup3.ItemLinks.Add(Me.buttonClearFiles)
Me.RibbonPageGroup3.Name = "RibbonPageGroup3"
Me.RibbonPageGroup3.Text = "RibbonPageGroup3"
Me.RibbonPageGroup3.Text = "Utils"
'
'RibbonStatusBar1
'
@@ -173,22 +198,22 @@ Partial Class Form1
Me.XtraTabPage1.Controls.Add(Me.SplitContainerControl1)
Me.XtraTabPage1.Name = "XtraTabPage1"
Me.XtraTabPage1.Size = New System.Drawing.Size(1143, 270)
Me.XtraTabPage1.Text = "XtraTabPage1"
Me.XtraTabPage1.Text = "Information"
'
'XtraTabPage2
'
Me.XtraTabPage2.Controls.Add(Me.listboxFileids)
Me.XtraTabPage2.Controls.Add(Me.DocumentViewer1)
Me.XtraTabPage2.Name = "XtraTabPage2"
Me.XtraTabPage2.Size = New System.Drawing.Size(1143, 270)
Me.XtraTabPage2.Text = "XtraTabPage2"
Me.XtraTabPage2.Text = "DocumentViewer"
'
'listboxFileids
'DocumentViewer1
'
Me.listboxFileids.Dock = System.Windows.Forms.DockStyle.Left
Me.listboxFileids.Location = New System.Drawing.Point(0, 0)
Me.listboxFileids.Name = "listboxFileids"
Me.listboxFileids.Size = New System.Drawing.Size(278, 270)
Me.listboxFileids.TabIndex = 0
Me.DocumentViewer1.Dock = System.Windows.Forms.DockStyle.Fill
Me.DocumentViewer1.Location = New System.Drawing.Point(0, 0)
Me.DocumentViewer1.Name = "DocumentViewer1"
Me.DocumentViewer1.Size = New System.Drawing.Size(1143, 270)
Me.DocumentViewer1.TabIndex = 0
'
'Form1
'
@@ -204,6 +229,7 @@ Partial Class Form1
Me.Text = "Form1"
CType(Me.listboxFiles, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.RibbonControl1, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.RepositoryItemTextEdit1, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.SplitContainerControl1, System.ComponentModel.ISupportInitialize).EndInit()
Me.SplitContainerControl1.ResumeLayout(False)
CType(Me.listboxLog, System.ComponentModel.ISupportInitialize).EndInit()
@@ -211,7 +237,6 @@ Partial Class Form1
Me.XtraTabControl1.ResumeLayout(False)
Me.XtraTabPage1.ResumeLayout(False)
Me.XtraTabPage2.ResumeLayout(False)
CType(Me.listboxFileids, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
Me.PerformLayout()
@@ -220,7 +245,6 @@ Partial Class Form1
Friend WithEvents RibbonControl1 As DevExpress.XtraBars.Ribbon.RibbonControl
Friend WithEvents RibbonPage1 As DevExpress.XtraBars.Ribbon.RibbonPage
Friend WithEvents RibbonPageGroup1 As DevExpress.XtraBars.Ribbon.RibbonPageGroup
Friend WithEvents RibbonPageGroup2 As DevExpress.XtraBars.Ribbon.RibbonPageGroup
Friend WithEvents RibbonStatusBar1 As DevExpress.XtraBars.Ribbon.RibbonStatusBar
Friend WithEvents RibbonPage2 As DevExpress.XtraBars.Ribbon.RibbonPage
Friend WithEvents ButtonSelectFiles As DevExpress.XtraBars.BarButtonItem
@@ -232,6 +256,10 @@ Partial Class Form1
Friend WithEvents buttonClearFiles As DevExpress.XtraBars.BarButtonItem
Friend WithEvents XtraTabControl1 As DevExpress.XtraTab.XtraTabControl
Friend WithEvents XtraTabPage1 As DevExpress.XtraTab.XtraTabPage
Friend WithEvents TextboxObejctId As DevExpress.XtraBars.BarEditItem
Friend WithEvents RepositoryItemTextEdit1 As DevExpress.XtraEditors.Repository.RepositoryItemTextEdit
Friend WithEvents ButtonLoadFile As DevExpress.XtraBars.BarButtonItem
Friend WithEvents RibbonPageGroup4 As DevExpress.XtraBars.Ribbon.RibbonPageGroup
Friend WithEvents XtraTabPage2 As DevExpress.XtraTab.XtraTabPage
Friend WithEvents listboxFileids As DevExpress.XtraEditors.ListBoxControl
Friend WithEvents DocumentViewer1 As DigitalData.Controls.DocumentViewer.DocumentViewer
End Class

View File

@@ -15,6 +15,8 @@ Public Class Form1
"net.tcp://172.24.12.39:9000/DigitalData/Services/Main")
_Channel = oChannelFactory.CreateChannel()
_Channel.Open()
DocumentViewer1.Init(oLogConfig, "21182889975216572111813147150675976632")
End Sub
Private Sub ButtonSelectFiles_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles ButtonSelectFiles.ItemClick
@@ -53,7 +55,6 @@ Public Class Form1
Dim oResult As EDMIServiceReference.DocumentResult2 = Await _Channel.ImportFileAsync(oFileInfo.Name, oContents, Environment.UserName)
If oResult.OK Then
listboxLog.Items.Add($"File [{oFileInfo.Name}] with Id [{oResult.Document.FileId}] imported!")
listboxFileids.Items.Add(oResult.Document.FileId)
Else
listboxLog.Items.Add($"Import Error: {oResult.ErrorMessage}")
End If
@@ -111,4 +112,25 @@ Public Class Form1
End Try
End Function
Private Async Sub ButtonLoadFile_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles ButtonLoadFile.ItemClick
Try
If TextboxObejctId.EditValue = "" Then
MsgBox("Please enter an object id!", MsgBoxStyle.Exclamation, "Uh oh!")
End If
Dim oObjectId As Integer = TextboxObejctId.EditValue
Dim oStream = Await _Channel.GetFileByObjectIdAsync(oObjectId)
Dim oMemoryStream As New MemoryStream()
oStream.CopyTo(oMemoryStream)
oMemoryStream.Position = 0
listboxLog.Items.Add("Stream read!")
DocumentViewer1.LoadFile("textfile.png", oMemoryStream)
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical, "Uh oh!")
End Try
End Sub
End Class

View File

@@ -57,6 +57,12 @@
<Reference Include="DigitalData.Controls.DocumentViewer">
<HintPath>..\Controls.DocumentViewer\obj\Debug\DigitalData.Controls.DocumentViewer.dll</HintPath>
</Reference>
<Reference Include="GdPicture.NET.14">
<HintPath>D:\ProgramFiles\GdPicture.NET 14\Redist\GdPicture.NET (.NET Framework 4.5)\GdPicture.NET.14.dll</HintPath>
</Reference>
<Reference Include="Independentsoft.Msg">
<HintPath>P:\Visual Studio Projekte\Bibliotheken\MSG .NET\Bin\22_11_19\Independentsoft.Msg.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CSharp" />
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.4.7.0\lib\net45\NLog.dll</HintPath>
@@ -142,6 +148,10 @@
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Controls.DocumentViewer\DocumentViewer.vbproj">
<Project>{0958cddf-4a16-41f6-8837-8335f71d599c}</Project>
<Name>DocumentViewer</Name>
</ProjectReference>
<ProjectReference Include="..\Modules.EDMIAPI\EDMI.API.vbproj">
<Project>{25017513-0d97-49d3-98d7-ba76d9b251b0}</Project>
<Name>EDMI.API</Name>

View File

@@ -1 +1,2 @@
DevExpress.XtraEditors.Repository.RepositoryItemTextEdit, DevExpress.XtraEditors.v19.2, Version=19.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
DevExpress.XtraBars.Ribbon.RibbonControl, DevExpress.XtraBars.v19.2, Version=19.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a