Пример #1
0
        public IResult AddLotAttributes(IAddLotAttributesParameters parameters)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }

            var parsedParameters = parameters.ToParsedParameters();

            if (!parsedParameters.Success)
            {
                return(parsedParameters);
            }

            var setAttributesResult = new SetLotAttributesConductor(_lotUnitOfWork).AddLotAttributes(_timeStamper.CurrentTimeStamp, parsedParameters.ResultingObject);

            if (!setAttributesResult.Success)
            {
                return(setAttributesResult);
            }

            _lotUnitOfWork.Commit();

            var syncParameters = new SynchronizeLotParameters
            {
                LotKeys = parsedParameters.ResultingObject.LotKeys,
                OverrideOldContextLotAsCompleted = parameters.OverrideOldContextLotAsCompleted
            };

            return(SyncParameters.Using(new SuccessResult <ILotStatInfoReturn>(new LotStatInfoReturn(syncParameters)), syncParameters));
        }
Пример #2
0
 public IResult AddLotAttributes(IAddLotAttributesParameters parameters)
 {
     try
     {
         return(_lotServiceProvider.AddLotAttributes(parameters));
     }
     catch (Exception ex)
     {
         _exceptionLogger.LogException(ex);
         return(new FailureResult());
     }
 }
Пример #3
0
        internal static IResult <AddLotAttributeParameters> ToParsedParameters(this IAddLotAttributesParameters parameters)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }

            var lotKeys = new List <LotKey>();

            foreach (var lotKey in parameters.LotKeys)
            {
                var lotKeyResult = KeyParserHelper.ParseResult <ILotKey>(lotKey);
                if (!lotKeyResult.Success)
                {
                    return(lotKeyResult.ConvertTo <AddLotAttributeParameters>());
                }

                lotKeys.Add(lotKeyResult.ResultingObject.ToLotKey());
            }

            var attributes = new Dictionary <AttributeNameKey, IAttributeValueParameters>();

            foreach (var attribute in parameters.Attributes)
            {
                var attributeNameResult = KeyParserHelper.ParseResult <IAttributeNameKey>(attribute.Key);
                if (!attributeNameResult.Success)
                {
                    return(attributeNameResult.ConvertTo <AddLotAttributeParameters>());
                }
                attributes.Add(new AttributeNameKey(attributeNameResult.ResultingObject), attribute.Value);
            }

            return(new SuccessResult <AddLotAttributeParameters>(new AddLotAttributeParameters
            {
                Parameters = parameters,
                LotKeys = lotKeys,
                Attributes = attributes
            }));
        }