当前位置: 首页>>代码示例>>C#>>正文


C# DefinedValueService.Queryable方法代码示例

本文整理汇总了C#中Rock.Model.DefinedValueService.Queryable方法的典型用法代码示例。如果您正苦于以下问题:C# DefinedValueService.Queryable方法的具体用法?C# DefinedValueService.Queryable怎么用?C# DefinedValueService.Queryable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Rock.Model.DefinedValueService的用法示例。


在下文中一共展示了DefinedValueService.Queryable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: btnSaveStars_OnClick

        protected void btnSaveStars_OnClick(object sender, EventArgs e)
        {
            // ddl
            var x = Convert.ToInt32(ddlStars.SelectedItem.Value);

            DefinedValueService definedValueService = new DefinedValueService(rockContext);

            var definedValue = definedValueService.Queryable().FirstOrDefault(a => a.Id == x);
            definedValue.LoadAttributes();
            var attributeValue = definedValue.GetAttributeValue("StarValue");
            var starsValue = Convert.ToDecimal(attributeValue);

            var pa = Person.PrimaryAliasId;
            //var pa = ppPerson.PersonAliasId;
            //var value = Decimal.Parse(tbValue.Text);

            StarsService starsService = new StarsService(starsProjectContext);

            org.newpointe.Stars.Model.Stars stars = new org.newpointe.Stars.Model.Stars();

            stars.PersonAliasId = pa.GetValueOrDefault();
            stars.CampusId = 1;
            stars.TransactionDateTime = DateTime.Now;
            stars.Value = starsValue;
            stars.Note = ddlStars.SelectedItem.Text + ". Manually added by " + CurrentPerson.FullName;

            starsService.Add(stars);

            starsProjectContext.SaveChanges();

            //Refresh Page to update grids
            Response.Redirect(Request.RawUrl);
        }
开发者ID:NewPointe,项目名称:Rockit,代码行数:33,代码来源:AddStars.ascx.cs

示例2: LoadCacheObjects

        /// <summary>
        /// Loads the cache objects.
        /// </summary>
        private void LoadCacheObjects()
        {
            using ( new Rock.Data.UnitOfWorkScope() )
            {
                // Cache all the Field Types
                var fieldTypeService = new Rock.Model.FieldTypeService();
                foreach ( var fieldType in fieldTypeService.Queryable().ToList() )
                    Rock.Web.Cache.FieldTypeCache.Read( fieldType );

                // Cache all tha Defined Types
                var definedTypeService = new Rock.Model.DefinedTypeService();
                foreach ( var definedType in definedTypeService.Queryable().ToList() )
                    Rock.Web.Cache.DefinedTypeCache.Read( definedType );

                // Cache all the Defined Values
                var definedValueService = new Rock.Model.DefinedValueService();
                foreach ( var definedValue in definedValueService.Queryable().ToList() )
                    Rock.Web.Cache.DefinedValueCache.Read( definedValue );

                // Read all the qualifiers first so that EF doesn't perform a query for each attribute when it's cached
                var qualifiers = new Dictionary<int, Dictionary<string, string>>();
                foreach ( var attributeQualifier in new Rock.Model.AttributeQualifierService().Queryable() )
                {
                    if ( !qualifiers.ContainsKey( attributeQualifier.AttributeId ) )
                        qualifiers.Add( attributeQualifier.AttributeId, new Dictionary<string, string>() );
                    qualifiers[attributeQualifier.AttributeId].Add( attributeQualifier.Key, attributeQualifier.Value );
                }

                // Cache all the attributes.
                foreach ( var attribute in new Rock.Model.AttributeService().Queryable().ToList() )
                {
                    if ( qualifiers.ContainsKey( attribute.Id ) )
                        Rock.Web.Cache.AttributeCache.Read( attribute, qualifiers[attribute.Id] );
                    else
                        Rock.Web.Cache.AttributeCache.Read( attribute, new Dictionary<string, string>() );
                }
            }
        }
开发者ID:jh2mhs8,项目名称:Rock-ChMS,代码行数:41,代码来源:Global.asax.cs

示例3: gDefinedValues_GridReorder

        /// <summary>
        /// Handles the GridReorder event of the gDefinedValues control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="GridReorderEventArgs"/> instance containing the event data.</param>
        protected void gDefinedValues_GridReorder( object sender, GridReorderEventArgs e )
        {
            var definedType = DefinedTypeCache.Read( Rock.SystemGuid.DefinedType.PROTECT_MY_MINISTRY_PACKAGES.AsGuid() );
            if ( definedType != null )
            {
                var changedIds = new List<int>();

                using ( var rockContext = new RockContext() )
                {
                    var definedValueService = new DefinedValueService( rockContext );
                    var definedValues = definedValueService.Queryable().Where( a => a.DefinedTypeId == definedType.Id ).OrderBy( a => a.Order ).ThenBy( a => a.Value );
                    changedIds = definedValueService.Reorder( definedValues.ToList(), e.OldIndex, e.NewIndex );
                    rockContext.SaveChanges();
                }

                DefinedTypeCache.Flush( definedType.Id );
                foreach ( int id in changedIds )
                {
                    Rock.Web.Cache.DefinedValueCache.Flush( id );
                }
            }

            BindPackageGrid();
        }
