Example #1
0
 public IList<Message> GetMessagesAndJournal(QueueType qType)
 {
     IList<Message> messages = GetMessages(qType);
     ReqMessageQueueJournal q = new ReqMessageQueueJournal(qConfiguration.GetQueueName(qType));
     IList<Message> messagesj = q.GetAllMessages().ToList<Message>();
     return messages.Union<Message>(messagesj).ToList();
 }
        public async Task <string> DequeueWork(QueueType queue)
        {
            CloudQueue cloudQueue = null;

            switch (queue)
            {
            case QueueType.Workflow:
                cloudQueue = _workflowQueue;
                break;

            case QueueType.Event:
                cloudQueue = _eventQueue;
                break;
            }

            if (cloudQueue == null)
            {
                return(null);
            }

            var msg = await cloudQueue.GetMessageAsync();

            if (msg == null)
            {
                return(null);
            }

            await cloudQueue.DeleteMessageAsync(msg);

            return(msg.AsString);
        }
Example #3
0
        public static queue CreateDownloadQueue(Tranferclint client, int id, string typ, string saveName, long length)
        {
            try
            {
                //Same as above with some changes.
                var queue = new queue();
                queue._Type  = typ;
                queue.Client = client;

                queue.Filename = saveName;
                queue._Type    = typ;

                queue.Type = QueueType.Download;
                //Create our file stream for writing.
                queue.FS = new FileStream(saveName, FileMode.Create);
                //Fill the stream will 0 bytes based on the real size. So we can index write.

                queue.Length = length;
                queue.FS.SetLength(length);
                //Instead of generating an ID, we will set the ID that has been sent.
                queue.ID = id;
                return(queue);
            }
            catch
            {
                return(null);
            }
        }
Example #4
0
        private async Task <string> ConstructQueueName(ILogger logger, int herId, QueueType type)
        {
            var details = await Core.AddressRegistry.FindCommunicationPartyDetailsAsync(logger, herId).ConfigureAwait(false);

            if (details == null)
            {
                throw new MessagingException("Could not find sender in address registry")
                      {
                          EventId = EventIds.SenderMissingInAddressRegistryEventId
                      };
            }

            switch (type)
            {
            case QueueType.Asynchronous:
                return(ExtractQueueName(details.AsynchronousQueueName));

            case QueueType.Synchronous:
                return(ExtractQueueName(details.SynchronousQueueName));

            case QueueType.Error:
                return(ExtractQueueName(details.ErrorQueueName));

            default:
                throw new InvalidOperationException("QueueType not supported");
            }
        }
Example #5
0
        private void TestUpdate()
        {
            var now = DateTime.Now;

            var queueType = new QueueType
            {
                Name     = "My Queue Type 2",
                Delay    = 4,
                Duration = 6,
                Created  = now
            };

            var created = _queueTypeRepository.Create(queueType).Result;

            Assert.Equal(created.Id, _queueTypeRepository.FindById(created.Id).Id);
            Assert.NotNull(created);
            Assert.Equal(created.Id, queueType.Id);

            created.Name = "I just changed my mind";

            var updated = _queueTypeRepository.Update(created).Result;

            Assert.NotNull(updated);
            Assert.Equal("I just changed my mind", updated.Name);
        }
        public bool SendDataToQueue(QueueType queueType, object data)
        {
            var result = true;

            try
            {
                if (_connection == null)
                {
                    _connection = _connectionFactory.CreateConnection();
                }

                var channel = _connection.CreateModel();
                channel.QueueDeclare(queueType.ToString(), false, false, false, null);
                var messageJson = Newtonsoft.Json.JsonConvert.SerializeObject(data);
                var message     = Encoding.UTF8.GetBytes(messageJson);

                channel.BasicPublish(exchange: String.Empty, routingKey: queueType.ToString(), basicProperties: null, body: message);
            }
            catch (Exception ex)
            {
                result = false;
            }

            return(result);
        }
Example #7
0
        public MessageQueue[] InitializeQueue(Endpoint queueEndpoint, QueueType queueType)
        {
            var queue = MsmqUtil.GetQueuePath(queueEndpoint).Create();

            switch (queueType)
            {
            case QueueType.Standard:
                return(new[]
                {
                    queue,
                    MsmqUtil.OpenOrCreateQueue(GetErrorsQueuePath(), QueueAccessMode.SendAndReceive, queue),
                    MsmqUtil.OpenOrCreateQueue(GetSubscriptionQueuePath(), QueueAccessMode.SendAndReceive, queue),
                    MsmqUtil.OpenOrCreateQueue(GetDiscardedQueuePath(), QueueAccessMode.SendAndReceive, queue),
                    MsmqUtil.OpenOrCreateQueue(GetTimeoutQueuePath(), QueueAccessMode.SendAndReceive, queue),
                });

            case QueueType.LoadBalancer:
                return(new[]
                {
                    queue,
                    MsmqUtil.OpenOrCreateQueue(GetKnownWorkersQueuePath(), QueueAccessMode.SendAndReceive, queue),
                    MsmqUtil.OpenOrCreateQueue(GetKnownEndpointsQueuePath(), QueueAccessMode.SendAndReceive, queue),
                });

            default:
                throw new ArgumentOutOfRangeException("queueType", "Can't handle queue type: " + queueType);
            }
        }
