예제 #1
0
        // GET: api/Queue/5 USE GET FOR TESTING ONLY
        //this is going to be post

        //7
        //851255a1-213c-4299-a50b-57a06f4a2ed0

        // http://localhost:62902/api/queue/
        //[System.Web.Http.HttpPost]
        public string Get(int id, string apiKey)

        {
            if (apiKey == SmtpFactory.GetApiKey(id).ToString())
            {
                var mailFrom    = new MailAddress("*****@*****.**");
                var mailTo      = new MailAddress("*****@*****.**");
                var mailMessage = new MailMessage(mailFrom, mailTo);


                mailMessage.Body    = "Testing body message";
                mailMessage.Subject = "Another Test";

                //C:\files/file.jpg

                ////upload files here////


                mailMessage.Headers.Add(Constant.OrganizationId, id.ToString());

                var queueId = SmtpFactory.InsertQueueMessage(mailMessage);
                mailMessage.Headers.Add(Constant.QueueId, queueId.ToString());

                //STOP

                //ADD new service to send OR Create function to look use QueueId
                //EmailService
                //SmtpFactory.SendMessage(mailMessage);

                return("");
            }
            return("Wrong ApiKey");
        }
예제 #2
0
        // GET api/<controller>/5 USE GET FOR TEST PURPOSE ONLY
        public string Get(string id)
        {
            var queueId = Guid.Parse(id);

            SmtpFactory.RemoveQueueMessage(queueId);

            return("value");
        }
예제 #3
0
        // POST: api/Queue
        public string Post(MailMessage mailMessage)
        {
            var queueId = SmtpFactory.InsertQueueMessage(mailMessage);

            mailMessage.Headers.Add(Constant.QueueId, queueId.ToString());

            SmtpFactory.SendMessage(mailMessage);

            return(queueId.ToString());
        }
예제 #4
0
        private void SendQueue(object sender, System.Timers.ElapsedEventArgs e)
        {
            _timer.Stop();


            var messageIds = SmtpFactory.GetAllMessageIds();

            foreach (Guid item in messageIds)
            {
                var _message = SmtpFactory.GetMessage(item);
                SmtpFactory.SendMessage(_message);
            }

            _timer.Start();
        }
예제 #5
0
        // POST api/<controller>
        public void Post(string qid)
        {
            var queueId = Guid.Parse(qid);

            SmtpFactory.RemoveQueueMessage(queueId);
        }