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); } }
protected void SaveBtnClick(object sender, EventArgs e) { if (!Page.IsValid) { return; } TbUserIdFieldName.Text = (string.IsNullOrEmpty(TbUserIdFieldName.Text)) ? "ID" : TbUserIdFieldName.Text; TbUserEmailFieldName.Text = (string.IsNullOrEmpty(TbUserEmailFieldName.Text)) ? "EMail" : TbUserEmailFieldName.Text; TbFarmUserEmailFieldName.Text = (string.IsNullOrEmpty(TbFarmUserEmailFieldName.Text)) ? "WorkEmail" : TbFarmUserEmailFieldName.Text; try { Authentication auth = AuthenticationHelper.FromHtml(CtAuth); if (Mode == PageMode.Add) { spSyncSettings = new SPProfileSyncProvider(TbSPSiteUrl.Text, TbUserIdFieldName.Text, TbUserEmailFieldName.Text, TbFarmUserEmailFieldName.Text, auth); } else { spSyncSettings.SPSiteURL = TbSPSiteUrl.Text; spSyncSettings.SPUserIdFieldName = TbUserIdFieldName.Text; spSyncSettings.SPUserEmailFieldName = TbUserEmailFieldName.Text; spSyncSettings.SPFarmUserEmailFieldName = TbFarmUserEmailFieldName.Text; spSyncSettings.Authentication = auth; } const string script = @"setTimeout(function(){{CloseWindow('{0}');}},100);"; CSControlUtility.Instance().RegisterClientScriptBlock(this, GetType(), "closechildwindow", string.Format(script, JavaScript.Encode(spSyncSettings.ToXml())), true); TempStoreSPSyncSettingsList(true); } catch (Exception) { ShowErrorMessage(); } }