Compile Subroutine Sql_User_Debug(MsgSent)

/******************************************************************************************************** 

    This program is proprietary and is not to be used by or disclosed to others, nor is it to
    be copied without written permission from SRP Computer Solutions, Inc.

    Name        :   Sql_User_Debug

    Description :   Intercepts debugger for SQL Server engines

    Parameters  :
		MsgSent		[out] --

    History (Date, Initials, Notes)
    	04/01/06    dmb     Initial new logic																			
		06/30/09    fjt     Updated for use in EPI
		06/30/10    jch     Cloned from debugger_replace in SYSPROG acct	

********************************************************************************************************/

$insert RTI_Debug_Common
$insert Logical
$insert SRPMail_Inserts

Declare function SRP_Send_Mail, Datetime

Process = 0
Loop
    Process += 1
    On Process GoSub Init, Development, Check, Text, Message, Send, Done
Until (Error or Done)
Repeat

Return


!----- PROCESS ROUTINES ---------------------------------------------------------------------------------


Init:
    Done     = No$
    Error    = No$
    Program  = Curr_Program@
    MsgSent  = ""
    
*    If Program EQ "" then Program = "SQL Debug Intercept Test"
*    
*    SentFrom = "oinotify@irf.com"
* 	SentTo   = "kfournier@srpcs.com"
* 	
*    ConfigFile = ""
*    ConfigFile<1> = SendUsing_Port$
*    ConfigFile<2> = ""
*    ConfigFile<3> = 25                      ;// Server port
*    ConfigFile<4> = "10.95.1.11"			;// Mail server
*    ConfigFile<5> = Yes$                    ;// Authenticate
*    ConfigFile<6> = "oinotify@irf.com"		;// Username
*    ConfigFile<7> = "oinotify1"		        ;// Password
*    ConfigFile<8> =	No$						;// Use SSL
return


Development:
* 	NoEmail = "SRP_FRANK"
* 	Locate @USER4 in NoEmail using "," setting x then
*		Done = Yes$
* 	end
return


Check:
return


Text:
    Text = ""
    Text<-1> = "App:     "	: @APPID<1>
    Text<-1> = "Window:  "  : @WINDOW
    Text<-1> = "User:    "	: @USER4
    Text<-1> = "Station: "	: @STATION
    Text<-1> = " "
    Text<-1> = "SP Status:    "  : SPStatus@
    Text<-1> = "SP Stat Code: "  : SPStatCode@
    Text<-1> = "Program:      "  : Program
    Text<-1> = "Call Depth:   "  : CallDepth@
    Text<-1> = "Line No:      "  : LineNo@
    Text<-1> = " "
    Text<-1> = "Stack:   "
    Text<-1> = CallStack@
    
*    Convert \00\ to "," in Text
*    Convert @VM to "-" in Text
*    Swap @FM with Char(13):Char(10) in Text
    
*    OSWrite Text to Drive():"\logs\debug_log.txt"
return

  
Message:  
    Message = ""
    Message<1> = "IR/EPI Debug Alert - ":Program	; // Subject
    Message<2> = SentFrom		                    ; // From (email address)
    Message<3> = SentTo			                    ; // Send to (email address)
    Message<5> = ""							        ; // Blind Carbon Copy (email address)
    Message<6> = ""							        ; // Reply To (email address)
    Message<7> = "TEXT"						        ; // Content Type (TEXT or HTML)
    Message<8> = Text						        ; // Content / Body
    Message<9> = ""							        ; // Attachment(s) (path to file name(s))
return
    

Send:
*    MsgSent = SRP_Send_Mail(Message, ConfigFile)

    Open "SQL_ERROR" to hSQL_ERROR then
        Write Text to hSQL_ERROR, Datetime() then null
    End
    
return


Done:
    Done = Yes$
return


