Skip to content

Commit

Permalink
corrected issue with updates
Browse files Browse the repository at this point in the history
  • Loading branch information
juwilliams committed Jul 25, 2017
1 parent bc6a845 commit 5b43eba
Show file tree
Hide file tree
Showing 7 changed files with 131 additions and 92 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SpatialConnect.Windows.DataServices.Constants
{
public sealed class ContainerConstants
{
public sealed class Destination
{
public const string WEBEOC = "webeoc";
public const string ARCGIS = "arcgis";
}
}
}
56 changes: 41 additions & 15 deletions SpatialConnect.Windows.DataServices/Service/RecordPushService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using SpatialConnect.Entity;
using SpatialConnect.Windows.DataServices.App;
using SpatialConnect.Windows.DataServices.BaseClasses;
using SpatialConnect.Windows.DataServices.Constants;
using SpatialConnect.Windows.DataServices.Interface;
using System;
using System.Collections.Generic;
Expand All @@ -30,6 +31,8 @@ public sealed class RecordPushService : IDataService

private string[] Pulls { get; set; }

private int expectedResultsCount = 0;

#endregion


Expand Down Expand Up @@ -82,6 +85,15 @@ public void Run()
}

records = records.Where(p => !this.Container.PushHistory.uids.Contains(p.uid)).ToList();
if (records.Count() == 0)
{
this.AfterRun(new List<GeoRecord>());

return;
}

// set the number of records we expect to push so that we know whether or not to archive the pull.json files
expectedResultsCount = records.Count();

// populate data ids if relationships are being used
if (this.Container.use_relationships && this.Container.Relationships.keys.Any())
Expand All @@ -90,7 +102,16 @@ public void Run()

foreach (GeoRecord relation in related)
{
relation.dataid = this.Container.Relationships.keys.FirstOrDefault(p => p.internal_id == relation.id).external_id;
// set the appropriate external system id field depending on the destination system
if (this.Container.destination.ToLower() == ContainerConstants.Destination.WEBEOC)
{
relation.dataid = this.Container.Relationships.keys.FirstOrDefault(p => p.internal_id == relation.id).external_id;
}
else
{
relation.objectid = this.Container.Relationships.keys.FirstOrDefault(p => p.internal_id == relation.id).external_id;
}

relation.was_update = true;
}

