本文整理汇总了C#中Duplicati.Server.WebServer.RESTMethods.RequestInfo.OutputOK方法的典型用法代码示例。如果您正苦于以下问题:C# RequestInfo.OutputOK方法的具体用法?C# RequestInfo.OutputOK怎么用?C# RequestInfo.OutputOK使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Duplicati.Server.WebServer.RESTMethods.RequestInfo
的用法示例。
在下文中一共展示了RequestInfo.OutputOK方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GET
public void GET(string key, RequestInfo info)
{
// Start with a scratch object
var o = new Newtonsoft.Json.Linq.JObject();
// Add application wide settings
o.Add("ApplicationOptions", new Newtonsoft.Json.Linq.JArray(
from n in Program.DataConnection.Settings
select Newtonsoft.Json.Linq.JObject.FromObject(n)
));
try
{
// Add built-in defaults
Newtonsoft.Json.Linq.JObject n;
using(var s = new System.IO.StreamReader(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(System.Reflection.Assembly.GetExecutingAssembly().GetName().Name + ".newbackup.json")))
n = (Newtonsoft.Json.Linq.JObject)Newtonsoft.Json.JsonConvert.DeserializeObject(s.ReadToEnd());
MergeJsonObjects(o, n);
}
catch
{
}
try
{
// Add install defaults/overrides, if present
var path = System.IO.Path.Combine(Duplicati.Library.AutoUpdater.UpdaterManager.InstalledBaseDir, "newbackup.json");
if (System.IO.File.Exists(path))
{
Newtonsoft.Json.Linq.JObject n;
n = (Newtonsoft.Json.Linq.JObject)Newtonsoft.Json.JsonConvert.DeserializeObject(System.IO.File.ReadAllText(path));
MergeJsonObjects(o, n);
}
}
catch
{
}
info.OutputOK(new
{
success = true,
data = o
});
}
示例2: GET
public void GET(string key, RequestInfo info)
{
var fromUpdate = info.Request.QueryString["from-update"].Value;
if (!Library.Utility.Utility.ParseBool(fromUpdate, false))
{
var path = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "changelog.txt");
info.OutputOK(new GetResponse() {
Status = "OK",
Version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(),
Changelog = System.IO.File.ReadAllText(path)
});
}
else
{
var updateInfo = Program.DataConnection.ApplicationSettings.UpdatedVersion;
if (updateInfo == null)
{
info.ReportClientError("No update found");
}
else
{
info.OutputOK(new GetResponse() {
Status = "OK",
Version = updateInfo.Version,
Changelog = updateInfo.ChangeInfo
});
}
}
}
示例3: SearchFiles
private void SearchFiles(IBackup backup, string filterstring, RequestInfo info)
{
var filter = Library.Utility.Uri.UrlDecode(filterstring ?? "").Split(new string[] { System.IO.Path.PathSeparator.ToString() }, StringSplitOptions.RemoveEmptyEntries);
var timestring = info.Request.QueryString["time"].Value;
var allversion = Duplicati.Library.Utility.Utility.ParseBool(info.Request.QueryString["all-versions"].Value, false);
if (string.IsNullOrWhiteSpace(timestring) && !allversion)
{
info.ReportClientError("Invalid or missing time");
return;
}
var prefixonly = Duplicati.Library.Utility.Utility.ParseBool(info.Request.QueryString["prefix-only"].Value, false);
var foldercontents = Duplicati.Library.Utility.Utility.ParseBool(info.Request.QueryString["folder-contents"].Value, false);
var time = new DateTime();
if (!allversion)
time = Duplicati.Library.Utility.Timeparser.ParseTimeInterval(timestring, DateTime.Now);
var r = Runner.Run(Runner.CreateListTask(backup, filter, prefixonly, allversion, foldercontents, time), false) as Duplicati.Library.Interface.IListResults;
var result = new Dictionary<string, object>();
foreach(HttpServer.HttpInputItem n in info.Request.QueryString)
result[n.Name] = n.Value;
result["Filesets"] = r.Filesets;
result["Files"] = r.Files;
info.OutputOK(result);
}
示例4: CreateFolder
private void CreateFolder(string uri, RequestInfo info)
{
using(var b = Duplicati.Library.DynamicLoader.BackendLoader.GetBackend(uri, new Dictionary<string, string>()))
b.CreateFolder();
info.OutputOK();
}
示例5: GET
public void GET(string key, RequestInfo info)
{
var adv_props = from n in Program.DataConnection.GetSettings(Database.Connection.APP_SETTINGS_ID)
select new KeyValuePair<string, string>(n.Name, n.Value);
info.OutputOK(adv_props.ToDictionary(x => x.Key, x => x.Value));
}
示例6: PATCH
public void PATCH(string key, RequestInfo info)
{
string str = info.Request.Form["data"].Value;
if (string.IsNullOrWhiteSpace(str))
str = new StreamReader(info.Request.Body, System.Text.Encoding.UTF8).ReadToEnd();
if (string.IsNullOrWhiteSpace(str))
{
info.ReportClientError("Missing data object");
return;
}
Dictionary<string, string> data = null;
try
{
data = Serializer.Deserialize<Dictionary<string, string>>(new StringReader(str));
if (data == null)
{
info.ReportClientError("Data object had no entry");
return;
}
Program.DataConnection.ApplicationSettings.UpdateSettings(data, false);
info.OutputOK();
}
catch (Exception ex)
{
if (data == null)
info.ReportClientError(string.Format("Unable to parse data object: {0}", ex.Message));
else
info.ReportClientError(string.Format("Unable to save settings: {0}", ex.Message));
}
}
示例7: LocateDbUri
private void LocateDbUri(string uri, RequestInfo info)
{
var path = Library.Main.DatabaseLocator.GetDatabasePath(uri, null, false, false);
info.OutputOK(new {
Exists = !string.IsNullOrWhiteSpace(path),
Path = path
});
}
示例8: GET
public void GET(string key, RequestInfo info)
{
var path = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "acknowledgements.txt");
info.OutputOK(new GetResponse() {
Status = "OK",
Acknowledgements = System.IO.File.ReadAllText(path)
});
}
示例9: 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));
}
示例10: GET
public void GET(string key, RequestInfo info)
{
bool isError;
long id = 0;
long.TryParse(key, out id);
if (info.LongPollCheck(Program.StatusEventNotifyer, ref id, out isError))
{
//Make sure we do not report a higher number than the eventnotifyer says
var st = new Serializable.ServerStatus();
st.LastEventID = id;
info.OutputOK(st);
}
else if (!isError)
{
info.OutputOK(new Serializable.ServerStatus());
}
}
示例11: POST
public void POST(string key, RequestInfo info)
{
var input = info.Request.Form;
switch ((key ?? "").ToLowerInvariant())
{
case "suppressdonationmessages":
Library.Main.Utility.SuppressDonationMessages = true;
info.OutputOK();
return;
case "showdonationmessages":
Library.Main.Utility.SuppressDonationMessages = false;
info.OutputOK();
return;
default:
info.ReportClientError("No such action", System.Net.HttpStatusCode.NotFound);
return;
}
}
示例12: POST
public void POST(string key, RequestInfo info)
{
var input = info.Request.Form;
switch ((key ?? "").ToLowerInvariant())
{
case "pause":
if (input.Contains("duration") && !string.IsNullOrWhiteSpace(input["duration"].Value))
{
TimeSpan ts;
try
{
ts = Library.Utility.Timeparser.ParseTimeSpan(input["duration"].Value);
}
catch (Exception ex)
{
info.ReportClientError(ex.Message);
return;
}
if (ts.TotalMilliseconds > 0)
Program.LiveControl.Pause(ts);
else
Program.LiveControl.Pause();
}
else
{
Program.LiveControl.Pause();
}
info.OutputOK();
return;
case "resume":
Program.LiveControl.Resume();
info.OutputOK();
return;
default:
info.ReportClientError("No such action", System.Net.HttpStatusCode.NotFound);
return;
}
}
示例13: GET
public void GET(string key, RequestInfo info)
{
var parts = (key ?? "").Split(new char[] { '/' }, 2);
long taskid;
if (parts.Length == 2 && long.TryParse(parts.First(), out taskid))
{
var task = Program.WorkThread.CurrentTask;
var tasks = Program.WorkThread.CurrentTasks;
if (task != null && task.TaskID == taskid)
{
info.OutputOK(new { Status = "Running" });
return;
}
task = tasks.Where(x => x.TaskID == taskid).FirstOrDefault();
if (tasks.Where(x => x.TaskID == taskid).FirstOrDefault() == null)
{
KeyValuePair<long, Exception>[] matches;
lock(Program.MainLock)
matches = Program.TaskResultCache.Where(x => x.Key == taskid).ToArray();
if (matches.Length == 0)
info.ReportClientError("No such task found", System.Net.HttpStatusCode.NotFound);
else
info.OutputOK(new {
Status = matches[0].Value == null ? "Completed" : "Failed",
ErrorMessage = matches[0].Value == null ? null : matches[0].Value.Message,
Exception = matches[0].Value == null ? null : matches[0].Value.ToString()
});
}
else
{
info.OutputOK(new { Status = "Waiting" });
}
}
else
{
info.ReportClientError("Invalid request");
}
}
示例14: 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();
}
}
示例15: ListFileSets
private void ListFileSets(IBackup backup, RequestInfo info)
{
var input = info.Request.QueryString;
var extra = new Dictionary<string, string>();
extra["list-sets-only"] = "true";
if (input["include-metadata"].Value != null)
extra["list-sets-only"] = (!Library.Utility.Utility.ParseBool(input["include-metadata"].Value, false)).ToString();
if (input["from-remote-only"].Value != null)
extra["no-local-db"] = Library.Utility.Utility.ParseBool(input["from-remote-only"].Value, false).ToString();
var r = Runner.Run(Runner.CreateTask(DuplicatiOperation.List, backup, extra), false) as Duplicati.Library.Interface.IListResults;
info.OutputOK(r.Filesets);
}