Пример #1
0
 /// <summary>
 /// Create default columns for Master Data Version Table
 /// e.g. Processed, Processing, IsApproved etc.
 /// </summary>
 /// <param name="Ver_AD_Table_ID"></param>
 /// <returns></returns>
 private string CreateDefaultVerCols(int Ver_AD_Table_ID)
 {
     for (int i = 0; i < listDefVerCols.Count; i++)
     {
         MColumn colVer = new MColumn(GetCtx(), 0, _trx);
         colVer.SetExport_ID(null);
         colVer.SetAD_Table_ID(Ver_AD_Table_ID);
         colVer.SetColumnName(listDefVerCols[i]);
         colVer.SetAD_Element_ID(_listDefVerElements[i]);
         colVer.SetAD_Reference_ID(listDefVerRef[i]);
         //if (listDefVerCols[i] == "VersionValidFrom")
         //    colVer.SetIsParent(true);
         if (listDefVerRef[i] == 10)
         {
             colVer.SetFieldLength(10);
         }
         if (listDefVerRef[i] == 14)
         {
             colVer.SetFieldLength(2000);
         }
         if (listDefVerRef[i] == 13)
         {
             colVer.SetIsKey(true);
             colVer.SetIsMandatory(true);
             colVer.SetIsMandatoryUI(true);
         }
         if (!colVer.Save())
         {
             ValueNamePair vnp   = VLogger.RetrieveError();
             string        error = "";
             if (vnp != null)
             {
                 error = vnp.GetName();
                 if (error == "" && vnp.GetValue() != null)
                 {
                     error = vnp.GetValue();
                 }
             }
             if (error == "")
             {
                 error = "Error in creating Version Column " + listDefVerCols[i];
             }
             log.Log(Level.SEVERE, "Version Column not created :: " + listDefVerCols[i] + " :: " + error);
             _trx.Rollback();
             return(Msg.GetMsg(GetCtx(), "VersionColNotCreated"));
         }
     }
     return("");
 }
