Example #1
0
 public QueueService(
     IQueueQuery queueQueryHelper,
     IQueueCommand queueCommandHelper,
     IQueueLocker queueLocker,
     IGetQueueMessagesQuery queueMessages,
     IQueueMessageRecorder historyRecorder,
     IGetAiringQuery airingQueryHelper,
     IAiringMessagePusherQueueApi messagePusher,
     IQueueSaveCommand queueSaveCommand,
     CurrentAiringsQuery currentAiringQuery,
     IHangfireRecurringJobCommand hangfireCommand,
     IRemoteQueueHandler remoteQueueHandler,
     IQueueDeleteCommand queueDeleteCommand)
 {
     this.queueQueryHelper   = queueQueryHelper;
     this.queueCommandHelper = queueCommandHelper;
     this.queueLocker        = queueLocker;
     this.queueMessages      = queueMessages;
     this.historyRecorder    = historyRecorder;
     this.airingQueryHelper  = airingQueryHelper;
     this.messagePusher      = messagePusher;
     this.queueSaveCommand   = queueSaveCommand;
     this.currentAiringQuery = currentAiringQuery;
     this.hangfireCommand    = hangfireCommand;
     this.remoteQueueHandler = remoteQueueHandler;
     this.queueDeleteCommand = queueDeleteCommand;
 }
Example #2
0
        protected void addQueueCommandInt(IQueueCommand pCmd)
        {
            LOG.INFO("addCommand: " + pCmd.toString());

            lock (m_mxStackCommands)
            {
                boolean bExist = false;
                if (isSkipDuplicateCmd())
                {
                    for (int i = 0; i < (int)m_stackCommands.size(); i++)
                    {
                        if (m_stackCommands.get(i).equals(pCmd))
                        {
                            LOG.INFO("Command already exists in queue. Skip it.");
                            bExist = true;
                            break;
                        }
                    }
                }

                if (!bExist)
                {
                    m_stackCommands.add(pCmd);
                }
            }
        }
Example #3
0
        public IQueueCommand selectMethod(string msgData)
        {
            IQueueCommand method = null;

            Type[] typeList = getTypesInNamespace(Assembly.GetExecutingAssembly(), m_asseblyName);

            foreach (Type currType in typeList)
            {
                if (currType.IsInterface)
                {
                    continue;
                }

                method = (IQueueCommand)Activator.CreateInstance(currType);
                method = (IQueueCommand)JsonConvert.DeserializeObject(msgData, currType);

                if (!method.isNull)
                {
                    break;
                }

                method = null;
            }

            if (method == null)
            {
                method = (IQueueCommand)JsonConvert.DeserializeObject <DefaultMethodClass>(msgData);
            }

            return(method);
        }
Example #4
0
 		    public boolean equals(IQueueCommand obj)
 		    {
 			    SyncCommand oSyncCmd = (SyncCommand)obj;
 			    return m_nCmdCode == oSyncCmd.m_nCmdCode && m_nCmdParam == oSyncCmd.m_nCmdParam &&
 				    (m_strCmdParam == oSyncCmd.m_strCmdParam ||
 				    (m_strCmdParam != null && oSyncCmd.m_strCmdParam != null && m_strCmdParam.equals(oSyncCmd.m_strCmdParam)));  		
 		    }
Example #5
0
            public boolean equals(IQueueCommand obj)
            {
                SyncCommand oSyncCmd = (SyncCommand)obj;

                return(m_nCmdCode == oSyncCmd.m_nCmdCode && m_nCmdParam == oSyncCmd.m_nCmdParam &&
                       (m_strCmdParam == oSyncCmd.m_strCmdParam ||
                        (m_strCmdParam != null && oSyncCmd.m_strCmdParam != null && m_strCmdParam.equals(oSyncCmd.m_strCmdParam))));
            }
Example #6
0
        public void addQueueCommand(IQueueCommand pCmd)
        { 
            addQueueCommandInt(pCmd);

            if ( isNoThreadedMode()  )
                processCommands();
            else if ( isAlive() )
    	        stopWait(); 
        }
