Skip to content

Commit

Permalink
Updated both the Silent Update routine and also the WinForms GUI to s…
Browse files Browse the repository at this point in the history
…upport the new code that detects if any in progress recordings are occuring on the Plex server.
  • Loading branch information
phantomtypist committed Aug 24, 2019
1 parent 697f866 commit 06afead
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 23 deletions.
45 changes: 34 additions & 11 deletions MainForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 13 additions & 7 deletions MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ void BtnUpdateClick(object sender, EventArgs e)
if (CheckIfCanUpdate())
{
PerformUpdate();
}
}
}

/// <summary>
Expand Down Expand Up @@ -190,25 +190,28 @@ private bool CheckIfCanUpdate()
}

int playCount = _server.GetPlayCount();
int inProgressRecordingCount = _server.GetInProgressRecordingCount();

// No item is currently being played
if (playCount == 0)
if (playCount == 0 && inProgressRecordingCount == 0)
{
txtUpdateStatus.Text += "The server is not in use continuing to perform the update.";
Log.Write("The server is not in use continuing to perform the update.");
lblPlayCount.Text = _server.PlayCount.ToString();
lblInProgressRecordingCountLabel.Text = _server.InProgressRecordingCount.ToString();
btnUpdate.Enabled = true;
_timer.Enabled = false;
return true;
}
// At least one item is being played
else if (playCount > 0)
else if (playCount > 0 || inProgressRecordingCount > 0)
{
lblPlayCount.Text = _server.PlayCount.ToString();
lblInProgressRecordingCountLabel.Text = _server.InProgressRecordingCount.ToString();
if (chkWait.Checked)
{
txtUpdateStatus.Text += "Waiting for the server to be free has not been enabled. Server update can begin.";
Log.Write("The server is in use. Waiting for all media to be stopped before performing the update.");
Log.Write("The server is in use. Waiting for all media and/or in progress recordings to be stopped before performing the update.");
btnUpdate.Enabled = false;
_timer.Interval =
Convert.ToDouble(Math.Abs(numSeconds.Value) * 1000);
Expand All @@ -230,6 +233,7 @@ private bool CheckIfCanUpdate()
txtUpdateStatus.Text += "The server in use status could not be determined. The server can be updated if you wish.";
Log.Write("The server in use status could not be determined. The server can be updated if you wish.");
lblPlayCount.Text = "Unknown";
lblInProgressRecordingCountLabel.Text = "Unknown";
btnUpdate.Enabled = true;
_timer.Enabled = false;
return true;
Expand Down Expand Up @@ -267,7 +271,7 @@ private void Initialize()

lblInstalledVersion.Text = _server.CurrentVersion.ToString();
lblLatestVersion.Text = _server.LatestVersion.ToString();

if (_server.LatestVersion > _server.CurrentVersion)
{
btnUpdate.Visible = true;
Expand All @@ -280,15 +284,17 @@ private void Initialize()
btnUpdate.Visible = false;
btnCancel.Visible = false;
btnExit.Enabled = true;
if (_server.GetPlayCount() >= 0)
if (_server.GetPlayCount() >= 0 || _server.GetInProgressRecordingCount() >= 0)
{
lblPlayCount.Text = _server.PlayCount.ToString();
lblInProgressRecordingCountLabel.Text = _server.InProgressRecordingCount.ToString();
}
else
{
lblPlayCount.Text = "Unknown";
lblInProgressRecordingCountLabel.Text = "Unknown";
}
}
}
}
catch (LocalSystem.Msi.MSIException ex)
{
Expand Down
11 changes: 6 additions & 5 deletions TE.Plex/classes/SilentUpdate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,23 +184,24 @@ private bool CheckIfCanUpdate()
}

int playCount = _server.GetPlayCount();
int inProgressRecordingCount = _server.GetInProgressRecordingCount();

// No item is currently being played
if (playCount == 0)
if (playCount == 0 && inProgressRecordingCount == 0)
{
Log.Write("The server is not in use continuing to perform the update.");
_timer.Enabled = false;
return true;
}
// At least one item is being played
else if (playCount > 0)
else if (playCount > 0 || inProgressRecordingCount > 0)
{
if (!ForceUpdate)
{
Log.Write("The server is in use. Waiting for all media to be stopped before performing the update.");
Log.Write("The server is in use. Waiting for all media and/or in progress recordings to be stopped before performing the update.");
_timer.Interval =
Convert.ToDouble(Math.Abs(WaitTime) * 1000);
_timer.Enabled = true;
_timer.Enabled = true;
return false;
}
else
Expand Down Expand Up @@ -229,7 +230,7 @@ private void Initialize()
_server = new MediaServer(true);
_timer = new Timer(DefaultWaitTime * 1000);
_timer.Elapsed += OnTimedEvent;
_timer.Enabled = false;
_timer.Enabled = false;
}
catch (AppNotInstalledException)
{
Expand Down

0 comments on commit 06afead

Please sign in to comment.