Example #8
0
        /// <inheritdoc />
        /// <summary>
        /// Write a new id to the specified queue
        /// </summary>
        /// <param name="id"></param>
        /// <param name="queue"></param>
        /// <returns></returns>
        public async Task QueueWork(string id, QueueType queue)
        {
            if (string.IsNullOrEmpty(id))
            {
                throw new ArgumentNullException(nameof(id), "Param id must not be null");
            }

            SqlConnection cn = new SqlConnection(_connectionString);

            try
            {
                cn.Open();
                var par = _config.GetByQueue(queue);

                _sqlCommandExecutor.ExecuteCommand(cn, null, _queueWorkCommand,
                                                   new SqlParameter("@initiatorService", par.InitiatorService),
                                                   new SqlParameter("@targetService", par.TargetService),
                                                   new SqlParameter("@contractName", par.ContractName),
                                                   new SqlParameter("@msgType", par.MsgType),
                                                   new SqlParameter("@RequestMessage", id)
                                                   );
            }
            finally
            {
                cn.Close();
            }
        }
Example #9
0
        public override StartCommandResult OnStartCommand(Intent intent, StartCommandFlags flags, int startId)
        {
            var id         = intent.GetIntExtra("id", 0);
            var url        = intent.GetStringExtra("url");
            var filePath   = intent.GetStringExtra("filePath");
            var iQueueType = intent.GetIntExtra("queueType", 0);

            QueueType queueType = ConvertIntToQueueType(iQueueType);

            Task.Run(() => {
                var imageHelper = new DownloadHelper();
                imageHelper.DownloadFileAsync(url, filePath)
                .ContinueWith(fp => {
                    var message = new DownloadFinishedMessage
                    {
                        Id        = id,
                        Url       = url,
                        FilePath  = fp.Result,
                        QueueType = queueType
                    };
                    MessagingCenter.Send(message, "DownloadFinishedMessage");
                });
            });

            return(StartCommandResult.Sticky);
        }
Example #10
0
        /// <summary>
        /// 佣兵招募冷却时间
        /// </summary>
        /// <param name="userID"></param>
        /// <param name="recruitRule"></param>
        /// <returns></returns>
        public static void UpdateRecruitColdTime(string userID, RecruitRule recruitRule)
        {
            QueueType queueType = QueueType.ShiLiTiaoYi;

            if (recruitRule.RecruitType == RecruitType.ShiLiTiaoYi.ToInt())
            {
                queueType = QueueType.ShiLiTiaoYi;
            }
            else if (recruitRule.RecruitType == RecruitType.BaiLiTiaoYi.ToInt())
            {
                queueType = QueueType.BaiLiTiaoYi;
            }
            else if (recruitRule.RecruitType == RecruitType.Golden.ToInt())
            {
                queueType = QueueType.Golden;
            }
            var       cacheSet  = new GameDataCacheSet <UserQueue>();
            UserQueue userQueue = cacheSet.Find(userID, s => s.QueueType == queueType);

            if (userQueue == null)
            {
                userQueue           = new UserQueue();
                userQueue.QueueID   = Guid.NewGuid().ToString();
                userQueue.UserID    = userID;
                userQueue.QueueType = queueType;
                cacheSet.Add(userQueue, userID.ToInt());
            }
            userQueue.QueueName     = queueType.ToString();
            userQueue.Timing        = DateTime.Now;
            userQueue.TotalColdTime = recruitRule.CodeTime;
            userQueue.ColdTime      = recruitRule.CodeTime;
            userQueue.StrengNum     = 1;
            userQueue.IsSuspend     = false;
        }
Example #11
0
        /// <summary>
        /// Sends a prepared message
        /// </summary>
        /// <param name="logger"></param>
        /// <param name="message">The prepared message</param>
        /// <param name="queueType">The type of queue to use</param>
        /// <param name="userId"></param>
        /// <param name="xml">Optional xml content. This will be logged depending on the logging level.</param>
        /// <returns></returns>
        private async Task Send(ILogger logger, IMessagingMessage message, QueueType queueType, string userId = "99999999999", XDocument xml = null)
        {
            if (message == null)
            {
                throw new ArgumentNullException(nameof(message));
            }

            IMessagingSender messageSender = null;

            try
            {
                messageSender = SenderPool.CreateCachedMessageSender(logger, message.To);
                await messageSender.SendAsync(message).ConfigureAwait(false);
            }
            catch (Exception ex)
            {
                logger.LogException("Cannot send message to service bus. Invalid endpoint.", ex);

                throw new MessagingException(ex.Message)
                      {
                          EventId = EventIds.Send
                      };
            }
            finally
            {
                if (messageSender != null)
                {
                    SenderPool.ReleaseCachedMessageSender(logger, message.To);
                }
            }
        }
        public override void SendCommandRemote(QueueType inQueue,
                                               LibCommon.Network.Types.GameMessage inEvent)
        {
            byte[] msg = ThriftMessageSerialize.SerializeCompact(inEvent);

            if (inQueue == QueueType.Client)
            {
                if (string.IsNullOrEmpty(inEvent.NetworkId))
                {
                    //_internalNetwork.BroadcastAll(NetworkUtils.SerializeEvent(inEvent));

                    _internalNetwork.BroadcastAll(msg);

                    ClientQueue.Enqueue(inEvent);
                }
                else
                {
                    Debug.Log(inEvent.NetworkId);

                    if (inEvent.NetworkId == "-1")
                    {
                        ClientQueue.Enqueue(inEvent);
                    }
                    else
                    {
                        _internalNetwork.SendPacketToClient(inEvent.NetworkId, msg);
                    }
                }
            }
            else
            {
                _internalNetwork.SendToServer(msg);
            }
        }
