GPAL - Generally Positive Automation Library v1.0
GPAL The Fluent Automation LIbrary
Loading...
Searching...
No Matches
DatabaseSettings.cs
1// =============================================================================
2// GPAL - Generally Positive Automation Library
3// Copyright © 2026 Software Decisions, Inc. All rights reserved.
4//
5// This file is part of GPAL.
6// Licensed under the Business Source License 1.1
7//
8// Primary development, architecture, and vision by Michael B. Vederman,
9// CEO of Software Decisions, Inc., Texas.
10//
11// Internal development maintained privately.
12// Public releases appear on GitHub: https://github.com/SoftwareDecisionsInc/GPAL.
13//
14// See LICENSE for full terms, including Additional Use Grant.
15// =============================================================================
16
17using System;
18using System.Collections.Generic;
19using System.Data;
20using System.Data.SqlClient;
21using System.Linq;
22using System.Text;
23using System.Threading.Tasks;
24using static GenerallyPositive.Enums;
25
26namespace GenerallyPositive
27{
28 internal class DatabaseSettings
29 {
30 public GPALDatabase Database { get; set; }
31 public DatabaseType DatabaseType { get; set; }
32 public string DatabaseName { get; set; }
33 public string TableName { get; set; }
34 public string ServerName { get; set; }
35 public string UserName { get; set; }
36 public string Password { get; set; }
37 public SqlConnection Connection { get; set; }
38 public SqlTransaction SqlTransaction { get; set; }
39 public string ConnectionString { get; set; }
40 private string ExecutionString { get; set; } = null;
41 public string CreateSQL { get; set; } = null;
42 public string ReadSQL { get; set; } = null;
43 public string UpdateSQL { get; set; } = null;
44 public string DeleteSQL { get; set; } = null;
45 public System.Data.CommandType SqlCommandType { get; set; } = CommandType.Text;
46 public List<DatabaseColumn> ColumnList { get; set; }
47 public List<string> ParameterNamesList { get; set; }
48 public List<string> ParametersList { get; set; }
49 public IGPALGrid<string> ParametersGrid { get; set; }
50 public GPALDatabase.DatabaseError LastError { get; set; } // null until something fails
51 public IGPALGrid<string> Tokens { get; set; } // rows and columns of data to enter into text fields, CAVEAT: possibly something other than text? an image?
52 public List<int> LastGridRowCountsPerTable { get; set; } // set by SaveTo(out IGPALGrid<string>); read back by the optional GetRowCount() chained call
53 public int RowCount { get; set; } = -1;
54 public int CommandTimeoutSeconds { get; set; } = -1; // -1 leaves the provider's own default alone
55 public GPALDatabase.CallOnError CallOnErrorHandler { get; set; } = null;
56 public string StoredProcedure
57 {
58 get
59 {
60 return ExecutionString;
61 }
62 internal set
63 {
64 SqlCommandType = CommandType.StoredProcedure;
65 ExecutionString = value;
66 }
67 }
68 public string SqlCommand
69 {
70 get
71 {
72 return ExecutionString;
73 }
74 set
75 {
76 SqlCommandType = CommandType.Text;
77 ExecutionString = value;
78 }
79 }
80 internal class DatabaseColumn
81 {
82 public string ColumName { get; set; } = null;
83 public SqlDbType ColumnType { get; set; }
84 public int ColumnLength { get; set; }
85 public int ColumnPrecision { get; set; }
86 public int ColumnScale { get; set; }
87 public string TvTableTypeName { get; set; } // UDTT name for SqlDbType.Structured
88 public DatabaseColumn(string name)
89 {
90 ColumName = name;
91 }
92 public DatabaseColumn(string name, SqlDbType sqlDbType)
93 {
94 ColumName = name;
95 ColumnType = sqlDbType;
96 }
97 }
98 public DatabaseSettings(GPALDatabase database)
99 {
100 ColumnList = new List<DatabaseColumn>();
101 ParameterNamesList = new List<string>();
102 ParametersList = new List<string>();
103 ParametersGrid = GPAL.Grid.ToGPALObject();
104 Tokens = GPAL.Grid.ToGPALObject();
105 Database = database;
106 }
107
108 }
109}
110