SenseNet.Benchmarking.Benchmark.CreateContent C# (CSharp) Метод

CreateContent() приватный Метод

private CreateContent ( HttpContext context ) : void
context System.Web.HttpContext
Результат void
        private void CreateContent(HttpContext context)
        {
            try
            {
                //---- content type

                var contentTypeName = GetRequestParameter("contenttype");
                if (String.IsNullOrEmpty(contentTypeName))
                {
                    WriteError("Parameter 'contenttype' cannot be null or empty.", context);
                    return;
                }

                var contentType = ContentType.GetByName(contentTypeName);
                if (contentType == null)
                {
                    WriteError("Content type not found: " + contentTypeName, context);
                    return;
                }
                //---- create content

                var snPath = GetRequestParameter("snpath");
                if (String.IsNullOrEmpty(snPath))
                {
                    WriteError("Parameter 'snpath' cannot be null or empty.", context);
                    return;
                }

                using (new SenseNet.ContentRepository.Storage.Security.SystemAccount())
                {
                    BenchmarkCounter.Reset();
                    benchmarkTimer = Stopwatch.StartNew();
                    benchmarkTimer.Restart();

                    var parentPath = RepositoryPath.GetParentPath(snPath);

                    BenchmarkCounter.IncrementBy(BenchmarkCounter.CounterName.GetParentPath, benchmarkTimer.ElapsedTicks);
                    benchmarkTimer.Restart();

                    var parent = Node.LoadNode(parentPath);
                    if (parent == null)
                    {
                        WriteError("Cannot load the parent: " + snPath, context);
                        return;
                    }

                    BenchmarkCounter.IncrementBy(BenchmarkCounter.CounterName.LoadParent, benchmarkTimer.ElapsedTicks);
                    benchmarkTimer.Restart();



                    var contentName = RepositoryPath.GetFileName(snPath);
                    var content = SnContent.CreateNew(contentTypeName, parent, contentName);

                    BenchmarkCounter.IncrementBy(BenchmarkCounter.CounterName.ContentCreate, benchmarkTimer.ElapsedTicks);
                    benchmarkTimer.Restart();

                    //---- create binary

                    if (contentTypeName == "File")
                    {
                        var fsPath = GetRequestParameter("fspath");
                        if (String.IsNullOrEmpty(snPath))
                        {
                            WriteError("Parameter 'fspath' cannot be null or empty if the content type is 'File'.", context);
                            return;
                        }

                        using (var stream = context.Request.InputStream)
                        {

                            var binaryData = new BinaryData();
                            binaryData.FileName = fsPath; //.Replace("$amp;", "&");
                            binaryData.SetStream(stream);

                            content["Binary"] = binaryData;
                            BenchmarkCounter.IncrementBy(BenchmarkCounter.CounterName.BinarySet, benchmarkTimer.ElapsedTicks);
                            benchmarkTimer.Restart();


                            using (new SenseNet.ContentRepository.Storage.Security.SystemAccount())
                                content.Save();
                        }
                    }
                    else
                    {
                        BenchmarkCounter.IncrementBy(BenchmarkCounter.CounterName.BinarySet, benchmarkTimer.ElapsedTicks);
                        benchmarkTimer.Restart();

                        content.Save();
                    }

                    BenchmarkCounter.IncrementBy(BenchmarkCounter.CounterName.FullSave, benchmarkTimer.ElapsedTicks);
                    benchmarkTimer.Restart();

                }
            }
            catch (Exception e)
            {
                //WriteError(String.Concat(e.Message, "\r", e.StackTrace), context);
                Logger.WriteException(e);
                WriteError(e, context);
                return;
            }

            WriteCounters(context);

            context.Response.StatusCode = 200;
            context.Response.Write("ok");
        }
        private void WriteCounters(HttpContext context)