2018-07-10 Fred Gleason <fredg@paravelsystems.com>

* Added a 'STACK_LINES' table to the database.
	* Incremented the database version to 293.
This commit is contained in:
Fred Gleason 2018-07-10 11:05:46 -04:00
parent c72c5702c0
commit 3973ab5f01
36 changed files with 210 additions and 294 deletions

View File

@ -17112,3 +17112,6 @@
2018-07-10 Fred Gleason <fredg@paravelsystems.com> 2018-07-10 Fred Gleason <fredg@paravelsystems.com>
* Added a 'RULE_LINES' table to the database. * Added a 'RULE_LINES' table to the database.
* Incremented the database version to 292. * Incremented the database version to 292.
2018-07-10 Fred Gleason <fredg@paravelsystems.com>
* Added a 'STACK_LINES' table to the database.
* Incremented the database version to 293.

View File

@ -75,6 +75,7 @@ EXTRA_DIST = audio_cards.txt\
service_clocks.txt\ service_clocks.txt\
services.txt\ services.txt\
sources.txt\ sources.txt\
stack_lines.txt\
stations.txt\ stations.txt\
system.txt\ system.txt\
triggers.txt\ triggers.txt\

View File

@ -0,0 +1,13 @@
Stack Lines Table Layout for Rivendell
The STACK_LINES table holds history data for the music scheduler.
FIELD NAME TYPE REMARKS
------------------------------------------------------------------------
ID int(10) unsigned Primary key, auto_increment
SCHED_STACK_ID int(10) unsigned
SERVICE_NAME char(10) From SERVICES.NAME
CART int(10) unsigned From CART.NUMBER
ARTIST varchar(255) From CART.ARTIST
SCHED_CODES varchar(255)
SCHEDULED_AT datetime

View File

@ -103,7 +103,6 @@ dist_librd_la_SOURCES = dbversion.h\
rdconf.cpp rdconf.h\ rdconf.cpp rdconf.h\
rdconfig.cpp rdconfig.h\ rdconfig.cpp rdconfig.h\
rdcopyaudio.cpp rdcopyaudio.h\ rdcopyaudio.cpp rdcopyaudio.h\
rdcreate_log.cpp rdcreate_log.h\
rdcreateauxfieldstable.cpp rdcreateauxfieldstable.h\ rdcreateauxfieldstable.cpp rdcreateauxfieldstable.h\
rdcueedit.cpp rdcueedit.h\ rdcueedit.cpp rdcueedit.h\
rdcueeditdialog.cpp rdcueeditdialog.h\ rdcueeditdialog.cpp rdcueeditdialog.h\

View File

@ -24,7 +24,7 @@
/* /*
* Current Database Version * Current Database Version
*/ */
#define RD_VERSION_DATABASE 292 #define RD_VERSION_DATABASE 293
#endif // DBVERSION_H #endif // DBVERSION_H

View File

@ -55,7 +55,6 @@ SOURCES += rdcmd_switch.cpp
SOURCES += rdcombobox.cpp SOURCES += rdcombobox.cpp
SOURCES += rdconf.cpp SOURCES += rdconf.cpp
SOURCES += rdconfig.cpp SOURCES += rdconfig.cpp
SOURCES += rdcreate_log.cpp
SOURCES += rdcut.cpp SOURCES += rdcut.cpp
SOURCES += rddatedialog.cpp SOURCES += rddatedialog.cpp
SOURCES += rddatedecode.cpp SOURCES += rddatedecode.cpp
@ -201,7 +200,6 @@ HEADERS += rdcmd_switch.h
HEADERS += rdcombobox.h HEADERS += rdcombobox.h
HEADERS += rdconf.h HEADERS += rdconf.h
HEADERS += rdconfig.h HEADERS += rdconfig.h
HEADERS += rdcreate_log.h
HEADERS += rdcut.h HEADERS += rdcut.h
HEADERS += rddatedecode.h HEADERS += rddatedecode.h
HEADERS += rddatedialog.h HEADERS += rddatedialog.h

View File

