private IEnumerable <ImportDataChunk <LookupChunkData> > GetLookupChunkData(ImportParameters importParameters)
        {
            var importColumns  = importParameters.Columns.Where(c => c.Destinations.Any(d => d.FindColumnTypeUId() == DataValueTypeUId));
            var entitiesChunks = importParameters.Entities.SplitOnChunks(importParameters.ChunkSize);
            var result         = new List <ImportDataChunk <LookupChunkData> >();

            if (!importColumns.Any())
            {
                return(result);
            }

            foreach (var entities in entitiesChunks)
            {
                var processor = new LookupValuesToProcess(UserConnection);
                foreach (var entity in entities)
                {
                    foreach (var column in importColumns)
                    {
                        var columnValue = entity.FindColumnValue(column);
                        if (columnValue == null)
                        {
                            continue;
                        }
                        foreach (var destination in column.Destinations)
                        {
                            processor.Add(entity, column, columnValue, destination);
                        }
                    }
                }
                result.Add(GetImportDataChunk(importParameters.ImportSessionId,
                                              processor.SaveState()));
            }

            return(result);
        }
            public ImportDataChunk <LookupChunkData> CreateChunk(ImportDataChunk <EntityChunkData> chunk)
            {
                var processor = new LookupValuesToProcess(_userConnection);

                foreach (var entityMemento in chunk.Data.Entities)
                {
                    var entity = ImportEntity.CreateFromMemento(entityMemento);
                    processor.Add(entity, _lookupColumns);
                }
                var newLookupChunk = CreateChunk(processor.SaveState());

                return(newLookupChunk);
            }
        private void OnProcessErrorReceived(object sender, LookupValuesProcessorErrorEventArgs eventArgs)
        {
            Guid   entitySchemaUId = eventArgs.EntitySchemaUId;
            string messingValue    = eventArgs.MissingValue;
            var    cellsIndexes    = LookupValuesToProcess.GetCellsIndexes(entitySchemaUId, eventArgs.ColumnName, messingValue);

            if (!cellsIndexes.Any())
            {
                return;
            }
            foreach (string cellsIndex in cellsIndexes)
            {
                SendProcessError(cellsIndex, CreateColumnProcessErrorMessage(entitySchemaUId, eventArgs.Exception.Message));
            }
        }
 /// <summary>
 /// Runs column values processing.
 /// </summary>
 public void Process()
 {
     _results = LookupValuesProcessor.ProcessValues(LookupValuesToProcess.GetItems());
 }
 /// <summary>
 /// Adds raw value that will be processed.
 /// </summary>
 /// <param name="importEntity">Import entity.</param>
 /// <param name="column">Import column.</param>
 /// <param name="columnValue">Import column value.</param>
 /// <param name="destination">Import column destination.</param>
 public void Add(ImportEntity importEntity, ImportColumn column, ImportColumnValue columnValue,
                 ImportColumnDestination destination)
 {
     LookupValuesToProcess.Add(importEntity, column, columnValue, destination);
 }