public PriorityTransactionalReader(string inputQueueFormatName)
 {
     Contract.Requires(inputQueueFormatName != null);
     InputQueueFormatName = inputQueueFormatName;
     _low  = new SubQueue(InputQueueFormatName + ";low");
     _high = new SubQueue(InputQueueFormatName + ";high");
 }
Beispiel #2
0
        private void ShowScreenInfo()
        {
            if (!NoSubtitlesMode)
            {
                if (RopeHook.entity1 != null && RopeHook.entity2 == null)
                {
                    GlobalSubtitle += ("VRope: Select a second object to attach.\n");
                }

                if (ForceHook.entity1 != null && ForceHook.entity2 == null)
                {
                    GlobalSubtitle += ("VRope: Select the target object.\n");
                }

                if (SelectedHooks.Count > 0)
                {
                    GlobalSubtitle += "VRope: Objects Selected [ " + SelectedHooks.Count + " ].\n";
                }

                GlobalSubtitle += SubQueue.MountSubtitle();

                if (DebugMode)
                {
                    GlobalSubtitle += "\n" + DebugInfo;
                }


                UI.ShowSubtitle(GlobalSubtitle);
            }
        }
Beispiel #3
0
        public static void CycleTransportHookFilterProc(bool nextFilter = true)
        {
            if (Util.IsPlayerAlive() && Util.IsPlayerSittingInFlyingVehicle())
            {
                if (nextFilter)
                {
                    if ((CurrentTransportHookFilterIndex + 1) < HookFilter.DefaultFilters.Count)
                    {
                        CurrentTransportHookFilterIndex++;
                    }
                    else
                    {
                        CurrentTransportHookFilterIndex = 0;
                    }
                }
                else
                {
                    if ((CurrentTransportHookFilterIndex - 1) >= 0)
                    {
                        CurrentTransportHookFilterIndex--;
                    }
                    else
                    {
                        CurrentTransportHookFilterIndex = HookFilter.DefaultFilters.Count - 1;
                    }
                }

                SubQueue.AddSubtitle(8808, "VRope Transport Hook Filter: " + HookFilter.DefaultFilters[CurrentTransportHookFilterIndex].label, SUBTITLE_DURATION);
            }
        }
