Skip to content

Commit

Permalink
ATSPM 4.2
Browse files Browse the repository at this point in the history
Bug fix for duplicate data aggregation rows
  • Loading branch information
udotdevelopment committed Nov 6, 2018
1 parent 995d635 commit 02b5b66
Show file tree
Hide file tree
Showing 48 changed files with 667 additions and 272 deletions.
4 changes: 2 additions & 2 deletions ArchiveMetricData/App.config
Expand Up @@ -8,11 +8,11 @@
<appSettings>
<add key="ErrorRecipients" value="dlowe@utah.gov, derekjlowe@gmail.com" />
<add key="BinSize" value="15" />
<add key="MaxThreads" value="60" />
<add key="MaxThreads" value="10" />
<add key="ClientSettingsProvider.ServiceUri" value="" />
</appSettings>
<connectionStrings>
<add name="SPM" connectionString="data source=SPMServer;initial catalog=MOE;Persist Security Info=True;User ID=spm;Password=SpmPassword;MultipleActiveResultSets=True;App=EntityFramework" providerName="System.Data.SqlClient" />
<add name="SPM" connectionString="data source=SpmServer;initial catalog=MOE;Persist Security Info=True;User ID=spm;Password=SpmPassword;Connection Timeout=120;MultipleActiveResultSets=True;App=EntityFramework" providerName="System.Data.SqlClient" />
<add name="ADConnectionString" connectionString="LDAP://itwcap1" />
</connectionStrings>
<startup>
Expand Down
2 changes: 1 addition & 1 deletion ConvertDBForHistoricalConfigurations/Program.cs
Expand Up @@ -244,7 +244,7 @@ private static void GetMetricComments()
metricComments.SignalId = (string) reader["SignalID"];
metricComments.TimeStamp = (DateTime) reader["TimeStamp"];
metricComments.ComentText = (string) reader["CommentText"];
metricComments.VersionId = (int) reader["VersionId"];
//metricComments.VersionId = (int) reader["VersionId"];
_oldMetricCommentsList.Add(metricComments);
}
sqlconn.Dispose();
Expand Down
Expand Up @@ -1238,17 +1238,17 @@ GO
USE [MOE_ORIG]


insert into __MigrationHistory select * from srwtcmoe.MOE.dbo.__MigrationHistory
insert into __MigrationHistory select * from SpmServer.MOE.dbo.__MigrationHistory

insert into ControllerTypes select* from srwtcmoe.MOE.dbo.ControllerTypes
insert into ControllerTypes select* from SpmServer.MOE.dbo.ControllerTypes

insert into DirectionTypes select* from srwtcmoe.MOE.dbo.DirectionTypes
insert into DirectionTypes select* from SpmServer.MOE.dbo.DirectionTypes

insert into DetectionHardwares select * from srwtcmoe.MOE.dbo.DetectionHardwares
insert into DetectionHardwares select * from SpmServer.MOE.dbo.DetectionHardwares

insert into DetectionTypes select * from srwtcmoe.MOE.dbo.DetectionTypes
insert into DetectionTypes select * from SpmServer.MOE.dbo.DetectionTypes

insert into LaneTypes select * from srwtcmoe.MOE.dbo.LaneTypes
insert into LaneTypes select * from SpmServer.MOE.dbo.LaneTypes

SET IDENTITY_INSERT dbo.MetricTypes ON