Expand All @@ -104,13 +125,13 @@ public void Run()
// push the concatenated record lists
switch (this.Container.destination.ToLower())
{
case "webeoc":
case ContainerConstants.Destination.WEBEOC:
{
PushToWebEOC(records);

break;
}
case "arcgis":
case ContainerConstants.Destination.ARCGIS:
{
PushToArcGIS(records);

Expand Down Expand Up @@ -143,7 +164,7 @@ public void AfterRun(List<GeoRecord> results)
{
Key key = new Key()
{
external_id = add.dataid,
external_id = this.Container.destination.ToLower() == ContainerConstants.Destination.WEBEOC ? add.dataid : add.objectid,
internal_id = add.id,
field_name = this.Container.key,
uid = add.uid
Expand All @@ -163,22 +184,27 @@ public void AfterRun(List<GeoRecord> results)
this.Container.Cache.Write(ServiceApp.app_path + "\\" + this.Container.name + "\\cache.json");

// archive previous pulls
foreach (string pull in Pulls)
if (expectedResultsCount == results.Count())
{
try
_log.Info("pushed all expected records successfully, archiving pull//*.pull.json files..");

foreach (string pull in Pulls)
{
string nextPath = ServiceApp.app_path + "\\" + this.Container.name + "\\pull\\archive\\" + Path.GetFileName(pull);
try
{
string nextPath = ServiceApp.app_path + "\\" + this.Container.name + "\\pull\\archive\\" + Path.GetFileName(pull);

if (File.Exists(nextPath))
{
File.Delete(nextPath);
}

if (File.Exists(nextPath))
File.Move(pull, nextPath);
}
catch (Exception ex)
{
File.Delete(nextPath);
_log.Error(ex.Message, ex);
}

File.Move(pull, nextPath);
}
catch (Exception ex)
{
_log.Error(ex.Message, ex);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
<ItemGroup>
<Compile Include="BaseClasses\DataServiceScheduler.cs" />
<Compile Include="BaseClasses\DataServiceManagerBase.cs" />
<Compile Include="Constants\ContainerConstants.cs" />
<Compile Include="Interface\IDataService.cs" />
<Compile Include="App\ServiceApp.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
Expand Down Expand Up @@ -114,9 +115,7 @@
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<Folder Include="Constants\" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,76 +1,73 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<system.net>
<defaultProxy useDefaultCredentials="true" />
</system.net>
<appSettings>
<add key="log4net.Internal.Debug" value="true" />
<!-- LOCAL DEV -->
<add key="webeoc-api-url" value="https://webeoc.in.gov/eoc7/api.asmx" />
<!--<add key="webeoc-api-url" value="http://dhswebd01pw.shared.state.in.us/eoc7/api.asmx" />-->
<!--<add key="app-path" value="C:\\src\\github.com\\juwilliams\\spatial-connect-cli\\tasks\\log\\"/>-->
<add key="app-path" value="D:\\src\\github.com\\juwilliams\\spatial-connect-cli\\tasks\\"/>
</appSettings>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="ApiSoap" openTimeout="00:05:00" receiveTimeout="00:20:00" sendTimeout="00:20:00" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" allowCookies="false" />
</basicHttpBinding>
<customBinding>
<binding name="WebeocHttpsBinding" closeTimeout="00:05:00" openTimeout="00:05:00" receiveTimeout="00:05:00" sendTimeout="00:05:00">
<transactionFlow />
<textMessageEncoding messageVersion="Soap11" />
<httpsTransport maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" authenticationScheme="Ntlm" maxBufferSize="2147483647" />
</binding>
<binding name="ApiSoap12">
<textMessageEncoding messageVersion="Soap12" />
<httpTransport allowCookies="false" />
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="https://webeoc.in.gov/eoc7/api.asmx" binding="customBinding" bindingConfiguration="WebeocHttpsBinding" contract="WebEOC7.APISoap" name="APISoap" />
<endpoint address="http://localhost:8089/SpatialConnectAPI.asmx" binding="basicHttpBinding" bindingConfiguration="ApiSoap" contract="SpatialConnectAPI.ApiSoap" name="ApiSoap" />
<endpoint address="http://localhost:8089/SpatialConnectAPI.asmx" binding="customBinding" bindingConfiguration="ApiSoap12" contract="SpatialConnectAPI.ApiSoap" name="ApiSoap12" />
</client>
</system.serviceModel>
<log4net>
<root>
<level value="DEBUG" />
<appender-ref ref="RollingFileAppender" />
</root>
<appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
<bufferSize value="1" />
<file type="log4net.Util.PatternString" value="%property{AppPath}\log\log.txt" />
<appendToFile value="true" />
<rollingStyle value="Size" />
<maxSizeRollBackups value="50" />
<maximumFileSize value="100KB" />
<staticLogFileName value="true" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
</layout>
</appender>
</log4net>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<system.diagnostics>
<trace autoflush="true">
<listeners>
<add name="textWriterTraceListener" type="System.Diagnostics.TextWriterTraceListener" initializeData="D:\temp\log4netSRC.txt" />
</listeners>
</trace>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<system.net>
<defaultProxy useDefaultCredentials="true" />
</system.net>
<appSettings>
<!-- This is the maximum number of records that can be retrieved from the API -->
<add key="max-api-record-count" value="15000" />
<add key="log4net.Internal.Debug" value="true" />
<!-- LOCAL DEV -->
<add key="app-path" value="D:\incidents\DailyOperationsFast2\connect"/>
<add key="env" value="prod"/>
</appSettings>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="ApiSoap" openTimeout="00:05:00" receiveTimeout="00:20:00" sendTimeout="00:20:00" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" allowCookies="false" />
</basicHttpBinding>
<customBinding>
<binding name="WebeocHttpsBinding" closeTimeout="00:05:00" openTimeout="00:05:00" receiveTimeout="00:05:00" sendTimeout="00:05:00">
<transactionFlow />
<textMessageEncoding messageVersion="Soap11" />
<httpsTransport maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" authenticationScheme="Ntlm" maxBufferSize="2147483647" />
</binding>
<binding name="ApiSoap12">
<textMessageEncoding messageVersion="Soap12" />
<httpTransport allowCookies="false" />
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="https://webeoc.in.gov/eoc7/api.asmx" binding="customBinding" bindingConfiguration="WebeocHttpsBinding" contract="WebEOC7.APISoap" name="APISoap" />
</client>
</system.serviceModel>
<log4net>
<root>
<level value="DEBUG" />
<appender-ref ref="RollingFileAppender" />
</root>
<appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
<file type="log4net.Util.PatternString" value="%property{AppPath}\log\log.txt" />
<appendToFile value="true" />
<rollingStyle value="Size" />
<maxSizeRollBackups value="10" />
<maximumFileSize value="100KB" />
<staticLogFileName value="true" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %message%newline" />
</layout>
</appender>
</log4net>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<system.diagnostics>
<trace autoflush="true">
<listeners>
<add name="textWriterTraceListener" type="System.Diagnostics.TextWriterTraceListener" initializeData="D:\temp\log4netDailyOps.txt" />
</listeners>
</trace>
</system.diagnostics>
</configuration>
Binary file modified SpatialConnect.Windows.Task/bin/Release/gbc.dll
Binary file not shown.

0 comments on commit 5b43eba

Please sign in to comment.