So here is the code for others if ever needed and it will be here for reference if I ever need the coding again.
Code:
'Date Created: 31-Mar-2016 09:59:28 AM 'Last Updated: 21-Feb-2018 04:50:28 PM 'Created By : Steve 'Updated By : hubby 'Prompt for text and store result in a variable called 'ftype'. 'Get 'Value' property of 'Idclientd' in Form 'clientstart' . DIM window_name as C window_name = ":"+"credmaster" DIM varP_Object as p 'Get a pointer to the specified window varP_Object = obj(window_name) 'Check if the specified window exists if .not. is_object(varP_Object) then ui_msg_box("Error","The window '"+window_name+"' does not exist.",ui_stop_symbol) else DIM SHARED clientid AS n clientid = varP_Object:Idclientd.value end if dim prmpt_title as c dim prmpt_prompt as c dim prmpt_default as c prmpt_title = "Description" prmpt_prompt = "File Description" prmpt_default = "" DIM SHARED ftype AS C ftype =alltrim(ui_get_text(prmpt_title,prmpt_prompt,prmpt_default)) 'Prompt for a filename and store result in a variable called 'fname'. 'Prompt for a filename and store result in a variable called 'fname'. dim prmpt_title as c dim prmpt_filter as c dim prmpt_default as c dim prmpt_flag as c prmpt_title = a5_eval_expression("=\"Choose File\"",local_variables()) prmpt_filter = "(*.*)" prmpt_default = "" DIM shared fname AS C fname =alltrim(ui_get_file( a5_eval_expression(prmpt_title,local_variables()),prmpt_filter,prmpt_default,"X")) dim dr as c dr=file.filename_parse(fname,"d") dim pth as c pth=file.filename_parse(fname,"p") dim fext as c fext=file.filename_parse(fname,"e") dim fn as c fn=file.filename_parse(fname,"ne") dim fupath as c fupath=chr(34)+dr+pth+fn+chr(34) dim encfu as c encfu=dr+pth+fn+".aes" 'if at(" ",fn) > 0 'file.rename(dr+pth+fn,strtran(dr+pth+fn," ","_")) 'end if if ftype ="" ui_msg_box("error","You Didn't Choose a File Description",UI_STOP_SYMBOL) end end if if fname="" ui_msg_box("error","You Didn't Choose a File",UI_STOP_SYMBOL) end end if sys_shell_wait(chr(34)+"c:\housing\aescrypt -e -p ************* "fupath) 'dim extn as c 'extn=Strtran(file.filename_parse(fname,"E"),".","") 'xbasic_wait_for_idle(2) 'dim st as c 'dim en as c 'st = "\\" ' 'en = " " dim upname as c upname=".aes" dim ftsend as c ftsend=ftype+fext+upname dim ftppath as c ftppath =alltrim("/srv/ftp/clientdocs/credit/"+clientid+chr(47)+ftype+fext+upname) cmd = <<%a% connect|****** onerror|error|Could not connect login|****|***** onerror|error|Could not log in mkdir|%a%"/srv/ftp/clientdocs/credit/" + clientid + crlf() + <<%a% onerror|quit quit %a% ftp_script_run_silent(cmd, .t.) xbasic_wait_for_idle(2) FTP_FILE_XFER("****","****","******",alltrim(encfu),alltrim(ftppath),"put",.F.,"File Uploading") 'Insert a new record into a remote SQL database. 'DIM a connection variable DIM cn as SQL::Connection dim flagResult as l flagResult = cn.open("::Name::pat") if flagResult = .f. then ui_msg_box("Error","Could not connect to database. Error reported was: " + crlf() + cn.CallResult.text) end end if 'Specify that we are using Portable SQL syntax cn.PortableSQLEnabled = .t. dim shared agent as c agent=user_name() 'Dim a SQL arguments object, create arguments and set their values DIM args as sql::arguments if a5_eval_valid_expression("=clientid",local_variables()) then args.add("idclientd",convert_type(a5_eval_expression("=clientid",local_variables()),"N")) end If if a5_eval_valid_expression("=ftsend",local_variables()) then args.add("doc_type",convert_type(a5_eval_expression("=ftsend",local_variables()),"C")) end If if a5_eval_valid_expression("=agent",local_variables()) then args.add("doc_who",convert_type(a5_eval_expression("=agent",local_variables()),"C")) end If dim sqlInsertStatement as c sqlInsertStatement = <<%txt% INSERT INTO cred_docs (idclientd, doc_type, doc_who) VALUES (:idclientd, :doc_type, :doc_who) %txt% dim flag as l flag = cn.Execute(sqlInsertStatement,args) if flag = .f. then ui_msg_box("Error","Record was not inserted. Error reported was: " + crlf(2) + cn.CallResult.text,UI_STOP_SYMBOL) else if cn.AffectedRows() = 1 then ui_msg_box("Notice","File Has Been Uploaded..",UI_INFORMATION_SYMBOL) else ui_msg_box("Error","File Has Not Been Uploaded." ,UI_STOP_SYMBOL) end if end if cn.close() xbasic_wait_for_idle(1) file.remove(dr+pth+fn) file.remove(dr+pth+fn+".aes") delete fname delete ftsend delete fupath delete pth delete fn delete dr
Leave a comment: