コード例 #1
0
        public Grid <Domain> Search(long tenantId, int?page, string search, bool modelStateValid)
        {
            // Construct grid object that will be returned
            Grid <Domain> grid = new Grid <Domain> {
                Search = search, NoItemsMessage = DomainResource.NoDomainsMessage
            };

            // Get search grid action buttons
            Button createDomainButton = new Button
            {
                Text          = DomainResource.CreateDomainButtonLabel,
                Icon          = Icon.Create,
                UrlParameters = new UrlParameters {
                    ControllerName = "domains", ActionName = "create"
                }
            };

            grid.Buttons = new List <Button> {
                createDomainButton
            };

            // Grid paging URL parameters
            grid.UrlParameters = new UrlParameters
            {
                ControllerName = "domains",
                ActionName     = "search",
                RouteValues    = new { search = search }
            };

            // If model state valid, get list of domains that will be used to populate grid
            if (modelStateValid)
            {
                // Get domains to display in grid
                grid.SearchParameters = new SearchParameters
                {
                    PageIndex = page == null ? 0 : page.Value - 1,
                    PageSize  = 10,
                    Search    = search
                };
                grid.SearchResult = _domainService.Search(tenantId, grid.SearchParameters);

                // Set action that is performed when user clicks on domain in grid
                UrlParameters itemUrlParameters = new UrlParameters {
                    ControllerName = "domains", ActionName = "update"
                };

                // Set domain property and route value that are used to render action links
                List <RoutePropertyPair> routePropertyPairs = new List <RoutePropertyPair> {
                    new RoutePropertyPair {
                        PropertyName = DomainPropertyNames.DomainId, RouteValueName = "domainid"
                    }
                };

                // Get grid columns
                grid.Columns = _gridColumnService.GetGridColumns <Domain>(itemUrlParameters, routePropertyPairs, DomainPropertyNames.Url, DomainPropertyNames.RedirectUrl);
            }

            // Return the result
            return(grid);
        }
コード例 #2
0
        public ThreadsViewModel GetThreadsViewModel(Page page, long tenantId, long?userId, long elementId, int?pageIndex)
        {
            int           threadsPerPage = _forumConfigurationService.ThreadsPerPage;
            ForumThreads  threads        = _forumService.ListThreads(tenantId, elementId, pageIndex == null ? 0 : (int)pageIndex - 1, threadsPerPage);
            UrlParameters urlParameters  = new UrlParameters {
                RouteName = "ReadPage", RouteValues = new { pageid = page.PageId, description = page.Name }
            };
            ThreadsViewModel viewModel = new ThreadsViewModel
            {
                Threads = threads,
                Pager   = new Pager {
                    PageIndex = pageIndex == null ? 1 : (int)pageIndex, Total = threads.Total, PageSize = threadsPerPage, UrlParameters = urlParameters
                },
                PageCounts       = new List <int>(),
                ShowCreateThread = (userId == null) || _forumAuthorizer.UserCanCreateThread(tenantId, elementId, userId.Value)
            };

            if (viewModel.ShowCreateThread)
            {
                viewModel.CreateThreadUrl = GetCreateThreadUrl(page, userId.HasValue);
            }
            int postsPerPage = _forumConfigurationService.PostsPerPage;

            foreach (ForumThreadExtended threadExtended in threads)
            {
                viewModel.PageCounts.Add(postsPerPage == 0 ? 1 : ((threadExtended.Thread.Replies - 1) / postsPerPage) + 1);
            }
            return(viewModel);
        }
コード例 #3
0
        /// <summary>
        /// Reemplaza los valores correspondientes a los parámetros de los endpoint
        /// </summary>
        /// <param name="url">endpoint</param>
        /// <param name="urlParameters">parámetros a reemplazar en la URL</param>
        /// <returns></returns>
        public static string ConvertUrl(this string url, UrlParameters urlParameters, bool?addField = null)
        {
            var listPropertyCase = GenericPropertyEntity <UrlParameters> .ModelProperty(urlParameters);

            List <Tuple <string, object> > tuples = new List <Tuple <string, object> >();
            string newUrl = string.Empty;

            foreach (var item in listPropertyCase.Where(x => x.Item2 != null))
            {
                string parametro = "{" + item.Item1 + "}";
                string value     = item.Item2.ToString();

                if (!url.Contains(parametro) && addField == true)
                {
                    tuples.Add(item);
                }

                url = url.Replace(parametro, value);
            }

            newUrl = url;

            if (newUrl.Contains("?") && addField == true)
            {
                var param = new Dictionary <string, string>();

                foreach (var item in tuples)
                {
                    param.Add(item.Item1, item.Item2.ToString());
                }

                newUrl = new Uri(QueryHelpers.AddQueryString(url, param)).ToString();
            }
            return(newUrl);
        }
