public HasTagsHandler(IRepository<Tag> tagsRepository, IRepository<TagsContentItems> tagsContentItemsRepository) { OnLoading<HasTags>((context, tags) => { // provide names of all tags on demand tags._allTags.Loader(list => tagsRepository.Table.ToList()); // populate list of attached tags on demand tags._currentTags.Loader(list => { var tagsContentItems = tagsContentItemsRepository.Fetch(x => x.ContentItemId == context.ContentItem.Id); foreach (var tagContentItem in tagsContentItems) { var tag = tagsRepository.Get(tagContentItem.TagId); list.Add(tag); } return list; }); }); OnRemoved<HasTags>((context, ht) => { tagsContentItemsRepository.Flush(); HasTags tags = context.ContentItem.As<HasTags>(); foreach (var tag in tags.CurrentTags) { if (!tagsContentItemsRepository.Fetch(x => x.ContentItemId == context.ContentItem.Id).Any()) { tagsRepository.Delete(tag); } } }); }
public WinXinUserInfoPartHandle(IRepository<WinXinUserInfoPartRecord> winXinUserInfoPartRecordRepository) { Filters.Add(new ActivatingFilter<WinXinUserInfoPart>("User")); OnInitialized<WinXinUserInfoPart>((context, part) => part.Record.Loader( () => winXinUserInfoPartRecordRepository .Fetch(x => x.UserId == context.ContentItem.Id).FirstOrDefault())); }
/// <summary> /// returns EmailQueueItems from the provided context which are belong in the union of all filter cases /// </summary> /// <param name="repository">The repository.</param> /// <returns></returns> public IEnumerable<EmailQueueItem> Filter(IRepository<EmailQueueItem> repository) { if(Filters.Count == 0) { this.And(new SentStatusDequeueFilter(false)).And(new RetriesFilter(5)); } int length = Filters.Count; var query = repository.Fetch(); while (length > 0) { var filter = Filters.Dequeue(); if(filter.Key == FilterOperand.And) { query = filter.Value.Filter(query); } length--; //add filter back at the end of the queue so we can use this FilterList over and over. //Essentially we iterate in place except that it isn't in place. //Should always be an O(1) operation because I don't think the capacity of the queue ever decreases. //If O(1), who cares about this then, this function is bounded by O(n) Filters.Enqueue(filter); } return query.ToArray(); }
public UserRolesPartHandler(IRepository<UserRolesPartRecord> userRolesRepository) { _userRolesRepository = userRolesRepository; Filters.Add(new ActivatingFilter<UserRolesPart>("User")); OnInitialized<UserRolesPart>((context, userRoles) => userRoles._roles.Loader(value => _userRolesRepository .Fetch(x => x.UserId == context.ContentItem.Id) .Select(x => x.Role.Name).ToList())); }
public UserRolesHandler(IRepository<UserRolesRecord> userRolesRepository) { _userRolesRepository = userRolesRepository; Filters.Add(new ActivatingFilter<UserRoles>("user")); OnLoaded<UserRoles>((context, userRoles) => { userRoles.Roles = _userRolesRepository .Fetch(x => x.UserId == context.ContentItem.Id) .Select(x => x.Role.Name).ToList(); }); }
public OrderPartHandler( IRepository<OrderPartRecord> repository, IContentManager contentManager, IRepository<OrderDetailRecord> orderDetailsRepository, IOrdersService ordersService, IRepository<OrderAddressRecord> orderAddressRepository) { _orderDetailsRepository = orderDetailsRepository; Filters.Add(StorageFilter.For(repository)); OnActivated<OrderPart>((context, part) => { // Details part._details.Loader(details => _orderDetailsRepository.Fetch(d => d.OrderId == part.Id) .Select(d => new OrderDetail(d)) .ToList()); // Order total part._orderTotal.Loader(orderTotal => BuildOrderTotal(part)); // BillingAddress part._billingAddress.Loader(shippingAddress => orderAddressRepository.Get(part.BillingAddressId)); }); OnLoading<OrderPart>((context, part) => { // Order total part._orderTotal.Loader(orderTotal => part.Retrieve(x => x.OrderTotal)); }); OnCreating<OrderPart>((context, part) => { if (String.IsNullOrWhiteSpace(part.Reference)) { part.Reference = ordersService.BuildOrderReference(); } }); OnCreated<OrderPart>((context, part) => { // Order total part.OrderTotal = BuildOrderTotal(part); SaveDetails(part); part.BillingAddressId = orderAddressRepository.CreateOrUpdate(part.BillingAddress); }); OnUpdated<OrderPart>((context, part) => { // Order total part.OrderTotal = BuildOrderTotal(part); SaveDetails(part); part.BillingAddressId = orderAddressRepository.CreateOrUpdate(part.BillingAddress); }); }
public PostHandler(ICourseMenuService menuService, IYearService yearService, ICourseService courseService, IRepository<MailSubscriptionRecord> mailRepo, IMembershipService membershipService, IMessageManager messageManager, IRepository<PostRecord> postRepo, IHttpContextAccessor httpContextAccessor) { this.courseService = courseService; this.yearService = yearService; this.menuService = menuService; this.httpContextAccessor = httpContextAccessor; this.postRepo = postRepo; this.mailRepo = mailRepo; this.messageManager = messageManager; this.membershipService = membershipService; OnPublished<RoutePart>((context, part) => { var item = postRepo.Fetch(x => x.ContentId == part.ContentItem.Id).FirstOrDefault(); if (item != null) { var menu = menuService.Get(item.Menu.Id); sendEmail(menu.Id, part.ContentItem); } }); }
public IQueryable <EmailLog> Fetch(Expression <Func <EmailLog, bool> > expression) { return(_emailLogRepository.Fetch(expression)); }
public IQueryable <PageTemplateLog> Fetch(Expression <Func <PageTemplateLog, bool> > expression) { return(_pageTemplateLogRepository.Fetch(expression)); }
private void PrintRoleRecord(RoleRecord roleRecord, int initialIndent = 0) { var secondIndent = initialIndent + 2; Context.Output.Write(new string(' ', initialIndent)); Context.Output.WriteLine(T("{0}", roleRecord.Name)); if (IncludePermissions) { Context.Output.Write(new string(' ', secondIndent)); Context.Output.WriteLine(T("List of Permissions")); Context.Output.Write(new string(' ', secondIndent)); Context.Output.WriteLine(T("--------------------------")); var permissionsEnumerable = roleRecord.RolesPermissions .Where(record => WithFeature == null || record.Permission.FeatureName == WithFeature) .Where(record => WithPermission == null || record.Permission.Name == WithPermission); var orderedPermissionsEnumerable = permissionsEnumerable .OrderBy(record => record.Permission.FeatureName) .ThenBy(record => record.Permission.Name); foreach (var rolesPermissionsRecord in orderedPermissionsEnumerable) { Context.Output.Write(new string(' ', secondIndent)); Context.Output.Write("Feature Name:".PadRight(15)); Context.Output.WriteLine(rolesPermissionsRecord.Permission.FeatureName); Context.Output.Write(new string(' ', secondIndent)); Context.Output.Write("Permission:".PadRight(15)); Context.Output.WriteLine(rolesPermissionsRecord.Permission.Name); Context.Output.Write(new string(' ', secondIndent)); Context.Output.Write("Description:".PadRight(15)); Context.Output.WriteLine(rolesPermissionsRecord.Permission.Description); Context.Output.WriteLine(); } } if (IncludeUsers) { var userRolesPartRecords = _userRolesRepository.Fetch(record => record.Role.Name == roleRecord.Name); Context.Output.Write(new string(' ', secondIndent)); Context.Output.WriteLine(T("List of Users")); Context.Output.Write(new string(' ', secondIndent)); Context.Output.WriteLine(T("--------------------------")); foreach (var userRolesPartRecord in userRolesPartRecords) { var userRolesPart = _contentManager.Get <UserRolesPart>(userRolesPartRecord.UserId); var user = userRolesPart.As <IUser>(); Context.Output.Write(new string(' ', secondIndent)); Context.Output.Write("UserName:"******"Email:".PadRight(15)); Context.Output.WriteLine(user.Email); Context.Output.WriteLine(); } } }
public ActionResult Index() { var model = orderRepository.Fetch(); return(View("Index", model)); }
public IEnumerable <RouteSettingsModel> GetRoutes() { return(_cacheManager.Get("WebAdvanced.Sitemap.Routes", ctx => { ctx.Monitor(_signals.When("WebAdvanced.Sitemap.Refresh")); var slugs = new Dictionary <string, string>(); // slug => Title (if available) // Extract filtered routes from route providers foreach (var provider in _routeProviders) { var routes = provider.GetDisplayRoutes() .Where(route => _routeFilters.All(filter => filter.AllowUrl(route.Url))) .AsEnumerable(); // Get all base paths foreach (var route in routes) { var alias = route.UrlAlias ?? route.Url; var slugParts = alias.Trim('/').Split('/'); if (slugParts.Count() == 1 && !string.IsNullOrWhiteSpace(route.Title)) { slugs[slugParts[0]] = route.Title; } else { if (!slugs.ContainsKey(slugParts[0])) { slugs[slugParts[0]] = slugParts[0].SlugToTitle(); } } } } var routeModels = new List <RouteSettingsModel>(); var orderedSlugs = slugs.OrderByDescending(s => s.Value).ToList(); foreach (var pair in orderedSlugs) { var slug = pair.Key; var route = _routeRepository.Fetch(q => q.Slug == slug).FirstOrDefault(); if (route == null) { route = new SitemapRouteRecord { Active = true, DisplayColumn = 1, DisplayLevels = 3, Weight = 0, Slug = slug }; _routeRepository.Create(route); } var model = new RouteSettingsModel { Active = route.Active, DisplayColumn = route.DisplayColumn, DisplayLevels = route.DisplayLevels, Id = route.Id, Name = pair.Value, Weight = route.Weight, Slug = slug }; routeModels.Add(model); } return routeModels; })); }
public UserRolesPartHandler(IRepository <UserRolesPartRecord> userRolesRepository) { _userRolesRepository = userRolesRepository; Filters.Add(new ActivatingFilter <UserRolesPart>("User")); OnInitialized <UserRolesPart>((context, userRoles) => userRoles._roles.Loader(() => _userRolesRepository .Fetch(x => x.UserId == context.ContentItem.Id) .Select(x => x.Role.Name).ToList())); }
protected virtual ICustomSessionFactoryHolder InternalCreateSessionFactoryHolder(string name) { var connectionsRecord = _connectionsRecordRepository.Fetch(c => c.Name == name).SingleOrDefault(); return(CreateSessionFactoryHolder(connectionsRecord.Provider, connectionsRecord.ConnectionString)); }
/// <summary> /// Fetch from the specified remote. /// </summary> /// <param name="repository">The <see cref="Repository"/> being worked with.</param> /// <param name="remoteName">The name of the <see cref="Remote"/> to fetch from.</param> public static void Fetch(this IRepository repository, string remoteName) { repository.Fetch(remoteName, null); }
public IQueryable <SiteSetting> Fetch(Expression <Func <SiteSetting, bool> > expression) { return(_siteSettingRepository.Fetch(expression)); }
public IQueryable <ProtectedDocumentLog> Fetch(Expression <Func <ProtectedDocumentLog, bool> > expression) { return(_protectedDocumentLogRepository.Fetch(expression)); }
public IQueryable <Tag> Fetch(Expression <Func <Tag, bool> > expression) { return(_tagRepository.Fetch(expression)); }
private Response ExecPost(List <AnswerWithResultViewModel> Risps, string QuestionnaireContext = "") { #if DEBUG Logger.Error(Request.Headers.ToString()); #endif int QuestionId = 0; if (_orchardServices.Authorizer.Authorize(Permissions.SubmitQuestionnaire)) { if (Risps.Count > 0) { var currentUser = _orchardServices.WorkContext.CurrentUser; if (Risps[0].Id > 0) { QuestionId = _repositoryAnswer.Fetch(x => x.Id == Risps[0].Id).FirstOrDefault().QuestionRecord_Id; } else { QuestionId = Risps[0].QuestionRecord_Id; } Int32 id = _repositoryQuestions.Fetch(x => x.Id == QuestionId).FirstOrDefault().QuestionnairePartRecord_Id; var content = _contentManager.Get(id); var qp = content.As <QuestionnairePart>(); QuestionnaireWithResultsViewModel qVM = _questionnairesServices.BuildViewModelWithResultsForQuestionnairePart(qp); foreach (QuestionWithResultsViewModel qresult in qVM.QuestionsWithResults) { if (qresult.QuestionType == QuestionType.OpenAnswer) { foreach (AnswerWithResultViewModel Risp in Risps) { if (qresult.Id == Risp.QuestionRecord_Id && !(string.IsNullOrEmpty(Risp.AnswerText))) { qresult.OpenAnswerAnswerText = Risp.AnswerText; } } } else { foreach (AnswerWithResultViewModel asw in qresult.AnswersWithResult) { foreach (AnswerWithResultViewModel Risp in Risps) { if (asw.Id == Risp.Id) { if (qresult.QuestionType == QuestionType.SingleChoice) { qresult.SingleChoiceAnswer = asw.Id; } else { asw.Answered = true; } } } } } } var context = new ValidationContext(qVM, serviceProvider: null, items: null); var results = new List <ValidationResult>(); var isValid = Validator.TryValidateObject(qVM, context, results); if (!isValid) { string messaggio = ""; foreach (var validationResult in results) { messaggio += validationResult.ErrorMessage + " "; } return(_utilsServices.GetResponse(ResponseType.Validation, "Validation:" + messaggio)); } else { qVM.Context = QuestionnaireContext; if (_questionnairesServices.Save(qVM, currentUser, HttpContext.Current.Session.SessionID)) { return(_utilsServices.GetResponse(ResponseType.Success)); } else { return(_utilsServices.GetResponse(ResponseType.Validation, "Questionnaire already submitted.")); } } } else { return(_utilsServices.GetResponse(ResponseType.Validation, "Validation: data list is empty.")); } } else { return(_utilsServices.GetResponse(ResponseType.UnAuthorized)); } }
public void Set(string path, IDictionary <string, string> routeValues, string source, bool isManaged) { if (path == null) { throw new ArgumentNullException("path"); } var aliasRecord = _aliasRepository.Fetch(r => r.Path == path, o => o.Asc(r => r.Id), 0, 1).FirstOrDefault(); aliasRecord = aliasRecord ?? new AliasRecord { Path = path }; string areaName = null; string controllerName = null; string actionName = null; var values = new XElement("v"); foreach (var routeValue in routeValues.OrderBy(kv => kv.Key, StringComparer.InvariantCultureIgnoreCase)) { if (string.Equals(routeValue.Key, "area", StringComparison.InvariantCultureIgnoreCase) || string.Equals(routeValue.Key, "area-", StringComparison.InvariantCultureIgnoreCase)) { areaName = routeValue.Value; } else if (string.Equals(routeValue.Key, "controller", StringComparison.InvariantCultureIgnoreCase)) { controllerName = routeValue.Value; } else if (string.Equals(routeValue.Key, "action", StringComparison.InvariantCultureIgnoreCase)) { actionName = routeValue.Value; } else { values.SetAttributeValue(routeValue.Key, routeValue.Value); } } aliasRecord.Action = _actionRepository.Fetch( r => r.Area == areaName && r.Controller == controllerName && r.Action == actionName, o => o.Asc(r => r.Id), 0, 1).FirstOrDefault(); aliasRecord.Action = aliasRecord.Action ?? new ActionRecord { Area = areaName, Controller = controllerName, Action = actionName }; aliasRecord.RouteValues = values.ToString(); aliasRecord.Source = source; aliasRecord.IsManaged = isManaged; if (aliasRecord.Action.Id == 0 || aliasRecord.Id == 0) { if (aliasRecord.Action.Id == 0) { _actionRepository.Create(aliasRecord.Action); } if (aliasRecord.Id == 0) { _aliasRepository.Create(aliasRecord); } // Bulk updates might go wrong if we don't flush _aliasRepository.Flush(); } // Transform and push into AliasHolder var dict = ToDictionary(aliasRecord); _aliasHolder.SetAlias(new AliasInfo { Path = dict.Item1, Area = dict.Item2, RouteValues = dict.Item3, IsManaged = dict.Item6 }); }
public IQueryable <StyleLog> Fetch(Expression <Func <StyleLog, bool> > expression) { return(_styleLogRepository.Fetch(expression)); }
public static TEntity?Fetch <TEntity, TProperty>(this IRepository <TEntity> repository, Expression <Func <TEntity, TProperty> > orderByExpression, bool ascending = false) => repository.Fetch(x => true, orderByExpression, ascending);
public void Calculate(Calculus calculus) { // look for the corresponding external function var function = _functions.Where(f => f.Name == calculus.FunctionName).FirstOrDefault(); if (function == null) { // no corresponding function found return; } // if an optimized calculation can't be executed, convert it to a Rebuild if (calculus.Mode == CalculationModes.Create && !function.CanCreate || calculus.Mode == CalculationModes.Delete && !function.CanDelete || calculus.Mode == CalculationModes.Update && !function.CanUpdate) { calculus = new RebuildCalculus { ContentId = calculus.ContentId, FunctionName = calculus.FunctionName, Dimension = calculus.Dimension }; } lock (_queue) { // if a rebuild is already waiting for the same content item and function, don't add a new one)) if (_queue.Any(c => c.Mode == CalculationModes.Rebuild && c.ContentId == calculus.ContentId && c.FunctionName == calculus.FunctionName && c.Dimension == calculus.Dimension)) { return; } _queue.Enqueue(calculus); } if (Monitor.TryEnter(_queue)) { while (_queue.Count > 0) { var currentCalculus = _queue.Dequeue(); calculus.GetVotes = () => { return(_voteRepository .Fetch(v => v.ContentItemRecord.Id == currentCalculus.ContentId && v.Dimension == currentCalculus.Dimension) .ToList()); }; // get the current result for this function and content item var result = _resultRepository .Fetch(r => r.ContentItemRecord.Id == currentCalculus.ContentId && r.FunctionName == currentCalculus.FunctionName) .SingleOrDefault(); var contentItem = _contentManager.Get(currentCalculus.ContentId); if (result == null) { result = new ResultRecord { Dimension = calculus.Dimension, ContentItemRecord = contentItem.Record, ContentType = contentItem.ContentType, FunctionName = calculus.FunctionName, Value = 0, Count = 0 }; } // either it's a new result or not, do update the CreatedUtc result.CreatedUtc = _clock.UtcNow; currentCalculus.Execute(function, result); if (result.Id == 0) { _resultRepository.Create(result); } // invalidates the cached result _signals.Trigger(DefaultVotingService.GetCacheKey(result.ContentItemRecord.Id, result.FunctionName, result.Dimension)); _eventHandler.Calculated(result); } Monitor.Exit(_queue); } }
public IEnumerable <CurrencyDTO> GetAvailableCurrencies() { var currencies = _currenciesRepository.Fetch(); return(_mapper.Map <IEnumerable <CurrencyDTO> >(currencies)); }
public virtual List <TEntity> All(Expression <Func <TEntity, bool> > predicate, bool track) { return (_repository.Fetch(predicate, track).ToList()); }
public IEnumerable <TeamAttendeeRecord> GetByTeam(int teamId) { return(_teamAttendeeRepository.Fetch(s => s.TeamPartRecord.Id == teamId)); }
public IEnumerable <CupPlaceRecord> GetByCup(int cupId) { return(_cupPlaceRepository .Fetch(s => s.CupPartRecord.Id == cupId) .OrderBy(s => s.Place)); }
public IQueryable <Notification> Fetch(Expression <Func <Notification, bool> > expression) { return(_notificationRepository.Fetch(expression)); }
public ManualsXapp(IAppHandler aHandler) { iHandler = aHandler; iXappMimeTypes = new Dictionary<string, string>(); iXappMimeTypes.Add(".css", "text/css"); iGitMimeTypes = new Dictionary<string, string>(); iGitMimeTypes.Add(".md", "text/md"); iGitMimeTypes.Add(".html", "text/html"); iGitMimeTypes.Add(".css", "text/css"); iGitMimeTypes.Add(".js", "text/javascript"); iGitMimeTypes.Add(".jpg", "image/jpg"); iGitMimeTypes.Add(".png", "image/png"); iResourceFolder = new ResourceFolder("http", iXappMimeTypes, iHandler.AppRoot); iGitPath = Path.Combine(iHandler.DataRoot, "GitManuals"); iRepository = GitFactory.Open(iGitPath, "git://github.com/cropotkin/Documentation.git"); iRepository.Fetch(); iMarkdown = new Markdown(); iAdvancedModule = new AdvancedModule("openhome.org.advanced", iHandler.AppRoot); iHandler.RegisterXapp(this, "xapp/main.css", iAdvancedModule); }
public IQueryable <Entity.Entities.Models.News> Fetch( Expression <Func <Entity.Entities.Models.News, bool> > expression) { return(_newsRepository.Fetch(expression)); }
bool UpdateGit(IRepository repo) { var recompileNeeded = true; using (var _ = new ChangingOutput("Updating source code . . .")) { _.FinishLine(); using (var t = new ChangingOutput("Fetching updates from GitHub . . .")) { repo.Fetch("origin", new FetchOptions() { OnTransferProgress = (x) => { t.PrintProgress((double) x.ReceivedObjects/x.TotalObjects); return true; } }); t.PrintResult(true); } var currentCommit = repo.Head.Tip; MergeResult result; try { using (var t = new ChangingOutput("Merging in updates . . .")) { result = repo.Merge(repo.Head.TrackedBranch, new Signature(Environment.UserName, "*****@*****.**", DateTime.Now), new MergeOptions { CommitOnSuccess = true, FileConflictStrategy = CheckoutFileConflictStrategy.Ours, MergeFileFavor = MergeFileFavor.Normal, OnCheckoutProgress = (n, processed, total) => { t.PrintProgress((double) processed/total); }, }); t.PrintResult(result.Status != MergeStatus.Conflicts); } if (result.Status == MergeStatus.UpToDate) { Console.WriteLine("Source was already up to date"); recompileNeeded = RestoreDeleteFiles(repo); _.PrintResult(true); } else if (result.Status == MergeStatus.Conflicts) { throw new MergeConflictException(); } else { Console.WriteLine("Updated to {0} : {1}", result.Commit.Sha.Substring(0, 10), result.Commit.MessageShort); _.PrintResult(true); } } catch (MergeConflictException) { Console.WriteLine("Merge resulted in conflicts. This usually indictates a user-edited source"); Console.WriteLine("Your Aura will NOT be updated until you undo your changes to the files."); Console.WriteLine("This is a bad thing, so fix it ASAP."); Console.WriteLine("NOTE: If you're trying to make configuration changes, use the \"user\" folders instead."); Console.WriteLine("Rolling back merge..."); repo.Reset(currentCommit); recompileNeeded = false; _.PrintResult(false); } return recompileNeeded; } }
public IEnumerable <OrderRecord> GetOrders(int customerId) { return(_orderRepository.Fetch(x => x.CustomerId == customerId)); }
public IQueryable <WidgetTemplateLog> Fetch(Expression <Func <WidgetTemplateLog, bool> > expression) { return(_templateLogRepository.Fetch(expression)); }
public IQueryable <FormDefaultComponent> Fetch(Expression <Func <FormDefaultComponent, bool> > expression) { return(_formDefaultComponentRepository.Fetch(expression)); }
public static TEntity?Fetch <TEntity>(this IRepository <TEntity> repository) => repository.Fetch(x => true);
public IQueryable <CampaignCode> Fetch(Expression <Func <CampaignCode, bool> > expression) { return(_campaignCodeRepository.Fetch(expression)); }
public IQueryable <Event> Fetch(Expression <Func <Event, bool> > expression) { return(_eventRepository.Fetch(expression)); }
public IQueryable <LinkTrackerClick> Fetch(Expression <Func <LinkTrackerClick, bool> > expression) { return(_linkTrackerClickRepository.Fetch(expression)); }
public Client FindClient(string clientId) { var client = _clientRepository.Fetch(x => x.Id == clientId).FirstOrDefault(); return(client); }