コード例 #1
0
 internal void Apply(UserObjectsMD userObject, string tableName)
 {
     userObject.Code       = ObjectId;
     userObject.Name       = ObjectName;
     userObject.ObjectType = ObjectType;
     userObject.TableName  = tableName;
 }
コード例 #2
0
 private void DisableAllServices(UserObjectsMD userObject)
 {
     userObject.CanFind         = BoYesNoEnum.tNO;
     userObject.CanDelete       = BoYesNoEnum.tNO;
     userObject.CanCancel       = BoYesNoEnum.tNO;
     userObject.CanClose        = BoYesNoEnum.tNO;
     userObject.CanLog          = BoYesNoEnum.tNO;
     userObject.ManageSeries    = BoYesNoEnum.tNO;
     userObject.CanYearTransfer = BoYesNoEnum.tNO;
 }
コード例 #3
0
        /// <summary>
        /// Adds the UDO object into the current company Database.
        /// </summary>
        /// <param name="company">SAPbobsCOM.Company we are connected to.</param>
        /// <returns>Return value of the UserObjectsMD.Add() call.</returns>
        public int Add(Company company)
        {
            UserObjectsMD udo = (UserObjectsMD)
                                company.GetBusinessObject(BoObjectTypes.oUserObjectsMD);

            udo.Code       = Code;
            udo.Name       = Name;
            udo.TableName  = Table;
            udo.ObjectType = Type;

            foreach (string child in Children)
            {
                udo.ChildTables.TableName = child;
                udo.ChildTables.Add();
            }

            // Services Definition
            udo.CanFind = CanFind;
            if (CanFind == BoYesNoEnum.tYES)
            {
                for (int i = 0; i < FindColumnsAlias.GetLength(0); i++)
                {
                    udo.FindColumns.ColumnAlias       = FindColumnsAlias[i];
                    udo.FindColumns.ColumnDescription = FindColumnsDesc[i];
                    udo.FindColumns.Add();
                }
            }
            udo.CanDelete       = CanDelete;
            udo.CanCancel       = CanCancel;
            udo.CanClose        = CanClose;
            udo.ManageSeries    = ManageSeries;
            udo.CanYearTransfer = CanYearTransfer;
            udo.CanLog          = CanLog;
            udo.LogTableName    = LogTableName;

            int ret = udo.Add();

#if     DEBUG
            if (ret != 0)
            {
                int    errcode;
                string errmsg;
                company.GetLastError(out errcode, out errmsg);
                System.Console.Out.WriteLine("UDO " + Name + " : " + errmsg);
            }
#endif

            // clean DI object
            System.Runtime.InteropServices.Marshal.ReleaseComObject(udo);
            udo = null;
            //System.GC.Collect();
            //System.GC.WaitForPendingFinalizers();

            return(ret);
        }
コード例 #4
0
        internal void Apply(UserObjectsMD userObject)
        {
            // the properties are unset (null) at this point in the userObject
            // we set them to tNO to avoid the no value found exception
            DisableAllServices(userObject);

            foreach (var service in services)
            {
                ActivateService(service, userObject);
            }
        }
コード例 #5
0
ファイル: InstallTest.cs プロジェクト: wgasparin/dover
        private void removeUDOs(string[] udos)
        {
            SAPbouiCOM.Application b1App         = app.Resolve <SAPbouiCOM.Application>();
            UserObjectsMD          userObjectsMD = (UserObjectsMD)b1Company.GetBusinessObject(BoObjectTypes.oUserObjectsMD);

            foreach (var udo in udos)
            {
                DoverSetup.removeUDO(userObjectsMD, udo, b1App, b1Company);
            }
            System.Runtime.InteropServices.Marshal.ReleaseComObject(userObjectsMD);
        }
コード例 #6
0
ファイル: ObjectDAO.cs プロジェクト: xavl369/UGRS
        /// <summary> Initializes the object. </summary>
        /// <remarks> Ranaya, 26/05/2017. </remarks>
        /// <param name="pObjObject"> The object object. </param>

        private void InitializeObject(IObject pObjObject)
        {
            UserObjectsMD lObjUserObject = pObjObject.GetUserObject();

            try
            {
                if (!ExistsObject(lObjUserObject.Code))
                {
                    HandleException.Object(lObjUserObject.Add());
                }
            }
            finally
            {
                MemoryUtility.ReleaseComObject(lObjUserObject);
            }
        }
