Esempio n. 1
0
        }       //	checkStandardColumns

        /// <summary>
        /// Create Column in AD and DB
        /// </summary>
        /// <param name="col">Column Object</param>
        /// <param name="table">Table Object</param>
        /// <param name="alsoInDB">Also in DB</param>
        /// <returns></returns>
        private static bool CreateColumn(MColumn col, MTable table, bool alsoInDB)
        {
            //	Element
            M_Element element = M_Element.Get(col.GetCtx(), col.GetColumnName(), col.Get_TrxName());

            if (element == null)
            {
                element = new M_Element(col.GetCtx(), col.GetColumnName(), col.GetEntityType(), null);
                if (!element.Save())
                {
                    return(false);
                }
                log.Info("Created Element: " + element.GetColumnName());
            }
            //	Column Sync
            col.SetColumnName(element.GetColumnName());
            col.SetName(element.GetName());
            col.SetDescription(element.GetDescription());
            col.SetHelp(element.GetHelp());
            col.SetAD_Element_ID(element.GetAD_Element_ID());
            //

            if (!col.Save())
            {
                return(false);
            }

            //	DB
            if (!alsoInDB)
            {
                return(true);
            }
            //
            String sql     = col.GetSQLAdd(table);
            bool   success = DataBase.DB.ExecuteUpdateMultiple(sql, false, table.Get_TrxName()) >= 0;

            if (success)
            {
                log.Info("Created: " + table.GetTableName()
                         + "." + col.GetColumnName());
            }
            else
            {
                log.Warning("NOT Created: " + table.GetTableName()
                            + "." + col.GetColumnName());
            }
            return(success);
        }       //	createColumn