Beispiel #4
0
        public static void CycleTransportHookModeProc(bool nextFilter = true)
        {
            if (Util.IsPlayerAlive() && Util.IsPlayerSittingInFlyingVehicle())
            {
                if (nextFilter)
                {
                    if ((CurrentTransportHookModeIndex + 1) < AllTransportHookModes.Length)
                    {
                        CurrentTransportHookModeIndex++;
                    }
                    else
                    {
                        CurrentTransportHookModeIndex = 0;
                    }
                }
                else
                {
                    if ((CurrentTransportHookModeIndex - 1) >= 0)
                    {
                        CurrentTransportHookModeIndex--;
                    }
                    else
                    {
                        CurrentTransportHookModeIndex = HookFilter.DefaultFilters.Count - 1;
                    }
                }

                SubQueue.AddSubtitle(8809, "VRope Transport Hook Mode: " + AllTransportHookModes[CurrentTransportHookModeIndex].second, SUBTITLE_DURATION);
            }
        }
 public bool TryMoveMessage(OpenedQueue queue, Message message, SubQueue subQueue, out string msgId)
 {
     using (var destinationQueue = queue.OpenSiblngQueue(subQueue, QueueAccessMode.Send))
     {
         Message receiveById;
         try
         {
             receiveById = queue.ReceiveById(message.Id);
         }
         catch (InvalidOperationException)
         {
             msgId = null;
             return(false);
         }
         receiveById.AppSpecific = 0;//reset flag
         destinationQueue.Send(receiveById);
         msgId = receiveById.Id;
         logger.DebugFormat("Moving messgage {0} from {1} to {2}, new id: {3}",
                            message.Id,
                            queue.RootUri,
                            destinationQueue.QueueUrl,
                            receiveById.Id);
         return(true);
     }
 }
 public static Uri AddSubQueue(this Uri self, SubQueue subQueue)
 {
     Uri subQueueUrl;
     if (self.AbsolutePath.EndsWith("/"))
         subQueueUrl = new Uri(self + subQueue.ToString());
     else
         subQueueUrl = new Uri(self + "/" + subQueue);
     return subQueueUrl;
 }
 /// <summary>
 /// Formats the entity path for a receiver or processor taking into account whether using a SubQueue.
 /// </summary>
 public static string FormatEntityPath(string entityPath, SubQueue subQueue)
 {
     return(subQueue switch
     {
         SubQueue.None => entityPath,
         SubQueue.DeadLetter => FormatDeadLetterPath(entityPath),
         SubQueue.TransferDeadLetter => FormatTransferDeadLetterPath(entityPath),
         _ => null
     });
Beispiel #8
0
        public OpenedQueue OpenSubQueue(SubQueue subQueue, QueueAccessMode access)
        {
            var messageQueue = new MessageQueue(info.QueuePath + ";" + subQueue);

            if (Formatter != null)
            {
                messageQueue.Formatter = Formatter;
            }
            return(new OpenedQueue(this, messageQueue, queueUrl + ";" + subQueue));
        }
Beispiel #9
0
 private void ReadUrisFromSubQueue(Set <Uri> set, SubQueue subQueue)
 {
     using (var q = MsmqUtil.GetQueuePath(Endpoint).Open(QueueAccessMode.Receive))
         using (var sq = q.OpenSubQueue(subQueue, QueueAccessMode.SendAndReceive))
         {
             var messages = sq.GetAllMessagesWithStringFormatter();
             foreach (var message in messages)
             {
                 var uriString = message.Body.ToString();
                 set.Add(new Uri(uriString));
             }
         }
 }
Beispiel #10
0
 public bool TryMoveMessage(OpenedQueue queue, Message message, SubQueue subQueue, out string msgId)
 {
     try
     {
         queue.MoveToSubQueue(subQueue, message);
         msgId = message.Id;
         return(true);
     }
     catch (TransportException)
     {
         msgId = null;
         return(false);
     }
 }
Beispiel #11
0
 public bool TryMoveMessage(OpenedQueue queue, Message message, SubQueue subQueue, out string msgId)
 {
     try
     {
         queue.MoveToSubQueue(subQueue, message);
         msgId = message.Id;
         return true;
     }
     catch (TransportException)
     {
         msgId = null;
         return false;
     }
 }
Beispiel #12
0
        public static Uri AddSubQueue(this Uri self, SubQueue subQueue)
        {
            Uri subQueueUrl;

            if (self.AbsolutePath.EndsWith("/"))
            {
                subQueueUrl = new Uri(self + SubQueue.Discarded.ToString());
            }
            else
            {
                subQueueUrl = new Uri(self + "/" + SubQueue.Discarded);
            }
            return(subQueueUrl);
        }
        private void MoveToUnroutableSubQueue(long lookupId, QueueTransaction transaction)
        {
            try
            {
                if (_posionSubQueue == null)
                {
                    _posionSubQueue = new SubQueue(_input.FormatName + ";" + UnroutableSubQueue);
                }

                Queues.MoveMessage(_input, _posionSubQueue, lookupId, transaction);
                return;
            }
            catch (QueueException e)
            {
                Console.Error.WriteLine($"WARN Failed to move message {{lookupId={lookupId}}} {{subqueue={UnroutableSubQueue}}} {{error={e.Message}}}");
            }
        }
Beispiel #14
0
 private void MoveToPoisonSubqueue(QueueReader fromQueue, long lookupId, QueueTransaction transaction)
 {
     Contract.Requires(fromQueue != null);
     if (_posionQueue == null)
     {
         _posionQueue = new SubQueue(InputQueueFormatName + ";" + UnroutableSubQueue);
     }
     try
     {
         Queues.MoveMessage(fromQueue, _posionQueue, lookupId, transaction);
         return;
     }
     catch (QueueException e)
     {
         Console.Error.WriteLine($"WARN Failed to move message {{lookupId={lookupId}}} {{subqueue={UnroutableSubQueue}}} {{error={e.Message}}}");
     }
 }
Beispiel #15
0
        public static void IncrementBalloonUpForce(bool negativeIncrement = false, bool halfIncrement = false)
        {
            float increment = BalloonUpForceIncrement;

            if (negativeIncrement)
            {
                increment = -increment;
            }

            if (halfIncrement)
            {
                increment = increment / 2f;
            }

            BalloonUpForce += increment * Game.LastFrameTime * 10.0f;

            SubQueue.AddSubtitle(333, "VRope Balloon Up Force: " + BalloonUpForce.ToString("0.00"), 220);
        }
Beispiel #16
0
        public static void IncrementForceProc(bool negativeIncrement = false, bool halfIncrement = false)
        {
            float increment = ForceIncrementValue;

            if (negativeIncrement)
            {
                increment = -increment;
            }

            if (halfIncrement)
            {
                increment = increment / 2f;
            }

            ForceMagnitude += increment * Game.LastFrameTime * 10.0f;

            SubQueue.AddSubtitle(14, "VRope Force Value: " + ForceMagnitude.ToString("0.00"), 220);
        }
        protected SubQueue GetRoute(Message msg)
        {
            SubQueue subQueue = null;

            try
            {
                subQueue = _router(msg);
                if (subQueue == null)
                {
                    throw new NullReferenceException("route");
                }
                return(subQueue);
            }
            catch (Exception ex)
            {
                throw new RouteException("Failed to get route", ex, msg.LookupId);
            }
        }
Beispiel #18
0
        public void can_peek_when_opened_with_move_acces()
        {
            var fn   = Queues.TryCreate(".\\private$\\subqtest", QueueTransactional.None);
            var sqfn = fn + ";sq";

            using (var qWriter = new QueueWriter(fn))
            {
                qWriter.Write(new Message {
                    AppSpecific = 234
                });
            }
            using (var qReader = new QueueReader(fn))
                using (var subQueue = new SubQueue(sqfn))
                {
                    var msg = qReader.Peek(Properties.LookupId);
                    Queues.MoveMessage(qReader, subQueue, msg.LookupId);
                    var got = subQueue.Read();
                    Assert.AreEqual(234, got.AppSpecific);
                }
        }
        /*
         * 0) Recover - wait for acks for each message in batch
         * 1) Peek message
         * 2) begin transaction
         * 3)   move to "batch" subqueue
         * 4)   send
         * 5) commit
         * 6) for each message in batch
         * 7)   wait for ack
         *         on success remove message from "batch" subqueue (Transaction.Single)
         *         on failure move to InProgressSubQueue
         */

        protected override async Task RunAsync()
        {
            await Task.Yield();

            _batchQueue = new SubQueue(InputQueueFormatName + ";" + InProgressSubQueue);
            try
            {
                await Recover(); // clean up the existing batch (if any)

                var sent = new List <Tracking>();
                for (;;)
                {
                    if (_input.Peek(PeekProperties, TimeSpan.Zero) == null)
                    {
                        await _input.PeekAsync(PeekProperties); // wait for next message
                    }
                    RouteBatch(sent);
                    await WaitForAcknowledgements(sent);

                    sent.Clear();
                }
            }
            catch (ObjectDisposedException)
            {
                Console.Error.WriteLine("INFO: stopping");
                // Stop was called
            }
            catch (QueueException ex) when(ex.ErrorCode == ErrorCode.OperationCanceled)
            {
                Console.Error.WriteLine("INFO: stopping");
                // Stop was called
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine("WARNING: " + ex);
            }
        }
 public Task <Task> StartAsync()
 {
     _low  = new SubQueue(InputQueueFormatName + ";low");
     _high = new SubQueue(InputQueueFormatName + ";high");
     return(_router.StartAsync());
 }
Beispiel #21
0
 public OpenedQueue OpenSubQueue(SubQueue subQueue, QueueAccessMode access)
 {
     var messageQueue = new MessageQueue(info.QueuePath + ";" + subQueue);
     if (Formatter != null)
         messageQueue.Formatter = Formatter;
     return new OpenedQueue(this, messageQueue, queueUrl+";"+subQueue);
 }
Beispiel #22
0
 public OpenedQueue OpenSiblngQueue(SubQueue subQueue, QueueAccessMode accessMode)
 {
     return new OpenedQueue(info, new MessageQueue(info.QueuePath + "#" + subQueue), queueUrl + "#" + subQueue, transactional);
 }
Beispiel #23
0
 public void MoveToSubQueue(SubQueue subQueue, Message message)
 {
     queue.MoveToSubQueue(subQueue.ToString(), message);
 }
 public bool TryMoveMessage(OpenedQueue queue, Message message, SubQueue subQueue, out string msgId)
 {
     using (var destinationQueue = queue.OpenSiblngQueue(subQueue, QueueAccessMode.Send))
     {
         Message receiveById;
         try
         {
             receiveById = queue.ReceiveById(message.Id);
         }
         catch (InvalidOperationException)
         {
             msgId = null;
             return false;
         }
         receiveById.AppSpecific = 0;//reset flag
         destinationQueue.Send(receiveById);
         msgId = receiveById.Id;
         logger.DebugFormat("Moving messgage {0} from {1} to {2}, new id: {3}",
             message.Id,
             queue.RootUri,
             destinationQueue.QueueUrl,
             receiveById.Id);
         return true;
     }
 }
Beispiel #25
0
 public PlayQueue()
 {
     _backLogQueue   = new SubQueue(this, EnumeratorType.BackLog);
     _immidiateQueue = new SubQueue(this, EnumeratorType.Immidiate);
     _queueQueue     = new SubQueue(this, EnumeratorType.Queue);
 }
Beispiel #26
0
 public OpenedQueue OpenSiblngQueue(SubQueue subQueue, QueueAccessMode accessMode)
 {
     return(new OpenedQueue(info, new MessageQueue(info.QueuePath + "#" + subQueue),
                            queueUrl + "#" + subQueue,
                            transactional));
 }
Beispiel #27
0
 public void MoveToSubQueue(SubQueue subQueue, Message message)
 {
     queue.MoveToSubQueue(subQueue.ToString(), message);
 }
Beispiel #28
0
 public OpenedQueue OpenSubQueue(OpenedQueue queue, SubQueue subQueue, QueueAccessMode accessMode)
 {
     return(queue.OpenSubQueue(subQueue, accessMode));
 }
Beispiel #29
0
        public static void ToggleBalloonHookModeProc()
        {
            BalloonHookMode = !BalloonHookMode;

            SubQueue.AddSubtitle(1230, "VRope Balloon Hook Mode: " + (BalloonHookMode ? "[ON]" : "(OFF)"), 550);
        }
Beispiel #30
0
 public static Message SetSubQueueToSendTo(this Message self, SubQueue queue)
 {
     self.AppSpecific = ((int)MessageType.MoveMessageMarker << 16) | (int)queue;
     return(self);
 }
Beispiel #31
0
 public OpenedQueue OpenSubQueue(OpenedQueue queue, SubQueue subQueue, QueueAccessMode accessMode)
 {
     return queue.OpenSubQueue(subQueue, accessMode);
 }
Beispiel #32
0
        protected override void Execute(CodeActivityContext context)
        {
            // Get the connection string
            DBConnection ext = context.GetExtension <DBConnection>();

            if (ext == null)
            {
                throw new InvalidProgramException("No connection string available");
            }

            UserTasksDataContext dc = new UserTasksDataContext(ext.ConnectionString);

            Queue    q          = null;
            SubQueue sq         = null;
            int      queueID    = 0;
            int      subQueueID = 0;

            if (QueueName.Get(context) != "" && SubQueueName.Get(context) != "None")
            {
                // Lookup the queue and subqueue
                q = dc.Queues.SingleOrDefault(x => x.QueueName == QueueName.Get(context));
                if (q == null)
                {
                    throw new InvalidProgramException("The specified queue (" + QueueName.Get(context) + ") was not found");
                }

                sq = dc.SubQueues.SingleOrDefault(x => x.QueueID == q.QueueID &&
                                                  x.SubQueueName == SubQueueName.Get(context));
                if (sq == null)
                {
                    throw new InvalidProgramException("The specified subqueue (" +
                                                      QueueName.Get(context) + " - " +
                                                      SubQueueName.Get(context) + ") was not found");
                }

                queueID    = q.QueueID;
                subQueueID = sq.SubQueueID;
            }

            // Lookup the QueueInstance
            dc.Refresh(System.Data.Linq.RefreshMode.OverwriteCurrentValues, dc.QueueInstances);
            QueueInstance qi = dc.QueueInstances.SingleOrDefault(x => x.QueueInstanceKey == QueueInstanceKey.Get(context));

            if (qi == null)
            {
                throw new InvalidProgramException("The specified request (" + QueueInstanceKey.Get(context) + ") was not found");
            }

            // Assign the QueueInstance to this subqueue
            if (sq != null)
            {
                qi.CurrentSubQueueID = sq.SubQueueID;
            }
            else
            {
                qi.CurrentSubQueueID = null;
            }

            qi.AssignedDate       = null;
            qi.AssignedOperatorID = null;
            qi.QC       = false;
            qi.Priority = null;

            // Update the QueueInstance record
            PersistQueueInstance persist = context.GetExtension <PersistQueueInstance>();

            persist.AddQueueInstance(qi);

            // Add a custom track record
            CustomTrackingRecord userRecord = new CustomTrackingRecord("Route")
            {
                Data =
                {
                    { "QueueInstanceKey", qi.QueueInstanceKey  },
                    { "SubQueueID",       qi.CurrentSubQueueID }
                }
            };

            // Emit the custom tracking record
            context.Track(userRecord);
        }
 public static Message SetSubQueueToSendTo(this Message self, SubQueue queue)
 {
     self.AppSpecific = ((int) MessageType.MoveMessageMarker << 16) | (int) queue;
     return self;
 }
Beispiel #34
0
        protected override void Execute(CodeActivityContext context)
        {
            // Get the connection string
            DBConnection ext = context.GetExtension <DBConnection>();

            if (ext == null)
            {
                throw new InvalidProgramException("No connection string available");
            }

            // Lookup the Queue
            UserTasksDataContext dc = new UserTasksDataContext(ext.ConnectionString);
            Queue q = dc.Queues.SingleOrDefault(x => x.QueueName == QueueName.Get(context));

            if (q == null)
            {
                throw new InvalidProgramException("The specified queue (" + QueueName.Get(context) + ") was not found");
            }

            SubQueue s = dc.SubQueues
                         .SingleOrDefault(x => x.QueueID == q.QueueID &&
                                          x.SubQueueName == SubQueueName.Get(context));

            if (s == null)
            {
                throw new InvalidProgramException("The specified sub-queue (" + SubQueueName.Get(context) + ") was not found");
            }

            // Create and initialize a QueueInstance object
            QueueInstance qi = new QueueInstance();

            qi.QueueInstanceKey  = Guid.NewGuid();
            qi.CurrentSubQueueID = s.SubQueueID;
            qi.CreateDate        = DateTime.UtcNow;
            qi.InstanceID        = context.WorkflowInstanceId;

            // Setup the initial values
            qi.AssignedDate       = null;
            qi.AssignedOperatorID = null;
            qi.QC       = false;
            qi.Priority = null;

            // Insert the Request record
            PersistQueueInstance persist = context.GetExtension <PersistQueueInstance>();

            persist.AddQueueInstance(qi);

            // Return the QueueInstance object
            QueueInstanceKey.Set(context, qi.QueueInstanceKey);

            CustomTrackingRecord userRecord = new CustomTrackingRecord("Start")
            {
                Data =
                {
                    { "QueueInstanceKey", qi.QueueInstanceKey  },
                    { "SubQueueID",       qi.CurrentSubQueueID }
                }
            };

            // Emit the custom tracking record
            context.Track(userRecord);
        }
Beispiel #35
0
		private void ReadUrisFromSubQueue(Set<Uri> set, SubQueue subQueue)
		{
			using (var q = MsmqUtil.GetQueuePath(Endpoint).Open(QueueAccessMode.Receive))
			using (var sq = this.queueStrategy.OpenSubQueue(q, subQueue, QueueAccessMode.SendAndReceive))
			{
				var messages = sq.GetAllMessagesWithStringFormatter();
				foreach (var message in messages)
				{
					var uriString = message.Body.ToString();
					set.Add(new Uri(uriString));
				}
			}
		}
Beispiel #36
0
        protected override void Execute(CodeActivityContext context)
        {
            // Get the connection string
            DBConnection ext = context.GetExtension <DBConnection>();

            if (ext == null)
            {
                throw new InvalidProgramException("No connection string available");
            }

            // Lookup the operator
            UserTasksDataContext dc = new UserTasksDataContext(ext.ConnectionString);
            OperatorConfig       oc = dc.OperatorConfigs.SingleOrDefault(x => x.OperatorKey == OperatorKey.Get(context));

            if (oc == null)
            {
                oc                     = new OperatorConfig();
                oc.OperatorKey         = OperatorKey.Get(context);
                oc.UnderEvaluation     = false;
                oc.Frequency           = 5;
                oc.NumberSinceLastEval = 0;

                dc.OperatorConfigs.InsertOnSubmit(oc);
                dc.SubmitChanges();
            }

            // Determine the Queue info
            char[]   delimiter = { '|' };
            string[] values    = QueueKey.Get(context).Split(delimiter, 3);

            // Lookup the queue and subqueue
            Queue q = dc.Queues.SingleOrDefault(x => x.QueueName == values[0]);

            if (q == null)
            {
                throw new InvalidProgramException("The specified queue (" + values[0] + ") was not found");
            }

            SubQueue sq = dc.SubQueues.SingleOrDefault(x => x.QueueID == q.QueueID &&
                                                       x.SubQueueName == values[1]);

            if (sq == null)
            {
                throw new InvalidProgramException("The specified subqueue (" +
                                                  values[0] + " - " +
                                                  values[1] + ") was not found");
            }

            bool bQC = bool.Parse(values[2]);

            if (sq.AllowSelection)
            {
                // Return all the available instances
                IEnumerable <QueueInstance> instances;

                if (bQC)
                {
                    instances = dc.QueueInstances
                                .Where(x => x.CurrentSubQueueID == sq.SubQueueID &&
                                       x.QC == bQC &&
                                       (x.AssignedOperatorID == null ||
                                        x.AssignedOperatorID == oc.OperatorConfigID))
                                .OrderBy(x => x.Priority.Value)
                                .OrderBy(x => x.CreateDate);
                }
                else
                {
                    instances = dc.QueueInstances
                                .Where(x => x.CurrentSubQueueID == sq.SubQueueID &&
                                       x.QC == bQC &&
                                       (x.AssignedOperatorID == null ||
                                        x.AssignedOperatorID == oc.OperatorConfigID))
                                .OrderBy(x => x.CreateDate);
                }

                if (instances.Count() > 0)
                {
                    QueueInstance[] qiList = new QueueInstance[instances.Count()];
                    int             i      = 0;
                    foreach (QueueInstance r in instances)
                    {
                        qiList[i++] = r;
                    }

                    QueueInstanceList.Set(context, qiList);
                }
            }
            else
            {
                // Return the oldest instance
                IEnumerable <QueueInstance> instances;
                if (bQC)
                {
                    instances = dc.QueueInstances
                                .Where(x => x.CurrentSubQueueID == sq.SubQueueID &&
                                       x.QC == bQC &&
                                       (x.AssignedOperatorID == null ||
                                        x.AssignedOperatorID == oc.OperatorConfigID))
                                .OrderBy(x => x.Priority.Value)
                                .OrderBy(x => x.CreateDate)
                                .Take(1);
                }
                else
                {
                    instances = dc.QueueInstances
                                .Where(x => x.CurrentSubQueueID == sq.SubQueueID &&
                                       x.QC == bQC &&
                                       (x.AssignedOperatorID == null ||
                                        x.AssignedOperatorID == oc.OperatorConfigID))
                                .OrderBy(x => (x.Priority.HasValue ? 1 : 0) * x.Priority.Value * (bQC ? 1 : 0))
                                .OrderBy(x => x.CreateDate)
                                .Take(1);
                }

                if (instances.Count() > 0)
                {
                    QueueInstance qi = instances.First <QueueInstance>();
                    qi.AssignedOperatorID = oc.OperatorConfigID;
                    dc.SubmitChanges();

                    QueueInstance[] qiList = new QueueInstance[1];
                    qiList[0] = qi;

                    QueueInstanceList.Set(context, qiList);
                }
            }
        }