2018-08-01 Fred Gleason <fredg@paravelsystems.com>

* Modified as-played reports to work correctly with UTF-8 strings.
This commit is contained in:
Fred Gleason 2018-08-01 14:28:32 -04:00
parent 949b3f903c
commit 4e125e2de7
15 changed files with 436 additions and 440 deletions

View File

@ -17291,3 +17291,5 @@
* Refactored 'RDMacro' to handle UTF-8 strings correctly.
2018-07-31 Fred Gleason <fredg@paravelsystems.com>
* Modified logging in caed(8) to use 'RDConfig::log()' method.
2018-08-01 Fred Gleason <fredg@paravelsystems.com>
* Modified as-played reports to work correctly with UTF-8 strings.

View File

@ -20,6 +20,9 @@
#include <stdio.h>
#include <qfile.h>
#include <qtextstream.h>
#include <rdcart.h>
#include <rddb.h>
#include <rddatedecode.h>
@ -31,7 +34,6 @@ bool RDReport::ExportBmiEmr(const QString &filename,const QDate &startdate,
{
QString sql;
RDSqlQuery *q;
FILE *f;
int records=0;
QDateTime current_datetime=
QDateTime(QDate::currentDate(),QTime::currentTime());
@ -39,6 +41,15 @@ bool RDReport::ExportBmiEmr(const QString &filename,const QDate &startdate,
QString usage_code;
QString station_format=stationFormat();
QFile *file=new QFile(filename);
if(!file->open(IO_WriteOnly|IO_Truncate)) {
report_error_code=RDReport::ErrorCantOpen;
delete file;
return false;
}
QTextStream *strm=new QTextStream(file);
strm->setEncoding(QTextStream::UnicodeUTF8);
//
// Station Type
//
@ -56,10 +67,6 @@ bool RDReport::ExportBmiEmr(const QString &filename,const QDate &startdate,
break;
}
if((f=fopen((const char *)filename,"wb"))==NULL) {
report_error_code=RDReport::ErrorCantOpen;
return false;
}
sql=QString("select ")+
"EVENT_DATETIME,"+ // 00
"TITLE,"+ // 01
@ -76,9 +83,9 @@ bool RDReport::ExportBmiEmr(const QString &filename,const QDate &startdate,
//
// Write HEDR Record
//
fprintf(f,"HEDRSTA%-25s%22sFMDT \x0d\x0a",
(const char *)stationId().utf8(),
(const char *)current_datetime.toString("yyyyMMddhhmmssyyyyMMdd"));
*strm << QString("HEDRSTA")+LeftJustify(stationId(),25)+
LeftJustify(current_datetime.toString("yyyyMMddhhmmssyyyyMMdd"),22)+
"FMDT \x0d\x0a";
records++;
//
@ -86,48 +93,47 @@ bool RDReport::ExportBmiEmr(const QString &filename,const QDate &startdate,
//
while(q->next()) {
switch((RDCart::UsageCode)q->value(6).toInt()) {
case RDCart::UsageFeature:
usage_code="F1";
break;
case RDCart::UsageFeature:
usage_code="F1";
break;
case RDCart::UsageOpen:
usage_code="TO";
break;
case RDCart::UsageOpen:
usage_code="TO";
break;
case RDCart::UsageClose:
usage_code="TC";
break;
case RDCart::UsageClose:
usage_code="TC";
break;
case RDCart::UsageTheme:
usage_code="TT";
break;
case RDCart::UsageTheme:
usage_code="TT";
break;
case RDCart::UsageBackground:
usage_code="B ";
break;
case RDCart::UsageBackground:
usage_code="B ";
break;
case RDCart::UsagePromo:
usage_code="JP";
break;
case RDCart::UsagePromo:
usage_code="JP";
break;
default:
usage_code="F1";
break;
default:
usage_code="F1";
break;
}
fprintf(f,"FMDT%-40s%2s%-25s%6s01%14s000000001%-40s%-40s%-40s%8s %12s%2s \x0d\x0a",
(const char *)stationId().utf8(),
(const char *)type_code.utf8(),
(const char *)station_format.utf8(),
(const char *)startdate.toString("yyyyMM"),
(const char *)q->value(0).toDateTime().
toString("yyyyMMddhh:mm:ss"),
(const char *)q->value(1).toString().utf8(),
(const char *)q->value(2).toString().utf8(),
(const char *)q->value(3).toString().utf8(),
(const char *)QTime().addMSecs(q->value(4).toInt()).
toString("hh:mm:ss"),
(const char *)q->value(5).toString().utf8(),
(const char *)usage_code.utf8());
*strm << QString("FMDT")+
LeftJustify(stationId(),40)+
type_code+
LeftJustify(station_format,25)+
startdate.toString("yyyyMM")+"01"+
LeftJustify(q->value(0).toDateTime().toString("yyyyMMddhh:mm:ss"),16)+
"000000001"+
LeftJustify(q->value(1).toString(),40)+
LeftJustify(q->value(2).toString(),40)+
LeftJustify(q->value(3).toString(),40)+
QTime().addMSecs(q->value(4).toInt()).toString("hh:mm:ss")+" "+
RightJustify(q->value(5).toString(),12)+
usage_code+" \x0d\x0a";
records++;
}
delete q;
@ -135,9 +141,11 @@ bool RDReport::ExportBmiEmr(const QString &filename,const QDate &startdate,
//
// Write TRLR Record
//
fprintf(f,"TRLR%012d \x0d\x0a",++records);
*strm << QString("TRLR")+
QString().sprintf("%012d \x0d\x0a",++records);
fclose(f);
delete strm;
delete file;
report_error_code=RDReport::ErrorOk;
return true;
}

View File

@ -2,7 +2,7 @@
//
// Export a Rivendell Cut Report.
//
// (C) Copyright 2002-2017 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2002-2018 Fred Gleason <fredg@paravelsystems.com>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
@ -36,17 +36,19 @@ bool RDReport::ExportCutLog(const QString &filename,const QDate &startdate,
{
QString sql;
RDSqlQuery *q;
FILE *f;
QString cut;
QString str;
QString cart_fmt;
QString cart_num;
QFile file(filename);
if((f=fopen((const char *)filename,"w"))==NULL) {
QFile *file=new QFile(filename);
if(!file->open(IO_WriteOnly|IO_Truncate)) {
report_error_code=RDReport::ErrorCantOpen;
delete file;
return false;
}
QTextStream *strm=new QTextStream(file);
strm->setEncoding(QTextStream::UnicodeUTF8);
if(useLeadingZeros()) {
cart_fmt=QString().sprintf("%%0%uu",cartDigits());
}
@ -78,21 +80,16 @@ bool RDReport::ExportCutLog(const QString &filename,const QDate &startdate,
// Write File Header
//
if(startdate==enddate) {
fprintf(f," Rivendell RDAirPlay Cut Report for %s\n",
(const char *)startdate.toString("MM/dd/yyyy"));
*strm << Center(QString("Rivendell RDAirPlay Cut Report for ")+
startdate.toString("MM/dd/yyyy"),75);
}
else {
fprintf(f," Rivendell RDAirPlay Cut Report for %s - %s\n",
(const char *)startdate.toString("MM/dd/yyyy"),
(const char *)enddate.toString("MM/dd/yyyy"));
*strm << Center(QString("Rivendell RDAirPlay Cut Report for ")+
startdate.toString("MM/dd/yyyy")+" - "+
enddate.toString("MM/dd/yyyy"),75)+"\n";
}
str=QString().sprintf("%s -- %s\n",(const char *)name(),
(const char *)description());
for(unsigned i=0;i<(80-str.length())/2;i++) {
fprintf(f," ");
}
fprintf(f,"%s\n",(const char *)str);
fprintf(f,"--Time-- -Cart- --Title---------------- Cut --Description------- -Len-\n");
*strm << Center(name()+" -- "+description(),75)+"\n";
*strm << "--Time-- -Cart- --Title---------------- Cut --Description------- -Len-\n";
//
// Write Data Rows
@ -115,18 +112,17 @@ bool RDReport::ExportCutLog(const QString &filename,const QDate &startdate,
if(desc.isEmpty()) {
desc=" ";
}
fprintf(f,"%8s %6s %-23s %3s %-20s %5s",
(const char *)q->value(2).toTime().toString("hh:mm:ss"),
(const char *)cart_num,
(const char *)q->value(8).toString().left(23),
(const char *)cut,
(const char *)desc.left(20),
(const char *)RDGetTimeLength(q->value(9).toInt(),true,false).
right(5));
fprintf(f,"\n");
*strm << q->value(2).toTime().toString("hh:mm:ss")+" ";
*strm << cart_num+" ";
*strm << LeftJustify(q->value(8).toString(),23)+" ";
*strm << cut+" ";
*strm << LeftJustify(desc,20)+" ";
*strm << RDGetTimeLength(q->value(9).toInt(),true,false).right(5);
*strm << "\n";
}
delete q;
fclose(f);
delete strm;
delete file;
report_error_code=RDReport::ErrorOk;
return true;
}

View File

@ -25,30 +25,30 @@
#define CBSI_STATION_ID 1
#define CBSI_SCHED_FLAG "C"
#include <stdio.h>
#include <qfile.h>
#include <qmessagebox.h>
#include <qtextstream.h>
#include <rddatedecode.h>
#include <rddb.h>
#include <rdescape_string.h>
#include <rdreport.h>
#include "rddatedecode.h"
#include "rddb.h"
#include "rdescape_string.h"
#include "rdreport.h"
bool RDReport::ExportDeltaflex(const QString &filename,const QDate &startdate,
const QDate &enddate,const QString &mixtable)
{
QString sql;
RDSqlQuery *q;
FILE *f;
QString air_fmt;
QFile file(filename);
if((f=fopen((const char *)filename,"wb"))==NULL) {
QFile *file=new QFile(filename);
if(!file->open(IO_WriteOnly|IO_Truncate)) {
report_error_code=RDReport::ErrorCantOpen;
delete file;
return false;
}
QTextStream *strm=new QTextStream(file);
strm->setEncoding(QTextStream::UnicodeUTF8);
if(useLeadingZeros()) {
air_fmt=QString().sprintf("%%0%uu",cartDigits());
}
@ -80,12 +80,12 @@ bool RDReport::ExportDeltaflex(const QString &filename,const QDate &startdate,
if(station_id>99) {
station_id=0;
}
fprintf(f,"Air Log for CBSI %03d|%s|%02u|%05d|%s|\x0d\x0a",
CBSI_DELTAFLEX_VERSION,
(const char *)startdate.toString("yy/MM/dd"),
station_id,
q->size(),
CBSI_SCHED_FLAG);
*strm << QString("Air Log for CBSI ");
*strm << QString().sprintf("%03d|",CBSI_DELTAFLEX_VERSION);
*strm << startdate.toString("yy/MM/dd");
*strm << QString().sprintf("|%02u|",station_id);
*strm << QString().sprintf("%05d|",q->size());
*strm << QString(CBSI_SCHED_FLAG)+"|\x0d\x0a";
//
// Write Data Rows
@ -151,21 +151,21 @@ bool RDReport::ExportDeltaflex(const QString &filename,const QDate &startdate,
air_cartnum=QString().sprintf(air_fmt,q->value(1).toUInt());
tfc_cartnum=q->value(10).toString();
fprintf(f,"%s|%4s|%-29s|%-12s|%-12s|%s|%s|%8s|%-3s| | |%4s|\x0d\x0a",
(const char *)q->value(2).toDateTime().toString("hhmm"),
(const char *)tfc_time,
(const char *)cart_title,
(const char *)air_cartnum,
(const char *)tfc_cartnum,
(const char *)play_length,
(const char *)tfc_length,
(const char *)ext_data,
(const char *)q->value(8).toString(),
(const char *)q->value(7).toString());
*strm << q->value(2).toDateTime().toString("hhmm")+"|";
*strm << LeftJustify(tfc_time,4)+"|";
*strm << LeftJustify(cart_title,29)+"|";
*strm << LeftJustify(air_cartnum,12)+"|";
*strm << LeftJustify(tfc_cartnum,12)+"|";
*strm << play_length+"|";
*strm << tfc_length+"|";
*strm << LeftJustify(ext_data,8)+"|";
*strm << LeftJustify(q->value(8).toString(),3)+"| | |";
*strm << LeftJustify(q->value(7).toString(),4)+"|\x0d\x0a";
}
delete q;
fclose(f);
delete strm;
delete file;
report_error_code=RDReport::ErrorOk;
return true;
}

View File

@ -2,7 +2,7 @@
//
// Export a Rivendell Classical Music Playout report
//
// (C) Copyright 2014,2016-2017 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2014,2016-2018 Fred Gleason <fredg@paravelsystems.com>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
@ -18,18 +18,17 @@
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
#include <stdio.h>
#include <qfile.h>
#include <qmessagebox.h>
#include <qtextstream.h>
#include <rdairplay_conf.h>
#include <rdconf.h>
#include <rddatedecode.h>
#include <rddb.h>
#include <rdescape_string.h>
#include <rdlog_line.h>
#include <rdreport.h>
#include "rdairplay_conf.h"
#include "rdconf.h"
#include "rddatedecode.h"
#include "rddb.h"
#include "rdescape_string.h"
#include "rdlog_line.h"
#include "rdreport.h"
bool RDReport::ExportMusicClassical(const QString &filename,
const QDate &startdate,const QDate &enddate,
@ -37,17 +36,19 @@ bool RDReport::ExportMusicClassical(const QString &filename,
{
QString sql;
RDSqlQuery *q;
FILE *f;
// FILE *f;
QString cut;
QString str;
QString cart_fmt;
QString cart_num;
QFile file(filename);
if((f=fopen((const char *)filename,"w"))==NULL) {
QFile *file=new QFile(filename);
if(!file->open(IO_WriteOnly|IO_Truncate)) {
report_error_code=RDReport::ErrorCantOpen;
delete file;
return false;
}
QTextStream *strm=new QTextStream(file);
strm->setEncoding(QTextStream::UnicodeUTF8);
if(useLeadingZeros()) {
cart_fmt=QString().sprintf("%%0%uu",cartDigits());
}
@ -72,21 +73,16 @@ bool RDReport::ExportMusicClassical(const QString &filename,
// Write File Header
//
if(startdate==enddate) {
fprintf(f," Rivendell RDAirPlay Classical Music Playout Report for %s\n",
(const char *)startdate.toString("MM/dd/yyyy"));
*strm << Center(QString("Rivendell RDAirPlay Classical Music Playout Report for ")+
startdate.toString("MM/dd/yyyy"),120)+"\n";
}
else {
fprintf(f," Rivendell RDAirPlay Music Playout Report for %s - %s\n",
(const char *)startdate.toString("MM/dd/yyyy"),
(const char *)enddate.toString("MM/dd/yyyy"));
*strm << Center(QString("Rivendell RDAirPlay Classical Music Playout Report for ")+
startdate.toString("MM/dd/yyyy")+" - "+
enddate.toString("MM/dd/yyyy"),120)+"\n";
}
str=QString().sprintf("%s -- %s\n",(const char *)name(),
(const char *)description());
for(unsigned i=0;i<(120-str.length())/2;i++) {
fprintf(f," ");
}
fprintf(f,"%s\n",(const char *)str);
fprintf(f,"Time -Len- --Title----------------------- --Composer-------------------- --Label / Spine #-------- Lib # Cart #\n");
*strm << Center(name()+" -- "+description(),120)+"\n";
*strm << "Time -Len- --Title----------------------- --Composer-------------------- --Label / Spine #-------- Lib # Cart #\n";
//
// Write Data Rows
@ -105,18 +101,17 @@ bool RDReport::ExportMusicClassical(const QString &filename,
}
}
cart_num=QString().sprintf(cart_fmt,q->value(1).toUInt());
fprintf(f,"%4s %5s %-30s %-30s %-25s %-5s %06u\n",
(const char *)q->value(2).toDateTime().time().toString("hhmm"),
(const char *)RDGetTimeLength(q->value(0).toInt(),true,false).
right(5),
(const char *)StringField(q->value(3).toString().left(30)),
(const char *)StringField(q->value(5).toString().left(30)),
(const char *)StringField(q->value(4).toString().left(25)),
(const char *)StringField(q->value(6).toString().left(5)),
q->value(1).toUInt());
*strm << q->value(2).toDateTime().time().toString("hhmm")+" ";
*strm << RDGetTimeLength(q->value(0).toInt(),true,false).right(5)+" ";
*strm << LeftJustify(q->value(3).toString(),30)+" ";
*strm << LeftJustify(q->value(5).toString(),30)+" ";
*strm << LeftJustify(q->value(4).toString(),25)+" ";
*strm << LeftJustify(q->value(6).toString(),5)+" ";
* strm << QString().sprintf("%06u",q->value(1).toUInt())+"\n";
}
delete q;
fclose(f);
delete strm;
delete file;
report_error_code=RDReport::ErrorOk;
return true;

View File

@ -18,18 +18,17 @@
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
#include <stdio.h>
#include <qfile.h>
#include <qmessagebox.h>
#include <qtextstream.h>
#include <rdairplay_conf.h>
#include <rdconf.h>
#include <rddatedecode.h>
#include <rddb.h>
#include <rdescape_string.h>
#include <rdlog_line.h>
#include <rdreport.h>
#include "rdairplay_conf.h"
#include "rdconf.h"
#include "rddatedecode.h"
#include "rddb.h"
#include "rdescape_string.h"
#include "rdlog_line.h"
#include "rdreport.h"
bool RDReport::ExportMusicPlayout(const QString &filename,
const QDate &startdate,const QDate &enddate,
@ -37,17 +36,19 @@ bool RDReport::ExportMusicPlayout(const QString &filename,
{
QString sql;
RDSqlQuery *q;
FILE *f;
QString cut;
QString str;
QString cart_fmt;
QString cart_num;
QFile file(filename);
if((f=fopen((const char *)filename,"w"))==NULL) {
QFile *file=new QFile(filename);
if(!file->open(IO_WriteOnly|IO_Truncate)) {
report_error_code=RDReport::ErrorCantOpen;
delete file;
return false;
}
QTextStream *strm=new QTextStream(file);
strm->setEncoding(QTextStream::UnicodeUTF8);
if(useLeadingZeros()) {
cart_fmt=QString().sprintf("%%0%uu",cartDigits());
}
@ -74,21 +75,16 @@ bool RDReport::ExportMusicPlayout(const QString &filename,
// Write File Header
//
if(startdate==enddate) {
fprintf(f," Rivendell RDAirPlay Music Playout Report for %s\n",
(const char *)startdate.toString("MM/dd/yyyy"));
*strm << Center(QString("Rivendell RDAirPlay Music Playout Report for ")+
startdate.toString("MM/dd/yyyy"),144)+"\n";
}
else {
fprintf(f," Rivendell RDAirPlay Music Playout Report for %s - %s\n",
(const char *)startdate.toString("MM/dd/yyyy"),
(const char *)enddate.toString("MM/dd/yyyy"));
*strm << Center(QString("Rivendell RDAirPlay Music Playout Report for ")+
startdate.toString("MM/dd/yyyy")+" - "+
enddate.toString("MM/dd/yyyy"),144)+"\n";
}
str=QString().sprintf("%s -- %s\n",(const char *)name(),
(const char *)description());
for(unsigned i=0;i<(180-str.length())/2;i++) {
fprintf(f," ");
}
fprintf(f,"%s\n",(const char *)str);
fprintf(f,"--Time-- -Cart- Cut A-Len --Title----------------------- --Artist---------------------- --Album------------------ --Label-------------\n");
*strm << Center(name()+" -- "+description(),144)+"\n";
*strm << "--Time-- -Cart- Cut A-Len --Title----------------------- --Artist---------------------- --Album------------------ --Label-------------\n";
//
// Write Data Rows
@ -107,19 +103,18 @@ bool RDReport::ExportMusicPlayout(const QString &filename,
}
}
cart_num=QString().sprintf(cart_fmt,q->value(1).toUInt());
fprintf(f,"%8s %6s %3s %5s %-30s %-30s %-25s %-20s\n",
(const char *)q->value(2).toDateTime().time().toString("hh:mm:ss"),
(const char *)cart_num,
(const char *)cut,
(const char *)RDGetTimeLength(q->value(0).toInt(),true,false).
right(5),
(const char *)StringField(q->value(4).toString().left(30)),
(const char *)StringField(q->value(6).toString().left(30)),
(const char *)StringField(q->value(7).toString().left(25)),
(const char *)StringField(q->value(8).toString().left(20)));
*strm << q->value(2).toDateTime().time().toString("hh:mm:ss")+" ";
*strm << cart_num+" ";
*strm << cut+" ";
*strm << RDGetTimeLength(q->value(0).toInt(),true,false).right(5)+" ";
*strm << LeftJustify(q->value(4).toString(),30)+" ";
*strm << LeftJustify(q->value(6).toString(),30)+" ";
*strm << LeftJustify(q->value(7).toString(),25)+" ";
*strm << LeftJustify(q->value(8).toString(),20)+"\n";
}
delete q;
fclose(f);
delete strm;
delete file;
report_error_code=RDReport::ErrorOk;
return true;

View File

@ -18,19 +18,17 @@
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
#include <stdio.h>
#include <qfile.h>
#include <qmessagebox.h>
#include <qtextstream.h>
#include <rdairplay_conf.h>
#include <rdconf.h>
#include <rddatedecode.h>
#include <rddb.h>
#include <rdescape_string.h>
#include <rdlog_line.h>
#include <rdreport.h>
#include "rdairplay_conf.h"
#include "rdconf.h"
#include "rddatedecode.h"
#include "rddb.h"
#include "rdescape_string.h"
#include "rdlog_line.h"
#include "rdreport.h"
bool RDReport::ExportMusicSummary(const QString &filename,
const QDate &startdate,const QDate &enddate,
@ -38,15 +36,17 @@ bool RDReport::ExportMusicSummary(const QString &filename,
{
QString sql;
RDSqlQuery *q;
FILE *f;
QString cut;
QString str;
QFile file(filename);
if((f=fopen((const char *)filename,"w"))==NULL) {
QFile *file=new QFile(filename);
if(!file->open(IO_WriteOnly|IO_Truncate)) {
report_error_code=RDReport::ErrorCantOpen;
delete file;
return false;
}
QTextStream *strm=new QTextStream(file);
strm->setEncoding(QTextStream::UnicodeUTF8);
sql=QString("select ")+
"ELR_LINES.ARTIST,"+ // 00
"ELR_LINES.TITLE,"+ // 01
@ -61,36 +61,32 @@ bool RDReport::ExportMusicSummary(const QString &filename,
// Write File Header
//
if(startdate==enddate) {
fprintf(f," Rivendell RDAirPlay Music Summary Report for %s\n",
(const char *)startdate.toString("MM/dd/yyyy"));
*strm << Center(QString("Rivendell RDAirPlay Music Summary Report for ")+
startdate.toString("MM/dd/yyyy"),75)+"\n";
}
else {
fprintf(f," Rivendell RDAirPlay Music Summary Report for %s - %s\n",
(const char *)startdate.toString("MM/dd/yyyy"),
(const char *)enddate.toString("MM/dd/yyyy"));
*strm << Center(QString("Rivendell RDAirPlay Music Summary Report for ")+
startdate.toString("MM/dd/yyyy")+" - "+
enddate.toString("MM/dd/yyyy"),75)+"\n";
}
str=QString().sprintf("%s -- %s\n",(const char *)name(),
(const char *)description());
for(unsigned i=0;i<(80-str.length())/2;i++) {
fprintf(f," ");
}
fprintf(f,"%s\n",(const char *)str);
*strm << Center(name()+" -- "+description(),75)+"\n";
//
// Write Data Rows
//
while(q->next()) {
if(!q->value(0).toString().isEmpty()) {
fprintf(f,"%s - ",(const char *)q->value(0).toString());
*strm << q->value(0).toString()+" - ";
}
fprintf(f,"%s",(const char *)q->value(1).toString());
*strm << q->value(1).toString();
if(!q->value(2).toString().isEmpty()) {
fprintf(f," [%s]",(const char *)q->value(2).toString());
*strm << QString("[")+q->value(2).toString()+"]";
}
fprintf(f,"\n");
*strm << "\n";
}
delete q;
fclose(f);
delete strm;
delete file;
report_error_code=RDReport::ErrorOk;
return true;
}

View File

@ -18,18 +18,17 @@
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
#include <stdio.h>
#include <qfile.h>
#include <qmessagebox.h>
#include <qtextstream.h>
#include <rdairplay_conf.h>
#include <rddatedecode.h>
#include <rddb.h>
#include <rdescape_string.h>
#include <rdget_ath.h>
#include <rdlog_line.h>
#include <rdreport.h>
#include "rdairplay_conf.h"
#include "rddatedecode.h"
#include "rddb.h"
#include "rdescape_string.h"
#include "rdget_ath.h"
#include "rdlog_line.h"
#include "rdreport.h"
//
// This implements a National Public Radio (NPR) standard.
@ -42,7 +41,6 @@ bool RDReport::ExportNprSoundEx(const QString &filename,const QDate &startdate,
{
QString sql;
RDSqlQuery *q;
FILE *f=NULL;
QString artist;
QString title;
QString album;
@ -51,15 +49,19 @@ bool RDReport::ExportNprSoundEx(const QString &filename,const QDate &startdate,
QString trans_category=stationFormat();
QString channel_name=stationId();
if((f=fopen(filename,"wb"))==NULL) {
QFile *file=new QFile(filename);
if(!file->open(IO_WriteOnly|IO_Truncate)) {
report_error_code=RDReport::ErrorCantOpen;
delete file;
return false;
}
QTextStream *strm=new QTextStream(file);
strm->setEncoding(QTextStream::UnicodeUTF8);
//
// Generate Header
//
fprintf(f,"Start Time\tEnd Time\tTitle\tArtist\tAlbum\tLabel\x0d\x0a");
*strm << QString("Start Time\tEnd Time\tTitle\tArtist\tAlbum\tLabel\x0d\x0a");
//
// Roll Up Records
@ -76,17 +78,17 @@ bool RDReport::ExportNprSoundEx(const QString &filename,const QDate &startdate,
"order by EVENT_DATETIME";
q=new RDSqlQuery(sql);
while(q->next()) {
fprintf(f,"%s\t",(const char *)q->value(0).toDateTime().
toString("MM/dd/yyyy hh:mm:ss"));
fprintf(f,"%s\t",(const char *)q->value(0).toDateTime().
addSecs(q->value(1).toInt()/1000).
toString("MM/dd/yyyy hh:mm:ss"));
fprintf(f,"%s\t",(const char *)StringField(q->value(2).toString()));
fprintf(f,"%s\t",(const char *)StringField(q->value(3).toString()));
fprintf(f,"%s\t",(const char *)StringField(q->value(4).toString()));
fprintf(f,"%s\x0d\x0a",(const char *)StringField(q->value(5).toString()));
*strm << q->value(0).toDateTime().toString("MM/dd/yyyy hh:mm:ss")+"\t";
*strm << q->value(0).toDateTime().addSecs(q->value(1).toInt()/1000).
toString("MM/dd/yyyy hh:mm:ss")+"\t";
*strm << q->value(2).toString()+"\t";
*strm << q->value(3).toString()+"\t";
*strm << q->value(4).toString()+"\t";
*strm << q->value(5).toString()+"\x0d\x0a";
}
fclose(f);
delete q;
delete strm;
delete file;
report_error_code=RDReport::ErrorOk;
return true;
}

View File

@ -18,16 +18,15 @@
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
#include <stdio.h>
#include <qfile.h>
#include <qmessagebox.h>
#include <qtextstream.h>
#include <rddb.h>
#include <rdconf.h>
#include <rddatedecode.h>
#include <rdescape_string.h>
#include <rdreport.h>
#include "rddb.h"
#include "rdconf.h"
#include "rddatedecode.h"
#include "rdescape_string.h"
#include "rdreport.h"
bool RDReport::ExportRadioTraffic(const QString &filename,
const QDate &startdate,const QDate &enddate,
@ -35,15 +34,16 @@ bool RDReport::ExportRadioTraffic(const QString &filename,
{
QString sql;
RDSqlQuery *q;
FILE *f;
QString air_fmt;
QFile file(filename);
if((f=fopen((const char *)filename,"wb"))==NULL) {
QFile *file=new QFile(filename);
if(!file->open(IO_WriteOnly|IO_Truncate)) {
report_error_code=RDReport::ErrorCantOpen;
delete file;
return false;
}
QTextStream *strm=new QTextStream(file);
strm->setEncoding(QTextStream::UnicodeUTF8);
if(useLeadingZeros()) {
air_fmt=QString().sprintf("%%0%uu ",cartDigits());
}
@ -72,37 +72,29 @@ bool RDReport::ExportRadioTraffic(const QString &filename,
// Write Data Rows
//
while(q->next()) {
fprintf(f,"%s ",(const char *)q->value(4).toTime().toString("hh:mm:ss"));
fprintf(f,"%s ",(const char *)q->value(2).toDateTime().
toString("hh:mm:ss"));
*strm << q->value(4).toTime().toString("hh:mm:ss")+" ";
*strm << q->value(2).toDateTime().toString("hh:mm:ss")+" ";
if(q->value(5).toInt()>0) {
fprintf(f,"0%s ",(const char *)RDGetTimeLength(q->value(5).toInt(),
true,false));
*strm << RDGetTimeLength(q->value(5).toInt(),true,false)+" ";
}
else {
fprintf(f,"00:00:00 ");
*strm << "00:00:00 ";
}
if(q->value(0).toInt()>0) {
fprintf(f,"0%s ",(const char *)RDGetTimeLength(q->value(0).toInt(),
true,false));
*strm << QString("0")+RDGetTimeLength(q->value(0).toInt(),true,false)+" ";
}
else {
fprintf(f,"00:00:00 ");
*strm << "00:00:00 ";
}
fprintf(f,air_fmt,q->value(1).toUInt());
fprintf(f,"%-34s ",(const char *)q->value(9).toString().left(34));
if(q->value(6).toString().isEmpty()) {
fprintf(f," ");
}
else {
fprintf(f,"%-32s",(const char *)q->value(6).toString().left(32).
stripWhiteSpace());
}
fprintf(f,"\x0d\x0a");
*strm << QString().sprintf(air_fmt,q->value(1).toUInt());
*strm << LeftJustify(q->value(9).toString(),34)+" ";
*strm << LeftJustify(q->value(6).toString(),32);
*strm << "\x0d\x0a";
}
delete q;
fclose(f);
delete strm;
delete file;
report_error_code=RDReport::ErrorOk;
return true;

View File

@ -18,25 +18,23 @@
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
#include <stdio.h>
#include <qfile.h>
#include <qmessagebox.h>
#include <qtextstream.h>
#include <rdairplay_conf.h>
#include <rddatedecode.h>
#include <rddb.h>
#include <rdescape_string.h>
#include <rdget_ath.h>
#include <rdlog_line.h>
#include <rdreport.h>
#include "rdairplay_conf.h"
#include "rddatedecode.h"
#include "rddb.h"
#include "rdescape_string.h"
#include "rdget_ath.h"
#include "rdlog_line.h"
#include "rdreport.h"
bool RDReport::ExportSoundEx(const QString &filename,const QDate &startdate,
const QDate &enddate,const QString &mixtable)
{
QString sql;
RDSqlQuery *q;
FILE *f;
unsigned cartnum=0;
QString artist;
QString title;
@ -58,15 +56,19 @@ bool RDReport::ExportSoundEx(const QString &filename,const QDate &startdate,
return false;
}
if((f=fopen((const char *)filename,"w"))==NULL) {
QFile *file=new QFile(filename);
if(!file->open(IO_WriteOnly|IO_Truncate)) {
report_error_code=RDReport::ErrorCantOpen;
delete file;
return false;
}
QTextStream *strm=new QTextStream(file);
strm->setEncoding(QTextStream::UnicodeUTF8);
//
// Generate Header
//
fprintf(f,"\"NAME_OF_SERVICE\",\"TRANSMISSION_CATEGORY\",\"FEATURED_ARTIST\",\"SOUND_RECORDING_TITLE\",\"ISRC\",\"ALBUM_TITLE\",\"MARKETING_LABEL\",\"ACTUAL_TOTAL_PERFORMANCES\",\"AGGREGATE_TUNING_HOURS\",\"CHANNEL_OR_PROGRAM_NAME\",\"PLAY_FREQUENCY\"\r\n");
*strm << "\"NAME_OF_SERVICE\",\"TRANSMISSION_CATEGORY\",\"FEATURED_ARTIST\",\"SOUND_RECORDING_TITLE\",\"ISRC\",\"ALBUM_TITLE\",\"MARKETING_LABEL\",\"ACTUAL_TOTAL_PERFORMANCES\",\"AGGREGATE_TUNING_HOURS\",\"CHANNEL_OR_PROGRAM_NAME\",\"PLAY_FREQUENCY\"\r\n";
//
// Roll Up Records
@ -88,18 +90,17 @@ bool RDReport::ExportSoundEx(const QString &filename,const QDate &startdate,
}
else {
if(cartnum!=0) {
fprintf(f,
"\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",,%9.2lf,\"%s\",%d\n",
(const char *)service_name,
(const char *)trans_category,
(const char *)artist,
(const char *)title,
(const char *)isrc,
(const char *)album,
(const char *)label,
ath,
(const char *)channel_name,
plays);
*strm << QString("\"")+service_name+"\",";
*strm << QString("\"")+trans_category+"\",";
*strm << QString("\"")+artist+"\",";
*strm << QString("\"")+title+"\",";
*strm << QString("\"")+isrc+"\",";
*strm << QString("\"")+album+"\",";
*strm << QString("\"")+label+"\",,";
*strm << QString().sprintf("%9.2f,",ath);
*strm << QString("\"")+channel_name+"\",";
*strm << QString().sprintf("%d",plays);
*strm << "\n";
}
plays=1;
if(q->value(1).isNull()) {
@ -132,20 +133,20 @@ bool RDReport::ExportSoundEx(const QString &filename,const QDate &startdate,
}
delete q;
if(cartnum!=0) {
fprintf(f,
"\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",,%9.2lf,\"%s\",%d\n",
(const char *)service_name,
(const char *)trans_category,
(const char *)artist,
(const char *)title,
(const char *)isrc,
(const char *)album,
(const char *)label,
ath,
(const char *)channel_name,
plays);
*strm << QString("\"")+service_name+"\",";
*strm << QString("\"")+trans_category+"\",";
*strm << QString("\"")+artist+"\",";
*strm << QString("\"")+title+"\",";
*strm << QString("\"")+isrc+"\",";
*strm << QString("\"")+album+"\",";
*strm << QString("\"")+label+"\",,";
*strm << QString().sprintf("%9.2f,",ath);
*strm << QString("\"")+channel_name+"\",";
*strm << QString().sprintf("%d",plays);
*strm << "\n";
}
fclose(f);
delete strm;
delete file;
report_error_code=RDReport::ErrorOk;
return true;
}

View File

@ -18,27 +18,25 @@
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
#include <stdio.h>
#include <map>
#include <qfile.h>
#include <qmessagebox.h>
#include <qtextstream.h>
#include <rdairplay_conf.h>
#include <rdconf.h>
#include <rddatedecode.h>
#include <rddb.h>
#include <rdescape_string.h>
#include <rdlog_line.h>
#include <rdreport.h>
#include "rdairplay_conf.h"
#include "rdconf.h"
#include "rddatedecode.h"
#include "rddb.h"
#include "rdescape_string.h"
#include "rdlog_line.h"
#include "rdreport.h"
bool RDReport::ExportSpinCount(const QString &filename,const QDate &startdate,
const QDate &enddate,const QString &mixtable)
{
QString sql;
RDSqlQuery *q;
FILE *f;
QString cut;
QString str;
QString cart_fmt;
@ -49,11 +47,14 @@ bool RDReport::ExportSpinCount(const QString &filename,const QDate &startdate,
std::map<unsigned,QString> labels;
std::map<unsigned,QString> albums;
QFile file(filename);
if((f=fopen((const char *)filename,"w"))==NULL) {
QFile *file=new QFile(filename);
if(!file->open(IO_WriteOnly|IO_Truncate)) {
report_error_code=RDReport::ErrorCantOpen;
delete file;
return false;
}
QTextStream *strm=new QTextStream(file);
strm->setEncoding(QTextStream::UnicodeUTF8);
if(useLeadingZeros()) {
cart_fmt=QString().sprintf("%%0%uu",cartDigits());
}
@ -86,36 +87,31 @@ bool RDReport::ExportSpinCount(const QString &filename,const QDate &startdate,
// Write File Header
//
if(startdate==enddate) {
fprintf(f," Rivendell Spin Count Report for %s\n",
(const char *)startdate.toString("MM/dd/yyyy"));
*strm << Center(QString("Rivendell Spin Count Report for ")+
startdate.toString("MM/dd/yyyy"),132)+"\n";
}
else {
fprintf(f," Rivendell Spin Count Report for %s - %s\n",
(const char *)startdate.toString("MM/dd/yyyy"),
(const char *)enddate.toString("MM/dd/yyyy"));
*strm << Center(QString("Rivendell Spin Count Report for ")+
startdate.toString("MM/dd/yyyy")+" - "+
enddate.toString("MM/dd/yyyy"),132)+"\n";
}
str=QString().sprintf("%s -- %s\n",(const char *)name(),
(const char *)description());
for(unsigned i=0;i<(132-str.length())/2;i++) {
fprintf(f," ");
}
fprintf(f,"%s\n",(const char *)str);
// fprintf(f,"------------------------------------------------------------------------------------------------------------------------------------\n");
fprintf(f,"--Title------------------------ --Artist----------------------- --Album------------------------ --Label----------------------- Spins\n");
*strm << Center(name()+" -- "+description(),132)+"\n";
*strm << "--Title------------------------ --Artist----------------------- --Album------------------------ --Label----------------------- Spins\n";
//
// Write Data Rows
//
for(std::map<unsigned,unsigned>::const_iterator it=carts.begin();
it!=carts.end();it++) {
fprintf(f,"%-30s %-30s %-30s %-29s %5u\n",
(const char *)titles[it->first],
(const char *)artists[it->first],
(const char *)albums[it->first],
(const char *)labels[it->first],
it->second);
*strm << LeftJustify(titles[it->first],30)+" ";
*strm << LeftJustify(artists[it->first],30)+" ";
*strm << LeftJustify(albums[it->first],30)+" ";
*strm << LeftJustify(labels[it->first],29)+" ";
*strm << QString().sprintf("%5u",it->second);
*strm << "\n";
}
fclose(f);
delete strm;
delete file;
report_error_code=RDReport::ErrorOk;
return true;
}

View File

@ -18,18 +18,15 @@
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
#include <stdio.h>
#include <qfile.h>
#include <qmessagebox.h>
#include <qtextstream.h>
#include <rdairplay_conf.h>
#include <rdconf.h>
#include <rddatedecode.h>
#include <rddb.h>
#include <rdescape_string.h>
#include <rdlog_line.h>
#include <rdreport.h>
#include "rdairplay_conf.h"
#include "rdconf.h"
#include "rddb.h"
#include "rdescape_string.h"
#include "rdlog_line.h"
#include "rdreport.h"
bool RDReport::ExportTechnical(const QString &filename,const QDate &startdate,
const QDate &enddate,bool incl_hdr,bool incl_crs,
@ -37,7 +34,6 @@ bool RDReport::ExportTechnical(const QString &filename,const QDate &startdate,
{
QString sql;
RDSqlQuery *q;
FILE *f;
QString cut;
QString str;
QString cart_fmt;
@ -48,11 +44,14 @@ bool RDReport::ExportTechnical(const QString &filename,const QDate &startdate,
strcpy(eol,"\r\n");
}
QFile file(filename);
if((f=fopen((const char *)filename,"w"))==NULL) {
QFile *file=new QFile(filename);
if(!file->open(IO_WriteOnly|IO_Truncate)) {
report_error_code=RDReport::ErrorCantOpen;
delete file;
return false;
}
QTextStream *strm=new QTextStream(file);
strm->setEncoding(QTextStream::UnicodeUTF8);
if(useLeadingZeros()) {
cart_fmt=QString().sprintf("%%0%uu",cartDigits());
}
@ -86,21 +85,16 @@ bool RDReport::ExportTechnical(const QString &filename,const QDate &startdate,
//
if(incl_hdr) {
if(startdate==enddate) {
fprintf(f," Rivendell RDAirPlay Technical Playout Report for %s%s",
(const char *)startdate.toString("MM/dd/yyyy"),eol);
*strm << Center("Rivendell RDAirPlay Technical Playout Report for "+
startdate.toString("MM/dd/yyyy"),96)+eol;
}
else {
fprintf(f," Rivendell RDAirPlay Technical Playout Report for %s - %s%s",
(const char *)startdate.toString("MM/dd/yyyy"),
(const char *)enddate.toString("MM/dd/yyyy"),eol);
*strm << Center("Rivendell RDAirPlay Technical Playout Report for "+
startdate.toString("MM/dd/yyyy")+" - "+
enddate.toString("MM/dd/yyyy"),96)+eol;
}
str=QString().sprintf("%s -- %s%s",(const char *)name(),
(const char *)description(),eol);
for(unsigned i=0;i<(80-str.length())/2;i++) {
fprintf(f," ");
}
fprintf(f,"%s%s",(const char *)str,eol);
fprintf(f,"--Time-- -Cart- Cut --Title---------------- A-Len N-Len --Host---- Srce StartedBy OnAir%s",eol);
*strm << Center(name()+" -- "+description(),96)+eol;
*strm << QString("--Time-- -Cart- Cut --Title---------------- A-Len N-Len --Host---- Srce StartedBy OnAir")+eol;
}
//
@ -120,53 +114,51 @@ bool RDReport::ExportTechnical(const QString &filename,const QDate &startdate,
}
}
cart_num=QString().sprintf(cart_fmt,q->value(1).toUInt());
fprintf(f,"%8s %6s %3s %-23s %5s %5s %-10s ",
(const char *)q->value(2).toTime().toString("hh:mm:ss"),
(const char *)cart_num,
(const char *)cut,
(const char *)q->value(8).toString().left(23),
(const char *)RDGetTimeLength(q->value(0).toInt(),true,false).
right(5),
(const char *)RDGetTimeLength(q->value(9).toInt(),true,false).
right(5),
(const char *)q->value(10).toString());
*strm << q->value(2).toTime().toString("hh:mm:ss")+" ";
*strm << cart_num+" ";
*strm << cut+" ";
*strm << LeftJustify(q->value(8).toString(),23)+" ";
*strm << RDGetTimeLength(q->value(0).toInt(),true,false).right(5)+" ";
*strm << RDGetTimeLength(q->value(9).toInt(),true,false).right(5)+" ";
*strm << LeftJustify(q->value(10).toString(),10)+" ";
switch((RDLogLine::PlaySource)q->value(11).toInt()) {
case RDLogLine::MainLog:
fprintf(f,"Main ");
break;
case RDLogLine::MainLog:
*strm << "Main ";
break;
case RDLogLine::AuxLog1:
fprintf(f,"Aux1 ");
break;
case RDLogLine::AuxLog1:
*strm << "Aux1 ";
break;
case RDLogLine::AuxLog2:
fprintf(f,"Aux2 ");
break;
case RDLogLine::AuxLog2:
*strm << "Aux2 ";
break;
case RDLogLine::SoundPanel:
fprintf(f,"SPnl ");
break;
case RDLogLine::SoundPanel:
*strm << "SPnl ";
break;
case RDLogLine::CartSlot:
fprintf(f,"Slot ");
break;
case RDLogLine::CartSlot:
*strm << "Slot ";
break;
default:
fprintf(f," ");
break;
default:
*strm << " ";
break;
}
fprintf(f,"%-7s ",(const char *)RDLogLine::
startSourceText((RDLogLine::StartSource)q->value(13).toInt()));
*strm << LeftJustify(RDLogLine::startSourceText((RDLogLine::StartSource)q->value(13).toInt()),7)+" ";
if(q->value(14).toString()=="Y") {
fprintf(f," Yes ");
*strm << " Yes ";
}
else {
fprintf(f," No ");
*strm << " No ";
}
fprintf(f,"%s",eol);
*strm << eol;
}
delete q;
fclose(f);
delete strm;
delete file;
report_error_code=RDReport::ErrorOk;
return true;
}

View File

@ -1,6 +1,6 @@
// export_textlog.cpp
//
// Export a Rivendell Report to an ASCII Text File.
// Export a Rivendell Report to an Text File.
//
// (C) Copyright 2002-2005,2016-2018 Fred Gleason <fredg@paravelsystems.com>
//
@ -18,35 +18,36 @@
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
#include <stdio.h>
#include <qfile.h>
#include <qmessagebox.h>
#include <qtextstream.h>
#include <rdairplay_conf.h>
#include <rdconf.h>
#include <rddatedecode.h>
#include <rddb.h>
#include <rdescape_string.h>
#include <rdlog_line.h>
#include <rdreport.h>
#include "rdairplay_conf.h"
#include "rdconf.h"
#include "rddatedecode.h"
#include "rddb.h"
#include "rdescape_string.h"
#include "rdlog_line.h"
#include "rdreport.h"
bool RDReport::ExportTextLog(const QString &filename,const QDate &startdate,
const QDate &enddate,const QString &mixtable)
{
QString sql;
RDSqlQuery *q;
FILE *f;
QString cut;
QString str;
QString cart_fmt;
QString cart_num;
QFile file(filename);
if((f=fopen((const char *)filename,"w"))==NULL) {
QFile *file=new QFile(filename);
if(!file->open(IO_WriteOnly|IO_Truncate)) {
report_error_code=RDReport::ErrorCantOpen;
delete file;
return false;
}
QTextStream *strm=new QTextStream(file);
strm->setEncoding(QTextStream::UnicodeUTF8);
if(useLeadingZeros()) {
cart_fmt=QString().sprintf("%%0%uu",cartDigits());
}
@ -77,21 +78,16 @@ bool RDReport::ExportTextLog(const QString &filename,const QDate &startdate,
// Write File Header
//
if(startdate==enddate) {
fprintf(f," Rivendell RDAirPlay Playout Report for %s\n",
(const char *)startdate.toString("MM/dd/yyyy"));
*strm << Center(QString("Rivendell RDAirPlay Playout Report for ")+
startdate.toString("MM/dd/yyyy"),78)+"\n";
}
else {
fprintf(f," Rivendell RDAirPlay Playout Report for %s - %s\n",
(const char *)startdate.toString("MM/dd/yyyy"),
(const char *)enddate.toString("MM/dd/yyyy"));
*strm << Center(QString("Rivendell RDAirPlay Playout Report for ")+
startdate.toString("MM/dd/yyyy")+" - "+
enddate.toString("MM/dd/yyyy"),78)+"\n";
}
str=QString().sprintf("%s -- %s\n",(const char *)name(),
(const char *)description());
for(unsigned i=0;i<(80-str.length())/2;i++) {
fprintf(f," ");
}
fprintf(f,"%s\n",(const char *)str);
fprintf(f,"--Time-- -Cart- Cut --Title---------------- A-Len N-Len --Host---- Srce\n");
*strm << Center(name()+" -- "+description(),78)+"\n";
*strm << "--Time-- -Cart- Cut --Title---------------- A-Len N-Len --Host---- Srce\n";
//
// Write Data Rows
@ -110,45 +106,44 @@ bool RDReport::ExportTextLog(const QString &filename,const QDate &startdate,
}
}
cart_num=QString().sprintf(cart_fmt,q->value(1).toUInt());
fprintf(f,"%8s %6s %3s %-23s %5s %5s %-10s ",
(const char *)q->value(2).toTime().toString("hh:mm:ss"),
(const char *)cart_num,
(const char *)cut,
(const char *)q->value(8).toString().left(23),
(const char *)RDGetTimeLength(q->value(0).toInt(),true,false).
right(5),
(const char *)RDGetTimeLength(q->value(9).toInt(),true,false).
right(5),
(const char *)q->value(10).toString());
*strm << q->value(2).toTime().toString("hh:mm:ss")+" ";
*strm << RightJustify(cart_num,6)+" ";
*strm << cut+" ";
*strm << LeftJustify(q->value(8).toString(),23)+" ";
*strm << RDGetTimeLength(q->value(0).toInt(),true,false).right(5)+" ";
*strm << RDGetTimeLength(q->value(8).toInt(),true,false).right(5)+" ";
*strm << LeftJustify(q->value(10).toString(),10)+" ";
switch((RDLogLine::PlaySource)q->value(11).toInt()) {
case RDLogLine::MainLog:
fprintf(f,"Main");
break;
case RDLogLine::MainLog:
*strm << "Main";
break;
case RDLogLine::AuxLog1:
fprintf(f,"Aux1");
break;
case RDLogLine::AuxLog1:
*strm << "Aux1";
break;
case RDLogLine::AuxLog2:
fprintf(f,"Aux2");
break;
case RDLogLine::AuxLog2:
*strm << "Aux2";
break;
case RDLogLine::SoundPanel:
fprintf(f,"SPnl");
break;
case RDLogLine::SoundPanel:
*strm << "SPnl";
break;
case RDLogLine::CartSlot:
fprintf(f,"Slot");
break;
case RDLogLine::CartSlot:
*strm << "Slot";
break;
default:
fprintf(f," ");
break;
default:
*strm << " ";
break;
}
fprintf(f,"\n");
*strm << "\n";
}
delete q;
fclose(f);
delete strm;
delete file;
report_error_code=RDReport::ErrorOk;
return true;
}

View File

@ -848,18 +848,42 @@ QString RDReport::errorText(RDReport::ErrorCode code)
}
QString RDReport::StringField(const QString &str,const QString &null_text) const
QString RDReport::LeftJustify(const QString &str,int width) const
{
QString ret=null_text;
QString ret=str.left(width);
if(!str.isEmpty()) {
ret=str;
while(ret.length()<(unsigned)width) {
ret+=" ";
}
return ret;
}
QString RDReport::RightJustify(const QString &str,int width) const
{
QString ret=str.left(width);
while(ret.length()<(unsigned)width) {
ret=" "+ret;
}
return ret;
}
QString RDReport::Center(const QString &str,int width) const
{
QString ret=str.left(width);
int margin=(width-ret.length())/2;
for(int i=0;i<margin;i++) {
ret=" "+ret;
}
return ret;
}
void RDReport::SetRow(const QString &param,const QString &value) const
{
RDSqlQuery *q;

View File

@ -95,6 +95,9 @@ class RDReport
static QString errorText(RDReport::ErrorCode code);
private:
QString LeftJustify(const QString &str,int width) const;
QString RightJustify(const QString &str,int width) const;
QString Center(const QString &str,int width) const;
bool ExportDeltaflex(const QString &filename,const QDate &startdate,
const QDate &enddate,const QString &mixtable);
bool ExportTextLog(const QString &filename,const QDate &startdate,
@ -120,7 +123,6 @@ class RDReport
const QDate &enddate,const QString &mixtable);
bool ExportCutLog(const QString &filename,const QDate &startdate,
const QDate &enddate,const QString &mixtable);
QString StringField(const QString &str,const QString &null_text="") const;
void SetRow(const QString &param,const QString &value) const;
void SetRow(const QString &param,int value) const;
void SetRow(const QString &param,unsigned value) const;