コード例 #4
0
        public static void SetPrincipal()
        {
            IKickPrincipal principal = null;
            FormsIdentity  identity;
            UrlParameters  urlParameters = UrlParametersHelper.GetUrlParameters(HttpContext.Current.Request);

            if (HttpContext.Current.Request.IsAuthenticated)
            {
                identity = (FormsIdentity)HttpContext.Current.User.Identity;

                User userProfile;
                urlParameters.SecurityToken = (((FormsIdentity)identity).Ticket).UserData;
                try {
                    userProfile = UserCache.GetUser(urlParameters.SecurityToken);
                    userProfile.UpdateLastActiveOn();
                    principal = new AuthenticatedKickPrincipal(identity, userProfile);
                } catch {
                    //TODO: Log an exception
                    FormsAuthentication.SignOut();
                    principal = new AnonymousKickPrincipal(new GuestIdentity(), UserCache.GetUser(null));
                }
            }
            else
            {
                principal = new AnonymousKickPrincipal(new GuestIdentity(), UserCache.GetUser(null));
            }

            HttpContext.Current.User = principal;
        }
コード例 #5
0
        public void AddUrlParameters(string key, string value)
        {
            CoreValidator.ThrowIfNullOrEmpty(key, nameof(key));
            CoreValidator.ThrowIfNullOrEmpty(value, nameof(value));

            UrlParameters.Add(key, value);
        }
コード例 #6
0
        public void DeleteUrlParametersInjection(UrlParameters inputType)
        {
            var optionHandler  = new OptionManager();
            var urlParamerters = new Dictionary <string, string>();
            var options        = new List <Dictionary <string, object> >()
            {
                new Dictionary <string, object>()
                {
                    ["id"] = Common.GetOptionsByCurrentContext("parentOptionCreateResponse").SingleOrDefault().Id.ToString(),
                }
            };

            if (inputType == UrlParameters.Operation)
            {
                urlParamerters["operation"] = Common.sqlInjection;
            }
            else
            {
                urlParamerters["operation"] = "delete";
                urlParamerters["physical"]  = Common.sqlInjection;
            }

            var response = optionHandler.DeleteOptions(options, urlParamerters);

            PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(HttpStatusCode.BadRequest).And.ErrorCode((int)ResultCode.InvalidParameter));
        }
コード例 #7
0
        public GetLeaderboardRequest(ulong guildId, int limit = 100)
        {
            UrlParameters.Add(new PluginLevelUrlParam());
            UrlParameters.Add(new LeaderboardUrlParam(guildId));

            QueryParameters.Add(new LimitQueryParam(limit));
        }
コード例 #8
0
 public WorkspaceProjectRequestConfig(long workspaceId, bool?active = null, bool actualHours = false, bool onlyTemplates = false)
     : base($"https://www.toggl.com/api/v8/workspaces/{workspaceId}/projects")
 {
     UrlParameters.Add("active", active?.ToString().ToLowerInvariant());
     UrlParameters.Add("actual_hours", actualHours.ToString().ToLowerInvariant());
     UrlParameters.Add("only_templates", onlyTemplates.ToString().ToLowerInvariant());
 }
