JegasAPI - Jegas, LLC - Copyright(c)2016

Unit uj_dbtools

DescriptionUsesClasses, Interfaces, Objects and RecordsFunctions and ProceduresTypesConstantsVariables

Description

JAS Database Tools

Overview

Functions and Procedures

procedure DBM_EmptyTrash(p_Context: TCONTEXT);
procedure DBM_KillOrphans(p_Context: TCONTEXT);
procedure DBM_SyncDBMSColumns(p_Context: TCONTEXT);
procedure DBM_SyncScreenFields(p_Context: TCONTEXT);
procedure DBM_JCaptionFlagOrphans(p_Context: TCONTEXT);
procedure DBM_JNoteFlagOrphans(p_Context: TCONTEXT);
procedure DBM_DiffTool(p_Context: TCONTEXT);
procedure DBM_WipeAllRecordLocks(p_Context: TCONTEXT);
procedure DBM_UpdateJCompanyMember(p_Context: TCONTEXT);
procedure DBM_FindDupeUID(p_Context: TCONTEXT);
procedure DBM_LearnTables(p_Context: TCONTEXT);
procedure CSVUpload(p_Context: TCONTEXT);
procedure CSVMapfields(p_Context: TCONTEXT);
procedure CSVImport(p_Context: TCONTEXT);
procedure JASSync(p_Context: TCONTEXT);
procedure FileUpload(p_Context: TCONTEXT);
procedure FileDownload(p_Context: TCONTEXT);
function bPreDel_JBlok(p_Context: TCONTEXT; p_TGT: JADO_CONNECTION; p_saUID: ansistring): boolean;
function bPreDel_JScreen(p_Context: TCONTEXT; p_TGT: JADO_CONNECTION; p_saUID: ansistring):boolean;
function bPreDel_JCase(p_Context: TCONTEXT; p_TGT: JADO_CONNECTION; p_saUID: ansistring):boolean;
function bPreDel_JTask(p_Context: TCONTEXT; p_TGT: JADO_CONNECTION; p_saUID: ansistring):boolean;
function bPreDel_JFile(p_Context: TCONTEXT; p_TGT: JADO_CONNECTION; p_saUID: ansistring):boolean;
function bPreDel_JCompany(p_Context: TCONTEXT; p_TGT: JADO_CONNECTION; p_saUID: ansistring):boolean;
function bPreDel_JFilterSave(p_Context: TCONTEXT; p_TGT: JADO_CONNECTION; p_saUID: ansistring):boolean;
function bPreDel_JIconContext(p_Context: TCONTEXT; p_TGT: JADO_CONNECTION; p_saUID: ansistring):boolean;
function bPreDel_JInvoice(p_Context: TCONTEXT; p_TGT: JADO_CONNECTION; p_saUID: ansistring):boolean;
function bPreDel_JLead(p_Context: TCONTEXT; p_TGT: JADO_CONNECTION; p_saUID: ansistring):boolean;
function bPreDel_JInstalled(p_Context: TCONTEXT; p_TGT: JADO_CONNECTION; p_saUID: ansistring):boolean;
function bPreDel_JModuleSetting(p_Context: TCONTEXT; p_TGT: JADO_CONNECTION; p_saUID: ansistring):boolean;
function bPreDel_JModule(p_Context: TCONTEXT; p_TGT: JADO_CONNECTION; p_saUID: ansistring):boolean;
function bPreDel_JPerson(p_Context: TCONTEXT; p_TGT: JADO_CONNECTION; p_saUID: ansistring):boolean;
function bPreDel_JProject(p_Context: TCONTEXT; p_TGT: JADO_CONNECTION; p_saUID: ansistring):boolean;
function bPreDel_JProduct(p_Context: TCONTEXT; p_TGT: JADO_CONNECTION; p_saUID: ansistring):boolean;
function bPreDel_JSecGrp(p_Context: TCONTEXT; p_TGT: JADO_CONNECTION; p_saUID: ansistring):boolean;
function bPreDel_JSecPerm(p_Context: TCONTEXT; p_TGT: JADO_CONNECTION; p_saUID: ansistring):boolean;
function bPreDel_JSession(p_Context: TCONTEXT; p_TGT: JADO_CONNECTION; p_saUID: ansistring):boolean;
function bPreDel_JSysModule(p_Context: TCONTEXT; p_TGT: JADO_CONNECTION; p_saUID: ansistring):boolean;
function bPreDel_JSysModuleLink(p_Context: TCONTEXT; p_TGT: JADO_CONNECTION; p_saUID: ansistring):boolean;
function bPreDel_JTable(p_Context: TCONTEXT; p_TGT: JADO_CONNECTION; p_saUID: ansistring):boolean;
function bPreDel_JTeam(p_Context: TCONTEXT; p_TGT: JADO_CONNECTION; p_saUID: ansistring):boolean;
function bPreDel_JUser(p_Context: TCONTEXT; p_TGT: JADO_CONNECTION; p_saUID: ansistring):boolean;
procedure DBM_FlagJasRow(p_Context: TCONTEXT);
procedure DBM_FlagJasRowExecute(p_Context: TCONTEXT);
function u8NewConAndDB( p_Context: TCONTEXT; p_saName: ansistring ): UInt64;
function bDBMasterUtility( p_Context: TCONTEXT; p_DBC: JADO_CONNECTION; var p_JDCon_JDConnection_UID: UInt64; p_saName: ansistring; p_bLeadJet: boolean ): boolean;
function bSetDefaultSecuritySettings(p_Context: TCONTEXT): Boolean;
procedure DBM_RemoveJet(p_Context: TCONTEXT);
function bDBM_DatabaseScrub(p_Context: TCONTEXT): boolean;
function DBM_JIPList(p_Con: JADO_CONNECTION; p_saAction: ansistring; p_sIP: string; p_sReason: string; p_u8UserID: UInt64):boolean;
function bDeleteRecord( p_Con: JADO_Connection; p_sTable: string; p_sColumnPrefix: string; p_saWhereClause: ansistring; p_u8UserID: UInt64 ): boolean;

