当前位置: 首页>>代码示例>>C#>>正文


C# RESTMethods.RequestInfo类代码示例

本文整理汇总了C#中Duplicati.Server.WebServer.RESTMethods.RequestInfo的典型用法代码示例。如果您正苦于以下问题:C# RequestInfo类的具体用法?C# RequestInfo怎么用?C# RequestInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


RequestInfo类属于Duplicati.Server.WebServer.RESTMethods命名空间,在下文中一共展示了RequestInfo类的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
            });
        }
开发者ID:thekrugers,项目名称:duplicati,代码行数:46,代码来源:BackupDefaults.cs

示例2: 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));
        }
开发者ID:thekrugers,项目名称:duplicati,代码行数:7,代码来源:ServerSettings.cs

示例3: POST

        public void POST(string key, RequestInfo info)
        {
            string url;

            using(var sr = new System.IO.StreamReader(info.Request.Body, System.Text.Encoding.UTF8, true))
                url = sr.ReadToEnd();

            switch (key)
            {
                case "dbpath":
                    LocateDbUri(url, info);
                    return;
                case "list":
                    ListFolder(url, info);
                    return;
                case "create":
                    CreateFolder(url, info);
                    return;
                case "test":
                    TestConnection(url, info);
                    return;
                default:
                    info.ReportClientError("No such method");
                    return;
            }
        }
开发者ID:thekrugers,项目名称:duplicati,代码行数:26,代码来源:RemoteOperation.cs

示例4: GET

        public void GET(string key, RequestInfo info)
        {
            var parts = (key ?? "").Split(new char[] { '/' }, 2);

            if (parts.Length <= 1)
            {
                info.ReportClientError("No url or operation supplied");
                return;
            }

            var url = Library.Utility.Uri.UrlDecode(parts.First());
            var operation = parts.Last().ToLowerInvariant();

            switch (operation)
            {
                case "dbpath":
                    LocateDbUri(url, info);
                    return;
                case "list":
                    ListFolder(url, info);
                    return;
                case "create":
                    CreateFolder(url, info);
                    return;
                case "test":
                    TestConnection(url, info);
                    return;
                default:
                    info.ReportClientError("No such method");
                    return;
            }
        }
开发者ID:thekrugers,项目名称:duplicati,代码行数:32,代码来源:RemoteOperation.cs

示例5: 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);

        }
开发者ID:AlexFRAN,项目名称:duplicati,代码行数:31,代码来源:Backup.cs

示例6: POST

        public void POST(string key, RequestInfo info)
        {
            if ("import".Equals(key, StringComparison.InvariantCultureIgnoreCase))
            {
                ImportBackup(info);
                return;
            }

            AddOrUpdateBackupData data = null;
            try
            {
                data = Serializer.Deserialize<AddOrUpdateBackupData>(new StringReader(info.Request.Form["data"].Value));
                if (data.Backup == null)
                {
                    info.ReportClientError("Data object had no backup entry");
                    return;
                }

                data.Backup.ID = null;

                if (Duplicati.Library.Utility.Utility.ParseBool(info.Request.Form["temporary"].Value, false))
                {
                    using(var tf = new Duplicati.Library.Utility.TempFile())
                        data.Backup.DBPath = tf;

                    Program.DataConnection.RegisterTemporaryBackup(data.Backup);

                    info.OutputOK(new { status = "OK", ID = data.Backup.ID });
                }
                else
                {
                    if (Library.Utility.Utility.ParseBool(info.Request.Form["existing_db"].Value, false))
                    {
                        data.Backup.DBPath = Library.Main.DatabaseLocator.GetDatabasePath(data.Backup.TargetURL, null, false, false);
                        if (string.IsNullOrWhiteSpace(data.Backup.DBPath))
                            throw new Exception("Unable to find remote db path?");
                    }

                    lock(Program.DataConnection.m_lock)
                    {
                        if (Program.DataConnection.Backups.Where(x => x.Name.Equals(data.Backup.Name, StringComparison.InvariantCultureIgnoreCase)).Any())
                        {
                            info.ReportClientError("There already exists a backup with the name: " + data.Backup.Name);
                            return;
                        }

                        Program.DataConnection.AddOrUpdateBackupAndSchedule(data.Backup, data.Schedule);
                    }

                    info.OutputOK(new { status = "OK", ID = data.Backup.ID });
                }
            }
            catch (Exception ex)
            {
                if (data == null)
                    info.ReportClientError(string.Format("Unable to parse backup or schedule object: {0}", ex.Message));
                else
                    info.ReportClientError(string.Format("Unable to save schedule or backup object: {0}", ex.Message));
            }
        }
