Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
857c49c
Used gemstone TimeFilter
Tenacs Jul 18, 2024
186f000
deleted ReportTimeFilter file and fixed TimeFilter props
Tenacs Jul 19, 2024
4bd04c4
wrapped EventTypeFilter in <Li> tag
Tenacs Jul 31, 2024
8fddbfd
updated packages
Tenacs Aug 13, 2024
1a789a8
formatted and added 'key' props
Aug 28, 2024
a87eef3
fixed optional prop
Sep 4, 2024
c1c345e
works with updated TimeFilter
Sep 4, 2024
37f20c3
removing center from selector
Sep 4, 2024
f3ce7c8
removed center from global.d.ts
Sep 4, 2024
3fbc5b2
imports, and formatting
Sep 6, 2024
325692f
time window was wrong
Sep 6, 2024
b2ec27a
removed a comment
Sep 6, 2024
a92faac
updated packages
Sep 9, 2024
1fb47c4
updated EvenSearchNavbar.tsx
Sep 9, 2024
306e3a2
SVGIcons not available anymore
Sep 9, 2024
5ddd007
TrendData startEnd Time Update
Sep 9, 2024
01e963a
updated global types
Sep 9, 2024
4357ae4
TrendDate time display changes
Sep 9, 2024
4da08c1
EventSearch time update
Sep 9, 2024
7e18afd
Updated front end to start-end
Sep 12, 2024
7cc6f64
initial pass on backend for start-end
Sep 12, 2024
1fc54b3
added global format
Sep 12, 2024
13af5ae
BreakerReport uses global time format
Sep 12, 2024
a4a8067
CapBankReport using global filter
Sep 12, 2024
a3d3596
DER using global time format
Sep 12, 2024
13656ad
EventSearch uses global time format. Changed all to useEffect
Sep 12, 2024
0cf28d7
RelayReport uses global time format
Sep 12, 2024
fc49be2
TrendMarkerTable uses global time format
Sep 12, 2024
a8c6df3
TrendData settings updated to global time format
Sep 12, 2024
1235def
TrendData is using global time format
Sep 12, 2024
30caf4b
Meter Activity uses global time format
Sep 12, 2024
654976f
Updated Meteractivity
Sep 12, 2024
6e0e166
updated breakerreport class
Sep 12, 2024
26e2ab6
fixed breakerreportnavbar class
Sep 13, 2024
8f9939c
date time filter matches up with backend
Sep 13, 2024
d531fbd
package-lock and package.json were unadded?
Sep 13, 2024
a9b4007
package-lock webconfig package.json were unadded?
Sep 13, 2024
b8f1c3a
removed useEffects
Sep 13, 2024
a78acee
simplified state
Sep 16, 2024
0868413
npm ci got removed from build script
Sep 16, 2024
4fe2cd7
EventSearchNavbar format
Sep 20, 2024
446945b
removed unused imports for linter
Sep 20, 2024
6146e95
final error fixes, lining up requests with db
Sep 24, 2024
ab73e5d
lint fixes
Sep 24, 2024
3b01d5d
Update Submodule Pointer
gsfbuildbot Jan 30, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions SEBrowser/Controllers/CapBankReport/CapBankReportController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,6 @@ public DataTable GetSubstationData()
{
using (AdoDataConnection connection = new("systemSettings"))
{


DataTable table = new();

using (IDbCommand sc = connection.Connection.CreateCommand())
Expand Down Expand Up @@ -205,13 +203,12 @@ public DataTable GetEventTable()
{
Dictionary<string, string> query = Request.QueryParameters();
int capBankId = int.Parse(query["capBankId"]);
DateTime dateTime = DateTime.ParseExact(query["date"] + " " + query["time"], "MM/dd/yyyy HH:mm:ss.fff", new CultureInfo("en-US"));
string timeWindowUnits = ((TimeWindowUnits)int.Parse(query["timeWindowUnits"])).GetDescription();
int windowSize = int.Parse(query["windowSize"]);
DateTime start = DateTime.ParseExact(query["start"], "MM/dd/yyyy HH:mm:ss.fff", new CultureInfo("en-US"));
DateTime end = DateTime.ParseExact(query["end"], "MM/dd/yyyy HH:mm:ss.fff", new CultureInfo("en-US"));
int selectedBank = int.Parse(query["bankNum"]);


string timeRestriction = $"(CBAnalyticResult.Time BETWEEN DATEADD({ timeWindowUnits}, { (-1 * windowSize)}, '{dateTime}') AND DATEADD({ timeWindowUnits}, { (windowSize)}, '{dateTime}'))";
string timeRestriction = $"(CBAnalyticResult.Time BETWEEN '{start}' AND '{end}')";
string capBankRestriction = $"((SELECT AssetID FROM EVENT WHERE Event.ID = CBAnalyticResult.EventID) = {capBankId})";
string bankNumRestriction = $"(CBAnalyticResult.EnergizedBanks = {selectedBank} OR CBAnalyticResult.DeEnergizedBanks = {selectedBank})";
string otherFilter = ProcessFilter(query);
Expand Down Expand Up @@ -293,13 +290,12 @@ public TrendingResponse GetTrendData()
{
Dictionary<string, string> query = Request.QueryParameters();
int capBankId = int.Parse(query["capBankId"]);
DateTime dateTime = DateTime.ParseExact(query["date"] + " " + query["time"], "MM/dd/yyyy HH:mm:ss.fff", new CultureInfo("en-US"));
string timeWindowUnits = ((TimeWindowUnits)int.Parse(query["timeWindowUnits"])).GetDescription();
int windowSize = int.Parse(query["windowSize"]);
DateTime start = DateTime.ParseExact(query["start"], "MM/dd/yyyy HH:mm:ss.fff", new CultureInfo("en-US"));
DateTime end = DateTime.ParseExact(query["end"], "MM/dd/yyyy HH:mm:ss.fff", new CultureInfo("en-US"));
int selectedBank = int.Parse(query["bankNum"]);


string timeRestriction = $"(CBAnalyticResult.Time BETWEEN DATEADD({ timeWindowUnits}, { (-1 * windowSize)}, '{dateTime}') AND DATEADD({ timeWindowUnits}, { (windowSize)}, '{dateTime}'))";
string timeRestriction = $"(CBAnalyticResult.Time BETWEEN '{start}' AND '{end}')";
string capBankRestriction = $"((SELECT AssetID FROM EVENT WHERE Event.ID = CBAnalyticResult.EventID) = {capBankId})";
string bankNumRestriction = $"(CBAnalyticResult.EnergizedBanks = {selectedBank} OR CBAnalyticResult.DeEnergizedBanks = {selectedBank})";
string bankNumAfterRestriction = $"(CBAnalyticResult.StepPost = {selectedBank})";
Expand Down
7 changes: 3 additions & 4 deletions SEBrowser/Controllers/DERReport/DERReportController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,8 @@ public IHttpActionResult GetRegulations()
public class DERReportPostRequest
{
public List<int> DERIDs { get; set; }
public DateTime Time { get; set; }
public int Window { get; set; }
public TimeWindowUnits TimeWindowUnit { get; set; }
public DateTime StartTime { get; set; }
public DateTime EndTime { get; set; }
public List<string> Regulations { get; set; }

}
Expand All @@ -264,7 +263,7 @@ DERAnalyticResult JOIN
ChannelDetail ON DERAnalyticResult.ChannelID = ChannelDetail.ID
WHERE
Asset.ID IN ({(content.DERIDs.Any() ? string.Join(",", content.DERIDs) : "-1")}) AND
(DERAnalyticResult.Time BETWEEN DATEADD({ content.TimeWindowUnit}, { (-1 * content.Window)}, '{content.Time}') AND DATEADD({ content.TimeWindowUnit}, { (content.Window)}, '{content.Time}')) AND
(DERAnalyticResult.Time BETWEEN DATEADD('{content.StartTime}') AND DATEADD('{content.EndTime}')) AND
DERAnalyticResult.Regulation IN ({(content.Regulations.Any() ? string.Join(",", content.Regulations.Select(s => "'" +s + "'")) : "-1")})

ORDER BY DERAnalyticResult.Time";
Expand Down
102 changes: 50 additions & 52 deletions SEBrowser/Controllers/OpenXDAController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Globalization;
using System.IO;
using System.Linq;
Expand Down Expand Up @@ -116,10 +117,8 @@ static OpenXDAController()

public class EventSearchPostData
{
public string date { get; set; }
public string time { get; set; }
public double windowSize { get; set; }
public int timeWindowUnits { get; set; }
public string start { get; set; }
public string end { get; set; }
public double durationMin { get; set; }
public double durationMax { get; set; }
public Phase phases { get; set; }
Expand Down Expand Up @@ -176,8 +175,9 @@ public DataTable GetEventSearchData(EventSearchPostData postData)
{
using (AdoDataConnection connection = new(SettingsCategory))
{
DateTime dateTime = DateTime.ParseExact(postData.date + " " + postData.time, "MM/dd/yyyy HH:mm:ss.fff", new CultureInfo("en-US"));

DateTime startTime = DateTime.ParseExact(postData.start, "MM/dd/yyyy HH:mm:ss.fff", new CultureInfo("en-US"));
DateTime endTime = DateTime.ParseExact(postData.end, "MM/dd/yyyy HH:mm:ss.fff", new CultureInfo("en-US"));

string eventType = (postData.typeIDs is null) ? null : getEventTypeFilter(postData);
string phase = (postData.phases is null) ? null : getPhaseFilter(postData);
string eventCharacteristic = getEventCharacteristicFilter(postData);
Expand All @@ -195,52 +195,52 @@ public DataTable GetEventSearchData(EventSearchPostData postData)

string query =
$@"SELECT TOP {postData.numberResults ?? "100"}
{Collumns}
FROM
(
SELECT
Event.ID EventID,
EventWorstDisturbance.WorstDisturbanceID DisturbanceID,
FaultSummary.FaultNumber FaultID
FROM
Event JOIN
EventType ON Event.EventTypeID = EventType.ID LEFT OUTER JOIN
EventWorstDisturbance ON
EventWorstDisturbance.EventID = Event.ID AND
EventType.Name IN ('Sag', 'Swell', 'Interruption', 'Transient') LEFT OUTER JOIN
FaultGroup ON
FaultGroup.EventID = Event.ID AND
COALESCE(FaultGroup.FaultDetectionLogicResult, 0) <> 0 LEFT OUTER JOIN
FaultSummary ON
FaultSummary.EventID = Event.ID AND
FaultSummary.IsSelectedAlgorithm <> 0 AND
(
FaultGroup.ID IS NOT NULL OR
(
FaultSummary.IsValid <> 0 AND
FaultSummary.IsSuppressed = 0
)
) AND
EventType.Name IN ('Fault', 'RecloseIntoFault')
WHERE
({getTimeFilter(postData)}) AND
{Collumns}
FROM
(
SELECT
Event.ID EventID,
EventWorstDisturbance.WorstDisturbanceID DisturbanceID,
FaultSummary.FaultNumber FaultID
FROM
Event JOIN
EventType ON Event.EventTypeID = EventType.ID LEFT OUTER JOIN
EventWorstDisturbance ON
EventWorstDisturbance.EventID = Event.ID AND
EventType.Name IN ('Sag', 'Swell', 'Interruption', 'Transient') LEFT OUTER JOIN
FaultGroup ON
FaultGroup.EventID = Event.ID AND
COALESCE(FaultGroup.FaultDetectionLogicResult, 0) <> 0 LEFT OUTER JOIN
FaultSummary ON
FaultSummary.EventID = Event.ID AND
FaultSummary.IsSelectedAlgorithm <> 0 AND
(
EventWorstDisturbance.ID IS NOT NULL OR
FaultSummary.ID IS NOT NULL OR
EventType.Name IN ('BreakerOpen', 'Other')
)
{filters}
) Main LEFT JOIN
[SEBrowser.EventSearchEventView] ON Main.EventID = [SEBrowser.EventSearchEventView].EventID Inner JOIN
[SEBrowser.EventSearchDetailsView] ON
Main.EventID = [SEBrowser.EventSearchDetailsView].EventID AND
FaultGroup.ID IS NOT NULL OR
(
FaultSummary.IsValid <> 0 AND
FaultSummary.IsSuppressed = 0
)
) AND
EventType.Name IN ('Fault', 'RecloseIntoFault')
WHERE
({getTimeFilter(postData)}) AND
(
(Main.DisturbanceID IS NOT NULL AND [SEBrowser.EventSearchDetailsView].DisturbanceID = Main.DisturbanceID) OR
(Main.FaultID IS NOT NULL AND [SEBrowser.EventSearchDetailsView].FaultID = Main.FaultID) OR
(COALESCE([SEBrowser.EventSearchDetailsView].DisturbanceID, Main.DisturbanceID) IS NULL AND COALESCE([SEBrowser.EventSearchDetailsView].FaultID, Main.FaultID) IS NULL)
) {sortBy}";
EventWorstDisturbance.ID IS NOT NULL OR
FaultSummary.ID IS NOT NULL OR
EventType.Name IN ('BreakerOpen', 'Other')
)
{filters}
) Main LEFT JOIN
[SEBrowser.EventSearchEventView] ON Main.EventID = [SEBrowser.EventSearchEventView].EventID Inner JOIN
[SEBrowser.EventSearchDetailsView] ON
Main.EventID = [SEBrowser.EventSearchDetailsView].EventID AND
(
(Main.DisturbanceID IS NOT NULL AND [SEBrowser.EventSearchDetailsView].DisturbanceID = Main.DisturbanceID) OR
(Main.FaultID IS NOT NULL AND [SEBrowser.EventSearchDetailsView].FaultID = Main.FaultID) OR
(COALESCE([SEBrowser.EventSearchDetailsView].DisturbanceID, Main.DisturbanceID) IS NULL AND COALESCE([SEBrowser.EventSearchDetailsView].FaultID, Main.FaultID) IS NULL)
) {sortBy}";

DataTable table = connection.RetrieveData(query, dateTime);
DataTable table = connection.RetrieveData(query, startTime, endTime);

return table;
}
Expand All @@ -249,9 +249,7 @@ [SEBrowser.EventSearchDetailsView] ON

private string getTimeFilter(EventSearchPostData postData)
{
string timeWindowUnits = ((TimeWindowUnits)postData.timeWindowUnits).GetDescription();

return $"Event.StartTime BETWEEN DATEADD({timeWindowUnits},{-1 * postData.windowSize}, {{0}}) AND DATEADD({timeWindowUnits},{postData.windowSize}, {{0}})";
return $"Event.StartTime BETWEEN '{postData.start}' AND '{postData.end}'";
}

private string getEventTypeFilter(EventSearchPostData postData)
Expand Down
20 changes: 9 additions & 11 deletions SEBrowser/Controllers/RelayReport/RelayReportController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,11 @@ FROM Channel

}

private DataTable RelayHistoryTable( DateTime dateTime, int windowSize, string timeWindowUnits, int relayID, int channelID = -1)
private DataTable RelayHistoryTable( DateTime start, DateTime end, int relayID, int channelID = -1)
{
DataTable dataTable;

string timeRestriction = $"TripInitiate Between DATEADD({timeWindowUnits}, { (-1 * windowSize)}, '{dateTime}') AND DATEADD({ timeWindowUnits}, { (windowSize)}, '{dateTime}')";
string timeRestriction = $"TripInitiate Between DATEADD('{start}') AND DATEADD('{end}')";

using (AdoDataConnection connection = new("systemSettings"))
{
Expand All @@ -222,7 +222,8 @@ private DataTable RelayHistoryTable( DateTime dateTime, int windowSize, string t
}
else
{
dataTable = connection.RetrieveData($"SELECT * FROM BreakerHistory WHERE BreakerId = {{0}} AND {timeRestriction}", relayID);
dataTable = connection.RetrieveData($"SELECT * FROM BreakerHistory WHERE BreakerId = {{0}}" +
$" AND {timeRestriction}", relayID);
}
}
return dataTable;
Expand All @@ -235,21 +236,18 @@ public DataTable GetRelayPerformance()
int lineID;
int channelID;

DateTime dateTime = DateTime.ParseExact(query["date"] + " " + query["time"], "MM/dd/yyyy HH:mm:ss.fff", new CultureInfo("en-US"));
string timeWindowUnits = ((TimeWindowUnits)int.Parse(query["timeWindowUnits"])).GetDescription();
int windowSize = int.Parse(query["windowSize"]);

DateTime start = DateTime.ParseExact(query["start"], "MM/dd/yyyy HH:mm:ss.fff", new CultureInfo("en-US"));
DateTime end = DateTime.ParseExact(query["end"], "MM/dd/yyyy HH:mm:ss.fff", new CultureInfo("en-US"));

try { channelID = int.Parse(query["channelID"]); }
catch { channelID = -1; }

try { lineID = int.Parse(query["lineID"]); }
catch { lineID = -1; }

if (lineID <= 0) return new DataTable();

return RelayHistoryTable(dateTime,windowSize,timeWindowUnits,lineID, channelID);


return RelayHistoryTable(start, end, lineID, channelID); // change this to start end too
}

#endregion
Expand Down
18 changes: 10 additions & 8 deletions SEBrowser/Scripts/TSX/Components/BreakerReport/BreakerReport.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@
import * as React from 'react';
import BreakerReportNavbar from './BreakerReportNavbar';
import * as queryString from 'querystring';
const momentDateFormat = "MM/DD/YYYY";
import moment from 'moment';
import { useLocation, useNavigate } from 'react-router-dom';
import { useSelector } from 'react-redux';
import { SelectDateTimeFormat } from '../SettingsSlice';

declare let homePath: string;

Expand All @@ -36,17 +37,18 @@ interface State {
}

const BreakerReport = () => {
const [fromDate, setFromDate] = React.useState<string>('');
const [toDate, setToDate] = React.useState<string>('');
const [breaker, setBreaker] = React.useState<string>('');
const navigate = useNavigate();
const history = useLocation();
const dateTimeFormat = useSelector(SelectDateTimeFormat);
const [toDate, setToDate] = React.useState<string>('');
const [breaker, setBreaker] = React.useState<string>('');
const [fromDate, setFromDate] = React.useState<string>('');

React.useEffect(() => {
const query = queryString.parse(history.search.replace("?", ""), "&", "=");

setFromDate(query['fromDate'] != undefined ? query['fromDate'].toString() : moment().subtract(30, 'days').format(momentDateFormat));
setToDate(query['toDate'] != undefined ? query['toDate'].toString() : moment().format(momentDateFormat));
setFromDate(query['fromDate'] != undefined ? query['fromDate'].toString() : moment().subtract(30, 'days').format(dateTimeFormat));
setToDate(query['toDate'] != undefined ? query['toDate'].toString() : moment().format(dateTimeFormat));
setBreaker(query['breaker'] != undefined ? query['breaker'].toString() : '0');

}, []);
Expand All @@ -58,7 +60,7 @@ const BreakerReport = () => {
const q = queryString.stringify(state, "&", "=");
const handle = setTimeout(() => navigate(history.pathname + '?' + q), 500);
return (() => { clearTimeout(handle); })
}, [fromDate,toDate,breaker])
}, [fromDate, toDate, breaker])

function setState(a: State) {
setFromDate(a.fromDate);
Expand All @@ -69,7 +71,7 @@ const BreakerReport = () => {
const link = `${homePath}api/BreakerReport/${(breaker == '0' ? `AllBreakersReport?` : `IndividualBreakerReport?breakerId=${breaker}&`)}startDate=${fromDate}&endDate=${toDate}`;
return (
<div style={{ width: '100%', height: '100%' }}>
<BreakerReportNavbar toDate={toDate} fromDate={fromDate} breaker={breaker} stateSetter={setState} />
<BreakerReportNavbar dateTimeFormat={dateTimeFormat} toDate={toDate} fromDate={fromDate} breaker={breaker} stateSetter={setState} />
<div style={{ width: '100%', height: 'calc( 100% - 163px)' }}>
<embed style={{ width: 'inherit', height: 'inherit', position: 'absolute' }} id="pdfContent" src={link} key={link} type="application/pdf" />
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,18 @@
import React from 'react';
import BreakerReportService from './../../../TS/Services/BreakerReport'


export interface BreakerReportNavbarProps {
fromDate: string,
toDate: string,
breaker: string,
stateSetter(state): void
stateSetter(state): void,
dateTimeFormat: string
}

interface State {
breakers: Array<any>
}

const momentDateFormat = "MM/DD/YYYY";


export default class BreakerReportNavbar extends React.Component<BreakerReportNavbarProps, State> {
breakerReportService: BreakerReportService;
constructor(props, context) {
Expand All @@ -51,13 +48,13 @@ export default class BreakerReportNavbar extends React.Component<BreakerReportNa
}

componentDidMount() {
$('#toDatePicker').datetimepicker({ format: momentDateFormat });
$('#toDatePicker').datetimepicker({ format: this.props.dateTimeFormat });
$('#toDatePicker').on('dp.change', (e) => this.props.stateSetter({ toDate: (e.target as any).value }));
$('#fromDatePicker').datetimepicker({ format: momentDateFormat });
$('#fromDatePicker').datetimepicker({ format: this.props.dateTimeFormat });
$('#fromDatePicker').on('dp.change', (e) => this.props.stateSetter({ fromDate: (e.target as any).value }));

this.breakerReportService.getMaximoBreakers().done(data => {
this.setState({ breakers: data.map((d,i) => <option key={i} value={d.AssetKey}>{d.BreakerName}</option>)});
this.setState({ breakers: data.map((d, i) => <option key={i} value={d.AssetKey}>{d.BreakerName}</option>) });
});
}

Expand Down
Loading