示例#1
0
            public ColumnValueBag[] Submit()
            {
                RowValidation.SetAsyncErrors(DataValidationResults.Empty);

                if (!SubmitInput())
                {
                    return(null);
                }

                var result            = new ColumnValueBag[DataSet.Count];
                var serializers       = GetColumnSerializers();
                var validationResults = DataValidationResults.Empty;

                for (int i = 0; i < DataSet.Count; i++)
                {
                    var validationErrors = DataValidationErrors.Empty;
                    var columnValueBag   = new ColumnValueBag();
                    result[i] = columnValueBag;
                    for (int j = 0; j < serializers.Count; j++)
                    {
                        var serializer = serializers[j];
                        if (serializer == null)
                        {
                            continue;
                        }

                        var textColumn = _.TextColumns[j];
                        try
                        {
                            serializer.Deserialize(textColumn[i], columnValueBag);
                        }
                        catch (Exception ex)
                        {
                            validationErrors = validationErrors.Add(new DataValidationError(ex.Message, textColumn));
                        }
                    }

                    if (validationErrors.Count > 0)
                    {
                        validationResults = validationResults.Add(new DataValidationResult(DataSet[i], validationErrors));
                    }
                }

                if (validationResults.Count > 0)
                {
                    RowValidation.SetAsyncErrors(validationResults);
                    return(null);
                }

                var pasteAppendService = _sourcePresenter.GetService <DataView.IPasteAppendService>(false);

                if (pasteAppendService != null && !pasteAppendService.Verify(result))
                {
                    return(null);
                }
                return(result);
            }
示例#2
0
        /// <summary>
        /// Indica que está no contexto de transformação do objeto
        /// </summary>
        /// <param name="context">Contexto de transformação</param>
        /// <param name="action">Ação que será executada para a transformação</param>
        protected override void InTransformContext(Unimake.ETL.ITransform context, System.Action action)
        {
            ObjectResult = new T();

            foreach (var inputRow in context.Source.Rows)
            {
                RowValidation rowValidation = new RowValidation();
                context.DoRowValidation(inputRow, rowValidation);
                if (rowValidation.HasErrors)
                {
                    context.RaiseRowInvalid(inputRow, rowValidation);
                }
                else
                {
                    RowOperation rowOp = context.GetRowOperation(inputRow);
                    if (rowOp != RowOperation.Ignore)
                    {
                        DictionaryRow transformedRow = new DictionaryRow();
                        foreach (var mapping in context.TransformMap)
                        {
                            object rowValue = inputRow[mapping.Key];
                            Func <object, object> transformFunc;
                            if (context.TransformFuncs.TryGetValue(mapping.Key, out transformFunc))
                            {
                                rowValue = transformFunc(rowValue);
                            }
                            transformedRow[mapping.Value] = rowValue;

                            //aqui temos que preencher o objeto com suas propriedades
                            SetValue(mapping, rowValue);
                        }

                        context.ProcessTransformedRow(rowOp, transformedRow);
                    }
                }
            }
        }