private void OnImportEntityError(Exception e, ImportEntity importEntity, Guid importSessionId)
        {
            var eventArgs = new ImportEntitySaveErrorEventArgs {
                Exception       = e,
                ImportEntity    = importEntity,
                ImportSessionId = importSessionId
            };

            Logger.HandleException(this, eventArgs);
        }
        private void OnImportEntitySaveError(Exception e, ImportEntity importEntity, Guid importSessionId)
        {
            var eventArgs = new ImportEntitySaveErrorEventArgs {
                Exception       = e,
                ImportEntity    = importEntity,
                ImportSessionId = importSessionId
            };

            ImportEntitySaveError?.Invoke(this, eventArgs);
        }
Example #3
0
        /// <summary>
        /// Saves import entities.
        /// </summary>
        /// <param name="parameters">File import parameters.</param>
        protected virtual void SaveImportEntities(ImportParameters parameters)
        {
            OnBeforeImportEntitiesSave(new BeforeImportEntitiesSaveEventArgs {
                RootSchemaUId = parameters.RootSchemaUId,
                ImportTags    = parameters.ImportTags
            });

            var          entities = parameters.Entities;
            ImportEntity importEntity;

            while ((importEntity = entities.FirstOrDefault()) != null)
            {
                try {
                    InitEntityForSave(parameters, importEntity);
                    var eventArgs = new ImportEntitySavingEventArgs {
                        TotalRowsCount     = parameters.TotalRowsCount,
                        ProcessedRowsCount = parameters.ProcessedRowsCount
                    };
                    OnImportEntitySaving(eventArgs);
                    importEntity.Save();
                    OnImportEntitySaved(new ImportEntitySavedEventArgs {
                        RootSchemaUId   = parameters.RootSchemaUId,
                        PrimaryEntity   = importEntity.PrimaryEntity,
                        ImportSessionId = parameters.ImportSessionId
                    });
                    parameters.ImportedRowsCount++;
                } catch (OutOfMemoryException e) {
                    throw;
                } catch (Exception e) {
                    parameters.NotImportedRowsCount++;
                    var eventArgs = new ImportEntitySaveErrorEventArgs {
                        Exception       = e,
                        ImportEntity    = importEntity,
                        ImportSessionId = parameters.ImportSessionId
                    };
                    OnImportEntitySaveError(eventArgs);
                } finally {
                    parameters.ProcessedRowsCount++;
                    entities.Remove(importEntity);
                }
            }
        }
 private void OnImportEntitySaveError(object sender, ImportEntitySaveErrorEventArgs args)
 {
     _processedWithErrorRowsCount++;
 }
Example #5
0
 /// <summary>
 /// Send message on entity saving error
 /// </summary>
 /// <param name="eventArgs"></param>
 protected void OnImportEntitySaveError(ImportEntitySaveErrorEventArgs eventArgs)
 {
     ImportEntitySaveError?.Invoke(this, eventArgs);
 }