TAKE FROM FTP1 — различия между версиями
Материал из Фабиус wiki
Hisava (обсуждение | вклад) м (→Использование) |
Hisava (обсуждение | вклад) м (→Текст) |
||
Строка 8: | Строка 8: | ||
try | try | ||
− | WaitMsg( 'Удаление', msg ) | + | [[WaitMsg]]( 'Удаление', msg ) |
− | temp_path := Nice_Path( ExpandUNCFileName( TempPath ) ) | + | temp_path := [[Nice_Path]]( [[ExpandUNCFileName]]( TempPath ) ) |
− | aaa := Directory( temp_path + '*', "D" ) | + | aaa := [[Directory]]( temp_path + '*', "D" ) |
− | for ii := 1 to len( aaa ) | + | for ii := 1 to [[len]]( aaa ) |
− | if val( aaa[ii,1] ) > 0 | + | if [[val]]( aaa[ii,1] ) > 0 |
− | r20_kod := val( aaa[ii,1] ) | + | r20_kod := [[val]]( aaa[ii,1] ) |
− | r20_kod := SeekRef( 'R603', r20_kod, ' | + | r20_kod := [[SeekRef]]( '[[R603]]', r20_kod, '[[R20]]_KOD', 1 ) |
− | if Empty( r20_kod ) | + | if [[Empty]]( r20_kod ) |
loop | loop | ||
endif | endif | ||
folder := temp_path + aaa[ii,1] | folder := temp_path + aaa[ii,1] | ||
− | file_name := Directory( folder + '\*rep*', "A" ) | + | file_name := [[Directory]]( folder + '\*rep*', "A" ) |
− | if Empty( file_name ) | + | if [[Empty]]( file_name ) |
loop | loop | ||
endif | endif | ||
file_name := file_name[1,1] | file_name := file_name[1,1] | ||
− | path := Nice_Path( folder ) | + | path := [[Nice_Path]]( folder ) |
file_name := path + file_name | file_name := path + file_name | ||
fld := ' _0,C,200; _1,D,4; _2,C,20; ' | fld := ' _0,C,200; _1,D,4; _2,C,20; ' | ||
try | try | ||
− | WaitMsg( 'Обработка данных' + file_name, msg ) | + | [[WaitMsg]]( 'Обработка данных' + file_name, msg ) |
− | _ := CreateTmpFile( fld, '_', ~IsFreeDel := true ) | + | _ := [[CreateTmpFile]]( fld, '_', ~IsFreeDel := true ) |
− | file_frontol := AssignFile( file_name ) | + | file_frontol := [[AssignFile]]( file_name ) |
− | if Empty( file_frontol ) | + | if [[Empty]]( file_frontol ) |
loop | loop | ||
endif | endif | ||
− | TextReset( file_frontol ) | + | [[TextReset]]( file_frontol ) |
− | aa := ReadLn( file_frontol ) | + | aa := [[ReadLn]]( file_frontol ) |
// заполнение временной таблицы | // заполнение временной таблицы | ||
− | while !TextEof( file_frontol ) | + | while ![[TextEof]]( file_frontol ) |
− | aa := ReadLn( file_frontol ) | + | aa := [[ReadLn]]( file_frontol ) |
− | WaitMsg( Left( aa, 16 ), msg ) | + | [[WaitMsg]]( [[Left]]( aa, 16 ), msg ) |
− | if len( aa ) > 10 | + | if [[len]]( aa ) > 10 |
− | ( _ )->( DbAppend() ) | + | ( _ )->( [[DbAppend]]() ) |
( _ )->_0 := aa | ( _ )->_0 := aa | ||
− | ( _ )->_1 := CtoD( Token( aa, 2 ) ) | + | ( _ )->_1 := [[CtoD]]( [[Token]]( aa, 2 ) ) |
− | ( _ )->_2 := Right( file_name, 20 ) | + | ( _ )->_2 := [[Right]]( file_name, 20 ) |
endif | endif | ||
end | end | ||
− | sql := [ Select DISTINCT _1 From ] + TmpFilePath( _ ) | + | sql := [ Select DISTINCT _1 From ] + [[TmpFilePath]]( _ ) |
− | aa := SqlToArr( sql, { '_1' } ) | + | aa := [[SqlToArr]]( sql, { '_1' } ) |
− | aa := PrepareArr( aa ) | + | aa := [[PrepareArr]]( aa ) |
− | for i := 1 to len( aa ) | + | for i := 1 to [[len]]( aa ) |
data := aa[i] | data := aa[i] | ||
− | WaitMsg( 'Удаление ранее загруженных данных за ' + aa[i], msg ) | + | [[WaitMsg]]( 'Удаление ранее загруженных данных за ' + aa[i], msg ) |
− | if !Is_File( 'DOCP', data ) | + | if ![[Is_File]]( '[[DOCP]]', data ) |
− | OpenFData( 'DOCP' + Ret_f_ext( data ), 'DOCP', false, OpdataPath, 'DOCP' ) | + | [[OpenFData]]( '[[DOCP]]' + [[Ret_f_ext]]( data ), '[[DOCP]]', false, OpdataPath, '[[DOCP]]' ) |
endif | endif | ||
// FTL | // FTL | ||
− | sql := [ Delete From DOCP] + Ret_f_ext( data ) + [ Where KINDDOC = 'FTL' and DATDOC = '] + SQlDate( data ) + [' and ; | + | sql := [ Delete From [[DOCP]]] + [[Ret_f_ext]]( data ) + [ Where KINDDOC = '[[FTL]]' and DATDOC = '] + [[SQlDate]]( data ) + [' and ; |
DREFL1 = '[[R20]] ' and DANAL1 = ] + r20_kod + [ and 'SYSTEM.' = 'SYSTEM.' ] | DREFL1 = '[[R20]] ' and DANAL1 = ] + r20_kod + [ and 'SYSTEM.' = 'SYSTEM.' ] | ||
SimpleSql( sql, OpdataPath ) | SimpleSql( sql, OpdataPath ) |
Версия 12:56, 4 мая 2017
TAKE_FROM_FTP1 - это программа из справочника R266
Удалить FTL и FRO
TAKE_FROM_FTP1()
Использование
Текст
local temp_path, aaa, ii, r20_kod, folder, file_name, path, fld, msg, _, file_frontol, aa, sql, data, i try WaitMsg( 'Удаление', msg ) temp_path := Nice_Path( ExpandUNCFileName( TempPath ) ) aaa := Directory( temp_path + '*', "D" ) for ii := 1 to len( aaa ) if val( aaa[ii,1] ) > 0 r20_kod := val( aaa[ii,1] ) r20_kod := SeekRef( 'R603', r20_kod, 'R20_KOD', 1 ) if Empty( r20_kod ) loop endif folder := temp_path + aaa[ii,1] file_name := Directory( folder + '\*rep*', "A" ) if Empty( file_name ) loop endif file_name := file_name[1,1] path := Nice_Path( folder ) file_name := path + file_name fld := ' _0,C,200; _1,D,4; _2,C,20; ' try WaitMsg( 'Обработка данных' + file_name, msg ) _ := CreateTmpFile( fld, '_', ~IsFreeDel := true ) file_frontol := AssignFile( file_name ) if Empty( file_frontol ) loop endif TextReset( file_frontol ) aa := ReadLn( file_frontol ) // заполнение временной таблицы while !TextEof( file_frontol ) aa := ReadLn( file_frontol ) WaitMsg( Left( aa, 16 ), msg ) if len( aa ) > 10 ( _ )->( DbAppend() ) ( _ )->_0 := aa ( _ )->_1 := CtoD( Token( aa, 2 ) ) ( _ )->_2 := Right( file_name, 20 ) endif end sql := [ Select DISTINCT _1 From ] + TmpFilePath( _ ) aa := SqlToArr( sql, { '_1' } ) aa := PrepareArr( aa ) for i := 1 to len( aa ) data := aa[i] WaitMsg( 'Удаление ранее загруженных данных за ' + aa[i], msg ) if !Is_File( 'DOCP', data ) OpenFData( 'DOCP' + Ret_f_ext( data ), 'DOCP', false, OpdataPath, 'DOCP' ) endif // FTL sql := [ Delete From DOCP] + Ret_f_ext( data ) + [ Where KINDDOC = 'FTL' and DATDOC = '] + SQlDate( data ) + [' and ; DREFL1 = 'R20 ' and DANAL1 = ] + r20_kod + [ and 'SYSTEM.' = 'SYSTEM.' ] SimpleSql( sql, OpdataPath ) // FRO sql := [ Delete From DOCP] + Ret_f_ext( data ) + [ Where KINDDOC = 'FRO' and DATDOC = '] + SQlDate( data ) + [' and ; KREFL1 = 'R20 ' and KANAL1 = ] + r20_kod + [ and 'SYSTEM.' = 'SYSTEM.' ] SimpleSql( sql, OpdataPath ) next finally if !Empty( file_frontol ) CloseFile( file_frontol ) endif CloseTable( _ ) HideMsg( msg ) end endif next finally HideMsg( msg ) end // _0 - текст из файла ( одна строка ) // _1 - дата // _2 - путь к файлу