#------------------------------------------ # Start of user-changeable variables #------------------------------------------ # # Define the client ID and name # CLIENTID=__CLIENTID__ NAME=__NAME__ # # Define the database connection info # DBUSER=__DBUSER__ DBPASS=__DBPASS__ DBHOST=__DBHOST__ DBNAME=C_${NAME} DBLOGIN=-u${DBUSER} -p${DBPASS} -h${DBHOST} ${DBNAME} TABLES=file sale license_income artist_contract_license_income license_income_type RPSMISC=/app/tools/rps/bin/misc STYLEHOME=/app/tools/support/lib/Support/DataImport/StyleTemplates DATE=__TIMESTAMP__ # # The name of the template containing licensing income lines. XXX NO SPACES XXX # INPUTFILE="__INPUTFILE__" # Name of license file that the transactions are a part of. XXX NO SPACES XXX # This is the filename that appears in RPS. The first time you import a license income # template, this will be the same as the input file. If there are exceptions, the # exceptions file will have a different filename, but by keeping the same LICENSEFILE you # can import additional license income sales to the same file. # Important: LICENSEFILE, if it already exists in RPS, must be a license income file. # Also, LICENSEFILE will be created if it does not exist. # LICENSEFILE="__LICENSEFILE__" #--------------------------------- # # End of user-changeable variables # #--------------------------------- BASENAME = $(basename ${LICENSEFILE}) LOWER_NAME=$(shell echo ${NAME} | tr A-Z a-z) DUMPFILE=bk_before_${LOWER_NAME}.sql TDTOXL=${RPSMISC}/tdtoxl_v2 STYLE=${STYLEHOME}/license_income_template_exceptions.fmt # PROG=${RPSMISC}/run_import.pl IMPORT_ARGS=__IMPORTID__ POSTIMPORT=${RPSMISC}/post_import.pl POST_ARGS=__POSTARGS__ # LOG_RO=debug_ro.txt LOG=debug.txt REPORT=${BASENAME}__import_${DATE}.txt EXCEPTIONS=${BASENAME}__exceptions_${DATE}.txt EXCEPTIONS_EXCEL=${BASENAME}__exceptions_${DATE}.xls # remove all quotes and re-add leading/trailing quotes REPORT := $(subst $\",,$(REPORT)) REPORT := $\"$(REPORT)$\" EXCEPTIONS := $(subst $\",,$(EXCEPTIONS)) EXCEPTIONS := $\"$(EXCEPTIONS)$\" EXCEPTIONS_EXCEL := $(subst $\",,$(EXCEPTIONS_EXCEL)) EXCEPTIONS_EXCEL := $\"$(EXCEPTIONS_EXCEL)$\" # default: $(warning $(DBUSER)) @echo "make backup|test|import" clean: rm -f ${LOG} ${REPORT} ${DUMPFILE} backup: # mysqldump ${DBLOGIN} ${TABLES} > ${DUMPFILE} # grep -i "create table" ${DUMPFILE} restore: mysql ${DBLOGIN} < ${DUMPFILE} test: perl ${PROG} -c ${CLIENTID} -f ${INPUTFILE} -l ${LICENSEFILE} ${IMPORT_ARGS} > ${LOG_RO} import: nice perl ${PROG} -c ${CLIENTID} -f ${INPUTFILE} -l ${LICENSEFILE} -e ${IMPORT_ARGS} > ${LOG} # grep "^STATUS" ${LOG} | sed "s/^STATUS:\t//" > ${REPORT} # grep "^STATUS" ${LOG} | head -1 | sed "s/^STATUS:\t//" > ${EXCEPTIONS} grep "^STATUS" ${LOG} | grep -e "__FAIL__" | grep -v "contract\-name" | sed "s/^STATUS:\t//" >> ${EXCEPTIONS} cat ${EXCEPTIONS} | ${TDTOXL} -o ${EXCEPTIONS_EXCEL} -s ${STYLE} #zip ${EXCEPTIONS_EXCEL}.zip ${EXCEPTIONS_EXCEL} nice perl ${POSTIMPORT} -c ${CLIENTID} -f ${EXCEPTIONS_EXCEL} -l ${LOG} ${POST_ARGS} find . -type f -not -name ${EXCEPTIONS_EXCEL} -exec gzip {} \;