---
title: OregonBusinessService
summary: API reference for OregonBusinessService.
status: draft
owner: SAIF Doc Gen
last_reviewed: 2026-09-24
library: SAIF.Services
reference_type: package
---

# OregonBusinessService

Bulk-loads a CSV feed of Oregon (DCBS) business registry records into the `OregonBusiness` data table, parsing the file with `FileReader<OregonBusinessCsvFile>`, truncating over-length name fields to fit column limits, and running the whole load inside a single `IUnitOfWork` transaction; collaborates with `IUserProfileService` to stamp each created row with the current user and `IErrorConditionHandler` for error handling (injected but not exercised in the shown logic).*

## Purpose
- Reads an Oregon business registry CSV file and loads each business row (with a state code shorter than 3 characters) into the `OregonBusiness` table.
- Truncates `FirstName`, `MiddleName`, and `LastName` values to their respective column-length limits (20/30/50 characters) before insertion.
- Stamps every created row with the current user's ID and creation timestamp.
- Wraps the entire file-load operation in a single transaction, committing only on success and rolling back (and re-throwing) on failure.

## Context
- Namespace: `SAIF.Services.Policies.DcbsOregonBusiness`
- Assembly/package: `SAIF.Services` (packaged inside the `SAIF.SAIFCode.Core` NuGet package).

## Public members
| Member | Signature | Purpose |
| --- | --- | --- |
| OregonBusinessService (constructor) | `public OregonBusinessService(IUnitOfWork uow, IUserProfileService prof, IErrorConditionHandler errorConditionHandler)` | Wires the unit of work, user-profile service (also assigned to a shared static field), and error-condition handler used during file processing. |
| DataException | `public Exception DataException { get; set; }` | Holds an exception captured during processing for inspection by the caller after the operation completes.* |
| ProcessOregonBusinessFile | `public bool ProcessOregonBusinessFile(ILogWriter controlLog, string filepath)` | Reads the CSV at `filepath`, inserts a new `OregonBusiness` row for each record whose state code is under 3 characters, commits the transaction on success (logging the loaded count and current user), or rolls back and throws on failure; logs progress and the abort line number via `controlLog`. |

## Behavioral notes
- `ProcessOregonBusinessFile` begins the transaction (`_unitOfWork.Begin()`) before parsing the file, so a parse failure leaves the transaction open until the surrounding `catch` re-throws without an explicit rollback call in that branch.*
- Only records whose `StateCode` is shorter than 3 characters are loaded; records with a state code of 3 or more characters are silently skipped and not counted in `loadcount`.
- `CreateOregonBusinessRow` is a `static` private helper that truncates `FirstName` (20 chars), `MiddleName` (30 chars), and `LastName` (curiously checked against `MiddleName.Length`, then substringed from `LastName`) (50 chars) before adding the row to the `OregonBusiness` repository.
- The user-profile service is assigned to a `private static IUserProfileService _profileService` field in the constructor, meaning the last-constructed instance's profile service is shared across all instances of this type.*
- On failure, the method logs the error, rolls back the transaction, and throws a plain `Exception("Error in Processing Oregon Businesses- review the log file")`, discarding the original exception's type.

## Constraints and usage notes
- `uow` and `prof` are null-checked via `Enforce.ArgumentNotNull`; `errorConditionHandler` is not.
- The class carries a `CA1506:AvoidExcessiveClassCoupling` suppression.
- Because `_profileService` is `static`, this service should not be treated as safe for concurrent use by multiple users in the same process without further verification.*

> **Note:** Statements marked with * were inferred from code structure, naming conventions, or
> contextual evidence where direct confirmation was not available in source artifacts. Statements
> marked with ** could not be confirmed; treat as unknown until verified.

## Sources
- `Services/SAIF.Services/Policies/DcbsOregonBusiness/OregonBusinessService.cs`