コード例 #9
0
        /// <summary>
        /// Actualiza caso de la aplicación Service Desk
        /// </summary>
        /// <param name="input">Parámetros para actualizar caso </param>
        /// <param name="user">Usuario autenticado</param>
        /// <returns>estado caso actualizado</returns>
        public async Task <OutputResponseCaseAsdkV8Dto> Update(InputUpdateCaseDto input)
        {
            UrlParameters parameterUrl = new UrlParameters
            {
                itemType = input.CaseType,
                idCase   = input.CaseId,
                userId   = Principal.User()?.Id,
            };

            string uriCreateCase = ConfigurationService.UrlUpdateCase.ConvertUrl(parameterUrl);
            string endpoint      = ConfigurationService.UrlServiceDesk + uriCreateCase;

            UpdateCaseV8 updateCase = input.MapperModel(new UpdateCaseV8());

            List <AnswerGeneralV8Api> listProperty = new List <AnswerGeneralV8Api>();

            listProperty.FillProperties(updateCase, true);

            List <AnswerGeneralV8Api> answerApi = await ConnectionService.PostAsync <List <AnswerGeneralV8Api> >(Principal.User()?.KeyAuthorization, endpoint, listProperty);

            OutputResponseCaseAsdkV8Dto answerUpdate = answerApi.ConvertModel(new OutputResponseCaseAsdkV8Dto());

            if (input.AdditionalFields?.Count > 0 && answerUpdate?.ItemId > 0)
            {
                await UpdateAdditionalFields(input.AdditionalFields, answerUpdate.ItemId, input.CaseType);
            }

            return(answerUpdate);
        }
コード例 #10
0
        public SummaryReportConfig(string userAgent, long workspaceId, DateTime?since = null,
                                   DateTime?until                 = null, BillableOptions?billableOptions = null, IList <int> clientIds        = null,
                                   IList <int> projectIds         = null, IList <int> userIds             = null, IList <int> memberOfGroupIds = null,
                                   IList <int> orMemberOfGroupIds = null, IList <int> tagIds              = null, IList <int> taskIds          = null,
                                   IList <int> timeEntryIds       = null, string description              = null, bool withoutDescription      = false,
                                   SummaryOrderField?orderField   = null, bool orderDescending            = false, bool distinctRates          = false,
                                   bool rounding = false, DisplayHours?displayHours                       = null) : base(ReportType.Summary, userAgent, workspaceId, since,
                                                                                                                         until, billableOptions, clientIds, projectIds, userIds, memberOfGroupIds, orMemberOfGroupIds, tagIds,
                                                                                                                         taskIds, timeEntryIds, description, withoutDescription, orderField?.UrlRepresentation(), orderDescending,
                                                                                                                         distinctRates, rounding, displayHours)
        {
            if (typeof(TGrouping).GetCustomAttribute(typeof(ToggleApiUrlValueAttribute)) is
                ToggleApiUrlValueAttribute groupingAttribute)
            {
                UrlParameters.Add("grouping", groupingAttribute.UrlValue);
            }

            if (typeof(TSubgrouping).GetCustomAttribute(typeof(ToggleApiUrlValueAttribute)) is
                ToggleApiUrlValueAttribute subGroupingAttribute)
            {
                UrlParameters.Add("subgrouping", subGroupingAttribute.UrlValue);
            }

            // Note that we default these to true to simplify the resulting model
            UrlParameters.Add("subgrouping_ids", "true");
            UrlParameters.Add("grouped_time_entry_ids", "true");
        }
コード例 #11
0
        private static string FormatUrl(string baseUrl, UrlParameters urlParameters)
        {
            var urlString = new StringBuilder();

            urlString.Append(FormatBaseUrl(baseUrl, urlParameters.SubDomain, urlParameters.Folder));

            if (!string.IsNullOrEmpty(urlParameters.Id))
            {
                urlString.Append($"{urlParameters.Id}/");
            }

            if (!string.IsNullOrEmpty(urlParameters.Controller))
            {
                urlString.Append($"{urlParameters.Controller}/");
            }

            if (!string.IsNullOrEmpty(urlParameters.Action))
            {
                urlString.Append($"{urlParameters.Action}/");
            }

            if (!string.IsNullOrEmpty(urlParameters.QueryString))
            {
                return($"{urlString.ToString().TrimEnd('/')}{urlParameters.QueryString}");
            }

            return(urlString.ToString().TrimEnd('/'));
        }
コード例 #12
0
        public string GenerateCohortDetailsUrl(uint?ukprn, string accountId, string cohortRef, bool isEmptyCohort = false,
                                               string journeyData = "")
        {
            var queryString = isEmptyCohort && ukprn.HasValue ? $"?providerId={ukprn}" : "";

            if (!string.IsNullOrWhiteSpace(journeyData))
            {
                if (string.IsNullOrWhiteSpace(journeyData))
                {
                    queryString = $"?journeyData={journeyData}";
                }
                else
                {
                    queryString += $"&journeyData={journeyData}";
                }
            }

            var urlParameters = new UrlParameters
            {
                Id = ukprn.HasValue && !isEmptyCohort?ukprn.Value.ToString() : accountId,
                         Controller  = string.IsNullOrEmpty(cohortRef) ? "unapproved/add" : $"apprentices/{cohortRef}",
                         Action      = isEmptyCohort ? "" : string.IsNullOrEmpty(cohortRef) ? "assign" : "details",
                         Folder      = ukprn.HasValue && !isEmptyCohort ? "" : "commitments/accounts",
                         QueryString = queryString
            };

            var baseUrl = GetBaseUrl();

            return(FormatUrl(baseUrl, urlParameters));
        }
