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

* Added an 'ELR_LINES' table to the database.
	* Incremented the database version to 289.
	* Removed the 'RDSvc::serviceTableName()' method.
This commit is contained in:
Fred Gleason
2018-07-05 08:52:38 -04:00
parent 300aebdc04
commit db70aa4550
32 changed files with 631 additions and 392 deletions

View File

@@ -2,7 +2,7 @@
//
// List Rivendell Services and Report Ages
//
// (C) Copyright 2002-2005,2016 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2002-2005,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
@@ -21,12 +21,14 @@
#include <qmessagebox.h>
#include <qdatetime.h>
#include <rdlog.h>
#include <rddb.h>
#include <list_svcs.h>
#include <svc_rec_dialog.h>
#include <pick_report_dates.h>
#include <globals.h>
#include <rdescape_string.h>
#include <rdlog.h>
#include "globals.h"
#include "list_svcs.h"
#include "svc_rec_dialog.h"
#include "pick_report_dates.h"
ListSvcs::ListSvcs(QWidget *parent)
: QDialog(parent,"",true)
@@ -153,7 +155,6 @@ void ListSvcs::resizeEvent(QResizeEvent *e)
void ListSvcs::RefreshList()
{
RDSqlQuery *q1;
QString tablename;
QListViewItem *item;
list_log_list->clear();
QString sql="select NAME from SERVICES order by NAME";
@@ -162,10 +163,9 @@ void ListSvcs::RefreshList()
while(q->next()) {
item=new QListViewItem(list_log_list);
item->setText(0,q->value(0).toString());
tablename=q->value(0).toString();
tablename.replace(" ","_");
sql=QString().sprintf("select EVENT_DATETIME from `%s_SRT` \
order by EVENT_DATETIME",(const char *)tablename);
sql=QString("select EVENT_DATETIME from ELR_LINES where ")+
"SERVICE_NAME=\""+RDEscapeString(q->value(0).toString())+"\" "+
"order by EVENT_DATETIME";
q1=new RDSqlQuery(sql);
if(q1->first()) {
item->setText(1,q1->value(0).toDate().toString("MM/dd/yyyy"));
@@ -183,10 +183,9 @@ void ListSvcs::RefreshLine(QListViewItem *item)
{
QString sql;
RDSqlQuery *q;
QString tablename=item->text(0);
tablename.replace(" ","_");
sql=QString().sprintf("select EVENT_DATETIME from `%s_SRT` \
order by EVENT_DATETIME",(const char *)tablename);
sql=QString("select EVENT_DATETIME from ELR_LINES where ")+
"SERVICE_NAME=\""+RDEscapeString(item->text(0))+"\" "+
"order by EVENT_DATETIME";
q=new RDSqlQuery(sql);
if(q->first()) {
item->setText(1,q->value(0).toDate().toString("MM/dd/yyyy"));

View File

@@ -22,8 +22,11 @@
#include <qstring.h>
#include <qlabel.h>
#include <qpalette.h>
#include <rddb.h>
#include <svc_rec.h>
#include <rdescape_string.h>
#include "svc_rec.h"
//
// Global Classes
@@ -46,14 +49,12 @@ SvcRec::SvcRec(const QString &svcname,QWidget *parent)
//
// Generate Date Boundaries
//
pick_tablename=svcname;
pick_tablename.replace(" ","_");
QDate current_date=QDate::currentDate();
pick_high_year=current_date.year();
pick_low_year=pick_high_year;
sql=QString().sprintf("select EVENT_DATETIME from `%s_SRT`\
order by EVENT_DATETIME",
(const char *)pick_tablename);
sql=QString("select EVENT_DATETIME from ELR_LINES where ")+
"SERVICE_NAME=\""+RDEscapeString(svcname)+"\" "+
"order by EVENT_DATETIME";
q=new RDSqlQuery(sql);
if(q->first()) {
pick_low_year=q->value(0).toDate().year();
@@ -214,14 +215,10 @@ void SvcRec::deleteDay()
QString sql;
RDSqlQuery *q;
QString tablename=pick_service_name;
tablename.replace(" ","_");
sql=QString().sprintf("delete from `%s_SRT` where \
(EVENT_DATETIME>=\"%s\")&&\
(EVENT_DATETIME<=\"%s\")",
(const char *)tablename,
(const char *)date().toString("yyyy-MM-dd 00:00:00"),
(const char *)date().toString("yyyy-MM-dd 23:59:59"));
sql=QString("delete from ELR_LINES where ")+
"SERVICE_NAME=\""+RDEscapeString(pick_service_name)+"\" && "+
"EVENT_DATETIME>=\""+date().toString("yyyy-MM-dd 00:00:00")+"\" && "+
"EVENT_DATETIME<\""+date().addDays(1).toString("yyyy-MM-dd 00:00:00")+"\"";
q=new RDSqlQuery(sql);
delete q;
GetActiveDays(pick_date);
@@ -403,13 +400,11 @@ void SvcRec::GetActiveDays(const QDate &date)
QString sql;
RDSqlQuery *q;
for(int i=0;i<=31;i++) {
sql=QString().sprintf("select ID from `%s_SRT` where \
(EVENT_DATETIME>=\"%s-%02d 00:00:00\")&&\
(EVENT_DATETIME<=\"%s-%02d 23:59:59\")",
(const char *)pick_tablename,
(const char *)date.toString("yyyy-MM"),i+1,
(const char *)date.toString("yyyy-MM"),i+1);
for(int i=0;i<=date.daysInMonth();i++) {
sql=QString("select ID from ELR_LINES where ")+
"SERVICE_NAME=\""+RDEscapeString(pick_service_name)+"\" && "+
"(EVENT_DATETIME>=\""+date.toString("yyyy-MM")+QString().sprintf("-%02d 00:00:00\")&&",i+1)+
"(EVENT_DATETIME<=\""+date.toString("yyyy-MM")+QString().sprintf("-%02d 23:59:59\")",i+1);
q=new RDSqlQuery(sql);
pick_active_days[i]=q->first();
delete q;

View File

@@ -75,7 +75,6 @@ class SvcRec : public QWidget
QSpinBox *pick_year_spin;
QLabel *pick_date_label[6][7];
QDate pick_date;
QString pick_tablename;
int pick_low_year;
int pick_high_year;
bool pick_active_days[31];