Show / Hide Table of Contents

Class Document

The document-specific section of information about a document

There is always a corresponding appointment record; the relation between appointment and document is navigable in both directions. A document-type appointment record always has a corresponding document record.

Entity Object for table 'document'. Entity objects represent full entities with both the base table object and all related objects, such as udef, publish, and things like owner associate and whatever else is logically related to the base object.
Inheritance
Object
NestedPersist
EntityBase
Document
Implements
INestedPersist
ISoItem
ITableRowLoadHandler
IEntityUdefHelperContainer
Inherited Members
EntityBase._onGetRelatedObjects
EntityBase.GetAdditionalRelatedNestedPersistViaBaseClass(List<INestedPersist>, Boolean)
EntityBase.OnPrimaryKeyRequest(PKContainer)
EntityBase.OnPrimaryKeyUpdate(PKContainer)
EntityBase.OnSave(BatchSave)
EntityBase.ITableRowLoadHandler.OnRowLoad(SoDataReader, TableRowBase)
EntityBase.ITableRowLoadHandler.OnRowLoaded()
EntityBase.UpdateSentryRelatedTableInfoInstance<MainTableInfoType>(SentryCollection, TableInfo)
EntityBase.IsDirty
EntityBase.OnGetRelatedObjects
NestedPersist._saveOwner
NestedPersist._isSaving
NestedPersist.SetSaveOwner(INestedPersist)
NestedPersist.Save()
NestedPersist.INestedPersist.OnPreIdUpdate()
NestedPersist.INestedPersist.OnPrimaryKeyRequest(PKContainer)
NestedPersist.INestedPersist.OnPrimaryKeyUpdate(PKContainer)
NestedPersist.INestedPersist.OnIdUpdate()
NestedPersist.INestedPersist.OnSave(BatchSave)
NestedPersist.INestedPersist.OnSaved(Boolean)
NestedPersist.IsSaving
NestedPersist.OnElementSaved
NestedPersist.OnElementIdUpdate
Object.ToString()
Object.Equals(Object)
Object.Equals(Object, Object)
Object.ReferenceEquals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
Namespace: SuperOffice.CRM.Entities
Assembly: SoDataBase.dll
Syntax
public class Document : EntityBase, INestedPersist, ISoItem, ITableRowLoadHandler, IEntityUdefHelperContainer
Remarks

Entity objects can be created in several ways.

  • Use the static CreateNew() method to create a new, empty object. After populating it with values, you call the method and corresponding row(s) in the database are created, and the objects' primary key field updated. This is the preferred way to insert new entities into the database.
  • You can create a (nested) Document Document.CustomSearch object to obtain a query pre-populated with the correct tableinfo and return fields. This query can be modified with restrictions, etc. Then, use the static GetFromCustomSearch(Document.CustomSearch) method to apply the query to the database and obtain the result as an Entity object. This is how you select existing entities from the database when you have a query that does not correspond to any of the existing database indexes.
  • For each unique index defined for the table, there is a corresponding GetFromIdx method to make retrieving data via the indexes easy. Note that if you try to fetch a row that does not exist (for instance, by using the primary key index and specifying a primary key that does not exist in the database), you will get a Row object with the and properties set to true. Such an Entity object is called a 'ghost' and cannot be updated, saved or deleted. You can also get a ghost if the row does exist in the database, but the Sentry system denies Select rights to the row.
Non-unique indexes are handled through the DocumentCollection collection, which has nested classes and GetFromIdx methods for each non-unique index. There are no 'GetFromReader' methods, since that would be rather complex (multiple TableInfo objects required).

Unique indexes on Document are:

Index fieldsNested index class name
DocumentIdDocumentId:

Primary key

Nested index class: Document.IdxDocumentId

Static Get method: GetFromIdxDocumentId(Int32)

Non-unique indexes on table Document are:
Index fieldsNested index class name
OurRefOurRef:

Our reference, searchable field from free-text search

Nested index class: DocumentCollection.IdxOurRef

Static Get method: GetFromIdxOurRef(String)

Userdef2IdUserdef2Id:

User-defined fields

Nested index class: DocumentCollection.IdxUserdef2Id

Static Get method: GetFromIdxUserdef2Id(Int32)

UserdefIdUserdefId:

User-defined fields

Nested index class: DocumentCollection.IdxUserdefId

Static Get method: GetFromIdxUserdefId(Int32)

ExtrefExtref:

External reference (notes ID, email ID, other ID used by the archive provider)

Nested index class: DocumentCollection.IdxExtref

Static Get method: GetFromIdxExtref(String)

HeaderHeader:

Visible document name

Nested index class: DocumentCollection.IdxHeader

Static Get method: GetFromIdxHeader(String)

SearchnameSearchname:

For future use

Nested index class: DocumentCollection.IdxSearchname

Static Get method: GetFromIdxSearchname(String)

ArchiveProviderArchiveProvider:

Reference to archive provider; for future use, and the Notes Link

Nested index class: DocumentCollection.IdxArchiveProvider

Static Get method: GetFromIdxArchiveProvider(Int32)

Constructors

Document(Document.DocumentIdxBase)

Constructor for class Document.
This object represents a row in table 'document'. Table contact: Documents, this table is an extension of the Appointment table

Declaration
protected Document(Document.DocumentIdxBase idx)
Parameters
Type Name Description
Document.DocumentIdxBase idx

ContactRowDocumentRow.DocumentRowIdx object that the Contact encapsulates.

Document(DocumentRow, Document.DocumentIdxBase)

Declaration
protected Document(DocumentRow row, Document.DocumentIdxBase idx)
Parameters
Type Name Description
DocumentRow row
Document.DocumentIdxBase idx

Fields

_createdAssociate

Related HDB object(s).

Declaration
protected AssociateRow _createdAssociate
Field Value
Type Description
AssociateRow

_documentAppointment

Related HDB object(s).

Declaration
protected Appointment _documentAppointment
Field Value
Type Description
Appointment

_documentText

Related HDB object(s).

Declaration
protected TextRow _documentText
Field Value
Type Description
TextRow

_externalApplication

Related HDB object(s).

Declaration
protected ExtAppRow _externalApplication
Field Value
Type Description
ExtAppRow

_row

HDB object this entity is a facade for.

Declaration
protected DocumentRow _row
Field Value
Type Description
DocumentRow

_rowIdx

Declaration
protected Document.DocumentIdxBase _rowIdx
Field Value
Type Description
Document.DocumentIdxBase

_udefLarge

Related HDB object(s).

Declaration
protected UDDocLargeRow _udefLarge
Field Value
Type Description
UDDocLargeRow

_udefSmall

Related HDB object(s).

Declaration
protected UDDocSmallRow _udefSmall
Field Value
Type Description
UDDocSmallRow

_updatedAssociate

Related HDB object(s).

Declaration
protected AssociateRow _updatedAssociate
Field Value
Type Description
AssociateRow

Properties

ArchiveProvider

"Reference to archive provider; for future use"

Declaration
public int ArchiveProvider { get; set; }
Property Value
Type Description
Int32

Attention

Attention/salutation

Declaration
public string Attention { get; set; }
Property Value
Type Description
String

CreatedAssociate

Related object AssociateRow: Employees, resources and other users - except for External persons

Declaration
public AssociateRow CreatedAssociate { get; set; }
Property Value
Type Description
AssociateRow

CustomFields

Declaration
public EntityCustomFieldsHelper CustomFields { get; }
Property Value
Type Description
EntityCustomFieldsHelper

DocumentAppointment

Related object Appointment: "Tasks, appointments, followups, phone calls; and documents"

Declaration
public Appointment DocumentAppointment { get; set; }
Property Value
Type Description
Appointment

DocumentId

Primary key

Declaration
public int DocumentId { get; }
Property Value
Type Description
Int32

DocumentText

Related object TextRow: Long text fields from all over the system

Declaration
public TextRow DocumentText { get; set; }
Property Value
Type Description
TextRow