Example #13
0
        public static List <CloudQueueMessage> GetQueueMessages(QueueType type, SourceType source, int messageCount)
        {
            messageCount = Math.Min(messageCount, 32); //32 is hard limit
            CloudQueue queue = GetCloudQueue(type, source);

            List <CloudQueueMessage> queueMessageList = new List <CloudQueueMessage>();

            IEnumerable <CloudQueueMessage> queueMessages = queue.GetMessages(messageCount);

            if ((queueMessages != null) && (queueMessages.Count <CloudQueueMessage>() > 0))
            {
                foreach (CloudQueueMessage message in queueMessages)
                {
                    //Check Poisen Message
                    if (message.DequeueCount < 3)
                    {
                        queueMessageList.Add(message);
                    }
                    else
                    {
                        AddQueueMessage(QueueType.Failures, SourceType.Twitter, message.AsString);
                        queue.DeleteMessage(message);
                    }
                }
            }

            return(queueMessageList);
        }
        public MessageQueue[] InitializeQueue(Endpoint queueEndpoint, QueueType queueType)
        {
        	var queue = MsmqUtil.GetQueuePath(queueEndpoint).Create();
        	switch (queueType)
            {
                case QueueType.Standard:
                    return new[]
	                {
	                    queue,
	                    MsmqUtil.OpenOrCreateQueue(GetErrorsQueuePath(), QueueAccessMode.SendAndReceive, queue),
	                    MsmqUtil.OpenOrCreateQueue(GetSubscriptionQueuePath(), QueueAccessMode.SendAndReceive, queue),
	                    MsmqUtil.OpenOrCreateQueue(GetDiscardedQueuePath(), QueueAccessMode.SendAndReceive, queue),
	                    MsmqUtil.OpenOrCreateQueue(GetTimeoutQueuePath(), QueueAccessMode.SendAndReceive, queue),
	                };
                case QueueType.LoadBalancer:
                    return new[]
	                {
	                    queue,
	                    MsmqUtil.OpenOrCreateQueue(GetKnownWorkersQueuePath(), QueueAccessMode.SendAndReceive, queue),
	                    MsmqUtil.OpenOrCreateQueue(GetKnownEndpointsQueuePath(), QueueAccessMode.SendAndReceive, queue),
	                };
                case QueueType.Raw:
                    return new[]
	                {
	                    queue,
	                };
                default:
                    throw new ArgumentOutOfRangeException("queueType", "Can't handle queue type: " + queueType);
            }
        }
        public bool IsEmpty(QueueType type)
        {
            int count;

            if (type == QueueType.Position)
            {
                lock (this)
                {
                    count = positionQueue.Count;
                }
            }
            else
            {
                lock (this)
                {
                    count = velocityQueue.Count;
                }
            }
            if (count == 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        public void Replace(QueueType type, double[,] points)
        {
            if (points == null)
            {
                return;
            }

            List <double[]> tempQueue = new List <double[]>();

            for (int i = 0; i < points.GetLength(1); i++)
            {
                tempQueue.Add(new double[2] {
                    points[0, i], points[1, i]
                });
            }
            if (type == QueueType.Position)
            {
                lock (this)
                {
                    positionQueue.Clear();
                    positionQueue.AddRange(tempQueue);
                }
            }
            else
            {
                lock (this)
                {
                    velocityQueue.Clear();
                    velocityQueue.AddRange(tempQueue);
                }
            }
        }
Example #17
0
        public static queue CreateUploadQueue(Tranferclint client, string fileName)
        {
            try
            {
                //We will create a new upload queue
                var queue = new queue();
                //Set our filename
                queue.Filename = fileName;
                // queue.Filename = fileName;

                queue._Type = Path.GetFileName(fileName).ToLower().Contains("jpg") || Path.GetFileName(fileName).ToLower().Contains("png") ? "Image" : "Video";



                //Set our client
                queue.Client = client;
                //Set our queue type to upload.
                queue.Type = QueueType.Upload;
                //Create our file stream for reading.
                queue.FS = new FileStream(fileName, FileMode.Open);
                //Create our transfer thread
                queue.Thread = new Thread(new ParameterizedThreadStart(transferProc));
                //   queue.Thread.IsBackground = true;
                //Generate our ID
                queue.ID = Application.Rand.Next();
                //Set our length to the size of the file.
                queue.Length = queue.FS.Length;
                return(queue);
            }
            catch
            {
                //If something goes wrong, return null
                return(null);
            }
        }
Example #18
0
    public void FixedUpdate()
    {
        if (ConstructingUnit != null)
        {
            ConstructionTimeLeft -= Time.deltaTime;

            if (ConstructionTimeLeft <= 0f)
            {
                ConstructingUnit.gameObject.SetActive(true);
                ConstructingUnit = null;

                GetComponent <SpriteRenderer>().sprite = CompletedSprite;
            }
        }

        if (QueueTimeLeft > 0)
        {
            QueueTimeLeft -= Time.fixedDeltaTime;
        }
        else if (CurrentQueuedItem != QueueType.None)
        {
            var coords   = CordUtil.WorldToTile(transform.position);
            var freespot = _map.FindNextFreeTile(coords.First, coords.Second);
            _unitfactory.Create(QueuedUnit, PlayerOwner, freespot.First, freespot.Second - 2);
            CurrentQueuedItem = QueueType.None;
        }

        if (HP <= 0)
        {
            //Building dies
            Destroy(gameObject);
        }
    }
        /// <summary>
        /// Sets the current playlist.
        /// Depending on the QueueType, we will either let the current song that is playing finish, or just immediately start playing our first song in the new playlist
        /// </summary>
        /// <param name="songs"></param>
        /// <param name="queueType"></param>
        public static void SetPlaylist(List <string> songs, QueueType queueType = QueueType.WaitForCurrent)
        {
            // If we are not adding any songs, don't bother doing the rest of this function
            if (songs == null || songs.Count == 0)
            {
                return;
            }

            // If the song we are currently playing is being added again by the new playlist, move it to the back
            // This means we will have to listen to all the others before we hear it again
            if (CurrentPlaylist.Count > 0 && CurrentSong != null)
            {
                string currentSongName = CurrentSong.Name;
                if (songs.Contains(currentSongName))
                {
                    songs.Remove(currentSongName);
                    songs.Add(currentSongName);
                }
            }

            // Resets the current song index so we play from the start of the new playlist
            CurrentPlaylist  = songs;
            CurrentSongIndex = 0;

            // If we have specified we wish to play immediately we skip the remainder of the current song and play the next one
            if (queueType == QueueType.PlayImmediately)
            {
                PlayNextSong();
            }
        }
Example #20
0
 public virtual void AddMusic(QueueType queueType = QueueType.PlayImmediately)
 {
     if (BaseScreenData != null)
     {
         MusicManager.QueueSongs(BaseScreenData.BackgroundMusicNames, queueType);
     }
 }
Example #21
0
        public async Task <string> DequeueWork(QueueType queue, CancellationToken cancellationToken)
        {
            if (_connection == null)
            {
                throw new InvalidOperationException("ActiveMQ provider not running");
            }

            var destination = GetDestination(queue);

            if (destination == null)
            {
                throw new InvalidOperationException("Invalid destination");
            }

            string result = null;

            using (var consumer = _session.CreateConsumer(destination))
            {
                var message = consumer.ReceiveNoWait();
                if (message != null)
                {
                    var txtMsg = message as ITextMessage;
                    if (txtMsg != null)
                    {
                        result = txtMsg.Text;
                    }
                    message.Acknowledge();
                }
            }
            return(result);
        }
Example #22
0
        private double[] Drain(QueueType type)
        {
            double[] item = null;

            switch (type)
            {
            case QueueType.ADC:
                lock (gyroQueue)
                {
                    if (gyroQueue.Count > 0)
                    {
                        item = gyroQueue.Dequeue();
                    }
                }
                break;

            case QueueType.Gyro:
                lock (adcQueue)
                {
                    if (adcQueue.Count > 0)
                    {
                        item = adcQueue.Dequeue();
                    }
                }
                break;
            }

            return(item);
        }
        /// <summary>
        /// Sends a prepared message
        /// </summary>
        /// <param name="logger"></param>
        /// <param name="message">The prepared message</param>
        /// <param name="queueType">The type of queue to use</param>
        /// <param name="userId"></param>
        /// <param name="xml">Optional xml content. This will be logged depending on the logging level.</param>
        /// <returns></returns>
        private async Task Send(ILogger logger, IMessagingMessage message, QueueType queueType, string userId = "99999999999", XDocument xml = null)
        {
            if (message == null)
            {
                throw new ArgumentNullException(nameof(message));
            }

            logger.LogStartSend(queueType, message.MessageFunction, message.FromHerId, message.ToHerId, message.MessageId, userId, xml);
            IMessagingSender messageSender = null;

            try
            {
                messageSender = SenderPool.CreateCachedMessageSender(logger, message.To);
                await messageSender.SendAsync(message).ConfigureAwait(false);
            }
            catch (Exception ex)
            {
                throw new MessagingException(ex.Message)
                      {
                          EventId = EventIds.Send
                      };
            }
            finally
            {
                if (messageSender != null)
                {
                    SenderPool.ReleaseCachedMessageSender(logger, message.To);
                }
            }

            logger.LogEndSend(queueType, message.MessageFunction, message.FromHerId, message.ToHerId, message.MessageId, userId);
        }
Example #24
0
 public DirectRoutingTopology(bool durable, QueueType queueType, Func <Type, string> routingKeyConvention = null, Func <string> exchangeNameConvention = null)
 {
     this.durable                = durable;
     this.queueType              = queueType;
     this.routingKeyConvention   = routingKeyConvention ?? DefaultRoutingKeyConvention.GenerateRoutingKey;
     this.exchangeNameConvention = exchangeNameConvention ?? (() => amqpTopicExchange);
 }
        public User createUser(string[] s, QueueType type)
        {
            int    id        = -1;
            string tableName = (type == QueueType.Banking) ? "[BankingQueue]" : "[NormalQueue]";


            SqlCommand cmd = new SqlCommand();

            cmd.CommandType = System.Data.CommandType.Text;
            cmd.CommandText = QueueInsertString(s[0], s[1], s[2], s[3], s[4], tableName);//"INSERT INTO [User](Email, Firstname, LastName, Hash) OUTPUT INSERTED.ID VALUES('*****@*****.**' ,'fname','lname', 'hash')";
            cmd.Connection  = this.con.getSQLConnection();

            try
            {
                con.getSQLConnection().Open();
                id = (Int32)cmd.ExecuteScalar();
            }
            catch (Exception e)
            {
                Console.Write(e.ToString());
            }
            finally
            {
                con.getSQLConnection().Close();
            }


            return(getUser(id));
        }
 public PriorityQueue(QueueType type = QueueType.Min, IComparer <T> comparer = null)
 {
     comparer = comparer ?? Comparer <T> .Default;
     set      = new SortedSet <PQItem>(Comparer <PQItem> .Create((x, y) =>
                                                                 comparer.Compare(x.Value, y.Value) == 0 ? x.Index - y.Index : comparer.Compare(x.Value, y.Value)));
     this.type = type;
 }
Example #27
0
        public async Task <string> DequeueWork(QueueType queue, CancellationToken cancellationToken)
        {
            if (_connection == null)
            {
                throw new InvalidOperationException("RabbitMQ provider not running");
            }

            using (var channel = _connection.CreateModel())
            {
                channel.QueueDeclare(queue: GetQueueName(queue),
                                     durable: true,
                                     exclusive: false,
                                     autoDelete: false,
                                     arguments: null);

                channel.BasicQos(prefetchSize: 0, prefetchCount: 1, global: false);

                var msg = channel.BasicGet(GetQueueName(queue), false);
                if (msg != null)
                {
                    var data = Encoding.UTF8.GetString(msg.Body);
                    channel.BasicAck(msg.DeliveryTag, false);
                    return(data);
                }
                return(null);
            }
        }
Example #28
0
        public void SendClientQueueSuccess(PlayerConnect _this, QueueType type, ulong characterId)
        {
            var data = new QueueSuccessData();

            data.Type = (int)type;
            switch (type)
            {
            case QueueType.Login:
            {
                LoginServerControlDefaultImpl.NotifyGateClientState(LoginServer.Instance.ServerControl,
                                                                    _this.ClientId, 0, GateClientState.Login);
                data.LastServerId = _this.Player.DbData.LastServerId;

                _this.Player.DbData.LoginDay++;
                _this.Player.DbData.LoginTotal++;
            }
            break;

            case QueueType.EnterGame:
                data.CharacterId = characterId;
                break;
            }

            PlayerLog.WriteLog((int)LogType.SendClientQueueSuccess, "SendClientQueueSuccess type = {0}, name = {1}",
                               type, _this.Name);
            LoginServer.Instance.ServerControl.NotifyQueueSuccess(_this.ClientId, data);
        }
Example #29
0
        public ICollection <UserReference> GetReportCreators(QueueType queueType)
        {
            var reports = GetReportsByQueueType(queueType);

            var ids = reports.Select(r => r.CreatedBy).Distinct().ToList();

            var creators =
                _administrationUnitOfWork.GetEntityQuery <User>(TrackingMode.Manual)
                .Where(x => ids.Contains(x.Id)).ToList();     // user by the unique creator id

            ICollection <UserReference> userReferences = new Collection <UserReference>();

            foreach (var user in creators)
            {
                userReferences.Add(new UserReference
                {
                    UserId   = user.Id,
                    Username =
                        String.IsNullOrWhiteSpace(user.FirstName)
                            ? user.LastName
                            : String.Concat(user.LastName, ", ", user.FirstName)
                });

                return(userReferences);
            }

            return(creators.Select(user => new UserReference
            {
                UserId = user.Id,
                Username = String.IsNullOrWhiteSpace(user.FirstName) ? user.LastName : String.Concat(user.LastName, ", ", user.FirstName)
            }).ToList());
        }
Example #30
0
        public int GetSummaryQueueCount(QueueType queueType, QueueQuery queueQuery)
        {
            switch (queueType)
            {
            case QueueType.Incident:
                return(IncidentSummaries(queueQuery).Count());

            case QueueType.Arrest:
                return(ArrestSummaries(queueQuery).Count());

            case QueueType.FieldInterview:
                return(FieldInterviewSummaries(queueQuery).Count());

            case QueueType.Case:
                return(CaseSummmaries(queueQuery).Count());

            case QueueType.OtherEvent:
                return(OtherEventSummaries(queueQuery).Count());

            case QueueType.Citation:
                return(CitationSummaries(queueQuery).Count());

            case QueueType.CallForService:
                return(CallForServiceSummaries(queueQuery).Count());
            }
            return(0);
        }
Example #31
0
 public Queue(QueueType qType)
 {
     QueueType = ((char)qType).ToString();
     Status    = (int)QueueStatus.Waiting;
     CreatedAt = DateTime.Now;
     UpdatedAt = CreatedAt;
 }
Example #32
0
        protected Guid ScheduleExportTableJob(string schemaName, string tableName, string path, QueueType queueType)
        {
            var queue = String.Format("Graywulf.Controller.Controller.{0}", queueType.ToString());

            using (var context = ContextManager.Instance.CreateContext(ConnectionMode.AutoOpen, TransactionMode.AutoCommit))
            {
                var user = SignInTestUser(context);

                var ef = new EntityFactory(context);
                var f = ef.LoadEntity<Federation>(Federation.AppSettings.FederationName);

                var format = new FileFormatFactory().GetFileFormatDescription("Jhu.Graywulf.Format.CsvFile");

                var source = new Jhu.Graywulf.Schema.Table()
                {
                    Dataset = user.GetUserDatabaseInstance(f.MyDBDatabaseVersion).GetDataset(),  // TODO: fix this
                    SchemaName = schemaName,
                    TableName = tableName
                };

                var etf = new ExportTableFactory(context);
                var ji = etf.ScheduleAsJob(
                    source,
                    path,
                    format,
                    queue,
                    "");

                ji.Save();

                return ji.Guid;
            }
        }
Example #33
0
 public ReaderQueue(QueueType pType, string pQueueName, bool pShared)
 {
     QueueName = pQueueName;
     QueueType = pType;
     Shared    = pShared;
     StartListening(QueueName);
 }
Example #34
0
 public MessageQueue[] InitializeQueue(Endpoint queueEndpoint, QueueType queueType)
 {
     var path = MsmqUtil.GetQueuePath(queueEndpoint);
     return new[]
     {
         path.Create()
     };
 }
Example #35
0
 public void insert(QueueType item)
 {
     items.Insert(0, item);
     if (items.Count() > len)
     {
         items.RemoveAt(items.Count() - 1);
     }
 }
Example #36
0
        public static void QueueSong(string songName, QueueType queueType = QueueType.WaitForCurrent)
        {
            QueueSongNames.Enqueue(songName);

            if (queueType == QueueType.PlayImmediately)
            {
                PlayNextSong();
            }
        }
Example #37
0
        public Message CreateMeesage(QueueType qType)
        {
            Message theMessage = new Message(messageBody);
            theMessage.Formatter = new System.Messaging.XmlMessageFormatter(new string[] { "System.String" });

            theMessage.Label = ((int)qType).ToString() + "|" + Guid.NewGuid();

            return theMessage;
        }
 protected void CreateQueues(QueueType mainQueueType, Endpoint mainQueueEndpoint, string user)
 {
     // will create the queues if they are not already there
     var queues = queueStrategy.InitializeQueue(mainQueueEndpoint, mainQueueType);
     foreach (var queue in queues)
     {
         GrantPermissions(queue, user);
     }
 }
Example #39
0
 public static void Prepare(string queueName, QueueType queueType)
 {
     var queueUri = new Uri(queueName);
     var queuePath = MsmqUtil.GetQueuePath(new Endpoint {
                                                        	Uri = queueUri
                                                        });
     CreateQueueIfNotExists(queuePath.QueuePath);
     //PurgeQueue(queuePath.QueuePath);
     //PurgeSubqueues(queuePath.QueuePath, queueType);
 }
Example #40
0
 public Queue(int type, double size, double pages = 0)
 {
     _Type = (QueueType) type;
     _MaxSize = size;
     _PageSizes = new Collection<double>();
     _PageSizes.Add(pages);
     _ProcessList = new Collection<Process>();
     _Log = new Collection<string>();
     _MemoryList = new Collection<Memory>();
 }
        private void SetupMessageReadPropertyFilters(MessageQueue q, QueueType type)
        {

            q.MessageReadPropertyFilter.Id = true;
            q.MessageReadPropertyFilter.ArrivedTime = true;
            q.MessageReadPropertyFilter.Label = true;
            q.MessageReadPropertyFilter.Body = false;

            //if( type == QueueType.Error )
            q.MessageReadPropertyFilter.Extension = true;
        }
Example #42
0
        public Queue(string name, QueueType type, int color = 0)
        {
            Name = name;
              Type = type;

              DisplayName = name.CutBeginning(46);

              Color = color;

              ColorString = "#" + color.ToString("X");
              SelectedColorString = "#" + GetSelectedColor(color).ToString("X");
        }
Example #43
0
 public static string GetQueueName(QueueType qType)
 {
     switch (qType)
     {
         case QueueType.Booking:
             return "Booking";
         case QueueType.Scheduling:
             return "Scheduling";
         default:
             return "default";
     }
 }
Example #44
0
    public Queue(string name, QueueType type, int color = 0, MessageContentFormat contentFormat = MessageContentFormat.Unknown) {
    
      Name = name;
      Type = type;

      DisplayName = name.CutBeginning(46);

      Color = color;

      ContentFormat = contentFormat;
      
      ColorString = "#" + color.ToString("X");
      SelectedColorString = "#" + GetSelectedColor(color).ToString("X");
    }
Example #45
0
        public TargetAction(int sequence, int frame, IPlayer player, 
            IMapPosition mapPosition, int objectId, 
            ObjectType objectType, OrderType orderType, 
            QueueType queueType)
            : base(sequence, frame, player)
        {
            this.MapPosition = mapPosition;
            this.ObjectIdentifier = objectId;
            this.ObjectType = objectType;
            this.OrderType = orderType;
            this.QueueType = queueType;

            ActionType = ActionType.Target;
        }
Example #46
0
        public static void QueueSongs(List<string> songs, QueueType queueType = QueueType.WaitForCurrent)
        {
            // If we are not adding any songs, don't bother doing the rest of this function
            if (songs.Count == 0)
                return;

            foreach (string song in songs)
            {
                QueueSongNames.Enqueue(song);
            }

            if (queueType == QueueType.PlayImmediately)
            {
                PlayNextSong();
            }
        }
        public static void Prepare(string queueName, QueueType queueType)
        {
            _logger.InfoFormat("Prepairing queue {0}...", queueName);

            var queueUri = new Uri(queueName);
            var endpoint = new Endpoint {Uri = queueUri};

            QueueInfo queuePath = MsmqUtil.GetQueuePath(endpoint);
            EnsureQueueExists(queuePath.QueuePath);

            /*NOTE:
            If a queue is created this way by a windows service it wont yield the correct permissions
            for other accounts i.e admin, developer to access this queue.*/
            //            CreateQueueIfNotExists(queuePath.QueuePath);
            //            PurgeQueue(queuePath.QueuePath);
            //            PurgeSubqueues(queuePath.QueuePath, queueType);
        }
Example #48
0
 private static void PurgeSubqueues(string queuePath, QueueType queueType)
 {
     switch (queueType) {
         case QueueType.Standard:
             PurgeSubqueue(queuePath, "errors");
             PurgeSubqueue(queuePath, "discarded");
             PurgeSubqueue(queuePath, "timeout");
             PurgeSubqueue(queuePath, "subscriptions");
             break;
         case QueueType.LoadBalancer:
             PurgeSubqueue(queuePath, "endpoints");
             PurgeSubqueue(queuePath, "workers");
             break;
         default:
             throw new ArgumentOutOfRangeException("queueType", "Can't handle queue type: " + queueType);
     }
 }
Example #49
0
        protected Guid ScheduleQueryJob(string query, QueueType queueType)
        {
            var queue = String.Format("QueueInstance:Graywulf.Controller.Controller.{0}", queueType.ToString());

            using (var context = ContextManager.Instance.CreateContext(ConnectionMode.AutoOpen, TransactionMode.AutoCommit))
            {
                SignInTestUser(context);

                var f = new SqlQueryFactory(context);

                var q = f.CreateQuery(query);
                var ji = f.ScheduleAsJob(q, queue, "testjob");

                ji.Save();

                return ji.Guid;
            }
        }
Example #50
0
        protected Guid ScheduleMirroDatabaseJob(QueueType queueType)
        {
            var queue = String.Format("Graywulf.Controller.Controller.{0}", queueType.ToString());

            using (var context = ContextManager.Instance.CreateContext(ConnectionMode.AutoOpen, TransactionMode.AutoCommit))
            {
                SignInTestUser(context);

                var ef = new EntityFactory(context);
                var jd = ef.LoadEntity<JobDefinition>(Cluster.AppSettings.ClusterName, typeof(MirrorDatabaseJob).Name);

                var ji = jd.CreateJobInstance(queue, ScheduleType.Queued);

                ji.Parameters["DatabaseVersionName"].SetValue("Graywulf.VOServices.SkyQuery.Galex.STAT");

                ji.Save();

                return ji.Guid;
            }
        }
Example #51
0
        protected Guid ScheduleExportTableJob(string schemaName, string tableName, string path, QueueType queueType)
        {
            var queue = String.Format("QueueInstance:Graywulf.Controller.Controller.{0}", queueType.ToString());

            using (var context = ContextManager.Instance.CreateContext(ConnectionMode.AutoOpen, TransactionMode.AutoCommit))
            {
                var user = SignInTestUser(context);

                var ef = new EntityFactory(context);
                var federation = ef.LoadEntity<Federation>(Registry.AppSettings.FederationName);
                var format = FileFormatFactory.Create(federation.FileFormatFactory).GetFileFormatDescription(typeof(Jhu.Graywulf.Format.DelimitedTextDataFile).FullName);

                var mydbds = federation.MyDBDatabaseVersion.GetUserDatabaseInstance(user).GetDataset();

                var source = new Jhu.Graywulf.Schema.Table()
                {
                    Dataset = mydbds,  // TODO: fix this
                    DatabaseName = mydbds.DatabaseName,
                    SchemaName = schemaName,
                    TableName = tableName
                };

                var etf = new ExportTablesFactory(context);
                var ji = etf.ScheduleAsJob(
                    federation,
                    new TableOrView[] {source },
                    path,
                    format,
                    queue,
                    "");

                ji.Save();

                return ji.Guid;
            }
        }
        private void MonitorStateChanged(QueueType type, bool value)
        {
            _monitorState.MonitorQueueType[(int)type] = value;

              if( !value ) {
            lock( _itemsLock ) {
              foreach( var itm in _items.Where(i => i.Queue.Type == type).ToArray() )
            _items.Remove(itm);
            }
              }
        }
 public uint GetUnprocessedItemsCount(QueueType qt)
 {
     return _unprocessedItemsCount[(int)qt];
 }
 private void ChangedMonitorFlag(QueueType type, bool newState)
 {
     switch( type ) {
     case QueueType.Command: _sys.MonitorCommands = newState; break;
     case QueueType.Event: _sys.MonitorEvents = newState; break;
     case QueueType.Message: _sys.MonitorMessages = newState; break;
     case QueueType.Error: _sys.MonitorErrors = newState; break;
       }
 }
 public bool IsMonitoringQueueType(QueueType type)
 {
     return MonitorQueueType[(int)type];
 }
Example #56
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="queue"></param>
        /// <param name="tag"></param>
        /// <param name="query"></param>
        public void RequestQueueFiles(QueueType queue, MetaTag tag, string query)
        {
            string filter = String.Empty;
            List<string> trackList = new List<string>();
            bool loop = true;
            switch (tag)
            {
                case MetaTag.artist:
                    filter = XmlFilter(new[] {"ArtistPeople"}, query, true);
                    break;
                case MetaTag.album:
                    filter = XmlFilter(new[] {"Album"}, query, true);
                    break;
                case MetaTag.genre:
                    filter = XmlFilter(new[] {"Genre"}, query, true);
                    break;
                case MetaTag.title:
                    trackList.Add(System.Text.Encoding.UTF8.GetString(Convert.FromBase64String(query)));
                    loop = false;
                    break;
                case MetaTag.none:
                    return;
                default:
                    return;
            }

            if (trackList.Count == 0)
            {
                mbApiInterface.Library_QueryFiles(filter);
                while (loop)
                {
                    string current = mbApiInterface.Library_QueryGetNextFile();
                    if (String.IsNullOrEmpty(current)) break;
                    trackList.Add(current);
                }
            }

            if (queue == QueueType.Next)
            {
                mbApiInterface.NowPlayingList_QueueFilesNext(trackList.ToArray());
            }
            else if (queue == QueueType.Last)
            {
                mbApiInterface.NowPlayingList_QueueFilesLast(trackList.ToArray());
            }
            else if (queue == QueueType.PlayNow)
            {
                mbApiInterface.NowPlayingList_Clear();
                mbApiInterface.NowPlayingList_QueueFilesLast(trackList.ToArray());
                mbApiInterface.NowPlayingList_PlayNow(trackList[0]);
            }
        }
        private string GetQueueStatusString()
        {
            QueueType[] itemTypes = null;
              if( _sys != null )
            itemTypes = _sys.Items.Select(i => i.Queue.Type).ToArray();
              else itemTypes = new QueueType[0];

              return string.Format(" Commands: {0} \r\n Events: {1} \r\n Messages: {2} \r\n Errors: {3} ",
                  itemTypes.Count(i => i == QueueType.Command),
                  itemTypes.Count(i => i == QueueType.Event),
                  itemTypes.Count(i => i == QueueType.Message),
                  itemTypes.Count(i => i == QueueType.Error)
                  );
        }
        public QueueFetchResult GetProcessedMessages(QueueType type, DateTime since, IEnumerable<QueueItem> currentItems)
        {
            var result = new QueueFetchResult();

            var queues = GetQueueListByType(type);

            if (queues.Count() == 0)
            {
                result.Items = new List<QueueItem>();
                return result;
            }

            List<QueueItem> r = new List<QueueItem>();
            result.Items = r;

            foreach (var q in queues)
            {
                string qName = q.GetDisplayName();

                if (IsIgnoredQueue(qName) || !q.CanReadJournalQueue)
                    continue;

                SetupMessageReadPropertyFilters(q.Journal, type);

                try
                {
                    List<Message> messages = new List<Message>();

                    // Enumete from the earliest item
                    MessageEnumerator msgs = q.Journal.GetMessageEnumerator2();
                    try
                    {
                        while (msgs.MoveNext())
                        {
                            Message msg = msgs.Current;

                            if (msg.ArrivedTime >= since)
                                messages.Add(msg);
                        }
                    }
                    finally
                    {
                        msgs.Close();
                    }

                    foreach (var msg in messages)
                    {
                        QueueItem itm = currentItems.FirstOrDefault(i => i.Id == msg.Id);

                        if (itm == null)
                        {
                            itm = CreateQueueItem(q.Queue, msg);
                            itm.Processed = true;

                            if (!PrepareQueueItemForAdd(itm))
                                itm = null;
                        }

                        if (itm != null)
                            r.Insert(0, itm);
                    }
                }
                catch (Exception e)
                {
                    OnError("Error occured when getting processed messages from queue \"" + qName + "\", " + e.Message, e, false);
                }
            }

            result.Count = (uint)r.Count;

            return result;
        }
 protected IEnumerable<MsmqMessageQueue> GetQueueListByType(QueueType type)
 {
     return _monitorMsmqQueues.Where(q => q.Queue.Type == type);
 }
 public abstract IEnumerable<QueueItem> GetUnprocessedMessages(QueueType type, IEnumerable<QueueItem> currentItems);