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


C# HttpApplicationState.Lock方法代码示例

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


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

示例1: GetSessionId

 private string GetSessionId(HttpApplicationState Application)
 {
     if (Application["sessionId"] == null)
     {
         Application.Lock();
         Application["sessionId"] = opentok.CreateSession().Id;
         Application.UnLock();
     }
     return (string)Application["sessionId"];
 }
开发者ID:jeffswartz,项目名称:OpenTok-DotNet,代码行数:10,代码来源:HomeController.cs

示例2: SetProgress

 /// <summary>
 /// 设置当前上传的进度信息
 /// 根据UploadID记录在Application中
 /// </summary>
 /// <param name="uploadId"></param>
 /// <param name="progress"></param>
 /// <param name="application"></param>
 void SetProgress(string uploadId, Progress progress, HttpApplicationState application)
 {
     if (uploadId == null || uploadId == string.Empty || progress == null)
         return;
     application.Lock();
     application["OpenlabUpload_" + uploadId] = progress;
     application.UnLock();
 }
开发者ID:rongcheng,项目名称:benz,代码行数:15,代码来源:HttpUploadModule.cs

示例3: SystemMessage

 public static void SystemMessage(HttpApplicationState Application, string sERROR_TYPE, StackFrame stack, string sMESSAGE)
 {
     if ( Application == null )
         return;
     // 08/12/2007 Paul.  Ignore the exception generated by Response.Redirect.
     // 08/13/2007 Paul.  Instead of ignoring the the english abort message,
     // transition to the above function that ignores the abort exception.  Every file will need to be touched.
     //if ( sMESSAGE == "Thread was being aborted." )
     //	return;
     try
     {
         Application.Lock();
         DataTable dt = Application["SystemErrors"] as DataTable;
         if ( dt == null )
         {
             dt = new DataTable();
             DataColumn colCREATED_BY   = new DataColumn("CREATED_BY"  , Type.GetType("System.Guid"    ));
             DataColumn colDATE_ENTERED = new DataColumn("DATE_ENTERED", Type.GetType("System.DateTime"));
             DataColumn colERROR_TYPE   = new DataColumn("ERROR_TYPE"  , Type.GetType("System.String"  ));
             DataColumn colUSER_NAME    = new DataColumn("USER_NAME"   , Type.GetType("System.String"  ));
             DataColumn colFILE_NAME    = new DataColumn("FILE_NAME"   , Type.GetType("System.String"  ));
             DataColumn colMETHOD       = new DataColumn("METHOD"      , Type.GetType("System.String"  ));
             DataColumn colLINE_NUMBER  = new DataColumn("LINE_NUMBER" , Type.GetType("System.String"  ));
             DataColumn colMESSAGE      = new DataColumn("MESSAGE"     , Type.GetType("System.String"  ));
             dt.Columns.Add(colCREATED_BY  );
             dt.Columns.Add(colDATE_ENTERED);
             dt.Columns.Add(colERROR_TYPE  );
             dt.Columns.Add(colUSER_NAME   );
             dt.Columns.Add(colFILE_NAME   );
             dt.Columns.Add(colMETHOD      );
             dt.Columns.Add(colLINE_NUMBER );
             dt.Columns.Add(colMESSAGE     );
             Application["SystemErrors"] = dt;
         }
         DataRow row = dt.NewRow();
         dt.Rows.Add(row);
         // 12/22/2007 Paul.  The current context will be null when inside a timer.
         if ( HttpContext.Current != null && HttpContext.Current.Session != null )
         {
             row["CREATED_BY"  ] = Security.USER_ID         ;
             row["USER_NAME"   ] = Security.USER_NAME       ;
         }
         row["DATE_ENTERED"] = DateTime.Now             ;
         row["ERROR_TYPE"  ] = sERROR_TYPE              ;
         row["MESSAGE"     ] = sMESSAGE                 ;
         if ( stack != null )
         {
             string sFILE_NAME = stack.GetFileName();
             if ( HttpContext.Current != null && HttpContext.Current.Request != null )
             {
                 if ( !Sql.IsEmptyString(sFILE_NAME) )
                 {
                     // 04/16/2006 Paul.  Use native function to get file name.
                     // 08/01/2007 Paul.  Include part of the path in the file name. Remove the physical root as it is not useful.
                     sFILE_NAME = sFILE_NAME.Replace(HttpContext.Current.Request.PhysicalApplicationPath, "~" + Path.DirectorySeparatorChar);
                     row["FILE_NAME"] = sFILE_NAME.Replace(Path.DirectorySeparatorChar, '/');
                 }
             }
             else
             {
                 row["FILE_NAME"] = sFILE_NAME;
             }
             row["METHOD"      ] = stack.GetMethod()        ;
             row["LINE_NUMBER" ] = stack.GetFileLineNumber();
         }
     }
     finally
     {
         Application.UnLock();
     }
 }
