Search Results for

    Show / Hide Table of Contents

    Class CSVImporter

    A class designed to import data from a given csv format with the use of IDataMappingBase for mappings of the file format/etc

    Inheritance
    System.Object
    CSVImporter
    Inherited Members
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.ToString()
    Namespace: LemonEdge.Entities.Processors.Importing
    Assembly: API.dll
    Syntax
    public class CSVImporter : IImporter

    Constructors

    CSVImporter(IDataMappingBase, IEnumerable<IDataMappingPropertyBase>, UserInfo, IReadOnlyCache, IProgressReporter, Func<Task<IEntityUpdater>>)

    Creates a new csv file importer with the specified mapping

    Declaration
    public CSVImporter(IDataMappingBase mapping, IEnumerable<IDataMappingPropertyBase> mappingProperties, UserInfo user, IReadOnlyCache cache, IProgressReporter reporter, Func<Task<IEntityUpdater>> getUpdater)
    Parameters
    Type Name Description
    IDataMappingBase mapping

    The specified mapping for the file to use. If blank LemonEdge.API.Entities.Helpers.MappingHelper.Default is used instead

    System.Collections.Generic.IEnumerable<IDataMappingPropertyBase> mappingProperties

    The specified property mapping for the import file. If null, then no mappings are used and the headers must match the expected template import headers for the entity type

    UserInfo user

    The current logged in user

    IReadOnlyCache cache

    A local cache

    IProgressReporter reporter

    A class for reporting the progress/status of the import to the client, or a log

    System.Func<System.Threading.Tasks.Task<IEntityUpdater>> getUpdater

    A function that returns a new updater context for retrieving and updating items

    Properties

    ProgressReporter

    An interface for reporting the progress, or status, of the import back to the client or a log

    Declaration
    public IProgressReporter ProgressReporter { get; }
    Property Value
    Type Description
    IProgressReporter

    Methods

    ImportData(IEntityUpdater, Boolean, Boolean, CancellationToken)

    Imports the data specified using InitDataForImport according to the specified parameters

    Leaves progress as 95% complete for saving if in batch/extra work/etc

    Declaration
    public Task<IEnumerable<ImportLineResultInfo>> ImportData(IEntityUpdater updater, bool saveSequentially, bool validate, CancellationToken cancel = default(CancellationToken))
    Parameters
    Type Name Description
    IEntityUpdater updater

    The current context of updater to use for importing/updating and committing the data

    System.Boolean saveSequentially

    Indicates the data should be saved and committed to the database for each line of data being imported. Creates a new context for each line to import.

    If this is false, the data is just all imported into the updater context, but is not saved. That needs to be done externally by the calling function.

    System.Boolean validate
    System.Threading.CancellationToken cancel

    A cancellation token to stop importing the data

    Returns
    Type Description
    System.Threading.Tasks.Task<System.Collections.Generic.IEnumerable<ImportLineResultInfo>>

    A task representing the completion of the operation with a list of information for each line imported

    InitDataForImport(IEnumerable<(EntityDescriptor ImportType, Byte[] ImortData)>)

    Adds the set of entities and their associated file to import

    Declaration
    public void InitDataForImport(IEnumerable<(EntityDescriptor ImportType, byte[] ImortData)> importData)
    Parameters
    Type Name Description
    System.Collections.Generic.IEnumerable<System.ValueTuple<EntityDescriptor, System.Byte[]>> importData

    An enumeration of a tuple holding an entity type to import and its associated binary file csv data

    Extension Methods

    MiscExtensions.SetIfNotEqual<T, P>(T, Expression<Func<T, P>>, P)
    ReflectionExtensions.ClearEventInvocations(Object, String)
    StringExtensions.ToCSVFormatString(Object, Type)
    SQLExtensions.ToSQLValue(Object, Boolean)
    In This Article
    Back to top © LemonEdge Technology. All rights reserved.