public override void FeatureActivated(SPFeatureReceiverProperties properties) { string RootPath = properties.Feature.Definition.RootDirectory; // feature is scoped at Site, so the parent is type SPSite rather than SPWeb.. using (SPSite site = properties.Feature.Parent as SPSite) { SPWeb currentWeb = null; Guid gRootWebId = Guid.Empty; if (site != null) { currentWeb = site.RootWeb; gRootWebId = currentWeb.ID; } else { currentWeb = properties.Feature.Parent as SPWeb; gRootWebId = currentWeb.Site.RootWeb.ID; } using (currentWeb) { string dataFile = RootPath + "\\" + properties.Feature.Properties["Data"].Value; AddListData(currentWeb, dataFile); } } }
public override void FeatureActivated(SPFeatureReceiverProperties properties) { SPSite site = properties.Feature.Parent as SPSite; if (site != null) { SPWeb topLevelSite = site.RootWeb; // Calculate relative path to site from Web Application root. string webAppRelativePath = topLevelSite.ServerRelativeUrl; if (!webAppRelativePath.EndsWith("/")) { webAppRelativePath += "/"; } // Activate publishing infrastructure site.Features.Add(new Guid("f6924d36-2fa8-4f0b-b16d-06b7250180fa"), true); // Enumerate through each site and apply branding. foreach (SPWeb web in site.AllWebs) { // Activate the publishing feature for all webs. web.Features.Add(new Guid("94c94ca6-b32f-4da9-a9e3-1f3d343d7ecb"), true); web.MasterUrl = webAppRelativePath + "_catalogs/masterpage/CompanyBranding.master"; web.CustomMasterUrl = webAppRelativePath + "_catalogs/masterpage/CompanyBranding.master"; web.Update(); } } }
// Uncomment the method below to handle the event raised after a feature has been activated. public override void FeatureActivated(SPFeatureReceiverProperties properties) { try { if (!Constants.IsitInDevelopmentMode) { var site = properties.Feature.Parent as SPSite; // make sure the job isn't already registered if (site != null) { foreach (SPJobDefinition job in site.WebApplication.JobDefinitions) { if (job.Name == Constants.TimerJobName) job.Delete(); } // install the job var currencyConversionTimerJob = new CurrencyConversionTimerJob(Constants.TimerJobName, site.WebApplication); //To perform the task on daily basis var schedule = new SPDailySchedule {BeginHour = 0, BeginMinute = 0, BeginSecond = 0}; currencyConversionTimerJob.Schedule = schedule; currencyConversionTimerJob.Update(); } } } catch (Exception ex) { ExceptionHandling.WriteUlsLog(ex); } }
/// <summary> /// Deletes event receivers for the <c>browsable</c> item content type /// </summary> /// <param name="properties">The event properties</param> public override void FeatureDeactivating(SPFeatureReceiverProperties properties) { var site = properties.Feature.Parent as SPSite; if (site != null) { using (var featureScope = SearchContainerProxy.BeginFeatureLifetimeScope(properties.Feature)) { var eventReceiverHelper = featureScope.Resolve<IEventReceiverHelper>(); var baseReceiversConfig = featureScope.Resolve<ISearchEventReceiverInfoConfig>(); var baseEventReceivers = baseReceiversConfig.EventReceivers; var resourceLocator = featureScope.Resolve<IResourceLocator>(); var logger = featureScope.Resolve<ILogger>(); var eventReceiversInfos = featureScope.Resolve<SearchEventReceiverInfos>(); // Add only Browsable Item events baseEventReceivers.Clear(); baseEventReceivers.Add(eventReceiversInfos.BrowsableItemItemAdded()); baseEventReceivers.Add(eventReceiversInfos.BrowsableItemItemUpdated()); foreach (var eventReceiver in baseEventReceivers) { logger.Info("Deleting event receiver for content type {0}", resourceLocator.Find(eventReceiver.ContentType.DisplayNameResourceKey)); eventReceiver.AssemblyName = Assembly.GetExecutingAssembly().FullName; eventReceiverHelper.DeleteContentTypeEventReceiverDefinition(site, eventReceiver); } } } }
static void UnRegisterLoggingService(SPFeatureReceiverProperties properties) { SPSecurity.RunWithElevatedPrivileges(delegate() { SPFarm farm = properties.Definition.Farm; if (farm != null) { LoggingService service = LoggingService.Local; if (service != null) service.Delete(); //foreach (SPServer server in farm.Servers) //{ // RegistryKey baseKey = RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, server.Address); // if (baseKey != null) // { // RegistryKey eventLogKey = baseKey.OpenSubKey(EventLogApplicationRegistryKeyPath, true); // if (eventLogKey != null) // { // RegistryKey loggingServiceKey = eventLogKey.OpenSubKey(LoggingService.AreaName); // if (loggingServiceKey != null) // eventLogKey.DeleteSubKey(LoggingService.AreaName); // } // } //} } }); }
public override void FeatureDeactivating(SPFeatureReceiverProperties properties) { var serviceLocator = SharePointServiceLocator.GetCurrent(); var typeMappings = serviceLocator.GetInstance<IServiceLocatorConfig>(); typeMappings.RemoveTypeMapping<IConfigPropertiesParser>(null); typeMappings.RemoveTypeMapping<IFileSystemHelper>(null); }
// Uncomment the method below to handle the event raised before a feature is deactivated. public override void FeatureDeactivating(SPFeatureReceiverProperties properties) { SPSite oSite = new SPSite(SPContext.Current.Site.ID); SPWebCollection collWebsite = oSite.AllWebs; for (int i = 0; i < collWebsite.Count; i++) { using (SPWeb oWebsite = collWebsite[i]) { try { SPWeb oWeb = oSite.OpenWeb(oWebsite.ID); oWeb.AllowUnsafeUpdates = true; oWeb.Features.Remove(new Guid(FeatureGUID_InternalMasterwithSearchBox)); oWeb.AllowUnsafeUpdates = false; } catch (Exception ex) { SPDiagnosticsService diagSvc = SPDiagnosticsService.Local; diagSvc.WriteTrace(0, new SPDiagnosticsCategory("Kapsch GSA Search Box On All Subsites", TraceSeverity.High, EventSeverity.Error), TraceSeverity.Monitorable, "Writing to the ULS log: {0}", new object[] { ex.Message }); } } } oSite.Dispose(); collWebsite = null; }
// Uncomment the method below to handle the event raised before a feature is deactivated. public override void FeatureDeactivating(SPFeatureReceiverProperties properties) { using (SPSite curSite = (SPSite)properties.Feature.Parent) { using (SPWeb curWeb = curSite.RootWeb) { Uri masterUri = new Uri(curWeb.Url + "/_catalogs/masterpage/v4.master"); MasterUrl = masterUri.AbsolutePath; CustomMasterUrl = masterUri.AbsolutePath; curWeb.MasterUrl = MasterUrl; curWeb.CustomMasterUrl = CustomMasterUrl; curWeb.Update(); foreach (SPWeb subWeb in curWeb.Webs) { UpdateMasterPageofWebs(subWeb); } } } }
/// <summary> /// Configures only the content pages catalog to allow the open term creation in the navigation column /// </summary> /// <param name="properties">Context properties</param> public override void FeatureActivated(SPFeatureReceiverProperties properties) { var web = properties.Feature.Parent as SPWeb; if (web != null) { using (var featureScope = NavigationContainerProxy.BeginFeatureLifetimeScope(properties.Feature)) { var listHelper = featureScope.Resolve<IListHelper>(); var listConfig = featureScope.Resolve<INavigationListInfosConfig>().Lists; var logger = featureScope.Resolve<ILogger>(); // Add only the target content pages list var contentPages = listConfig.FirstOrDefault(p => p.WebRelativeUrl.ToString().Equals("Pages")); if (contentPages != null) { listConfig.Clear(); listConfig.Add(contentPages); // Create lists foreach (var list in listConfig) { logger.Info("Configuring list {0} in web {1}", list.WebRelativeUrl, web.Url); listHelper.EnsureList(web, list); } } else { logger.Info("No content pages list information found in the configuration. Please add the content pages list configuration to use this feature"); } } } }
// Uncomment the method below to handle the event raised after a feature has been activated. public override void FeatureActivated(SPFeatureReceiverProperties properties) { ServiceLocatorConfig serviceLocatorConfig = new ServiceLocatorConfig(); serviceLocatorConfig.RegisterTypeMapping<IIssueManagementRepository, IssueManagementRepository>(); }
public override void FeatureUninstalling(SPFeatureReceiverProperties properties) { SPSecurity.RunWithElevatedPrivileges(delegate() { this.RemovePersistedObject(); }); }
public override void FeatureActivated(SPFeatureReceiverProperties properties) { char[] slashes = { '/' }; string _masterPagePath = string.Empty; try { SPSite ObjSite = properties.Feature.Parent as SPSite; //Getting the master page file path. SPFeatureProperty masterFile = properties.Definition.Properties[MASTERPAGEFILE]; //Getting Site Ref foreach (SPWeb ObjWeb in ObjSite.AllWebs) { if (ObjWeb.IsRootWeb) { _masterPagePath=ObjWeb.ServerRelativeUrl.TrimEnd(slashes) + "/_catalogs/masterpage/" + masterFile.Value; } //Updating master pages for all sites; ObjWeb.CustomMasterUrl = _masterPagePath; ObjWeb.MasterUrl = _masterPagePath; ObjWeb.ApplyTheme("simple"); ObjWeb.Update(); } } catch (Exception ex) { throw ex; } }
public override void FeatureDeactivating(SPFeatureReceiverProperties properties) { var site = properties.Feature.Parent as SPSite; SPWeb web = site.RootWeb; try { RemoveEventReceivers(web); // http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spsecurity.runwithelevatedprivileges(v=office.14).aspx SPSecurity.RunWithElevatedPrivileges(() => { using (var epsite = new SPSite(site.ID)) { RemoveCleanupTimerJob(epsite.WebApplication); } }); LogList.DeleteList(web); } catch (Exception ex) { ULSLog.LogError(ex); } finally { site.Dispose(); web.Dispose(); } }
// フィーチャーをアクティブにした後に発生したイベントを処理するには、以下のメソッドのコメントを解除します。 //public override void FeatureActivated(SPFeatureReceiverProperties properties) //{ // // サイト (SPWeb) またはサイトコレクション (SPSite) の SPWeb を取得します // SPWeb web; // if (properties.Feature.Parent is SPWeb) // web = (SPWeb)properties.Feature.Parent; //サイトの場合 // else // web = ((SPSite)properties.Feature.Parent).RootWeb; //サイトコレクションの場合 // web.AllowUnsafeUpdates = true; // // [ページ] 内のすべてのページにマスターページを適用 // web.CustomMasterUrl = SPUrlUtility.CombineUrl(web.ServerRelativeUrl, // "_catalogs/masterpage/MyDemoMaster/mysample.master"); // // システムのページ (設定画面など) にマスターページを適用 // web.MasterUrl = SPUrlUtility.CombineUrl(web.ServerRelativeUrl, // "_catalogs/masterpage/MyDemoMaster/mysample.master"); // web.Update(); //} // フィーチャーを非アクティブにする前に発生したイベントを処理するには、以下のメソッドのコメントを解除します。 public override void FeatureDeactivating(SPFeatureReceiverProperties properties) { // サイト (SPWeb) またはサイトコレクション (SPSite) の SPWeb を取得します SPWeb web; if (properties.Feature.Parent is SPWeb) web = (SPWeb)properties.Feature.Parent; //サイトの場合 else web = ((SPSite)properties.Feature.Parent).RootWeb; //サイトコレクションの場合 //web.AllowUnsafeUpdates = true; //// [ページ] 内のすべてのページにマスターページを適用 //web.CustomMasterUrl = SPUrlUtility.CombineUrl(web.ServerRelativeUrl, // "_catalogs/masterpage/v4.master"); //// システムのページ (設定画面など) にマスターページを適用 //web.MasterUrl = SPUrlUtility.CombineUrl(web.ServerRelativeUrl, // "_catalogs/masterpage/v4.master"); //web.Update(); // カスタムリスト定義から派生されたリストをすべて削除 List<SPList> deleteLists = new List<SPList>(); foreach (SPList list in web.Lists) { if ((list.BaseTemplate.ToString().Equals("16301")) || (list.BaseTemplate.ToString().Equals("16302"))) deleteLists.Add(list); } foreach (SPList list in deleteLists) { list.Delete(); } // リソース ライブラリーを削除 if(web.Lists.TryGetList("MSKK_SandboxDemo_Resources") != null) web.Lists["MSKK_SandboxDemo_Resources"].Delete(); }
public override void FeatureActivated(SPFeatureReceiverProperties properties) { base.FeatureActivated(properties); SPSite site = (SPSite)properties.Feature.Parent; SPWeb web = site.RootWeb; SPList list = web.Lists["Articles"]; //SPContentType newContentType = web.AvailableContentTypes["Article2"]; SPContentType oldContentType = list.ContentTypes["Article"]; oldContentType.EditFormTemplateName = "NCArticleListEditForm"; oldContentType.NewFormTemplateName = "NCArticleListEditForm"; list.ContentTypesEnabled = true; //try //{ // list.ContentTypes.Add(newContentType); //} //catch { } //try //{ // list.ContentTypes.Delete(oldContentType.Id); //} //catch { } oldContentType.Update(); list.Update(); }
// Uncomment the method below to handle the event raised after a feature has been activated. public override void FeatureActivated(SPFeatureReceiverProperties properties) { try { var site = (SPSite)properties.Feature.Parent; bool timerJobFound = site.WebApplication.JobDefinitions.Any(jobDefinition => jobDefinition.Title == Utilities.TimerJobName); if (!timerJobFound) { var addingleavedays = new NotificationTimerJob(Utilities.TimerJobName, site.WebApplication); var dailySchedule = new SPDailySchedule { BeginHour = 0, BeginMinute = 0, BeginSecond = 0, EndHour = 1, EndMinute = 59, EndSecond = 59 }; addingleavedays.Schedule = dailySchedule; addingleavedays.Update(); } } catch (Exception ex) { SPDiagnosticsService.Local.WriteTrace(0, new SPDiagnosticsCategory("Udateleavebalance", TraceSeverity.Monitorable, EventSeverity.Error), TraceSeverity.Monitorable, ex.Message, new object[] { ex.StackTrace }); } }
// Uncomment the method below to handle the event raised after a feature has been activated. public override void FeatureActivated(SPFeatureReceiverProperties properties) { SPWeb web = (SPWeb)properties.Feature.Parent; try { ProvisionWebParts(web); //Set WebPart Properties RemoveWebPart(web); AddNavigation(web); //CreateOverlapCalenday(web); EnableEmailNotify(web); EnsureSupervisorGroup(web); SetListPermission(web); SPWebApplication webApp = web.Site.WebApplication; BeachCampReminder beachCampJob = new BeachCampReminder(webApp); beachCampJob.Title = BeachCampReminder.BEACH_CAMP_JOB_NAME; DeleteJob(webApp.JobDefinitions, BeachCampReminder.BEACH_CAMP_JOB_NAME); SPDailySchedule dailySchedule = new SPDailySchedule(); dailySchedule.BeginHour = 23; dailySchedule.BeginMinute = 0; dailySchedule.BeginSecond = 0; beachCampJob.Schedule = dailySchedule; beachCampJob.Update(); } catch (Exception ex) { Utility.LogError(ex.Message, Util.BeachCampFeatures.BeachCamp); } }
// Uncomment the method below to handle the event raised after a feature has been activated. public override void FeatureActivated(SPFeatureReceiverProperties properties) { SPWeb website = properties.Feature.Parent as SPWeb; FileInfo file; if (properties.Feature.TryLocateElementFile("app2.config", out file) == false) { throw new FileNotFoundException("element file file not found", "app2.config"); } foreach (KeyValueConfigurationElement appSetting in file.AppSettings()) { string fullkey = Setting.BuildWebSitePropertyKey(appSetting.Key); if (website.AllProperties.Contains(fullkey)) { website.SetProperty(fullkey, appSetting.Value); } else { website.AddProperty(fullkey, appSetting.Value); } website.Update(); } }
// Uncomment the method below to handle the event raised after a feature has been activated. public override void FeatureActivated(SPFeatureReceiverProperties properties) { var web = properties.Feature.Parent as SPWeb; if (web.Lists.TryGetList("Book Categories") == null) { var categoriesListId = web.Lists.Add("Book Categories", "", SPListTemplateType.GenericList); if (web.Lists.TryGetList("Books") == null) { var booksListId = web.Lists.Add("Books", "", SPListTemplateType.GenericList); var booksList = web.Lists[booksListId]; booksList.Fields.Add("Description", SPFieldType.Note, false); var imageFieldName = booksList.Fields.Add("Image", SPFieldType.URL, true); var imageField = booksList.Fields[imageFieldName] as SPFieldUrl; imageField.DisplayFormat = SPUrlFieldFormatType.Image; imageField.Update(); var categoryFieldName = booksList.Fields.AddLookup("Category", categoriesListId, true); var categoryField = booksList.Fields[categoryFieldName] as SPFieldLookup; categoryField.LookupField = "Title"; categoryField.Update(); booksList.DefaultView.ViewFields.Add(imageField); booksList.DefaultView.ViewFields.Add(categoryField); booksList.DefaultView.Update(); } } }
public override void FeatureActivated(SPFeatureReceiverProperties properties) { SPWeb web = (SPWeb)properties.Feature.Parent; SPList list = web.Lists["Service announcements"]; list.ContentTypesEnabled = true; list.Update(); }
// Uncomment the method below to handle the event raised after a feature has been activated. public override void FeatureActivated(SPFeatureReceiverProperties properties) { using (SPSite site = properties.Feature.Parent as SPSite) { using (SPWeb web = site.OpenWeb()) { string urlFile = "/Lists/IA/EditForm.aspx"; string urlFile1 = "/Lists/IA/NewForm.aspx"; SPFile file = web.GetFile(urlFile); using (SPLimitedWebPartManager webpartMgr = file.GetLimitedWebPartManager(PersonalizationScope.Shared)) { CheckifExists(webpartMgr, "Jquery AutoComplete"); SPEduQuickStart.WebParts.AutocompleteSugestionTemplate.AutocompleteSugestionTemplate wp = new SPEduQuickStart.WebParts.AutocompleteSugestionTemplate.AutocompleteSugestionTemplate(); wp.Title = "Jquery AutoComplete"; webpartMgr.AddWebPart(wp, "Top", 1); } SPFile file2 = web.GetFile(urlFile1); using (SPLimitedWebPartManager webpartMgr = file2.GetLimitedWebPartManager(PersonalizationScope.Shared)) { CheckifExists(webpartMgr, "Jquery AutoComplete"); SPEduQuickStart.WebParts.AutocompleteSugestionTemplate.AutocompleteSugestionTemplate wp = new SPEduQuickStart.WebParts.AutocompleteSugestionTemplate.AutocompleteSugestionTemplate(); wp.Title = "Jquery AutoComplete"; webpartMgr.AddWebPart(wp, "Top", 1); } } } }
public override void FeatureDeactivating(SPFeatureReceiverProperties properties) { try { SPWebApplication webApp = null; if (properties.Feature.Parent is SPSite) { SPSite spSite = properties.Feature.Parent as SPSite; webApp = spSite.WebApplication; } else if (properties.Feature.Parent is SPWebApplication) { webApp = properties.Feature.Parent as SPWebApplication; } String pathToCompatBrowser = webApp.IisSettings[SPUrlZone.Default].Path + @"\App_Browsers\compat.browser"; XElement compatBrowser = XElement.Load(pathToCompatBrowser); XElement mobileAdapter = compatBrowser.XPathSelectElement(String.Format("./browser[@refID = \"default\"]/controlAdapters/adapter[@controlType = \"{0}\"]", controlType)); mobileAdapter.Remove(); // Overwrite the old version of compat.browser with your new version. compatBrowser.Save(pathToCompatBrowser); } catch { } }
public override void FeatureActivated(SPFeatureReceiverProperties properties) { var configManager = SharePointServiceLocator.GetCurrent().GetInstance<IConfigManager>(); var configuredAreas = new DiagnosticsAreaCollection(configManager); foreach (var newArea in Areas) { var existingArea = configuredAreas[newArea.Name]; if (existingArea == null) { configuredAreas.Add(newArea); } else { foreach (var category in newArea.DiagnosticsCategories) { var existingCategory = existingArea.DiagnosticsCategories[category.Name]; if (existingCategory == null) { existingArea.DiagnosticsCategories.Add(category); } } } } configuredAreas.SaveConfiguration(); DiagnosticsAreaEventSource.EnsureConfiguredAreasRegistered(); }
/// <summary> /// Event Receiver for Feature Activated /// </summary> /// <param name="properties">The event properties</param> public override void FeatureActivated(SPFeatureReceiverProperties properties) { var site = properties.Feature.Parent as SPSite; if (site != null) { using (var featureScope = DesignContainerProxy.BeginFeatureLifetimeScope(properties.Feature)) { var masterPageHelper = featureScope.Resolve<IMasterPageHelper>(); var designConfig = featureScope.Resolve<IDesignConfig>(); // Resolve feature dependency activator // Note: Need to pass the site and web objects to support site and web scoped features. var featureDependencyActivator = featureScope.Resolve<IFeatureDependencyActivator>( new TypedParameter(typeof(SPSite), site), new TypedParameter(typeof(SPWeb), site.RootWeb)); // Activate feature dependencies defined in this configuration featureDependencyActivator.EnsureFeatureActivation(designConfig as IFeatureDependencyConfig); // Generate masterpage file from HTML design file masterPageHelper.GenerateMasterPage(site, designConfig.MasterPageHTMLFilename); // Set the masterpage on the site masterPageHelper.ApplyRootMasterPage(site, null, designConfig.MasterPageMASTERFilename); } } }
/// <summary> /// Creates fields for the navigation module /// </summary> /// <param name="properties">The event properties</param> public override void FeatureActivated(SPFeatureReceiverProperties properties) { var site = properties.Feature.Parent as SPSite; if (site != null) { using (var featureScope = NavigationContainerProxy.BeginFeatureLifetimeScope(properties.Feature)) { var fieldHelper = featureScope.Resolve<IFieldHelper>(); var baseFieldInfoConfig = featureScope.Resolve<INavigationFieldInfoConfig>(); var baseFields = baseFieldInfoConfig.Fields; var logger = featureScope.Resolve<ILogger>(); using (new Unsafe(site.RootWeb)) { // Create fields foreach (BaseFieldInfo field in baseFields) { logger.Info("Creating field {0}", field.InternalName); fieldHelper.EnsureField(site.RootWeb.Fields, field); } } } } }
public override void FeatureActivated(SPFeatureReceiverProperties properties) { var webApp = properties.Feature.Parent as SPWebApplication; if (webApp == null) throw new Exception("webApp"); // undeploy the job if already registered var ej = from SPJobDefinition job in webApp.JobDefinitions where job.Name == FileLoader.JOB_DEFINITION_NAME select job; if (ej.Count() > 0) ej.First().Delete(); // create and configure timerjob var schedule = new SPMinuteSchedule { BeginSecond = 0, EndSecond = 59, Interval = 55, }; var myJob = new FileLoader(webApp) { Schedule = schedule, IsDisabled = false }; // save the timer job deployment myJob.Update(); }
public override void FeatureActivated(SPFeatureReceiverProperties properties) { RegisterLogger(); // Make sure the job isn't there foreach (SPJobDefinition job in SPFarm.Local.TimerService.JobDefinitions) { if (job.Name == ADFSCertificateUpdaterJob.JobName) { job.Delete(); } } // Add the configuration object. Getting it for the first time forces the creation. var config = ADFSCertificateUpdaterConfiguration.GetFromConfigDB(); // Install the job ADFSCertificateUpdaterJob newJob = new ADFSCertificateUpdaterJob(); // Run daily at 0015 var schedule = new SPDailySchedule(); schedule.BeginHour = 0; schedule.EndHour = 0; schedule.BeginMinute = 15; schedule.EndMinute = 15; newJob.Schedule = schedule; newJob.Update(); }
public override void FeatureDeactivating(SPFeatureReceiverProperties properties) { var configManager = SharePointServiceLocator.GetCurrent().GetInstance<IConfigManager>(); var configuredAreas = new DiagnosticsAreaCollection(configManager); foreach (var area in Areas) { var areaToRemove = configuredAreas[area.Name]; if (areaToRemove != null) { foreach (var c in area.DiagnosticsCategories) { var existingCat = areaToRemove.DiagnosticsCategories[c.Name]; if (existingCat != null) { areaToRemove.DiagnosticsCategories.Remove(existingCat); } } if (areaToRemove.DiagnosticsCategories.Count == 0) { configuredAreas.Remove(areaToRemove); } } } configuredAreas.SaveConfiguration(); }
public override void FeatureDeactivating(SPFeatureReceiverProperties properties) { string assembly = "ExternalListEvents, Culture=neutral, Version=1.0.0.0, PublicKeyToken=f3e998418ec415ce"; using (SPSite siteCollection = new SPSite("http://dev.wingtip13.com/bcs")) { using (SPWeb site = siteCollection.OpenWeb()) { SPList customers = site.Lists["Customers"]; SPEventReceiverDefinitionCollection receivers = customers.EventReceivers; SPEventReceiverDefinition activityReceiver = null; foreach (SPEventReceiverDefinition receiver in receivers) { if (receiver.Assembly.Equals(assembly, StringComparison.OrdinalIgnoreCase)) { activityReceiver = receiver; break; } } if (activityReceiver != null) { activityReceiver.Delete(); } } } }
public override void FeatureActivated(SPFeatureReceiverProperties properties) { using (SPSite curSite = (SPSite)properties.Feature.Parent) { using (SPWeb curWeb = curSite.RootWeb) { Uri masterUri = new Uri(curWeb.Url + "/_catalogs/masterpage/KapschMaster-archive.master"); MasterUrl = masterUri.AbsolutePath; CustomMasterUrl = masterUri.AbsolutePath; curWeb.MasterUrl = MasterUrl; curWeb.CustomMasterUrl = CustomMasterUrl; curWeb.Update(); SPWebCollection webCol = curWeb.Webs; foreach (SPWeb childWeb in webCol) { UpdateMasterPageofWebs(childWeb); } } } }
public override void FeatureUpgrading(SPFeatureReceiverProperties properties, string upgradeActionName, System.Collections.Generic.IDictionary <string, string> parameters) { ////TODO: place receiver code here or remove method }
public override void FeatureDeactivating(SPFeatureReceiverProperties properties) { Setup.Uninstall((properties.Feature.Parent as SPSite).RootWeb); }
public override void FeatureDeactivating(SPFeatureReceiverProperties properties) { }
public override void FeatureDeactivating(SPFeatureReceiverProperties properties) { var site = properties.Feature.Parent as SPWebApplication; RemoveJobIfRegistered(site); }
public void ActivateFBAManagement(SPFeatureReceiverProperties properties) { // get site reference SPSite site = properties.Feature.Parent as SPSite; SPList list = site.RootWeb.SiteUserInfoList; SPField field; if (!list.Fields.ContainsField("CMIT Location")) { field = list.Fields.CreateNewField(SPFieldType.Text.ToString(), "CMIT Location"); //You can change the field data type here as well list.Fields.Add(field); list.Update(); } if (!list.Fields.ContainsField("CMITTitle")) { field = list.Fields.CreateNewField(SPFieldType.Text.ToString(), "CMITTitle"); //You can change the field data type here as well list.Fields.Add(field); list.Update(); } if (!list.Fields.ContainsField("Telephone Number")) { field = list.Fields.CreateNewField(SPFieldType.Text.ToString(), "Telephone Number"); //You can change the field data type here as well list.Fields.Add(field); list.Update(); } if (!list.Fields.ContainsField("Date of provisioning")) { field = list.Fields.CreateNewField(SPFieldType.DateTime.ToString(), "Date of provisioning"); //You can change the field data type here as well list.Fields.Add(field); list.Update(); } /* bms Get a reference to the web */ // get a web reference //SPWeb web = site.OpenWeb(); ///* Set the options in the web properties */ //UpdateProperty(MembershipOptions.ENABLEROLES, Boolean.TrueString, web); //UpdateProperty(MembershipOptions.REVIEWMEMBERSHIPREQUESTS, Boolean.FalseString, web); ///* bms Set the URL strings in the web properties */ ////TODO: Make these resources //UpdateProperty(MembershipReviewSiteURL.CHANGEPASSWORDPAGE,"Pages/ChangePassword.aspx",web); //UpdateProperty(MembershipReviewSiteURL.PASSWORDQUESTIONPAGE,"Pages/PasswordQuestion.aspx",web); //UpdateProperty(MembershipReviewSiteURL.THANKYOUPAGE,"Pages/Thankyou.aspx",web); ///* bms Set the XSLT location web properties */ ////TODO: Make these resources //UpdateProperty(MembershipReviewSiteXSLTEmail.MEMBERSHIPAPPROVED,"/_layouts/15/FBA/emails/MembershipApproved.xslt",web); //UpdateProperty(MembershipReviewSiteXSLTEmail.MEMBERSHIPERROR,"/_layouts/15/FBA/emails/MembershipError.xslt",web); //UpdateProperty(MembershipReviewSiteXSLTEmail.MEMBERSHIPPENDING,"/_layouts/15/FBA/emails/MembershipPending.xslt",web); //UpdateProperty(MembershipReviewSiteXSLTEmail.MEMBERSHIPREJECTED,"/_layouts/15/FBA/emails/MembershipRejected.xslt",web); //UpdateProperty(MembershipReviewSiteXSLTEmail.PASSWORDRECOVERY,"/_layouts/15/FBA/emails/PasswordRecovery.xslt",web); // update layouts site map try { //UpdateLayoutsSitemap uls = new UpdateLayoutsSitemap(site.WebApplication); //uls.AddSitemap("layouts.sitemap.FBAManagement.xml"); //uls.SubmitJob(); SPFarm.Local.Services.GetValue <SPWebService>(). ApplyApplicationContentToLocalServer(); } catch (Exception ex) { Utils.LogError(ex); } }
// Uncomment the method below to handle the event raised after a feature has been activated. public override void FeatureActivated(SPFeatureReceiverProperties properties) { SPWeb web = properties.Feature.Parent as SPWeb; SPSite site = web.Site; List <Guid> doneLists = new List <Guid>(); bool retry = false; bool canCreateDM = false; try { do { retry = false; foreach (SPList list in web.Lists) { try { if (doneLists.Contains(list.ID)) { continue; } if ((int)list.BaseTemplate == 20003) { AddListItem(web, list, "List1-Value1", "List1-Value1-1"); AddListItem(web, list, "List1-Value1", "List1-Value1-2"); AddListItem(web, list, "List1-Value1", "List1-Value1-3"); AddListItem(web, list, "List1-Value1", "List1-Value1-4"); AddListItem(web, list, "List1-Value2", "List1-Value2-1"); AddListItem(web, list, "List1-Value2", "List1-Value2-2"); AddListItem(web, list, "List1-Value2", "List1-Value2-3"); AddListItem(web, list, "List1-Value2", "List1-Value2-4"); AddListItem(web, list, "List1-Value3", "List1-Value3-1"); AddListItem(web, list, "List1-Value3", "List1-Value3-2"); AddListItem(web, list, "List1-Value3", "List1-Value3-3"); AddListItem(web, list, "List1-Value3", "List1-Value3-4"); AddListItem(web, list, "List1-Value4", "List1-Value4-1"); AddListItem(web, list, "List1-Value4", "List1-Value4-2"); AddListItem(web, list, "List1-Value4", "List1-Value4-3"); AddListItem(web, list, "List1-Value4", "List1-Value4-4"); AddListItem(web, list, "List1-Value5", "List1-Value5-1"); AddListItem(web, list, "List1-Value5", "List1-Value5-2"); AddListItem(web, list, "List1-Value5", "List1-Value5-3"); AddListItem(web, list, "List1-Value5", "List1-Value5-4"); AddListItem(web, list, "List1-Value6", "List1-Value6-1"); AddListItem(web, list, "List1-Value6", "List1-Value6-2"); AddListItem(web, list, "List1-Value6", "List1-Value6-3"); AddListItem(web, list, "List1-Value6", "List1-Value6-4"); doneLists.Add(list.ID); retry = true; break; } ; } catch (Exception ex2) { } } ; } while (retry); } catch (Exception ex) { return; }; }
// Uncomment the method below to handle the event raised before a feature is deactivated. public override void FeatureDeactivating(SPFeatureReceiverProperties properties) { SPWebApplication webApp = properties.Feature.Parent as SPWebApplication; RemoveAllCustomisations(webApp); }
// Uncomment the method below to handle the event raised before a feature is deactivated. public override void FeatureDeactivating(SPFeatureReceiverProperties properties) { UnRegisterLoggingService(properties); }
// Uncomment the method below to handle the event raised after a feature has been activated. public override void FeatureActivated(SPFeatureReceiverProperties properties) { WBUtils.logMessage("Activating Farm Admin Feature"); RegisterLoggingService(properties); }
/// <summary> /// Invoke on Feature Activation /// </summary> /// <param name="properties"></param> public override void FeatureActivated(SPFeatureReceiverProperties properties) { try { SPSite site = properties.Feature.Parent as SPSite; jobTitle = jobTitle + site.Url.ToString(); // Delete Existing Timer Job If Installed foreach (SPJobDefinition job in site.WebApplication.JobDefinitions) { if (job.Name.Equals(jobTitle, StringComparison.InvariantCultureIgnoreCase)) { job.Delete(); } } AlertJobdefinition objArchivalJob = new AlertJobdefinition(jobTitle, site.WebApplication); SPMinuteSchedule schedule = new SPMinuteSchedule(); if (schedule != null) { schedule.BeginSecond = 0; schedule.EndSecond = 59; schedule.Interval = 30; objArchivalJob.Properties.Add(WebSiteURL_KeyName, site.Url); objArchivalJob.Schedule = schedule; objArchivalJob.Update(); } //Creating Hidden List1 SPWeb web = site.OpenWeb(); SPListCollection lists = web.Lists; lists.Add("CCSAdvancedAlertsList", "CrowCanyon Advanced Alerts List", SPListTemplateType.GenericList); SPList newList = web.Lists["CCSAdvancedAlertsList"]; newList.Fields.Add("WebID", SPFieldType.Text, false); newList.Fields.Add("ListID", SPFieldType.Text, false); newList.Fields.Add("ItemID", SPFieldType.Text, false); newList.Fields.Add("WhenToSend", SPFieldType.Choice, false); SPFieldChoice WhenToSendChoiceCol = (SPFieldChoice)newList.Fields["WhenToSend"]; string[] strdata = new string[3]; strdata[0] = "Immediate"; strdata[1] = "Daily"; strdata[2] = "Weekely"; WhenToSendChoiceCol.Choices.Add(strdata[0]); WhenToSendChoiceCol.Choices.Add(strdata[1]); WhenToSendChoiceCol.Choices.Add(strdata[2]); WhenToSendChoiceCol.Update(); newList.Fields.Add("DetailInfo", SPFieldType.Note, false); newList.Fields.Add("Owner", SPFieldType.User, false); newList.Fields.Add("EventType", SPFieldType.Choice, false); SPFieldChoice EventTypeChoiceCol = (SPFieldChoice)newList.Fields["EventType"]; string[] strdata1 = new string[4]; strdata1[0] = "ItemAdded"; strdata1[1] = "ItemUpdated"; strdata1[2] = "ItemDeleted"; strdata1[3] = "DateColumn"; EventTypeChoiceCol.Choices.Add(strdata1[0]); EventTypeChoiceCol.Choices.Add(strdata1[1]); EventTypeChoiceCol.Choices.Add(strdata1[2]); EventTypeChoiceCol.Choices.Add(strdata1[3]); EventTypeChoiceCol.Update(); newList.Fields.Add("SendDay", SPFieldType.Choice, false); SPFieldChoice SendDayChoiceCol = (SPFieldChoice)newList.Fields["SendDay"]; string[] strdata2 = new string[7]; strdata2[0] = "1"; strdata2[1] = "2"; strdata2[2] = "3"; strdata2[3] = "4"; strdata2[4] = "5"; strdata2[5] = "6"; strdata2[6] = "7"; SendDayChoiceCol.Choices.Add(strdata2[0]); SendDayChoiceCol.Choices.Add(strdata2[1]); SendDayChoiceCol.Choices.Add(strdata2[2]); SendDayChoiceCol.Choices.Add(strdata2[3]); SendDayChoiceCol.Choices.Add(strdata2[4]); SendDayChoiceCol.Choices.Add(strdata2[5]); SendDayChoiceCol.Choices.Add(strdata2[6]); SendDayChoiceCol.Update(); newList.Fields.Add("SendHour", SPFieldType.Choice, false); SPFieldChoice SendHourChoiceCol = (SPFieldChoice)newList.Fields["SendHour"]; string[] strdata3 = new string[24]; strdata3[0] = "0"; strdata3[1] = "1"; strdata3[2] = "2"; strdata3[3] = "3"; strdata3[4] = "4"; strdata3[5] = "5"; strdata3[6] = "6"; strdata3[7] = "7"; strdata3[8] = "8"; strdata3[9] = "9"; strdata3[10] = "10"; strdata3[11] = "11"; strdata3[12] = "12"; strdata3[13] = "13"; strdata3[14] = "14"; strdata3[15] = "15"; strdata3[16] = "16"; strdata3[17] = "17"; strdata3[18] = "18"; strdata3[19] = "19"; strdata3[20] = "20"; strdata3[21] = "21"; strdata3[22] = "22"; strdata3[23] = "23"; SendHourChoiceCol.Choices.Add(strdata3[0]); SendHourChoiceCol.Choices.Add(strdata3[1]); SendHourChoiceCol.Choices.Add(strdata3[2]); SendHourChoiceCol.Choices.Add(strdata3[3]); SendHourChoiceCol.Choices.Add(strdata3[4]); SendHourChoiceCol.Choices.Add(strdata3[5]); SendHourChoiceCol.Choices.Add(strdata3[6]); SendHourChoiceCol.Choices.Add(strdata3[7]); SendHourChoiceCol.Choices.Add(strdata3[8]); SendHourChoiceCol.Choices.Add(strdata3[9]); SendHourChoiceCol.Choices.Add(strdata3[10]); SendHourChoiceCol.Choices.Add(strdata3[11]); SendHourChoiceCol.Choices.Add(strdata3[12]); SendHourChoiceCol.Choices.Add(strdata3[13]); SendHourChoiceCol.Choices.Add(strdata3[14]); SendHourChoiceCol.Choices.Add(strdata3[15]); SendHourChoiceCol.Choices.Add(strdata3[16]); SendHourChoiceCol.Choices.Add(strdata3[17]); SendHourChoiceCol.Choices.Add(strdata3[18]); SendHourChoiceCol.Choices.Add(strdata3[19]); SendHourChoiceCol.Choices.Add(strdata3[20]); SendHourChoiceCol.Choices.Add(strdata3[21]); SendHourChoiceCol.Choices.Add(strdata3[22]); SendHourChoiceCol.Choices.Add(strdata3[23]); SendHourChoiceCol.Update(); SPView view = newList.DefaultView; view.ViewFields.Add("WebID"); view.ViewFields.Add("ListID"); view.ViewFields.Add("ItemID"); view.ViewFields.Add("WhenToSend"); view.ViewFields.Add("DetailInfo"); view.ViewFields.Add("Owner"); view.ViewFields.Add("EventType"); view.ViewFields.Add("SendDay"); view.ViewFields.Add("SendHour"); view.Update(); newList.Hidden = true; newList.Update(); //Creating Hidden List2 lists.Add("CCSAdvancedAlertsMailTemplates", "CrowCanyon Advanced Alerts Mail Templates", SPListTemplateType.GenericList); SPList newList2 = web.Lists["CCSAdvancedAlertsMailTemplates"]; newList2.Fields.Add("InsertUpdatedFields", SPFieldType.Boolean, false); newList2.Fields.Add("HighLightUpdatedFields", SPFieldType.Boolean, false); newList2.Fields.Add("InsertAttachments", SPFieldType.Boolean, false); newList2.Fields.Add("Owner", SPFieldType.User, false); newList2.Fields.Add("Subject", SPFieldType.Text, false); newList2.Fields.Add("Body", SPFieldType.Note, false); SPView view2 = newList2.DefaultView; view2.ViewFields.Add("InsertUpdatedFields"); view2.ViewFields.Add("HighLightUpdatedFields"); view2.ViewFields.Add("InsertAttachments"); view2.ViewFields.Add("Owner"); view2.ViewFields.Add("Subject"); view2.ViewFields.Add("Body"); view2.Update(); newList2.Hidden = true; newList2.Update(); // Creating Hidden List3 lists.Add("CCSAdvancedTemplateForAlert", "CrowCanyon Advanced Template for alert", SPListTemplateType.GenericList); SPList newList3 = web.Lists["CCSAdvancedTemplateForAlert"]; newList3.Fields.AddLookup("Template", newList2.ID, false); SPFieldLookup lkp = (SPFieldLookup)newList3.Fields["Template"]; lkp.LookupField = newList2.Fields["Title"].InternalName; newList3.Fields.Add("EventType", SPFieldType.Choice, false); SPFieldChoice EventTypeChoiceCol2 = (SPFieldChoice)newList3.Fields["EventType"]; string[] strdata4 = new string[4]; strdata4[0] = "ItemAdded"; strdata4[1] = "ItemUpdated"; strdata4[2] = "ItemDeleted"; strdata4[3] = "DateColumn"; EventTypeChoiceCol2.Choices.Add(strdata4[0]); EventTypeChoiceCol2.Choices.Add(strdata4[1]); EventTypeChoiceCol2.Choices.Add(strdata4[2]); EventTypeChoiceCol2.Choices.Add(strdata4[3]); EventTypeChoiceCol2.Update(); newList3.Fields.Add("InsertUpdatedFields", SPFieldType.Boolean, false); newList3.Fields.Add("HighLightUpdatedFields", SPFieldType.Boolean, false); newList3.Fields.Add("InsertAttachments", SPFieldType.Boolean, false); newList3.Fields.AddLookup("Alert", newList.ID, false); SPFieldLookup lkp2 = (SPFieldLookup)newList3.Fields["Alert"]; lkp2.LookupField = newList.Fields["Title"].InternalName; newList3.Update(); SPView view3 = newList3.DefaultView; view3.ViewFields.Add("Template"); view3.ViewFields.Add("EventType"); view3.ViewFields.Add("InsertUpdatedFields"); view3.ViewFields.Add("HighLightUpdatedFields"); view3.ViewFields.Add("InsertAttachments"); view3.ViewFields.Add("Alert"); view3.Update(); newList3.Hidden = true; newList3.Update(); //Creating Hidden List 4 lists.Add("CCSAdvancedDelayedAlerts", "CrowCanyon Advanced Delayed Alerts", SPListTemplateType.GenericList); SPList newList4 = web.Lists["CCSAdvancedDelayedAlerts"]; newList4.Fields.Add("Subject", SPFieldType.Text, false); newList4.Fields.Add("Body", SPFieldType.Note, false); newList4.Fields.Add("EventType", SPFieldType.Choice, false); SPFieldChoice EventTypeChoiceCol3 = (SPFieldChoice)newList4.Fields["EventType"]; string[] strdata5 = new string[4]; strdata5[0] = "ItemAdded"; strdata5[1] = "ItemUpdated"; strdata5[2] = "ItemDeleted"; strdata5[3] = "DateColumn"; EventTypeChoiceCol3.Choices.Add(strdata5[0]); EventTypeChoiceCol3.Choices.Add(strdata5[1]); EventTypeChoiceCol3.Choices.Add(strdata5[2]); EventTypeChoiceCol3.Choices.Add(strdata5[3]); EventTypeChoiceCol3.Update(); newList4.Fields.AddLookup("Alert", newList.ID, false); SPFieldLookup lkp3 = (SPFieldLookup)newList4.Fields["Alert"]; lkp3.LookupField = newList.Fields["Title"].InternalName; newList4.Fields.Add("ItemID", SPFieldType.Text, false); newList4.Update(); SPView view4 = newList4.DefaultView; view4.ViewFields.Add("Subject"); view4.ViewFields.Add("Body"); view4.ViewFields.Add("EventType"); view4.ViewFields.Add("Alert"); view4.ViewFields.Add("ItemID"); view4.Update(); newList4.Hidden = true; newList4.Update(); } catch (System.Exception Ex) { } }
public override void FeatureActivated(SPFeatureReceiverProperties properties) { FindWebApplication(properties); foreach (SPSite site in webApp.Sites) { try { site.Features.Add(new Guid("63DE505E-E5AB-422d-909A-09609FD40CC8"), true); } catch (Exception ex) { SPDiagnosticsService.Local.WriteTrace(0, new SPDiagnosticsCategory(ex.Source, TraceSeverity.High, EventSeverity.Error), TraceSeverity.High, ex.Message, ex.Data); //ex.ToString(); } try { site.Features.Remove(new Guid("F41CC668-37E5-4743-B4A8-74D1DB3FD8A4"), true); } catch (Exception ex) { SPDiagnosticsService.Local.WriteTrace(0, new SPDiagnosticsCategory(ex.Source, TraceSeverity.High, EventSeverity.Error), TraceSeverity.High, ex.Message, ex.Data); //ex.ToString(); } foreach (SPWeb web in site.AllWebs) { try { web.Features.Add(new Guid("63DE505E-E5AB-422d-909A-09609FD40CC8"), true); web.Update(); } catch (Exception ex) { SPDiagnosticsService.Local.WriteTrace(0, new SPDiagnosticsCategory(ex.Source, TraceSeverity.High, EventSeverity.Error), TraceSeverity.High, ex.Message, ex.Data); //ex.ToString(); } try { web.Features.Remove(new Guid("F41CC668-37E5-4743-B4A8-74D1DB3FD8A4"), true); web.Update(); } catch (Exception ex) { SPDiagnosticsService.Local.WriteTrace(0, new SPDiagnosticsCategory(ex.Source, TraceSeverity.High, EventSeverity.Error), TraceSeverity.High, ex.Message, ex.Data); //ex.ToString(); } } try { //OverrideBrowserCaps(properties); } catch (Exception ex) { SPDiagnosticsService.Local.WriteTrace(0, new SPDiagnosticsCategory(ex.Source, TraceSeverity.High, EventSeverity.Error), TraceSeverity.High, ex.Message, ex.Data); //ex.ToString(); } } }
// Uncomment the method below to handle the event raised before a feature is deactivated. public override void FeatureDeactivating(SPFeatureReceiverProperties properties) { DeactivateMembershipReviewList(properties); }
// Uncomment the method below to handle the event raised after a feature has been installed. //public override void FeatureInstalled(SPFeatureReceiverProperties properties) //{ //} // Uncomment the method below to handle the event raised before a feature is uninstalled. public override void FeatureUninstalling(SPFeatureReceiverProperties properties) { SetBackAlertTemplate(properties); }
public override void FeatureActivated(SPFeatureReceiverProperties properties) { SPWeb web = properties.Feature.Parent as SPWeb; if (web.WebTemplate.ToLower() == "websiteroot") { //Hemrika.SharePresence.WebSite.Modules.ErrorModule.ErrorModule, Hemrika.SharePresence.WebSite, Version=1.0.0.0, Culture=neutral, PublicKeyToken=11e6604a27f32a11 CreateWorkItem(web, "Hemrika.SharePresence.WebSite.Modules.ErrorModule.ErrorModule", "Hemrika.SharePresence.WebSite, Version=1.0.0.0, Culture=neutral, PublicKeyToken=11e6604a27f32a11"); CreateErrorWorkItem(web, HttpStatusCode.BadRequest); CreateErrorWorkItem(web, HttpStatusCode.Conflict); CreateErrorWorkItem(web, HttpStatusCode.ExpectationFailed); CreateErrorWorkItem(web, HttpStatusCode.Forbidden); CreateErrorWorkItem(web, HttpStatusCode.Gone); CreateErrorWorkItem(web, HttpStatusCode.LengthRequired); CreateErrorWorkItem(web, HttpStatusCode.MethodNotAllowed); CreateErrorWorkItem(web, HttpStatusCode.NotAcceptable); CreateErrorWorkItem(web, HttpStatusCode.NotFound); CreateErrorWorkItem(web, HttpStatusCode.PaymentRequired); CreateErrorWorkItem(web, HttpStatusCode.PreconditionFailed); CreateErrorWorkItem(web, HttpStatusCode.ProxyAuthenticationRequired); CreateErrorWorkItem(web, HttpStatusCode.RequestedRangeNotSatisfiable); CreateErrorWorkItem(web, HttpStatusCode.RequestEntityTooLarge); CreateErrorWorkItem(web, HttpStatusCode.RequestTimeout); CreateErrorWorkItem(web, HttpStatusCode.RequestUriTooLong); CreateErrorWorkItem(web, HttpStatusCode.Unauthorized); CreateErrorWorkItem(web, HttpStatusCode.UnsupportedMediaType); try { SPSecurity.CatchAccessDeniedException = true; } catch (Exception ex) { SPDiagnosticsService.Local.WriteTrace(0, new SPDiagnosticsCategory(ex.Source, TraceSeverity.High, EventSeverity.Error), TraceSeverity.High, ex.Message, ex.Data); } /* * SPSecurity.RunWithElevatedPrivileges(delegate() * { * try * { * SPSecurity.CatchAccessDeniedException = true; * * SPWebApplication webApp = web.Site.WebApplication; * if (webApp != null) * { * webApp.UpdateMappedPage(SPWebApplication.SPCustomPage.AccessDenied, "/_layouts/Error/" + HttpStatusCode.Unauthorized.ToString() + ".aspx;"); * //web.Site.WebApplication.UpdateMappedPage(SPWebApplication.SPCustomPage.Confirmation, ""); * webApp.UpdateMappedPage(SPWebApplication.SPCustomPage.Error, "/_layouts/Error/" + HttpStatusCode.BadRequest.ToString() + ".aspx;"); * webApp.UpdateMappedPage(SPWebApplication.SPCustomPage.Login, "/_layouts/Error/" + HttpStatusCode.Forbidden.ToString() + ".aspx;"); * //web.Site.WebApplication.UpdateMappedPage(SPWebApplication.SPCustomPage.RequestAccess, String.Format("{0}:{1};", "ErrorPage", "Error/" + HttpStatusCode.Forbidden.ToString() + ".aspx;")); * //web.Site.WebApplication.UpdateMappedPage(SPWebApplication.SPCustomPage.Signout, ""); * webApp.UpdateMappedPage(SPWebApplication.SPCustomPage.WebDeleted, "/_layouts/Error/" + HttpStatusCode.Gone.ToString() + ".aspx;"); * * webApp.Update(false); * } * } * catch (Exception ex) * { * ex.ToString(); * } * }); * * SPList specifiedList = web.GetList("Error"); * specifiedList.AnonymousPermMask64 = SPBasePermissions.ViewListItems; * specifiedList.Update(); */ } }
// Rimuovere il commento dal metodo seguente per gestire l'evento generato dopo l'attivazione di una funzionalità. //public override void FeatureActivated(SPFeatureReceiverProperties properties) //{ //} public override void FeatureActivated(SPFeatureReceiverProperties properties) { SPSite site = properties.Feature.Parent as SPSite; UpdateMasterpageGallery(properties, site.RootWeb); }
//private void UpdateProperty(string key, string value, SPWeb currentWeb) //{ // if (currentWeb.Properties.ContainsKey(key)) // { // currentWeb.Properties[key] = value; // } // else // { // currentWeb.Properties.Add(key, value); // } // currentWeb.Properties.Update(); //} // Uncomment the method below to handle the event raised after a feature has been activated. public override void FeatureActivated(SPFeatureReceiverProperties properties) { ActivateFBAManagement(properties); ActivateMembershipReviewList(properties); }
public override void FeatureActivated(SPFeatureReceiverProperties properties) { SPWeb web = properties.Feature.Parent as SPWeb; web.ApplyTheme("Contoso"); }
public override void FeatureInstalled(SPFeatureReceiverProperties properties) { }
// Uncomment the method below to handle the event raised before a feature is deactivated. public override void FeatureDeactivating(SPFeatureReceiverProperties properties) { SPWebApplication webApp = properties.Feature.Parent as SPWebApplication; DeleteJob(webApp.JobDefinitions); }
public override void FeatureActivated(SPFeatureReceiverProperties properties) { var web = (SPWeb)properties.Feature.Parent as SPWeb; MoveAndSetCustomerWizardFile(web); }
public override void FeatureDeactivating(SPFeatureReceiverProperties properties) { SPWeb web = properties.Feature.Parent as SPWeb; web.ApplyTheme("none"); }
// Uncomment the method below to handle the event raised after a feature has been installed. //public override void FeatureInstalled(SPFeatureReceiverProperties properties) //{ //} // Uncomment the method below to handle the event raised before a feature is uninstalled. public override void FeatureUninstalling(SPFeatureReceiverProperties properties) { var webApp = properties.Feature.Parent as SPWebApplication; RemoveFbaSettings(webApp, properties); }
public override void FeatureUninstalling(SPFeatureReceiverProperties properties) { }
// Uncomment the method below to handle the event raised after a feature has been activated. public override void FeatureActivated(SPFeatureReceiverProperties properties) { var webApp = properties.Feature.Parent as SPWebApplication; //Build MasterXmlFragment if SPListItem is blank or missing attributes using (SPSite siteCollection = new SPSite(SPContext.Current.Site.ID)) { using (SPWeb site = siteCollection.OpenWeb()) { try { SPList list = site.Lists.TryGetList("Nauplius.ADLDS.FBA - StsFarm"); if (list != null) { if (list.ItemCount >= 1) { foreach (SPListItem item in list.Items) { if (item["StsConfig"].ToString() == "MasterXmlFragment") { try { MasterXmlFragment.LoadXml((string)item["XMLStsConfig"]); } catch (XmlException) { MasterXmlFragment.AppendChild( MasterXmlFragment.CreateNode(XmlNodeType.Element, "system.web", "")); } if (MasterXmlFragment.SelectSingleNode(@"system.web/membership") == null) { CreateStsXPath(MasterXmlFragment, item, "system.web/membership"); } if (MasterXmlFragment.SelectSingleNode(@"system.web/membership/providers") == null) { CreateStsXPath(MasterXmlFragment, item, "system.web/membership/providers"); } if (MasterXmlFragment.SelectSingleNode(@"system.web/roleManager") == null) { CreateStsXPath(MasterXmlFragment, item, "system.web/roleManager"); } if (MasterXmlFragment.SelectSingleNode(@"system.web/roleManager/providers") == null) { CreateStsXPath(MasterXmlFragment, item, "system.web/roleManager/providers"); } if ( MasterXmlFragment.SelectSingleNode( @"system.web/roleManager[@enabled='true']") == null) { var roleManagerNode = (XmlElement) MasterXmlFragment.SelectSingleNode(@"system.web/roleManager"); roleManagerNode.SetAttribute("enabled", "true"); item["XMLStsConfig"] = MasterXmlFragment.OuterXml; try { item.Update(); } catch (SPException ex) { Logging.LogMessage(950, Logging.LogCategories.STSXML, TraceSeverity.Unexpected, String.Format( "Unable to update the StsFarm List in Central Administration. {0}", ex.StackTrace), new object[] { null }); throw new SPException( @"Unable to update the StsFarm List in Central Administration. Check to see if the item was removed."); } } } } } else { SPListItem item = list.Items.Add(); item["StsConfig"] = "MasterXmlFragment"; item["XMLStsConfig"] = @"<system.web><membership><providers /></membership><roleManager enabled='true'><providers /></roleManager></system.web>"; try { item.Update(); } catch (SPException ex) { Logging.LogMessage(950, Logging.LogCategories.STSXML, TraceSeverity.Unexpected, String.Format( "Unable to update the StsFarm List in Central Administration. {0}", ex.StackTrace), new object[] { null }); throw new SPException( @"Unable to update the StsFarm List in Central Administration. Check to see if the item was removed."); } } } } catch (SPException ex) { Logging.LogMessage(950, Logging.LogCategories.STSXML, TraceSeverity.Unexpected, String.Format("Unable to update the StsFarm List in Central Administration. {0}", ex.StackTrace), new object[] { null }); throw new SPException(@"Unable to update the StsFarm List in Central Administration. Validate the list exists."); } try { SPList list = site.Lists.TryGetList("Nauplius.ADLDS.FBA - WebApplicationSettings"); if (list != null) { SPListItemCollection items = list.Items; foreach (SPListItem item in items) { var zone = GetZone(item); if (item["WebApplicationUrl"].ToString() == webApp.GetResponseUri(zone).ToString()) { //Set the Membership and Role providers for the Web Application var ap = new SPFormsAuthenticationProvider( item["WebApplicationMembershipProvider"].ToString(), item["WebApplicationRoleProvider"].ToString()); //Set the custom URL try { var customUrl = item["CustomUrl"].ToString(); webApp.IisSettings[zone].ClaimsAuthenticationRedirectionUrl = new Uri(customUrl, UriKind.RelativeOrAbsolute); } catch (NullReferenceException) { //CustomUrl is null } try { webApp.IisSettings[zone].AddClaimsAuthenticationProvider(ap); webApp.Update(); webApp.ProvisionGlobally(); } catch (ArgumentException) { foreach ( var provider in webApp.IisSettings[zone].ClaimsAuthenticationProviders) { if (provider.ClaimProviderName == "Forms") { webApp.IisSettings[zone].DeleteClaimsAuthenticationProvider(provider); webApp.Update(); break; } } webApp.IisSettings[zone].AddClaimsAuthenticationProvider(ap); webApp.Update(); webApp.ProvisionGlobally(); } try { WebModifications.CreateWildcardNode(false, webApp, zone); WebModifications.CreateProviderNode(false, webApp, zone); WebModifications.CreateStsProviderNode(false, properties, zone); WebModifications.CreateAdminWildcardNode(false, webApp, zone); WebModifications.CreateAdminProviderNode(false, webApp, zone); var local = SPFarm.Local; var services = from s in local.Services where s.Name == "SPTimerV4" select s; var service = services.First(); foreach (SPJobDefinition job in service.JobDefinitions) { if (job.Name == tJobName) { if (job.IsDisabled) { job.IsDisabled = false; } job.Update(); job.RunNow(); } } } catch (SPException ex) { Logging.LogMessage(952, Logging.LogCategories.STSXML, TraceSeverity.Unexpected, String.Format("An unknown error has occurred. {0}", ex.StackTrace), new object[] { null }); throw new SPException(@"An unknown error has occurred. Please review the ULS file."); } } } } } catch (SPException ex) { Logging.LogMessage(951, Logging.LogCategories.STSXML, TraceSeverity.Unexpected, String.Format("Unable to update the WebApplicationSettings List in Central Administration. {0}", ex.StackTrace), new object[] { null }); throw new SPException(@"Unable to update the WebApplicationSettings List in Central Administration. Validate the list exists."); } } } }
protected void RemoveFbaSettings(SPWebApplication webApp, SPFeatureReceiverProperties properties) { using (SPSite siteCollection = new SPSite(SPContext.Current.Site.ID)) { using (SPWeb site = siteCollection.OpenWeb()) { try { SPList list = site.Lists.TryGetList("Nauplius.ADLDS.FBA - WebApplicationSettings"); if (list != null) { SPListItemCollection items = list.Items; foreach (SPListItem item in items) { var zone = GetZone(item); if (item["WebApplicationUrl"].ToString() == webApp.GetResponseUri(zone).AbsoluteUri) { //Remove the Forms Authentication provider for the Web Application try { foreach (var provider in webApp.IisSettings[zone].ClaimsAuthenticationProviders) { if (provider.ClaimProviderName == "Forms") { webApp.IisSettings[zone].DeleteClaimsAuthenticationProvider(provider); webApp.Update(); webApp.ProvisionGlobally(); break; } } } catch (ArgumentNullException) { //Forms provider already removed } catch (ArgumentException) { //Claims provider is null } finally { webApp.IisSettings[zone].ClaimsAuthenticationRedirectionUrl = null; webApp.Update(); webApp.ProvisionGlobally(); } WebModifications.CreateWildcardNode(true, webApp, zone); WebModifications.CreateProviderNode(true, webApp, zone); WebModifications.CreateStsProviderNode(true, properties, zone); WebModifications.CreateAdminWildcardNode(true, webApp, zone); WebModifications.CreateAdminProviderNode(true, webApp, zone); var local = SPFarm.Local; var services = from s in local.Services where s.Name == "SPTimerV4" select s; var service = services.First(); foreach (var job in service.JobDefinitions) { if (job.Name == tJobName) { if (job.IsDisabled) { job.IsDisabled = false; } job.Update(); job.RunNow(); } } } } } } catch (SPException ex) { Logging.LogMessage(951, Logging.LogCategories.STSXML, TraceSeverity.Unexpected, String.Format("Unable to update the WebApplicationSettings List in Central Administration. {0}", ex.StackTrace), new object[] { null }); throw new SPException(@"Unable to update the WebApplicationSettings List in Central Administration. Validate the list exists."); } } } }
// Uncomment the method below to handle the event raised after a feature has been activated. public override void FeatureActivated(SPFeatureReceiverProperties properties) { // Get the Catalog for the SharePoint site BdcService service = SPFarm.Local.Services.GetValue <BdcService>(String.Empty); SPSite site = new SPSite("http://sp2016:2016/"); SPServiceContext context = SPServiceContext.GetContext(site); AdministrationMetadataCatalog catalog = service.GetAdministrationMetadataCatalog(context); catalog.GetModels("EmployeeModel")?.ToList().ForEach(m => m.Delete()); // Create a new Employee Model // NOTE: Assume that the "EmployeeModel" Model // does not already exist. Model EmployeeModel = Model.Create("EmployeeModel", true, catalog); // Make a new Employee LobSystem // NOTE: Assume that the "AdventureWorks" LobSystem // does not already exist. LobSystem adventureWorksLobSystem = EmployeeModel.OwnedReferencedLobSystems.Create("AdventureWorks", true, SystemType.Database); // Make a new AdventureWorks LobSystemInstance. LobSystemInstance adventureWorksLobSystemInstance = adventureWorksLobSystem.LobSystemInstances.Create("AdventureWorks", true); // Set the connection properties. adventureWorksLobSystemInstance.Properties.Add( "ShowInSearchUI", ""); adventureWorksLobSystemInstance.Properties.Add( "DatabaseAccessProvider", "SqlServer"); adventureWorksLobSystemInstance.Properties.Add( "RdbConnection Data Source", "SP2016"); adventureWorksLobSystemInstance.Properties.Add( "RdbConnection Initial Catalog", "AdventureWorks2016"); adventureWorksLobSystemInstance.Properties.Add( "AuthenticationMode", "RdbCredentials"); adventureWorksLobSystemInstance.Properties.Add( "SsoProviderImplementation", "Microsoft.Office.SecureStoreService.Server.SecureStoreProvider, Microsoft.Office.SecureStoreService, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"); adventureWorksLobSystemInstance.Properties.Add( "SsoApplicationId", "Adventure"); adventureWorksLobSystemInstance.Properties.Add( "RdbConnection Pooling", "true"); // Create a new Employee Entity. Entity EmployeeEntity = Entity.Create( "Employee", "AdventureWorks", true, new Version("1.0.0.4"), 10000, CacheUsage.Default, adventureWorksLobSystem, EmployeeModel, catalog); // Set the identifier to the EmployeeID column. EmployeeEntity.Identifiers.Create( "BusinessEntityID", true, "System.Int32"); // Create the Finder Method, // i.e. the method to return all rows. CreateReadListMethod(catalog, EmployeeEntity); // Create the Specific Finder Method, // i.e. the method to return one row. CreateReadItemMethod(catalog, EmployeeEntity); // Validate the Employee Entity. ActivationError[] activationErrors = EmployeeEntity.Validate(); // Check if the validation failed. if (activationErrors.Count() == 0) { // The validation was successful so publish the Employee Entity. EmployeeEntity.Activate(); } }
public override void FeatureActivated(SPFeatureReceiverProperties properties) { }
public override void FeatureUninstalling(SPFeatureReceiverProperties properties) { ////TODO: place receiver code here or remove method }
public override void FeatureDeactivating(SPFeatureReceiverProperties properties) { properties.SetMasterPage(); }
public override void FeatureActivated(SPFeatureReceiverProperties properties) { Setup.Install((properties.Feature.Parent as SPSite).RootWeb); }