开发者ID:NALSS,项目名称:splendidcrm-99885,代码行数:71,代码来源:SplendidError.cs

示例4: SystemMessage

		public static void SystemMessage(HttpApplicationState Application, HttpContext Context, string sERROR_TYPE, StackFrame stack, string sMESSAGE)
		{
			if ( Application == null )
				return;
			// 08/12/2007   Ignore the exception generated by Response.Redirect. 
			// 08/13/2007   Instead of ignoring the the english abort message, 
			// transition to the above function that ignores the abort exception.  Every file will need to be touched. 
			//if ( sMESSAGE == "Thread was being aborted." )
			//	return;
			try
			{
				Application.Lock();
				DataTable dt = Application["SystemErrors"] as DataTable;
				if ( dt == null )
				{
					dt = new DataTable();
					DataColumn colCREATED_BY   = new DataColumn("CREATED_BY"  , Type.GetType("System.Guid"    ));
					DataColumn colDATE_ENTERED = new DataColumn("DATE_ENTERED", Type.GetType("System.DateTime"));
					DataColumn colERROR_TYPE   = new DataColumn("ERROR_TYPE"  , Type.GetType("System.String"  ));
					DataColumn colUSER_NAME    = new DataColumn("USER_NAME"   , Type.GetType("System.String"  ));
					DataColumn colFILE_NAME    = new DataColumn("FILE_NAME"   , Type.GetType("System.String"  ));
					DataColumn colMETHOD       = new DataColumn("METHOD"      , Type.GetType("System.String"  ));
					DataColumn colLINE_NUMBER  = new DataColumn("LINE_NUMBER" , Type.GetType("System.String"  ));
					DataColumn colMESSAGE      = new DataColumn("MESSAGE"     , Type.GetType("System.String"  ));
					dt.Columns.Add(colCREATED_BY  );
					dt.Columns.Add(colDATE_ENTERED);
					dt.Columns.Add(colERROR_TYPE  );
					dt.Columns.Add(colUSER_NAME   );
					dt.Columns.Add(colFILE_NAME   );
					dt.Columns.Add(colMETHOD      );
					dt.Columns.Add(colLINE_NUMBER );
					dt.Columns.Add(colMESSAGE     );
					Application["SystemErrors"] = dt;
				}

				Guid   gUSER_ID          = Guid.Empty;
				string sUSER_NAME        = String.Empty;
				string sMACHINE          = String.Empty;
				string sASPNET_SESSIONID = String.Empty;
				string sREMOTE_HOST      = String.Empty;
				string sSERVER_HOST      = String.Empty;
				string sTARGET           = String.Empty;
				string sRELATIVE_PATH    = String.Empty;
				string sPARAMETERS       = String.Empty;
				string sFILE_NAME        = String.Empty;
				string sMETHOD           = String.Empty;
				Int32  nLINE_NUMBER      = 0;

				try
				{
					// 09/17/2009   Azure does not support MachineName.  Just ignore the error. 
					sMACHINE = System.Environment.MachineName;
				}
				catch
				{
				}
				DataRow row = dt.NewRow();
				dt.Rows.Add(row);
				try
				{
					// 12/22/2007   The current context will be null when inside a timer. 
					if ( Context != null && Context.Session != null )
					{
						gUSER_ID          = Security.USER_ID  ;
						sUSER_NAME        = Security.USER_NAME;
						sASPNET_SESSIONID = Context.Session.SessionID;
					}
				}
				catch
				{
				}
				row["CREATED_BY"  ] = gUSER_ID    ;
				row["USER_NAME"   ] = sUSER_NAME  ;
				row["DATE_ENTERED"] = DateTime.Now;
				row["ERROR_TYPE"  ] = sERROR_TYPE ;
				row["MESSAGE"     ] = sMESSAGE    ;
				try
				{
					if ( Context != null && Context.Request != null )
					{
						HttpRequest Request = Context.Request;
						sREMOTE_HOST      = Request.UserHostName;
						sSERVER_HOST      = Request.Url.Host    ;
						sTARGET           = Request.Path        ;
						sRELATIVE_PATH    = Request.AppRelativeCurrentExecutionFilePath;
						sPARAMETERS       = Request.QueryString.ToString();
					}
				}
				catch
				{
				}
				if ( stack != null )
				{
					sFILE_NAME   = stack.GetFileName();
					sMETHOD      = stack.GetMethod().ToString();
					nLINE_NUMBER = stack.GetFileLineNumber();
					try
					{
						if ( Context != null && Context.Request != null )
						{
//.........这里部分代码省略.........
开发者ID:huamouse,项目名称:Taoqi,代码行数:101,代码来源:SplendidError.cs

示例5: SystemMessage

		public static void SystemMessage(HttpApplicationState Application, HttpContext Context, string sERROR_TYPE, StackFrame stack, string sMESSAGE)
		{
			if ( Application == null )
				return;
			try
			{
				Application.Lock();
				// 11/29/2009   Use a global status value that can be polled. 
				Application["SystemSync.Status"] = sMESSAGE;
				DataTable dt = Application["SystemSync.Errors"] as DataTable;
				if ( dt == null )
				{
					dt = new DataTable();
					DataColumn colDATE_ENTERED = new DataColumn("DATE_ENTERED", Type.GetType("System.DateTime"));
					DataColumn colERROR_TYPE   = new DataColumn("ERROR_TYPE"  , Type.GetType("System.String"  ));
					DataColumn colFILE_NAME    = new DataColumn("FILE_NAME"   , Type.GetType("System.String"  ));
					DataColumn colMETHOD       = new DataColumn("METHOD"      , Type.GetType("System.String"  ));
					DataColumn colLINE_NUMBER  = new DataColumn("LINE_NUMBER" , Type.GetType("System.String"  ));
					DataColumn colMESSAGE      = new DataColumn("MESSAGE"     , Type.GetType("System.String"  ));
					dt.Columns.Add(colDATE_ENTERED);
					dt.Columns.Add(colERROR_TYPE  );
					dt.Columns.Add(colMESSAGE     );
					dt.Columns.Add(colFILE_NAME   );
					dt.Columns.Add(colMETHOD      );
					dt.Columns.Add(colLINE_NUMBER );
					Application["SystemSync.Errors"] = dt;
				}

				Guid   gUSER_ID          = Guid.Empty;
				string sUSER_NAME        = String.Empty;
				string sMACHINE          = String.Empty;
				string sREMOTE_URL       = Sql.ToString(Application["Taoqi_REMOTE_URL"]);
				string sFILE_NAME        = String.Empty;
				string sMETHOD           = String.Empty;
				Int32  nLINE_NUMBER      = 0;

				try
				{
					// 09/17/2009   Azure does not support MachineName.  Just ignore the error. 
					sMACHINE = System.Environment.MachineName;
				}
				catch
				{
				}
				DataRow row = dt.NewRow();
				dt.Rows.Add(row);
				try
				{
					// 12/22/2007   The current context will be null when inside a timer. 
					if ( Context != null && Context.Session != null )
					{
						gUSER_ID          = Security.USER_ID  ;
						sUSER_NAME        = Security.USER_NAME;
					}
				}
				catch
				{
				}
				row["DATE_ENTERED"] = DateTime.Now;
				row["ERROR_TYPE"  ] = sERROR_TYPE ;
				row["MESSAGE"     ] = sMESSAGE    ;
				if ( stack != null )
				{
					sFILE_NAME   = stack.GetFileName();
					sMETHOD      = stack.GetMethod().ToString();
					nLINE_NUMBER = stack.GetFileLineNumber();
					try
					{
						if ( Context != null && Context.Request != null )
						{
							if ( !Sql.IsEmptyString(sFILE_NAME) )
							{
								// 04/16/2006   Use native function to get file name. 
								// 08/01/2007   Include part of the path in the file name. Remove the physical root as it is not useful. 
								sFILE_NAME = sFILE_NAME.Replace(Context.Request.PhysicalApplicationPath, "~" + Path.DirectorySeparatorChar);
								sFILE_NAME = sFILE_NAME.Replace(Path.DirectorySeparatorChar, '/');
							}
						}
					}
					catch
					{
					}
					row["FILE_NAME"   ] = sFILE_NAME;
					row["METHOD"      ] = sMETHOD;
					row["LINE_NUMBER" ] = nLINE_NUMBER;
				}

				try
				{
					DbProviderFactory dbf = DbProviderFactories.GetFactory(Application);
					using ( IDbConnection con = dbf.CreateConnection() )
					{
						con.Open();
						// 10/07/2009   We need to create our own global transaction ID to support auditing and workflow on SQL Azure, PostgreSQL, Oracle, DB2 and MySQL. 
						using ( IDbTransaction trn = Sql.BeginTransaction(con) )
						{
							try
							{
								SqlProcs.spSYSTEM_SYNC_LOG_InsertOnly(gUSER_ID, sMACHINE, sREMOTE_URL, sERROR_TYPE, sFILE_NAME, sMETHOD, nLINE_NUMBER, sMESSAGE, trn);
								trn.Commit();
//.........这里部分代码省略.........
开发者ID:huamouse,项目名称:Taoqi,代码行数:101,代码来源:SyncError.cs


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