Example #7
0
        private void Config()
        {
            FilterGraph fg = new FilterGraph();

            m_qc = fg as IQueueCommand;
            m_mc = (IMediaControl)fg;

            int hr = ((IGraphBuilder)fg).RenderFile(@"foo.avi", null);
        }
 public ModifiedTitleService(IQueueCommand resetDeliveryCommand,
                             ITitleIdsQuery titlIdsQuery,
                             ITitleIdsCommand titleIDsCommand, AppSettings _appSettings)
 {
     _resetDeliveryCommand = resetDeliveryCommand;
     _titlIdsQuery         = titlIdsQuery;
     _titleIDsCommand      = titleIDsCommand;
     this.appSettings      = _appSettings;
     _client = new RestClient(appSettings.GetExternalService("Flow").Url);
 }
Example #9
0
        public void addQueueCommand(IQueueCommand pCmd)
        {
            addQueueCommandInt(pCmd);

            if (isNoThreadedMode())
            {
                processCommands();
            }
            else if (isAlive())
            {
                stopWait();
            }
        }
Example #10
0
        void processCommands()//throws Exception
        {
            while (!isStopping() && !isNoCommands())
            {
                IQueueCommand pCmd = null;
                lock (m_mxStackCommands)
                {
                    pCmd = (IQueueCommand)m_stackCommands.removeFirst();
                }

                processCommandBase(pCmd);
            }
        }
Example #11
0
        protected void processCommandBase(IQueueCommand pCmd)
        {
            lock (m_mxStackCommands)
            {
                m_pCurCmd = pCmd;
            }

            processCommand(pCmd);

            lock (m_mxStackCommands)
            {
                m_pCurCmd = null;
            }
        }
Example #12
0
        public override void processCommand(IQueueCommand pCmd)
        {
            SyncCommand oSyncCmd = (SyncCommand)pCmd;

            switch (oSyncCmd.m_nCmdCode)
            {
            case scSyncAll:
                checkShowStatus(oSyncCmd);
                m_oSyncEngine.doSyncAllSources();
                break;

            case scSyncOne:
            {
                checkShowStatus(oSyncCmd);
                m_oSyncEngine.doSyncSource(new SyncEngine.SourceID(oSyncCmd.m_nCmdParam, oSyncCmd.m_strCmdParam));
            }
            break;

            case scSearchOne:
            {
                checkShowStatus(oSyncCmd);
                m_oSyncEngine.doSearch(((SyncSearchCommand)oSyncCmd).m_arSources, oSyncCmd.m_strCmdParam,
                                       ((SyncSearchCommand)oSyncCmd).m_strFrom, ((SyncSearchCommand)oSyncCmd).m_bSyncChanges,
                                       oSyncCmd.m_nCmdParam);
            }
            break;

            case scLogin:
            {
                SyncLoginCommand oLoginCmd = (SyncLoginCommand)oSyncCmd;
                checkShowStatus(oSyncCmd);
                m_oSyncEngine.login(oLoginCmd.m_strName, oLoginCmd.m_strPassword, oLoginCmd.m_pNotify);
            }
            break;
            }
        }
        public void BasicPublish(string exchangeName, IQueueCommand command, string routingKey = "", bool isDoChannelClose = true)
        {
            try
            {
                var basicProperties = this.Channel.CreateBasicProperties();
                basicProperties.Headers = new Dictionary <string, object>
                {
                    { commandTypeName, command.GetType().AssemblyQualifiedName },
                    { "host", Environment.MachineName }
                };

                var message = JsonConvert.SerializeObject(command);
                var body    = Encoding.UTF8.GetBytes(message);

                var address = new PublicationAddress(ExchangeType.Fanout, exchangeName, routingKey);

                Retry.Do(() =>
                {
                    this.Channel.BasicPublish(address, basicProperties, body);
                }, TimeSpan.FromSeconds(1));
            }
            catch (Exception e)
            {
                //var erroMsg = "Rabbitmq Message published failed.";
                //this.logger.Error(e, erroMsg);
                //this.slackSimpleClient.PostException(SlackSetting.ERROR_EXCEPTION_WEB_HOOK, e, erroMsg);
                Console.WriteLine(e);
            }

            //this.logger.Info($"Publish to {exchangeName}");

            if (isDoChannelClose)
            {
                CloseChannel();
            }
        }
