private void WriteStructure1()
        {
            SnTrace.Test.Write("1");
            SnTrace.Write("2");
            SnTrace.Test.Write("3");
            SnTrace.Write("4");
            SnTrace.Web.Write("5");
            SnTrace.Repository.Write("6");
            using (var op = SnTrace.Test.StartOperation("7"))
            {
                using (var op1 = SnTrace.StartOperation("8"))
                {
                    op1.Successful = true;
                }
                using (var op2 = SnTrace.Repository.StartOperation("9"))
                {
                    op2.Successful = true;
                }
                using (var op2 = SnTrace.Test.StartOperation("10"))
                {
                    op2.Successful = true;
                }
                using (var op2 = SnTrace.Test.StartOperation("11"))
                {
                    op2.Successful = false;
                }
                op.Successful = true;
            }
            SnTrace.Test.Write("12");
            SnTrace.Repository.Write("13");
            using (var op2 = SnTrace.Test.StartOperation("14"))
            {
                op2.Successful = true;
            }
            SnTrace.Repository.Write("15");
            SnTrace.Test.Write("16");

            SnTrace.Flush();
        }
Exemple #2
0
        protected async Task BackupAsync(CancellationToken cancellationToken)
        {
            var status = await IndexManager.LoadCurrentIndexingActivityStatusAsync(cancellationToken)
                         .ConfigureAwait(false);

            using (var op = SnTrace.StartOperation("#### BACKUP " + this.GetType().Name))
            {
                SnTrace.Write("####   Indexing activity status: " + status);
                Console.WriteLine();
                Console.WriteLine("BACKUP start. Indexing activity status: " + status);

                var response = await _engine.BackupAsync(_backupDirectoryPath, CancellationToken.None)
                               .ConfigureAwait(false);

                if (response.State == BackupState.Started)
                {
                    while (true)
                    {
                        await Task.Delay(400, cancellationToken).ConfigureAwait(false);

                        response = await _engine.QueryBackupAsync(cancellationToken).ConfigureAwait(false);

                        WriteProgress(response);

                        if (response.State != BackupState.Executing)
                        {
                            break;
                        }
                    }
                    //Console.WriteLine("BACKUP finished");
                }
                else
                {
                    Console.WriteLine("BACKUP already started");
                }

                op.Successful = true;
            }
        }
Exemple #3
0
        public void SnTrace_Entries_Operations()
        {
            CleanupAndEnableAll();

            using (var op1 = SnTrace.StartOperation("Op1"))
            {
                // ReSharper disable once UnusedVariable
                using (var op2 = SnTrace.StartOperation("Op2"))
                {
                    SnTrace.Write("asdf");
                }
                using (var op3 = SnTrace.StartOperation("Op3"))
                {
                    SnTrace.Write("qwer");
                    op3.Successful = false;
                }
                using (var op4 = SnTrace.StartOperation("Op4"))
                {
                    SnTrace.Write("yxcv");
                    op4.Successful = true;
                }
                op1.Successful = true;
            }

            var log = DisableAllAndGetLog();

            var entries = log.Select(Entry.Parse).Where(e => e != null).ToArray();

            Assert.AreEqual(11, entries.Length);

            var operationData = string.Join(",", entries.Select(x => x.Status + ":" + x.Message));

            Assert.AreEqual("Start:Op1,Start:Op2,:asdf,UNTERMINATED:Op2,Start:Op3,:qwer,UNTERMINATED:Op3,Start:Op4,:yxcv,End:Op4,End:Op1", operationData);
            Assert.AreEqual(entries[0].OpId, entries[10].OpId);
            Assert.AreEqual(entries[1].OpId, entries[3].OpId);
            Assert.AreEqual(entries[4].OpId, entries[6].OpId);
            Assert.AreEqual(entries[7].OpId, entries[9].OpId);
        }
Exemple #4
0
        public void SnTrace_Operation_Nested()
        {
            CleanupAndEnableAll();
            ResetOperationId();

            using (var op1 = SnTrace.StartOperation("Op1"))
            {
                // ReSharper disable once UnusedVariable
                using (var op2 = SnTrace.StartOperation("Op2"))
                {
                    SnTrace.Write("asdf");
                }
                using (var op3 = SnTrace.StartOperation("Op3"))
                {
                    SnTrace.Write("qwer");
                    op3.Successful = false;
                }
                using (var op4 = SnTrace.StartOperation("Op4"))
                {
                    SnTrace.Write("yxcv");
                    op4.Successful = true;
                }
                op1.Successful = true;
            }

            var log = DisableAllAndGetLog();

            Assert.AreEqual(11, log.Count);

            var messages = string.Join(", ", log.Select(GetMessageFromLine));

            Assert.AreEqual("Op1, Op2, asdf, Op2, Op3, qwer, Op3, Op4, yxcv, Op4, Op1", messages);

            var operationData = string.Join(", ", log.Select(x => GetColumnFromLine(x, 5) + " " + GetColumnFromLine(x, 6)));

            Assert.AreEqual("Op:1 Start, Op:2 Start,  , Op:2 UNTERMINATED, Op:3 Start,  , Op:3 UNTERMINATED, Op:4 Start,  , Op:4 End, Op:1 End", operationData);
        }