Ejemplo n.º 1
0
        internal static IResult <CreateLotDefectParameters> ToParsedParameters(this ICreateLotDefectParameters parameters)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }

            if (parameters.DefectType != DefectTypeEnum.InHouseContamination)
            {
                return(new InvalidResult <CreateLotDefectParameters>(null, UserMessages.OnlyInHouseContaminationValid));
            }

            var lotKey = KeyParserHelper.ParseResult <ILotKey>(parameters.LotKey);

            if (!lotKey.Success)
            {
                return(lotKey.ConvertTo <CreateLotDefectParameters>(null));
            }

            return(new SuccessResult <CreateLotDefectParameters>(new CreateLotDefectParameters
            {
                Parameters = parameters,
                LotKey = new LotKey(lotKey.ResultingObject)
            }));
        }
Ejemplo n.º 2
0
        public IResult <ICreateLotDefectReturn> CreateLotDefect(ICreateLotDefectParameters parameters)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }

            var parsedParameters = parameters.ToParsedParameters();

            if (!parsedParameters.Success)
            {
                return(parsedParameters.ConvertTo <ICreateLotDefectReturn>());
            }

            var createDefectResult = new CreateInHouseContaminationDefectCommand(_lotUnitOfWork).Execute(parsedParameters.ResultingObject, _timeStamper.CurrentTimeStamp);

            if (!createDefectResult.Success)
            {
                return(createDefectResult.ConvertTo <ICreateLotDefectReturn>());
            }

            _lotUnitOfWork.Commit();

            var synchronizeLotParameters = new SynchronizeLotParameters
            {
                LotKey = parsedParameters.ResultingObject.LotKey,
                OverrideOldContextLotAsCompleted = false
            };

            return(SyncParameters.Using(new SuccessResult <ICreateLotDefectReturn>(
                                            new CreateLotDefectReturn(createDefectResult.ResultingObject.ToLotDefectKey(), synchronizeLotParameters)),
                                        synchronizeLotParameters));
        }
Ejemplo n.º 3
0
 public IResult <ICreateLotDefectReturn> CreateLotDefect(ICreateLotDefectParameters parameters)
 {
     try
     {
         return(_lotServiceProvider.CreateLotDefect(parameters));
     }
     catch (Exception ex)
     {
         _exceptionLogger.LogException(ex);
         return(new FailureResult <ICreateLotDefectReturn>(null, ex.Message));
     }
 }