Community
Showing results for 
Search instead for 
Do you mean 
Reply

Plugin Starting Point

Copper Super Contributor
Posts: 52
Country: United_Kingdom

Plugin Starting Point

[ Edited ]

Hi Everyone, 

 

After a few questions from community member on how to get started with an Act! plugin I thought it might be of benefit if I posted a class template that demonstrates this. 

 

C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Act.UI.Core;
using Act.UI;
using Act.Framework;
using System.Windows.Forms;

namespace Plugin1
{
    public class Class1 : IPlugin
    {
        private ActApplication oApp;

        //LOAD
        public void OnLoad(ActApplication ACTApp)
        {
            oApp = ACTApp;

            oApp.AfterLogon += new EventHandler(oApp_AfterLogon);
            oApp.BeforeLogoff += new EventHandler(oApp_BeforeLogoff);
        }

        //LOGON LOGOFF EVENTS
        private void oApp_AfterLogon(object sender, EventArgs e)
        {
        }
        private void oApp_BeforeLogoff(object sender, EventArgs e)
        {
        }
    
        //UNLOAD
        public void OnUnLoad()
        {
            oApp.AfterLogon -= oApp_AfterLogon;
            oApp.BeforeLogoff -= oApp_BeforeLogoff;
        }
    }
}

 

VB.NET

Imports System.Collections.Generic
Imports System.Linq
Imports System.Text
Imports Act.UI.Core
Imports Act.UI
Imports Act.Framework
Imports System.Windows.Forms

Namespace Plugin1
Public Class Class1
Implements IPlugin
Private oApp As ActApplication
Friend Shared HostApplication As ActApplication 'Reference to the ACT! Application
Friend Shared HostFramework As Act.Framework.ActFramework 'Reference to the ACT! Framework

'LOAD
Public Sub OnLoad(ByVal ActApp As ActApplication) Implements IPlugin.OnLoad

HostApplication = ActApp
HostFramework = ActApp.ActFramework

AddHandler HostApplication.AfterLogon, AddressOf oApp_AfterLogon
AddHandler HostApplication.BeforeLogon, AddressOf oApp_BeforeLogoff

End Sub

'LOGON LOGOFF EVENTS
Private Sub oApp_AfterLogon(sender As Object, e As EventArgs)
AddHandler HostApplication.ViewLoaded, AddressOf oApp_viewLoaded

End Sub
Private Sub oApp_BeforeLogoff(sender As Object, e As EventArgs)
End Sub

'UNLOAD
Public Sub OnUnLoad() Implements IPlugin.OnUnLoad
RemoveHandler HostApplication.AfterLogon, AddressOf oApp_AfterLogon
RemoveHandler HostApplication.BeforeLogoff, AddressOf oApp_BeforeLogoff
End Sub

Private Sub oApp_viewLoaded(sender As Object, e As ViewEventArgs)



End Sub

End Class
End Namespace

I hope this helps kickstart some plugin projects.

 

Regards,

 

 

Russell

Avid Listener
Posts: 49
Country: USA

Re: Plugin Starting Point

Could someone tell me where I'm going wrong with this?  It's saying ActApplication could not be found:

 

using System;

using Act.Web.Framework;

using Act.UI;

 

namespace Plugin1

{

public class Class1 : IWebPlugin

{

public ActApplication oApp;

//LOAD

public void OnLoad(ActApplication ACTApp)

{

oApp = ACTApp;

oApp.AfterLogon += new EventHandler(oApp_AfterLogon);

oApp.BeforeLogoff += new EventHandler(oApp_BeforeLogoff);

}

//LOGON LOGOFF EVENTS

private void oApp_AfterLogon(object sender, EventArgs e)

{

}

private void oApp_BeforeLogoff(object sender, EventArgs e)

{

}

//UNLOAD

public void OnUnLoad()

{

oApp.AfterLogon -= oApp_AfterLogon;

oApp.BeforeLogoff -= oApp_BeforeLogoff;

}

public void Init(ACTSessionManager session)

{

throw new NotImplementedException();

}

}

}

 

Kevin Varnon
ClientTrax CRM
Kansas City
(785) 408-3702
kevin@clienttrax.com
Copper Elite Contributor
Posts: 81
Country: Canada

Re: Plugin Starting Point

[ Edited ]

Check your references to make sure you added a reference to Act.UI.dll to your project but it looks like you are trying to create an Act For Web Plugin and I believe ActApplication is only used if creating an Act For Windows plugin. So you shouldn't even really be working with the ActApplication class.

Ahsan Khalid

Chief Technology Officer
Keystroke Quality Computing Inc.
www.keystroke.ca

Avid Listener
Posts: 49
Country: USA

Re: Plugin Starting Point

I as trying to create a plugin for Act! for Web.  What should I be working with?  I took it straight from the example.

Kevin Varnon
ClientTrax CRM
Kansas City
(785) 408-3702
kevin@clienttrax.com
Administrator
Posts: 221
Country: United States

Re: Plugin Starting Point

There are two different types of plugins; Windows (IPlugin) and Web (IWebPlugin). While it's technically possible to make one plugin that implements both interfaces, it's more practical to implement each interface separately in two different assemblies (Or you could package together). IWebPlugin is located in Act.Web.Framework.dll.

Search the forums here for IWebPlugin and you should find some simple examples to get you started... I have given a few webinars in the past, maybe it's time to do another.
Administrator
Posts: 221
Country: United States

Re: Plugin Starting Point

Look at this presentation thread and look at the sample code...

 

http://community.act.com/t5/Act-Developer-s-Forum/Sage-ACT-Premium-for-Web-plugin-presentation/m-p/1...