public HttpResponseMessage Canvas(String tenantId, String flowId, String playerUrl) { String redirectUrl = null; String signedRequest = null; CanvasRequest canvasRequest = null; HttpResponseMessage response = null; try { // Get the signed request from the form post signedRequest = System.Web.HttpContext.Current.Request.Form["signed_request"]; // Grab the canvas request object from the post // The secret needs to be stored somewhere - actually, it doesn't - we don't need the secret at all canvasRequest = SalesforceCanvasUtils.VerifyAndDecode(null, signedRequest, "6156156167154975556"); if (flowId == null || flowId.Trim().Length == 0) { throw new ArgumentNullException("BadRequest", "A flow identifier is required. Please pass in a parameter for \"flow-id\"."); } if (tenantId == null || tenantId.Trim().Length == 0) { throw new ArgumentNullException("BadRequest", "A tenant identifier is required. Please pass in a parameter for \"tenant-id\"."); } if (playerUrl == null || playerUrl.Trim().Length == 0) { throw new ArgumentNullException("BadRequest", "A player is required. Please pass in a parameter for \"player-url\"."); } // Construct the redirect url so the player knows what to do redirectUrl = ""; redirectUrl += SettingUtils.GetStringSetting(SETTING_SERVER_BASE_PATH) + "/" + tenantId + "/play/" + playerUrl; redirectUrl += "?session-token=" + canvasRequest.client.oauthToken; redirectUrl += "&session-url=" + HttpUtility.HtmlEncode(canvasRequest.client.instanceUrl + canvasRequest.context.links.partnerUrl); // Create the run url stuff using utils redirectUrl = RunUtils.CompleteRunUrl(redirectUrl, Guid.Parse(flowId)); // Tell the caller to redirect back to the desired location response = Request.CreateResponse(HttpStatusCode.RedirectMethod, redirectUrl); response.Headers.Add("Location", redirectUrl); } catch (Exception exception) { throw BaseHttpUtils.GetWebException(HttpStatusCode.BadRequest, BaseHttpUtils.GetExceptionMessage(exception)); } return(response); }
public ObjectDataResponseAPI DeleteFile(FileDataRequestAPI fileDataRequestAPI) { try { throw new NotImplementedException("File delete is not currently enabled."); } catch (Exception exception) { throw BaseHttpUtils.GetWebException(HttpStatusCode.BadRequest, BaseHttpUtils.GetExceptionMessage(exception)); } }
public Task <List <MentionedWhoAPI> > SearchUsersByName(String streamId, String name, SocialServiceRequestAPI socialServiceRequest) { try { return(SalesforceServiceSingleton.GetInstance().SearchUsersByName(EmailNotifier.GetInstance(this.GetWho(), socialServiceRequest.configurationValues, "PluginSalesforceController.SearchUsersByName"), this.GetWho(), streamId, name, socialServiceRequest)); } catch (Exception exception) { throw BaseHttpUtils.GetWebException(HttpStatusCode.BadRequest, BaseHttpUtils.GetExceptionMessage(exception)); } }
public AuthenticatedWhoResultAPI Login(AuthenticationCredentialsAPI authenticationCredentialsAPI) { try { return(SalesforceServiceSingleton.GetInstance().Login(authenticationCredentialsAPI)); } catch (Exception exception) { throw BaseHttpUtils.GetWebException(HttpStatusCode.BadRequest, BaseHttpUtils.GetExceptionMessage(exception)); } }
public Task <MessageAPI> PostNewMessage(String streamId) { try { return(SalesforceServiceSingleton.GetInstance().PostNewMessage(this.GetWho(), streamId, Request.Content)); } catch (Exception exception) { throw BaseHttpUtils.GetWebException(HttpStatusCode.BadRequest, BaseHttpUtils.GetExceptionMessage(exception)); } }
public ObjectDataResponseAPI GetUserInAuthorizationContext(ObjectDataRequestAPI objectDataRequestAPI) { try { return(SalesforceServiceSingleton.GetInstance().GetUserInAuthorizationContext(EmailNotifier.GetInstance(this.GetWho(), objectDataRequestAPI.configurationValues, "PluginSalesforceController.GetUserInAuthorizationContext"), this.GetWho(), objectDataRequestAPI)); } catch (Exception exception) { throw BaseHttpUtils.GetWebException(HttpStatusCode.BadRequest, BaseHttpUtils.GetExceptionMessage(exception)); } }
public ObjectDataResponseAPI LoadGroupAttributes(ObjectDataRequestAPI objectDataRequestAPI) { try { return(SalesforceServiceSingleton.GetInstance().LoadGroupAttributes(objectDataRequestAPI)); } catch (Exception exception) { throw BaseHttpUtils.GetWebException(HttpStatusCode.BadRequest, BaseHttpUtils.GetExceptionMessage(exception)); } }
public Task <String> FollowStream(String streamId, String follow, SocialServiceRequestAPI socialServiceRequest) { try { return(SalesforceServiceSingleton.GetInstance().FollowStream(EmailNotifier.GetInstance(this.GetWho(), socialServiceRequest.configurationValues, "PluginSalesforceController.FollowStream"), this.GetWho(), streamId, Boolean.Parse(follow), socialServiceRequest)); } catch (Exception exception) { throw BaseHttpUtils.GetWebException(HttpStatusCode.BadRequest, BaseHttpUtils.GetExceptionMessage(exception)); } }
public DescribeServiceResponseAPI Describe(DescribeServiceRequestAPI describeServiceRequest) { try { return(SalesforceServiceSingleton.GetInstance().Describe(this.GetWho(), describeServiceRequest)); } catch (Exception exception) { throw BaseHttpUtils.GetWebException(HttpStatusCode.BadRequest, BaseHttpUtils.GetExceptionMessage(exception)); } }
public void Notification(ServiceNotificationRequestAPI serviceNotificationRequestAPI) { try { SalesforceServiceSingleton.GetInstance().Notify(EmailNotifier.GetInstance(this.GetWho(), serviceNotificationRequestAPI.configurationValues, "PluginSalesforceController.Notification"), this.GetWho(), serviceNotificationRequestAPI); } catch (Exception exception) { throw BaseHttpUtils.GetWebException(HttpStatusCode.BadRequest, BaseHttpUtils.GetExceptionMessage(exception)); } }
public ObjectDataResponseAPI LoadFiles(FileDataRequestAPI fileDataRequestAPI) { try { return(SalesforceServiceSingleton.GetInstance().LoadFiles(this.GetWho(), fileDataRequestAPI)); } catch (Exception exception) { throw BaseHttpUtils.GetWebException(HttpStatusCode.BadRequest, BaseHttpUtils.GetExceptionMessage(exception)); } }
public VoteResponseAPI Vote(VoteRequestAPI voteRequestAPI) { try { return(SalesforceServiceSingleton.GetInstance().Vote(EmailNotifier.GetInstance(this.GetWho(), voteRequestAPI.configurationValues, "PluginSalesforceController.Vote"), this.GetWho(), voteRequestAPI)); } catch (Exception exception) { throw BaseHttpUtils.GetWebException(HttpStatusCode.BadRequest, BaseHttpUtils.GetExceptionMessage(exception)); } }
public ServiceResponseAPI Invoke(String actionName, ServiceRequestAPI serviceRequest) { try { return(SalesforceServiceSingleton.GetInstance().Invoke(EmailNotifier.GetInstance(this.GetWho(), serviceRequest.configurationValues, "PluginSalesforceController.Invoke"), this.GetWho(), actionName, serviceRequest)); } catch (Exception exception) { throw BaseHttpUtils.GetWebException(HttpStatusCode.BadRequest, BaseHttpUtils.GetExceptionMessage(exception)); } }
public List <TypeElementPropertyBindingAPI> DescribeFields(ObjectDataRequestAPI objectDataRequestAPI) { try { return(SalesforceServiceSingleton.GetInstance().DescribeFields(this.GetWho(), objectDataRequestAPI)); } catch (Exception exception) { throw BaseHttpUtils.GetWebException(HttpStatusCode.BadRequest, BaseHttpUtils.GetExceptionMessage(exception)); } }
public Task <MessageListAPI> GetStreamMessages(String streamId, SocialServiceRequestAPI socialServiceRequest) { try { return(SalesforceServiceSingleton.GetInstance().GetStreamMessages(EmailNotifier.GetInstance(this.GetWho(), socialServiceRequest.configurationValues, "PluginSalesforceController.GetStreamMessages"), this.GetWho(), streamId, socialServiceRequest)); } catch (Exception exception) { throw BaseHttpUtils.GetWebException(HttpStatusCode.BadRequest, BaseHttpUtils.GetExceptionMessage(exception)); } }
public Task <ObjectDataResponseAPI> UploadFile() { try { return(SalesforceServiceSingleton.GetInstance().UploadFile(this.GetWho(), Request.Content)); } catch (Exception exception) { throw BaseHttpUtils.GetWebException(HttpStatusCode.BadRequest, BaseHttpUtils.GetExceptionMessage(exception)); } }
public HttpResponseMessage SessionSignIn(String tenantId, String flowId, String playerUrl, String sessionId, String sessionUrl) { String redirectUrl = null; HttpResponseMessage response = null; try { if (flowId == null || flowId.Trim().Length == 0) { throw new ArgumentNullException("BadRequest", "A flow identifier is required. Please pass in a parameter for \"flow-id\"."); } if (tenantId == null || tenantId.Trim().Length == 0) { throw new ArgumentNullException("BadRequest", "A tenant identifier is required. Please pass in a parameter for \"tenant-id\"."); } if (playerUrl == null || playerUrl.Trim().Length == 0) { throw new ArgumentNullException("BadRequest", "A player is required. Please pass in a parameter for \"player-url\"."); } // Construct the redirect url so the player knows what to do redirectUrl = ""; redirectUrl += SettingUtils.GetStringSetting(SETTING_SERVER_BASE_PATH) + "/" + tenantId + "/play/" + playerUrl; redirectUrl += "?session-token=" + sessionId; redirectUrl += "&session-url=" + sessionUrl; // Create the run url stuff using utils redirectUrl = RunUtils.CompleteRunUrl(redirectUrl, Guid.Parse(flowId)); // Tell the caller to redirect back to the desired location response = Request.CreateResponse(HttpStatusCode.RedirectMethod, redirectUrl); response.Headers.Add("Location", redirectUrl); } catch (Exception exception) { throw BaseHttpUtils.GetWebException(HttpStatusCode.BadRequest, BaseHttpUtils.GetExceptionMessage(exception)); } return(response); }
protected override System.Threading.Tasks.Task <HttpResponseMessage> SendAsync(HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) { WorkflowRuleNotification receivedNotification = null; IAuthenticatedWho authenticatedWho = null; INotifier emailNotifier = null; Guid tenantGuid = Guid.Empty; String tenantId = null; String mode = null; String email = null; try { // Get the mode from the request uri mode = BaseHttpUtils.GetModeFromQuery(request.RequestUri); // Get any provided notification email email = BaseHttpUtils.GetEmailFromQuery(request.RequestUri); // Check to make sure the incoming request has enough segments // Deployed we have an extra segment for the deployment sub-directory, hence this is one more than you would have thought if (request.RequestUri.Segments.Length < 9) { throw new ArgumentNullException("Request.Segments", "The incoming request is not a valid Url for outbound messages."); } // Get the segments from the call so we know which tenant we're executing against tenantId = request.RequestUri.Segments[8].Replace("/", ""); // Check to make sure we've received valid guids if (Guid.TryParse(tenantId, out tenantGuid) == false) { throw new ArgumentNullException("Request.Segments", "The incoming request does not contain a valid tenant identifier. You provided: " + tenantId); } // Create a basic authenticated who for the notifier authenticatedWho = AuthenticationUtils.CreatePublicUser(tenantId); authenticatedWho.Email = email; // Create the notifier emailNotifier = EmailNotifier.GetInstance(tenantId, authenticatedWho, null, "WorkflowRuleListenerMessageHandler"); // ExtractData would populate notification class' variables, which can be used to get desired data. receivedNotification = new WorkflowRuleNotification(); receivedNotification.ExtractData(emailNotifier, request.Content.ReadAsStringAsync().Result, mode); // Now send ManyWho the notification that something has changed on a set of records, but only if ManyWho actually cares about them this.Execute(emailNotifier, tenantId, mode, receivedNotification); // Send the debug log if the user is running in debug mode if (SettingUtils.IsDebugging(mode)) { ErrorUtils.SendAlert(emailNotifier, null, ErrorUtils.ALERT_TYPE_WARNING, "Debug Log Entries"); } // Send a response back to SFDC // Note: since we are not calling base class' SendAsync function, the request will return from here, and will not reach our POST function. return(Task.FromResult(receivedNotification.PrepareResponse(request))); } catch (Exception exception) { // Send the debug log if the user is running in debug mode if (SettingUtils.IsDebugging(mode)) { ErrorUtils.SendAlert(emailNotifier, null, ErrorUtils.ALERT_TYPE_WARNING, BaseHttpUtils.GetExceptionMessage(exception)); } throw BaseHttpUtils.GetWebException(HttpStatusCode.BadRequest, BaseHttpUtils.GetExceptionMessage(exception)); } }
protected override System.Threading.Tasks.Task <HttpResponseMessage> SendAsync(HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) { WorkflowRuleNotification receivedNotification = null; IAuthenticatedWho authenticatedWho = null; INotifier emailNotifier = null; Guid tenantGuid = Guid.Empty; Guid flowGuid = Guid.Empty; String tenantId = null; String flowId = null; String player = null; String mode = null; String email = null; String reportingMode = null; try { // Get the mode from the request uri mode = BaseHttpUtils.GetModeFromQuery(request.RequestUri); // Get the reporting mode from the request uri reportingMode = BaseHttpUtils.GetReportingModeFromQuery(request.RequestUri); // Get any provided notification email email = BaseHttpUtils.GetEmailFromQuery(request.RequestUri); // Check to make sure the incoming request has enough segments if (request.RequestUri.Segments.Length < 9) { throw new ArgumentNullException("Request.Segments", "The incoming request is not a valid Url for outbound messages."); } // Get the segments from the call so we know which tenant we're executing against tenantId = request.RequestUri.Segments[7].Replace("/", ""); flowId = request.RequestUri.Segments[8].Replace("/", ""); player = request.RequestUri.Segments[9]; // Check to make sure we've received valid guids if (Guid.TryParse(tenantId, out tenantGuid) == false) { throw new ArgumentNullException("Request.Segments", "The incoming request does not contain a valid tenant identifier."); } if (Guid.TryParse(flowId, out flowGuid) == false) { throw new ArgumentNullException("Request.Segments", "The incoming request does not contain a valid flow identifier."); } // If a player has not been provided, we make it the default player if (String.IsNullOrWhiteSpace(player) == true) { player = "default"; } // Create a basic authenticated who for the notifier authenticatedWho = AuthenticationUtils.CreatePublicUser(tenantId); authenticatedWho.Email = email; // Create the notifier emailNotifier = EmailNotifier.GetInstance(tenantId, authenticatedWho, null, "WorkflowRuleMessageHandler"); //ExtractData would populate notification class' variables, which can be used to get desired data. receivedNotification = new WorkflowRuleNotification(); receivedNotification.ExtractData(emailNotifier, request.Content.ReadAsStringAsync().Result, mode); if (SettingUtils.IsDebugging(mode)) { emailNotifier.AddLogEntry("Mode: " + mode); } if (SettingUtils.IsDebugging(mode)) { emailNotifier.AddLogEntry("Email: " + email); } if (SettingUtils.IsDebugging(mode)) { emailNotifier.AddLogEntry("Reporting Mode: " + reportingMode); } // Execute the notifications against ManyWho this.Execute(emailNotifier, tenantId, flowId, player, mode, reportingMode, receivedNotification); // Send the debug log if the user is running in debug mode if (SettingUtils.IsDebugging(mode)) { ErrorUtils.SendAlert(emailNotifier, null, ErrorUtils.ALERT_TYPE_WARNING, "Debug Log Entries"); } //Send a response back to SFDC //Note: since we are not calling base class' SendAsync function, the request will return from here, and will not reach our POST function. return(Task.FromResult(receivedNotification.PrepareResponse(request))); } catch (Exception exception) { // Send the debug log if the user is running in debug mode if (SettingUtils.IsDebugging(mode)) { ErrorUtils.SendAlert(emailNotifier, null, ErrorUtils.ALERT_TYPE_WARNING, BaseHttpUtils.GetExceptionMessage(exception)); } throw BaseHttpUtils.GetWebException(HttpStatusCode.BadRequest, BaseHttpUtils.GetExceptionMessage(exception)); } }
public HttpResponseMessage TaskEmailOutcomeResponse(String token, String selectedOutcomeId, String redirectUri = null) { IAuthenticatedWho authenticatedWho = null; INotifier notifier = null; HttpResponseMessage response = null; ServiceResponseAPI serviceResponse = null; ServiceRequestAPI serviceRequest = null; String invokeType = null; String responseContent = null; try { if (String.IsNullOrWhiteSpace(token) == true) { throw new ArgumentNullException("Token", "The token for the request is null or blank."); } if (String.IsNullOrWhiteSpace(selectedOutcomeId) == true) { throw new ArgumentNullException("SelectedOutcomeId", "The selected outcome for the request is null or blank."); } // Get the email verification for this tracking code serviceRequest = JsonConvert.DeserializeObject <ServiceRequestAPI>(StorageUtils.GetStoredJson(token.ToLower())); if (serviceRequest == null) { throw new ArgumentNullException("ServiceRequest", "The request has already been processed."); } // Get the notifier email authenticatedWho = new AuthenticatedWho(); authenticatedWho.Email = ValueUtils.GetContentValue(SalesforceServiceSingleton.SERVICE_VALUE_ADMIN_EMAIL, serviceRequest.configurationValues, true); // Create the notifier notifier = EmailNotifier.GetInstance(serviceRequest.tenantId, authenticatedWho, null, "TaskEmailOutcomeResponse"); // Create the service response to send back to ManyWho based on this outcome click serviceResponse = new ServiceResponseAPI(); serviceResponse.invokeType = ManyWhoConstants.INVOKE_TYPE_FORWARD; serviceResponse.tenantId = serviceRequest.tenantId; serviceResponse.token = serviceRequest.token; serviceResponse.selectedOutcomeId = selectedOutcomeId; // Invoke the response on the manywho service invokeType = RunSingleton.GetInstance().Response(notifier, null, serviceRequest.tenantId, serviceRequest.callbackUri, serviceResponse); if (invokeType == null || invokeType.Trim().Length == 0) { throw new ArgumentNullException("ServiceRequest", "The invokeType coming back from ManyWho cannot be null or blank."); } if (invokeType.IndexOf(ManyWhoConstants.INVOKE_TYPE_SUCCESS, StringComparison.InvariantCultureIgnoreCase) >= 0) { // The system has accepted our task email response so the token is now dead - we remove it from storage StorageUtils.RemoveStoredJson(token.ToLower()); } else { // The system has not accepted our task email response, so we should simply keep waiting and responding to emails with this task token } // Tell the user the outcome selection was successful responseContent = "Your request has been successfully completed. Please close this window."; if (String.IsNullOrWhiteSpace(redirectUri) == false) { // Redirect the user as specified response = Request.CreateResponse(HttpStatusCode.RedirectMethod, redirectUri); response.Headers.Add("Location", redirectUri); } else { // Send the user a response page response = Request.CreateResponse(HttpStatusCode.OK); response.Content = new StringContent(responseContent); } } catch (Exception exception) { throw BaseHttpUtils.GetWebException(HttpStatusCode.BadRequest, BaseHttpUtils.GetExceptionMessage(exception)); } return(response); }