ExternalApplication

Related object ExtAppRow: ExtApp list table

Declaration
public ExtAppRow ExternalApplication { get; set; }
Property Value
Type Description
ExtAppRow

ExtraFields

Declaration
public EntityExtraFieldsHelper ExtraFields { get; }
Property Value
Type Description
EntityExtraFieldsHelper

Extref

External reference (notes ID, email ID, whatever)

Declaration
public string Extref { get; set; }
Property Value
Type Description
String

Header

Visible document name

Declaration
public string Header { get; set; }
Property Value
Type Description
String

IsDeleted

Is the row deleted?

Declaration
public override bool IsDeleted { get; }
Property Value
Type Description
Boolean
Overrides
NestedPersist.IsDeleted

IsMarkedForDelete

Gets or sets a value indicating whether this instance is marked for delete.

Declaration
public override bool IsMarkedForDelete { get; set; }
Property Value
Type Description
Boolean

true if this instance is marked for delete; otherwise, false.

Overrides
NestedPersist.IsMarkedForDelete

IsNew

Is the row new, e.g. not been inserted to the database?

Declaration
public override bool IsNew { get; }
Property Value
Type Description
Boolean
Overrides
EntityBase.IsNew

LinksHelper

Links helper The helper manages the links belonging to the document. Helper updates the corresponding appointment's ActiveLinks property

Declaration
public ActivityLinksHelper LinksHelper { get; }
Property Value
Type Description
ActivityLinksHelper

LockSemantics

Locking semantics requested/applied to a document; 'downgrading' is not allowed for existing documents

Declaration
public DocumentLockSemantics LockSemantics { get; set; }
Property Value
Type Description
DocumentLockSemantics

MainRow

Return the main row for the Entity.

Declaration
protected override TableRowBase MainRow { get; }
Property Value
Type Description
TableRowBase
Overrides
EntityBase.MainRow

Name

File name

Declaration
public string Name { get; set; }
Property Value
Type Description
String

OurRef

Our reference, searchable field from freetext search

Declaration
public string OurRef { get; set; }
Property Value
Type Description
String

PublishHelper

Get the helper class for working with the publish-state of the entity.
Published means that it is available for external persons in applications like SuperOffice Audience.

Declaration
public EntityPublishHelper PublishHelper { get; }
Property Value
Type Description
EntityPublishHelper

Registered

Registered when

Declaration
public DateTime Registered { get; set; }
Property Value
Type Description
DateTime

Row

The encapsulated object DocumentRow.

Declaration
public DocumentRow Row { get; }
Property Value
Type Description
DocumentRow

Searchname

Searchable name (not used?)

Declaration
public string Searchname { get; set; }
Property Value
Type Description
String

Snum

snum, Number created when creating document from template

Declaration
public int Snum { get; set; }
Property Value
Type Description
Int32

TableInfo

Get a TableInfo object for the document table.

Declaration
public DocumentTableInfo TableInfo { get; }
Property Value
Type Description
DocumentTableInfo

UdefHelper

Get the Udef class of EntityUdefHelper for working with udef fields

Declaration
public EntityUdefHelper UdefHelper { get; }
Property Value
Type Description
EntityUdefHelper

UdefLarge

Related object UDDocLargeRow: User-defined fields

Declaration
public UDDocLargeRow UdefLarge { get; set; }
Property Value
Type Description
UDDocLargeRow

UdefSmall

Related object UDDocSmallRow: User-defined fields

Declaration
public UDDocSmallRow UdefSmall { get; set; }
Property Value
Type Description
UDDocSmallRow

Updated

Last updated when

Declaration
public DateTime Updated { get; set; }
Property Value
Type Description
DateTime

UpdatedAssociate

Related object AssociateRow: Employees, resources and other users - except for External persons

Declaration
public AssociateRow UpdatedAssociate { get; set; }
Property Value
Type Description
AssociateRow

UpdatedCount

Declaration
public short UpdatedCount { get; set; }
Property Value
Type Description
Int16

YourRef

Your reference