コード例 #13
0
        public string AddUrlParameter(string paramKey, string paramValue)
        {
            // alpha, alphaValue
            string returnValue = string.Empty;

            List <UrlParameter> urlParams    = this.UrlParameters;
            UrlParameters       urlParameter = urlParams.Where(x => x.Key == paramKey).SingleOrDefault()

                                               if (urlParameter != null)
            {
                urlParams.Remove(urlParameter);
            }


            urlParams.Add(new UrlParameter()
            {
                Key   = paramKey,
                Value = paramValue
            });

            // [0] Key = alpha, Value = alphaValue
            // [1] Key = beta, Value = betaValue
            // [2] Key = gamma, Value = gammaValue

            for (int i = 0; i < urlParams.Count(); i++)
            {
                returnValue += i == 0 ? "?" : "&";
                returnValue += urlParams[i].Key + "=" + urlParams[i].Value;

                // ?alpha=alphaValue&beta=betaValue&gamma=gammaValue
            }

            return(returnValue);
        }
コード例 #14
0
        public async Task <OutputParametersDto> GetSLA(int serviceId, int itemType)
        {
            UrlParameters urlParameters = new UrlParameters
            {
                serviceId = serviceId,
                itemType  = itemType
            };

            List <Parameters> listSla = new List <Parameters>();

            foreach (var url in ConfigurationService.UrlSlAs)
            {
                string uri = url.ConvertUrl(urlParameters);

                string endpoint = ConfigurationService.UrlServiceDesk + uri;

                Parameters parameter = await ConnectionService.GetAsync <Parameters>(token, endpoint, Constants.NameHeaderTokenASDK_V9);

                listSla.AddUnic(parameter);
            }

            return(new OutputParametersDto
            {
                Parameters = listSla
            });
        }
コード例 #15
0
 protected ReportConfig(ReportType reportType, string userAgent, long workspaceId, DateTime?since = null, DateTime?until = null, BillableOptions?billableOptions = null,
                        IList <int> clientIds        = null, IList <int> projectIds = null, IList <int> userIds = null,
                        IList <int> memberOfGroupIds = null, IList <int> orMemberOfGroupIds = null, IList <int> tagIds = null,
                        IList <int> taskIds          = null, IList <int> timeEntryIds = null, string description         = null,
                        bool withoutDescription      = false, string orderField       = null, bool orderDescending       = false,
                        bool distinctRates           = false, bool rounding           = false, DisplayHours?displayHours = null) :
     base($"https://toggl.com/reports/api/v2/{reportType.UrlRepresentation()}")
 {
     UrlParameters.Add("user_agent", userAgent);
     UrlParameters.Add("workspace_id", workspaceId);
     UrlParameters.Add("since", since?.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture));
     UrlParameters.Add("until", until?.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture));
     UrlParameters.Add("billable", billableOptions?.UrlRepresentation());
     UrlParameters.Add("client_ids", (clientIds == null) ? null : string.Join(",", clientIds));
     UrlParameters.Add("project_ids", (projectIds == null) ? null : string.Join(",", projectIds));
     UrlParameters.Add("user_ids", (userIds == null) ? null : string.Join(",", userIds));
     UrlParameters.Add("member_of_group_ids", (memberOfGroupIds == null) ? null : string.Join(",", memberOfGroupIds));
     UrlParameters.Add("or_member_of_group_ids", (orMemberOfGroupIds == null) ? null : string.Join(",", orMemberOfGroupIds));
     UrlParameters.Add("tag_ids", (tagIds == null) ? null : string.Join(",", tagIds));
     UrlParameters.Add("task_ids", (taskIds == null) ? null : string.Join(",", taskIds));
     UrlParameters.Add("time_entry_ids", (timeEntryIds == null) ? null : string.Join(",", timeEntryIds));
     UrlParameters.Add("description", description);
     UrlParameters.Add("without_description", withoutDescription.ToString().ToLowerInvariant());
     UrlParameters.Add("order_field", orderField);
     UrlParameters.Add("order_descending", orderDescending.ToString().ToLowerInvariant());
     UrlParameters.Add("distinct_rates", distinctRates.ToString().ToLowerInvariant());
     UrlParameters.Add("rounding", rounding.ToString().ToLowerInvariant());
     UrlParameters.Add("display_hours", displayHours?.UrlRepresentation());
 }
