Author Topic: Steps for adding functionality to the AppServer  (Read 9089 times)

Offline IvarE

  • Newbie
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Steps for adding functionality to the AppServer
« on: May 07, 2007, 01:00:25 AM »
Hi,

I am trying to add some integration functionality to the AppServer, but I don't know how to register my library to the AppServer.
I have:
1) created a library (dll in C#) with functions that update a postgresql database
2) copied the dll file to the assemblies directory for my offline system
3) added a new AppServerRule in the Toolkit system, but here I run into some problems since I'm not sure how to fill the AppServer Rule form. I put:
    i) Name: the name of the assembly file (which is the same as my namespace name)
    ii) GUID: my namespace/my class name
    iii) Assembly Name: my namespace name
    iv) Class Name: my class name
    v) I even checked both check boxes, .NET ASR and Execute Uses Transaction
4) loaded the assembly using the LCS Customization Assistant

One problem is that when I'm creating a new Agent that is supposed to call functions from the assembly, I get a message saying: "Form initialized successfully. However, there is no server script attached to this form".
So, I guess my question is: How/where am I supposed to attach the server script to the form?

The c#-library implements IRAppScript

Thanks a lot for any help.
//Ivar

Offline IvarE

  • Newbie
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: Steps for adding functionality to the AppServer
« Reply #1 on: May 07, 2007, 11:34:25 PM »
OK. I figured out that. It was just to add the AppServer Rule in the Properties form for the Active Form.
Now I don't get the warning, however my agent doesn't seem to call the functions in my AppServer Rule.
What am I doing wrong?
Thanks again.

Offline kwiecin

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 84
  • Karma: +0/-0
  • Gender: Male
    • View Profile
    • Pivotal CRM Blog
Re: Steps for adding functionality to the AppServer
« Reply #2 on: May 08, 2007, 12:48:55 AM »
Have you set the properties at Lifecycle Server tab at eRaletionship Enterprise Manager?
There is property "Agent System" where you should put your system's name.

Best regards,
MK
Marcin Kwiecinski
CRM || ITIL Consultant
Microsoft Certified Professional
-------------------------------------------------------------------------
Pivotal CRM Blog - Your everyday Pivotal Web Toolkit
www.pivotalcrm.info

Offline PivotalTim

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 164
  • Karma: +6/-0
    • View Profile
    • xemware
Re: Steps for adding functionality to the AppServer
« Reply #3 on: May 13, 2007, 10:25:59 PM »
It sounds like Agent System is set correctly, but...

I believe the Active Form component only supports IRFormScript interface, not IRAppScript (you only mention IRAppScript in your original post).

So, you actually want to have an IRFormScript.Execute method.
Tim Shnaider
xemware limited
http://www.xemware.com

Looksie - Prototyping Covered!
http://www.looksie.me

Offline Rus

  • Administrator
  • Hero Member
  • *****
  • Posts: 122
  • Karma: +0/-1
    • View Profile
Re: Steps for adding functionality to the AppServer
« Reply #4 on: May 17, 2007, 09:22:36 PM »
PivotalTim is right, you are using the wrong interface.

NB: I advise against using ASRs through ActiveForm component.
One Stop Shop Pivotal CRM Support and Development Service

http://www.pivotalcrmsupport.com

Offline IvarE

  • Newbie
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: Steps for adding functionality to the AppServer
« Reply #5 on: May 17, 2007, 11:19:42 PM »
I was implementing the IRAppScript interface instead of IRFormScript because my first thought was to use the library functionality in other parts of Pivotal (not only in a form). But having it working in a form is already a great step for me.

Thank you all!
//Ivar

Offline Rommel

  • Full Member
  • ***
  • Posts: 35
  • Karma: +0/-0
  • Gender: Male
  • forza AC MILAN
    • View Profile
Re: Steps for adding functionality to the AppServer
« Reply #6 on: April 29, 2008, 08:41:57 AM »
Just to guide how the implementation class should look like in a .NET 2.0 ASR:


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
using System;
using System.Xml;
using System.Text;
using System.Collections;
using System.Diagnostics;
using System.Reflection;
using AN.Utilities;
using Pivotal.Interop.ADODBLib;
using Pivotal.Interop.RDALib;
using Pivotal.Application.Foundation.Utility;
using Pivotal.Application.Foundation.Data.Element;
using Pivotal.Application.AltNet.ANOutboundEmail;

//using Pivotal.Application.Foundation.Data;
//using Pivotal.Application.Foundation.BusinessRule;

namespace Pivotal.Application.AltNet.ANOutboundEmail
{
    /// <summary>
    /// OutboundEmail Form ASR
    /// </summary>
    /// <history>
    /// Revision#      Date          Author            Description
    /// 1.0.0.0        25/12/2007  Ramy Abou El Dahab  Initial Version
    /// </history>
    public class OutboundEmail : IRFormScript
    {
        #region Private Properties
        private IRSystem7 m_rdaSystem;
        private bool IsLogged = false;
        EmailProcessing objEmailProcess = new EmailProcessing();
        #endregion

        #region IRFormScript Implementations

        /// <summary>
        /// AddFormData
        /// </summary>
        /// <history>
        /// Revision# Date          Author                  Description
        /// 1.0.0.0   07/01/2007    Ramy Abou El Dahab      Initial Version
        /// </history>
        /// <param name="pForm"></param>
        /// <param name="recordsets"></param>
        /// <param name="parameterList"></param>
        /// <returns></returns>
        public virtual object AddFormData(IRForm pForm, object recordsets, ref object parameterList)
        {
            object vntfOutboundEmail_Id = DBNull.Value;
            try
            {
                vntfOutboundEmail_Id = pForm.DoAddFormData(recordsets, ref parameterList);
            }

            catch (Exception e)
            {
                if (!this.IsLogged)
                {
                    ANLogger AN_Logger = new ANLogger(MethodBase.GetCurrentMethod().DeclaringType.Name.ToString(), new StackFrame().GetMethod().Name.ToString());
                    AN_Logger.LogApplicationError(e.Message, m_rdaSystem.CurrentUserName(), m_rdaSystem.SystemName);
                }
                throw new PivotalApplicationException(e.Message, e, m_rdaSystem);
            }

            return vntfOutboundEmail_Id;
        }

        /// <summary>
        /// DeleteFormData
        /// </summary>
        /// <history>
        /// Revision# Date          Author                  Description
        /// 1.0.0.0   07/01/2007    Ramy Abou El Dahab      Initial Version
        /// </history>
        /// <param name="pForm"></param>
        /// <param name="recordId"></param>
        /// <param name="parameterList"></param>
        public virtual void DeleteFormData(IRForm pForm, object recordId, ref object parameterList)
        {
            try
            {
                pForm.DoDeleteFormData(recordId, ref parameterList);
            }
            catch (Exception e)
            {
                if (!this.IsLogged)
                {
                    ANLogger AN_Logger = new ANLogger(MethodBase.GetCurrentMethod().DeclaringType.Name.ToString(), new StackFrame().GetMethod().Name.ToString());
                    AN_Logger.LogApplicationError(e.Message, m_rdaSystem.CurrentUserName(), m_rdaSystem.SystemName);
                }
                throw new PivotalApplicationException(e.Message, e, m_rdaSystem);
            }
        }

        /// <summary>
        /// Execute Method
        /// </summary>
        /// <history>
        /// Revision# Date          Author                  Description
        /// 1.0.0.0   07/01/2007    Ramy Abou El Dahab      Initial Version
        /// </history>
        /// <param name="pForm"></param>
        /// <param name="MethodName">Method to be used executed</param>
        /// <param name="parameterList"></param>
        ///
        public virtual void Execute(IRForm pForm, string MethodName, ref object parameterList)
        {
            object returnValue = DBNull.Value;
            try
            {
                TransitionPointParameter transitionPointParameter = (TransitionPointParameter)m_rdaSystem
                            .ServerScripts[AppServerRuleData.TransitionPointParameterAppServerRuleName].CreateInstance();
                transitionPointParameter.ParameterList = parameterList;
                object[] userDefParameterArray = (object[])transitionPointParameter.GetUserDefinedParameterArray();

                switch (MethodName)
                {
                    case ANOutboundEmail.Methods.ProcessEmails :
                        objEmailProcess.RdaSystem = this.m_rdaSystem;
                        objEmailProcess.ProcessEmails();
                        objEmailProcess = null;
                        break;
                   
                    default:
                        throw new PivotalApplicationException("No implementations for Execute Methods");
                }

            }
            catch (Exception e)
            {
                if (!this.IsLogged)
                {
                    ANLogger AN_Logger = new ANLogger(MethodBase.GetCurrentMethod().DeclaringType.Name.ToString(), new StackFrame().GetMethod().Name.ToString());
                    AN_Logger.LogApplicationError(e.Message, m_rdaSystem.CurrentUserName(), m_rdaSystem.SystemName);
                }
                throw new PivotalApplicationException(e.Message, e, m_rdaSystem);
            }
        }

        /// <summary>
        /// LoadFormData
        /// </summary>
        /// <history>
        /// Revision# Date          Author                  Description
        /// 1.0.0.0   07/01/2007    Ramy Abou El Dahab      Initial Version
        /// </history>
        /// <param name="pForm"></param>
        /// <param name="recordId"></param>
        /// <param name="parameterList"></param>
        /// <returns></returns>
        public virtual object LoadFormData(IRForm pForm, object recordId, ref object parameterList)
        {
            try
            {
                // set the form recordset
                object recordsetList = pForm.DoLoadFormData(recordId, ref parameterList);

                // Checking and setting of the system parameters
                TransitionPointParameter transitionPointParameter = (TransitionPointParameter)m_rdaSystem
                    .ServerScripts[AppServerRuleData.TransitionPointParameterAppServerRuleName].CreateInstance();
                if (!transitionPointParameter.HasValidParameters()) transitionPointParameter.Construct();

                // Get primary recordset
                object[] recordsetArray = (object[])recordsetList;

                return recordsetList;
            }
            catch (Exception e)
            {
                ANLogger AN_Logger = new ANLogger(MethodBase.GetCurrentMethod().DeclaringType.Name.ToString(), new StackFrame().GetMethod().Name.ToString());
                AN_Logger.LogApplicationError(e.Message, m_rdaSystem.CurrentUserName(), m_rdaSystem.SystemName);
                throw new PivotalApplicationException(e.Message, e, m_rdaSystem);
            }

        }

        /// <summary>
        /// NewFormData
        /// </summary>
        /// <history>
        /// Revision# Date          Author                  Description
        /// 1.0.0.0   07/01/2007    Ramy Abou El Dahab      Initial Version
        /// </history>
        /// <param name="pForm"></param>
        /// <param name="parameterList"></param>
        /// <returns></returns>
        public virtual object NewFormData(IRForm pForm, ref object parameterList)
        {
            object vntrecordsets = null;
            try
            {
                // Checking and setting of the system parameters
                TransitionPointParameter transitionPointParameter = (TransitionPointParameter)m_rdaSystem.ServerScripts[AppServerRuleData.TransitionPointParameterAppServerRuleName].CreateInstance();
                transitionPointParameter.ParameterList = parameterList;
                if (!transitionPointParameter.HasValidParameters()) transitionPointParameter.Construct();

                // Get recordset array for the active form
                vntrecordsets = pForm.DoNewFormData(ref parameterList);

                return vntrecordsets;
            }
            catch (Exception e)
            {
                ANLogger AN_Logger = new ANLogger(MethodBase.GetCurrentMethod().DeclaringType.Name.ToString(), new StackFrame().GetMethod().Name.ToString());
                AN_Logger.LogApplicationError(e.Message, m_rdaSystem.CurrentUserName(), m_rdaSystem.SystemName);
                throw new PivotalApplicationException(e.Message, e, m_rdaSystem);
            }
        }

