added LSL2 stored procedures
This commit is contained in:
151
LSL2/STPROC/COMPANY_SERVICES.txt
Normal file
151
LSL2/STPROC/COMPANY_SERVICES.txt
Normal file
@ -0,0 +1,151 @@
|
||||
Function Company_Services(@Service, @Params)
|
||||
/***********************************************************************************************************************
|
||||
|
||||
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 : Company_Services
|
||||
|
||||
Description : Handler program for all module related services.
|
||||
|
||||
Notes : The generic parameters should contain all the necessary information to process the services. Often
|
||||
this will be information like the data Record and Key ID.
|
||||
|
||||
Parameters :
|
||||
Service [in] -- Name of the service being requested
|
||||
Param1-10 [in/out] -- Additional request parameter holders
|
||||
Response [out] -- Response to be sent back to the Controller (MCP) or requesting procedure
|
||||
|
||||
Metadata :
|
||||
|
||||
History : (Date, Initials, Notes)
|
||||
08/13/17 dmb Original programmer. - [EPIOI-8]
|
||||
|
||||
***********************************************************************************************************************/
|
||||
|
||||
#pragma precomp SRP_PreCompiler
|
||||
|
||||
$insert APP_INSERTS
|
||||
$insert SERVICE_SETUP
|
||||
$insert COMPANY_EQUATES
|
||||
|
||||
Declare subroutine Error_Services, Company_Services, Memory_Services, RList, Database_Services, SRP_JSON
|
||||
Declare function SRP_Array, Company_Services, Memory_Services, Database_Services, SRP_Sort_Array, SRP_JSON
|
||||
|
||||
GoToService else
|
||||
Error_Services('Set', Service : ' is not a valid service request within the ' : ServiceModule : ' services module.')
|
||||
end
|
||||
|
||||
Return Response else ''
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Services
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//----------------------------------------------------------------------------------------------------------------------
|
||||
// GetCompany
|
||||
//
|
||||
// Returns a JSON formatted object of information related to the indicated company number.
|
||||
//----------------------------------------------------------------------------------------------------------------------
|
||||
Service GetCompany(CompanyNo)
|
||||
SRP_Stopwatch('Start', Service)
|
||||
ServiceKeyID := '*' : CompanyNo
|
||||
Company = ''
|
||||
|
||||
If Memory_Services('IsValueCurrent', ServiceKeyID, 3600, True$) then
|
||||
Company = Memory_Services('GetValue', ServiceKeyID)
|
||||
end else
|
||||
If CompanyNo NE '' then
|
||||
CompanyRow = Database_Services('ReadDataRow', 'COMPANY', CompanyNo, True$, 3600)
|
||||
If SRP_JSON(objCompany, 'NEW', 'OBJECT') then
|
||||
SRP_JSON(objCompany, 'SETVALUE', 'CompanyNumber', CompanyNo, 'STRING')
|
||||
SRP_JSON(objCompany, 'SETVALUE', 'Name', CompanyRow<COMPANY_CO_NAME$>, 'STRING')
|
||||
NameAbbreviated = CompanyRow<COMPANY_ABBREV$>
|
||||
SRP_JSON(objCompany, 'SETVALUE', 'NameAbbreviated', NameAbbreviated, 'STRING')
|
||||
Begin Case
|
||||
Case NameAbbreviated _EQC 'International Rectifier' ; NameShort = 'IR'
|
||||
Case NameAbbreviated _EQC 'IRNewport' ; NameShort = 'Newport'
|
||||
Case NameAbbreviated _EQC 'IFX (Kulim)' ; NameShort = 'Kulim'
|
||||
Case NameAbbreviated _EQC 'IFX Austria AG' ; NameShort = 'Austria'
|
||||
Case NameAbbreviated _EQC 'Tower Semiconductor' ; NameShort = 'Tower'
|
||||
Case Otherwise$ ; NameShort = NameAbbreviated
|
||||
End Case
|
||||
SRP_JSON(objCompany, 'SETVALUE', 'NameShort', NameShort, 'STRING')
|
||||
Company = SRP_JSON(objCompany, 'STRINGIFY', 'FAST')
|
||||
Memory_Services('SetValue', ServiceKeyID, Company)
|
||||
SRP_JSON(objCompany, 'RELEASE')
|
||||
end else
|
||||
Error_Services('Add', 'Error creating objCompany in the ' : Service : ' service.')
|
||||
end
|
||||
end else
|
||||
Error_Services('Add', 'Company argument was missing from the ' : Service : ' service.')
|
||||
end
|
||||
end
|
||||
|
||||
Response = Company
|
||||
SRP_Stopwatch('Stop', Service)
|
||||
end service
|
||||
|
||||
//----------------------------------------------------------------------------------------------------------------------
|
||||
// GetFTPServer
|
||||
//
|
||||
// Returns a multivalued list of all server connection settings specific for the company
|
||||
// 1. Server Address
|
||||
// 2. Username
|
||||
// 3. Password
|
||||
// 4. Company Remote Directory
|
||||
// 5. Company Local Directory
|
||||
//----------------------------------------------------------------------------------------------------------------------
|
||||
Service GetFTPServer(CompanyNo)
|
||||
|
||||
If CompanyNo NE '' then
|
||||
CompanyRec = Database_Services('ReadDataRow', 'COMPANY', CompanyNo)
|
||||
FTPServer = CompanyRec<COMPANY_FTP_SERVER$>
|
||||
LocalDirectory = CompanyRec<COMPANY_SHIP_DATA_DIR$>
|
||||
Swap '\' with @FM in LocalDirectory
|
||||
LocalDirectory = LocalDirectory<DCOUNT(LocalDirectory, @FM)>;//Take only the last part, this is for backwards compatability
|
||||
RemoteDirectory = CompanyRec<COMPANY_FTP_DIRECTORY$>
|
||||
Username = ''
|
||||
Password = ''
|
||||
SSH = 0
|
||||
IF FTPServer NE '' then
|
||||
IF FTPServer EQ 'sFTPNA.extra.infineon.com' then
|
||||
Username = 'DNAMesaFI-FTP'
|
||||
Password = 'OpenInsight2018....!'
|
||||
SSH = 1
|
||||
end
|
||||
IF FTPServer EQ '10.72.176.48' then
|
||||
Username = 'Infineon\TEMFTPEPIMesa'
|
||||
Password = 'fW&EHJhKWg!skUKV4_34'
|
||||
SSH = 0
|
||||
end
|
||||
If LocalDirectory NE '' then
|
||||
If RemoteDirectory EQ '' then
|
||||
Error_Services('Add', 'Company Record does not contain a defined Local directory ' : Service)
|
||||
end
|
||||
end else
|
||||
Error_Services('Add', 'Company Record does not contain a defined Local directory ' : Service)
|
||||
end
|
||||
end else
|
||||
Error_Services('Add', 'Company Record does not contain a defined FTP server. ' : Service)
|
||||
end
|
||||
|
||||
|
||||
end else
|
||||
Error_Services('Add', 'Invalid or no COMPANY record passed to the ':Service:' service.')
|
||||
end
|
||||
|
||||
FTPSettings = ''
|
||||
FTPSettings<1> = FTPServer
|
||||
FTPSettings<2> = Username
|
||||
FTPSettings<3> = Password
|
||||
FTPSettings<4> = LocalDirectory
|
||||
FTPSettings<5> = RemoteDirectory
|
||||
FTPSettings<6> = SSH
|
||||
|
||||
Response = FTPSettings
|
||||
end service
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Internal GoSubs
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
Reference in New Issue
Block a user