Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
using System;
using PX.Data;
using System.Collections.Specialized;
using Customization;
using System.Web.Security;
using System.IO;
using PX.Common;
namespace ChangeWebConfig
{
//Customization plugin is used to execute custom actions after customization project was published
public class MyPlugIn: CustomizationPlugin
{
//This method executed right after website files were updated, but before website was restarted
//Method invoked on each cluster node in cluster environment
//Method invoked only if runtimecompilation is enabled
//Do not access custom code published to bin folder, it may not be loaded yet
public override void OnPublished()
{
this.WriteLog("OnPublished Event");
String file = File.ReadAllText(Path.Combine(PX.Data.Update.PXInstanceHelper.RootFolder, "packages.config"));
file = webconfig.Replace("</packages>",
"<package id=/"Newtonsoft.Json/" version=/"6.0.8/" targetFramework=/"net451/" /></packages>");
File.WriteAllText(Path.Combine(PX.Data.Update.PXInstanceHelper.RootFolder, "packages.config"), file);
}
//This method executed after customization was published and website was restarted.
public override void UpdateDatabase()
{
this.WriteLog("UpdateDatabase Event");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment