AnsweredAssumed Answered

Epdm AddIn -> Button on Datacard

Question asked by Mario Zahren on Jun 22, 2016
Latest reply on Jun 24, 2016 by Mario Zahren

Hello everybody.

I have created an addin that should be activated by a push of a button on the data card. This addin writes values in variable fields.

Therefore I use the function "poCmdMgr.AddHook (EdmCmdType.EdmCmd_CardButton);"

 

In debug mode everything is going well if I have a file selected but if I do start a search, I get the following error message "0x080004003 - an invalid pointer was supplied to the method"

 

Here the code I have created

 

using System;
using Microsoft.VisualBasic;
using EdmLib;
using System.Runtime.InteropServices;

namespace CardButtonControl
{
    public class CardButton : IEdmAddIn5
    {
        public void GetAddInInfo(ref EdmAddInInfo poInfo, IEdmVault5 poVault, IEdmCmdMgr5 poCmdMgr)
        {  
            poInfo.mbsAddInName = "CardButtons";
            poInfo.mbsCompany = "Mario Boelingen";
            poInfo.mbsDescription = "Knöpfe auf Datenkarte.";
            poInfo.mlAddInVersion = 1002;

            poInfo.mlRequiredVersionMajor = 14;
            poInfo.mlRequiredVersionMinor = 3;

            poCmdMgr.AddHook(EdmCmdType.EdmCmd_CardButton);
        }

        public void OnCmd(ref EdmCmd poCmd, ref Array ppoData)
        {
            IEdmVault5 vault = new EdmVault5() as IEdmVault5;
            vault.LoginAuto("hegenscheidt", 0);

            const string varNameProduktArt = "HS_Produktart";
            const string varNameProduktArtLong = "HS_ProduktartLang";
            const string varNameArtikelart = "HS_Artikelart";
            const string varNameArtikelArtLong = "HS_ArtikelartLang";
            const string varNameProdKlasse = "HS_Produktklasse";
            const string varNameProdKlasseLong = "HS_ProduktklasseLang";
            const string varNameArtikelGruppe = "HS_Artikelgruppe";
            const string varNameArtikelGruppeLong = "HS_ArtikelGrpLang";
            const string varNameProduktBereich = "HS_Produktbereich";
            const string varNameTeileArt = "HS_Teileart";

            string varValProduktArt = null;
            string varValProduktArtLong = null;
            string varValArtikelArt = null;
            string varValArtikelArtLong = null;
            string varValProdKlasse = null;
            string varValProdKlasseLong = null;
            string varValArtikelGruppe = null;
            string varValArtikelGruppeLong = null;
            string varValProduktBereich = null;
            string varValTeileArt = null;
            
            string ConfigName = null;
            string filePath = null;

            int index = 0;
            int last = 0;
            index = Information.LBound(ppoData);
            last = Information.UBound(ppoData);
            int FileID = 0;
            int FolderID = 0;

            FileID = ((EdmCmdData)ppoData.GetValue(index)).mlObjectID1;
            FolderID = ((EdmCmdData)ppoData.GetValue(index)).mlObjectID2;
            ConfigName = ((EdmCmdData)ppoData.GetValue(index)).mbsStrData1;
            filePath = ((EdmCmdData)ppoData.GetValue(index)).mbsStrData2;

            IEdmFile8 File = default(IEdmFile8);
            IEdmFolder5 ppoRetParentFolder;
            File = (IEdmFile8)vault.GetFileFromPath(filePath, out ppoRetParentFolder);

            IEdmEnumeratorVariable8 varEnum1 = default(IEdmEnumeratorVariable8);
            varEnum1 = (IEdmEnumeratorVariable8)File.GetEnumeratorVariable();

            try
            {
                switch (poCmd.mbsComment)
                {
                    #region case Pb1SetFertMech
                    case "Pb1SetFertMech":
                        varValProduktArt = "004";
                        varValProduktArtLong = "Fertigungsteile";
                        varValArtikelArt = "F";
                        varValArtikelArtLong = "Fertigungsartikel";
                        varValProdKlasse = "110045";
                        varValProdKlasseLong = "anonymer Maschinenvorrat PB I";
                        varValArtikelGruppe = "025";
                        varValArtikelGruppeLong = "Eigenfert. anonym Maschine";
                        varValProduktBereich = "PB 1";
                        varValTeileArt = "Fertigungsteil Mech.";
                        
                        varEnum1.SetVar(varNameProduktArt, ConfigName, varValProduktArt);
                        varEnum1.SetVar(varNameProduktArtLong, ConfigName, varValProduktArtLong);
                        varEnum1.SetVar(varNameArtikelArt, ConfigName, varValArtikelArt);
                        varEnum1.SetVar(varNameArtikelArtLong, ConfigName, varValArtikelArtLong);
                        varEnum1.SetVar(varNameProdKlasse, ConfigName, varValProdKlasse);
                        varEnum1.SetVar(varNameProdKlasseLong, ConfigName, varValProdKlasseLong);
                        varEnum1.SetVar(varNameArtikelGruppe, ConfigName, varValArtikelGruppe);
                        varEnum1.SetVar(varNameArtikelGruppeLong, ConfigName, varValArtikelGruppeLong);
                        varEnum1.SetVar(varNameProduktBereich, ConfigName, varValProduktBereich);
                        varEnum1.SetVar(varNameTeileArt, ConfigName, varValTeileArt);
                        varEnum1.CloseFile(true);
                        break;
                        #endregion

                    #region case Pb1SetFertAufgl
                    case "Pb1SetFertAufgl":
                        blablabla
                    #endregion
                }

            }

            catch (COMException exp)
            {
                string errorName, errorDesc;
                vault.GetErrorString(exp.ErrorCode, out errorName, out errorDesc);
                vault.MsgBox(0, errorDesc, EdmMBoxType.EdmMbt_OKOnly, errorName);
            }

        }

    }

}

 

What am I doing wrong??

Any help would bo great!

 

Mario

Outcomes