开发者ID:RMRDevelopment,项目名称:Rockit,代码行数:29,代码来源:ProtectMyMinistrySettings.ascx.cs

示例4: BindGrid

        /// <summary>
        /// Binds the grid.
        /// </summary>
        private void BindGrid()
        {
            Guid externalApplicationGuid = Rock.SystemGuid.DefinedType.EXTERNAL_APPLICATION.AsGuid();

            var definedValueService = new DefinedValueService( new RockContext() );
            var queryable = definedValueService.Queryable().Where( f => f.DefinedType.Guid == externalApplicationGuid );

            var sortProperty = gExternalApplication.SortProperty;

            List<DefinedValue> list;

            if ( sortProperty != null )
            {
                list = queryable.Sort( sortProperty ).ToList();
            }
            else
            {
                list = queryable.OrderBy( d => d.Order).ThenBy( d => d.Value ).ToList();
            }

            foreach ( var item in list )
            {
                item.LoadAttributes();
            }

            gExternalApplication.DataSource = list;

            gExternalApplication.DataBind();
        }
开发者ID:tcavaletto,项目名称:Rock-CentralAZ,代码行数:32,代码来源:ExternalApplicationList.ascx.cs

示例5: gDefinedValues_GridReorder

        /// <summary>
        /// Handles the GridReorder event of the gDefinedValues control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="GridReorderEventArgs"/> instance containing the event data.</param>
        private void gDefinedValues_GridReorder( object sender, GridReorderEventArgs e )
        {
            int definedTypeId = hfDefinedTypeId.ValueAsInt();
            DefinedTypeCache.Flush( definedTypeId );

            var rockContext = new RockContext();
            var definedValueService = new DefinedValueService( rockContext );
            var definedValues = definedValueService.Queryable().Where( a => a.DefinedTypeId == definedTypeId ).OrderBy( a => a.Order ).ThenBy( a => a.Name);
            var changedIds = definedValueService.Reorder( definedValues.ToList(), e.OldIndex, e.NewIndex );
            rockContext.SaveChanges();

            Rock.Web.Cache.DefinedTypeCache.Flush( definedTypeId );
            foreach(int id in changedIds)
            {
                Rock.Web.Cache.DefinedValueCache.Flush( id );
            }

            BindDefinedValuesGrid();
        }
开发者ID:CentralAZ,项目名称:Rockit-CentralAZ,代码行数:24,代码来源:DefinedValueList.ascx.cs

示例6: CrossroadsSportsCampYears

        //using this to enter the Connect Group Seasons GUID of a defined Year that is already in Rock
        private string CrossroadsSportsCampYears( DateTime? f1StartDate, string playVol )
        {
            DateTime startDate = (DateTime)f1StartDate;

            var lookupContext = new RockContext();
            var dvService = new DefinedValueService( lookupContext );
            var dtService = new DefinedTypeService( lookupContext );

            var yearInList = new DefinedValue();
            int dtInList; //= new DefinedType();

            var yearMultiSelectDefinedType = dtService.Queryable()
                .Where( dt => dt.Name == "Crossroads Sports Camp Years" ).ToList(); //finds all rows in Defined Type with this name (only one present)
            dtInList = yearMultiSelectDefinedType.Where( dt => dt.Name == "Crossroads Sports Camp Years" ) //sets the above Defined Type ID to this variable.
                .Select( dt => dt.Id ).FirstOrDefault();

            var existingDefinedYears = dvService.Queryable()
                .Where( dv => dv.DefinedTypeId == dtInList ).ToList();  //finds all Definded Values with the Defined Type ID from the item above.

            string guid = string.Format( "{0}", existingDefinedYears.Where( dt => dt.Value == string.Format( "{0} ({1})", startDate.Year, playVol ) ).Select( dt => dt.Guid ).FirstOrDefault() ); //the value that will be returned. Takes on two properties, the start date and the second word (Play) etc.

            return guid;
        }
开发者ID:BEGamache,项目名称:Excavator,代码行数:24,代码来源:Attributes.cs

