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


C# IHttpContext.Log方法代码示例

本文整理汇总了C#中IHttpContext.Log方法的典型用法代码示例。如果您正苦于以下问题:C# IHttpContext.Log方法的具体用法?C# IHttpContext.Log怎么用?C# IHttpContext.Log使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IHttpContext的用法示例。


在下文中一共展示了IHttpContext.Log方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnBulkOperation

		private void OnBulkOperation(IHttpContext context, Func<string, IndexQuery, bool, RavenJArray> batchOperation)
		{
			var match = urlMatcher.Match(context.GetRequestUrl());
			var index = match.Groups[2].Value;
			if (string.IsNullOrEmpty(index))
			{
				context.SetStatusToBadRequest();
				return;
			}
			var allowStale = context.GetAllowStale();
			var indexQuery = context.GetIndexQueryFromHttpContext(maxPageSize: int.MaxValue);

		    var status = new BulkOperationStatus();
			var sp = Stopwatch.StartNew();
			long id = 0;

			var task = Task.Factory.StartNew(() =>
			{
				var array = batchOperation(index, indexQuery, allowStale);
			    status.State = array;
				status.Completed = true;

				context.Log(log => log.Debug("\tBatch Operation worked on {0:#,#;;0} documents in {1}, task #: {2}", array.Length, sp.Elapsed, id));
			});

			Database.AddTask(task, status, out id);

			context.WriteJson(new
			{
				OperationId = id
			});
		}
开发者ID:robashton,项目名称:ravendb,代码行数:32,代码来源:DocumentBatch.cs

示例2: Respond

		public override void Respond(IHttpContext context)
		{
			if (string.IsNullOrEmpty(context.Request.QueryString["no-op"]) == false)
			{
				// this is a no-op request which is there just to force the client HTTP layer to handle the authentication
				// only used for legacy clients
				return; 
			}
			if("generate-single-use-auth-token".Equals(context.Request.QueryString["op"],StringComparison.InvariantCultureIgnoreCase))
			{
				// using windows auth with anonymous access = none sometimes generate a 401 even though we made two requests
				// instead of relying on windows auth, which require request buffering, we generate a one time token and return it.
				// we KNOW that the user have access to this db for writing, since they got here, so there is no issue in generating 
				// a single use token for them.
				var token = server.RequestAuthorizer.GenerateSingleUseAuthToken(Database, context.User);
				context.WriteJson(new
				{
					Token = token
				});
				return;
			}

			if (HttpContext.Current != null)
			{
				HttpContext.Current.Server.ScriptTimeout = 60*60*6; // six hours should do it, I think.
			}
			var options = new BulkInsertOptions
			{
				CheckForUpdates = context.GetCheckForUpdates(),
				CheckReferencesInIndexes = context.GetCheckReferencesInIndexes()
			};

			var operationId = ExtractOperationId(context);
			var sp = Stopwatch.StartNew();

			var status = new BulkInsertStatus();

			int documents = 0;
			var mre = new ManualResetEventSlim(false);

			var currentDatbase = Database;
			var task = Task.Factory.StartNew(() =>
			{
				currentDatbase.BulkInsert(options, YieldBatches(context, mre, batchSize => documents += batchSize), operationId);
			    status.Documents = documents;
			    status.Completed = true;
			});

			long id;
			Database.AddTask(task, status, out id);

			mre.Wait(Database.WorkContext.CancellationToken);

			context.Log(log => log.Debug("\tBulk inserted received {0:#,#;;0} documents in {1}, task #: {2}", documents, sp.Elapsed, id));

			context.WriteJson(new
			{
				OperationId = id
			});
		}
开发者ID:robashton,项目名称:ravendb,代码行数:60,代码来源:BulkInsert.cs

示例3: Respond

		public override void Respond(IHttpContext context)
		{
			if (string.IsNullOrEmpty(context.Request.QueryString["no-op"]) == false)
			{
				// this is a no-op request which is there just to force the client HTTP layer
				// to handle the authentication
				return; 
			}

			var options = new BulkInsertOptions
			{
				CheckForUpdates = context.GetCheckForUpdates(),
				CheckReferencesInIndexes = context.GetCheckReferencesInIndexes()
			};

			var sp = Stopwatch.StartNew();

			var documents = Database.BulkInsert(options, YieldBatches(context));

			context.Log(log => log.Debug("\tBulk inserted {0:#,#;;0} documents in {1}", documents, sp.Elapsed));

			context.WriteJson(new
			{
				Documents = documents
			});
		}
开发者ID:carlosagsmendes,项目名称:ravendb,代码行数:26,代码来源:BulkInsert.cs