Пример #2
0
        /// <summary>
        /// Create default columns for Master Data Version Table
        /// e.g. Processed, Processing, IsApproved etc.
        /// </summary>
        /// <param name="Ver_AD_Table_ID"></param>
        /// <returns></returns>
        private string CreateDefaultVerCols(int Ver_AD_Table_ID)
        {
            DataSet dstblCols = DB.ExecuteDataset("SELECT ColumnName FROM AD_Column WHERE AD_Table_ID = " + Ver_AD_Table_ID, null, null);

            for (int i = 0; i < listDefVerCols.Count; i++)
            {
                bool hasCol = false;
                if (dstblCols != null && dstblCols.Tables[0].Rows.Count > 0)
                {
                    DataRow[] dr = dstblCols.Tables[0].Select("ColumnName = '" + listDefVerCols[i] + "'");
                    if (dr != null && dr.Length > 0)
                    {
                        hasCol = true;
                    }
                }
                if (hasCol)
                {
                    continue;
                }
                MColumn colVer = new MColumn(GetCtx(), 0, _trx);
                colVer.SetExport_ID(null);
                colVer.SetAD_Table_ID(Ver_AD_Table_ID);
                colVer.SetColumnName(listDefVerCols[i]);
                colVer.SetAD_Element_ID(_listDefVerElements[i]);
                colVer.SetAD_Reference_ID(listDefVerRef[i]);
                //if (listDefVerCols[i] == "VersionValidFrom")
                //    colVer.SetIsParent(true);
                if (listDefVerRef[i] == 10)
                {
                    colVer.SetFieldLength(10);
                }
                if (listDefVerRef[i] == 14)
                {
                    colVer.SetFieldLength(2000);
                }
                if (listDefVerRef[i] == 13)
                {
                    colVer.SetIsKey(true);
                    colVer.SetIsMandatory(true);
                    colVer.SetIsMandatoryUI(true);
                }
                if (!colVer.Save())
                {
                    ValueNamePair vnp   = VLogger.RetrieveError();
                    string        error = "";
                    if (vnp != null)
                    {
                        error = vnp.GetName();
                        if (error == "" && vnp.GetValue() != null)
                        {
                            error = vnp.GetValue();
                        }
                    }
                    if (error == "")
                    {
                        error = "Error in creating Version Column " + listDefVerCols[i];
                    }
                    log.Log(Level.SEVERE, "Version Column not created :: " + listDefVerCols[i] + " :: " + error);
                    _trx.Rollback();
                    return(Msg.GetMsg(GetCtx(), "VersionColNotCreated"));
                }
                else
                {
                    oldVerCol = colVer.GetAD_Column_ID();
                }
            }
            return("");
        }
        }       //	prepare

        /**
         *  Process
         *	@return info
         *	@throws Exception
         */
        protected override String DoIt()// throws Exception
        {
            log.Info("AD_Column_ID=" + p_AD_Column_ID
                     + ", IsEncrypted=" + p_IsEncrypted
                     + ", ChangeSetting=" + p_ChangeSetting
                     + ", MaxLength=" + p_MaxLength);
            MColumn column = new MColumn(GetCtx(), p_AD_Column_ID, Get_Trx());

            if (column.Get_ID() == 0 || column.Get_ID() != p_AD_Column_ID)
            {
                throw new Exception("@NotFound@ @AD_Column_ID@ - " + p_AD_Column_ID);
            }
            //
            String columnName = column.GetColumnName();
            int    dt         = column.GetAD_Reference_ID();

            //	Can it be enabled?
            if (column.IsKey() ||
                column.IsParent() ||
                column.IsStandardColumn() ||
                column.IsVirtualColumn() ||
                column.IsIdentifier() ||
                column.IsTranslated() ||
                DisplayType.IsLookup(dt) ||
                DisplayType.IsLOB(dt) ||
                "DocumentNo".Equals(column.GetColumnName(), StringComparison.OrdinalIgnoreCase) ||
                "Value".Equals(column.GetColumnName(), StringComparison.OrdinalIgnoreCase) ||
                "Name".Equals(column.GetColumnName(), StringComparison.OrdinalIgnoreCase))
            {
                if (column.IsEncrypted())
                {
                    column.SetIsEncrypted(false);
                    column.Save(Get_Trx());
                }
                return(columnName + ": cannot be encrypted");
            }

            //	Start
            AddLog(0, null, null, "Encryption Class = " + SecureEngine.GetClassName());
            bool error = false;

            //	Test Value
            if (p_TestValue != null && p_TestValue.Length > 0)
            {
                String encString = SecureEngine.Encrypt(p_TestValue);
                AddLog(0, null, null, "Encrypted Test Value=" + encString);
                String clearString = SecureEngine.Decrypt(encString);
                if (p_TestValue.Equals(clearString))
                {
                    AddLog(0, null, null, "Decrypted=" + clearString
                           + " (same as test value)");
                }
                else
                {
                    AddLog(0, null, null, "Decrypted=" + clearString
                           + " (NOT the same as test value - check algorithm)");
                    error = true;
                }
                int encLength = encString.Length;
                AddLog(0, null, null, "Test Length=" + p_TestValue.Length + " -> " + encLength);
                if (encLength <= column.GetFieldLength())
                {
                    AddLog(0, null, null, "Encrypted Length (" + encLength
                           + ") fits into field (" + column.GetFieldLength() + ")");
                }
                else
                {
                    AddLog(0, null, null, "Encrypted Length (" + encLength
                           + ") does NOT fit into field (" + column.GetFieldLength() + ") - resize field");
                    error = true;
                }
            }

            //	Length Test
            if (p_MaxLength != 0)
            {
                String testClear = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
                while (testClear.Length < p_MaxLength)
                {
                    testClear += testClear;
                }
                testClear = testClear.Substring(0, p_MaxLength);
                log.Config("Test=" + testClear + " (" + p_MaxLength + ")");
                //
                String encString = SecureEngine.Encrypt(testClear);
                int    encLength = encString.Length;
                AddLog(0, null, null, "Test Max Length=" + testClear.Length + " -> " + encLength);
                if (encLength <= column.GetFieldLength())
                {
                    AddLog(0, null, null, "Encrypted Max Length (" + encLength
                           + ") fits into field (" + column.GetFieldLength() + ")");
                }
                else
                {
                    AddLog(0, null, null, "Encrypted Max Length (" + encLength
                           + ") does NOT fit into field (" + column.GetFieldLength() + ") - resize field");
                    error = true;
                }
            }

            if (p_IsEncrypted != column.IsEncrypted())
            {
                if (error || !p_ChangeSetting)
                {
                    AddLog(0, null, null, "Encryption NOT changed - Encryption=" + column.IsEncrypted());
                }
                else
                {
                    column.SetIsEncrypted(p_IsEncrypted);
                    if (column.Save(Get_Trx()))
                    {
                        AddLog(0, null, null, "Encryption CHANGED - Encryption=" + column.IsEncrypted());
                    }
                    else
                    {
                        AddLog(0, null, null, "Save Error");
                    }
                }
            }


            if (p_IsEncrypted == column.IsEncrypted() && !error)      // Done By Karan on 10-nov-2016, to encrypt/decrypt passwords according to settings.
            {
                //object colID = DB.ExecuteScalar("SELECT AD_Column_ID FROM AD_Column WHERE AD_Table_ID =(SELECT AD_Table_ID From AD_Table WHERE TableName='AD_User') AND ColumnName='Password'", null, Get_Trx());



                // if (colID != null && colID != DBNull.Value && Convert.ToInt32(colID) == column.GetAD_Column_ID())
                //{

                string tableName = MTable.GetTableName(GetCtx(), column.GetAD_Table_ID());

                DataSet ds = DB.ExecuteDataset("SELECT " + column.GetColumnName() + "," + tableName
                                               + "_ID FROM " + tableName, null, Get_Trx());
                if (ds != null && ds.Tables[0].Rows.Count > 0)
                {
                    if (p_IsEncrypted)
                    {
                        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                        {
                            if (ds.Tables[0].Rows[i][column.GetColumnName()] != null && ds.Tables[0].Rows[i][column.GetColumnName()] != DBNull.Value &&
                                !SecureEngine.IsEncrypted(ds.Tables[0].Rows[i][column.GetColumnName()].ToString()))
                            {
                                //MUser user = new MUser(GetCtx(), Util.GetValueOfInt(ds.Tables[0].Rows[i][MTable.GetTableName(GetCtx(), column.GetAD_Table_ID()) + "_ID"]), Get_Trx());
                                //user.SetPassword(SecureEngine.Encrypt(ds.Tables[0].Rows[i][column.GetColumnName()].ToString()));

                                int encLength = SecureEngine.Encrypt(ds.Tables[0].Rows[i][column.GetColumnName()].ToString()).Length;

                                if (encLength <= column.GetFieldLength())
                                {
                                    //PO tab = MTable.GetPO(GetCtx(), tableName,
                                    //    Util.GetValueOfInt(ds.Tables[0].Rows[i][tableName + "_ID"]), Get_Trx());

                                    //tab.Set_Value(column.GetColumnName(), (SecureEngine.Encrypt(ds.Tables[0].Rows[i][column.GetColumnName()].ToString())));
                                    //if (!tab.Save(Get_Trx()))
                                    //{
                                    //    Rollback();
                                    //    return "Encryption=" + false;
                                    //}
                                    string p_NewPassword = SecureEngine.Encrypt(ds.Tables[0].Rows[i][column.GetColumnName()].ToString());
                                    String sql           = "UPDATE " + tableName + " SET Updated=SYSDATE, UpdatedBy=" + GetAD_User_ID();
                                    if (!string.IsNullOrEmpty(p_NewPassword))
                                    {
                                        sql += ", " + column.GetColumnName() + "=" + GlobalVariable.TO_STRING(p_NewPassword);
                                    }
                                    sql += " WHERE " + tableName + "_ID=" + Util.GetValueOfInt(ds.Tables[0].Rows[i][tableName + "_ID"]);
                                    int iRes = DB.ExecuteQuery(sql, null, Get_Trx());
                                    if (iRes <= 0)
                                    {
                                        Rollback();
                                        return("Encryption=" + false);
                                    }
                                }
                                else
                                {
                                    Rollback();
                                    return("After Encryption some values may exceed the value of column length. Please exceed column Length.");
                                }
                            }
                        }
                    }
                    else
                    {
                        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                        {
                            if (ds.Tables[0].Rows[i][column.GetColumnName()] != null && ds.Tables[0].Rows[i][column.GetColumnName()] != DBNull.Value &&
                                SecureEngine.IsEncrypted(ds.Tables[0].Rows[i][column.GetColumnName()].ToString()))
                            {
                                // MUser user = new MUser(GetCtx(), Util.GetValueOfInt(ds.Tables[0].Rows[i][MTable.GetTableName(GetCtx(), column.GetAD_Table_ID())+"_ID"]), Get_Trx());

                                //PO tab = MTable.GetPO(GetCtx(), tableName,
                                //   Util.GetValueOfInt(ds.Tables[0].Rows[i][tableName + "_ID"]), Get_Trx());

                                //tab.Set_Value(column.GetColumnName(), (SecureEngine.Decrypt(ds.Tables[0].Rows[i][column.GetColumnName()].ToString())));
                                //if (!tab.Save(Get_Trx()))
                                //{
                                //    Rollback();
                                //    return "Encryption=" + false;
                                //}

                                string p_NewPassword = SecureEngine.Decrypt(ds.Tables[0].Rows[i][column.GetColumnName()].ToString());
                                String sql           = "UPDATE " + tableName + "  SET Updated=SYSDATE, UpdatedBy=" + GetAD_User_ID();
                                if (!string.IsNullOrEmpty(p_NewPassword))
                                {
                                    sql += ", " + column.GetColumnName() + "=" + GlobalVariable.TO_STRING(p_NewPassword);
                                }
                                sql += " WHERE " + tableName + "_ID  =" + Util.GetValueOfInt(ds.Tables[0].Rows[i][tableName + "_ID"]);
                                int iRes = DB.ExecuteQuery(sql, null, Get_Trx());
                                if (iRes <= 0)
                                {
                                    Rollback();
                                    return("Encryption=" + false);
                                }
                            }
                        }
                    }
                }
                //}
            }
            return("Encryption=" + column.IsEncrypted());
        }
