mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-05-19 22:48:01 +02:00
* Modified reports in rdlogmanager(1) to use standard date/time formats. Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
119 lines
3.8 KiB
C++
119 lines
3.8 KiB
C++
// export_musicclassical.cpp
|
|
//
|
|
// Export a Rivendell Classical Music Playout report
|
|
//
|
|
// (C) Copyright 2014-2021 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
|
|
// published by the Free Software Foundation.
|
|
//
|
|
// This program is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU General Public
|
|
// License along with this program; if not, write to the Free Software
|
|
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
//
|
|
|
|
#include <QFile>
|
|
#include <QMessageBox>
|
|
#include <QTextStream>
|
|
|
|
#include "rdairplay_conf.h"
|
|
#include "rdapplication.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,
|
|
const QString &mixtable)
|
|
{
|
|
QString sql;
|
|
RDSqlQuery *q;
|
|
QString cut;
|
|
QString str;
|
|
QString cart_fmt;
|
|
QString cart_num;
|
|
QFile *file=new QFile(filename);
|
|
if(!file->open(QIODevice::WriteOnly|QIODevice::Truncate)) {
|
|
report_error_code=RDReport::ErrorCantOpen;
|
|
delete file;
|
|
return false;
|
|
}
|
|
QTextStream *strm=new QTextStream(file);
|
|
strm->setCodec("UTF-8");
|
|
if(useLeadingZeros()) {
|
|
cart_fmt=QString().sprintf("%%0%uu",cartDigits());
|
|
}
|
|
else {
|
|
cart_fmt="%6u";
|
|
}
|
|
sql=QString("select ")+
|
|
"`ELR_LINES`.`LENGTH`,"+ // 00
|
|
"`ELR_LINES`.`CART_NUMBER`,"+ // 01
|
|
"`ELR_LINES`.`EVENT_DATETIME`,"+ // 02
|
|
"`ELR_LINES`.`TITLE`,"+ // 03
|
|
"`ELR_LINES`.`ALBUM`,"+ // 04
|
|
"`ELR_LINES`.`COMPOSER`,"+ // 05
|
|
"`ELR_LINES`.`USER_DEFINED` "+ // 06
|
|
"from `ELR_LINES` left join `CART` "+
|
|
"on `ELR_LINES`.`CART_NUMBER`=`CART`.`NUMBER` where "+
|
|
"`ELR_LINES`.`SERVICE_NAME`='"+RDEscapeString(mixtable)+"' "+
|
|
"order by `EVENT_DATETIME`";
|
|
q=new RDSqlQuery(sql);
|
|
|
|
//
|
|
// Write File Header
|
|
//
|
|
if(startdate==enddate) {
|
|
*strm << RDReport::center(QString("Rivendell RDAirPlay Classical Music Playout Report for ")+
|
|
rda->shortDateString(startdate),120)+"\n";
|
|
}
|
|
else {
|
|
*strm << RDReport::center(QString("Rivendell RDAirPlay Classical Music Playout Report for ")+
|
|
rda->shortDateString(startdate)+" - "+
|
|
rda->shortDateString(enddate),120)+"\n";
|
|
}
|
|
*strm << RDReport::center(name()+" -- "+description(),120)+"\n";
|
|
*strm << "Time -Len- --Title----------------------- --Composer-------------------- --Label / Spine #-------- Lib # Cart #\n";
|
|
|
|
//
|
|
// Write Data Rows
|
|
//
|
|
while(q->next()) {
|
|
if(q->value(5).toInt()>0) {
|
|
cut=QString().sprintf("%03d",q->value(5).toInt());
|
|
}
|
|
else {
|
|
if((RDAirPlayConf::TrafficAction)q->value(6).toInt()==
|
|
RDAirPlayConf::TrafficMacro) {
|
|
cut="rml";
|
|
}
|
|
else {
|
|
cut=" ";
|
|
}
|
|
}
|
|
cart_num=QString().sprintf(cart_fmt.toUtf8(),q->value(1).toUInt());
|
|
*strm << q->value(2).toDateTime().time().toString("hhmm")+" ";
|
|
*strm << RDGetTimeLength(q->value(0).toInt(),true,false).right(5)+" ";
|
|
*strm << RDReport::leftJustify(q->value(3).toString(),30)+" ";
|
|
*strm << RDReport::leftJustify(q->value(5).toString(),30)+" ";
|
|
*strm << RDReport::leftJustify(q->value(4).toString(),25)+" ";
|
|
*strm << RDReport::leftJustify(q->value(6).toString(),5)+" ";
|
|
* strm << QString().sprintf("%06u",q->value(1).toUInt())+"\n";
|
|
}
|
|
delete q;
|
|
delete strm;
|
|
delete file;
|
|
report_error_code=RDReport::ErrorOk;
|
|
|
|
return true;
|
|
}
|