Description

Functions and Procedures

procedure DBM_EmptyTrash(p_Context: TCONTEXT);

Delete all records in tables with _Deleted_b flag set to true.

procedure DBM_KillOrphans(p_Context: TCONTEXT);

Delete all orphaned records in the database.

procedure DBM_SyncDBMSColumns(p_Context: TCONTEXT);

This function goes thru DBMS schema and corrects jcolumn Records if it can EACH DBMS will need to be addressed as the techniques and data will vary. Starting with MySQL and using the information schema.

procedure DBM_SyncScreenFields(p_Context: TCONTEXT);

This function examines jblokfield records system wide. If they have a column associated with then (i.e. not a custom jblokfield) and the properties aren't set for max width, length and height - this function adjusts them based on the associated database columns.

procedure DBM_JCaptionFlagOrphans(p_Context: TCONTEXT);
 
procedure DBM_JNoteFlagOrphans(p_Context: TCONTEXT);
 
procedure DBM_DiffTool(p_Context: TCONTEXT);

This procedure compares JAS Database info against actual database

procedure DBM_WipeAllRecordLocks(p_Context: TCONTEXT);

Delete all records in tables with _Deleted_b flag set to true.

procedure DBM_UpdateJCompanyMember(p_Context: TCONTEXT);

Updates jcompanymember by interrogating the jperson table and the jcompany table to find members that may not of been added.

procedure DBM_FindDupeUID(p_Context: TCONTEXT);

Diagnostic looking for Duplicate UID's. Shouldn't be any, but if there are, the table should be altered to have the UID column set as the primary key after the data is scrubbed accordingly.

procedure DBM_LearnTables(p_Context: TCONTEXT);

This tool allows you to point to a connected database connection and select one or more tables and submit your selection. Once submitted this function will add table records and column records into JAS' meta data allowing you to later view them, and make screens for them from the JTable Search screen or from the record/detail view of any one of those tables.

