コード例 #1
0
        protected void SetRelations(GOUserGroupDataObject x)
        {
            var prefetches = PrefetchAssociations.Get("GOUserGroup", ApplicationSettings.Resolve <IDataProviderTransaction>()?.Parameters);

            if (prefetches.Contains("Group") && this.Group != null)
            {
                var group = x.ObjectsDataSet.GetObject(new GOGroupDataObject((System.String) this.Group.Name)
                {
                    IsNew = false
                });

                if (group == null)
                {
                    group = this.Group.ToDataObject(x.ObjectsDataSet) as GOGroupDataObject;
                }

                x.SetGroupValue(group);
            }

            if (prefetches.Contains("User") && this.User != null)
            {
                var user = x.ObjectsDataSet.GetObject(new GOUserDataObject((System.Guid) this.User.Id)
                {
                    IsNew = false
                });

                if (user == null)
                {
                    user = this.User.ToDataObject(x.ObjectsDataSet) as GOUserDataObject;
                }

                x.SetUserValue(user);
            }
        }
        public void DispatchForEntityCollection(IEnumerable <GOLoginHistoryDataObject> entities, List <string> includes, IObjectsDataSet context, Dictionary <string, object> parameters, bool skipSecurity = false)
        {
            // Remember includes we've already dispatched so as to avoid multiple data fetches
            var dispatched = new HashSet <string>();

            // get (custom) prefetch list so we can skip the dispatch for stuff we already fetched
            var prefetches = PrefetchAssociations.Get("GOLoginHistory", parameters);

            foreach (var include in includes)
            {
                string relation    = include.Split('.').First().ToLower();
                var    subincludes = DispatchPath.GetSubIncludes(relation, includes);

                if (relation.Contains(":"))
                {
                    relation = relation.Substring(relation.IndexOf(':') + 1);
                }

                if (dispatched.Contains(relation))
                {
                    continue;
                }

                dispatched.Add(relation);

                switch (relation)
                {
                default:
                    throw new ApplicationException("GOLoginHistory Entity has no relation named " + relation);
                }
            }
        }
コード例 #3
0
        public void DispatchForEntity(CountryDataObject entity, List <string> includes, IObjectsDataSet context, Dictionary <string, object> parameters, bool skipSecurity = false)
        {
            // Remember includes we've already dispatched so as to avoid multiple data fetches
            var dispatched = new HashSet <string>();

            // get (custom) prefetch list so we can skip the dispatch for stuff we already fetched
            var prefetches = PrefetchAssociations.Get("Country", parameters);

            foreach (var include in includes)
            {
                string relation    = include.Split('.').First().ToLower();
                var    subincludes = DispatchPath.GetSubIncludes(relation, includes);

                if (relation.Contains(":"))
                {
                    relation = relation.Substring(relation.IndexOf(':') + 1);
                }

                if (dispatched.Contains(relation))
                {
                    continue;
                }

                dispatched.Add(relation);

                switch (relation)
                {
                case "visitedplaceitems":
                {
                    // custom code can implement IPrefetch<ORMCountry> and add prefetch info through PrefetchAssociations helper => if set, we skip the dispatch-fetch
                    if (prefetches.Contains("VisitedPlaceItems"))
                    {
                        break;
                    }

                    try
                    {
                        var objectToFetch = VisitedPlaceDataProvider.GetCollection(null, String.Format("CountryURI == \"{0}\"", entity.URI), null, null, 0, 0, subincludes, context, parameters, skipSecurity);
                        if (objectToFetch != null)
                        {
                            entity.ObjectsDataSet.Merge(objectToFetch.ObjectsDataSet);
                        }
                    }
                    catch (GOServerException e)
                    {
                        if (e.Reason != "accessDenied")
                        {
                            throw;
                        }
                    }
                    break;
                }

                default:
                    throw new ApplicationException("Country Entity has no relation named " + relation);
                }
            }
        }
        public void DispatchForEntityCollection(IEnumerable <LocationDataObject> entities, List <string> includes, IObjectsDataSet context, Dictionary <string, object> parameters, bool skipSecurity = false)
        {
            // Remember includes we've already dispatched so as to avoid multiple data fetches
            var dispatched = new HashSet <string>();

            // get (custom) prefetch list so we can skip the dispatch for stuff we already fetched
            var prefetches = PrefetchAssociations.Get("Location", parameters);

            foreach (var include in includes)
            {
                string relation    = include.Split('.').First().ToLower();
                var    subincludes = DispatchPath.GetSubIncludes(relation, includes);

                if (relation.Contains(":"))
                {
                    relation = relation.Substring(relation.IndexOf(':') + 1);
                }

                if (dispatched.Contains(relation))
                {
                    continue;
                }

                dispatched.Add(relation);

                switch (relation)
                {
                case "placetolocationitems":
                {
                    // custom code can implement IPrefetch<ORMLocation> and add prefetch info through PrefetchAssociations helper => if set, we skip the dispatch-fetch
                    if (prefetches.Contains("PlaceToLocationItems"))
                    {
                        break;
                    }

                    var filterparameters = new object[] { entities.Select(e => e.URI).Distinct().ToArray() };
                    try
                    {
                        entities.First().ObjectsDataSet.Merge(PlaceToLocationDataProvider.GetCollection(null, "(@0.Contains(outerIt.LocationURI))", filterparameters, null, 0, 0, subincludes, context, parameters, skipSecurity).ObjectsDataSet);
                    }
                    catch (GOServerException e)
                    {
                        if (e.Reason != "accessDenied")
                        {
                            throw;
                        }
                    }
                    break;
                }

                default:
                    throw new ApplicationException("Location Entity has no relation named " + relation);
                }
            }
        }
