Click or drag to resize
XFileField Class
Class XFileField.

 

Code of field: F (for File)

Type of field: container for files of any format (pictures, MS-Office documents, trace files, etc).

Storage: The file content is stored in a BLOB (Binary Large Object) in the database.

Applicable to:

Any file of any format associated with a given record. Files that are too large could create problems depending on the setting of the underlying database (MySQL, MongoDB) since some size limitations may apply.

Inheritance Hierarchy

Namespace:  Biolomics.BioCallback
Assembly:  Biolomics.BioCallback (in Biolomics.BioCallback.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
public class XFileField : XField

The XFileField type exposes the following members.

Constructors
  NameDescription
Public methodXFileField(XFileField)
Copy ctor
Public methodXFileField(TFileField, XRecord)
Initializes a new instance of the XFileField class.
Public methodXFileField(XFileField, XRecord)
Copy ctor but into a new XRecord
Top
Properties
  NameDescription
Public propertyContent
Gets or sets the content of the file.
Public propertyFieldValue
Gets or sets the field value.
(Overrides XFieldFieldValue.)
Public propertyFileName
Gets or sets the name of the file.
Public propertyIsModified
Gets or sets a value indicating whether this instance is modified.
(Inherited from XField.)
Top
Methods
  NameDescription
Public methodCanRead
Determines whether current connection can read from Field.
(Inherited from XField.)
Public methodCanUploadFile
Determines whether this instance [can upload file] the specified main SQL co.
Public methodCanWrite
Determines whether current connection can write from Field.
(Inherited from XField.)
Public methodClear
Clears this instance.
(Inherited from XField.)
Public methodClone
Clones this instance.
Public methodCloneAsXField
We cannot use name 'Clone' here otherwise Implements vector.TId(Of XSField) fails because XSField.Clone() returns a XField instead of a XSField !!!
(Overrides XFieldCloneAsXField(XRecord).)
Public methodDataToView
Converts field value to readable string.
(Inherited from XField.)
Public methodDataToView(Int32)
Mandatory otherwise DataToView(5) returns letter 5 of string given by DataToView(), instead of the subfield value
(Inherited from XField.)
Public methodEquals
Determines whether the specified Object is equal to this instance.
(Inherited from XField.)
Protected methodField
each derived class embed its own TField member, which can be a TAField, TCField, TEField, etc. this function must return that original TField
(Overrides XFieldField.)
Public methodFieldDef
Gets the Field definition.
(Inherited from XField.)
Public methodFieldType
The Field type.
(Inherited from XField.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodKey
Gets Field Key.
(Inherited from XField.)
Public methodLoadLocalFile
Loads the local file.
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodParentRecord
Gets the parent record.
(Inherited from XField.)
Public methodRead
Reads the Content from source object.
(Inherited from XField.)
Public methodReset
Resets this instance.
(Inherited from XField.)
Public methodSaveLocalFile
Saves the local file.
Public methodSetDefaultValues
Sets the default values.
(Inherited from XField.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Public methodWrite
Writes data into a TQuery and Format it depending to field type
(Inherited from XField.)
Top
Examples
This is an example of how to upload file in flink field or file field.
Example VB.Net
Imports System
Imports System.Collections
Imports Biolomics.BioCallback
Imports Biolomics.SharedClasses
Imports Biolomics.Utility.DatabaseConstants


Public Class Program

    <STAThread()>
    Shared Sub Main()
        Dim program As New Program
        program.UploadFile()
        program.CheckRecords()
    End Sub

    Public Sub UploadFile()
        '    *****    Get selected record IDs    *****
        Dim RecordIdList As New Generic.List(Of Integer)
        Dim ErrorCode As Integer = Run.GetSelRecordIdList(RecordIdList, Run.GetRecordIdListEnum.Selected)
        If RecordIdList.Count = 0 Then
            Return
        End If

        '    get the current connection
        Dim SqlCo As XConnection = Run.GetCurrentConnection()
        If SqlCo Is Nothing Then
            Return
        End If

        '    get the current layout table 
        Dim CurrentLayout As XDataLayout = Run.GetCurrentLayout()
        If CurrentLayout Is Nothing Then
            Return
        End If

        '    get the current table displayed in that layout
        Dim TableDef As XTableDef = SqlCo.GetTableDef(CurrentLayout.TableKey)
        If TableDef Is Nothing Then
            Return
        End If

        Dim FullFileName As String = "Your_Full_Fil_Name\result.png"
        Dim FileLinkName As String = "Your_FileLink_Field_Name"

        '    attach to the first selected record
        Dim RecordId As Integer = RecordIdList(0)
        ErrorCode = Run.UploadFile(FullFileName, TableDef.UserName, FileLinkName, RecordId)
        If ErrorCode <> 0 Then
            Console.Write(vbCrLf & "Could not upload file")
        End If

    End Sub


End Class
See Also