mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-04-23 09:18:34 +02:00
* Added an 'ELR_LINES' table to the database. * Incremented the database version to 289. * Removed the 'RDSvc::serviceTableName()' method.
98 lines
2.7 KiB
C++
98 lines
2.7 KiB
C++
// export_musicsummary.cpp
|
|
//
|
|
// Export a Rivendell Report to an ASCII Text File.
|
|
//
|
|
// (C) Copyright 2012,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
|
|
// 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 <stdio.h>
|
|
|
|
#include <qfile.h>
|
|
#include <qmessagebox.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,
|
|
const QString &mixtable)
|
|
{
|
|
QString sql;
|
|
RDSqlQuery *q;
|
|
FILE *f;
|
|
QString cut;
|
|
QString str;
|
|
|
|
QFile file(filename);
|
|
if((f=fopen((const char *)filename,"w"))==NULL) {
|
|
report_error_code=RDReport::ErrorCantOpen;
|
|
return false;
|
|
}
|
|
sql=QString("select ")+
|
|
"ELR_LINES.ARTIST,"+
|
|
"ELR_LINES.TITLE,"+
|
|
"ELR_LINES.ALBUM "+
|
|
"from ELR_LINES left join CART "+
|
|
"on ELR_LINES.CART_NUMBER=CART.NUMBER where "+
|
|
"SERVICE_NAME=\""+RDEscapeString(mixtable)+"\" "+
|
|
"order by EVENT_DATETIME";
|
|
q=new RDSqlQuery(sql);
|
|
|
|
//
|
|
// Write File Header
|
|
//
|
|
if(startdate==enddate) {
|
|
fprintf(f," Rivendell RDAirPlay Music Summary Report for %s\n",
|
|
(const char *)startdate.toString("MM/dd/yyyy"));
|
|
}
|
|
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"));
|
|
}
|
|
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);
|
|
|
|
//
|
|
// Write Data Rows
|
|
//
|
|
while(q->next()) {
|
|
if(!q->value(0).toString().isEmpty()) {
|
|
fprintf(f,"%s - ",(const char *)q->value(0).toString());
|
|
}
|
|
fprintf(f,"%s",(const char *)q->value(1).toString());
|
|
if(!q->value(2).toString().isEmpty()) {
|
|
fprintf(f," [%s]",(const char *)q->value(2).toString());
|
|
}
|
|
fprintf(f,"\n");
|
|
}
|
|
delete q;
|
|
fclose(f);
|
|
report_error_code=RDReport::ErrorOk;
|
|
return true;
|
|
}
|
|
|