示例#1
0
        public IPersonalDataRow ReadPersonalDataRow(object userId, string tableId, object rowId)
        {
            if (userId is null)
            {
                throw new ArgumentNullException(nameof(userId));
            }

            if (String.IsNullOrEmpty(tableId))
            {
                throw new ArgumentException($"Parameter {nameof(tableId)} must not be null or empty", nameof(tableId));
            }

            if (rowId is null)
            {
                throw new ArgumentNullException(nameof(rowId));
            }

            lock (dataAccessLock)
            {
                CheckUserId(userId);
                CheckTableId(tableId);
                CheckRowId(tableId, rowId);

                object ownerId = dataProvider.GetOwnerForRowId(tableId, rowId);
                IEnumerable <IColumnDefinition> columns = dataProvider.ListColumns(tableId);

                CheckAccessibility(PurposeType.HoldingAndReading, ownerId, tableId, rowId, columns.Select(c => c.ID));

                IPersonalDataRow row = dataProvider.ReadPersonalDataRow(tableId, rowId);

                ITableDefinition table        = dataProvider.GetTable(tableId);
                string           tableLogName = table.Name ?? table.ID;

                if (row.PersonalDataCells.Any(r => r.IsDefined))
                {
                    WriteOwnerLog(ownerId, $"We accessed your personal data and read the whole row with ID \"{rowId.ToString()}\" in the table \"{tableLogName}\"");
                }

                WriteUserLog(userId, $"Whole row of owner ID \"{ownerId.ToString()}\" has been accessed in table \"{tableId}\"");

                return(row);
            }
        }
示例#2
0
        public IPersonalDataRow ReadPersonalDataRow(object ownerId, string tableId, object rowId)
        {
            if (ownerId is null)
            {
                throw new ArgumentNullException(nameof(ownerId));
            }

            if (String.IsNullOrEmpty(tableId))
            {
                throw new ArgumentException($"Parameter {nameof(tableId)} must not be null or empty", nameof(tableId));
            }

            if (rowId is null)
            {
                throw new ArgumentNullException(nameof(rowId));
            }

            lock (dataAccessLock)
            {
                CheckOwnerId(ownerId);
                CheckTableId(tableId);
                CheckRowId(tableId, rowId);

                object trueOwnerId = dataProvider.GetOwnerForRowId(tableId, rowId);

                if (!ownerId.Equals(trueOwnerId))
                {
                    throw new PersonalDataDBException($"The requested row does not belong to the owner in the parameter {nameof(ownerId)}");
                }

                IPersonalDataRow row = dataProvider.ReadPersonalDataRow(tableId, rowId);

                ITableDefinition table        = dataProvider.GetTable(tableId);
                string           tableLogName = table.Name ?? table.ID;

                WriteOwnerLog(ownerId, $"You accessed your personal data and read the whole row with ID \"{rowId.ToString()}\" in the table \"{tableLogName}\"");
                return(row);
            }
        }