public void HandleSpan(MessageSink messageSink, MessageActionSpan actionSpan) { var httpRequest = WebRequest.Create(actionSpan.Data); var httpResponse = httpRequest.GetResponse(); messageSink("URL Redirect: " + httpResponse.ResponseUri.AbsoluteUri); }
void ReportErrorToVS(IVsGeneratorProgress generatorProgress, Severity severity, object context, string message, object[] args) { int line = 0, col = 1; string message2 = Localize.From(message, args); if (context is LNode) { var range = ((LNode)context).Range; line = range.Start.Line; col = range.Start.PosInLine; } else if (context is SourcePos) { line = ((SourcePos)context).Line; col = ((SourcePos)context).PosInLine; } else if (context is SourceRange) { line = ((SourceRange)context).Start.Line; col = ((SourceRange)context).Start.PosInLine; } else { message2 = MessageSink.LocationString(context) + ": " + message2; } bool subwarning = severity < Severity.Warning; int n = subwarning ? 2 : severity == Severity.Warning ? 1 : 0; generatorProgress.GeneratorError(n, 0u, message2, (uint)line - 1u, (uint)col - 1u); }
public bool HandleMessage(MessageSink messageSink, string message) { if (message[0] != '!' && message[0] != '/' && (message[0] != ' ' || message[0] != '/')) { return(false); } var command = new Command(message); ICommandHandler commandHandler = null; if (CommandHandlers.ContainsKey(command.Name)) { commandHandler = CommandHandlers[command.Name]; } else if (CommandHandlers.ContainsKey(command.Name)) { commandHandler = LowercaseCommandHandlers[command.Name.ToLower()]; } else { return(false); } commandHandler.Handle(messageSink, command); return(true); }
public void AddMetadata(string metadataKey, string metadataValue) { if (metadataKey == null) { throw new ArgumentNullException(@"metadataKey"); } if (metadataValue == null) { throw new ArgumentNullException(@"metadataValue"); } lock (syncRoot) { if (!IsRunning) { throw new InvalidOperationException("Cannot add metadata unless the test step is running."); } testStep.Metadata.Add(metadataKey, metadataValue); MessageSink.Publish(new TestStepMetadataAddedMessage() { StepId = testStep.Id, MetadataKey = metadataKey, MetadataValue = metadataValue }); } }
void WriteMessageCore(Severity severity, object ctx, string fmt, params object[] args) { string msg = fmt; try { msg = Localize.Localized(fmt, args); } catch { } var pos = GetSourcePos(ctx); if (pos == null) { msg = MessageSink.ContextToString(ctx) + ": " + msg; } var lvi = new ListViewItem(new string[] { pos != null ? pos.Line.ToString() : "", pos != null ? pos.PosInLine.ToString() : "", severity.ToString(), msg }); lvi.BackColor = severity >= Severity.Error ? Color.Pink : severity >= Severity.Warning ? Color.LightYellow : messageList.BackColor; messageList.Items.Add(lvi); }
public void TestLambdaMethod() { // Test lambda-style method TestCs(@"#useSequenceExpressions; int fSquare(int x) => f(x)::fx * fx; " , @" int fSquare(int x) { var fx = f(x); return fx * fx; }" ); // Test lambda function using (MessageSink.SetDefault(new SeverityMessageFilter(_msgHolder, Severity.DebugDetail))) { _msgHolder.List.Clear(); TestCs(@"#useSequenceExpressions; void f() { Func<int,int> fSquare = (int x) => f(x)::fx * fx; } " , @" void f() { Func<int,int> fSquare = (int x) => { var fx = f(x); return fx * fx; }; }" ); Assert.AreEqual(1, _msgHolder.List.Count); Assert.AreEqual(Severity.Warning, _msgHolder.List[0].Severity); _msgHolder.WriteListTo(TraceMessageSink.Value); } }
private void btnRegister_Click(object sender, EventArgs e) { int count = RegisterOrUnregister(MessageSink.FromDelegate(MessageBoxWriter), false); MessageBox.Show(string.Format("Registered with {0} Visual Studio edition(s).", count)); Close(); }
public void Handle(MessageSink messageSink, Command command) { using (var client = new WebClient()) { var response = client.DownloadString(statsurl); var data = JsonConvert.DeserializeObject <Dictionary <string, string> >(response); if (data.ContainsKey("offline")) { messageSink("Stream is offline."); return; } var listeners = int.Parse(data["listeners"]); if (listeners > 0) { messageSink(string.Format("Now playing with {0} listener{1}: {2} - {3}\n{4}", listeners, ((listeners == 1) ? "" : "s"), data["artist"], data["title"], url)); } else { messageSink(string.Format("Now playing: {0} - {1}\n{2}", data["artist"], data["title"], url)); } } }
public void MessageSink_should_be_able_to_infer_message_type() { var specPass = new SpecPass(1, GetType().Assembly.GetName().Name); var specFail = new SpecFail(1, GetType().Assembly.GetName().Name); var loggingActor = Sys.ActorOf <LoggingActor>(); Sys.EventStream.Subscribe(TestActor, typeof(Debug)); loggingActor.Tell("LOG ME!"); //capture the logged message var foundMessage = ExpectMsg <Debug>(); //format the string as it would appear when reported by multinode test runner var nodeMessageStr = "[NODE1]" + foundMessage; var nodeMessageFragment = "[NODE1] Only part of a message!"; var runnerMessageStr = foundMessage.ToString(); MessageSink.DetermineMessageType(nodeMessageStr).ShouldBe(MessageSink.MultiNodeTestRunnerMessageType.NodeLogMessage); MessageSink.DetermineMessageType(runnerMessageStr).ShouldBe(MessageSink.MultiNodeTestRunnerMessageType.RunnerLogMessage); MessageSink.DetermineMessageType(specPass.ToString()).ShouldBe(MessageSink.MultiNodeTestRunnerMessageType.NodePassMessage); MessageSink.DetermineMessageType(specFail.ToString()).ShouldBe(MessageSink.MultiNodeTestRunnerMessageType.NodeFailMessage); MessageSink.DetermineMessageType("[Node2][FAIL-EXCEPTION] Type: Xunit.Sdk.TrueException").ShouldBe(MessageSink.MultiNodeTestRunnerMessageType.NodeFailureException); MessageSink.DetermineMessageType(nodeMessageFragment).ShouldBe(MessageSink.MultiNodeTestRunnerMessageType.NodeLogFragment); MessageSink.DetermineMessageType("foo!").ShouldBe(MessageSink.MultiNodeTestRunnerMessageType.Unknown); }
public void AddDryrunMessage(string message) { if (m_parent != null) { m_parent.AddDryrunMessage(message); } else { lock (Logging.Log.Lock) { if (m_is_reporting) { return; } try { m_is_reporting = true; Logging.Log.WriteMessage(message, Duplicati.Library.Logging.LogMessageType.Information, null); if (MessageSink != null) { MessageSink.DryrunEvent(message); } } finally { m_is_reporting = false; } } } }
public void TestNoBodyError() { using (MessageSink.PushCurrent(_msgHolder)) { TestEcs("void Set(set int X);", "void Set(set int X);"); // Body required Assert.IsTrue(_msgHolder.List.Count > 0, "warning expected"); } }
public void WithTest() { int n = MacroProcessor.NextTempCounter; TestEcs("with (foo) { .bar = .baz(#); }", "{ var tmp_1 = foo; tmp_1.bar = tmp_1.baz(tmp_1); }".Replace("tmp_1", "tmp_" + n)); // This test ensures with() doesn't act like it is in an expression context n = MacroProcessor.NextTempCounter; TestEcs("if (c) with (foo) { .bar = .baz(#); }", "if (c) { var tmp_1 = foo; tmp_1.bar = tmp_1.baz(tmp_1); }".Replace("tmp_1", "tmp_" + n)); // Ignore note about 'declined to process... with' using (MessageSink.PushCurrent(_msgHolder)) { n = MacroProcessor.NextTempCounter; TestEcs(@" with (jekyll) { .A = 1; with(mr.hyde()) { x = .F(x); } with(.B + .C(.D)); }" , @"{ var tmp_{0} = jekyll; tmp_{0}.A = 1; { var tmp_{1} = mr.hyde(); x = tmp_{1}.F(x); } with(tmp_{0}.B + tmp_{0}.C(tmp_{0}.D)); }" .Replace("{0}", (n + 1).ToString()).Replace("{1}", (n).ToString())); } }
// Scan source code for strings and print them out! void ScanForCsStrings(string path, IMessageSink msgOut) { var files = Directory.EnumerateFiles(path, "*.cs", SearchOption.AllDirectories); using (MessageSink.SetContextToString(ctx => { // Show line and column instead of character range if (ctx is SourceRange) { return(((SourceRange)ctx).Start.ToString()); } return(MessageSink.GetLocationString(ctx)); })) { foreach (string file in files) { // Important: ignore comments because their values are strings // and we are only interested in actual strings. var code = Loyc.Ecs.EcsLanguageService.Value.ParseFile(file, msgOut, ParsingMode.File, preserveComments: false); var strings = from statement in code from node in statement.Descendants() where node.Value is string && ((string)node.Value).Any(c => char.IsLetter(c)) select node; foreach (var strNode in strings) { msgOut.Write(Severity.Note, strNode.Range, strNode.Value as string); } } } }
public void AddVerboseMessage(string message, params object[] args) { if (m_parent != null) { m_parent.AddVerboseMessage(message, args); } else { lock (Logging.Log.Lock) { if (m_is_reporting) { return; } try { m_is_reporting = true; Logging.Log.WriteMessage(string.Format(message, args), Duplicati.Library.Logging.LogMessageType.Profiling, null); if (MessageSink != null) { MessageSink.VerboseEvent(message, args); } } finally { m_is_reporting = false; } } } }
public void TestDefineFn() { TestLes(@"define WL() { Console.WriteLine(); }; WL(); WL();", @"Console.WriteLine(); Console.WriteLine();"); TestEcs(@"define NL() => Console.WriteLine(); NL(); NL();", @"Console.WriteLine(); Console.WriteLine();"); TestEcs(@"define Methods($T) { void F($T arg) {} void G($T arg) {} } Methods(int); Methods(List<int>);", @"void F(int arg) {} void G(int arg) {} void F(List<int> arg) {} void G(List<int> arg) {}"); TestEcs(@"define WL($format, $(..args)) => Console.WriteLine($format, $(..args)); WL(1, 2, 3);", @"Console.WriteLine(1, 2, 3);"); TestLes(@"define WL($format, $(..args)) { Console.WriteLine($format, $(..args)); }; WL(1, 2, 3);", @"Console.WriteLine(1, 2, 3);"); TestEcs(@"[Passive] define operator=(Foo[$index], $value) => Foo.SetAt($index, $value); x = Foo[y] = z;", @"x = Foo.SetAt(y, z);"); // Test warnings about `$` using (MessageSink.SetDefault(new SeverityMessageFilter(_msgHolder, Severity.DebugDetail))) { _msgHolder.List.Clear(); TestEcs(@"define Foo(w, $x, y, $z) => (x, $y);", @""); Assert.AreEqual(2, _msgHolder.List.Count); TestEcs(@"define Foo(a, b) => (a, b);", @""); Assert.AreEqual(4, _msgHolder.List.Count); Assert.IsTrue(_msgHolder.List.All(msg => msg.Severity == Severity.Warning)); _msgHolder.WriteListTo(TraceMessageSink.Value); } }
public void TestReplace_basics() { // Simple cases using (MessageSink.SetDefault(_msgHolder)) { TestLes(@"replace (nothing => nobody) {nowhere;}", "nowhere;"); Assert.IsTrue(_msgHolder.List.Count > 0, "expected warning about 'no replacements'"); } TestLes(@"replace (a => b) {a;}", "b;"); TestLes(@"replace (7 => seven) {x = 7;}", "x = seven;"); TestLes(@"replace (7() => ""seven"") {x = 7() + 7;}", @"x = ""seven"" + 7;"); TestLes(@"replace (a => b) {@[Hello] a; a(a);}", "@[Hello] b; b(b);"); TestLes("replace (MS => MessageSink; C => Current; W => Write; S => Severity; B => \"Bam!\")\n" + " { MS.C.W(S.Error, @null, B); }", @"MessageSink.Current.Write(Severity.Error, @null, ""Bam!"");"); TestLes(@"replace (Write => Store; Console.Write => Console.Write) " + @"{ Write(x); Console.Write(x); }", "Store(x); Console.Write(x);"); // Swap TestLes("replace (foo => bar; bar => foo) {foo() = bar;}", "bar() = foo;"); TestLes("replace (a => 'a'; 'a' => A; A => a) {'a' = A - a;}", "A = a - 'a';"); // Captures TestBoth("replace (input($capture) => output($capture)) { var i = 21; input(i * 2); };", "replace (input($capture) => output($capture)) { var i = 21; input(i * 2); }", "var i = 21; output(i * 2);"); }
public void TestProcessCommandLineArguments2() { // Generate two options files, where the first refers to the second string atFolder = Environment.ExpandEnvironmentVariables("%TEMP%"); string file1 = "test ProcessCmdLine 1.txt"; string file2 = "test ProcessCmdLine 2.txt"; StreamWriter w = new StreamWriter(Path.Combine(atFolder, file1)); w.WriteLine("\"@" + file2 + "\" fox--jumps\n--over"); w.Close(); w = new StreamWriter(Path.Combine(atFolder, file2)); w.WriteLine("these arguments are ignored (arg limit exceeded)"); w.Close(); // Expand command line and ensure that the arg limit is enforced List <string> args = G.SplitCommandLineArguments("\"@" + file1 + "\" \"lazy dog\""); var options = new DList <KeyValuePair <string, string> >(); var msgs = new MessageHolder(); using (MessageSink.SetDefault(msgs)) UG.ProcessCommandLineArguments(args, options, atFolder, null, null, 5); ExpectList(args.AsListSource(), "@" + file1, "@" + file2, "fox--jumps", "lazy dog"); ExpectList(options, P("over", null)); ExpectList(msgs.List.Select(msg => msg.ToString()).AsListSource(), "@test ProcessCmdLine 2.txt: Warning: Limit of 5 commands exceeded"); }
public void HandleSpan(MessageSink messageSink, MessageActionSpan actionSpan) { if (DateTime.Now.Subtract(lastdoge).Seconds <= 10) { var prefix = actionSpan.Match.Groups[1].ToString(); var word = actionSpan.Match.Groups[2].ToString(); var thesaurus = new Thesaurus(word); if (thesaurus.Success) { var message = ""; foreach (var p in DogeRegEx) { if (thesaurus.Synonyms.Count == 0) { break; } if (p != prefix) { var pos = rnd.Next(thesaurus.Synonyms.Count - 1); message += p + " " + thesaurus.Synonyms[pos] + "\n"; thesaurus.Synonyms.RemoveAt(pos); } } messageSink(message); } } lastdoge = DateTime.Now; }
public void AddMessage(string message) { if (m_parent != null) { m_parent.AddMessage(message); } else { lock (m_lock) { Logging.Log.WriteMessage(message, Duplicati.Library.Logging.LogMessageType.Information); m_messages.Add(message); if (MessageSink != null) { MessageSink.MessageEvent(message); } if (m_db != null && !m_db.IsDisposed) { LogDbMessage("Message", message, null); } } } }
internal void InitializeAndStartStep() { lock (syncRoot) { if (executionStatus != StatusCreated) { throw new InvalidOperationException("Cannot initialize and start the test step twice."); } stopwatch = Stopwatch.StartNew(); // Dispatch the start notification. MessageSink.Publish(new TestStepStartedMessage() { Step = new TestStepData(testStep), CodeElement = testStep.CodeElement }); // Consider the test started. executionStatus = StatusStarted; LifecyclePhase = LifecyclePhases.Starting; // Enter the context. contextCookie = Enter(); } // Note: We exit the lock before manipulating the parent context to avoid reentry. if (parent != null) { parent.Finishing += HandleParentFinishedBeforeThisContext; } }
public void HandleSpan(MessageSink messageSink, MessageActionSpan actionSpan) { var vineid = actionSpan.Match.Groups[2].ToString(); var vine = new Vine(vineid); messageSink("Vine: " + vine.Title + " By: " + vine.Author); }
public void Handle(MessageSink messageSink, Command command) { var slogan = new Slogan(command.FullArguments); if (slogan.Success) { messageSink(slogan.SloganText); } }
public void Handle(MessageSink messageSink, Command command) { var plot = new Plot(); if (plot.Success) { messageSink(plot.PlotText); } }
private static SinkDefinition GetSinkDefinition(MessageSink sink) { var definition = new SinkDefinition(); definition.Id = string.Format("sink{0}", DateTime.Now.Ticks); definition.Type = sink.GetType().AssemblyQualifiedName; LoadPropertyValues(definition, sink); return(definition); }
public void HandleSpan(MessageSink messageSink, MessageActionSpan actionSpan) { var amazon = new Amazon(actionSpan.Match.ToString()); if (amazon.Success) { messageSink("Amazon: " + amazon.Title + "\n\t" + amazon.Price); } }
public void GivenIHaveACleanSiteBasedOn(string siteFolder, string virtualDirectory) { _webHost = new WebHost(_orchardTemp); Host.Initialize(siteFolder, virtualDirectory ?? "/", _dynamicCompilationOption); var shuttle = new Shuttle(); Host.Execute(() => Executor(shuttle)); _messages = shuttle._sink; }
public void MessageSink_should_parse_Node_SpecFail_message_correctly() { var specFail = new SpecFail(1, GetType().Assembly.GetName().Name); NodeCompletedSpecWithFail nodeCompletedSpecWithFail; MessageSink.TryParseFailureMessage(specFail.ToString(), out nodeCompletedSpecWithFail) .ShouldBeTrue("should have been able to parse node failure message"); Assert.Equal(specFail.NodeIndex, nodeCompletedSpecWithFail.NodeIndex); }
private void AssertMessage <T>(MessageSink sink, int expectedCount) where T : ITestCaseMessage { var messages = sink.GetMessages <T>(); foreach (var message in messages) { _output.WriteLine(message.TestCase.DisplayName); } Assert.True(messages.Length == expectedCount, string.Format(" Expected to receive {0} {1} message(s), got {2}", expectedCount, typeof(T).Name, messages.Length)); }
public void MessageSink_should_parse_Node_SpecPass_message_correctly() { var specPass = new SpecPass(1, GetType().Assembly.GetName().Name); NodeCompletedSpecWithSuccess nodeCompletedSpecWithSuccess; MessageSink.TryParseSuccessMessage(specPass.ToString(), out nodeCompletedSpecWithSuccess) .ShouldBeTrue("should have been able to parse node success message"); Assert.Equal(specPass.NodeIndex, nodeCompletedSpecWithSuccess.NodeIndex); }
protected void WriteError(int index, string msg, params object[] args) { if (ErrorSink == null) { throw new FormatException(MessageSink.FormatMessage(Severity.Error, SourceFile.IndexToLine(index), msg, args)); } else { ErrorSink.Write(Severity.Error, SourceFile.IndexToLine(index), msg, args); } }
protected override void DoConfigure(Environment.IConfigSectionNode node) { base.DoConfigure(node); m_Sink = FactoryUtils.MakeAndConfigure<MessageSink>(node[CONFIG_SINK_SECTION], typeof(SMTPMessageSink), args: new object[] { this }); m_FallbackSink = FactoryUtils.MakeAndConfigure<MessageSink>(node[CONFIG_FALLBACK_SINK_SECTION], typeof(NOPMessageSink), args: new object[] { this }); }
public static Duplicati.Library.Interface.IBasicResults Run(IRunnerData data, bool fromQueue) { var backup = data.Backup; if (backup.Metadata == null) backup.Metadata = new Dictionary<string, string>(); try { var options = ApplyOptions(backup, data.Operation, GetCommonOptions(backup, data.Operation)); var sink = new MessageSink(data.TaskID, backup.ID); if (fromQueue) { Program.GenerateProgressState = () => sink.Copy(); Program.StatusEventNotifyer.SignalNewEvent(); } if (data.ExtraOptions != null) foreach(var k in data.ExtraOptions) options[k.Key] = k.Value; if (options.ContainsKey("log-file")) { var file = options["log-file"]; string o; Library.Logging.LogMessageType level; options.TryGetValue("log-level", out o); Enum.TryParse<Library.Logging.LogMessageType>(o, true, out level); options.Remove("log-file"); options.Remove("log-level"); Program.LogHandler.SetOperationFile(file, level); } using(var controller = new Duplicati.Library.Main.Controller(backup.TargetURL, options, sink)) { ((RunnerData)data).Controller = controller; switch (data.Operation) { case DuplicatiOperation.Backup: { var filter = ApplyFilter(backup, data.Operation, GetCommonFilter(backup, data.Operation)); var sources = (from n in backup.Sources let p = SpecialFolders.ExpandEnvironmentVariables(n) where !string.IsNullOrWhiteSpace(p) select p).ToArray(); var r = controller.Backup(sources, filter); UpdateMetadata(backup, r); return r; } case DuplicatiOperation.List: { var r = controller.List(data.FilterStrings); UpdateMetadata(backup, r); return r; } case DuplicatiOperation.Repair: { var r = controller.Repair(); UpdateMetadata(backup, r); return r; } case DuplicatiOperation.Remove: { var r = controller.Delete(); UpdateMetadata(backup, r); return r; } case DuplicatiOperation.Restore: { var r = controller.Restore(data.FilterStrings); UpdateMetadata(backup, r); return r; } case DuplicatiOperation.Verify: { var r = controller.Test(); UpdateMetadata(backup, r); return r; } case DuplicatiOperation.CreateReport: { using(var tf = new Duplicati.Library.Utility.TempFile()) { var r = controller.CreateLogDatabase(tf); var tempid = Program.DataConnection.RegisterTempFile("create-bug-report", r.TargetPath, DateTime.Now.AddDays(3)); if (string.Equals(tf, r.TargetPath, Library.Utility.Utility.ClientFilenameStringComparision)) tf.Protected = true; Program.DataConnection.RegisterNotification( NotificationType.Information, "Bugreport ready", "Bugreport is ready for download", null, null, "bug-report:created:" + tempid, (n, a) => n ); return r; } } default: //TODO: Log this return null; } } } catch (Exception ex) { Program.DataConnection.LogError(data.Backup.ID, string.Format("Failed while executing \"{0}\" with id: {1}", data.Operation, data.Backup.ID), ex); UpdateMetadataError(data.Backup, ex); if (!fromQueue) throw; return null; } finally { ((RunnerData)data).Controller = null; Program.LogHandler.RemoveOperationFile(); } }
public static Duplicati.Library.Interface.IBasicResults Run(IRunnerData data, bool fromQueue) { var backup = data.Backup; Duplicati.Library.Utility.TempFolder tempfolder = null; if (backup.Metadata == null) backup.Metadata = new Dictionary<string, string>(); try { var options = ApplyOptions(backup, data.Operation, GetCommonOptions(backup, data.Operation)); var sink = new MessageSink(data.TaskID, backup.ID); if (fromQueue) { Program.GenerateProgressState = () => sink.Copy(); Program.StatusEventNotifyer.SignalNewEvent(); } if (data.ExtraOptions != null) foreach(var k in data.ExtraOptions) options[k.Key] = k.Value; // Log file is using the internal log-handler // so we can display output in the GUI as well as log // into the given file if (options.ContainsKey("log-file")) { var file = options["log-file"]; string o; Library.Logging.LogMessageType level; options.TryGetValue("log-level", out o); Enum.TryParse<Library.Logging.LogMessageType>(o, true, out level); options.Remove("log-file"); options.Remove("log-level"); Program.LogHandler.SetOperationFile(file, level); } // Pack in the system or task config for easy restore if (data.Operation == DuplicatiOperation.Backup && options.ContainsKey("store-task-config")) { var all_tasks = string.Equals(options["store-task-config"], "all", StringComparison.InvariantCultureIgnoreCase) || string.Equals(options["store-task-config"], "*", StringComparison.InvariantCultureIgnoreCase); var this_task = Duplicati.Library.Utility.Utility.ParseBool(options["store-task-config"], false); options.Remove("store-task-config"); if (all_tasks || this_task) { if (tempfolder == null) tempfolder = new Duplicati.Library.Utility.TempFolder(); var temppath = System.IO.Path.Combine(tempfolder, "task-setup.json"); using(var tempfile = Duplicati.Library.Utility.TempFile.WrapExistingFile(temppath)) { object taskdata = null; if (all_tasks) taskdata = Program.DataConnection.Backups.Where(x => !x.IsTemporary).Select(x => Program.DataConnection.PrepareBackupForExport(Program.DataConnection.GetBackup(x.ID))); else taskdata = new [] { Program.DataConnection.PrepareBackupForExport(data.Backup) }; using(var fs = System.IO.File.OpenWrite(tempfile)) using(var sw = new System.IO.StreamWriter(fs, System.Text.Encoding.UTF8)) Serializer.SerializeJson(sw, taskdata, true); tempfile.Protected = true; string controlfiles = null; options.TryGetValue("control-files", out controlfiles); if (string.IsNullOrWhiteSpace(controlfiles)) controlfiles = tempfile; else controlfiles += System.IO.Path.PathSeparator + tempfile; options["control-files"] = controlfiles; } } } using(tempfolder) using(var controller = new Duplicati.Library.Main.Controller(backup.TargetURL, options, sink)) { ((RunnerData)data).Controller = controller; switch (data.Operation) { case DuplicatiOperation.Backup: { var filter = ApplyFilter(backup, data.Operation, GetCommonFilter(backup, data.Operation)); var sources = (from n in backup.Sources let p = SpecialFolders.ExpandEnvironmentVariables(n) where !string.IsNullOrWhiteSpace(p) select p).ToArray(); var r = controller.Backup(sources, filter); UpdateMetadata(backup, r); return r; } case DuplicatiOperation.List: { var r = controller.List(data.FilterStrings); UpdateMetadata(backup, r); return r; } case DuplicatiOperation.Repair: { var r = controller.Repair(data.FilterStrings == null ? null : new Library.Utility.FilterExpression(data.FilterStrings)); UpdateMetadata(backup, r); return r; } case DuplicatiOperation.RepairUpdate: { var r = controller.UpdateDatabaseWithVersions(); UpdateMetadata(backup, r); return r; } case DuplicatiOperation.Remove: { var r = controller.Delete(); UpdateMetadata(backup, r); return r; } case DuplicatiOperation.Restore: { var r = controller.Restore(data.FilterStrings); UpdateMetadata(backup, r); return r; } case DuplicatiOperation.Verify: { var r = controller.Test(); UpdateMetadata(backup, r); return r; } case DuplicatiOperation.CreateReport: { using(var tf = new Duplicati.Library.Utility.TempFile()) { var r = controller.CreateLogDatabase(tf); var tempid = Program.DataConnection.RegisterTempFile("create-bug-report", r.TargetPath, DateTime.Now.AddDays(3)); if (string.Equals(tf, r.TargetPath, Library.Utility.Utility.ClientFilenameStringComparision)) tf.Protected = true; Program.DataConnection.RegisterNotification( NotificationType.Information, "Bugreport ready", "Bugreport is ready for download", null, null, "bug-report:created:" + tempid, (n, a) => n ); return r; } } default: //TODO: Log this return null; } } } catch (Exception ex) { Program.DataConnection.LogError(data.Backup.ID, string.Format("Failed while executing \"{0}\" with id: {1}", data.Operation, data.Backup.ID), ex); UpdateMetadataError(data.Backup, ex); Library.UsageReporter.Reporter.Report(ex); if (!fromQueue) throw; return null; } finally { ((RunnerData)data).Controller = null; Program.LogHandler.RemoveOperationFile(); } }