Example #14
0
        protected void addQueueCommandInt(IQueueCommand pCmd)
        {
            LOG.INFO("addCommand: " + pCmd.toString());

            lock(m_mxStackCommands)
            {
	    	    boolean bExist = false;
	            if ( isSkipDuplicateCmd() )
	            {
	    	        for ( int i = 0; i < (int)m_stackCommands.size(); i++ )
	    	        {
	    	    	    if ( m_stackCommands.get(i).equals(pCmd) )
	    		        {
	                        LOG.INFO("Command already exists in queue. Skip it.");
	    			        bExist = true;
	    			        break;
	    		        }
	    	        }
	            }
	
	    	    if ( !bExist )
	    		    m_stackCommands.add(pCmd);
            }
        }
Example #15
0
 public override void processCommand(IQueueCommand pCmd)
 {
     ((HttpCommand)pCmd).execute();
 }
Example #16
0
	    public override void processCommand(IQueueCommand pCmd)
	    {
		    SyncCommand oSyncCmd = (SyncCommand)pCmd;
	        switch(oSyncCmd.m_nCmdCode)
	        {
	        case scSyncAll:
	    	    checkShowStatus(oSyncCmd);
	            m_oSyncEngine.doSyncAllSources();
	            break;
            case scSyncOne:
	            {
				    checkShowStatus(oSyncCmd);
	                m_oSyncEngine.doSyncSource(new SyncEngine.SourceID(oSyncCmd.m_nCmdParam,oSyncCmd.m_strCmdParam));
	            }
	            break;
	        
	        case scSearchOne:
		        {
				    checkShowStatus(oSyncCmd);
	                m_oSyncEngine.doSearch( ((SyncSearchCommand)oSyncCmd).m_arSources, oSyncCmd.m_strCmdParam, 
	                        ((SyncSearchCommand)oSyncCmd).m_strFrom, ((SyncSearchCommand)oSyncCmd).m_bSyncChanges,
	                        oSyncCmd.m_nCmdParam);
		        }
	            break;
	        
	        case scLogin:
	    	    {
	    		    SyncLoginCommand oLoginCmd = (SyncLoginCommand)oSyncCmd;
	    		    checkShowStatus(oSyncCmd);
	    		    m_oSyncEngine.login(oLoginCmd.m_strName, oLoginCmd.m_strPassword, oLoginCmd.m_pNotify );
	    	    }
	            break;
	        
	        }
	    }
Example #17
0
        public MutableString addHttpCommand(IQueueCommand pCmd)
        {
            if (((HttpCommand)pCmd).m_strCallback.length() == 0)
            {
                processCommandBase(pCmd);
                return ((HttpCommand)pCmd).getRetValue();
            }
            else
            {
                addQueueCommand(pCmd);
                start(epLow);

                return ((HttpCommand)pCmd).getRetValue();
            }
        }
Example #18
0
 public abstract void processCommand(IQueueCommand pCmd);
Example #19
0
        protected void processCommandBase(IQueueCommand pCmd)
        {
            lock(m_mxStackCommands)
            {
                m_pCurCmd = pCmd;
            }

            processCommand(pCmd);

            lock(m_mxStackCommands)
            {
                m_pCurCmd = null;
            }
        }
Example #20
0
 public override void processCommand(IQueueCommand pCmd)
 {
     (pCmd as CServerCommand).execute();
 }
 public EtlEnqueueHandler(ICensusFileCommand censusFileCommand,
                          IQueueCommand queueCommand)
 {
     this.censusFileCommand = censusFileCommand;
     this.queueCommand      = queueCommand;
 }
Example #22
0
 public override void processCommand(IQueueCommand pCmd)
 {
     ((HttpCommand)pCmd).execute();
 }
Example #23
0
 public boolean equals(IQueueCommand cmd)
 {
     return(false);
 }
Example #24
0
 public override void processCommand(IQueueCommand pCmd)
 {
     (pCmd as CServerCommand).execute();
 }
Example #25
0
 public abstract void processCommand(IQueueCommand pCmd);
Example #26
0
	    public boolean equals(IQueueCommand cmd){ return false; }