Expand All @@ -1259,27 +1259,27 @@ insert into MetricTypes([MetricID]
select [MetricID]
,[ChartName]
,[Abbreviation]
,[ShowOnWebsite] from srwtcmoe.MOE.dbo.MetricTypes
,[ShowOnWebsite] from SpmServer.MOE.dbo.MetricTypes

SET IDENTITY_INSERT dbo.MetricTypes OFF

insert into MovementTypes select * from srwtcmoe.MOE.dbo.MovementTypes
insert into MovementTypes select * from SpmServer.MOE.dbo.MovementTypes

insert into DetectionTypeMetricTypes select * from srwtcmoe.MOE.dbo.DetectionTypeMetricTypes
insert into DetectionTypeMetricTypes select * from SpmServer.MOE.dbo.DetectionTypeMetricTypes


insert into Region (id, Description) select ID, Description from srwtcmoe.MOE.dbo.Region
insert into Region (id, Description) select ID, Description from SpmServer.MOE.dbo.Region


Insert Into Signals(SignalID, PrimaryName, SecondaryName, IPAddress, ControllerTypeID, Enabled, Latitude, Longitude, RegionID)
Select SignalID, PrimaryName, SecondaryName, IPAddress, ControllerTypeID, Enabled, Latitude, Longitude, RegionID From [srwtcmoe].[moe].dbo.Signals
Select SignalID, PrimaryName, SecondaryName, IPAddress, ControllerTypeID, Enabled, Latitude, Longitude, RegionID From [SpmServer].[moe].dbo.Signals

Go

SET IDENTITY_INSERT dbo.Approaches ON
Go
Insert into Approaches(ApproachID,SignalId, DirectionTypeID, Description, MPH, ProtectedPhaseNumber, IsProtectedPhaseOverlap, PermissivePhaseNumber)
Select ApproachID,SignalId, DirectionTypeID, Description, MPH, ProtectedPhaseNumber, IsProtectedPhaseOverlap, PermissivePhaseNumber From [srwtcmoe].[moe].dbo.Approaches
Select ApproachID,SignalId, DirectionTypeID, Description, MPH, ProtectedPhaseNumber, IsProtectedPhaseOverlap, PermissivePhaseNumber From [SpmServer].[moe].dbo.Approaches


SET IDENTITY_INSERT dbo.Approaches OFF
Expand All @@ -1290,36 +1290,36 @@ SET IDENTITY_INSERT dbo.Detectors ON
Go

Insert Into Detectors (ID, DetectorID, DetChannel, DistanceFromStopBar, MinSpeedFilter, DateAdded, DateDisabled, LaneNumber, MovementTypeID, LaneTypeID, DecisionPoint, MovementDelay, ApproachID, DetectionHardwareID)
Select * From [srwtcmoe].[moe].dbo.Detectors
Select * From [SpmServer].[moe].dbo.Detectors

Go

SET IDENTITY_INSERT dbo.Detectors OFF
Go

insert into Accordian select AccHeader, AccContent, AccOrder, Application from srwtcmoe.MOE.dbo.Accordian
insert into Accordian select AccHeader, AccContent, AccOrder, Application from SpmServer.MOE.dbo.Accordian

SET IDENTITY_INSERT dbo.Agencies ON
insert into Agencies([AgencyID]
,[Description])
select [AgencyID]
,[Description] from srwtcmoe.MOE.dbo.Agencies
,[Description] from SpmServer.MOE.dbo.Agencies

SET IDENTITY_INSERT dbo.Agencies OFF

SET IDENTITY_INSERT ActionLogs ON
insert into ActionLogs(ActionLogID, DATE, AgencyID, Comment, signalID, Name) select ActionLogID, DATE, AgencyID, Comment, signalID, Name from srwtcmoe.MOE.dbo.ActionLogs
insert into ActionLogs(ActionLogID, DATE, AgencyID, Comment, signalID, Name) select ActionLogID, DATE, AgencyID, Comment, signalID, Name from SpmServer.MOE.dbo.ActionLogs
SET IDENTITY_INSERT ActionLogs OFF

insert into ActionLogMetricTypes select * from srwtcmoe.MOE.dbo.ActionLogMetricTypes
insert into ActionLogMetricTypes select * from SpmServer.MOE.dbo.ActionLogMetricTypes



insert into Alert_Day_Types select * from srwtcmoe.MOE.dbo.Alert_Day_Types
insert into Alert_Day_Types select * from SpmServer.MOE.dbo.Alert_Day_Types


SET IDENTITY_INSERT ApproachRoute ON
insert into ApproachRoute(ApproachRouteId, RouteName) select ApproachRouteId, RouteName from srwtcmoe.MOE.dbo.ApproachRoute
insert into ApproachRoute(ApproachRouteId, RouteName) select ApproachRouteId, RouteName from SpmServer.MOE.dbo.ApproachRoute
SET IDENTITY_INSERT ApproachRoute Off


Expand All @@ -1331,38 +1331,38 @@ insert into ApproachRouteDetail([ApproachRouteId]
select [ApproachRouteId]
,[ApproachOrder]
,[RouteDetailID]
,[ApproachID] from srwtcmoe.MOE.dbo.ApproachRouteDetail
,[ApproachID] from SpmServer.MOE.dbo.ApproachRouteDetail
SET IDENTITY_INSERT ApproachRouteDetail OFF



insert into Archived_Metrics select top 10000 * from srwtcmoe.MOE.dbo.Archived_Metrics
insert into Archived_Metrics select top 10000 * from SpmServer.MOE.dbo.Archived_Metrics



insert into Controller_Event_Log select top 10000 * from srwtcmoe.MOE.dbo.Controller_Event_Log
insert into Controller_Event_Log select top 10000 * from SpmServer.MOE.dbo.Controller_Event_Log



insert into DetectorComments select ID,Timestamp, CommentText from srwtcmoe.MOE.dbo.DetectorComments
insert into DetectionTypeDetector select ID,DetectionTypeID from srwtcmoe.MOE.dbo.DetectionTypeDetector
insert into DetectorComments select ID,Timestamp, CommentText from SpmServer.MOE.dbo.DetectorComments
insert into DetectionTypeDetector select ID,DetectionTypeID from SpmServer.MOE.dbo.DetectionTypeDetector

insert into DownloadAgreements select CompanyName, Address, PhoneNumber, EmailAddress, Acknowledged, AgreementDate from srwtcmoe.MOE.dbo.DownloadAgreements
insert into DownloadAgreements select CompanyName, Address, PhoneNumber, EmailAddress, Acknowledged, AgreementDate from SpmServer.MOE.dbo.DownloadAgreements

insert into Menu(MenuId, MenuName, ParentId, Application, DisplayOrder) select MenuId, MenuName, ParentId, Application, DisplayOrder from srwtcmoe.MOE.dbo.Menu
insert into Menu(MenuId, MenuName, ParentId, Application, DisplayOrder) select MenuId, MenuName, ParentId, Application, DisplayOrder from SpmServer.MOE.dbo.Menu

insert into Program_Message select top 10000 Priority, Program, Message, Timestamp from srwtcmoe.MOE.dbo.Program_Message
insert into Program_Message select top 10000 Priority, Program, Message, Timestamp from SpmServer.MOE.dbo.Program_Message


insert into Program_Settings select top 10000 * from srwtcmoe.MOE.dbo.Program_Settings
insert into Program_Settings select top 10000 * from SpmServer.MOE.dbo.Program_Settings


SET IDENTITY_INSERT Route ON
insert into Route (RouteID, Description, Region, Name) select RouteID, Description, Region, Name from srwtcmoe.MOE.dbo.Route
insert into Route (RouteID, Description, Region, Name) select RouteID, Description, Region, Name from SpmServer.MOE.dbo.Route
SET IDENTITY_INSERT Route OFF


insert into Route_Detectors (DetectorID, RouteID, RouteOrder) select DetectorID, RouteID, RouteOrder from srwtcmoe.MOE.dbo.Route_Detectors
insert into Route_Detectors (DetectorID, RouteID, RouteOrder) select DetectorID, RouteID, RouteOrder from SpmServer.MOE.dbo.Route_Detectors


insert into Speed_Events select top 10000 * from srwtcmoe.MOE.dbo.Speed_Events
insert into Speed_Events select top 10000 * from SpmServer.MOE.dbo.Speed_Events
4 changes: 2 additions & 2 deletions GetMaxTimeRecords/App.config
Expand Up @@ -9,8 +9,8 @@
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
</configSections>
<connectionStrings>
<add name="SPM" connectionString="Data Source=MOE;Initial Catalog=MOE;Persist Security Info=True;User ID=SPM;Password=SpmPassword" providerName="System.Data.SqlClient" />
<add name="GetMaxTimeRecords.Properties.Settings.SPM" connectionString="Data Source=AtspmServer;Initial Catalog=MOE;Persist Security Info=True;User ID=SPM;Password=SpmPassword" providerName="System.Data.SqlClient" />
<add name="SPM" connectionString="Data Source=ATSPMServer;Initial Catalog=MOE;Persist Security Info=True;User ID=SPM;Password=ATSPMPassword" providerName="System.Data.SqlClient" />
<add name="GetMaxTimeRecords.Properties.Settings.SPM" connectionString="Data Source=ATSPMServer;Initial Catalog=MOE;Persist Security Info=True;User ID=SPM;Password=ATSPMPassword" providerName="System.Data.SqlClient" />
</connectionStrings>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
Expand Down
72 changes: 45 additions & 27 deletions GetMaxTimeRecords/GetMaxTimeRecords.cs
Expand Up @@ -9,7 +9,8 @@
using System.Data.SqlClient;
using System.Net;
using System.Net.NetworkInformation;

using MOE.Common.Models;
using MOE.Common.Models.Repositories;


namespace GetMaxTimeRecords
Expand Down Expand Up @@ -71,35 +72,52 @@ private static bool TestIPAddress (MOE.Common.Models.Signal Signal)
IPAddress ip ;
bool hasValidIP = true;
hasValidIP = IPAddress.TryParse(Signal.IPAddress, out ip);


if (Signal.IPAddress == "0")
{
hasValidIP = false;
}

//test to see if the address is reachable
if (hasValidIP)
{
Ping pingSender = new Ping ();
PingOptions pingOptions = new PingOptions ();

// Use the default Ttl value which is 128,
// but change the fragmentation behavior.
pingOptions.DontFragment = true;

// Create a buffer of 32 bytes of data to be transmitted.
string data = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
byte[] buffer = Encoding.ASCII.GetBytes (data);
int timeout = 120;
PingReply reply = pingSender.Send(Signal.IPAddress, timeout, buffer, pingOptions);
if (reply.Status != IPStatus.Success)
{
hasValidIP = false;
}
}
return hasValidIP;
{
hasValidIP = false;
}

//test to see if the address is reachable
if (hasValidIP)
{
Ping pingSender = new Ping();
PingOptions pingOptions = new PingOptions();

// Use the default Ttl value which is 128,
// but change the fragmentation behavior.
pingOptions.DontFragment = true;

// Create a buffer of 32 bytes of data to be transmitted.
string data = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
byte[] buffer = Encoding.ASCII.GetBytes(data);
int timeout = 120;
PingReply reply = null;
try
{
reply = pingSender.Send(Signal.IPAddress, timeout, buffer, pingOptions);
if (reply.Status != IPStatus.Success)
{
var errorLog = ApplicationEventRepositoryFactory.Create();
errorLog.QuickAdd(System.Reflection.Assembly.GetExecutingAssembly().GetName().ToString(),
"GetMaxTimeRecords", "TestIPAddress", ApplicationEvent.SeverityLevels.High, "Signal - " + Signal.SignalID + " IP Address - " + Signal.IPAddress + " - Invalid IP Address");
hasValidIP = false;
}
}
catch( Exception e)
{
if (reply == null || reply.Status != IPStatus.Success)
{
var errorLog = ApplicationEventRepositoryFactory.Create();
errorLog.QuickAdd(System.Reflection.Assembly.GetExecutingAssembly().GetName().ToString(),
"GetMaxTimeRecords", e.TargetSite.ToString(), ApplicationEvent.SeverityLevels.High, "Signal - " + Signal.SignalID + " IP Address - " + Signal.IPAddress + " - " + e.Message);

hasValidIP = false;
}
}
}
return hasValidIP;
}

private static DateTime GetMostRecentRecordTime(string signalId)
{
Expand Down
5 changes: 3 additions & 2 deletions GetMaxTimeRecords/GetMaxTimeRecords.csproj
Expand Up @@ -13,7 +13,6 @@
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>

<SccProjectName>Svn</SccProjectName>
<SccLocalPath>Svn</SccLocalPath>
<SccAuxPath>Svn</SccAuxPath>
Expand Down Expand Up @@ -91,7 +90,9 @@
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="App.config">
<SubType>Designer</SubType>
</None>
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
Expand Down
10 changes: 6 additions & 4 deletions MOE.Common/Business/ApproachVolume/ApproachVolume.cs
Expand Up @@ -24,6 +24,8 @@ public class ApproachVolume
public DetectionType DetectionType { get; set; }
public List<Models.Detector> Detectors { get; set; } = new List<Models.Detector>();
public MetricInfo MetricInfo { get; set; } = new MetricInfo();
public List<Controller_Event_Log> PrimaryDetectorEvents { get; set; } = new List<Controller_Event_Log>();
public List<Controller_Event_Log> OpposingDetectorEvents { get; set; } = new List<Controller_Event_Log>();


public ApproachVolume(List<Models.Approach> primaryDirectionApproaches, List<Models.Approach> opposingDirectionApproaches, ApproachVolumeOptions approachVolumeOptions,
Expand All @@ -44,14 +46,14 @@ public class ApproachVolume

public void SetVolume()
{
PrimaryDirectionVolume = SetVolumeByDetection(_primaryDirectionApproaches);
OpposingDirectionVolume = SetVolumeByDetection(_opposingDirectionApproaches);
PrimaryDirectionVolume = SetVolumeByDetection(_primaryDirectionApproaches, PrimaryDetectorEvents);
OpposingDirectionVolume = SetVolumeByDetection(_opposingDirectionApproaches, OpposingDetectorEvents);
}

private VolumeCollection SetVolumeByDetection(List<Models.Approach> approaches)
private VolumeCollection SetVolumeByDetection(List<Models.Approach> approaches, List<Controller_Event_Log> detectorEvents)
{
var controllerEventLogRepository = MOE.Common.Models.Repositories.ControllerEventLogRepositoryFactory.Create();
var detectorEvents = new List<Controller_Event_Log>();

foreach (var approach in approaches)
{
foreach (var detector in approach.Detectors)
Expand Down
10 changes: 6 additions & 4 deletions MOE.Common/Business/Bins/BinFactory.cs
Expand Up @@ -61,7 +61,7 @@ private static List<BinsContainer> GetDayBinsContainersForRange(BinFactoryOption
var binsContainer = new BinsContainer(timeOptions.Start, timeOptions.End);
for (var startTime = new DateTime(timeOptions.Start.Year, timeOptions.Start.Month, timeOptions.Start.Day, 0,
0, 0);
startTime.Date < timeOptions.End.Date;
startTime.Date <= timeOptions.End.Date;
startTime = startTime.AddDays(1))
if (timeOptions.TimeOption == BinFactoryOptions.TimeOptions.StartToEnd && timeOptions.DaysOfWeek.Contains(startTime.DayOfWeek))
{
Expand Down Expand Up @@ -149,7 +149,9 @@ private static List<BinsContainer> GetBinsForRange(BinFactoryOptions timeOptions
var binsContainers = new List<BinsContainer>();
var startTimeSpan = new TimeSpan();
var endTimeSpan = new TimeSpan();
if (timeOptions.TimeOption == BinFactoryOptions.TimeOptions.TimePeriod &&
var tempStart = timeOptions.Start;
var tempEnd = timeOptions.End;
if (//timeOptions.TimeOption == BinFactoryOptions.TimeOptions.TimePeriod &&
timeOptions.TimeOfDayStartHour != null &&
timeOptions.TimeOfDayStartMinute != null &&
timeOptions.TimeOfDayEndHour != null &&
Expand All @@ -161,8 +163,8 @@ private static List<BinsContainer> GetBinsForRange(BinFactoryOptions timeOptions
timeOptions.TimeOfDayEndMinute.Value, 0);
}
var binsContainer = new BinsContainer(timeOptions.Start, timeOptions.End);
for (var startTime = timeOptions.Start;
startTime < timeOptions.End;
for (var startTime = tempStart;
startTime < tempEnd;
startTime = startTime.AddMinutes(minutes))
switch (timeOptions.TimeOption)
{
Expand Down

0 comments on commit 02b5b66

Please sign in to comment.