@ -1,154 +0,0 @@
// rdcreate_log.cpp
//
// Create a new, empty Rivendell log table.
//
// (C) Copyright 2002-2014,2016 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 <rddb.h>
#include <rdclock.h>
#include <rdcreate_log.h>
#include <rdescape_string.h>
#include <rdlog.h>
#include <rdsvc.h>
#include <rd.h>
/*
void RDCreateLogTable(const QString &name,RDConfig *config)
{
QString sql=RDCreateLogTableSql(name,config);
RDSqlQuery *q=new RDSqlQuery(sql);
delete q;
}
*/
/*
QString RDCreateLogTableSql(QString name,RDConfig *config)
{
return QString("create table if not exists `")+name+"`"+
"(ID INT NOT NULL PRIMARY KEY,"+
"COUNT INT NOT NULL,"+
"TYPE INT DEFAULT 0,"+
"SOURCE INT NOT NULL,"+
"START_TIME int,"+
"GRACE_TIME int default 0,"+
"CART_NUMBER INT UNSIGNED NOT NULL default 0,"+
"TIME_TYPE INT NOT NULL,"+
"POST_POINT enum('N','Y') default 'N',"+
"TRANS_TYPE INT NOT NULL,"+
"START_POINT INT NOT NULL DEFAULT -1,"+
"END_POINT INT NOT NULL DEFAULT -1,"+
"FADEUP_POINT int default -1,"+
QString().sprintf("FADEUP_GAIN int default %d,",RD_FADE_DEPTH)+
"FADEDOWN_POINT int default -1,"+
QString().sprintf("FADEDOWN_GAIN int default %d,",RD_FADE_DEPTH)+
"SEGUE_START_POINT INT NOT NULL DEFAULT -1,"+
"SEGUE_END_POINT INT NOT NULL DEFAULT -1,"+
QString().sprintf("SEGUE_GAIN int default %d,",RD_FADE_DEPTH)+
"DUCK_UP_GAIN int default 0,"+
"DUCK_DOWN_GAIN int default 0,"+
"COMMENT CHAR(255),"+
"LABEL CHAR(64),"+
"ORIGIN_USER char(255),"+
"ORIGIN_DATETIME datetime,"+
"EVENT_LENGTH int default -1,"+
"LINK_EVENT_NAME char(64),"+
"LINK_START_TIME int,"+
"LINK_LENGTH int default 0,"+
"LINK_START_SLOP int default 0,"+
"LINK_END_SLOP int default 0,"+
"LINK_ID int default -1,"+
"LINK_EMBEDDED enum('N','Y') default 'N',"+
"EXT_START_TIME time,"+
"EXT_LENGTH int,"+
"EXT_CART_NAME char(32),"+
"EXT_DATA char(32),"+
"EXT_EVENT_ID char(32),"+
"EXT_ANNC_TYPE char(8),"+
"index COUNT_IDX (COUNT),"+
"index CART_NUMBER_IDX (CART_NUMBER),"+
"index LABEL_IDX (LABEL))"+
config->createTablePostfix();
}
*/
/*
QString RDCreateClockTableSql(QString name,RDConfig *config)
{
return QString("create table `")+name+"` ("+
"ID int unsigned auto_increment not null primary key,"+
"EVENT_NAME char(64) not null,"+
"START_TIME int not null,"+
"LENGTH int not null,"+
"INDEX EVENT_NAME_IDX (EVENT_NAME))"+
config->createTablePostfix();
}
*/
/*
QString RDCreateReconciliationTableSql(QString name,RDConfig *config)
{
QString sql=QString("create table `")+name+"` ("+
"ID int unsigned auto_increment primary key,"+
"LENGTH int,"+
"LOG_NAME char(64),"+
"LOG_ID int,"+
"CART_NUMBER int unsigned,"+
"CUT_NUMBER int,"+
"TITLE char(255),"+
"ARTIST char(255),"+
"PUBLISHER char(64),"+
"COMPOSER char(64),"+
"USER_DEFINED char(255),"+
"SONG_ID char(32),"+
"ALBUM char(255),"+
"LABEL char(64),"+
"CONDUCTOR char(64),"+
"USAGE_CODE int,"+
"DESCRIPTION char(64),"+
"OUTCUE char(64),"+
"ISRC char(12),"+
"ISCI char(32),"+
"STATION_NAME char(64),"+
"EVENT_DATETIME datetime,"+
"SCHEDULED_TIME time,"+
"EVENT_TYPE int,"+
"EVENT_SOURCE int,"+
"PLAY_SOURCE int,"+
"START_SOURCE int default 0,"+
"ONAIR_FLAG enum('N','Y') default 'N',"+
"EXT_START_TIME time,"+
"EXT_LENGTH int,"+
"EXT_CART_NAME char(32),"+
"EXT_DATA char(32),"+
"EXT_EVENT_ID char(8),"+
"EXT_ANNC_TYPE char(8),"+
"index EVENT_DATETIME_IDX(EVENT_DATETIME))"+
config->createTablePostfix();
return sql;
}
*/
QString RDCreateStackTableSql(QString name,RDConfig *config)
{
QString sql;
sql=QString().sprintf("create table if not exists `%s_STACK` (\
SCHED_STACK_ID int unsigned not null primary key,\
CART int unsigned not null,\
ARTIST varchar(255),\
SCHED_CODES varchar(255),\
SCHEDULED_AT datetime default '1000-01-01 00:00:00')",
(const char *)name.replace(" ","_"))+
config->createTablePostfix();
return sql;
}

View File

@ -1,32 +0,0 @@
// rdcreate_log.h
//
// Create a new, empty Rivendell log table.
//
// (C) Copyright 2002-2003,2016 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 "rdconfig.h"
#ifndef RDCREATE_LOG_H
#define RDCREATE_LOG_H
//void RDCreateLogTable(const QString &name,RDConfig *config);
//QString RDCreateLogTableSql(QString name,RDConfig *config);
//QString RDCreateClockTableSql(QString name,RDConfig *config);
//QString RDCreateReconciliationTableSql(QString name,RDConfig *config);
QString RDCreateStackTableSql(QString name,RDConfig *config);
#endif

View File

