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

C# WebServer.BodyWriter类代码示例

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

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



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

示例1: GetBackup

        private void GetBackup(HttpServer.IHttpRequest request, HttpServer.IHttpResponse response, HttpServer.Sessions.IHttpSession session, BodyWriter bw)
        {
            HttpServer.HttpInput input = request.Method.ToUpper() == "POST" ? request.Form : request.QueryString;
            var bk = Program.DataConnection.GetBackup(input["id"].Value);
            if (bk == null)
                ReportError(response, bw, "Invalid or missing backup id");
            else
            {
                var scheduleId = Program.DataConnection.GetScheduleIDsFromTags(new string[] { "ID=" + bk.ID });
                var schedule = scheduleId.Any() ? Program.DataConnection.GetSchedule(scheduleId.First()) : null;
                var sourcenames = GetSourceNames(bk);

                //TODO: Filter out the password in both settings and the target url

                bw.OutputOK(new
                {
                    success = true,
                    data = new {
                        Schedule = schedule,
                        Backup = bk,
                        DisplayNames = sourcenames
                    }
                });
            }
        }
开发者ID:admz,项目名称:duplicati,代码行数:25,代码来源:GetBackup.cs


示例2: AddBackup

        private void AddBackup(HttpServer.IHttpRequest request, HttpServer.IHttpResponse response, HttpServer.Sessions.IHttpSession session, BodyWriter bw)
        {
            var str = request.Form["data"].Value;

            if (string.IsNullOrWhiteSpace(str))
            {
                ReportError(response, bw, "Missing backup object");
                return;
            }

            AddOrUpdateBackupData data = null;
            try
            {
                data = Serializer.Deserialize<AddOrUpdateBackupData>(new StringReader(str));
                if (data.Backup == null)
                {
                    ReportError(response, bw, "Data object had no backup entry");
                    return;
                }

                data.Backup.ID = null;

                if (Duplicati.Library.Utility.Utility.ParseBool(request.Form["temporary"].Value, false))
                {
                    Program.DataConnection.RegisterTemporaryBackup(data.Backup);

                    bw.OutputOK(new { status = "OK", ID = data.Backup.ID });
                }
                else
                {
                    if (Library.Utility.Utility.ParseBool(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())
                        {
                            ReportError(response, bw, "There already exists a backup with the name: " + data.Backup.Name);
                            return;
                        }

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

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


示例3: HandleControlCGI

 public static void HandleControlCGI(HttpServer.IHttpRequest request, HttpServer.IHttpResponse response, HttpServer.Sessions.IHttpSession session, BodyWriter bw, Type module)
 {
     var method = request.Method;
     if (!string.IsNullOrWhiteSpace(request.Headers["X-HTTP-Method-Override"]))
         method = request.Headers["X-HTTP-Method-Override"];
     
     DoProcess(request, response, session, method, module.Name.ToLowerInvariant(), (request.Method.ToUpper() == "POST" ? request.Form : request.QueryString)["id"].Value);
 }
开发者ID:Xelio,项目名称:duplicati,代码行数:8,代码来源:RESTHandler.cs


示例4: ReadLogData

        private void ReadLogData(HttpServer.IHttpRequest request, HttpServer.IHttpResponse response, HttpServer.Sessions.IHttpSession session, BodyWriter bw)
        {
            HttpServer.HttpInput input = request.Method.ToUpper() == "POST" ? request.Form : request.QueryString;
            var backupid = input["id"].Value;

            if (string.IsNullOrWhiteSpace(backupid))
            {
                List<Dictionary<string, object>> res = null;
                Program.DataConnection.ExecuteWithCommand(x =>
                {
                    res = DumpTable(x, "ErrorLog", "Timestamp", input["offset"].Value, input["pagesize"].Value);
                });

                bw.OutputOK(res);
            }
            else
            {
                var backup = Program.DataConnection.GetBackup(backupid);
                if (backup == null)
                {
                    ReportError(response, bw, "Invalid or missing backup id");
                    return;
                }

                using(var con = (System.Data.IDbConnection)Activator.CreateInstance(Duplicati.Library.SQLiteHelper.SQLiteLoader.SQLiteConnectionType))
                {
                    con.ConnectionString = "Data Source=" + backup.DBPath;
                    con.Open();

                    using(var cmd = con.CreateCommand())
                    {
                        if (Duplicati.Library.Utility.Utility.ParseBool(input["remotelog"].Value, false))
                        {
                            var dt = DumpTable(cmd, "RemoteOperation", "ID", input["offset"].Value, input["pagesize"].Value);

                            // Unwrap raw data to a string
                            foreach(var n in dt)
                                try { n["Data"] = System.Text.Encoding.UTF8.GetString((byte[])n["Data"]); }
                            catch { }

                            bw.OutputOK(dt);
                        }
                        else
                        {
                            var dt = DumpTable(cmd, "LogData", "ID", input["offset"].Value, input["pagesize"].Value);
                            bw.OutputOK(dt);
                        }
                    }
                }
            }
        }
开发者ID:Torgalide,项目名称:duplicati,代码行数:51,代码来源:ReadLogData.cs


示例5: SearchBackupFiles

        private void SearchBackupFiles(HttpServer.IHttpRequest request, HttpServer.IHttpResponse response, HttpServer.Sessions.IHttpSession session, BodyWriter bw)
        {
            HttpServer.HttpInput input = request.Method.ToUpper() == "POST" ? request.Form : request.QueryString;

            var filter = (input["filter"].Value ?? "").Split(new string[] { System.IO.Path.PathSeparator.ToString() }, StringSplitOptions.RemoveEmptyEntries);
            var timestring = input["time"].Value;
            var allversion = Duplicati.Library.Utility.Utility.ParseBool(input["all-versions"].Value, false);

            if (string.IsNullOrWhiteSpace(timestring) && !allversion)
            {
                ReportError(response, bw, "Invalid or missing time");
                return;
            }
            var bk = Program.DataConnection.GetBackup(input["id"].Value);
            if (bk == null)
            {
                ReportError(response, bw, "Invalid or missing backup id");
                return;
            }

            var prefixonly = Duplicati.Library.Utility.Utility.ParseBool(input["prefix-only"].Value, false);
            var foldercontents = Duplicati.Library.Utility.Utility.ParseBool(input["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(bk, filter, prefixonly, allversion, foldercontents, time), false) as Duplicati.Library.Interface.IListResults;

            var result = new Dictionary<string, object>();

            foreach(HttpServer.HttpInputItem n in input)
                result[n.Name] = n.Value;

            result["Filesets"] = r.Filesets;
            result["Files"] = r.Files;

            bw.OutputOK(result);
        }
开发者ID:admz,项目名称:duplicati,代码行数:38,代码来源:SearchBackupFiles.cs


示例6: DeleteBackup

        private void DeleteBackup(HttpServer.IHttpRequest request, HttpServer.IHttpResponse response, HttpServer.Sessions.IHttpSession session, BodyWriter bw)
        {
            HttpServer.HttpInput input = request.Method.ToUpper() == "POST" ? request.Form : request.QueryString;
            var backup = Program.DataConnection.GetBackup(input["id"].Value);
            if (backup == null)
            {
                ReportError(response, bw, "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(input["force"].Value, out force))
                            force = false;

                        if (!force)
                        {
                            bw.WriteJsonObject(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();
                                bw.WriteJsonObject(new { status = "failed", reason = "backup-unstoppable" });
                                return;
                            }
                        }

                        if (hasPaused)
                            Program.LiveControl.Resume();
                    }
                }
                catch (Exception ex)
                {
                    bw.WriteJsonObject(new { status = "error", message = ex.Message });
                    return;
                }
            }

            Program.DataConnection.DeleteBackup(backup);

            //We have fiddled with the schedules
            Program.Scheduler.Reschedule();

            bw.OutputOK();
        }
开发者ID:Berimor66,项目名称:duplicati,代码行数:80,代码来源:DeleteBackup.cs


示例7: SendCommand

        private void SendCommand(HttpServer.IHttpRequest request, HttpServer.IHttpResponse response, HttpServer.Sessions.IHttpSession session, BodyWriter bw)
        {
            HttpServer.HttpInput input = request.Method.ToUpper() == "POST" ? request.Form : request.QueryString;

            string command = input["command"].Value ?? "";

            switch (command.ToLowerInvariant())
            {
                case "check-update":
                    RESTHandler.DoProcess(request, response, session, "POST", typeof(RESTMethods.Updates).Name.ToLowerInvariant(), "check");
                    return;

                case "install-update":
                    RESTHandler.DoProcess(request, response, session, "POST", typeof(RESTMethods.Updates).Name.ToLowerInvariant(), "install");
                    return;

                case "activate-update":
                    RESTHandler.DoProcess(request, response, session, "POST", typeof(RESTMethods.Updates).Name.ToLowerInvariant(), "activate");
                    return;

                case "pause":
                    RESTHandler.DoProcess(request, response, session, "POST", typeof(RESTMethods.ServerState).Name.ToLowerInvariant(), "pause");
                    return;

                case "resume":
                    RESTHandler.DoProcess(request, response, session, "POST", typeof(RESTMethods.ServerState).Name.ToLowerInvariant(), "resume");
                    return;

                case "stop":
                case "abort":
                    {
                        var key = string.Format("{0}/{1}", input["taskid"].Value, command);
                        RESTHandler.DoProcess(request, response, session, "POST", typeof(RESTMethods.Task).Name.ToLowerInvariant(), key);
                    }
                    return;

                case "is-backup-active":
                    {
                        var key = string.Format("{0}/isactive", Library.Utility.Uri.UrlPathEncode(input["id"].Value));
                        RESTHandler.DoProcess(request, response, session, "GET", typeof(RESTMethods.Backup).Name.ToLowerInvariant(), key);
                    }
                    return;

                case "run":
                case "run-backup":
                    {
                        var key = string.Format("{0}/start", Library.Utility.Uri.UrlPathEncode(input["id"].Value));
                        RESTHandler.DoProcess(request, response, session, "POST", typeof(RESTMethods.Backup).Name.ToLowerInvariant(), key);
                    }
                    return;

                case "run-verify":
                    {
                        var key = string.Format("{0}/verify", Library.Utility.Uri.UrlPathEncode(input["id"].Value));
                        RESTHandler.DoProcess(request, response, session, "POST", typeof(RESTMethods.Backup).Name.ToLowerInvariant(), key);
                    }
                    return;

                case "run-repair-update":
                    {
                        var key = string.Format("{0}/repairupdate", Library.Utility.Uri.UrlPathEncode(input["id"].Value));
                        RESTHandler.DoProcess(request, response, session, "POST", typeof(RESTMethods.Backup).Name.ToLowerInvariant(), key);
                    }
                    return;

                case "run-repair":
                    {
                        var key = string.Format("{0}/repair", Library.Utility.Uri.UrlPathEncode(input["id"].Value));
                        RESTHandler.DoProcess(request, response, session, "POST", typeof(RESTMethods.Backup).Name.ToLowerInvariant(), key);
                    }
                    return;
                case "create-report":
                    {
                        var key = string.Format("{0}/createreport", Library.Utility.Uri.UrlPathEncode(input["id"].Value));
                        RESTHandler.DoProcess(request, response, session, "POST", typeof(RESTMethods.Backup).Name.ToLowerInvariant(), key);
                    }
                    return;

                default:
                    {
                        var key = string.Format("{0}", Library.Utility.Uri.UrlPathEncode(input["command"].Value));
                        RESTHandler.DoProcess(request, response, session, "POST", typeof(RESTMethods.WebModule).Name.ToLowerInvariant(), key);
                        return;
                    }
            }
        }
开发者ID:HITSUN2015,项目名称:duplicati,代码行数:86,代码来源:ControlHandler.cs


示例8: GetBackupDefaults

 private void GetBackupDefaults(HttpServer.IHttpRequest request, HttpServer.IHttpResponse response, HttpServer.Sessions.IHttpSession session, BodyWriter bw)
 {   
     RESTHandler.HandleControlCGI(request, response, session, bw, typeof(RESTMethods.BackupDefaults));
 }
开发者ID:HITSUN2015,项目名称:duplicati,代码行数:4,代码来源:ControlHandler.cs


示例9: DismissNotification

 private void DismissNotification(HttpServer.IHttpRequest request, HttpServer.IHttpResponse response, HttpServer.Sessions.IHttpSession session, BodyWriter bw)
 {
     request.Method = "DELETE";
     RESTHandler.HandleControlCGI(request, response, session, bw, typeof(RESTMethods.Notification));
 }
开发者ID:HITSUN2015,项目名称:duplicati,代码行数:5,代码来源:ControlHandler.cs


示例10: ImportBackup

 private void ImportBackup(HttpServer.IHttpRequest request, HttpServer.IHttpResponse response, HttpServer.Sessions.IHttpSession session, BodyWriter bw)
 {
     RESTHandler.DoProcess(request, response, session, "POST", typeof(RESTMethods.Backups).Name.ToLowerInvariant(), "import");
 }
开发者ID:HITSUN2015,项目名称:duplicati,代码行数:4,代码来源:ControlHandler.cs


示例11: ListBackupSets

 private void ListBackupSets(HttpServer.IHttpRequest request, HttpServer.IHttpResponse response, HttpServer.Sessions.IHttpSession session, BodyWriter bw)
 {
     var input = request.Method.ToUpper() == "POST" ? request.Form : request.QueryString;
     var key = string.Format("{0}/filesets", input["id"].Value);
     RESTHandler.DoProcess(request, response, session, request.Method, typeof(RESTMethods.Backup).Name.ToLowerInvariant(), key);
 }
开发者ID:HITSUN2015,项目名称:duplicati,代码行数:6,代码来源:ControlHandler.cs


示例12: GetAcknowledgements

 private void GetAcknowledgements(HttpServer.IHttpRequest request, HttpServer.IHttpResponse response, HttpServer.Sessions.IHttpSession session, BodyWriter bw)
 {
     RESTHandler.HandleControlCGI(request, response, session, bw, typeof(RESTMethods.Acknowledgements));
 }
开发者ID:HITSUN2015,项目名称:duplicati,代码行数:4,代码来源:ControlHandler.cs


示例13: UpdateBackup

 private void UpdateBackup(HttpServer.IHttpRequest request, HttpServer.IHttpResponse response, HttpServer.Sessions.IHttpSession session, BodyWriter bw)
 {
     request.Method = HttpServer.Method.Put;
     RESTHandler.HandleControlCGI(request, response, session, bw, typeof(RESTMethods.Backup));
 }
开发者ID:HITSUN2015,项目名称:duplicati,代码行数:5,代码来源:ControlHandler.cs


示例14: GetFolderContents

 private void GetFolderContents(HttpServer.IHttpRequest request, HttpServer.IHttpResponse response, HttpServer.Sessions.IHttpSession session, BodyWriter bw)
 {
     RESTHandler.DoProcess(request, response, session, request.Method, typeof(RESTMethods.Filesystem).Name.ToLowerInvariant(), Library.Utility.Uri.UrlPathEncode(request.QueryString["path"].Value));
 }      
开发者ID:HITSUN2015,项目名称:duplicati,代码行数:4,代码来源:ControlHandler.cs


示例15: SearchBackupFiles

        private void SearchBackupFiles(HttpServer.IHttpRequest request, HttpServer.IHttpResponse response, HttpServer.Sessions.IHttpSession session, BodyWriter bw)
        {
            var input = request.Method.Equals("POST", StringComparison.InvariantCultureIgnoreCase) ? request.Form : request.QueryString;
            var key = string.Format("{0}/files/{1}", input["id"].Value, input["filter"].Value);

            RESTHandler.DoProcess(request, response, session, request.Method, typeof(RESTMethods.Backup).Name.ToLowerInvariant(), key);

        }
开发者ID:HITSUN2015,项目名称:duplicati,代码行数:8,代码来源:ControlHandler.cs


示例16: SetServerOptions

 private void SetServerOptions(HttpServer.IHttpRequest request, HttpServer.IHttpResponse response, HttpServer.Sessions.IHttpSession session, BodyWriter bw)
 {
     request.Method = "PATCH";
     RESTHandler.HandleControlCGI(request, response, session, bw, typeof(RESTMethods.ServerSettings));
 }
开发者ID:HITSUN2015,项目名称:duplicati,代码行数:5,代码来源:ControlHandler.cs


示例17: ExportBackup

 private void ExportBackup(HttpServer.IHttpRequest request, HttpServer.IHttpResponse response, HttpServer.Sessions.IHttpSession session, BodyWriter bw)
 {
     var input = request.Method.ToUpper() == "POST" ? request.Form : request.QueryString;
     var key = string.Format("{0}/export", Library.Utility.Uri.UrlPathEncode(input["id"].Value));
     RESTHandler.DoProcess(request, response, session, request.Method, typeof(RESTMethods.Backup).Name.ToLowerInvariant(), key);
 }
开发者ID:HITSUN2015,项目名称:duplicati,代码行数:6,代码来源:ControlHandler.cs


示例18: CreateRemoteFolder

 private void CreateRemoteFolder(HttpServer.IHttpRequest request, HttpServer.IHttpResponse response, HttpServer.Sessions.IHttpSession session, BodyWriter bw)
 {
     var input = request.Method.ToUpper() == "POST" ? request.Form : request.QueryString;
     var key = string.Format("{0}/create", Library.Utility.Uri.UrlPathEncode(input["url"].Value));
     RESTHandler.DoProcess(request, response, session, request.Method, typeof(RESTMethods.RemoteOperation).Name.ToLowerInvariant(), key);
 }
开发者ID:HITSUN2015,项目名称:duplicati,代码行数:6,代码来源:ControlHandler.cs


示例19: GetNotifications

 private void GetNotifications(HttpServer.IHttpRequest request, HttpServer.IHttpResponse response, HttpServer.Sessions.IHttpSession session, BodyWriter bw)
 {
     RESTHandler.HandleControlCGI(request, response, session, bw, typeof(RESTMethods.Notifications));
 }
开发者ID:HITSUN2015,项目名称:duplicati,代码行数:4,代码来源:ControlHandler.cs


示例20: ListSystemInfo

 private void ListSystemInfo(HttpServer.IHttpRequest request, HttpServer.IHttpResponse response, HttpServer.Sessions.IHttpSession session, BodyWriter bw)
 {
     RESTHandler.HandleControlCGI(request, response, session, bw, typeof(RESTMethods.SystemInfo));
 }
开发者ID:HITSUN2015,项目名称:duplicati,代码行数:4,代码来源:ControlHandler.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# RESTMethods.RequestInfo类代码示例发布时间:2022-05-24
下一篇:
C# Physics.RigidBody类代码示例发布时间: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