diff --git a/.gitignore b/.gitignore index 0e3b714..b7b0c06 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,8 @@ # Compilación .NET Framework / ASP.NET [Bb]in/ +!SIG.Web/[Bb]in/ +!SIG.Web/[Bb]in/** [Oo]bj/ [Dd]ebug/ [Rr]elease/ diff --git a/240722_Formato Alta Lotes_AP+ALC_CANT 2da ET_HMO_Red Interna_ET 1_259viv_AGUAHH.xlsx b/240722_Formato Alta Lotes_AP+ALC_CANT 2da ET_HMO_Red Interna_ET 1_259viv_AGUAHH.xlsx new file mode 100644 index 0000000..079b119 Binary files /dev/null and b/240722_Formato Alta Lotes_AP+ALC_CANT 2da ET_HMO_Red Interna_ET 1_259viv_AGUAHH.xlsx differ diff --git a/AGENTS.md b/AGENTS.md index 5b8669e..a51874d 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -53,6 +53,25 @@ Database --- +## Source code readability rules + +All generated or modified source code must be formatted for human maintenance. + +- Do not compress multiple controls, HTML elements, CSS rules, SQL clauses, assignments, conditions, or statements onto one line merely to reduce file length. +- Use consistent indentation and line breaks that make nesting and control flow visible. +- Put independent C# statements on separate lines. Expand non-trivial `if`, loops, object initializers, method calls, and methods across multiple lines. +- In ASPX/HTML, place nested elements and server controls on separate indented lines. Keep attributes readable; wrap long declarations across lines. +- Format CSS with one declaration per line for page-specific styles. Format JavaScript and SQL using the same readability principle. +- Prefer clear diffs and easy future editing over compact generated output. +- The command rule requiring one-line PowerShell or terminal commands applies only to commands. It does not apply to C#, ASPX, HTML, CSS, JavaScript, SQL, XML, or configuration source. + +## Agent instruction file maintenance rules + +- Before modifying `AGENTS.md` or any complementary `AGENTS_*.md` file, read the existing file and apply only the smallest required addition or correction. +- Do not rewrite or replace an entire agent instruction file unless the user explicitly requests a complete rewrite. +- Preserve existing user-authored rules, terminology, capitalization, examples, and formatting outside the requested change. +- When adding a rule, first verify whether an equivalent or conflicting rule already exists and update only the relevant section. + ## Command rules When giving commands for this project: @@ -88,7 +107,7 @@ Use this base structure: ```text SIG.Web/ - AppCode/ + App_Code/ Infrastructure/ Sql/ Repositories/ @@ -114,10 +133,14 @@ SIG.Web/ Rules: +- The active application uses the ASP.NET Web Site runtime-compilation model. +- Shared C# source belongs in the exact special folder `App_Code`. +- Pages, master pages, controls, handlers, and `Global.asax` use `CodeFile` or source compiled from `App_Code`; do not introduce new `CodeBehind` dependencies on `SIG.Web.dll`. +- Keep third-party and external assemblies in `bin`, but do not build or deploy a project assembly named `SIG.Web.dll`. - Do not place database access directly inside `.aspx.cs`, `.ascx.cs`, or `Site.master.cs`. - Database-related helpers go under `App_Code/Sql` or a clearly named SQL/data folder. - Business access goes through `Contracts` and `Services`. -- If the project file needs explicit compilation entries, include C# files recursively, for example `App_Code\**\*.cs`, but avoid duplicate compile entries that include the same file twice. +- The active Web Site does not use explicit project compilation entries; C# files under `App_Code` compile automatically at runtime. --- @@ -282,6 +305,19 @@ Do not mix placeholder naming systems in the same project. --- +## WebForms tab and page-state rules + +- Register AjaxControlToolkit once in `Web.config` under `system.web/pages/controls` with the exact prefix `ajax`; do not add `<%@ Register ... %>` directives for it in individual pages. +- AjaxControlToolkit controls must use the `ajax:` prefix, for example `ajax:TabContainer` and `ajax:TabPanel`; do not use `ajaxToolkit:` or another page-specific prefix. +- Tabs in WebForms pages must use `ajax:TabContainer` and `ajax:TabPanel`; do not build page tabs with Bootstrap `nav-tabs`, custom hidden panels, or JavaScript-only tab switching. +- Use the `ScriptManager` owned by `Site.master` and the existing AjaxControlToolkit resources. Do not add another `ScriptManager` or duplicate Toolkit scripts/styles. +- Server-side page state such as current entity keys, selected child keys, editing mode, flags, and the active tab must be stored in typed `ViewState` properties when it must survive postback. +- Do not add `asp:HiddenField` merely to preserve server-side state across postbacks. A hidden field is allowed only when client-side JavaScript must read or change the value. +- Hidden-field values are client-controlled and must never be trusted for authorization or sensitive decisions; validate them again on the server when their use is unavoidable. +- Keep ViewState values small and serializable. Do not store database connections, commands, readers, services, repositories, or unnecessarily large result sets in ViewState. +- ViewState property and key names must identify the entity and purpose, for example `CveFraccionamientoActual` and `CveFraccionamientoEtapaActual`. + +--- ## Login and session rules Authentication must go through a contract. @@ -358,6 +394,23 @@ Rules: --- +## Repository ownership rules + +Repository ownership is determined by the data domain and stored-procedure prefix, not by the page or feature that currently consumes the data. + +- Procedures named `PA_Gral_*` belong behind contracts and repositories under `Contracts/General` and `Repositories/General`. +- General catalogs such as states, countries, municipalities, neighborhoods, and postal codes must not be placed in a security, registration, sales, or page-specific repository. +- A feature service such as public registration may orchestrate both its feature repository and `IGeneralCatalogRepository`, but it must not move general catalog access into the feature repository. +- Apply the same ownership rule to future procedure families: `PA_Sis_*` belongs to security/system infrastructure, `PA_Tra_*` to procedures, `PA_Vta_*` to sales, and so on. + +## Database executor ownership rules + +- `IDbExecutor`, `DbExecutor`, `StoredProcedureCommand`, `IDbCommand`, and direct stored-procedure execution may only be used inside classes under `Repositories` or repository database infrastructure. +- Services must not reference or receive `IDbExecutor`, create database commands, execute readers, or call stored procedures directly. +- A service that needs persisted data must depend on a repository contract. The concrete repository receives `IDbExecutor` and owns parameter configuration and result mapping. +- Keep the `DbExecutor` implementation under `Repositories/Database`; do not place it under `Services` or expose it publicly through `AppServices`. + +--- ## Service rules Services belong in `/Services`. @@ -379,6 +432,12 @@ Rules: - Services may depend on SQL helpers/repositories. - `.aspx.cs` files should be thin and delegate work to services. - Keep dummy services separate from SQL-backed services. +- Services own application transactions when one business operation performs one or more repository mutations. +- Use `TransactionLogic` inside a `using` block around the repository calls and invoke `Commit()` only after every required repository result succeeds. +- Pages and repositories must not create, commit, roll back, or dispose application transactions. +- Repositories participate through the ambient `TransactionScope`; connection strings used for transactional work must not set `Enlist=false`. +- Select `TransactionScopeOption`, isolation level, and timeout in the service according to the business operation. Use `RequiresNew` or `Suppress` only when that behavior is intentional and documented by the call site. +- Do not include slow external operations such as SMTP or HTTP calls inside a database transaction. --- @@ -428,15 +487,20 @@ Rules: - Do not create `SqlCommand` directly in `.aspx.cs`. - Use repositories or SQL executor classes behind contracts. - All application database reads and writes must use stored procedures; inline SQL in C# is prohibited. -- Mandatory: read and follow `AGENTS_STORED_PROCEDURES.md` for naming, output parameters, TRY/CATCH, logging, transactions, and logical deletion. +- Mandatory: read and follow `AGENTS_STORED_PROCEDURES.md` for naming, output parameters, TRY/CATCH, logging, transactions, and physical deletion. - Mandatory: read and follow `AGENTS_DATA_READER_MAPPING.md` for object, list, `DataTable`, and `JArray` result mapping. - Mandatory: read and follow `AGENTS_DATABASE_ERROR_LOGGING.md` for safe parameter logging and reproducible stored-procedure calls. - Mandatory: read and follow `AGENTS_PAGE_STRUCTURE.md` for the `Pages/Modulo/` location of all new WebForms pages. - Mandatory: read and follow `AGENTS_WEBFORMS_PARTIAL_POSTBACKS.md` for the single master form, ScriptManager ownership, UpdatePanel usage, and partial-postback rules. - Mandatory: read and follow `AGENTS_JAVASCRIPT_INITIALIZATION.md` for per-element initialization flags, global event guards, and idempotent control setup after partial postbacks. +- Mandatory: read and follow `AGENTS_CATALOG_STRUCTURE.md` for catalog titles, breadcrumbs, actions, filters, indicators, grids, quick-create modals, and detail pages. - Keep stored procedure names centralized. - Repositories must use `CommandType.StoredProcedure` and parameterized inputs/outputs. - Never concatenate raw user input into SQL. +- The database default collation and general text columns must use `Modern_Spanish_CS_AS`. +- Columns named `Codigo`, beginning with `Codigo`, or containing a real user login identifier such as `NombreUsuario`, `UsuarioPortal`, or `Acum_PortalUsuario` must use `Modern_Spanish_CI_AS`. +- `AgenteUsuario` is browser/device metadata, not a login identifier, and must use the general `Modern_Spanish_CS_AS` collation. +- Do not use `Modern_Spanish_CS_AI`. Recommended Web.config connection string pattern: @@ -582,6 +646,8 @@ Rules: - Do not build the menu from SQL inside `Site.master.cs`. - Menu items should use `MenuItemModel` or an equivalent model. - Encode text output when generating HTML menu strings. +- Module visibility and page access are separate concerns: `Sis_Modulos.Visible` controls whether an item is shown in the menu, but it must not deny direct page access. +- `PA_Sis_PaginaAccessCheck` must validate role assignment, `PuedeVer`, active state, and URL. It must not require `Sis_Modulos.Visible = 1`. --- @@ -622,15 +688,42 @@ MasterLayoutModel ## Error handling rules +Controlled outcomes and technical failures must use different logs. + +- `@ErrorTipo = 1`, SQL exceptions, timeouts, contract failures, and unexpected exceptions go to the main technical log. +- `@ErrorTipo = 2` is a controlled warning. It must not be written to the main technical log. +- Controlled warnings go to daily compact files under `~/log/controlled`. +- Controlled log files retain only the current day and the previous two days. The retention is configured with `ControlledLogRetentionDays = 3`. +- Explicit controlled throws must use `ControlledApplicationException`; do not classify arbitrary `Exception` or `InvalidOperationException` instances as controlled. +- Controlled logs record date, source, procedure, URL, and friendly message, but omit full stack traces and replay SQL to remain compact. +- A controlled exception must still return a friendly result to the page and must never be presented as an unexpected application failure. + - Handle null session user cleanly and redirect to login. - Handle failed login with a friendly message. - Handle async postback errors through `ScriptManager.AsyncPostBackError` only if the handler exists. - Avoid infinite loading states in JavaScript controls. - For AJAX/server search controls, use client and server timeouts. - Recommended default search timeout: about 20 to 30 seconds unless the user asks otherwise. +## Action availability and feedback rules + +- Do not disable a button or primary action only because a business prerequisite is missing, such as an unassigned client or an empty related catalog. +- Keep the action available by default; when the user clicks it, validate the prerequisite and show a clear message explaining why the operation cannot continue and what must be done next. +- Never leave a disabled action without an immediately visible explanation. +- Before adding `Enabled="false"`, the HTML `disabled` attribute, or an equivalent disabled CSS/JavaScript state to a catalog or page action, ask the user whether disabling is acceptable or whether a message, modal, link, or other alternative should be used. +- A transient disabled state used only while a request is being processed to prevent duplicate submissions is allowed, but the action must be restored when processing finishes. --- +## Grid display rules + +- Every new or modified `asp:GridView` must declare `GridLines="None"`. +- Its `CssClass` must include the exact utility class `Widthall` so the grid uses the full available width. +- Do not add `table-bordered` to a GridView. Existing visual classes such as `table`, `table-striped`, and `table-hover` may be retained when appropriate. +- Keep GridView declarations and their columns expanded and indented according to the source code readability rules. +- Detail-page navigation from a GridView or list must use `asp:HyperLink` or another real link with `NavigateUrl`; do not use `LinkButton`, `RowCommand`, or a postback only to open a detail page. +- URL-building variables and helpers must describe the row entity, for example `cveFraccionamiento`, `fraccionamientoDetalleUrl`, or `GetFraccionamientoDetalleUrl`. Avoid generic names such as `id`, `itemUrl`, or `detailUrl` when the entity is known. + +--- ## JavaScript and CSS rules - Global scripts/styles must be registered in `BundleConfig` and rendered by master. @@ -673,6 +766,20 @@ If the PDF viewer is added to this project later: Use only one active home page convention. +For local development, the canonical home URL is: + +```text +http://localhost:52706/Inicio.aspx +``` + +The application root must be equivalent and redirect explicitly to that page: + +```text +http://localhost:52706/ -> http://localhost:52706/Inicio.aspx +``` + +Keep the root redirect and the `Inicio.aspx` default document consistent. Do not introduce another startup page. + Allowed options: ```text diff --git a/AGENTS_CATALOG_STRUCTURE.md b/AGENTS_CATALOG_STRUCTURE.md new file mode 100644 index 0000000..49f6e91 --- /dev/null +++ b/AGENTS_CATALOG_STRUCTURE.md @@ -0,0 +1,116 @@ +# Reglas obligatorias para páginas de catálogo + +Estas reglas complementan `AGENTS.md`, `AGENTS_PAGE_STRUCTURE.md`, `AGENTS_WEBFORMS_PARTIAL_POSTBACKS.md` y `AGENTS_JAVASCRIPT_INITIALIZATION.md`. + +## Estructura visual + +Toda página de catálogo debe organizarse, en este orden: + +1. Título de la página. +2. Barra de navegación ascendente y menú de acciones. +3. Barra o control de filtros. +4. Sección opcional de cabecera con indicadores o resúmenes. +5. Grid o contenido principal. + +- El título, breadcrumb y contenedor de acciones pertenecen a `Site.master`; no deben duplicarse en cada ASPX. +- La barra de navegación debe mostrar la jerarquía ascendente hasta la página actual, por ejemplo `Inicio > Desarrolladores > Fraccionamientos`. +- La master debe exponer un `ContentPlaceHolder` de acciones dentro de un `