        /// <summary>
        /// NewSecondaryData
        /// </summary>
        /// <history>
        /// Revision# Date          Author                  Description
        /// 1.0.0.0   07/01/2007    Ramy Abou El Dahab      Initial Version
        /// </history>
        /// <param name="pForm"></param>
        /// <param name="SecondaryName"></param>
        /// <param name="parameterList"></param>
        /// <param name="Recordset"></param>
        public virtual void NewSecondaryData(IRForm pForm, object SecondaryName, ref object parameterList, ref Recordset Recordset)
        {
            try
            {
                // Save new secondary data
                pForm.DoNewSecondaryData(SecondaryName, ref parameterList, Recordset);

            }
            catch (Exception e)
            {
                ANLogger AN_Logger = new ANLogger(MethodBase.GetCurrentMethod().DeclaringType.Name.ToString(), new StackFrame().GetMethod().Name.ToString());
                AN_Logger.LogApplicationError(e.Message, m_rdaSystem.CurrentUserName(), m_rdaSystem.SystemName);
                throw new PivotalApplicationException(e.Message, e, m_rdaSystem);
            }
        }

        /// <summary>
        /// SaveFormData
        /// </summary>
        /// <history>
        /// Revision# Date          Author                  Description
        /// 1.0.0.0   07/01/2007    Ramy Abou El Dahab      Initial Version
        /// </history>
        /// <param name="pForm"></param>
        /// <param name="recordsets"></param>
        /// <param name="parameterList"></param>
        public virtual void SaveFormData(IRForm pForm, object recordsets, ref object parameterList)
        {
            try
            {

                // Checking and setting of the system parameters
                TransitionPointParameter transitionPointParameter = (TransitionPointParameter)m_rdaSystem.ServerScripts[AppServerRuleData.TransitionPointParameterAppServerRuleName].CreateInstance();
                transitionPointParameter.ParameterList = parameterList;
                if (!transitionPointParameter.HasValidParameters()) transitionPointParameter.Construct();


                // Get primary recordset
                object[] recordsetArray = (object[])recordsets;

                // save form data
                pForm.DoSaveFormData(recordsets, ref parameterList);

            }
            catch (Exception e)
            {
                if (!this.IsLogged)
                {
                    ANLogger AN_Logger = new ANLogger(MethodBase.GetCurrentMethod().DeclaringType.Name.ToString(), new StackFrame().GetMethod().Name.ToString());
                    AN_Logger.LogApplicationError(e.Message, m_rdaSystem.CurrentUserName(), m_rdaSystem.SystemName);
                }
                throw new PivotalApplicationException(e.Message, e, m_rdaSystem);

            }
        }

        /// <summary>
        /// IRSystem reference variables for any other procedures in the current module.
        /// </summary>
        /// <param name="pSystem">Contains the current IRSystem Instance Reference</param>
        /// <history>
        /// Revision# Date          Author                  Description
        /// 1.0.0.0   07/01/2007    Ramy Abou El Dahab      Initial Version
        /// </history>
        public virtual void SetSystem(RSystem pSystem)
        {
            try
            {
                m_rdaSystem = (IRSystem7)pSystem;
            }
            catch (Exception e)
            {
                if (!this.IsLogged)
                {
                    ANLogger AN_Logger = new ANLogger(MethodBase.GetCurrentMethod().DeclaringType.Name.ToString(), new StackFrame().GetMethod().Name.ToString());
                    AN_Logger.LogApplicationError(e.Message, m_rdaSystem.CurrentUserName(), m_rdaSystem.SystemName);
                }
                throw new PivotalApplicationException(e.Message, e, m_rdaSystem);
            }
        }
       
        #endregion
    }
}