Пример #1
0
        protected void ApplyBtnClick(object sender, EventArgs e)
        {
            if (!Page.IsValid)
            {
                ShowErrorMessage("Invalid Data");
                return;
            }

            try
            {
                spConfig.SyncEnabled     = cbSyncEnable.Checked;
                spConfig.FarmSyncEnabled = cbFarmSyncEnable.Checked;

                spConfig.SiteProfileMappedFields = new List <UserFieldMapping>();
                ProcessPostedData(spConfig.SiteProfileMappedFields, hdnSiteProfileFieldsMap.Value);

                spConfig.FarmProfileMappedFields = new List <UserFieldMapping>();
                ProcessPostedData(spConfig.FarmProfileMappedFields, hdnFarmProfileFieldsMap.Value);

                // Save Configuration to a syncSettings object
                spSyncSettings.SyncConfig = new SPBaseConfig
                {
                    FarmProfileMappedFields = spConfig.FarmProfileMappedFields,
                    SiteProfileMappedFields = spConfig.SiteProfileMappedFields,
                    SyncEnabled             = spConfig.SyncEnabled,
                    FarmSyncEnabled         = spConfig.FarmSyncEnabled
                };

                BindDropDownListData(ddlSPSiteProfileFields, spConfig.SiteProfileFields.OrderBy(f => f.Title).ToList(), f => String.Format("{0} - {1}", f.Title, f.Name));
                BindDropDownListData(ddlSPFarmProfileFields, spConfig.FarmProfileFields.OrderBy(f => f.Title), f => f.Title);
                BindDropDownListData(ddlTEProfileFields, TEUserProfileFieldsHelper.GetFields().OrderBy(f => f.Name).ToList(), f => f.Name);

                const string script = @"setTimeout(function(){{parent.window.frames[0].AddSyncSettings('{0}');}},100);";
                CSControlUtility.Instance().RegisterClientScriptBlock(this, GetType(), "applychildwindow", string.Format(script, JavaScript.Encode(spSyncSettings.ToXml())), true);
            }
            catch (Exception ex)
            {
                ShowErrorMessage(ex.Message);
                SPLog.RoleOperationUnavailable(ex, ex.Message);
            }
        }
Пример #2
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            if (!IsPostBack)
            {
                try
                {
                    // Data Binding
                    cbSyncEnable.Checked     = spConfig.SyncEnabled;
                    cbFarmSyncEnable.Checked = spConfig.FarmSyncEnabled;
                    BindDropDownListData(ddlSPSiteProfileFields, spConfig.SiteProfileFields.OrderBy(f => f.Title).ToList(), f => f.Title);
                    BindDropDownListData(ddlSPFarmProfileFields, spConfig.FarmProfileFields.OrderBy(f => f.Title), f => f.Title);
                    BindDropDownListData(ddlTEProfileFields, TEUserProfileFieldsHelper.GetFields().OrderBy(f => f.Name).ToList(), f => f.Title);
                    hdnSiteProfileFieldsMap.Value = GetJSONMapping(spConfig.SiteProfileMappedFields);
                    hdnFarmProfileFieldsMap.Value = GetJSONMapping(spConfig.FarmProfileMappedFields);
                }
                catch (Exception ex)
                {
                    ShowErrorMessage(ex.Message);
                    SPLog.RoleOperationUnavailable(ex, ex.Message);
                }
            }
        }