示例4: Respond

		public override void Respond(IHttpContext context)
		{
			if (string.IsNullOrEmpty(context.Request.QueryString["no-op"]) == false)
			{
				// this is a no-op request which is there just to force the client HTTP layer
				// to handle the authentication
				return; 
			}
			if (HttpContext.Current != null)
			{
				HttpContext.Current.Server.ScriptTimeout = 60*60*6; // six hours should do it, I think.
			}
			var options = new BulkInsertOptions
			{
				CheckForUpdates = context.GetCheckForUpdates(),
				CheckReferencesInIndexes = context.GetCheckReferencesInIndexes()
			};

			var sp = Stopwatch.StartNew();

			var status = new RavenJObject
			{
				{"Documents", 0},
				{"Completed", false}
			};

			int documents = 0;
			var mre = new ManualResetEventSlim(false);

			var currentDatbase = Database;
			var task = Task.Factory.StartNew(() =>
			{
				documents = currentDatbase.BulkInsert(options, YieldBatches(context, mre));
				status["Documents"] = documents;
				status["Completed"] = true;
			});

			long id;
			Database.AddTask(task, status, out id);

			mre.Wait(Database.WorkContext.CancellationToken);

			context.Log(log => log.Debug("\tBulk inserted received {0:#,#;;0} documents in {1}, task #: {2}", documents, sp.Elapsed, id));

			context.WriteJson(new
			{
				OperationId = id
			});
		}
开发者ID:Nordis,项目名称:ravendb,代码行数:49,代码来源:BulkInsert.cs

示例5: ExecuteQuery

        private QueryResultWithIncludes ExecuteQuery(IHttpContext context, string index, CancellationToken token, out Etag indexEtag)
        {
            var indexQuery = context.GetIndexQueryFromHttpContext(Database.Configuration.MaxPageSize);
            RewriteDateQueriesFromOldClients(context, indexQuery);

            var sp = Stopwatch.StartNew();
            var result = index.StartsWith("dynamic/", StringComparison.OrdinalIgnoreCase) || index.Equals("dynamic", StringComparison.OrdinalIgnoreCase) ?
                PerformQueryAgainstDynamicIndex(context, index, indexQuery, token, out indexEtag) :
                PerformQueryAgainstExistingIndex(context, index, indexQuery, token, out indexEtag);

            sp.Stop();

            context.Log(log => log.Debug(() =>
            {
                var sb = new StringBuilder("\tQuery: ")
                    .Append(indexQuery.Query)
                    .AppendLine();
                sb.Append("\t").AppendFormat("Time: {0:#,#;;0} ms", sp.ElapsedMilliseconds).AppendLine();

                if (result == null)
                    return sb.ToString();

                sb.Append("\tIndex: ")
                    .AppendLine(result.IndexName);
                sb.Append("\t").AppendFormat("Results: {0:#,#;;0} returned out of {1:#,#;;0} total.", result.Results.Count, result.TotalResults).AppendLine();

                return sb.ToString();
            }));

            return result;
        }
开发者ID:925coder,项目名称:ravendb,代码行数:31,代码来源:Index.cs

示例6: Batch

		private void Batch(IHttpContext context)
		{
			var jsonCommandArray = context.ReadJsonArray();

			var transactionInformation = GetRequestTransaction(context);
			var commands = (from RavenJObject jsonCommand in jsonCommandArray
			                select CommandDataFactory.CreateCommand(jsonCommand, transactionInformation))
				.ToArray();

			context.Log(log => log.Debug(()=>
			{
				if(commands.Length > 15) // this is probably an import method, we will input minimal information, to avoid filling up the log
				{
					return "\tExecuted " + string.Join(", ", commands.GroupBy(x => x.Method).Select(x => string.Format("{0:#,#} {1} operations", x.Count(), x.Key)));
				}

				var sb = new StringBuilder();
				foreach (var commandData in commands)
				{
					sb.AppendFormat("\t{0} {1}{2}", commandData.Method, commandData.Key, Environment.NewLine);
				}
				return sb.ToString();
			}));

			var batchResult = Database.Batch(commands);
			context.WriteJson(batchResult);
		}
开发者ID:JPT123,项目名称:ravendb,代码行数:27,代码来源:DocumentBatch.cs

示例7: Batch

    	private void Batch(IHttpContext context)
        {
            var jsonCommandArray = context.ReadJsonArray();

    		var transactionInformation = GetRequestTransaction(context);
    		var commands = (from RavenJObject jsonCommand in jsonCommandArray
    		                select CommandDataFactory.CreateCommand(jsonCommand, transactionInformation))
    			.ToArray();

			context.Log(log => log.Debug(()=>
			{
				var sb = new StringBuilder();
				foreach (var commandData in commands)
				{
					sb.AppendFormat("\t{0} {1}{2}", commandData.Method, commandData.Key, Environment.NewLine);
				}
				return sb.ToString();
			}));

    		var batchResult = Database.Batch(commands);
            context.WriteJson(batchResult);
        }
开发者ID:larsudengaard,项目名称:ravendb,代码行数:22,代码来源:DocumentBatch.cs

示例8: Batch

    	private void Batch(IHttpContext context)
        {
            var jsonCommandArray = context.ReadJsonArray();

    		var transactionInformation = GetRequestTransaction(context);
    		var commands = (from JObject jsonCommand in jsonCommandArray
    		                select CommandDataFactory.CreateCommand(jsonCommand, transactionInformation))
    			.ToArray();

			context.Log(log =>
			{
				if (log.IsDebugEnabled)
				{
					foreach (var commandData in commands)
					{
						log.DebugFormat("\t{0} {1}", commandData.Method, commandData.Key);
					}
				}
			});

    		var batchResult = Database.Batch(commands);
            context.WriteJson(batchResult);
        }
开发者ID:philiphoy,项目名称:ravendb,代码行数:23,代码来源:DocumentBatch.cs


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