Files
duplicati/Duplicati/Server/Serializable/ServerStatus.cs
T
kenneth@hexad.dk 11c8f232b7 Fixed a quit problem.
Changed the status reporting method to not include status for the current running backup.
That will be implemented with a separate call so the tray icon can reduce the number of requests.

git-svn-id: https://duplicati.googlecode.com/svn/trunk@1332 59da171f-624f-0410-aa54-27559c288bec
2012-06-06 12:58:27 +00:00

121 lines
3.8 KiB
C#

#region "Disclaimer / License"
// Copyright (C) 2011, Kenneth Skovhede
// http://www.hexad.dk, opensource@hexad.dk
//
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; either version 2.1 of the
// License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#endregion
using System;
using System.Linq;
using System.Collections.Generic;
using Duplicati.Server.Serialization;
namespace Duplicati.Server.Serializable
{
/// <summary>
/// This class collects all reportable status properties into a single class that can be exported as JSON
/// </summary>
public class ServerStatus : IServerStatus
{
public LiveControlState ProgramState
{
get { return EnumConverter.Convert<LiveControlState>(Program.LiveControl.State); }
}
public RunnerState ActiveBackupState
{
get { return Program.Runner.CurrentState; }
}
public long ActiveScheduleId
{
get
{
IDuplicityTask t = Program.WorkThread.CurrentTask;
if (t == null || t.Schedule == null)
return -1;
else
return t.Schedule.ID;
}
}
public IList<long> SchedulerQueueIds
{
get { return Program.Scheduler.WorkerQueue.Select(x => x.ID).ToList(); }
}
public bool HasWarning { get { return Program.HasWarning; } }
public bool HasError { get { return Program.HasError; } }
public SuggestedStatusIcon SuggestedStatusIcon
{
get
{
if (this.ActiveScheduleId < 0)
{
if (this.ProgramState == LiveControlState.Paused)
return SuggestedStatusIcon.Paused;
if (this.HasError)
return SuggestedStatusIcon.ReadyError;
if (this.HasWarning)
return SuggestedStatusIcon.ReadyWarning;
return SuggestedStatusIcon.Ready;
}
else
{
if (this.ProgramState == LiveControlState.Running)
return SuggestedStatusIcon.Active;
else
return SuggestedStatusIcon.ActivePaused;
}
}
}
public DateTime LastLogUpdate
{
get
{
var lst = Program.DataConnection.GetObjects<Datamodel.Log>().Select(x => x.EndTime).ToList();
if (lst.Count == 0)
return new DateTime(0);
else
return lst.Max();
}
}
public DateTime EstimatedPauseEnd
{
get
{
return Program.LiveControl.EstimatedPauseEnd;
}
}
private long m_lastEventID = Program.StatusEventNotifyer.EventNo;
public long LastEventID
{
get { return m_lastEventID; }
set { m_lastEventID = value; }
}
public long LastDataUpdateID { get { return Program.LastDataUpdateID; } }
}
}