procedure CSVUpload(p_Context: TCONTEXT);

Routine that does the actual importing of CSV files

procedure CSVMapfields(p_Context: TCONTEXT);

Routine To Handle the process of mapping fields from the CSV to the target table

procedure CSVImport(p_Context: TCONTEXT);

First step int the CSV import process -starts here

procedure JASSync(p_Context: TCONTEXT);

This function literally synchronizes Itself with another JAS Installation connected as a Datasource. It doesn't work over the web via some sort of webbrowser connection. A web browser is the default way to invoke the synchronization however.

procedure FileUpload(p_Context: TCONTEXT);

handles uploaded files to system

procedure FileDownload(p_Context: TCONTEXT);

This function is for downloading files from the file repository and it takes permissions and ownership into consideration. Ownership first, if the user is not the Owner (Created By) then the user must have the permission assigned to the file. If they do not have the permission, or the permission is NULL or ZERO - then access is denied.

function bPreDel_JBlok(p_Context: TCONTEXT; p_TGT: JADO_CONNECTION; p_saUID: ansistring): boolean;

Delete JBlok children

function bPreDel_JScreen(p_Context: TCONTEXT; p_TGT: JADO_CONNECTION; p_saUID: ansistring):boolean;

Delete JScreen children

function bPreDel_JCase(p_Context: TCONTEXT; p_TGT: JADO_CONNECTION; p_saUID: ansistring):boolean;

Delete JCase children

function bPreDel_JTask(p_Context: TCONTEXT; p_TGT: JADO_CONNECTION; p_saUID: ansistring):boolean;

Delete JTask children

function bPreDel_JFile(p_Context: TCONTEXT; p_TGT: JADO_CONNECTION; p_saUID: ansistring):boolean;

Rename JFile Records File to Linux "hidden"; prepend period to name.

function bPreDel_JCompany(p_Context: TCONTEXT; p_TGT: JADO_CONNECTION; p_saUID: ansistring):boolean;

Delete JCompany Children

function bPreDel_JFilterSave(p_Context: TCONTEXT; p_TGT: JADO_CONNECTION; p_saUID: ansistring):boolean;

Delete JFilterSave Children (defaults)

function bPreDel_JIconContext(p_Context: TCONTEXT; p_TGT: JADO_CONNECTION; p_saUID: ansistring):boolean;

Delete JIconContext Children (jiconmaster)

function bPreDel_JInvoice(p_Context: TCONTEXT; p_TGT: JADO_CONNECTION; p_saUID: ansistring):boolean;

Delete JInvoice Children (jinvoicelines)

function bPreDel_JLead(p_Context: TCONTEXT; p_TGT: JADO_CONNECTION; p_saUID: ansistring):boolean;

Delete JLead Children

function bPreDel_JInstalled(p_Context: TCONTEXT; p_TGT: JADO_CONNECTION; p_saUID: ansistring):boolean;

Delete JInstalled Children

function bPreDel_JModuleSetting(p_Context: TCONTEXT; p_TGT: JADO_CONNECTION; p_saUID: ansistring):boolean;

Delete JModuleSetting Children

function bPreDel_JModule(p_Context: TCONTEXT; p_TGT: JADO_CONNECTION; p_saUID: ansistring):boolean;

Delete JModule Children

function bPreDel_JPerson(p_Context: TCONTEXT; p_TGT: JADO_CONNECTION; p_saUID: ansistring):boolean;

Delete JPerson Children

function bPreDel_JProject(p_Context: TCONTEXT; p_TGT: JADO_CONNECTION; p_saUID: ansistring):boolean;

Delete JProject Children

function bPreDel_JProduct(p_Context: TCONTEXT; p_TGT: JADO_CONNECTION; p_saUID: ansistring):boolean;

Delete JProduct Children

function bPreDel_JSecGrp(p_Context: TCONTEXT; p_TGT: JADO_CONNECTION; p_saUID: ansistring):boolean;

