Skip to main content

Prerequisites

Before you begin, ensure you have the following installed:

.NET 8.0 SDK

Download from dotnet.microsoft.com

SQL Server

SQL Server 2019+ or SQL Server LocalDB for development
This guide uses SQL Server LocalDB for development. For production deployments, use a full SQL Server instance.

Installation

1

Clone or extract the source code

Extract the MasterLabel application source code to your local machine.
cd /path/to/MasterLabel
2

Set up the database

Create the MasterLabel database using the provided SQL script:
CREATE DATABASE [MasterLabelDB]
 CONTAINMENT = NONE
 ON PRIMARY 
( NAME = N'MasterLabelDB', FILENAME = N'C:\\MasterLabelDB.mdf' , 
  SIZE = 8192KB , MAXSIZE = UNLIMITED, FILEGROWTH = 65536KB )
 LOG ON 
( NAME = N'MasterLabelDB_log', FILENAME = N'C:\\MasterLabelDB_log.ldf' , 
  SIZE = 8192KB , MAXSIZE = 2048GB , FILEGROWTH = 65536KB )
GO

USE [MasterLabelDB]
GO

CREATE TABLE [dbo].[LabelData](
    [Id] [int] IDENTITY(1,1) NOT NULL,
    [JobId] [int] NULL,
    [SerialNumber] [varchar](50) NULL,
    [Job] [varchar](50) NULL,
    [Item] [varchar](50) NULL,
    [Description] [varchar](max) NULL,
    [OrderNumber] [decimal](18, 0) NULL,
    [OrderLine] [varchar](20) NULL,
    [LPN] [varchar](50) NULL,
    [TagNumber] [varchar](100) NULL,
    [ShipCode] [varchar](10) NULL,
    [IRNO] [varchar](100) NULL,
    [Subinv] [varchar](50) NULL,
    [FullAddress] [varchar](max) NULL,
    [CreatedDate] [datetime] NULL DEFAULT (getdate()),
    CONSTRAINT [PK__LabelDat__3214EC07D2298E42] PRIMARY KEY CLUSTERED ([Id] ASC)
)
GO

CREATE NONCLUSTERED INDEX [IX_LabelData_SerialNumber] 
ON [dbo].[LabelData] ([SerialNumber] ASC)
GO
Run the complete MasterLabel.sql script provided in the source code to create the database with all configurations.
3

Configure the connection string

Update the appsettings.json file with your SQL Server connection details:
{
  "ConnectionStrings": {
    "SqlConnection": "Server=(localdb)\\mssqllocaldb;Database=MasterLabelDB;Trusted_Connection=True;"
  }
}
The default configuration uses LocalDB. Update the connection string based on your environment.
4

Restore dependencies

Install the required NuGet packages:
dotnet restore
5

Run the application

Start the development server:
dotnet run
The application will start on https://localhost:5001 (or the port specified in your launch settings).
info: Microsoft.Hosting.Lifetime[14]
      Now listening on: https://localhost:5001
info: Microsoft.Hosting.Lifetime[0]
      Application started. Press Ctrl+C to shut down.

Logging Your First Incident

Once the application is running, follow these steps to log your first label printing incident:
1

Navigate to the application

Open your browser and go to https://localhost:5001
2

Search for label data

Enter a serial number in the search field to retrieve label information from the Oracle Support Dashboard.The application will call the Oracle Support Dashboard API:
[HttpPost]
public async Task<IActionResult> GetReportData([FromBody] SearchParameters parameters)
{
    var requestUrl = $"{BaseUrl}GetReportData?id=2154&parameters={{\"serial_number\":\"{parameters.SerialNumber}\"}}";
    var response = await _httpClient.PostAsync(requestUrl, null);
    
    if (response.IsSuccessStatusCode)
    {
        var jsonResult = await response.Content.ReadAsStringAsync();
        return Json(jsonResult);
    }
    // Error handling...
}
3

Review the retrieved data

The application will display label information including:
  • Serial Number
  • Job details
  • Item and Description
  • Order Number and Line
  • LPN (License Plate Number)
  • Tag Number
  • Ship Code
  • Subinventory
  • Full Address
4

Save the incident

Click the save button to log the incident to the database. The data is saved using:
[HttpPost]
public IActionResult SaveLabelData([FromBody] ReportData data)
{
    string connectionString = _configuration.GetConnectionString("SqlConnection");
    using (SqlConnection connection = new SqlConnection(connectionString))
    {
        connection.Open();
        
        string sql = @"INSERT INTO LabelData 
                    (SerialNumber, Job, Item, Description, OrderNumber, OrderLine, 
                     LPN, TagNumber, ShipCode, IRNO, Subinv, FullAddress, CreatedDate)
                    VALUES 
                    (@SerialNumber, @Job, @Item, @Description, @OrderNumber, @OrderLine,
                     @LPN, @TagNumber, @ShipCode, @IRNO, @Subinv, @Address, @Date)";
        
        using (SqlCommand command = new SqlCommand(sql, connection))
        {
            // Parameter binding...
            command.ExecuteNonQuery();
        }
    }
    
    return Json(new { success = true, message = "Datos guardados correctamente" });
}
The CreatedDate is automatically set to the current timestamp when saving.
5

Verify the incident was logged

Query the database to confirm the incident was saved:
SELECT TOP 10 * 
FROM LabelData 
ORDER BY CreatedDate DESC

Application Structure

Understanding the key components:
Program.cs
var builder = WebApplication.CreateBuilder(args);

// Add services to the container
builder.Services.AddControllersWithViews();
builder.Services.AddHttpClient();  // For Oracle Support Dashboard API calls

var app = builder.Build();

// Configure the HTTP request pipeline
if (!app.Environment.IsDevelopment())
{
    app.UseExceptionHandler("/Home/Error");
    app.UseHsts();
}

app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthorization();

app.MapControllerRoute(
    name: "default",
    pattern: "{controller=Home}/{action=Index}/{id?}");

app.Run();
The application uses the standard ASP.NET Core MVC pattern with controllers handling HTTP requests and Razor views for the UI.

Next Steps

Incident Logging

Learn about the full incident logging workflow

API Reference

Explore the API endpoints in detail

Database Setup

Learn more about the database schema and configuration

Data Search

Understand the Oracle Support Dashboard integration

Build docs developers (and LLMs) love