Skip to content
This repository has been archived by the owner on Mar 25, 2024. It is now read-only.

Commit

Permalink
save new subscriberEndindex after re-running aborted changelog
Browse files Browse the repository at this point in the history
minor refactoring
  • Loading branch information
jarle pedersen committed Jan 30, 2019
1 parent a08c7d4 commit 2a3d266
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 15 deletions.
2 changes: 0 additions & 2 deletions CORESubscriber/Changelog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ internal static void Run()
directoryInfo.GetDirectories().ToList().ForEach(ReadFiles);

ReadFiles(directoryInfo);

Dataset.ResetAbortedChangelog();
}

private static void ReadFiles(DirectoryInfo directoryInfo)
Expand Down
21 changes: 15 additions & 6 deletions CORESubscriber/Dataset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ internal class Dataset

public static string Version { get; set; }

internal static void UpdateSettings()
internal static void SaveFinalSettings()
{
OrderedChangelogId = EmptyValue;
ResetAbortedChangelog();

SetSubscriberLastIndexToProviderLastIndex();
SetOrderedChangelogId(EmptyValue);

SetAbortedchangelogToChangelogId();
SetSubscriberLastIndexToProviderLastIndex();

Provider.Save();
ResetAbortedchangelogId();
}

private static void SetSubscriberLastIndexToProviderLastIndex()
Expand Down Expand Up @@ -98,6 +98,15 @@ public static string GetAbortedChangelogId()
.Value;
}

public static long GetProviderLastIndex()
{
var endIndex = GetDatasetConfigFirstDescendant(XmlElements.AbortedChangelog)
.Attribute(XmlAttributes.EndIndex)
.Value;

return string.IsNullOrEmpty(endIndex) ? Convert.ToInt64(EmptyValue) : Convert.ToInt64(endIndex);
}

public static void SetChangelogPath(string dataFolder)
{
GetDatasetConfigFirstDescendant(XmlElements.AbortedChangelog)
Expand Down Expand Up @@ -138,7 +147,7 @@ public static int GetTransaction()
.Attribute(XmlAttributes.Transaction).Value);
}

private static void SetAbortedchangelogToChangelogId()
private static void ResetAbortedchangelogId()
{
GetDatasetConfigFirstDescendant(XmlElements.AbortedChangelog)
.SetAttributeValue(XmlAttributes.ChangelogId, EmptyValue);
Expand Down
19 changes: 12 additions & 7 deletions CORESubscriber/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@ private static string SynchronizeDataset(XObject subscribed)

Changelog.Run();

Dataset.UpdateSettings();
Dataset.ProviderLastIndex = Dataset.GetProviderLastIndex();

Dataset.SaveFinalSettings();

return Dataset.GetDatasetIdFromElement(subscribed);
}
Expand All @@ -144,16 +146,21 @@ private static void GetChangelog()
{
Dataset.OrderedChangelogId = abortedChangelogId;

GetChangelogStatus.Run();

Changelog.Get(SoapAction.GetChangelog.Run()).Wait();
WaitForChangelogAndDownload();

return;
}

Changelog.DataFolder = changelogPath;
}

private static void WaitForChangelogAndDownload()
{
GetChangelogStatus.Run();

Changelog.Get(SoapAction.GetChangelog.Run()).Wait();
}

private static void WriteDatasetInformation()
{
Console.WriteLine(
Expand All @@ -166,9 +173,7 @@ private static void GetChangelogFromProvider()

else OrderChangelog2.Run();

GetChangelogStatus.Run();

Changelog.Get(SoapAction.GetChangelog.Run()).Wait();
WaitForChangelogAndDownload();
}

private static Stopwatch StartTimer()
Expand Down

0 comments on commit 2a3d266

Please sign in to comment.