コード例 #7
0
        public void addUDO(Company oCompany, string sObjeto, string sCode, string sName, string sTableName, BoUDOObjType TipoObjeto,
                           BoYesNoEnum CanFind, BoYesNoEnum CanDelete, BoYesNoEnum CanCancel, BoYesNoEnum CanYearTransfer, BoYesNoEnum CanLog,
                           string sLogTableName)
        {
            UserObjectsMD oUserObjectMD = null;

            oUserObjectMD = (UserObjectsMD)oCompany.GetBusinessObject(BoObjectTypes.oUserObjectsMD);

            int    lRetVal;
            string lErrMsg = string.Empty;

            System.Runtime.InteropServices.Marshal.ReleaseComObject(oUserObjectMD);
            oUserObjectMD = null;
            GC.Collect();
            oUserObjectMD = (UserObjectsMD)oCompany.GetBusinessObject(BoObjectTypes.oUserObjectsMD);

            if (oUserObjectMD.GetByKey(sObjeto) == false)
            {
                oUserObjectMD.Code      = sCode;
                oUserObjectMD.Name      = sName;
                oUserObjectMD.TableName = sTableName;

                oUserObjectMD.ObjectType = TipoObjeto;

                oUserObjectMD.CanFind         = CanFind;
                oUserObjectMD.CanDelete       = CanDelete;
                oUserObjectMD.CanCancel       = CanCancel;
                oUserObjectMD.CanYearTransfer = CanYearTransfer;
                oUserObjectMD.CanLog          = CanLog;
                oUserObjectMD.LogTableName    = sLogTableName;

                lRetVal = oUserObjectMD.Add();

                if (lRetVal != 0)
                {
                    oCompany.GetLastError(out lRetVal, out lErrMsg);
                }
            }

            System.Runtime.InteropServices.Marshal.ReleaseComObject(oUserObjectMD);
            oUserObjectMD = null;
            GC.Collect();
        }
コード例 #8
0
        public void MakeFieldsSearchable(string tableInitial)
        {
            Log.AppendFormat("Liberando campos para pesquisa");

            Recordset rs  = (Recordset)(SBOApp.Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset));
            string    sql = "SELECT * FROM CUFD WHERE TableID LIKE '{0}%'";

            rs.DoQuery(String.Format(sql, tableInitial));
            string        tableName     = String.Empty;
            UserObjectsMD userObjectsMD = (UserObjectsMD)SBOApp.Company.GetBusinessObject(BoObjectTypes.oUserObjectsMD);

            while (!rs.EoF)
            {
                if (tableName != rs.Fields.Item("TableID").Value.ToString())
                {
                    tableName = rs.Fields.Item("TableID").Value.ToString();
                }

                // Remove a arroba do usertable Name
                tableName = tableName.Replace("@", "");

                bool bUpdate = userObjectsMD.GetByKey(tableName);

                userObjectsMD.FindColumns.ColumnAlias       = rs.Fields.Item("AliasID").Value.ToString();
                userObjectsMD.FindColumns.ColumnDescription = rs.Fields.Item("Descr").Value.ToString();
                userObjectsMD.FindColumns.Add();

                if (bUpdate)
                {
                    CodErro = userObjectsMD.Update();
                }
                else
                {
                    CodErro = userObjectsMD.Add();
                }

                this.ValidateAction();

                Marshal.ReleaseComObject(userObjectsMD);
                userObjectsMD = null;
            }
        }
コード例 #9
0
        private void ActivateService(ObjectServices service, UserObjectsMD userObject)
        {
            switch (service)
            {
            case ObjectServices.Find:
                userObject.CanFind = BoYesNoEnum.tYES;
                break;

            case ObjectServices.Delete:
                userObject.CanDelete = BoYesNoEnum.tYES;
                break;

            case ObjectServices.Cancel:
                userObject.CanCancel = BoYesNoEnum.tYES;
                break;

            case ObjectServices.Close:
                userObject.CanClose = BoYesNoEnum.tYES;
                break;

            case ObjectServices.Log:
                userObject.CanLog       = BoYesNoEnum.tYES;
                userObject.LogTableName = $"{userObject.TableName}_LOG";
                break;

            case ObjectServices.ManageSeries:
                userObject.ManageSeries = BoYesNoEnum.tYES;
                break;

            case ObjectServices.YearTransfer:
                userObject.CanYearTransfer = BoYesNoEnum.tYES;
                break;

            case ObjectServices.Default:
                userObject.CanFind   = BoYesNoEnum.tYES;
                userObject.CanDelete = BoYesNoEnum.tYES;
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(service), service, "Unknown service");
            }
        }
