Пример #1
0
        /// <summary>
        /// Sends a GetDataObjects message to a store.
        /// </summary>
        /// <param name="uris">The URI.</param>
        /// <param name="format">The format of the response (XML or JSON).</param>
        /// <param name="extension">The message header extension.</param>
        /// <returns>The sent message on success; <c>null</c> otherwise.</returns>
        public virtual EtpMessage <GetDataObjects> GetDataObjects(IDictionary <string, string> uris, string format = Formats.Xml, IMessageHeaderExtension extension = null)
        {
            var body = new GetDataObjects
            {
                Uris   = uris ?? new Dictionary <string, string>(),
                Format = format ?? Formats.Xml,
            };

            return(SendRequest(body, extension: extension));
        }
        /// <summary>
        /// Sends a GetDataObjects message to a store.
        /// </summary>
        /// <param name="uris">The URIs.</param>
        /// <param name="messageFlag">The message flag.</param>
        /// <returns>The message identifier.</returns>
        public virtual long GetDataObjects(IList <string> uris, MessageFlags messageFlag = MessageFlags.MultiPartAndFinalPart)
        {
            var header = CreateMessageHeader(Protocols.Store, MessageTypes.Store.GetDataObjects, messageFlags: messageFlag);

            var getObject = new GetDataObjects
            {
                Uris = uris
            };

            return(Session.SendMessage(header, getObject));
        }
Пример #3
0
        /// <summary>
        /// Handles the GetDataObjects message from a customer.
        /// </summary>
        /// <param name="header">The message header.</param>
        /// <param name="getDataObjects">The GetDataObjects message.</param>
        protected virtual void HandleGetDataObjects(IMessageHeader header, GetDataObjects getDataObjects)
        {
            var args        = Notify(OnGetDataObjects, header, getDataObjects);
            var dataObjects = new List <DataObject>();
            var errors      = new List <ErrorInfo>();

            HandleGetDataObjects(args, dataObjects, errors);

            if (args.Cancel)
            {
                return;
            }

            if (!dataObjects.Any() && !errors.Any())
            {
                GetDataObjectsResponse(header.MessageId, dataObjects, errors, MessageFlags.NoData);
            }
            else
            {
                GetDataObjectsResponse(header.MessageId, dataObjects, errors);
            }
        }