Example #1
0
        // get the flow files to process
        protected virtual ProcessResult <TPart, TWhole> GetTargetToEnrich(string targetEntityInstanceId)
        {
            var repo = new ProcessResultRepository <ProcessResult <TPart, TWhole> >()
            {
                DataDir = TargetDirectoy.FullName
            };

            // load results to get the invalid items
            ProcessResult <TPart, TWhole> result = repo.Get(targetEntityInstanceId);

            return(result);
        }
Example #2
0
        void ProcessResults(ProcessResult <TPart, TWhole> result)
        {
            // get new batch process
            var batchProcess = GetNewBatchProcess();

            var outResult = new ProcessResult <TPart, TWhole>()
            {
                Exceptions = new List <Exception>(),
                Errors     = new List <ProcessError <TPart> >(),
                FlowBatch  = batchProcess,
                Output     = new List <TWhole>(),
                Invalid    = new List <TWhole>()
            };

            var valid   = new List <TWhole>();
            var inValid = new List <TWhole>();

            foreach (var source in new[] { result.Output, result.Invalid })
            {
                foreach (var entityOut in source)
                {
                    var errors = _specs.ToErrors(entityOut).ToList();
                    if (!errors.Any())
                    {
                        valid.Add(entityOut);
                    }
                    else
                    {
                        // get all errors and add to error collection
                        foreach (var error in errors)
                        {
                            outResult.Errors.Add(new ProcessError <TPart>()
                            {
                                Error = new ErrorEvent()
                                {
                                    Message = error.Message,
                                    Type    = error.Type
                                },
                            });
                        }

                        inValid.Add(entityOut);
                    }
                }
            }

            // validate collection
            var collectionErrors = _specsForCollection.ToErrors(valid);

            if (!collectionErrors.Any())
            {
                result.Invalid = inValid;
                result.Output  = valid;
            }
            else
            {
                // add all to invalid list
                inValid.AddRange(valid);

                result.Invalid = inValid;
            }

            // source repository save results
            var repo = new ProcessResultRepository <ProcessResult <TPart, TWhole> >()
            {
                DataDir = TargetDirectoy.FullName
            };

            repo.Save(outResult);
        }