This commit is contained in:
Алексей Заблоцкий 2023-11-16 22:22:59 +03:00
parent 6488e9c8b4
commit ae186d4934
7 changed files with 88 additions and 19 deletions

View File

@ -55,6 +55,8 @@ begin
self.Logger.AppendContent:=true;
self.Logger.LogType := ltFile;
self.Logger.FileName := format('%s/server.log',[extractfilepath(paramstr(0))]);
{$ELSE}
self.Logger.LogType := ltSystem;
{$ENDIF}
self.logger.Identification:='LMS-Report-Service';
self.Logger.Active:=true;

View File

@ -64,6 +64,7 @@ end;
procedure TReportCommand.SetStage(ALevel: TLogLevel; Sender: TObject;
stageName: string);
begin
log(mtInfo,stageName);
fcurrentStage:=format('выполняется (%s)',[stageName]);
end;
@ -245,6 +246,8 @@ begin
end;
fResult := TCommandData.Create(0,fileData.size,ReportTitle+'.pdf',['type=application/pdf'],[],fileData);
fileData.Seek(0,soFromBeginning);
(fileData as TMemoryStream).SaveToFile(Extractfilepath(paramstr(0))+'out/report.pdf');
fileData.Seek(0,soFromBeginning);
result := true;
finally
fileData.Free;

View File

@ -185,6 +185,7 @@ var
i: integer;
con: TBaseConnection;
begin
log(mtDebug,self,'ClearTerminated');
for i := conlist.Count-1 downto 0 do
begin
con := TBaseConnection(conlist[i]);
@ -224,6 +225,7 @@ begin
setLength(iValues,0);
if ACommand='stop' then
begin
log(mtDebug,self,'stop');
ClearConnections;
Input.Terminate;
fRunning:=false;
@ -354,9 +356,11 @@ begin
begin
if cmd.Status=StatusComplete then
begin
log(mtDebug,self,'result ready');
cmd.Results.AssignTo(Code,RetValue,Answer,rValues,iValues,ByteData);
cmd.Done;
result := true;
log(mtDebug,self,'result ready ok ');
end
else
begin

View File

@ -443,6 +443,7 @@ procedure TCommandData.AssignTo(out ACode: DWORD; out AParam: QWord; out
var
i: integer;
begin
ACode := Code;
AParam := Param;
AName := Name;

View File

@ -14,8 +14,9 @@
<UseAppBundle Value="False"/>
<ResourceType Value="res"/>
</General>
<MacroValues Count="1">
<MacroValues Count="2">
<Macro1 Name="LCLWidgetType" Value="nogui"/>
<Macro4 Name="LCLWidgetType" Value="gtk2"/>
</MacroValues>
<BuildModes>
<Item Name="Default" Default="True"/>
@ -48,10 +49,11 @@
</Linking>
</CompilerOptions>
</Item>
<SharedMatrixOptions Count="3">
<SharedMatrixOptions Count="4">
<Item1 ID="700255898348" Modes="Default" Type="IDEMacro" MacroName="LCLWidgetType" Value="nogui"/>
<Item2 ID="180994852241" Type="IDEMacro" MacroName="LCLWidgetType" Value="nogui"/>
<Item3 ID="177903334474" Modes="Release" Type="IDEMacro" MacroName="LCLWidgetType" Value="nogui"/>
<Item4 ID="292602196485" Modes="Default" Type="IDEMacro" MacroName="LCLWidgetType" Value="gtk2"/>
</SharedMatrixOptions>
</BuildModes>
<PublishOptions>
@ -147,7 +149,9 @@
<Unit>
<Filename Value="reportdmunit.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="ReportDM"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="DataModule"/>
<UnitName Value="reportDMUnit"/>
</Unit>
<Unit>

View File

@ -5,7 +5,7 @@ object ReportDM: TReportDM
VerticalOffset = 317
Width = 330
object frxReport: TfrxReport
Version = '2023.1'
Version = '2023.3.3'
DotMatrixReport = False
EngineOptions.SilentMode = True
EngineOptions.NewSilentMode = simSilent
@ -22,6 +22,7 @@ object ReportDM: TReportDM
''
'end.'
)
OnEndDoc = frxReportEndDoc
OnLoadTemplate = frxReportLoadTemplate
OnLoadDetailTemplate = frxReportLoadDetailTemplate
Left = 176
@ -31,10 +32,12 @@ object ReportDM: TReportDM
Style = <>
end
object frxPDFExport1: TfrxPDFExport
ExportNotPrintable = True
UseFileCache = True
ShowProgress = True
OverwritePrompt = False
DataOnly = False
EmbeddedFonts = True
EmbedFontsIfProtected = False
InteractiveFormsFontSubset = 'A-Z,a-z,0-9,#43-#47 '
OpenAfterExport = False
@ -97,4 +100,41 @@ object ReportDM: TReportDM
Left = 186
Top = 155
end
object frxHTMLExport1: TfrxHTMLExport
UseFileCache = True
ShowProgress = True
OverwritePrompt = False
DataOnly = False
OpenAfterExport = False
FixedWidth = True
Background = False
Centered = False
EmptyLines = True
Print = False
PictureType = gpPNG
Outline = False
Left = 252
Top = 27
end
object frxHTML4DivExport1: TfrxHTML4DivExport
UseFileCache = True
ShowProgress = True
OverwritePrompt = False
DataOnly = False
OpenAfterExport = False
MultiPage = False
Formatted = False
PictureFormat = pfPNG
UnifiedPictures = True
Navigation = False
EmbeddedPictures = False
EmbeddedCSS = False
Outline = False
HTML5 = False
AllPictures = False
ExportAnchors = True
PictureTag = 0
Left = 255
Top = 75
end
end