コード例 #16
0
 public RegistrationLoggingBehavior(
     IContainer container,
     IBehaviorChain behaviorChainChain, Logger logger,
     HttpRequestMessage requestMessage,
     HttpResponseMessage responseMessage,
     HttpResponseHeaders responseHeaders,
     HttpConfiguration httpConfiguration,
     HttpRequestContext httpRequestContext,
     ActionDescriptor actionDescriptor,
     ActionMethod actionMethod,
     RouteDescriptor routeDescriptor,
     RequestCancellation requestCancellation,
     UrlParameters urlParameters,
     QuerystringParameters querystringParameters,
     SomeType someInstance)
 {
     BehaviorChain = behaviorChainChain;
     logger.Write(container);
     logger.Write(requestMessage);
     logger.Write(responseMessage);
     logger.Write(responseHeaders);
     logger.Write(actionMethod);
     logger.Write(actionDescriptor);
     logger.Write(routeDescriptor);
     logger.Write(httpRequestContext);
     logger.Write(httpConfiguration);
     logger.Write(requestCancellation);
     logger.Write(urlParameters);
     logger.Write(querystringParameters);
     logger.Write(someInstance);
 }
コード例 #17
0
        public void DeleteInvalidUrlParametersOption(UrlParameters urlParameter, InvalidOptionCases inputType)
        {
            var deleteParameters = new Dictionary <string, object>();
            var optionHandler    = new OptionManager();
            var options          = new List <Dictionary <string, object> >();
            var urlParams        = new Dictionary <string, string>();
            var value            = OptionData.InvalidOptionMapper[inputType];

            deleteParameters["id"] = Common.GetOptionsByCurrentContext("parentOptionCreateResponse").FirstOrDefault().Id;

            if (!(inputType == InvalidOptionCases.Missing && urlParameter == UrlParameters.Operation))
            {
                if (urlParameter == UrlParameters.Operation)
                {
                    urlParams["operation"] = value;
                }
                else
                {
                    urlParams["operation"] = "delete";
                    urlParams["physical"]  = value;
                }
            }

            options.Add(deleteParameters);
            var response = optionHandler.DeleteOptions(options, urlParams);

            PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(HttpStatusCode.BadRequest).
                          And.ErrorCode((inputType == InvalidOptionCases.Missing && urlParameter == UrlParameters.Operation) ? (int)ResultCode.ParameterInsufficient : (int)ResultCode.InvalidValue));
        }
コード例 #18
0
ファイル: BaseServer.cs プロジェクト: RodrasSilva/DIDA-GSTORE
        public void Run()
        {
            Console.Title = "Server: " + _serverId;
            Console.WriteLine("Running base version");
            var freezeUtilities       = new FreezeUtilities();
            var serverParameters      = UrlParameters.From(_serverUrl);
            var serverService         = new ServerService(_storage, freezeUtilities, _serverUrl, DelayMessage);
            var nodeService           = new NodeService(freezeUtilities, DelayMessage, RegisterServers, RegisterPartitions);
            var registerSlavesService = new SlaveRegisteringService(_storage);

            AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
            var server = new Grpc.Core.Server {
                Services =
                {
                    DIDAService.BindService(serverService),
                    NodeControlService.BindService(nodeService),
                    RegisterSlaveToMasterService.BindService(registerSlavesService),
                    BaseSlaveService.BindService(new BaseSlaveServerService(_storage))
                },
                Ports =
                {
                    new ServerPort(serverParameters.Hostname,
                                   serverParameters.Port, ServerCredentials.Insecure)
                }
            };

            server.Start();
            Console.WriteLine("Server " + _serverId + " listening on port " + serverParameters.Port);
            ReadCommands();

            server.ShutdownAsync().Wait();
        }
