本文整理汇总了C#中Duplicati.Server.WebServer.RESTMethods.RequestInfo.OutputError方法的典型用法代码示例。如果您正苦于以下问题:C# RequestInfo.OutputError方法的具体用法?C# RequestInfo.OutputError怎么用?C# RequestInfo.OutputError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Duplicati.Server.WebServer.RESTMethods.RequestInfo
的用法示例。
在下文中一共展示了RequestInfo.OutputError方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GET
public void GET(string key, RequestInfo info)
{
var prop = typeof(Database.ApplicationSettings).GetProperty(key);
if (prop == null)
info.OutputError(null, System.Net.HttpStatusCode.NotFound, "Not found");
else
info.OutputOK(prop.GetValue(Program.DataConnection.ApplicationSettings));
}
示例2: PUT
public void PUT(string key, RequestInfo info)
{
var prop = typeof(Database.ApplicationSettings).GetProperty(key);
if (prop == null)
info.OutputError(null, System.Net.HttpStatusCode.NotFound, "Not found");
else
{
var dict = new Dictionary<string, string>();
dict[key] = info.Request.Form["data"].Value;
Program.DataConnection.ApplicationSettings.UpdateSettings(dict, false);
info.OutputOK();
}
}
示例3: DELETE
public void DELETE(string key, RequestInfo info)
{
var backup = Program.DataConnection.GetBackup(key);
if (backup == null)
{
info.ReportClientError("Invalid or missing backup id");
return;
}
if (Program.WorkThread.Active)
{
try
{
//TODO: It's not safe to access the values like this,
//because the runner thread might interfere
var nt = Program.WorkThread.CurrentTask;
if (backup.Equals(nt == null ? null : nt.Backup))
{
bool force;
if (!bool.TryParse(info.Request.QueryString["force"].Value, out force))
force = false;
if (!force)
{
info.OutputError(new { status = "failed", reason = "backup-in-progress" });
return;
}
bool hasPaused = Program.LiveControl.State == LiveControls.LiveControlState.Paused;
Program.LiveControl.Pause();
try
{
for(int i = 0; i < 10; i++)
if (Program.WorkThread.Active)
{
var t = Program.WorkThread.CurrentTask;
if (backup.Equals(t == null ? null : t.Backup))
System.Threading.Thread.Sleep(1000);
else
break;
}
else
break;
}
finally
{
}
if (Program.WorkThread.Active)
{
var t = Program.WorkThread.CurrentTask;
if (backup.Equals(t == null ? null : t.Backup))
{
if (hasPaused)
Program.LiveControl.Resume();
info.OutputError(new { status = "failed", reason = "backup-unstoppable" });
return;
}
}
if (hasPaused)
Program.LiveControl.Resume();
}
}
catch (Exception ex)
{
info.OutputError(new { status = "error", message = ex.Message });
return;
}
}
//var dbpath = backup.DBPath;
Program.DataConnection.DeleteBackup(backup);
// TODO: Before we activate this,
// we need some strategy to figure out
// if the db is shared with something else
// like the commandline or another backup
/*try
{
if (System.IO.File.Exists(dbpath))
System.IO.File.Delete(dbpath);
}
catch (Exception ex)
{
Program.DataConnection.LogError(null, string.Format("Failed to delete database: {0}", dbpath), ex);
}*/
//We have fiddled with the schedules
Program.Scheduler.Reschedule();
info.OutputOK();
}
示例4:
//引入命名空间
using Duplicati.Server.Serialization.Interface;