Пример #4
0
        }       //	addTable

        /// <summary>
        /// Add Table columns in DB
        /// </summary>
        /// <param name="ctx">Ctx</param>
        /// <param name="rs">Dataset</param>
        /// <param name="table">Table Object</param>
        /// <param name="entityType">Entity type</param>
        /// <returns></returns>
        protected List <String> AddTableColumn(Ctx ctx, DataSet rs, MTable table, String entityType)
        {
            //MClientShare
            List <String> colName   = new List <String>();
            String        tableName = table.GetTableName();

            if (DatabaseType.IsOracle)
            {
                tableName = tableName.ToUpper();
                //
                for (int i = 0; i <= rs.Tables[0].Rows.Count - 1; i++)
                {
                    String tn = rs.Tables[0].Rows[i]["TABLE_NAME"].ToString();
                    if (!tableName.Equals(tn, StringComparison.OrdinalIgnoreCase))
                    {
                        continue;
                    }
                    String columnName = rs.Tables[0].Rows[i]["COLUMN_NAME"].ToString();
                    colName.Add(columnName);
                    MColumn column = table.GetColumn(columnName);
                    if (column != null)
                    {
                        continue;
                    }
                    //int dataType = Utility.Util.GetValueOfInt(rs.Tables[0].Rows[i]["DATATYPE"].ToString());
                    String typeName = rs.Tables[0].Rows[i]["DATATYPE"].ToString();
                    String nullable = rs.Tables[0].Rows[i]["NULLABLE"].ToString();
                    int    size     = Utility.Util.GetValueOfInt(rs.Tables[0].Rows[i]["LENGTH"]);
                    int    digits   = Utility.Util.GetValueOfInt(rs.Tables[0].Rows[i]["PRECISION"]);
                    //
                    log.Config(columnName + " - DataType=" + " " + typeName
                               + ", Nullable=" + nullable + ", Size=" + size + ", Digits="
                               + digits);
                    //
                    column = new MColumn(table);
                    column.SetEntityType(entityType);
                    //	Element
                    M_Element element = M_Element.Get(ctx, columnName, Get_Trx());
                    if (element == null)
                    {
                        element = new M_Element(ctx, columnName, entityType, Get_Trx());
                        element.Save();
                    }
                    //	Column Sync
                    column.SetColumnName(element.GetColumnName());
                    column.SetName(element.GetName());
                    column.SetDescription(element.GetDescription());
                    column.SetHelp(element.GetHelp());
                    column.SetAD_Element_ID(element.GetAD_Element_ID());
                    //	Other
                    column.SetIsMandatory("NO".Equals(nullable));
                    column.SetIsMandatoryUI(column.IsMandatory());

                    // Key
                    if (columnName.Equals(tableName + "_ID", StringComparison.OrdinalIgnoreCase))
                    {
                        column.SetIsKey(true);
                        column.SetAD_Reference_ID(DisplayType.ID);
                        column.SetIsUpdateable(false);
                    }
                    // Account
                    else if ((columnName.ToUpper().IndexOf("ACCT") != -1) &&
                             (size == 10))
                    {
                        column.SetAD_Reference_ID(DisplayType.Account);
                    }
                    // Location
                    else if (columnName.Equals("C_Location_ID", StringComparison.OrdinalIgnoreCase))
                    {
                        column.SetAD_Reference_ID(DisplayType.Location);
                    }
                    // Product Attribute
                    else if (columnName.Equals("M_AttributeSetInstance_ID"))
                    {
                        column.SetAD_Reference_ID(DisplayType.PAttribute);
                    }
                    // SalesRep_ID (=User)
                    else if (columnName.Equals("SalesRep_ID", StringComparison.OrdinalIgnoreCase))
                    {
                        column.SetAD_Reference_ID(DisplayType.Table);
                        column.SetAD_Reference_Value_ID(190);
                    }
                    // ID
                    else if (columnName.EndsWith("_ID"))
                    {
                        column.SetAD_Reference_ID(DisplayType.TableDir);
                    }
                    // Date
                    else if ((typeName == Types.DATE) || (typeName == Types.TIME) ||
                             (typeName == Types.TIMESTAMP)
                             // || columnName.toUpperCase().indexOf("DATE") != -1
                             || columnName.Equals("Created", StringComparison.OrdinalIgnoreCase) ||
                             columnName.Equals("Updated", StringComparison.OrdinalIgnoreCase))
                    {
                        column.SetAD_Reference_ID(DisplayType.DateTime);
                        column.SetIsUpdateable(false);
                    }
                    // CreatedBy/UpdatedBy (=User)
                    else if (columnName.Equals("CreatedBy", StringComparison.OrdinalIgnoreCase) ||
                             columnName.Equals("UpdatedBy", StringComparison.OrdinalIgnoreCase))
                    {
                        column.SetAD_Reference_ID(DisplayType.Table);
                        column.SetAD_Reference_Value_ID(110);
                        column.SetConstraintType(X_AD_Column.CONSTRAINTTYPE_DoNOTCreate);
                        column.SetIsUpdateable(false);
                    }
                    //	Entity Type
                    else if (columnName.Equals("EntityType", StringComparison.OrdinalIgnoreCase))
                    {
                        column.SetAD_Reference_ID(DisplayType.Table);
                        column.SetAD_Reference_Value_ID(389);
                        column.SetDefaultValue("U");
                        column.SetConstraintType(X_AD_Column.CONSTRAINTTYPE_Restrict);
                        column.SetReadOnlyLogic("@EntityType@=D");
                    }
                    // CLOB
                    else if (typeName == Types.CLOB)
                    {
                        column.SetAD_Reference_ID(DisplayType.TextLong);
                    }
                    // BLOB
                    else if (typeName == Types.BLOB)
                    {
                        column.SetAD_Reference_ID(DisplayType.Binary);
                    }
                    // Amount
                    else if (columnName.ToUpper().IndexOf("AMT") != -1)
                    {
                        column.SetAD_Reference_ID(DisplayType.Amount);
                    }
                    // Qty
                    else if (columnName.ToUpper().IndexOf("QTY") != -1)
                    {
                        column.SetAD_Reference_ID(DisplayType.Quantity);
                    }
                    // Boolean
                    else if ((size == 1) &&
                             (columnName.ToUpper().StartsWith("IS") || (typeName == Types.CHAR)))
                    {
                        column.SetAD_Reference_ID(DisplayType.YesNo);
                    }
                    // List
                    else if ((size < 4) && (typeName == Types.CHAR))
                    {
                        column.SetAD_Reference_ID(DisplayType.List);
                    }
                    // Name, DocumentNo
                    else if (columnName.Equals("Name", StringComparison.OrdinalIgnoreCase) ||
                             columnName.Equals("DocumentNo", StringComparison.OrdinalIgnoreCase))
                    {
                        column.SetAD_Reference_ID(DisplayType.String);
                        column.SetIsIdentifier(true);
                        column.SetSeqNo(1);
                    }
                    // String, Text
                    else if ((typeName == Types.CHAR) || (typeName == Types.VARCHAR) ||
                             typeName.StartsWith("NVAR") ||
                             typeName.StartsWith("NCHAR"))
                    {
                        if (typeName.StartsWith("N"))   //	MultiByte
                        {
                            size /= 2;
                        }
                        if (size > 255)
                        {
                            column.SetAD_Reference_ID(DisplayType.Text);
                        }
                        else
                        {
                            column.SetAD_Reference_ID(DisplayType.String);
                        }
                    }

                    // Number
                    else if ((typeName == Types.INTEGER) || (typeName == Types.SMALLINT) ||
                             (typeName == Types.DECIMAL) || (typeName == Types.NUMERIC))
                    {
                        if (size == 10)
                        {
                            column.SetAD_Reference_ID(DisplayType.Integer);
                        }
                        else
                        {
                            column.SetAD_Reference_ID(DisplayType.Number);
                        }
                    }
                    //	??
                    else
                    {
                        column.SetAD_Reference_ID(DisplayType.String);
                    }

                    //	General Defaults
                    if (columnName.EndsWith("_ID"))
                    {
                        column.SetConstraintType(X_AD_Column.CONSTRAINTTYPE_Restrict);
                    }
                    if (columnName.Equals("AD_Client_ID"))
                    {
                        column.SetAD_Val_Rule_ID(116);  //	Client Login
                        column.SetDefaultValue("@#AD_Client_ID@");
                        column.SetIsUpdateable(false);
                    }
                    else if (columnName.Equals("AD_Org_ID"))
                    {
                        column.SetAD_Val_Rule_ID(104);  //	Org Security
                        column.SetDefaultValue("@#AD_Org_ID@");
                        column.SetIsUpdateable(false);
                    }
                    else if (columnName.Equals("Processed"))
                    {
                        column.SetAD_Reference_ID(DisplayType.YesNo);
                        column.SetDefaultValue("N");
                        column.SetIsUpdateable(false);
                    }
                    else if (columnName.Equals("Posted"))
                    {
                        column.SetAD_Reference_ID(DisplayType.Button);
                        column.SetAD_Reference_Value_ID(234);   //	_PostedStatus
                        column.SetDefaultValue("N");
                        column.SetIsUpdateable(false);
                    }

                    //	General
                    column.SetFieldLength(size);
                    if (column.IsUpdateable() && table.IsView())
                    {
                        column.SetIsUpdateable(false);
                    }

                    //	Done
                    if (column.Save())
                    {
                        AddLog(0, DateTime.Now, null, table.GetTableName() + "." + column.GetColumnName());
                        m_count++;
                    }
                }       //	while columns
            }
            return(colName);
        }       //	addTableColumn
Пример #5
0
        }       //	prepare

        /**
         *  Process
         *	@return info
         *	@throws Exception
         */
        protected override String DoIt()// throws Exception
        {
            log.Info("AD_Column_ID=" + p_AD_Column_ID
                     + ", IsEncrypted=" + p_IsEncrypted
                     + ", ChangeSetting=" + p_ChangeSetting
                     + ", MaxLength=" + p_MaxLength);
            MColumn column = new MColumn(GetCtx(), p_AD_Column_ID, null);

            if (column.Get_ID() == 0 || column.Get_ID() != p_AD_Column_ID)
            {
                throw new Exception("@NotFound@ @AD_Column_ID@ - " + p_AD_Column_ID);
            }
            //
            String columnName = column.GetColumnName();
            int    dt         = column.GetAD_Reference_ID();

            //	Can it be enabled?
            if (column.IsKey() ||
                column.IsParent() ||
                column.IsStandardColumn() ||
                column.IsVirtualColumn() ||
                column.IsIdentifier() ||
                column.IsTranslated() ||
                DisplayType.IsLookup(dt) ||
                DisplayType.IsLOB(dt) ||
                "DocumentNo".Equals(column.GetColumnName(), StringComparison.OrdinalIgnoreCase) ||
                "Value".Equals(column.GetColumnName(), StringComparison.OrdinalIgnoreCase) ||
                "Name".Equals(column.GetColumnName(), StringComparison.OrdinalIgnoreCase))
            {
                if (column.IsEncrypted())
                {
                    column.SetIsEncrypted(false);
                    column.Save();
                }
                return(columnName + ": cannot be encrypted");
            }

            //	Start
            AddLog(0, null, null, "Encryption Class = " + SecureEngineUtility.SecureEngine.GetClassName());
            bool error = false;

            //	Test Value
            if (p_TestValue != null && p_TestValue.Length > 0)
            {
                String encString = SecureEngineUtility.SecureEngine.Encrypt(p_TestValue);
                AddLog(0, null, null, "Encrypted Test Value=" + encString);
                String clearString = SecureEngineUtility.SecureEngine.Decrypt(encString);
                if (p_TestValue.Equals(clearString))
                {
                    AddLog(0, null, null, "Decrypted=" + clearString
                           + " (same as test value)");
                }
                else
                {
                    AddLog(0, null, null, "Decrypted=" + clearString
                           + " (NOT the same as test value - check algorithm)");
                    error = true;
                }
                int encLength = encString.Length;
                AddLog(0, null, null, "Test Length=" + p_TestValue.Length + " -> " + encLength);
                if (encLength <= column.GetFieldLength())
                {
                    AddLog(0, null, null, "Encrypted Length (" + encLength
                           + ") fits into field (" + column.GetFieldLength() + ")");
                }
                else
                {
                    AddLog(0, null, null, "Encrypted Length (" + encLength
                           + ") does NOT fit into field (" + column.GetFieldLength() + ") - resize field");
                    error = true;
                }
            }

            //	Length Test
            if (p_MaxLength != 0)
            {
                String testClear = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
                while (testClear.Length < p_MaxLength)
                {
                    testClear += testClear;
                }
                testClear = testClear.Substring(0, p_MaxLength);
                log.Config("Test=" + testClear + " (" + p_MaxLength + ")");
                //
                String encString = SecureEngineUtility.SecureEngine.Encrypt(testClear);
                int    encLength = encString.Length;
                AddLog(0, null, null, "Test Max Length=" + testClear.Length + " -> " + encLength);
                if (encLength <= column.GetFieldLength())
                {
                    AddLog(0, null, null, "Encrypted Max Length (" + encLength
                           + ") fits into field (" + column.GetFieldLength() + ")");
                }
                else
                {
                    AddLog(0, null, null, "Encrypted Max Length (" + encLength
                           + ") does NOT fit into field (" + column.GetFieldLength() + ") - resize field");
                    error = true;
                }
            }

            if (p_IsEncrypted != column.IsEncrypted())
            {
                if (error || !p_ChangeSetting)
                {
                    AddLog(0, null, null, "Encryption NOT changed - Encryption=" + column.IsEncrypted());
                }
                else
                {
                    column.SetIsEncrypted(p_IsEncrypted);
                    if (column.Save())
                    {
                        AddLog(0, null, null, "Encryption CHANGED - Encryption=" + column.IsEncrypted());
                    }
                    else
                    {
                        AddLog(0, null, null, "Save Error");
                    }
                }
            }
            return("Encryption=" + column.IsEncrypted());
        }