コード例 #10
0
        //static void SBO_Application_AppEvent(SAPbouiCOM.BoAppEventTypes EventType)
        //{
        //    switch (EventType)
        //    {
        //        case SAPbouiCOM.BoAppEventTypes.aet_ShutDown:
        //            //Exit Add-On
        //            System.Windows.Forms.Application.Exit();
        //            break;
        //        case SAPbouiCOM.BoAppEventTypes.aet_CompanyChanged:
        //            break;
        //        case SAPbouiCOM.BoAppEventTypes.aet_FontChanged:
        //            break;
        //        case SAPbouiCOM.BoAppEventTypes.aet_LanguageChanged:
        //            break;
        //        case SAPbouiCOM.BoAppEventTypes.aet_ServerTerminition:
        //            break;
        //        default:
        //            break;
        //    }
        //}

        internal static bool UDOExist(string udoName)
        {
            UserObjectsMD UDO = (UserObjectsMD)AddOnUtilities.oCompany.GetBusinessObject(BoObjectTypes.oUserObjectsMD);

            try
            {
                bool result = UDO.GetByKey(udoName);
                System.Runtime.InteropServices.Marshal.ReleaseComObject(UDO);
                UDO = null;
                return(result);
            }
            catch (Exception ex)
            {
                throw;
            }
            finally
            {
                System.Runtime.InteropServices.Marshal.ReleaseComObject(UDO);
            }
        }
コード例 #11
0
ファイル: DoverSetup.cs プロジェクト: wgasparin/dover
        internal static void removeUDO(UserObjectsMD uo, string name,
                                       SAPbouiCOM.Application app, SAPbobsCOM.Company company)
        {
            int    ret;
            string errMsg;

            if (uo.GetByKey(name))
            {
                ret = uo.Remove();
                if (ret != 0)
                {
                    company.GetLastError(out ret, out errMsg);
                    app.SetStatusBarMessage(string.Format("Error removing object {0}", name),
                                            SAPbouiCOM.BoMessageTime.bmt_Short, true);
                    throw new Exception(errMsg);
                }
                app.StatusBar.SetSystemMessage(string.Format("Removed field {0}", name),
                                               SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Success);
            }
        }
コード例 #12
0
        public static void CriarObjeto(Company oCmp, Objeto objeto)
        {
            UserObjectsMD oUdo = (UserObjectsMD)oCmp.GetBusinessObject(BoObjectTypes.oUserObjectsMD);

            oUdo.Code            = objeto.Codigo;
            oUdo.Name            = objeto.Name;
            oUdo.ObjectType      = objeto.Tipo;
            oUdo.TableName       = objeto.NomeTabela;
            oUdo.CanFind         = objeto.CanFind;
            oUdo.CanDelete       = objeto.CanDelete;
            oUdo.CanCancel       = objeto.CanCancel;
            oUdo.CanLog          = objeto.CanLog;
            oUdo.ManageSeries    = objeto.MngSeries;
            oUdo.CanYearTransfer = objeto.CanYrTransf;

            foreach (Campo campo in objeto.Campos)
            {
                oUdo.FindColumns.ColumnAlias       = campo.Name;
                oUdo.FindColumns.ColumnDescription = campo.Description;
                oUdo.FindColumns.Add();
            }

            if (objeto.TabelaFilhas != null)
            {
                foreach (Tabela tabela in objeto.TabelaFilhas)
                {
                    oUdo.ChildTables.TableName = tabela.TableName;
                    oUdo.ChildTables.Add();
                }
            }

            int a = oUdo.Add();

            System.Runtime.InteropServices.Marshal.ReleaseComObject(oUdo);
            oUdo = null;
            GC.Collect();
            if (a != 0)
            {
                throw new Exception(oCmp.GetLastErrorDescription());
            }
        }
コード例 #13
0
 public TypeUserObjectAdapter(Type type, string tableName, UserObjectsMD userObject)
 {
     this.type       = type;
     this.tableName  = tableName;
     this.userObject = userObject;
 }
