Exemple #1
0
        static string CreateActionLink(DisplayFormUserTask task)
        {
            var    baseAddress = ConfigurationSettings.GetSiteConfigurationSection().SiteSettings.Address;
            var    tenantID    = RequestContext.TenantId;
            string tenantName;

            using (new AdministratorContext())
            {
                tenantName = Entity.Get <Tenant>(tenantID, Tenant.Name_Field).Name;
            }

            string url;

            if (task.RecordToPresent != null)
            {
                url = string.Format(ActionLinkWithRecordFormat, baseAddress, tenantName, task.RecordToPresent.Id, task.Id);
            }
            else
            {
                url = string.Format(ActionLinkFormat, baseAddress, tenantName, task.Id);
            }

            if (task.FormToUse != null)
            {
                url += "&formId=" + task.FormToUse.Id;
            }

            return(url);
        }
        /// <summary>
        ///     Initializes a service client for a request to the specified server type.
        /// </summary>
        /// <param name="client">
        ///     An object representing a service client.
        /// </param>
        /// <param name="server">
        ///     An ID identifying the server to process the service request.
        /// </param>
        /// <param name="serviceAddress">
        ///     A string containing the service address.
        /// </param>
        /// <param name="credentials">
        ///     The credentials required to access the server.
        /// </param>
        public static void InitializeClient <TChannel>(ClientBase <TChannel> client, string server, string serviceAddress, Credentials credentials) where TChannel : class
        {
            if (client == null)
            {
                throw new ArgumentNullException("client");
            }

            if (String.IsNullOrEmpty(server))
            {
                throw new ArgumentException("The specified server parameter is invalid.");
            }

            if (String.IsNullOrEmpty(serviceAddress))
            {
                throw new ArgumentException("The specified serviceAddress parameter is invalid.");
            }

            // Get the server's default service address
            string address = string.Format(@"https://{0}{1}", server, ConfigurationSettings.GetSiteConfigurationSection( ).SiteSettings.ServiceRootAddress);

            // Initialize the endpoint address
            client.Endpoint.Address = new EndpointAddress(string.Format("{0}/{1}.svc", address, serviceAddress));

            // Initialize the client credentials
            if (client.ClientCredentials != null)
            {
                client.ClientCredentials.UserName.UserName = Credentials.GetFullyQualifiedName(credentials);
                client.ClientCredentials.UserName.Password = credentials.Password;
            }
        }
Exemple #3
0
        /// <summary>
        /// Get a link to view a resource.
        /// </summary>
        /// <param name="resourceRef"></param>
        /// <returns></returns>
        public static Uri GetResourceViewUrl(EntityRef resourceRef)
        {
            var baseAddress = ConfigurationSettings.GetSiteConfigurationSection().SiteSettings.Address;
            var tenantName  = RequestContext.GetContext().Tenant.Name;

            return(new Uri(string.Format(resourceViewFormat, baseAddress, tenantName, resourceRef.Id)));
        }
Exemple #4
0
        public string GenerateSelectionPageUrl(string taskToken)
        {
            var baseAddress       = ConfigurationSettings.GetSiteConfigurationSection().SiteSettings.Address;
            var escapedTenantName = Uri.EscapeUriString(RequestContext.GetContext().Tenant.Name);
            var escapedTaskToken  = Uri.EscapeDataString(taskToken);

            return($"https://{baseAddress}/spapi/approval/{escapedTenantName}/approve?token={escapedTaskToken}");
        }
        private void ValidateRequest(TwilioNotifier notifier)
        {
            var httpContext = System.Web.HttpContext.Current;

            if (httpContext == null)    // We are not coming via the http stack so don't validate.
            {
                return;
            }

            // To validate a dev request we need to ignore any ADC transformations that may have occurred.
            var  externalAddress = ConfigurationSettings.GetSiteConfigurationSection().SiteSettings.Address;
            var  alternativeUrl  = $"https://{externalAddress}{httpContext.Request.Url.PathAndQuery}";
            bool isValid         = _validator.IsValidRequest(httpContext, notifier.TpAuthToken, alternativeUrl);

            if (!isValid)
            {
                throw new TwilioValidationException();
            }
        }
 /// <summary>
 ///     Initializes a service client for a request to the specified server type.
 /// </summary>
 /// <param name="client">
 ///     An object representing a service client.
 /// </param>
 /// <param name="serviceAddress">
 ///     A string containing the service address.
 /// </param>
 /// <param name="credentials">
 ///     The credentials required to access the server.
 /// </param>
 public static void InitializeClient <TChannel>(ClientBase <TChannel> client, string serviceAddress, Credentials credentials) where TChannel : class
 {
     InitializeClient(client, ConfigurationSettings.GetSiteConfigurationSection( ).SiteSettings.Address, serviceAddress, credentials);
 }
 string GetBaseAddress()
 {
     return(ConfigurationSettings.GetSiteConfigurationSection().SiteSettings.Address);
 }