コード例 #19
0
        /// <summary>
        /// usage https://subDomain.baseUrl/folder/id/controller/action?queryString
        /// </summary>
        /// <param name="urlParameters"></param>
        /// <returns></returns>
        public string GenerateAddApprenticeUrl(UrlParameters urlParameters)
        {
            var baseUrl = _configuration["AuthType"].Equals("employer", StringComparison.CurrentCultureIgnoreCase)
                ? _options.EmployerApprenticeUrl
                : _options.ApprenticeUrl;

            return(FormatUrl(baseUrl, urlParameters));
        }
コード例 #20
0
 protected override BWebServiceResponse OnRequestPP(HttpListenerContext _Context, Action <string> _ErrorMessageAction = null)
 {
     if (UrlParameters.ContainsKey("secret") && UrlParameters["secret"] == InternalCallPrivateKey)
     {
         return(Process(_Context, _ErrorMessageAction));
     }
     return(BWebResponse.Forbidden("You are trying to access to a private service."));
 }
コード例 #21
0
ファイル: TmdbClient.cs プロジェクト: kiritodom53/TMDBApiDom
        /// <summary>
        /// Sestaví url s parametrama
        /// </summary>
        /// <param name="url">URL</param>
        /// <param name="parameters">Parametry</param>
        /// <returns>URL dotaz</returns>
        private string BuildUrl(string url, UrlParameters parameters)
        {
            var builder = new UriBuilder(url);

            parameters.Add("api_key", this.apikey);
            builder.Query = Helpers.EncodeDictionary(parameters);

            return(builder.ToString());
        }
コード例 #22
0
 public UrlParameterBinder(
     RouteDescriptor routeDescriptor,
     ArgumentBinder argumentBinder,
     UrlParameters urlParameters)
 {
     _argumentBinder  = argumentBinder;
     _routeDescriptor = routeDescriptor;
     _urlParameters   = urlParameters;
 }
コード例 #23
0
 public string GetUrl(UrlParameters urlParameters)
 {
     if (urlParameters.IsRoute)
     {
         return(GetRouteUrl(urlParameters, null));
     }
     else
     {
         return(GetActionUrl(urlParameters, null));
     }
 }
コード例 #24
0
 public string GetUrl(UrlParameters urlParameters, object routeValues)
 {
     if (urlParameters.IsRoute)
     {
         return(GetRouteUrl(urlParameters, routeValues));
     }
     else
     {
         return(GetActionUrl(urlParameters, routeValues));
     }
 }
コード例 #25
0
        public void CompilePageModel(string model, string param = "", string param2 = "")
        {
            if (string.IsNullOrEmpty(model))
            {
                this.Errors.Add("model cannot be empty in CompilePageModel");
                return;
            }

            using (var CSharpProvider = new CSharpCodeProvider())
            {
                StringCompilerModel stringCompilerModel = this._AddModelToCodeTemplate(model);

                // try to compile model and invoke Execute method
                var providerResult = CSharpProvider.CompileAssemblyFromSource(stringCompilerModel.CopilerParams, stringCompilerModel.Template);
                try
                {
                    var modelClassType = providerResult.CompiledAssembly.GetType("ModelClass");
                    var classInstance  = Activator.CreateInstance(modelClassType);
                    // Method ModelClass.Execute has two parameters UrlParameters and HttpContext
                    var urlParameters = new UrlParameters
                    {
                        Param       = param,
                        Param2      = param2,
                        Url         = HttpContext.Current != null ? HttpContext.Current.Request.Url : null,
                        QueryString = HttpContext.Current != null?HttpContext.Current.Request.QueryString.ToDictionary() : null
                    };
                    var httpContext = HttpContext.Current;
                    // Invoke ModelClass.Execute method with paramaters UrlParameters and HttpContext
                    // Method returns an object that will be parsed as JSON to pass to the view
                    object output = modelClassType.GetMethod("Execute").Invoke(classInstance, new object[] { urlParameters, httpContext });
                    this.JsonResult = output.ToString();
                } // end try compile model
                catch (Exception ex)
                {
                    this.JsonResult = "{ \"Error\" : \"failed to compile model\" }";
                    if (providerResult.Errors.HasErrors)
                    {
                        for (var i = 0; i < providerResult.Errors.Count; i++)
                        {
                            var errorLine = providerResult.Errors[i].Line > 4 ? providerResult.Errors[i].Line - 4 : providerResult.Errors[i].Line;
                            // need to adjust error lines since ui editor is offset
                            if (errorLine > 6)
                            {
                                errorLine = errorLine - 7;
                            }
                            this.Errors.Add(string.Format("Model Compile Error: {0}, Line: {1}", providerResult.Errors[i].ErrorText, errorLine));
                        }
                    }
                    this.Errors.Add(ex.Message);
                } // end catch
            }     // end using CSharpCodeProvider
            return;
        }