示例7: dlgLink_SaveClick

        /// <summary>
        /// Handles the SaveClick event of the dlgLink control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void dlgLink_SaveClick( object sender, EventArgs e )
        {
            DefinedValue definedValue = null;
            using ( var rockContext = new RockContext() )
            {
                var service = new DefinedValueService( rockContext );
                int? definedValueId = hfDefinedValueId.Value.AsIntegerOrNull();
                if ( definedValueId.HasValue )
                {
                    definedValue = service.Get( definedValueId.Value );
                }

                if ( definedValue == null )
                {
                    definedValue = new DefinedValue { Id = 0 };
                    definedValue.DefinedTypeId = _definedType.Id;
                    definedValue.IsSystem = false;

                    var orders = service.Queryable()
                        .Where( d => d.DefinedTypeId == _definedType.Id )
                        .Select( d => d.Order )
                        .ToList();

                    definedValue.Order = orders.Any() ? orders.Max() + 1 : 0;
                }

                definedValue.Value = tbTitle.Text;
                definedValue.Description = tbLink.Text;
                definedValue.LoadAttributes();
                definedValue.SetAttributeValue( "IsLink", ( rblLinkType.SelectedValue == "Link" ).ToString() );

                rockContext.WrapTransaction( () =>
                {
                    if ( definedValue.Id.Equals( 0 ) )
                    {
                        service.Add( definedValue );
                    }

                    rockContext.SaveChanges();

                    definedValue.SaveAttributeValues( rockContext );

                } );

                Rock.Web.Cache.DefinedTypeCache.Flush( definedValue.DefinedTypeId );
                Rock.Web.Cache.DefinedValueCache.Flush( definedValue.Id );
            }

            HideDialog();

            BindGrid();
        }
开发者ID:NewPointe,项目名称:Rockit,代码行数:57,代码来源:LinkListLava.ascx.cs

