Dim $MARKETLOGS = @MyDocumentsDir & "\EVE\logs\Marketlogs"
Func GetMyOrders($ImportFile)
;в качестве параметра передается имя файла который будем обрабатывать
Local $File, $i, $n, $line, $check, $temp, $Captions, $Data, $FieldCount, $TimeStamp
If StringLeft($ImportFile, 9) = "My orders" Then
$File = FileOpen($MARKETLOGS & "\" & $ImportFile)
;Возьмем из имени файла время когда были импортированы ордера----------
$i = StringLen($ImportFile)-19
$n = StringLen($ImportFile)-4
$temp = StringMid($ImportFile, $i+1, $n-$i)
$TimeStamp = StringLeft($temp, 4) & "-" & StringMid($temp, 6, 2) & "-" & StringMid($temp, 9, 2) & " " & StringMid($temp, 12, 2) & ":" & StringRight($temp, 2)
;----------------------------------------------------------------------
$i=0
$n=0
$check=0
While 1
$i = $i + 1
$line = FileReadLine($File, $i) ;считываем строку из файла
If @error = -1 Then ExitLoop
If $i = 1 Then
;проверка наличия необходимых заголовков в файле----------
If Not (StringRegExp($line, "orderID", 0) And StringRegExp($line, "typeID", 0) And StringRegExp($line, "charID", 0) And StringRegExp($line, "charName", 0) And StringRegExp($line, "regionID", 0) And StringRegExp($line, "regionName", 0) And StringRegExp($line, "stationID", 0) And StringRegExp($line, "stationName", 0) And StringRegExp($line, "range", 0) And StringRegExp($line, "bid", 0) And StringRegExp($line, "price", 0) And StringRegExp($line, "volEntered", 0) And StringRegExp($line, "volRemaining", 0) And StringRegExp($line, "issued", 0) And StringRegExp($line, "orderState", 0) And StringRegExp($line, "minVolume", 0) And StringRegExp($line, "contraband", 0) And StringRegExp($line, "accountID", 0) And StringRegExp($line, "duration", 0) And StringRegExp($line, "isCorp", 0) And StringRegExp($line, "solarSystemID", 0) And StringRegExp($line, "solarSystemName", 0) And StringRegExp($line, "escrow", 0)) Then ExitLoop
;---------------------------------------------------------
$Captions = StringRegExp($line, '(.*?),', 3)
;контроль количества полей---------------------------
$FieldCount = UBound($Captions)
If Not $FieldCount = 23 Then ExitLoop
;----------------------------------------------------
;очистка таблицы ордеров перед новым заполнением
ClearTableDatabase("MyOrders")
$temp = ""
EndIf
If $i>1 Then
$Data = StringRegExp($line, '(.*?),', 3)
If UBound($Data) = $FieldCount Then
If $temp = "" Then $temp = "INSERT INTO MyOrders(orderID, typeID, charID, charName, regionID, regionName, stationID, stationName, range, bid, price, volEntered, volRemaining, issued, orderState, minVolume, contraband, accountID, duration, isCorp, solarSystemID, solarSystemName, escrow, TimeStamp) VALUES (" & "'" & $Data[0] & "'"
For $n = 0 To $FieldCount-1
;создаем строку для занесения данных в базу
If StringInStr("typeID,charID,charName,regionID,regionName,stationID,stationName,range,bid,price,volEntered,volRemaining,issued,orderState,minVolume,contraband,accountID,duration,isCorp,solarSystemID,solarSystemName,escrow", $Captions[$n]) Then $temp = $temp & ", '" & $Data[$n] & "'"
Next
;завершаем строку
$temp = $temp & ", '" & $TimeStamp & "');"
;выполняем запрос на добавление данных
InitDatabase()
_SQLite_Exec (-1, $temp)
CloseDatabase()
$temp = ""
EndIf
EndIf
$check=1
Wend
FileClose($File)
EndIf
EndFunc