Delete JSecGrp Children

function bPreDel_JSecPerm(p_Context: TCONTEXT; p_TGT: JADO_CONNECTION; p_saUID: ansistring):boolean;

Delete JSecPerm Children

function bPreDel_JSession(p_Context: TCONTEXT; p_TGT: JADO_CONNECTION; p_saUID: ansistring):boolean;

Delete JSession Children

function bPreDel_JSysModule(p_Context: TCONTEXT; p_TGT: JADO_CONNECTION; p_saUID: ansistring):boolean;

Delete JSysModule Children

function bPreDel_JSysModuleLink(p_Context: TCONTEXT; p_TGT: JADO_CONNECTION; p_saUID: ansistring):boolean;

Delete JSysModuleLink Children

function bPreDel_JTable(p_Context: TCONTEXT; p_TGT: JADO_CONNECTION; p_saUID: ansistring):boolean;

Delete JTable Children (columns)

function bPreDel_JTeam(p_Context: TCONTEXT; p_TGT: JADO_CONNECTION; p_saUID: ansistring):boolean;

Delete JTeam Children

function bPreDel_JUser(p_Context: TCONTEXT; p_TGT: JADO_CONNECTION; p_saUID: ansistring):boolean;

Delete JUser Children

procedure DBM_FlagJasRow(p_Context: TCONTEXT);

This function is only for the main JAS database and is for preparing for distribution of new upgrades, making new JAS databases and new Jet databases.

procedure DBM_FlagJasRowExecute(p_Context: TCONTEXT);

This function does the actual work that DBM_FlagJasRow commands.

function u8NewConAndDB( p_Context: TCONTEXT; p_saName: ansistring ): UInt64;

Makes new user, password and database and makes a JAS connection for it using same info. This routin passes back the JDConnection UID when successful or a ZERO if it fails. Note the connection IS NOT ENABLED so the next step to make the database etc would be to load the info into an instance of JDCON, Doo all you have to do then SAVE the connection as ENABLED and send the Cycle command into the JobQueue of the Squadron Leader databse.

function bDBMasterUtility( p_Context: TCONTEXT; p_DBC: JADO_CONNECTION; var p_JDCon_JDConnection_UID: UInt64; p_saName: ansistring; p_bLeadJet: boolean ): boolean;

DBC - Main DB Connection (SOURCE) JDCon_JDConnection_UID: Database connection in source DB to use Name to use making a connection if JDCon_JDConnection_UID is ZERO on entry bLeadJet: If True treat as Master Database, otherwise like a JET database.

Makes New Master databses or Jet databases and also upgrades existing databases.

Make Tables (jtable info) or Alter NOTE: if not exist (Use JAS_Row_b Column Records for info) Add Rows or Update from master flagged JAS_Row_b Note: Tables without JAS_Row_b - Add rows (e.g. jasident, juserpref) TODO: Add VIEW SQL to jtable - for each DBMS - Use to make Views)

function bSetDefaultSecuritySettings(p_Context: TCONTEXT): Boolean;

Make Default Security Settings

procedure DBM_RemoveJet(p_Context: TCONTEXT);
 
function bDBM_DatabaseScrub(p_Context: TCONTEXT): boolean;
 
function DBM_JIPList(p_Con: JADO_CONNECTION; p_saAction: ansistring; p_sIP: string; p_sReason: string; p_u8UserID: UInt64):boolean;

Quick way to take immediate charge of the JIPLIST for banning, unbanning etc This effect both the database and memory. No Cycling. B = Ban P = Promote or Whitelist F = Forget or Remove from jiplist

function bDeleteRecord( p_Con: JADO_Connection; p_sTable: string; p_sColumnPrefix: string; p_saWhereClause: ansistring; p_u8UserID: UInt64 ): boolean;

Using this takes into account the configuration setting grJASConfig.bSafeDelete which decides if records get flagged as deleted or just deleted outright

http://www.jegas.com
Generated by PasDoc 0.14.0.