コード例 #14
0
ファイル: Test.cs プロジェクト: victorhtun/SDKUtilities
        private void CreateUDO(string udoName, string udoCode, BoUDOObjType udoType, string headerTableName, List <String> childTables, BoYesNoEnum isMenuItem, string menuCaption, int fatherMenuId, int menuPosition, BoYesNoEnum canCancel = BoYesNoEnum.tYES, BoYesNoEnum canClose = BoYesNoEnum.tNO, BoYesNoEnum canCreateDefaultForm = BoYesNoEnum.tYES, BoYesNoEnum canDelete = BoYesNoEnum.tYES, BoYesNoEnum canFind = BoYesNoEnum.tYES, BoYesNoEnum canLog = BoYesNoEnum.tYES, BoYesNoEnum canYearTransfer = BoYesNoEnum.tNO)
        {
            try
            {
                if (!(AddOnUtilities.UDOExist(udoName)))
                {
                    UserObjectsMD UDO = (UserObjectsMD)AddOnUtilities.oCompany.GetBusinessObject(BoObjectTypes.oUserObjectsMD);

                    //Set Services
                    // TODO: use optional params for properties below
                    UDO.CanCancel            = canCancel;
                    UDO.CanClose             = canClose;
                    UDO.CanCreateDefaultForm = canCreateDefaultForm;
                    UDO.CanDelete            = canDelete;
                    UDO.CanFind         = canFind;
                    UDO.CanLog          = canLog;
                    UDO.CanYearTransfer = canYearTransfer;

                    UDO.TableName             = headerTableName;
                    UDO.FormColumns.SonNumber = childTables.Count;
                    UDO.EnableEnhancedForm    = BoYesNoEnum.tYES; // To show Header Line Style
                    UDO.Code       = udoCode;
                    UDO.Name       = udoName;
                    UDO.ObjectType = udoType;

                    //Display columns
                    UDO.FormColumns.FormColumnAlias       = "Code";
                    UDO.FormColumns.FormColumnDescription = "Code";
                    UDO.FormColumns.Editable = BoYesNoEnum.tYES;
                    UDO.FormColumns.Add();

                    UDO.FormColumns.FormColumnAlias       = "U_User";
                    UDO.FormColumns.FormColumnDescription = "User";
                    UDO.FormColumns.Editable = BoYesNoEnum.tYES;
                    UDO.FormColumns.Add();

                    //UDO.FormColumns.FormColumnAlias = "U_Dimension1";
                    //UDO.FormColumns.FormColumnDescription = "Dimension 1";
                    //UDO.FormColumns.Add();

                    //UDO.FormColumns.FormColumnAlias = "U_Dimension2";
                    //UDO.FormColumns.FormColumnDescription = "Dimension 2";
                    //UDO.FormColumns.Add();

                    //Columns to be used in find mode
                    UDO.FindColumns.ColumnAlias       = "Code";
                    UDO.FindColumns.ColumnDescription = "Code";
                    UDO.FindColumns.Add();

                    UDO.FindColumns.ColumnAlias       = "U_User";
                    UDO.FindColumns.ColumnDescription = "User";
                    UDO.FindColumns.Add();

                    // Set UDO to have a menu
                    UDO.MenuItem    = isMenuItem;
                    UDO.MenuCaption = menuCaption;
                    // Set father and gnment of menu item.
                    UDO.FatherMenuID = fatherMenuId;
                    UDO.Position     = 1;
                    // Set UDO menu UID
                    UDO.MenuUID = "UserDimension";

                    //Link with child tables.
                    foreach (var childTable in childTables)
                    {
                        UDO.ChildTables.TableName = childTable;
                        UDO.ChildTables.Add();
                    }

                    int RetCode = UDO.Add();
                    if (RetCode != 0)
                    {
                        string errMsg = AddOnUtilities.oCompany.GetLastErrorDescription();
                        MessageBox.Show("Failed to add UDO");
                    }
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(UDO);
                }
            }
            catch (Exception ex)
            {
                AddOnUtilities.MsgBoxWrapper(ex.Message + " " + ex.StackTrace);
                SAPbouiCOM.EventForm e = null;
            }
        }
コード例 #15
0
 /// <summary>
 /// Activates the approve service.
 /// </summary>
 /// <param name="userObject">The user object.</param>
 internal void Apply(UserObjectsMD userObject)
 {
     userObject.CanApprove = BoYesNoEnum.tYES;
     userObject.TemplateID = TemplateId;
 }
コード例 #16
0
ファイル: UDO.cs プロジェクト: wgasparin/dover
 internal override string GetFormattedDescription()
 {
     return(UserObjectsMD
            .With(x => x[0])
            .Return(x => x.Name, string.Empty));
 }
コード例 #17
0
ファイル: AddUserObject.cs プロジェクト: onixus74/b1pp
 public AddUserObject(Company company, UserObjectsMD userObjectMd)
 {
     this.company      = company;
     this.userObjectMd = userObjectMd;
 }
コード例 #18
0
ファイル: DoverSetup.cs プロジェクト: THJLI/dover
 internal static void removeUDO(UserObjectsMD uo, string name,
                     SAPbouiCOM.Application app, SAPbobsCOM.Company company)
 {
     int ret;
     string errMsg;
     if (uo.GetByKey(name))
     {
         ret = uo.Remove();
         if (ret != 0)
         {
             company.GetLastError(out ret, out errMsg);
             app.SetStatusBarMessage(string.Format("Error removing object {0}", name),
                 SAPbouiCOM.BoMessageTime.bmt_Short, true);
             throw new Exception(errMsg);
         }
         app.StatusBar.SetSystemMessage(string.Format("Removed field {0}", name),
             SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Success);
     }
 }
コード例 #19
0
ファイル: UDO.cs プロジェクト: wgasparin/dover
 internal override string GetFormattedKey()
 {
     return("[" + UserObjectsMD
            .With(x => x[0])
            .Return(x => x.Code, string.Empty) + "]");
 }