View File

@ -5,11 +5,12 @@ unit reportDMUnit;
interface
uses
Classes, SysUtils, frxClass, frxExportPDF, frxExportODF,
xpMemParamManagerUnit, AbUnzper, AbZipper, frxDBSet, cgiDM,extTypes;
Classes, SysUtils, frxClass, frxExportPDF, frxExportODF, frxExportHTML,
frxExportHTMLDiv, xpMemParamManagerUnit, AbUnzper, AbZipper, frxDBSet, cgiDM,
extTypes;
type
TExportFileType = (ftPDF,ftRTF,ftXLS);//(ftPDF,ftMail,ftRTF,ftXLS,ftHTML);
TExportFileType = (ftPDF,ftRTF,ftXLS,ftHTML);//(ftPDF,ftMail,ftRTF,ftXLS,ftHTML);
{ TReportDM }
TReportQuery=class;
@ -40,10 +41,13 @@ type
TReportDM = class(TDataModule)
AbUnZipper1: TAbUnZipper;
AbZipper1: TAbZipper;
frxHTML4DivExport1: TfrxHTML4DivExport;
frxHTMLExport1: TfrxHTMLExport;
frxODSExport1: TfrxODSExport;
frxODTExport1: TfrxODTExport;
frxPDFExport1: TfrxPDFExport;
frxReport: TfrxReport;
procedure frxReportEndDoc(Sender: TObject);
function frxReportLoadDetailTemplate(Report: TfrxReport;
const TemplateName: String; const AHyperlink: TfrxHyperlink): Boolean;
procedure frxReportLoadTemplate(Report: TfrxReport;
@ -83,6 +87,7 @@ type
function LoadReportTemplate(OnHash: TCalcHashProc): string;
procedure SaveReportTemplate(hash: string;OnHash: TCalcHashProc);
procedure CopyReportVariables(AVariables, AParam: TxpMemParamManager);
procedure LogExport(Sender: TObject);
public
RecordID: integer;
NidbData: TNIDBDM;
@ -187,6 +192,11 @@ begin
NidbData.log(mtDebug,self,'LoadDetailTemplate '+TemplateName);
end;
procedure TReportDM.frxReportEndDoc(Sender: TObject);
begin
NidbData.log(mtDebug,Sender,'TReportDM.frxReportEndDoc');;
end;
procedure TReportDM.CreateDBDataSet(Query: TReportQuery; EditReport: Boolean);
var
i: integer;
@ -354,13 +364,8 @@ procedure TReportDM.frxReportPreview(Sender: TObject);
var
Report: TfrxReport;
begin
inherited;
try
Report := Sender as TfrxReport;
Report.PreviewForm.BringToFront;
except on e: Exception do
NidbData.log(mtError,self,e.message);
end;
NidbData.log(mtDebug,Sender,'TReportDM.frxReportPreview');;
inherited;
end;
procedure TReportDM.LoadQueries;
@ -652,6 +657,11 @@ begin
end;
procedure TReportDM.LogExport(Sender: TObject);
begin
NidbData.log(mtDebug,Sender,'export-started');
end;
procedure TReportDM.ExportReport(ExportType: TExportFileType; Data: TStream;
@ -696,7 +706,7 @@ begin
try
frxReport.PrepareReport(False);
frxReport.OnPreview := @frxReportPreview;
frxReport.SaveToFile(Extractfilepath(paramstr(0))+'out/report.fr3');
except on e: Exception do
begin
NidbData.logError(self,e,'frxReport.PrepareReport');
@ -705,10 +715,14 @@ begin
end;
case ExportType of
ftPDF: flt := TfrxPDFExport.Create(self);
ftRTF: flt := TfrxODTExport.Create(self);
ftXLS: flt := TfrxODSExport.Create(self);
ftPDF: flt := frxPDFExport1;
ftRTF: flt := frxODTExport1;
ftXLS: flt := frxODSExport1;
ftHTML: flt := frxHTML4DivExport1;
end;
flt.OnBeforeExport:=@LogExport;
flt.OnBeginExport:=@LogExport;
try
if assigned(OnStage) then
OnStage(mtExtra,self,'выгрузка');
@ -718,7 +732,8 @@ begin
flt.FileName:='';
flt.ShowProgress := false;
try
frxReport.Export(flt);
if not frxReport.Export(flt) then
NidbData.log(mtWarning,self,'ERROR EXPORT PDF');
except on e: Exception do
begin
@ -727,7 +742,7 @@ begin
end;
end;
finally
flt.Free;
//flt.Free;
end;
end;
//FreeContainer;