Declaration
public string YourRef { get; set; }
Property Value
Type Description
String

Methods

CreateNew()

Create a new instance of the Document entity.

Declaration
public static Document CreateNew()
Returns
Type Description
Document

A new instance of the Document entity.

CreateNew(Document.DocumentIdxBase)

Create a new instance of the Document entity, by reading from the database using the specified index (represented by a nested index class).

Declaration
public static Document CreateNew(Document.DocumentIdxBase idx)
Parameters
Type Name Description
Document.DocumentIdxBase idx

Index search, represented by a subclass if the Document.DocumentIdxBase nested index class

Returns
Type Description
Document

A new instance of the Document entity.

Delete()

Delete the row.

Declaration
public override void Delete()
Overrides
EntityBase.Delete()

ForceEntityUpdate()

Force Updated and UpdatedAssociate to be updated with current time and Currently logged in associate. This will again be overridden in the Database update operation by a query processor.

Declaration
protected override void ForceEntityUpdate()
Overrides
EntityBase.ForceEntityUpdate()

FromDocumentRow(DocumentRow)

Operator asigning a Document from a DocumentRow.

Declaration
public static Document FromDocumentRow(DocumentRow row)
Parameters
Type Name Description
DocumentRow row

DocumentRow object

Returns
Type Description
Document

Document Entity

FromDocumentRow(DocumentRow, Document.DocumentIdxBase)

Declaration
public static Document FromDocumentRow(DocumentRow row, Document.DocumentIdxBase idx)
Parameters
Type Name Description
DocumentRow row
Document.DocumentIdxBase idx
Returns
Type Description
Document

GetAdditionalRelatedNestedPersist(List<INestedPersist>, Boolean)

Add the Links Helper to the list of related nestedpersist objects, to ensure it gets a chance to do its save operations

Declaration
protected override void GetAdditionalRelatedNestedPersist(List<INestedPersist> relatedObjects, bool lacyFetchIfNeeded)
Parameters
Type Name Description
List<INestedPersist> relatedObjects
Boolean lacyFetchIfNeeded
Overrides
EntityBase.GetAdditionalRelatedNestedPersist(List<INestedPersist>, Boolean)

GetFromCustomSearch(Document.CustomSearch)

Create a new instance of the Document object, and populate it with data from a custom search. If the search returns no results, an empty entity will be returned; if the result contains rows, one Document object representing the first row will be returned. Any further rows in the result will be ignored.

Declaration
public static Document GetFromCustomSearch(Document.CustomSearch query)
Parameters
Type Name Description
Document.CustomSearch query

The custom search to execute against the database

Returns
Type Description
Document

A new instance of the Document object, reflecting the result of the query.

GetFromIdxDocumentId(Int32)

Create a new instance of the Document object, by querying the database table via the index 'IDXDocId'. This method is intended to make it easy to use efficient queries that match a database index.

Declaration
public static Document GetFromIdxDocumentId(int documentId)
Parameters
Type Name Description
Int32 documentId

Primary key

Returns
Type Description
Document

Row object that represents the result of the search. IsNew will be true if the query did not match any row in the table

Remarks

This method represents one of the unique indexes on the Document table. Non-unique indexes have corresponding inner classes and methods in the DocumentCollection collection, since they may return more than one row.

GetRelatedNestedPersist(List<INestedPersist>, Boolean)

Append all the related objects to a list of INestedPersist.

Declaration
protected override void GetRelatedNestedPersist(List<INestedPersist> relatedObjects, bool lacyFetchIfNeeded)
Parameters
Type Name Description
List<INestedPersist> relatedObjects

List to append related objects to.

Boolean lacyFetchIfNeeded
Overrides
EntityBase.GetRelatedNestedPersist(List<INestedPersist>, Boolean)

OnIdUpdate()

Update related objects with correct id's to make sure that relations are consistent before saving to the database.

Declaration
protected override void OnIdUpdate()
Overrides
EntityBase.OnIdUpdate()

OnIdUpdateImplementation()

