示例#1
0
        public void SetConfigurationDefinedValue(Rock.Client.DefinedValue configDefinedValue, ConfigurationSet onConfigSet)
        {
            // extract the config template from the defined value
            ConfigurationTemplate configTemplate = ConfigurationTemplate.Template(configDefinedValue);

            configTemplate.VisualSettings.RemoveDownloadedImages( );

            // first get the theme images
            configTemplate.VisualSettings.DownloadImages(RockApi.BaseUrl,
                                                         delegate(bool imageResult)
            {
                if (imageResult == true)
                {
                    // start by sorting our attributes so we get the defined values correctly
                    configTemplate.SortAttributeLists( );

                    // get the family attribute definitions
                    DownloadAttributeDefinitions(configTemplate.FamilyAttributes, delegate(List <Rock.Client.Attribute> familyAttribDefines)
                    {
                        if (familyAttribDefines != null)
                        {
                            // finally, download the PERSON attribute definitions
                            DownloadAttributeDefinitions(configTemplate.PersonAttributes, delegate(List <Rock.Client.Attribute> personAttribDefines)
                            {
                                // it worked! we're done.
                                if (personAttribDefines != null)
                                {
                                    // it all worked, so store our values and save!
                                    CurrentConfigurationTemplate = configDefinedValue;

                                    _Instance.FamilyAttributeDefines = familyAttribDefines;
                                    _Instance.PersonAttributeDefines = personAttribDefines;

                                    // save to the device
                                    SaveToDevice( );
                                }

                                // and either way, return the result
                                onConfigSet(personAttribDefines != null ? true : false);
                            });
                        }
                        // failed to download family attributes
                        else
                        {
                            onConfigSet(false);
                        }
                    });
                }
                // failed to get the images
                else
                {
                    onConfigSet(false);
                }
            });
        }