示例#1
0
        public HttpResponseMessage Get(
            [FromUri] string tenant,                // Our stuff
            [FromUri] string notifierId,
            [FromUri] TwilioSms sms)
        {
            // Run service
            using (Profiler.Measure("TwilioController.Get"))
            {
                try
                {
                    long notifierIdNum;

                    try
                    {
                        notifierIdNum = Int64.Parse(notifierId);
                    }
                    catch
                    {
                        throw new UnmatchedNotifierException();
                    }

                    using (WebApiHelpers.GetTenantContext(tenant))
                    {
                        _receiver.HandleRequest(notifierIdNum, sms);
                    }

                    return(new HttpResponseMessage(HttpStatusCode.Accepted));
                }
                catch (TwilioValidationException)
                {
                    EventLog.Application.WriteError($"Request failed validation. URL:{System.Web.HttpContext.Current.Request.Url}");
                    return(new HttpResponseMessage(HttpStatusCode.BadRequest));
                }
            }
        }
示例#2
0
        public HttpResponseMessage Get(
            [FromUri] string tenant,
            [FromUri] string token,
            [FromUri] string select = null
            )
        {
            if (!Factory.FeatureSwitch.Get("enableWfUserActionNotify"))
            {
                return(new HttpResponseMessage(System.Net.HttpStatusCode.NotFound));
            }

            using (Profiler.Measure("ApproveController.Approve"))
            {
                using (WebApiHelpers.GetTenantContext(tenant))
                {
                    string responseHtml = null;

                    var task = UserTaskHelper.GetTaskFromLinkToken(token);

                    if (task == null)
                    {
                        responseHtml = _htmlGenerator.GenerateRejectionPage();
                    }
                    else
                    {
                        if (select == null)
                        {
                            responseHtml = _htmlGenerator.GenerateSelectionPage(task);
                        }
                        else
                        {
                            // TODO: make the selection]
                            UserTaskHelper.ProcessApproval(task.Id, select);
                            responseHtml = _htmlGenerator.GenerateCompletedPage(task);
                        }
                    }

                    var response = new HttpResponseMessage(System.Net.HttpStatusCode.Accepted);
                    response.Content = new StringContent(responseHtml, Encoding.UTF8, "text/html");

                    return(response);
                }
            }
        }
示例#3
0
        public HttpResponseMessage UpdateStatus([FromUri] string tenant, [FromUri] string notifierId, SmsStatus request)
        {
            string messageSid    = request.SmsSid;
            string messageStatus = request.MessageStatus;
            string errorCode     = request.ErrorCode;

            // Run service
            using (Profiler.Measure("TwilioController.UpdateStatus"))
            {
                try
                {
                    long notifierIdNum;

                    try
                    {
                        notifierIdNum = Int64.Parse(notifierId);
                    }
                    catch
                    {
                        throw new UnmatchedNotifierException();
                    }

                    bool handled = false;

                    using (WebApiHelpers.GetTenantContext(tenant))
                    {
                        handled = _receiver.HandleStatusUpdate(notifierIdNum, messageSid, messageStatus, errorCode);
                    }

                    return(new HttpResponseMessage(handled ? HttpStatusCode.Accepted : HttpStatusCode.NotFound));
                }
                catch (TwilioValidationException)
                {
                    EventLog.Application.WriteError($"Request failed validation. URL:{System.Web.HttpContext.Current.Request.Url}");
                    return(new HttpResponseMessage(HttpStatusCode.BadRequest));
                }
            }
        }