コード例 #5
0
        protected void SetRelations(GOUserDataObject x)
        {
            var prefetches = PrefetchAssociations.Get("GOUser", ApplicationSettings.Resolve <IDataProviderTransaction>()?.Parameters);

            if (prefetches.Contains("UserRoleItems") && this.UserRoleItems.Count > 0)
            {
                var iter = this.UserRoleItems.GetEnumerator();

                while (iter.MoveNext())
                {
                    var userRoleItemsItem = x.ObjectsDataSet.GetObject(new GOUserRoleDataObject((System.String)iter.Current.GORoleName, (System.Guid)iter.Current.GOUserId)
                    {
                        IsNew = false
                    });

                    if (userRoleItemsItem == null)
                    {
                        userRoleItemsItem = iter.Current.ToDataObject(x.ObjectsDataSet) as GOUserRoleDataObject;
                    }

                    x.UserRoleItems.Add(userRoleItemsItem);
                }
            }

            if (prefetches.Contains("UserGroupItems") && this.UserGroupItems.Count > 0)
            {
                var iter = this.UserGroupItems.GetEnumerator();

                while (iter.MoveNext())
                {
                    var userGroupItemsItem = x.ObjectsDataSet.GetObject(new GOUserGroupDataObject((System.String)iter.Current.GOGroupName, (System.Guid)iter.Current.GOUserId)
                    {
                        IsNew = false
                    });

                    if (userGroupItemsItem == null)
                    {
                        userGroupItemsItem = iter.Current.ToDataObject(x.ObjectsDataSet) as GOUserGroupDataObject;
                    }

                    x.UserGroupItems.Add(userGroupItemsItem);
                }
            }
        }
コード例 #6
0
        protected void SetRelations(UserProfileDataObject x)
        {
            var prefetches = PrefetchAssociations.Get("UserProfile", ApplicationSettings.Resolve <IDataProviderTransaction>()?.Parameters);

            if (prefetches.Contains("GOUser") && this.GOUser != null)
            {
                var gOUser = x.ObjectsDataSet.GetObject(new GOUserDataObject((System.Guid) this.GOUser.Id)
                {
                    IsNew = false
                });

                if (gOUser == null)
                {
                    gOUser = this.GOUser.ToDataObject(x.ObjectsDataSet) as GOUserDataObject;
                }

                x.SetGOUserValue(gOUser);
            }
        }
 protected void SetRelations(GOLoginHistoryDataObject x)
 {
     var prefetches = PrefetchAssociations.Get("GOLoginHistory", ApplicationSettings.Resolve <IDataProviderTransaction>()?.Parameters);
 }