Ejemplo n.º 1
0
        public QueueModel.Queue Save(QueueModel.Queue queue)
        {
            var collection = _database.GetCollection <QueueModel.Queue>("DeliveryQueue");

            collection.Save(queue);
            return(queue);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Save's the queue
        /// </summary>
        /// <param name="queue">queue model to save</param>
        /// <returns>Returns saved queue</returns>
        public Model.Queue SaveQueue(Model.Queue queue)
        {
            DefaultQueueKeyFields(queue);

            DLModel.Queue dataModel = queue.ToDataModel <Model.Queue, DLModel.Queue>();

            var prioritySelectionChanged     = false;
            var versionSelectionChanged      = false;
            var prohibitResendMediaIdChanged = false;

            if (!string.IsNullOrEmpty(dataModel.Name))
            {
                var existingQueueSettings = queueQueryHelper.GetByApiKey(dataModel.Name);

                if (existingQueueSettings != null)
                {
                    prioritySelectionChanged     = existingQueueSettings.IsPriorityQueue != dataModel.IsPriorityQueue;
                    versionSelectionChanged      = !existingQueueSettings.AllowAiringsWithNoVersion && dataModel.AllowAiringsWithNoVersion;
                    prohibitResendMediaIdChanged = existingQueueSettings.IsProhibitResendMediaId &&
                                                   !dataModel.IsProhibitResendMediaId;
                }
            }

            dataModel = queueSaveCommand.Save(dataModel);

            remoteQueueHandler.Create(queue, prioritySelectionChanged);

            if (dataModel.Active)
            {
                hangfireCommand.CreatePublisherJob(dataModel.Name);
            }
            else
            {
                hangfireCommand.DeletePublisherJob(dataModel.Name);
            }

            if (versionSelectionChanged || prohibitResendMediaIdChanged)
            {
                currentAiringQuery.DeleteIgnoredQueue(dataModel.Name);
            }

            return(dataModel.ToBusinessModel <DLModel.Queue, Model.Queue>());
        }