Declaration
protected override void OnIdUpdateImplementation()
Overrides
EntityBase.OnIdUpdateImplementation()

OnPostSaveMe()

Handle actions needed to be taken after this object has been saved, but before saving objects depending upon this one.

Declaration
protected virtual void OnPostSaveMe()

OnPreIdUpdate()

Allow for "fake id's" to be forced upon related objects.

Declaration
protected override void OnPreIdUpdate()
Overrides
EntityBase.OnPreIdUpdate()
Remarks

In order to figure out which objects taking part of the nested save operation that actually needs to be saved, this method allows for "fake id's" to be forced upon related objects. Upon receiving the "fake id", the objects receiving such an id can determine if they needs to be persisted (e.g. saved) to the database. However, the fake id's forced upon related objects must be set to correct id's in the OnIdUpdate method taking place later in the save operation.

OnPreIdUpdateImplementation()

Declaration
protected override void OnPreIdUpdateImplementation()
Overrides
EntityBase.OnPreIdUpdateImplementation()

OnPreSaveMe()

Handle actions needed to be taken after objects this object depends on have been saved, but before this object is saved.

Declaration
protected virtual void OnPreSaveMe()

OnRowLoad(SoDataReader, TableRowBase)

Event raised when the row is loaded from the database

Declaration
protected override void OnRowLoad(SoDataReader reader, TableRowBase row)
Parameters
Type Name Description
SoDataReader reader
TableRowBase row
Overrides
EntityBase.OnRowLoad(SoDataReader, TableRowBase)

OnRowLoaded()

Declaration
protected override void OnRowLoaded()
Overrides
EntityBase.OnRowLoaded()

OnSaved(Boolean)

Override: User story 12100: If a document is a quote doc (from the template) and related to a sale with a quote that does not yet have a quote doc, then this is it!

Declaration
protected override void OnSaved(bool bSucceeded)
Parameters
Type Name Description
Boolean bSucceeded
Overrides
EntityBase.OnSaved(Boolean)

SetDefaults()

Set default values for the entity.

Declaration
public void SetDefaults()

SetDefaults(DefaulterStrategy)

Set default values for the entity.

Declaration
public void SetDefaults(DefaulterStrategy strategy)
Parameters
Type Name Description
DefaulterStrategy strategy

Strategy used when appliying default values.

SetMarkedForDeleteOnRelatedObjects(Boolean)

Make sure the AppointmentRow part of the document record is deleted as well when deleting a document.

Declaration
protected override void SetMarkedForDeleteOnRelatedObjects(bool isMarkedForDelete)
Parameters
Type Name Description
Boolean isMarkedForDelete
Overrides
EntityBase.SetMarkedForDeleteOnRelatedObjects(Boolean)

Validate()

Check the entity and related objects for consistency and required fields, and return fields and error messages.

Declaration
public override Dictionary<string, string> Validate()
Returns
Type Description
Dictionary<String, String>

Field names and error messages

Overrides
EntityBase.Validate()

Operators

Explicit(DocumentRow to Document)

Operator assigning a Document from a DocumentRow.

Declaration
public static explicit operator Document(DocumentRow row)
Parameters
Type Name Description
DocumentRow row

DocumentRow object

Returns
Type Description
Document

Document Entity

Explicit Interface Implementations

IEntityUdefHelperContainer.UDefLarge

Declaration
TableRowBase IEntityUdefHelperContainer.UDefLarge { get; }
Returns
Type Description
TableRowBase

IEntityUdefHelperContainer.UDefSmall

Declaration
TableRowBase IEntityUdefHelperContainer.UDefSmall { get; }
Returns
Type Description
TableRowBase

Implements

INestedPersist
ISoItem
ITableRowLoadHandler
IEntityUdefHelperContainer

Extension Methods

EnumUtil.MapEnums<From, To>(From)
Converters.MapEnums<From, To>(From)
© SuperOffice. All rights reserved.
SuperOffice |  Community |  Release Notes |  Privacy |  Site feedback |  Search Docs |  About Docs |  Contribute |  Back to top