Esempio n. 1
0
 private void OnDocumentSaved(object sender, DocumentEventArgs e)
 {
     _msmqSender.Send(new FileInfoMessage
     {
         FilePath = e.FilePath
     });
 }
Esempio n. 2
0
        private void InitializeCentralQueueSender(string currentQueuePath)
        {
            var centralQueueName    = _settingsProvider.GetCentralMessageQueueName();
            var centralQueueMachine = _settingsProvider.GetCentralMessageQueueMachine();
            var centralQueuePath    = MessageQueueHelper.GetQueuePath(centralQueueName, centralQueueMachine);

            _msmqSender = _msmqFactory.GetSender(centralQueuePath);
            _msmqSender.Send(new AddSubscriberMessage
            {
                SubscriberQueue = currentQueuePath
            });
        }
Esempio n. 3
0
        /// <summary>
        /// A straight forward implementation to calculate a prime number.
        /// Restrict yourself to the max calc for the square-root of the given input number
        ///
        /// Input: A number
        /// Response: true if it is a prime number, false otherwise
        /// </summary>
        /// <param name="request">a number</param>
        /// <param name="context"></param>
        /// <returns>true if it is a prime number, false otherwise</returns>
        public override async Task <PrimeReply> IsItPrime(PrimeRequest request, ServerCallContext context)
        {
            if (request == null)
            {
                return(FALSE_RESULT);
            }

            if (request.Number <= 0)
            {
                return(FALSE_RESULT);
            }
            else if (request.Number == 1 || request.Number == 2)
            {
                return(TRUE_RESULT);
            }
            else if (request.Number % 2 == 0)
            {
                return(FALSE_RESULT);
            }
            else
            {
                var answerFromCache = await GetFromCache(request.Number);

                if (answerFromCache == CACHE_HIT_SUCCESS)
                {
                    return(TRUE_RESULT);
                }

                var boundary = (int)Math.Floor(Math.Sqrt(request.Number));

                for (int i = 3; i <= boundary; i += 2)
                {
                    if (request.Number % i == 0)
                    {
                        return(FALSE_RESULT);
                    }
                }

                await SetThePrimeInCache(request);

                _mqSender.Send(_queueName, request.Number.ToString());
                return(TRUE_RESULT);
            }
        }