• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# RESTMethods.RequestInfo类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



RequestInfo类属于Duplicati.Server.WebServer.RESTMethods命名空间,在下文中一共展示了RequestInfo类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


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


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


示例18: GET

        public void GET(string key, RequestInfo info)
        {
            var schedules = Program.DataConnection.Schedules;
            var backups = Program.DataConnection.Backups;

            var all = from n in backups
                select new AddOrUpdateBackupData() {
                Backup = (Database.Backup)n,
                Schedule =
                    (from x in schedules
                        where x.Tags != null && x.Tags.Contains("ID=" + n.ID)
                        select (Database.Schedule)x).FirstOrDefault()
                };

            info.BodyWriter.OutputOK(all.ToArray());
        }
开发者ID:neilramsay,项目名称:duplicati,代码行数:16,代码来源:Backups.cs


示例19: UploadFile

        private void UploadFile(string uri, RequestInfo info)
        {
            var data = info.Request.QueryString["data"].Value;
            var remotename = info.Request.QueryString["filename"].Value;

            using(var ms = new System.IO.MemoryStream())   
            using(var b = Duplicati.Library.DynamicLoader.BackendLoader.GetBackend(uri, new Dictionary<string, string>()))
            {
                using(var tf = new Duplicati.Library.Utility.TempFile())
                {
                    System.IO.File.WriteAllText(tf, data);
                    b.Put(remotename, tf);
                }
            }

            info.OutputOK();
        }
开发者ID:AlexFRAN,项目名称:duplicati,代码行数:17,代码来源:RemoteOperation.cs


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

            if (r.EncryptedFiles && backup.Settings.Any(x => string.Equals("--no-encryption", x.Name, StringComparison.InvariantCultureIgnoreCase)))
                info.ReportServerError("encrypted-storage");
            else
                info.OutputOK(r.Filesets);
        }
开发者ID:AlexFRAN,项目名称:duplicati,代码行数:17,代码来源:Backup.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Messages.DicomMessage类代码示例发布时间:2022-05-24
下一篇:
C# WebServer.BodyWriter类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap