CompleteRequest() public method

Sets the Item record with the required settings to complete a request. Note record is not written to database - Call Save explicitly.
public CompleteRequest ( QueueMessageItem item = null, string messageText = null, bool autoSave = false ) : bool
item QueueMessageItem
messageText string
autoSave bool
return bool
コード例 #1
0
        protected override void OnExecuteStart(QueueMessageManager manager)
        {
            base.OnExecuteStart(manager);            

            var queueItem = manager.Item;

            try
            {
                string action = queueItem.Action;

                if (!string.IsNullOrEmpty(action))
                {
                    //Initialize Anything
                    action = action.Trim();
                }

                switch (action)
                {
                    default:
                        // TODO: Remove for production                                                
                        Thread.Sleep( (int) (DateTime.Now.Ticks % 500));

                        // use this instead to ensure that messages get updated properly and consistently
                        // that is: All flags are set, date is always UTC date, etc.
                        //if (!manager.CancelRequest(messageText: "Unknown Action", autoSave: true))
                        if (!manager.CompleteRequest(messageText: "Processing complete.", autoSave: true))
                        {
                            // this is pointless - if this save fails
                            // it's likely the save you are doing in
                            // onError will also fail
                            OnError(manager);
                            return;
                        }
                        //manager.CompleteCancelRequest(messageText: "Invalid message action provided.");
                        break;
                }
            }
            catch (Exception ex)
            {
                OnError(manager,ex.GetBaseException().Message);
                return;
            }

        }
コード例 #2
0
        /// <summary>
        /// This is where your processing happens
        /// </summary>
        /// <param name="manager"></param>
        private void controller_ExecuteStart(QueueMessageManager manager)
        {
            // get active queue item
            var item = manager.Item;

            // Typically perform tasks based on some Action/request
            if (item.Action == "PRINTIMAGE")
            {
                // recommend you offload processing
                //PrintImage(manager);                
            }
            else if (item.Action == "RESIZETHUMBNAIL")
            {
                //ResizeThumbnail(manager);
            }

            // just for kicks
           Interlocked.Increment(ref RequestCount);

            // every other request should throw exception, trigger ExecuteFailed            
            if (RequestCount % 2 == 0)
            {
                // Execption:
                object obj = null;
                obj.ToString();
            }

            // Complete request 
            manager.CompleteRequest(messageText: "Completed request " + DateTime.Now,
                                    autoSave: true);            
        }