@ -620,7 +620,10 @@ bool RDEventLine::generateLog(QString logname,const QString &svcname,
} }
delete q; delete q;
sql=QString("SELECT MAX(SCHED_STACK_ID) from `"+svcname_rp+"_STACK`"); sql=QString("select ")+
"MAX(SCHED_STACK_ID) "+
"from STACK_LINES where "+
"SERVICE_NAME=\""+RDEscapeString(svcname)+"\"";
q=new RDSqlQuery(sql); q=new RDSqlQuery(sql);
if (q->next()) if (q->next())
{ {
@ -667,10 +670,10 @@ bool RDEventLine::generateLog(QString logname,const QString &svcname,
// Title separation // Title separation
schedCL->save(); schedCL->save();
sql=QString("select CART from `")+svcname_rp+"_STACK` where "+ sql=QString("select CART from STACK_LINES where ")+
"SERVICE_NAME=\""+RDEscapeString(svcname)+"\" && "+
QString().sprintf("SCHED_STACK_ID >= %d",stackid-titlesep); QString().sprintf("SCHED_STACK_ID >= %d",stackid-titlesep);
q=new RDSqlQuery(sql); q=new RDSqlQuery(sql);
while (q->next()) { while (q->next()) {
for(counter=0;counter<schedCL->getNumberOfItems();counter++) { for(counter=0;counter<schedCL->getNumberOfItems();counter++) {
if(q->value(0).toUInt()==schedCL->getItemCartnumber(counter)) { if(q->value(0).toUInt()==schedCL->getItemCartnumber(counter)) {
@ -686,7 +689,8 @@ bool RDEventLine::generateLog(QString logname,const QString &svcname,
// Artist separation // Artist separation
schedCL->save(); schedCL->save();
sql=QString("select ARTIST from `")+svcname_rp+"_STACK` where "+ sql=QString("select ARTIST from STACK_LINES where ")+
"SERVICE_NAME=\""+RDEscapeString(svcname)+"\" && "+
QString().sprintf("SCHED_STACK_ID >= %d",stackid-artistsep); QString().sprintf("SCHED_STACK_ID >= %d",stackid-artistsep);
q=new RDSqlQuery(sql); q=new RDSqlQuery(sql);
while (q->next()) { while (q->next()) {
@ -722,8 +726,9 @@ bool RDEventLine::generateLog(QString logname,const QString &svcname,
QString wstr=q->value(0).toString(); QString wstr=q->value(0).toString();
wstr+=" "; wstr+=" ";
wstr=wstr.left(11); wstr=wstr.left(11);
sql=QString("select CART from `")+svcname_rp+"_STACK` where "+ sql=QString("select CART from STACK_LINES where ")+
QString().sprintf("SCHED_STACK_ID > %d and ",stackid-range)+ "SERVICE_NAME=\""+RDEscapeString(svcname)+"\" && "+
QString().sprintf("SCHED_STACK_ID > %d && ",stackid-range)+
"SCHED_CODES like \"%%"+RDEscapeString(wstr)+"%%\""; "SCHED_CODES like \"%%"+RDEscapeString(wstr)+"%%\"";
q1=new RDSqlQuery(sql); q1=new RDSqlQuery(sql);
if(q1->size()>=allowed || allowed==0) { if(q1->size()>=allowed || allowed==0) {
@ -744,8 +749,10 @@ bool RDEventLine::generateLog(QString logname,const QString &svcname,
QString wstr=q->value(3).toString(); QString wstr=q->value(3).toString();
wstr+=" "; wstr+=" ";
wstr=wstr.left(11); wstr=wstr.left(11);
sql=QString().sprintf("select CART from %s_STACK \ sql=QString("select CART from STACK_LINES where ")+
where SCHED_STACK_ID = %d and SCHED_CODES like \"%%%s%%\"",(const char*)svcname_rp,(stackid-1),(const char *)wstr); "SERVICE_NAME=\""+RDEscapeString(svcname)+"\" && "+
QString().sprintf("SCHED_STACK_ID=%d && ",stackid-1)+
"SCHED_CODES like \"%"+RDEscapeString(wstr)+"%\"";
q1=new RDSqlQuery(sql); q1=new RDSqlQuery(sql);
if(q1->size()>0) { if(q1->size()>0) {
for(counter=0;counter<schedCL->getNumberOfItems();counter++) { for(counter=0;counter<schedCL->getNumberOfItems();counter++) {
@ -766,8 +773,9 @@ bool RDEventLine::generateLog(QString logname,const QString &svcname,
QString wstr=q->value(4).toString(); QString wstr=q->value(4).toString();
wstr+=" "; wstr+=" ";
wstr=wstr.left(11); wstr=wstr.left(11);
sql=QString().sprintf("select CART from %s_STACK \ sql=QString("select CART from STACK_LINES where ")+
where SCHED_STACK_ID = %d and SCHED_CODES like \"%%%s%%\"",(const char*)svcname_rp,(stackid-1),(const char *)wstr); QString().sprintf("SCHED_STACK_ID=%d && ",stackid-1)+
"SCHED_CODES like \"%"+RDEscapeString(wstr)+"%\"";
q1=new RDSqlQuery(sql); q1=new RDSqlQuery(sql);
if(q1->size()>0) { if(q1->size()>0) {
for(counter=0;counter<schedCL->getNumberOfItems();counter++) { for(counter=0;counter<schedCL->getNumberOfItems();counter++) {
@ -788,8 +796,9 @@ bool RDEventLine::generateLog(QString logname,const QString &svcname,
QString wstr=q->value(5).toString(); QString wstr=q->value(5).toString();
wstr+=" "; wstr+=" ";
wstr=wstr.left(11); wstr=wstr.left(11);
sql=QString().sprintf("select CART from %s_STACK \ sql=QString("select CART from STACK_LINES where ")+
where SCHED_STACK_ID = %d and SCHED_CODES like \"%%%s%%\"",(const char*)svcname_rp,(stackid-1),(const char *)wstr); QString().sprintf("SCHED_STACK_ID=%d && ",stackid-1)+
"SCHED_CODES like \"%"+RDEscapeString(wstr)+"%\"";
q1=new RDSqlQuery(sql); q1=new RDSqlQuery(sql);
if(q1->size()>0) { if(q1->size()>0) {
for(counter=0;counter<schedCL->getNumberOfItems();counter++) { for(counter=0;counter<schedCL->getNumberOfItems();counter++) {
@ -830,7 +839,8 @@ bool RDEventLine::generateLog(QString logname,const QString &svcname,
count++; count++;
sql=QString("insert into `")+svcname_rp+"_STACK` set "+ sql=QString("insert into STACK_LINES set ")+
"SERVICE_NAME=\""+RDEscapeString(svcname)+"\","+
"SCHEDULED_AT=now(),"+ "SCHEDULED_AT=now(),"+
QString().sprintf("SCHED_STACK_ID=%u,",stackid)+ QString().sprintf("SCHED_STACK_ID=%u,",stackid)+
QString().sprintf("CART=%u,",schedCL->getItemCartnumber(schedpos))+ QString().sprintf("CART=%u,",schedCL->getItemCartnumber(schedpos))+

View File

@ -23,7 +23,6 @@
#include "rdapplication.h" #include "rdapplication.h"
#include "rddb.h" #include "rddb.h"
#include "rdconf.h" #include "rdconf.h"
#include "rdcreate_log.h"
#include "rdescape_string.h" #include "rdescape_string.h"
#include "rdlog.h" #include "rdlog.h"
#include "rdlog_line.h" #include "rdlog_line.h"

View File

@ -2,7 +2,7 @@
// //
// Abstract Rivendell Log Events. // Abstract Rivendell Log Events.
// //
// (C) Copyright 2002-2014,2016 Fred Gleason <fredg@paravelsystems.com> // (C) Copyright 2002-2014,2016-2018 Fred Gleason <fredg@paravelsystems.com>
// //
// This program is free software; you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License version 2 as
@ -19,15 +19,15 @@
// //
#include <map> #include <map>
#include <rdapplication.h>
#include <rddb.h> #include "rd.h"
#include <rdconf.h> #include "rdapplication.h"
#include <rdlog.h> #include "rdconf.h"
#include <rdlog_event.h> #include "rddb.h"
#include <rdcreate_log.h> #include "rddebug.h"
#include <rddebug.h> #include "rdescape_string.h"
#include <rd.h> #include "rdlog.h"
#include <rdescape_string.h> #include "rdlog_event.h"
// //
// Global Classes // Global Classes

View File

@ -25,7 +25,6 @@
#include "rdapplication.h" #include "rdapplication.h"
#include "rdconf.h" #include "rdconf.h"
#include "rdcreate_log.h"
#include "rddatedecode.h" #include "rddatedecode.h"
#include "rdescape_string.h" #include "rdescape_string.h"
#include "rdlog_line.h" #include "rdlog_line.h"

View File

@ -23,7 +23,6 @@
#include "rdapplication.h" #include "rdapplication.h"
#include "rdclock.h" #include "rdclock.h"
#include "rdconf.h" #include "rdconf.h"
#include "rdcreate_log.h"
#include "rddatedecode.h" #include "rddatedecode.h"
#include "rddb.h" #include "rddb.h"
#include "rd.h" #include "rd.h"
@ -32,9 +31,6 @@
#include "rdsvc.h" #include "rdsvc.h"
#include "rdweb.h" #include "rdweb.h"
//
// Global Classes
//
RDSvc::RDSvc(QString svcname,RDStation *station,RDConfig *config,QObject *parent) RDSvc::RDSvc(QString svcname,RDStation *station,RDConfig *config,QObject *parent)
: QObject(parent) : QObject(parent)
{ {
@ -1453,9 +1449,9 @@ void RDSvc::remove(const QString &name)
} }
delete q; delete q;
QString tablename=name; sql=QString("delete from STACK_LINES where ")+
tablename.replace(" ","_"); "SERVICE_NAME=\""+RDEscapeString(name)+"\"";
rda->dropTable(tablename+"_STACK"); RDSqlQuery::apply(sql);
sql=QString("delete from ELR_LINES where ")+ sql=QString("delete from ELR_LINES where ")+
"SERVICE_NAME=\""+RDEscapeString(name)+"\""; "SERVICE_NAME=\""+RDEscapeString(name)+"\"";

View File

@ -25,7 +25,6 @@
#include <rdapplication.h> #include <rdapplication.h>
#include <rdconf.h> #include <rdconf.h>
#include <rdcreate_log.h>
#include <rddb.h> #include <rddb.h>
#include <rddebug.h> #include <rddebug.h>
#include <rdlistviewitem.h> #include <rdlistviewitem.h>
@ -45,7 +44,6 @@
#include "../icons/traffic.xpm" #include "../icons/traffic.xpm"
#include "../icons/music.xpm" #include "../icons/music.xpm"
ListLog::ListLog(RDLogPlay *log,RDCae *cae,int id,bool allow_pause, ListLog::ListLog(RDLogPlay *log,RDCae *cae,int id,bool allow_pause,
QWidget *parent) QWidget *parent)
: QWidget(parent) : QWidget(parent)

View File

@ -34,7 +34,6 @@
#include <rdadd_log.h> #include <rdadd_log.h>
#include <rdapplication.h> #include <rdapplication.h>
#include <rdconf.h> #include <rdconf.h>
#include <rdcreate_log.h>
#include <rddatedialog.h> #include <rddatedialog.h>
#include <rddb.h> #include <rddb.h>
#include <rddebug.h> #include <rddebug.h>

View File

@ -25,7 +25,6 @@
#include <dbversion.h> #include <dbversion.h>
#include <rdapplication.h> #include <rdapplication.h>
#include <rdcreate_log.h>
#include <rddatedecode.h> #include <rddatedecode.h>
#include <rdlog.h> #include <rdlog.h>
#include <rdlog_event.h> #include <rdlog_event.h>

View File

@ -34,7 +34,6 @@
#include <rd.h> #include <rd.h>
#include <rdapplication.h> #include <rdapplication.h>
#include <rdconf.h> #include <rdconf.h>
#include <rdcreate_log.h>
#include <rddb.h> #include <rddb.h>
#include <rdescape_string.h> #include <rdescape_string.h>
#include <rdevent.h> #include <rdevent.h>

View File

@ -2,7 +2,7 @@
// //
// Edit Rivendell Log Eventline // Edit Rivendell Log Eventline
// //
// (C) Copyright 2002-2004,2016 Fred Gleason <fredg@paravelsystems.com> // (C) Copyright 2002-2004,2016-2018 Fred Gleason <fredg@paravelsystems.com>
// //
// This program is free software; you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License version 2 as
@ -25,16 +25,14 @@
#include <qmessagebox.h> #include <qmessagebox.h>
#include <qpushbutton.h> #include <qpushbutton.h>
#include <rddb.h>
#include <rd.h> #include <rd.h>
#include <rddb.h>
#include <rdevent.h> #include <rdevent.h>
#include <rdcreate_log.h>
#include <rdtextvalidator.h> #include <rdtextvalidator.h>
#include <list_events.h> #include <list_events.h>
#include <edit_eventline.h> #include <edit_eventline.h>
EditEventLine::EditEventLine(RDEventLine *eventline,RDClock *clock,int line, EditEventLine::EditEventLine(RDEventLine *eventline,RDClock *clock,int line,
QWidget *parent) QWidget *parent)
: QDialog(parent,"",true) : QDialog(parent,"",true)

View File

@ -2,7 +2,7 @@
// //
// Edit Rivendell Log Grid // Edit Rivendell Log Grid
// //
// (C) Copyright 2002-2016 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 // 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 // it under the terms of the GNU General Public License version 2 as
@ -30,15 +30,14 @@
#include <qcolordialog.h> #include <qcolordialog.h>
#include <qsignalmapper.h> #include <qsignalmapper.h>
#include <rddb.h>
#include <rd.h> #include <rd.h>
#include <rddb.h>
#include <rdescape_string.h> #include <rdescape_string.h>
#include <rdevent.h> #include <rdevent.h>
#include <rdcreate_log.h>
#include <edit_grid.h> #include "edit_grid.h"
#include <list_clocks.h> #include "list_clocks.h"
#include <edit_clock.h> #include "edit_clock.h"
EditGrid::EditGrid(QString servicename,QWidget *parent) EditGrid::EditGrid(QString servicename,QWidget *parent)
: QDialog(parent,"",true) : QDialog(parent,"",true)

View File

@ -2,7 +2,7 @@
// //
// Edit a Rivendell LogManager Note // Edit a Rivendell LogManager Note
// //
// (C) Copyright 2002-2004,2016 Fred Gleason <fredg@paravelsystems.com> // (C) Copyright 2002-2004,2016-2018 Fred Gleason <fredg@paravelsystems.com>
// //
// This program is free software; you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License version 2 as
@ -27,9 +27,8 @@
#include <rd.h> #include <rd.h>
#include <rdevent.h> #include <rdevent.h>
#include <rdcreate_log.h>
#include <edit_note.h> #include "edit_note.h"
EditNote::EditNote(QString *text,QWidget *parent) EditNote::EditNote(QString *text,QWidget *parent)
: QDialog(parent,"",true) : QDialog(parent,"",true)

View File

@ -2,7 +2,7 @@
// //
// Edit a Rivendell LogManager Track // Edit a Rivendell LogManager Track
// //
// (C) Copyright 2002-2004,2016 Fred Gleason <fredg@paravelsystems.com> // (C) Copyright 2002-2004,2016-2018 Fred Gleason <fredg@paravelsystems.com>
// //
// This program is free software; you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License version 2 as
@ -27,9 +27,8 @@
#include <rd.h> #include <rd.h>
#include <rdevent.h> #include <rdevent.h>
#include <rdcreate_log.h>
#include <edit_track.h> #include "edit_track.h"
EditTrack::EditTrack(QString *text,QWidget *parent) EditTrack::EditTrack(QString *text,QWidget *parent)
: QDialog(parent,"",true) : QDialog(parent,"",true)

View File

@ -29,7 +29,6 @@
#include <rd.h> #include <rd.h>
#include <rdapplication.h> #include <rdapplication.h>
#include <rdcreate_log.h>
#include <rddatedecode.h> #include <rddatedecode.h>
#include <rddb.h> #include <rddb.h>
#include <rddatedialog.h> #include <rddatedialog.h>
@ -49,7 +48,6 @@
#include "../icons/greenball.xpm" #include "../icons/greenball.xpm"
#include "../icons/redball.xpm" #include "../icons/redball.xpm"
GenerateLog::GenerateLog(QWidget *parent,int cmd_switch,QString *cmd_service, GenerateLog::GenerateLog(QWidget *parent,int cmd_switch,QString *cmd_service,
QDate *cmd_date) QDate *cmd_date)
: QDialog(parent,"",true) : QDialog(parent,"",true)
@ -348,18 +346,6 @@ void GenerateLog::createData()
RDSqlQuery *q; RDSqlQuery *q;
srand(QTime::currentTime().msec()); srand(QTime::currentTime().msec());
sql=RDCreateStackTableSql(gen_service_box->currentText().replace(" ","_"),
rda->config());
q=new RDSqlQuery(sql);
if(!q->isActive()) {
fprintf(stderr,"SQL: %s\n",(const char *)sql);
fprintf(stderr,"SQL Error: %s\n",
(const char *)q->lastError().databaseText());
delete q;
}
delete q;
connect(svc,SIGNAL(generationProgress(int)), connect(svc,SIGNAL(generationProgress(int)),
gen_progress_dialog,SLOT(setProgress(int))); gen_progress_dialog,SLOT(setProgress(int)));
if(!svc->generateLog(gen_date_edit->date(), if(!svc->generateLog(gen_date_edit->date(),

View File

@ -28,7 +28,6 @@
#include <rd.h> #include <rd.h>
#include <rdapplication.h> #include <rdapplication.h>
#include <rdcreate_log.h>
#include <rddb.h> #include <rddb.h>
#include <rdescape_string.h> #include <rdescape_string.h>
#include <rdevent.h> #include <rdevent.h>

View File

@ -28,7 +28,6 @@
#include <rd.h> #include <rd.h>
#include <rdapplication.h> #include <rdapplication.h>
#include <rdcreate_log.h>
#include <rddb.h> #include <rddb.h>
#include <rdescape_string.h> #include <rdescape_string.h>
#include <rdevent.h> #include <rdevent.h>

View File

@ -27,11 +27,10 @@
#include <rddb.h> #include <rddb.h>
#include <rd.h> #include <rd.h>
#include <rdevent.h> #include <rdevent.h>
#include <rdcreate_log.h>
#include <list_grids.h> #include "edit_grid.h"
#include <edit_grid.h> #include "globals.h"
#include <globals.h> #include "list_grids.h"
ListGrids::ListGrids(QWidget *parent) ListGrids::ListGrids(QWidget *parent)
: QDialog(parent,"",true) : QDialog(parent,"",true)

View File

@ -23,7 +23,6 @@
#include <qapplication.h> #include <qapplication.h>
#include <rdapplication.h> #include <rdapplication.h>
#include <rdcreate_log.h>
#include <rddatedecode.h> #include <rddatedecode.h>
#include <rdlog.h> #include <rdlog.h>
#include <rdsvc.h> #include <rdsvc.h>
@ -62,8 +61,6 @@ LogObject::LogObject(const QString &svcname,int start_offset,
void LogObject::userData() void LogObject::userData()
{ {
QString err_msg; QString err_msg;
QString sql;
RDSqlQuery *q;
QString report; QString report;
QString unused_report; QString unused_report;
QString svcname_table=log_service_name; QString svcname_table=log_service_name;
@ -96,14 +93,6 @@ void LogObject::userData()
SendNotification(RDNotification::DeleteAction,log->name()); SendNotification(RDNotification::DeleteAction,log->name());
log->removeTracks(rda->station(),rda->user(),rda->config()); log->removeTracks(rda->station(),rda->user(),rda->config());
srand(QTime::currentTime().msec()); srand(QTime::currentTime().msec());
sql=RDCreateStackTableSql(svcname_table,rda->config());
q=new RDSqlQuery(sql);
if(!q->isActive()) {
fprintf(stderr,"SQL: %s\n",(const char *)sql);
fprintf(stderr,"SQL Error: %s\n",
(const char *)q->lastError().databaseText());
}
delete q;
if(!svc->generateLog(start_date, if(!svc->generateLog(start_date,
RDDateDecode(svc->nameTemplate(),start_date, RDDateDecode(svc->nameTemplate(),start_date,
rda->station(),rda->config(),svc->name()), rda->station(),rda->config(),svc->name()),

View File

@ -43,7 +43,6 @@
#include <rd.h> #include <rd.h>
#include <rdapplication.h> #include <rdapplication.h>
#include <rdcheck_daemons.h> #include <rdcheck_daemons.h>
#include <rdcreate_log.h>
#include <rdcmd_switch.h> #include <rdcmd_switch.h>
#include <rddatedecode.h> #include <rddatedecode.h>
#include <rddbheartbeat.h> #include <rddbheartbeat.h>

View File

@ -2,7 +2,7 @@
// //
// Edit a Rivendell LogManager Note // Edit a Rivendell LogManager Note
// //
// (C) Copyright 2002-2004,2016 Fred Gleason <fredg@paravelsystems.com> // (C) Copyright 2002-2004,2016-2018 Fred Gleason <fredg@paravelsystems.com>
// //
// This program is free software; you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License version 2 as
@ -24,13 +24,12 @@
#include <qpainter.h> #include <qpainter.h>
#include <qmessagebox.h> #include <qmessagebox.h>
#include <rddb.h>
#include <rd.h> #include <rd.h>
#include <rddb.h>
#include <rdevent.h> #include <rdevent.h>
#include <rdcreate_log.h>
#include <rdtextvalidator.h> #include <rdtextvalidator.h>
#include <rename_item.h> #include "rename_item.h"
RenameItem::RenameItem(QString *text,QString table,QWidget *parent) RenameItem::RenameItem(QString *text,QString table,QWidget *parent)
: QDialog(parent,"",true) : QDialog(parent,"",true)

View File

@ -20,7 +20,6 @@
#include <rdapplication.h> #include <rdapplication.h>
#include <rdconf.h> #include <rdconf.h>
#include <rdcreate_log.h>
#include <rdescape_string.h> #include <rdescape_string.h>
#include <rdsvc.h> #include <rdsvc.h>

View File

@ -30,7 +30,6 @@
#include <dbversion.h> #include <dbversion.h>
#include <rdcart.h> #include <rdcart.h>
#include <rdclock.h> #include <rdclock.h>
#include <rdcreate_log.h>
#include <rdcut.h> #include <rdcut.h>
#include <rddb.h> #include <rddb.h>
#include <rdescape_string.h> #include <rdescape_string.h>

View File

@ -38,6 +38,62 @@ bool MainObject::RevertSchema(int cur_schema,int set_schema,QString *err_msg) co
// //
//
// Revert 293
//
if((cur_schema==293)&&(set_schema<cur_schema)) {
sql=QString("select NAME from SERVICES");
q=new RDSqlQuery(sql);
while(q->next()) {
QString tablename=q->value(0).toString()+"_STACK";
tablename.replace(" ","_");
sql=QString("create table `")+tablename+"` ("+
"SCHED_STACK_ID int unsigned not null primary key,"+
"CART int unsigned not null,"+
"ARTIST varchar(255),"+
"SCHED_CODES varchar(255),"+
"SCHEDULED_AT datetime default '1000-01-01 00:00:00')"+
db_table_create_postfix;
if(!RDSqlQuery::apply(sql,err_msg)) {
return false;
}
sql=QString("select ")+
"SCHED_STACK_ID,"+ // 00
"CART,"+ // 01
"ARTIST,"+ // 02
"SCHED_CODES,"+ // 03
"SCHEDULED_AT "+ // 04
"from STACK_LINES where "+
"SERVICE_NAME=\""+RDEscapeString(q->value(0).toString())+"\"";
q1=new RDSqlQuery(sql,false);
while(q1->next()) {
sql=QString("insert into `")+tablename+"` set "+
QString().sprintf("SCHED_STACK_ID=%u,",q1->value(0).toUInt())+
QString().sprintf("CART=%u,",q1->value(1).toUInt())+
"ARTIST=\""+RDEscapeString(q1->value(2).toString())+"\","+
"SCHED_CODES=\""+RDEscapeString(q1->value(3).toString())+"\","+
"SCHEDULED_AT=\""+RDEscapeString(q1->value(4).toDateTime().
toString("yyyy-MM-dd hh:mm:ss"))+"\"";
if(!RDSqlQuery::apply(sql,err_msg)) {
return false;
}
}
sql=QString("update `")+tablename+"` set "+
"SCHEDULED_AT=\"1000-01-01 00:00:00\" where "+
"SCHEDULED_AT=\"1752-09-14 00:00:00\"";
if(!RDSqlQuery::apply(sql,err_msg)) {
return false;
}
}
delete q;
if(!DropTable("STACK_LINES",err_msg)) {
return false;
}
WriteSchemaVersion(--cur_schema);
}
// //
// Revert 292 // Revert 292
// //

View File

@ -132,7 +132,7 @@ void MainObject::InitializeSchemaMap() {
global_version_map["2.17"]=268; global_version_map["2.17"]=268;
global_version_map["2.18"]=272; global_version_map["2.18"]=272;
global_version_map["2.19"]=275; global_version_map["2.19"]=275;
global_version_map["2.20"]=292; global_version_map["2.20"]=293;
} }

View File

@ -7722,6 +7722,77 @@ bool MainObject::UpdateSchema(int cur_schema,int set_schema,QString *err_msg) co
WriteSchemaVersion(++cur_schema); WriteSchemaVersion(++cur_schema);
} }
if((cur_schema<293)&&(set_schema>cur_schema)) {
sql=QString("create table if not exists STACK_LINES (")+
"ID int unsigned not null auto_increment primary key,"+
"SCHED_STACK_ID int unsigned not null,"+
"SERVICE_NAME char(10) not null,"+
"CART int unsigned not null,"+
"ARTIST varchar(255),"+
"SCHED_CODES varchar(255),"+
"SCHEDULED_AT datetime default '1752-09-14 00:00:00',"+
"index SERVICE_NAME_IDX(SERVICE_NAME),"+
"index SCHED_STACK_ID_IDX(SERVICE_NAME,SCHED_STACK_ID,SCHED_CODES))"+
db_table_create_postfix;
if(!RDSqlQuery::apply(sql,err_msg)) {
return false;
}
sql=QString("select NAME from SERVICES");
q=new RDSqlQuery(sql,false);
while(q->next()) {
QString tablename=q->value(0).toString()+"_STACK";
tablename.replace(" ","_");
//
// 9/14/1752 is the earliest valid QDate
//
sql=QString("update `")+tablename+"` set "+
"SCHEDULED_AT=\"1752-09-14 00:00:00\" where "+
"SCHEDULED_AT<\"1752-09-14 00:00:00\"";
if(!RDSqlQuery::apply(sql,err_msg)) {
return false;
}
sql=QString("select ")+
"SCHED_STACK_ID,"+ // 00
"CART,"+ // 01
"ARTIST,"+ // 02
"SCHED_CODES,"+ // 03
"SCHEDULED_AT "+ // 04
"from `"+tablename+"` "+
"order by SCHEDULED_AT";
q1=new RDSqlQuery(sql,false);
while(q1->next()) {
sql=QString("insert into STACK_LINES set ")+
"SERVICE_NAME=\""+RDEscapeString(q->value(0).toString())+"\","+
QString().sprintf("SCHED_STACK_ID=%u,",q1->value(0).toUInt())+
QString().sprintf("CART=%u,",q1->value(1).toUInt())+
"ARTIST=\""+RDEscapeString(q1->value(2).toString())+"\","+
"SCHED_CODES=\""+RDEscapeString(q1->value(3).toString())+"\","+
"SCHEDULED_AT=\""+RDEscapeString(q1->value(4).toDateTime().
toString("yyyy-MM-dd hh:mm:ss"))+"\"";
if(!RDSqlQuery::apply(sql,err_msg)) {
return false;
}
}
delete q1;
if(!DropTable(tablename,err_msg)) {
return false;
}
}
delete q;
sql=QString("show tables where ")+
"Tables_in_"+db_config->mysqlDbname()+" like \"%_STACK\"";
q=new RDSqlQuery(sql);
while(q->next()) {
if(DropTable(q->value(0).toString(),err_msg)) {
fprintf(stderr,"rddbmgr: dropping orphaned STACK table \"%s\"\n",
(const char *)q->value(0).toString());
}
}
delete q;
WriteSchemaVersion(++cur_schema);
}

View File

@ -220,7 +220,6 @@ void MainObject::PurgeElr()
{ {
QString sql; QString sql;
RDSqlQuery *q; RDSqlQuery *q;
RDSqlQuery *q1;
QDateTime dt=QDateTime(QDate::currentDate(),QTime::currentTime()); QDateTime dt=QDateTime(QDate::currentDate(),QTime::currentTime());
sql=QString("select ")+ sql=QString("select ")+
@ -319,19 +318,21 @@ void MainObject::PurgeStacks()
sql="select NAME from SERVICES"; sql="select NAME from SERVICES";
q=new RDSqlQuery(sql); q=new RDSqlQuery(sql);
while(q->next()) { while(q->next()) {
QString tablename=q->value(0).toString()+"_STACK"; sql=QString().sprintf("select MAX(SCHED_STACK_ID) from STACK_LINES where ")+
tablename.replace(" ","_"); "SERVICE_NAME=\""+RDEscapeString(q->value(0).toString())+"\"";
sql=QString().sprintf("SELECT MAX(SCHED_STACK_ID) from %s",(const char*)tablename);
q1=new RDSqlQuery(sql); q1=new RDSqlQuery(sql);
if (q1->next()) if (q1->next()) {
{
stackid=q1->value(0).toUInt(); stackid=q1->value(0).toUInt();
if (stackid-stacksize > 0) { if (stackid-stacksize > 0) {
sql=QString().sprintf("DELETE from `%s` where SCHED_STACK_ID <= %d", (const char*)tablename, stackid-stacksize); sql=QString("delete from STACK_LINES where ")+
q2=new RDSqlQuery(sql); "SERVICE_NAME=\""+RDEscapeString(q->value(0).toString())+"\" && "+
delete q2; QString().sprintf("SCHED_STACK_ID<=%d",stackid-stacksize);
RDSqlQuery::apply(sql);
sql=QString().sprintf("UPDATE `%s` SET SCHED_STACK_ID=SCHED_STACK_ID-%d", (const char*)tablename, stackid-stacksize); sql=QString("update STACK_LINES set ")+
QString().sprintf("SCHED_STACK_ID=SCHED_STACK_ID-%d where ",
stackid-stacksize)+
"SERVICE_NAME=\""+RDEscapeString(q->value(0).toString())+"\"";
q2=new RDSqlQuery(sql); q2=new RDSqlQuery(sql);
delete q2; delete q2;
} }

View File

@ -35,7 +35,6 @@
#include <rdaudioinfo.h> #include <rdaudioinfo.h>
#include <rddb.h> #include <rddb.h>
#include <rdcart.h> #include <rdcart.h>
#include <rdcreate_log.h>
#include <rdcut.h> #include <rdcut.h>
#include <rdescape_string.h> #include <rdescape_string.h>
#include <rdgroup.h> #include <rdgroup.h>

View File

@ -26,7 +26,6 @@
#include <rdapplication.h> #include <rdapplication.h>
#include <rdconf.h> #include <rdconf.h>
#include <rdcreate_log.h>
#include <rddb.h> #include <rddb.h>
#include <rdescape_string.h> #include <rdescape_string.h>
#include <rdformpost.h> #include <rdformpost.h>