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


C# RequestInfo.OutputError方法代码示例

本文整理汇总了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));
 }
开发者ID:thekrugers,项目名称:duplicati,代码行数:8,代码来源:ServerSetting.cs

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

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

示例4:

//引入命名空间
using Duplicati.Server.Serialization.Interface;
开发者ID:videocrap,项目名称:duplicati,代码行数:2,代码来源:Backup.cs


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