예제 #1
0
        private bool DeleteGroupEntryFromXrefTable(int groupID, GroupDeleteTableType groupDeleteTableType)
        {
            bool   isDeleted    = false;
            int    count        = -1;
            int    countDeleted = -1;
            string tableName    = GetTableNameForGroup(groupDeleteTableType);
            string sql          = "";

            Logger.Log("Start deleting records from table '" + tableName + "' for group id " + groupID);
            try {
                DbInfo = new DatabaseWrapper(Lcf);
                DbInfo.Connect();

                Logger.Log("Getting records from table '" + tableName + "' for group id " + groupID);
                count = GetRecordsForAGroupFromXref(groupID, tableName);
                if (count > 0)
                {
                    Logger.Log("Start deleting records from '" + tableName + "' for group id = " + groupID);
                    sql = GroupQB.GetDelteGroupSql(groupID, tableName, false);
                    bool success = false;
                    countDeleted = DbInfo.ExecuteSQL(sql, ref success);
                    if (count == countDeleted)
                    {
                        Logger.Log("Successfully deleted " + count + " records from " + tableName + " for group id = " + groupID);
                        isDeleted = true;
                    }
                    else
                    {
                        Logger.Log("Failed to delte " + count + " records from " + tableName + " for group id = " + groupID);
                    }
                }
                else if (count == 0)
                {
                    Logger.Log("No records was found in table '" + tableName + "' for group id " + groupID);
                    return(true);
                }
            } catch (Exception ex) {
                Logger.Log("Error deleting records from table '" + tableName + "' for group id " + groupID + " at: " + ex);
                return(false);
            } finally {
                if (isDeleted)
                {
                    SecureContentWrapper.SecurityHasBeenModifiedThisSession = true;
                }


                if (DbInfo != null)
                {
                    DbInfo.Disconnect();
                }
            }
            return(isDeleted);
        }
예제 #2
0
        private bool DeleteGroupFromMain(int groupID)
        {
            bool   isDeleted = false;
            string sql       = "";
            string tableName = "";

            try {
                Logger.Log("Trying to delete the group entry from main table '" + GroupQB.GROUP_TBLE_NAME + "'");

                tableName = GetTableNameForGroup(GroupDeleteTableType.Main);

                sql    = GroupQB.GetDelteGroupSql(groupID, tableName, true);
                DbInfo = new DatabaseWrapper(Lcf);
                DbInfo.Connect();
                bool success    = false;
                int  numChanged = DbInfo.ExecuteSQL(sql, ref success);
                if (numChanged == 0)
                {
                    isDeleted = false;
                }
                else
                {
                    isDeleted = true;
                }
            } catch (Exception ex) {
                Logger.LogError(5, "Error deleting the group entry from main table '" + GroupQB.GROUP_TBLE_NAME + "' at: " + ex);
                return(false);
            } finally {
                if (isDeleted)
                {
                    SecureContentWrapper.SecurityHasBeenModifiedThisSession = true;
                }

                if (DbInfo != null)
                {
                    DbInfo.Disconnect();
                }
            }
            return(isDeleted);
        }