示例8: MapAttendance

        /// <summary>
        /// Maps the attendance.
        /// </summary>
        /// <param name="tableData">The table data.</param>
        /// <returns></returns>
        //private DateTime? StartDateTime { get; set;}
        private void MapAttendance( IQueryable<Row> tableData )
        {
            var lookupContext = new RockContext();
            int completed = 0;
            int totalRows = tableData.Count();
            int percentage = ( totalRows - 1 ) / 100 + 1;
            ReportProgress( 0, string.Format( "Verifying Attendance import ({0:N0} found).", totalRows ) );

            var attendanceList = new List<Rock.Model.Attendance>();
            var groupService = new GroupService( lookupContext );
            var existingGroupList = new List<Group>();
            existingGroupList = groupService.Queryable().ToList();

            foreach ( var row in tableData )
            {

                   DateTime? startTime = row["Start_Date_Time"] as DateTime?;
                if ( startTime != null && startTime != DateTime.MinValue)
                {
                    DateTime startDateTime = (DateTime)startTime;
                    if ( startDateTime.Year == 2014 && startDateTime.Month >= 1 && startDateTime.Month <= 8 )
                    {

                    //startDateTime = BruteForceDateTime(startTime);

                    var attendance = new Rock.Model.Attendance();
                    attendance.CreatedByPersonAliasId = ImportPersonAlias.Id;
                    attendance.ModifiedByPersonAliasId = ImportPersonAlias.Id;
                    attendance.CreatedDateTime = DateTime.Today;
                    attendance.ModifiedDateTime = DateTime.Today;
                    attendance.StartDateTime = startDateTime; //(DateTime)startTime;
                    attendance.DidAttend = true;
                    attendance.CampusId = 1; //Campus is needed for attendance to show in attendance analysis.

                    //string position = row["CheckedInAs"] as string;
                    //string jobTitle = row["Job_Title"] as string;
                    //string machineName = row["Checkin_Machine_Name"] as string;
                    int? rlcId = row["RLC_ID"] as int?;

                    int? individualId = row["Individual_ID"] as int?;

                        if ( individualId != null )
                        {
                            attendance.PersonAliasId = GetPersonAliasId( individualId );
                        }

                        DateTime? checkInTime = row["Check_In_Time"] as DateTime?;
                        if ( checkInTime != null )
                        {
                            // set the start time to the time they actually checked in. If null it maintains Start_Date_Time
                            attendance.StartDateTime = (DateTime)checkInTime; //BruteForceDateTime( checkInTime );
                        }

                        DateTime? checkOutTime = row["Check_Out_Time"] as DateTime?;
                        if ( checkOutTime != null )
                        {
                            attendance.EndDateTime = (DateTime)checkOutTime; //BruteForceDateTime( checkOutTime );
                        }

                        //string f1AttendanceCode = row["Tag_Code"] as string;
                        //if ( f1AttendanceCode != null )
                        //{
                        //    attendance.AttendanceCode = new Rock.Model.AttendanceCode();
                        //    attendance.AttendanceCode.Code = f1AttendanceCode;
                        //}
                        string f1AttendanceCheckedInAs = row["CheckedInAs"] as string;
                        if ( f1AttendanceCheckedInAs != null )
                        {
                            attendance.Note = f1AttendanceCheckedInAs;
                        }

                        // look up location, schedule, and device -- all of these fields can be null if need be
                        attendance.LocationId = GetLocationId( Convert.ToInt32( rlcId ) );

                        //look up Group
                        Group rlcGroup = existingGroupList.Where( g => g.ForeignId == ( rlcId.ToString() ) ).FirstOrDefault();
                        if ( rlcGroup != null )
                        {
                            attendance.GroupId = rlcGroup.Id;
                        }

                        var dvService = new DefinedValueService( lookupContext );

                        attendance.SearchTypeValueId = dvService.Queryable().Where( dv => dv.Value == "Phone Number" ).FirstOrDefault().Id;

                        //ReportProgress( 0, string.Format( "{0},{1},{2},{3},{4},{5},{6},{7},{8}", individualId,rlcId,rlcGroup.Name,attendance.CreatedByPersonAliasId,attendance.ModifiedByPersonAliasId,attendance.StartDateTime,attendance.DidAttend,attendance.AttendanceCode,attendance.LocationId ) );

                        //look into creating DeviceIds and Locations (Generic)

                        // Other Attributes to create:
                        // Tag_Comment
                        // BreakoutGroup_Name
                        // Pager_Code

//.........这里部分代码省略.........
开发者ID:BEGamache,项目名称:Excavator,代码行数:101,代码来源:Attendance.cs

示例9: MapGroupsAttendance

        /// <summary>
        /// Maps the group attendance.
        /// </summary>
        /// <param name="tableData">The table data.</param>
        /// <returns></returns>
        //private DateTime? StartDateTime { get; set;}
        private void MapGroupsAttendance( IQueryable<Row> tableData )
        {
            var lookupContext = new RockContext();
            int completed = 0;
            int totalRows = tableData.Count();
            int percentage = ( totalRows - 1 ) / 100 + 1;
            ReportProgress( 0, string.Format( "Verifying Attendance import ({0:N0} found).", totalRows ) );

            var attendanceList = new List<Rock.Model.Attendance>();

            var groupService = new GroupService( lookupContext );
            var existingGroupList = new List<Group>();
            existingGroupList = groupService.Queryable().Where(g => g.ForeignId != null).ToList();

            foreach ( var row in tableData )
            {

                DateTime? startTime = row["StartDateTime"] as DateTime?;
                if ( startTime != null && startTime != DateTime.MinValue )
                {
                    int? groupId = row["GroupID"] as int?;
                    if ( existingGroupList.Find(g => g.ForeignId == groupId.ToString()) != null ) //making sure the group has been created.
                    {
                    DateTime startDateTime = (DateTime)startTime;
                    DateTime? endTime = row["EndDateTime"] as DateTime?;
                    int? met = row["Met"] as int?;
                    bool didAttend = true;
                    if ( met == 0 ) { didAttend = false; }
                    string comments = row["Comments"] as string;

                        var attendance = new Rock.Model.Attendance();
                        attendance.CreatedByPersonAliasId = ImportPersonAlias.Id;
                        attendance.ModifiedByPersonAliasId = ImportPersonAlias.Id;
                        attendance.CreatedDateTime = DateTime.Today;
                        attendance.ModifiedDateTime = DateTime.Today;
                        attendance.StartDateTime = startDateTime;
                        attendance.EndDateTime = endTime;
                        attendance.DidAttend = didAttend;
                        attendance.Note = comments;
                        attendance.CampusId = 1; //Campus is needed for attendance to show in attendance analysis.
                        attendance.GroupId = existingGroupList.Find( g => g.ForeignId == groupId.ToString() ).Id;

                        int? individualId = row["IndividualID"] as int?;

                        if ( individualId != null )
                        {
                            attendance.PersonAliasId = GetPersonAliasId( individualId );
                        }

                        ////look up Group
                        //int? groupId = row["GroupID"] as int?;

                        //Group group = existingGroupList.Where( g => g.ForeignId == ( groupId.ToString() ) ).FirstOrDefault();
                        //if ( group != null )
                        //{
                        //    attendance.GroupId = group.Id;
                        //}

                    //no other search type right now; small group attendance not currently set up in Rock.
                        var dvService = new DefinedValueService( lookupContext );

                        attendance.SearchTypeValueId = dvService.Queryable().Where( dv => dv.Value == "Phone Number" ).FirstOrDefault().Id;

                        completed++;
                        if ( completed % percentage < 1 )
                        {
                            int percentComplete = completed / percentage;
                            ReportProgress( percentComplete, string.Format( "Completed: {0:N0} Percent Completed: {0:N0} ", completed, percentComplete ) );
                        }

                        var rockContext = new RockContext();
                        rockContext.WrapTransaction( () =>
                        {
                            rockContext.Configuration.AutoDetectChangesEnabled = false;

                            rockContext.Attendances.Add( attendance );
                            rockContext.SaveChanges( DisableAudit );
                        } );

                        ReportPartialProgress();
                }
            }
            }
        }
开发者ID:CrossroadsChristian,项目名称:Excavator,代码行数:90,代码来源:GroupsAttendance.cs

示例10: LoadCacheObjects

        /// <summary>
        /// Loads the cache objects.
        /// </summary>
        private void LoadCacheObjects( RockContext rockContext )
        {
            // Read all the qualifiers first so that EF doesn't perform a query for each attribute when it's cached
            var qualifiers = new Dictionary<int, Dictionary<string, string>>();
            foreach ( var attributeQualifier in new Rock.Model.AttributeQualifierService( rockContext ).Queryable() )
            {
                if ( !qualifiers.ContainsKey( attributeQualifier.AttributeId ) )
                    qualifiers.Add( attributeQualifier.AttributeId, new Dictionary<string, string>() );
                qualifiers[attributeQualifier.AttributeId].Add( attributeQualifier.Key, attributeQualifier.Value );
            }

            // Cache all the attributes.
            foreach ( var attribute in new Rock.Model.AttributeService( rockContext ).Queryable( "Categories" ).ToList() )
            {
                if ( qualifiers.ContainsKey( attribute.Id ) )
                    Rock.Web.Cache.AttributeCache.Read( attribute, qualifiers[attribute.Id] );
                else
                    Rock.Web.Cache.AttributeCache.Read( attribute, new Dictionary<string, string>() );
            }

            // Cache all the Field Types
            var all = Rock.Web.Cache.FieldTypeCache.All();

            // DT: When running with production CCV Data, this is taking a considerable amount of time

            // Cache all tha Defined Types
            var definedTypeService = new Rock.Model.DefinedTypeService( rockContext );
            foreach ( var definedType in definedTypeService.Queryable().ToList() )
            {
                Rock.Web.Cache.DefinedTypeCache.Read( definedType );
            }

            // Cache all the Defined Values
            var definedValueService = new Rock.Model.DefinedValueService( rockContext );
            foreach ( var definedValue in definedValueService.Queryable().ToList() )
            {
                Rock.Web.Cache.DefinedValueCache.Read( definedValue );
            }
        }
开发者ID:CentralAZ,项目名称:Rockit-CentralAZ,代码行数:42,代码来源:Global.asax.cs

示例11: MapPerson

        /// <summary>
        /// Maps the person.
        /// </summary>
        /// <param name="tableData">The table data.</param>
        /// <param name="selectedColumns">The selected columns.</param>
        private void MapPerson( IQueryable<Row> tableData, List<string> selectedColumns = null )
        {
            var lookupContext = new RockContext();
            var groupTypeRoleService = new GroupTypeRoleService( lookupContext );
            var dvService = new DefinedValueService( lookupContext );

            var schoolList = new List<DefinedValue>();
            var newSchool = new DefinedValue();
            var existingSchoolLookUp = dvService.Queryable()
                .Where( dv => dv.DefinedTypeId == 34 ).ToList();

            // Marital statuses: Married, Single, Separated, etc
            var maritalStatusTypes = DefinedTypeCache.Read( new Guid( Rock.SystemGuid.DefinedType.PERSON_MARITAL_STATUS ), lookupContext ).DefinedValues;

            // Connection statuses: Member, Visitor, Attendee, etc
            var connectionStatusTypes = DefinedTypeCache.Read( new Guid( Rock.SystemGuid.DefinedType.PERSON_CONNECTION_STATUS ), lookupContext ).DefinedValues;

            // Record status reasons: No Activity, Moved, Deceased, etc
            var recordStatusReasons = DefinedTypeCache.Read( new Guid( Rock.SystemGuid.DefinedType.PERSON_RECORD_STATUS_REASON ), lookupContext ).DefinedValues;

            // Record statuses: Active, Inactive, Pending
            int? recordStatusActiveId = DefinedValueCache.Read( new Guid( Rock.SystemGuid.DefinedValue.PERSON_RECORD_STATUS_ACTIVE ), lookupContext ).Id;
            int? recordStatusInactiveId = DefinedValueCache.Read( new Guid( Rock.SystemGuid.DefinedValue.PERSON_RECORD_STATUS_INACTIVE ), lookupContext ).Id;
            int? recordStatusPendingId = DefinedValueCache.Read( new Guid( Rock.SystemGuid.DefinedValue.PERSON_RECORD_STATUS_PENDING ), lookupContext ).Id;

            // Record type: Person
            int? personRecordTypeId = DefinedValueCache.Read( new Guid( Rock.SystemGuid.DefinedValue.PERSON_RECORD_TYPE_PERSON ), lookupContext ).Id;

            // Suffix type: Dr., Jr., II, etc
            var suffixTypes = DefinedTypeCache.Read( new Guid( Rock.SystemGuid.DefinedType.PERSON_SUFFIX ) ).DefinedValues;

            // Title type: Mr., Mrs. Dr., etc
            var titleTypes = DefinedTypeCache.Read( new Guid( Rock.SystemGuid.DefinedType.PERSON_TITLE ), lookupContext ).DefinedValues;

            // Note type: Comment
            int noteCommentTypeId = new NoteTypeService( lookupContext ).Get( new Guid( "7E53487C-D650-4D85-97E2-350EB8332763" ) ).Id;

            // Group roles: Owner, Adult, Child, others
            GroupTypeRole ownerRole = groupTypeRoleService.Get( new Guid( Rock.SystemGuid.GroupRole.GROUPROLE_KNOWN_RELATIONSHIPS_OWNER ) );
            int adultRoleId = groupTypeRoleService.Get( new Guid( Rock.SystemGuid.GroupRole.GROUPROLE_FAMILY_MEMBER_ADULT ) ).Id;
            int childRoleId = groupTypeRoleService.Get( new Guid( Rock.SystemGuid.GroupRole.GROUPROLE_FAMILY_MEMBER_CHILD ) ).Id;
            int inviteeRoleId = groupTypeRoleService.Get( new Guid( Rock.SystemGuid.GroupRole.GROUPROLE_KNOWN_RELATIONSHIPS_INVITED ) ).Id;
            int invitedByRoleId = groupTypeRoleService.Get( new Guid( Rock.SystemGuid.GroupRole.GROUPROLE_KNOWN_RELATIONSHIPS_INVITED_BY ) ).Id;
            int canCheckInRoleId = groupTypeRoleService.Get( new Guid( Rock.SystemGuid.GroupRole.GROUPROLE_KNOWN_RELATIONSHIPS_CAN_CHECK_IN ) ).Id;
            int allowCheckInByRoleId = groupTypeRoleService.Get( new Guid( Rock.SystemGuid.GroupRole.GROUPROLE_KNOWN_RELATIONSHIPS_ALLOW_CHECK_IN_BY ) ).Id;

            // Group type: Family
            int familyGroupTypeId = new GroupTypeService( lookupContext ).Get( new Guid( Rock.SystemGuid.GroupType.GROUPTYPE_FAMILY ) ).Id;

            // Look up additional Person attributes (existing)
            var personAttributes = new AttributeService( lookupContext ).GetByEntityTypeId( PersonEntityTypeId ).ToList();

            // Cached F1 attributes: IndividualId, HouseholdId
            // Core attributes: PreviousChurch, Position, Employer, School
            var individualIdAttribute = AttributeCache.Read( personAttributes.FirstOrDefault( a => a.Key == "F1IndividualId" ) );
            var householdIdAttribute = AttributeCache.Read( personAttributes.FirstOrDefault( a => a.Key == "F1HouseholdId" ) );
            var previousChurchAttribute = AttributeCache.Read( personAttributes.FirstOrDefault( a => a.Key == "PreviousChurch" ) );
            var employerAttribute = AttributeCache.Read( personAttributes.FirstOrDefault( a => a.Key == "Employer" ) );
            var positionAttribute = AttributeCache.Read( personAttributes.FirstOrDefault( a => a.Key == "Position" ) );
            var firstVisitAttribute = AttributeCache.Read( personAttributes.FirstOrDefault( a => a.Key == "FirstVisit" ) );
            var schoolAttribute = AttributeCache.Read( personAttributes.FirstOrDefault( a => a.Key == "School" ) );
            var membershipDateAttribute = AttributeCache.Read( personAttributes.FirstOrDefault( a => a.Key == "MembershipDate" ) );

            var familyList = new List<Group>();
            var visitorList = new List<Group>();

            int completed = 0;
            int totalRows = tableData.Count();
            int percentage = ( totalRows - 1 ) / 100 + 1;
            ReportProgress( 0, string.Format( "Verifying person import ({0:N0} found, {1:N0} already exist).", totalRows, ImportedPeople.Count() ) );

            foreach ( var groupedRows in tableData.GroupBy<Row, int?>( r => r["Household_ID"] as int? ) )
            {
                var familyGroup = new Group();
                var householdCampusList = new List<string>();

                foreach ( var row in groupedRows )
                {
                    bool isFamilyRelationship = true;
                    string currentCampus = string.Empty;
                    int? individualId = row["Individual_ID"] as int?;
                    int? householdId = row["Household_ID"] as int?;
                    if ( GetPersonAliasId( individualId, householdId ) == null )
                    {
                        var person = new Person();
                        person.FirstName = row["First_Name"] as string;
                        person.MiddleName = row["Middle_Name"] as string;
                        person.NickName = row["Goes_By"] as string ?? person.FirstName;
                        person.LastName = row["Last_Name"] as string;
                        person.BirthDate = row["Date_Of_Birth"] as DateTime?;
                        person.CreatedByPersonAliasId = ImportPersonAlias.Id;
                        person.RecordTypeValueId = personRecordTypeId;
                        person.ForeignId = individualId.ToString();
                        int groupRoleId = adultRoleId;

//.........这里部分代码省略.........
开发者ID:CrossroadsChristian,项目名称:Excavator,代码行数:101,代码来源:People.cs

示例12: checkSchool

        /// <summary>
        /// Check DB if school already listed in Defined Value
        /// </summary>
        /// <param name="school">The School Name</param>
        /// <returns>School ID as string</returns>
        private string checkSchool( string school )
        {
            var lookupContext = new RockContext();
            var dvService = new DefinedValueService( lookupContext );

            var dtService = new DefinedTypeService( lookupContext );
            int schoolDefinedTypeId = dtService.Queryable().Where( dt => dt.Name == "School" ).FirstOrDefault().Id;

            var schoolList = new List<DefinedValue>();
            var checkedSchool = new DefinedValue();
            //var schoolAttribute = AttributeCache.Read( personAttributes.FirstOrDefault( a => a.Key == "School" ) );

            //Checks if school is in DB
            //Gets Defined Type and seaches Defined Values for the schoolDefinedTypeId
            schoolList = dvService.Queryable()
                .Where( dv => dv.DefinedTypeId == schoolDefinedTypeId ).ToList(); //Defined Type should equal 34 (CCC)
            //Gets school info if it is present in DB
            checkedSchool = schoolList.Where(s => s.Value == school.Trim()).FirstOrDefault();

            int count = 0;
            //If it isn't in the DB it will add it.
            while ( checkedSchool == null )
            {
                var newSchool = new DefinedValue();
                var newSchoolList = new List<DefinedValue>();

                newSchool.IsSystem = false;
                newSchool.DefinedTypeId = 34;
                newSchool.Order = 0;
                newSchool.Value = school.Trim();
                newSchool.Guid = new Guid();

                newSchoolList.Add( newSchool );

                var rockContext = new RockContext();
                rockContext.WrapTransaction( () =>
                {
                    rockContext.Configuration.AutoDetectChangesEnabled = false;
                    rockContext.DefinedValues.AddRange( newSchoolList );
                    rockContext.SaveChanges( DisableAudit );
                } );

                ReportProgress( 0, string.Format( "New School Added: {0}.", school.Trim() ) );

                count++;

                if ( count > 3 )
                {
                    ReportProgress( 0, string.Format( "Stuck in Loop and school is not being added properly.", school.Trim() ) );
                    return "173";
                }

            }

            //If School is already in Defined Value Table, its Id is returned.
            return Convert.ToString(checkedSchool.Id);

            throw new NotImplementedException();
        }
开发者ID:CrossroadsChristian,项目名称:Excavator,代码行数:64,代码来源:People.cs

示例13: MapIndividualGiftedness

        /// <summary>
        /// Maps the Individual Giftedness.
        /// </summary>
        /// <param name="tableData">The table data.</param>
        private void MapIndividualGiftedness( IQueryable<Row> tableData )
        {
            var lookupContext = new RockContext();
            var attributeService = new AttributeService( lookupContext );

            int rank1Id = attributeService.Queryable().Where( a => a.Key == "Rank1" ).FirstOrDefault().Id;
            int rank2Id = attributeService.Queryable().Where( a => a.Key == "Rank2" ).FirstOrDefault().Id;
            int rank3Id = attributeService.Queryable().Where( a => a.Key == "Rank3" ).FirstOrDefault().Id;
            int rank4Id = attributeService.Queryable().Where( a => a.Key == "Rank4" ).FirstOrDefault().Id;

            int completed = 0;
            int totalRows = tableData.Count();
            int percentage = ( totalRows - 1 ) / 100 + 1;
            ReportProgress( 0, string.Format( "Verifying Giftedness Program import ({0:N0} found).", totalRows ) );

            var newAttributeValueList = new List<AttributeValue>();

            foreach ( var row in tableData )
            {
                int? individualId = row["Individual_ID"] as int?;
                int personId = (int)GetPersonAliasId( individualId );
                var newAttributeValue = new AttributeValue();
                int? rank = row["Rank"] as int?;
                int rankId = 0;

                //not everyone has all 4 ranks, some are missing the fourth and that was causing it to run in the below if condition and try to create a duplicate record.
                if ( rank == 1 ) { rankId = rank1Id; }
                if ( rank == 2 ) { rankId = rank2Id; }
                if ( rank == 3 ) { rankId = rank3Id; }
                if ( rank == 4 ) { rankId = rank4Id; }

                if ( personId != 0 && rankId != 0 )
                {
                    var attributeValueService = new AttributeValueService( lookupContext );

                    //checks if they are in the database already or if there is a record currently in the newAttributeValueList
                    if ( attributeValueService.Queryable().Where( a => a.AttributeId == rankId && a.EntityId == personId ).FirstOrDefault() == null && newAttributeValueList.Find(a => a.AttributeId == rankId && a.EntityId == personId) == null )
                    {

                        DateTime? assessmentDate = row["AssessmentDate"] as DateTime?;
                        int? giftAttributeId = row["GiftAttributeID"] as int?;
                        string giftAttributeIdString = Convert.ToString( giftAttributeId );

                        var definedValueService = new DefinedValueService( lookupContext );

                        newAttributeValue.IsSystem = false;
                        newAttributeValue.EntityId = personId;

                        if ( rank == 1 ) { newAttributeValue.AttributeId = rank1Id; }
                        if ( rank == 2 ) { newAttributeValue.AttributeId = rank2Id; }
                        if ( rank == 3 ) { newAttributeValue.AttributeId = rank3Id; }
                        if ( rank == 4 ) { newAttributeValue.AttributeId = rank4Id; }

                        newAttributeValue.Value = Convert.ToString( definedValueService.Queryable().Where( a => a.ForeignId == giftAttributeIdString ).FirstOrDefault().Guid );
                        newAttributeValue.CreatedDateTime = assessmentDate;

                        newAttributeValueList.Add( newAttributeValue );
                        completed++;
                    }
                }
                if ( newAttributeValueList.Any() )
                {
                    if ( completed % percentage < 1 )
                    {
                        int percentComplete = completed / percentage;
                        ReportProgress( percentComplete, string.Format( "{0:N0} spiritual gifts imported ({1}% complete).", completed, percentComplete ) );
                    }
                    else if ( completed % ReportingNumber < 1 )
                    {
                        var rockContext = new RockContext();
                        rockContext.WrapTransaction( () =>
                        {
                            rockContext.Configuration.AutoDetectChangesEnabled = false;
                            rockContext.AttributeValues.AddRange( newAttributeValueList );
                            rockContext.SaveChanges( DisableAudit );
                            newAttributeValueList.Clear();
                        } );
                        ReportPartialProgress();
                    }
                }
            }

            if ( newAttributeValueList.Any() )
            {
                var rockContext = new RockContext();
                rockContext.WrapTransaction( () =>
                {
                    rockContext.Configuration.AutoDetectChangesEnabled = false;
                    rockContext.AttributeValues.AddRange( newAttributeValueList );
                    rockContext.SaveChanges( DisableAudit );
                } );
            }

            ReportProgress( 100, string.Format( "Finished individual gifts import: {0:N0} spiritual gifts imported.", completed ) );
        }
开发者ID:CrossroadsChristian,项目名称:Excavator,代码行数:99,代码来源:Giftedness.cs

示例14: gLinks_GridReorder

        /// <summary>
        /// Handles the GridReorder event of the gLinks control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="GridReorderEventArgs"/> instance containing the event data.</param>
        void gLinks_GridReorder( object sender, GridReorderEventArgs e )
        {
            using ( var rockContext = new RockContext() )
            {
                var service = new DefinedValueService( rockContext );
                var definedValues = service.Queryable().Where( a => a.DefinedTypeId == _definedType.Id ).OrderBy( a => a.Order ).ThenBy( a => a.Value );
                var changedIds = service.Reorder( definedValues.ToList(), e.OldIndex, e.NewIndex );
                rockContext.SaveChanges();

                foreach ( int id in changedIds )
                {
                    Rock.Web.Cache.DefinedValueCache.Flush( id );
                }
            }

            DefinedTypeCache.Flush( _definedType.Id );

            BindGrid();
        }
开发者ID:NewPointe,项目名称:Rockit,代码行数:24,代码来源:LinkListLava.ascx.cs

示例15: btnSaveValue_Click

        /// <summary>
        /// Handles the Click event of the btnSaveDefinedValue control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        protected void btnSaveValue_Click( object sender, EventArgs e )
        {
            DefinedValue definedValue;
            DefinedValueService definedValueService = new DefinedValueService();

            int definedValueId = hfDefinedValueId.ValueAsInt();

            if ( definedValueId.Equals( 0 ) )
            {
                int definedTypeId = hfDefinedTypeId.ValueAsInt();
                definedValue = new DefinedValue { Id = 0 };
                definedValue.DefinedTypeId = definedTypeId;
                definedValue.IsSystem = false;

                var orders = definedValueService.Queryable()
                    .Where( d => d.DefinedTypeId == definedTypeId )
                    .Select( d => d.Order)
                    .ToList();
                
                definedValue.Order = orders.Any() ? orders.Max() + 1 : 0;
            }
            else
            {
                definedValue = definedValueService.Get( definedValueId );
            }

            definedValue.Name = tbValueName.Text;
            definedValue.Description = tbValueDescription.Text;
            definedValue.LoadAttributes();
            Rock.Attribute.Helper.GetEditValues( phDefinedValueAttributes, definedValue );

            if ( !Page.IsValid )
            {
                return;
            }

            if ( !definedValue.IsValid )
            {
                // Controls will render the error messages                    
                return;
            }

            RockTransactionScope.WrapTransaction( () =>
            {
                if ( definedValue.Id.Equals( 0 ) )
                {
                    definedValueService.Add( definedValue, CurrentPersonId );
                }

                definedValueService.Save( definedValue, CurrentPersonId );
                Rock.Attribute.Helper.SaveAttributeValues( definedValue, CurrentPersonId );

                Rock.Web.Cache.DefinedTypeCache.Flush( definedValue.DefinedTypeId );
                Rock.Web.Cache.DefinedValueCache.Flush( definedValue.Id );
            } );
                        
            BindDefinedValuesGrid();

            hfDefinedValueId.Value = string.Empty;
            modalValue.Hide();
        }
开发者ID:pkdevbox,项目名称:Rock,代码行数:66,代码来源:DefinedValueList.ascx.cs


注:本文中的Rock.Model.DefinedValueService.Queryable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。