コード例 #26
0
 public DetailedReportConfig(string userAgent, long workspaceId, DateTime?since = null,
                             DateTime?until                 = null, BillableOptions?billableOptions = null, IList <int> clientIds        = null,
                             IList <int> projectIds         = null, IList <int> userIds             = null, IList <int> memberOfGroupIds = null,
                             IList <int> orMemberOfGroupIds = null, IList <int> tagIds              = null, IList <int> taskIds          = null,
                             IList <int> timeEntryIds       = null, string description              = null, bool withoutDescription      = false,
                             DetailedOrderField?orderField  = null, bool orderDescending            = false, bool distinctRates          = false, bool rounding = false,
                             DisplayHours?displayHours      = null) : base(ReportType.Detailed, userAgent, workspaceId, since, until, billableOptions, clientIds,
                                                                           projectIds, userIds, memberOfGroupIds, orMemberOfGroupIds, tagIds, taskIds, timeEntryIds, description,
                                                                           withoutDescription, orderField?.UrlRepresentation(), orderDescending, distinctRates, rounding, displayHours)
 {
     UrlParameters.Add("page", 1);
 }
コード例 #27
0
        private IEnumerable <KeyValuePair <string, string> > GetCreateUserEmailSubstitutions(long tenantId, string email, string alias, Token confirmToken)
        {
            UrlParameters urlParameters = _authenticationUrlService.GetConfirmSetPasswordUrlParameters(tenantId, confirmToken);
            string        confirmUrl    = _webHelperService.GetUrl(urlParameters);
            Dictionary <string, string> substitutions = new Dictionary <string, string>();

            substitutions.Add(AliasKeyword, alias);
            substitutions.Add(EmailKeyword, email);
            substitutions.Add(ConfirmUrl, confirmUrl);
            substitutions.Add(ConfirmExpires, confirmToken.Expiry.ToString("dd MMMM yyyy HH:mm:ss") + " GMT");
            return(substitutions);
        }
コード例 #28
0
        private IEnumerable <KeyValuePair <string, string> > GetCreatePostSubstitutions(string email, string alias, long postId, int?page, string subject, string postAlias)
        {
            UrlParameters urlParameters = _forumUrlService.GetCreatePostUrlParameters(postId, page);
            string        forumUrl      = _webHelperService.GetUrl(urlParameters);
            Dictionary <string, string> substitutions = new Dictionary <string, string>();

            substitutions.Add(ALIAS_KEYWORD, alias);
            substitutions.Add(EMAIL_KEYWORD, email);
            substitutions.Add(FORUM_URL, forumUrl);
            substitutions.Add(THREAD_SUBJECT, subject);
            substitutions.Add(POST_ALIAS, postAlias);
            return(substitutions);
        }
コード例 #29
0
        private string GetRouteUrl(UrlParameters urlParameters, object routeValues)
        {
            UrlRouteContext routeContext = new UrlRouteContext
            {
                Fragment  = urlParameters.Fragment,
                Host      = urlParameters.HostName,
                Protocol  = urlParameters.Protocol,
                RouteName = urlParameters.RouteName,
                Values    = routeValues != null ? routeValues : urlParameters.RouteValues
            };
            IUrlHelper urlHelper = _urlHelperFactory.GetUrlHelper(_actionContextAccessor.ActionContext);

            return(urlHelper.RouteUrl(routeContext));
        }
コード例 #30
0
        public void AddUrlParameter(string key, string value)
        {
            CoreValidator.ThrowIfNullOrEmpty(key, nameof(key));
            CoreValidator.ThrowIfNullOrEmpty(value, nameof(value));

            if (!UrlParameters.ContainsKey(key))
            {
                this.UrlParameters.Add(key, value);
            }
            else
            {
                this.UrlParameters[key] = value;
            }
        }