开发者ID:neilramsay,项目名称:duplicati,代码行数:60,代码来源:Backups.cs

示例7: GET

        public void GET(string key, RequestInfo info)
        {
            long id;
            long.TryParse(key, out id);

            var tf = Program.DataConnection.GetTempFiles().Where(x => x.ID == id).FirstOrDefault();
            if (tf == null)
            {
                info.ReportClientError("Invalid or missing bugreport id");
                return;
            }

            if (!System.IO.File.Exists(tf.Path))
            {
                info.ReportClientError("File is missing");
                return;
            }

            var filename = "bugreport.zip";
            using(var fs = System.IO.File.OpenRead(tf.Path))
            {
                info.Response.ContentLength = fs.Length;
                info.Response.AddHeader("Content-Disposition", string.Format("attachment; filename={0}", filename));
                info.Response.ContentType = "application/octet-stream";

                info.BodyWriter.SetOK();
                info.Response.SendHeaders();
                fs.CopyTo(info.Response.Body);
                info.Response.Send();
            }
        }
开发者ID:HITSUN2015,项目名称:duplicati,代码行数:31,代码来源:BugReport.cs

示例8: 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();
        }
开发者ID:AlexFRAN,项目名称:duplicati,代码行数:7,代码来源:RemoteOperation.cs

示例9: 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
             });
         }
     }
 }
开发者ID:thekrugers,项目名称:duplicati,代码行数:29,代码来源:Changelog.cs

示例10: 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));
            }
        }
开发者ID:thekrugers,项目名称:duplicati,代码行数:35,代码来源:ServerSettings.cs

示例11: POST

        public void POST(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)
                    tasks.Insert(0, task);

                task = tasks.Where(x => x.TaskID == taskid).FirstOrDefault();
                if (task == null)
                {
                    info.ReportClientError("No such task", System.Net.HttpStatusCode.NotFound);
                    return;
                }

                switch (parts.Last().ToLowerInvariant())
                {
                    case "abort":
                        task.Abort();
                        info.OutputOK();
                        return;

                    case "stop":
                        task.Stop();
                        info.OutputOK();
                        return;
                }
            }

            info.ReportClientError("Invalid or missing task id");
        }
开发者ID:chris-cashin,项目名称:duplicati,代码行数:35,代码来源:Task.cs

示例12: 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));
 }
开发者ID:thekrugers,项目名称:duplicati,代码行数:8,代码来源:ServerSetting.cs

示例13: 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
     });
 }
开发者ID:AlexFRAN,项目名称:duplicati,代码行数:8,代码来源:RemoteOperation.cs

示例14: 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)
     });            
 }
开发者ID:HITSUN2015,项目名称:duplicati,代码行数:8,代码来源:Acknowledgements.cs

示例15: GET

 public void GET(string key, RequestInfo info)
 {
     var parts = (key ?? "").Split(new char[] { '/' });
     var path = Duplicati.Library.Utility.Uri.UrlDecode((parts.Length == 2 ? parts.FirstOrDefault() : key ?? ""));
     var command = parts.Length == 2 ? parts.Last() : null;
     if (string.IsNullOrEmpty(path))
         path = info.Request.QueryString["path"].Value;
     
     Process(command, path, info);
 }
开发者ID:HITSUN2015,项目名称:duplicati,代码行数:10,代码来源:Filesystem.cs


注:本文中的Duplicati.Server.WebServer.RESTMethods.RequestInfo类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。