Class BpApplication
- Namespace
- BpNexT.NET
- Assembly
- BpNexT.NET.dll
Represents the BpNexT.NET wrapper class for easier handling of microtech ERP
public class BpApplication : IBpApplication, IDisposable
- Inheritance
-
objectBpApplication
- Implements
Constructors
BpApplication()
Initializes a new instance of the BpApplication class.
public BpApplication()
BpApplication(Application?, ILoggerFactory?)
Initializes a new instance of the BpApplication class around an optional existing microtech ERP application instance. Requires a valid license file to be set via LoadLicenseFromFile(string, string?) or LoadLicenseFromString(string, string?).
public BpApplication(Application? bpApp = null, ILoggerFactory? loggerFactory = null)
Parameters
bpAppApplicationThe microtech ERP application instance to wrap. If null, a new instance will be created.
loggerFactoryILoggerFactoryOptional logger factory. If null, SDK logging is disabled for this instance.
Properties
Dokumente
Accesses the Dokumente special object.
public BpSpecialObject<AutoDokument> Dokumente { get; }
Property Value
- BpSpecialObject<AutoDokument>
Remarks
Call FreeSpecialObject<T>(BpSpecialObject<T>)(this) after use
Accesses the Drucken special object.
public BpSpecialObject<AutoSpecialDrucken> Drucken { get; }
Property Value
- BpSpecialObject<AutoSpecialDrucken>
Remarks
Call FreeSpecialObject<T>(BpSpecialObject<T>)(this) after use
Events
Accesses the Events special object.
public BpSpecialObject<AutoSpecialEvents> Events { get; }
Property Value
- BpSpecialObject<AutoSpecialEvents>
Remarks
Call FreeSpecialObject<T>(BpSpecialObject<T>)(this) after use
InstanceId
Unique identifier for this microtech ERP application instance.
public Guid InstanceId { get; }
Property Value
IsEvaluationMode
Whether BpNexT.NET is running in evaluation mode (no valid license found).
public static bool IsEvaluationMode { get; }
Property Value
Remarks
In Multi-Tenancy setups, this property reflects the license status of the current tenant.
Lager
Accesses the Lager special object.
public BpSpecialObject<AutoLager> Lager { get; }
Property Value
- BpSpecialObject<AutoLager>
Remarks
Call FreeSpecialObject<T>(BpSpecialObject<T>)(this) after use
Projekte
Accesses the Projekte special object.
public BpSpecialObject<AutoSpecialProjekte> Projekte { get; }
Property Value
- BpSpecialObject<AutoSpecialProjekte>
Remarks
Call FreeSpecialObject<T>(BpSpecialObject<T>)(this) after use
RequestRetryCount
Gets or sets the retry count for requests to the microtech ERP application.
public int RequestRetryCount { get; set; }
Property Value
RequestTimeOut
Gets or sets the timeout (in milliseconds) for requests to the microtech ERP application.
public int RequestTimeOut { get; set; }
Property Value
Vorgaenge
Accesses the Vorgang special object.
public BpSpecialObject<AutoVorgang> Vorgaenge { get; }
Property Value
- BpSpecialObject<AutoVorgang>
Remarks
Call FreeSpecialObject<T>(BpSpecialObject<T>)(this) after use
Wandeln
Accesses the Wandeln special object for converting Vorgänge.
public BpSpecialObject<AutoWandeln> Wandeln { get; }
Property Value
- BpSpecialObject<AutoWandeln>
Remarks
Call FreeSpecialObject<T>(BpSpecialObject<T>)(this) after use
Methods
AddDataSet<T>()
Appends a new instance to the AutoDataSet of type T.
public T AddDataSet<T>() where T : IHasAutoDataSet, new()
Returns
- T
An instance of type T with properties populated from the AutoDataSet.
Type Parameters
TThe type of the object to append, which must inherit from HasAutoDataSet and have a parameterless constructor.
AllocSpecialObject<T>(SpecialObjects)
Allocates an instance of a special object, wrapped with its owning BpApplication instance ID.
public BpSpecialObject<T> AllocSpecialObject<T>(SpecialObjects specialObjectEnum) where T : class
Parameters
specialObjectEnumSpecialObjectsThe identifier of the special object.
Returns
- BpSpecialObject<T>
A BpSpecialObject<T> containing the special object of type
T.
Type Parameters
TThe type of the special object.
Remarks
Must call FreeSpecialObject<T>(BpSpecialObject<T>) after use.
Exceptions
- InvalidOperationException
Thrown when the object cannot be cast to the specified type.
ArtikelLager(string, string?)
Initializes a LagerContext for a specific article and currency.
public LagerContext ArtikelLager(string artikelNummer, string? waehrung = null)
Parameters
Returns
Exceptions
ClearSolutionPartnerCredentials()
Clears previously set solution partner credentials so that subsequent logins fall back to the auto-detected company name.
public void ClearSolutionPartnerCredentials()
DeselectMandant()
Deselects the currently selected mandant.
public void DeselectMandant()
Dispose()
Releases unmanaged resources.
public void Dispose()
EnsureTransactionSafety(string)
Validates if the current thread is allowed to write to the given DataSet.
public void EnsureTransactionSafety(string dataSetName)
Parameters
dataSetNamestringThe logical name of the dataset (e.g. "Artikel")
Exceptions
- InvalidOperationException
If blocked by another thread.
~BpApplication()
Finalizer for automatic cleanup by the Garbage Collector.
protected ~BpApplication()
FindById<T>(int)
Retrieves the dataset of the specified type by the given ID.
public T? FindById<T>(int id) where T : IHasAutoDataSet, new()
Parameters
idintThe ID to search for.
Returns
- T
The dataset of the specified type if found; otherwise, null.
Type Parameters
T
Exceptions
Find<T>(IDataSetIndex, string[]?)
Retrieves the dataset of the specified type by the given index.
public T? Find<T>(IDataSetIndex index, string[]? includes = null) where T : IHasAutoDataSet, new()
Parameters
indexIDataSetIndexAn instance of IDataSetIndex to use for the search.
includesstring[]Optional: Names of the fields to load in the dataset.
Returns
- T
The dataset of the specified type if found; otherwise, null.
Type Parameters
T
FreeSpecialObject<T>(BpSpecialObject<T>)
Frees a special object and removes it from the cache. Expects a BpSpecialObject<T> or the raw COM object if cached directly.
public void FreeSpecialObject<T>(BpSpecialObject<T> wrapper) where T : class
Parameters
wrapperBpSpecialObject<T>The special object wrapper to be freed.
Type Parameters
TThe type of the raw special object.
Get()
Gets the microtech ERP application instance. With this instance, you can access all microtech ERP functions according to the microtech ERP documentation.
public Application Get()
Returns
- Application
GetChanged<T>(DateTime, string?, string[]?)
Retrieves a dataset of the specified type that has changed since the given date, with an optional filter.
public FilterableChangedDataSet<T> GetChanged<T>(DateTime date, string? filter = null, string[]? includes = null) where T : IHasAutoDataSet, IHasAendDat, new()
Parameters
dateDateTimeThe date to filter changes from.
filterstringOptional: Filter to apply to the dataset.
includesstring[]Optional: Names of the fields to load in the dataset.
Returns
- FilterableChangedDataSet<T>
An enumerable collection of the specified type.
Type Parameters
TThe type of the dataset.
GetChanged<T>(Func<string, string, DateTime>, string?, string[]?)
Retrieves a dataset of the specified type that has changed since the given date, with an optional filter.
public FilterableChangedDataSet<T> GetChanged<T>(Func<string, string, DateTime> getLastSyncDate, string? filter = null, string[]? includes = null) where T : IHasAutoDataSet, IHasAendDat, new()
Parameters
getLastSyncDateFunc<string, string, DateTime>A function to get the last sync date for the item.
filterstringOptional filter to apply to the dataset.
includesstring[]Optional: Names of the fields to load in the dataset.
Returns
- FilterableChangedDataSet<T>
An enumerable collection of the specified type.
Type Parameters
TThe type of the dataset.
GetCustomerData()
Retrieves customer data.
public BpCustomerData GetCustomerData()
Returns
- BpCustomerData
A BpCustomerData object containing customer information.
Exceptions
- ArgumentNullException
Thrown when the company name is not found.
GetDataSet(string, string?)
Retrieves a dataset of the specified type with an optional filter.
public IEnumerable<HasAutoDataSet> GetDataSet(string dataSetName, string? filter = null)
Parameters
dataSetNamestringThe name of the dataset to retrieve.
filterstringOptional filter to apply to the dataset.
Returns
- IEnumerable<HasAutoDataSet>
An enumerable collection of the specified type.
GetDataSet<T>(string?, string[]?)
Retrieves a dataset of the specified type with an optional filter.
public FilterableDataSet<T> GetDataSet<T>(string? filter = null, string[]? includes = null) where T : IHasAutoDataSet, new()
Parameters
filterstringOptional: Filter to apply to the dataset.
includesstring[]Optional: Names of the fields to load in the dataset.
Returns
- FilterableDataSet<T>
An enumerable collection of the specified type.
Type Parameters
TThe type of the dataset.
GetInstance(Guid)
Retrieves a microtech ERP application instance by its unique identifier.
public static BpApplication GetInstance(Guid id)
Parameters
idGuidThe unique identifier of the microtech ERP application instance.
Returns
- BpApplication
The microtech ERP application instance.
Exceptions
- InvalidOperationException
Thrown if no instance with the specified ID is found.
GetLoginException()
Retrieves and clears the last exception that occurred during microtech ERP login.
public Exception? GetLoginException()
Returns
- Exception
The last login exception, or null if no exception occurred.
GetMandant()
Returns the currently specified mandant.
public string? GetMandant()
Returns
GetMandantState()
Gets the current mandant state from microtech ERP. Returns Unavailable instead of throwing when the COM server process is unreachable; recover via RecreateApplication(bool) and a fresh login.
public MandantState GetMandantState()
Returns
- MandantState
The current MandantState.
GetRange<T>(IDataSetIndex, IDataSetIndex, string?, string[]?)
Retrieves a dataset of the specified type within a given range.
public FilterableRangeDataSet<T> GetRange<T>(IDataSetIndex indexStart, IDataSetIndex indexEnd, string? filter = null, string[]? includes = null) where T : IHasAutoDataSet, new()
Parameters
indexStartIDataSetIndexThe limits for the range start.
indexEndIDataSetIndexThe limits for the range end.
filterstringOptional: Filter to apply to the dataset.
includesstring[]Optional: Names of the fields to load in the dataset.
Returns
- FilterableRangeDataSet<T>
An enumerable collection of the specified type.
Type Parameters
TThe type of the dataset.
GetSelektionsFelder(string)
Retrieves the SelektionsFelder for the specified DataSet name. Results are cached per DataSet name.
public List<SelektionsFeld> GetSelektionsFelder(string dataSetName)
Parameters
dataSetNamestringThe name of the DataSet.
Returns
- List<SelektionsFeld>
A list of SelektionsFelder for the DataSet.
GetSelektionsFelder<T>()
Retrieves the SelektionsFelder for the specified DataSet type. Results are cached per DataSet name.
public List<SelektionsFeld> GetSelektionsFelder<T>() where T : IHasAutoDataSet
Returns
- List<SelektionsFeld>
A list of SelektionsFelder for the type.
Type Parameters
TThe DataSet type.
GetVersion()
Gets the version of BpNexT.NET.
public static string GetVersion()
Returns
InsertDataSet<T>()
Inserts a new instance into the AutoDataSet of type T.
[Obsolete("Use AddDataSet<T>() instead.")]
public T InsertDataSet<T>() where T : IHasAutoDataSet, new()
Returns
- T
An instance of type T with properties populated from the AutoDataSet.
Type Parameters
TThe type of the object to insert, which must inherit from HasAutoDataSet and have a parameterless constructor.
IsLoggedIn()
Returns whether the user is logged in.
public bool IsLoggedIn()
Returns
IsServerUnavailableException(Exception)
Returns true when the exception indicates the microtech ERP COM server process is gone ("The RPC server is unavailable" and related HRESULTs) and only RecreateApplication(bool) followed by a fresh Login(string, string, string?) can recover the connection. Useful for classifying exceptions from direct calls on Get().
public static bool IsServerUnavailableException(Exception exception)
Parameters
exceptionExceptionThe exception to classify.
Returns
LoggedInAs()
Returns the currently logged-in mandant or an empty string if no mandant is selected.
[Obsolete("Use LoggedInMandant() instead.")]
public string LoggedInAs()
Returns
LoggedInMandant()
Returns the currently logged-in mandant or an empty string if no mandant is selected.
public string LoggedInMandant()
Returns
LoggedInUser()
Returns the currently logged-in user or n/A if the login did not happen via BpNexT.NET (e.g., via microtech ERP directly).
public string LoggedInUser()
Returns
Login(string, string, string?)
Logs in to the application using the provided username and password. Uses the solution partner credentials set via SetSolutionPartnerCredentials(string, string) if present, otherwise automatically gathers the company name. Requires a valid license file to be set via LoadLicenseFromFile(string, string?) or LoadLicenseFromString(string, string?).
public bool Login(string username, string password, string? mandant = null)
Parameters
usernamestringThe username for login.
passwordstringThe password for login.
mandantstringOptional mandant to select after login.
Returns
- bool
True if login is successful, otherwise false.
Login(string, string, string, string, string?)
Logs in to the application using the provided connection details. Requires a valid license file to be set via LoadLicenseFromFile(string, string?) or LoadLicenseFromString(string, string?).
public bool Login(string connectionName, string connectionKey, string username, string password, string? mandant = null)
Parameters
connectionNamestringThe connection name.
connectionKeystringThe connection key.
usernamestringThe username for login.
passwordstringThe password for login.
mandantstringOptional mandant to select after login.
Returns
- bool
True if login is successful, otherwise false.
Remarks
If the function returns false, use GetLoginException() to retrieve the last exception that occurred during login.
Logout()
Logs out of the application.
public void Logout()
OpenDataSet(string)
Opens a dataset of the specified type.
public AutoDataSet OpenDataSet(string dataSet)
Parameters
dataSetstring
Returns
- AutoDataSet
OpenDataSet<T>()
Opens a dataset of the specified type.
public AutoDataSet OpenDataSet<T>()
Returns
- AutoDataSet
Type Parameters
T
QueryChanged<T>(DateTime, string[]?)
Retrieves a dataset of the specified type that has changed since the given date.
public IQueryable<T> QueryChanged<T>(DateTime date, string[]? includes = null) where T : class, IHasAutoDataSet, IHasAendDat, new()
Parameters
dateDateTimeThe date to filter changes from.
includesstring[]Optional: Names of the fields to load in the dataset.
Returns
- IQueryable<T>
Type Parameters
T
QueryChanged<T>(Func<string, string, DateTime>, string[]?)
Retrieves a dataset of the specified type that has changed since the last sync date.
public IQueryable<T> QueryChanged<T>(Func<string, string, DateTime> getLastSyncDate, string[]? includes = null) where T : IHasAutoDataSet, IHasAendDat, new()
Parameters
getLastSyncDateFunc<string, string, DateTime>A function to get the last sync date for the item.
includesstring[]Optional: Names of the fields to load in the dataset.
Returns
- IQueryable<T>
Type Parameters
TThe type of the dataset.
QueryDataSet<T>(string[]?)
Returns an IQueryable for the specified DataSet type, automatically optimizing queries using available indices where possible.
public IQueryable<T> QueryDataSet<T>(string[]? includes = null) where T : IHasAutoDataSet, new()
Parameters
includesstring[]
Returns
- IQueryable<T>
Type Parameters
TThe DataSet type.
ReadChanged<T>(DateTime, string[]?, int)
Retrieves a dataset of the specified type that has changed since the given date.
public IQueryable<T> ReadChanged<T>(DateTime date, string[]? includes = null, int chunkSize = 1000) where T : class, IHasAutoDataSet, IHasAendDat, new()
Parameters
dateDateTimeThe date to filter changes from.
includesstring[]Optional: Names of the fields to load in the dataset.
chunkSizeintOptional: The size of the chunks to read from the dataset.
Returns
- IQueryable<T>
Type Parameters
T
ReadChanged<T>(Func<string, string, DateTime>, string[]?, int)
Retrieves a dataset of the specified type that has changed since the last sync date.
public IQueryable<T> ReadChanged<T>(Func<string, string, DateTime> getLastSyncDate, string[]? includes = null, int chunkSize = 1000) where T : IHasAutoDataSet, IHasAendDat, new()
Parameters
getLastSyncDateFunc<string, string, DateTime>A function to get the last sync date for the item.
includesstring[]Optional: Names of the fields to load in the dataset.
chunkSizeintOptional: The size of the chunks to read from the dataset.
Returns
- IQueryable<T>
Type Parameters
TThe type of the dataset.
ReadDataSet<T>(string[]?, int)
Returns an IQueryable for the specified DataSet type,
automatically optimizing queries using available indices where possible.
public IQueryable<T> ReadDataSet<T>(string[]? includes = null, int chunkSize = 1000) where T : IHasAutoDataSet, new()
Parameters
Returns
- IQueryable<T>
Type Parameters
T
RecreateApplication(bool)
Recreates the microtech ERP application instance. Use this method to reset the application state if the RPC server becomes unresponsive — i.e. when GetMandantState() returns Unavailable. A fresh Login(string, string, string?) is required afterwards.
public void RecreateApplication(bool killProcess = false)
Parameters
killProcessboolIf true, the previous/existing microtech ERP process will be terminated before recreating the application instance.
RequiresReLogin()
Returns whether the current session requires a re-login due to a day change, a parameter change, or an unreachable COM server (Unavailable — recreate the application first).
public bool RequiresReLogin()
Returns
- bool
True if a re-login is required, otherwise false.
SelectMandant(string)
Selects the specified mandant.
public void SelectMandant(string mandant)
Parameters
mandantstringThe mandant to select.
Exceptions
- InvalidOperationException
Thrown when a mandant is already selected.
SetRetryTimeout(int, int)
Sets the retry count and timeout for requests to the microtech ERP application.
public void SetRetryTimeout(int retryCount = 100, int timeout = 2000)
Parameters
SetSolutionPartnerCredentials(string, string)
Sets the solution partner credentials to use for subsequent logins. Must be called before Login(string, string, string?); when set, login connects via the solution partner name and key instead of the auto-detected company name.
public void SetSolutionPartnerCredentials(string name, string key)
Parameters
SetupLogger()
Legacy no-op. Configure logging in the host application and pass an ILoggerFactory to SDK application constructors, or call UseLoggerFactory(ILoggerFactory?) for static SDK helpers.
[Obsolete("Configure logging in the host application and pass ILoggerFactory to SDK application constructors, or use BpNexTLogging.UseLoggerFactory.")]
public static void SetupLogger()
StartTransaction(string)
Starts a transaction for the specified DataSet name.
public BpTransaction StartTransaction(string dataSetName)
Parameters
dataSetNamestring
Returns
StartTransaction<T>()
Starts a transaction for the specified DataSet type.
public BpTransaction StartTransaction<T>() where T : IHasAutoDataSet
Returns
Type Parameters
T
SubscribeToNotifications(Func<MeldFensterRequest, int>, Action<Exception>?)
Subscribes to microtech ERP notifications.
public IDisposable SubscribeToNotifications(Func<MeldFensterRequest, int> handler, Action<Exception>? onError = null)
Parameters
handlerFunc<MeldFensterRequest, int>onErrorAction<Exception>
Returns
WandelnVorgang(string, int)
Creates a WandelnBuilder to convert a Vorgang to a different Vorgangsart.
public WandelnBuilder WandelnVorgang(string vorgangNr, int targetVorgangArt)
Parameters
vorgangNrstringThe Vorgangsnummer (BelegNr) of the Vorgang to convert.
targetVorgangArtintThe target Vorgangsart number (from BEARBEITEN - PARAMETER - ARTEN).
Returns
- WandelnBuilder
A WandelnBuilder for fluent configuration.