本文整理汇总了C#中System.Web.HttpApplicationState.UnLock方法的典型用法代码示例。如果您正苦于以下问题:C# HttpApplicationState.UnLock方法的具体用法?C# HttpApplicationState.UnLock怎么用?C# HttpApplicationState.UnLock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.HttpApplicationState
的用法示例。
在下文中一共展示了HttpApplicationState.UnLock方法的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"];
}
示例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();
}
示例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();
}
}
示例4: SystemMessage
//.........这里部分代码省略.........
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 )
{
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_LOG_InsertOnly(gUSER_ID, sUSER_NAME, sMACHINE, sASPNET_SESSIONID, sREMOTE_HOST, sSERVER_HOST, sTARGET, sRELATIVE_PATH, sPARAMETERS, sERROR_TYPE, sFILE_NAME, sMETHOD, nLINE_NUMBER, sMESSAGE, trn);
trn.Commit();
}
catch//(Exception ex)
{
trn.Rollback();
// 10/26/2008 Can't throw an exception here as it could create an endless loop.
//SplendidError.SystemMessage(Context, "Error", new StackTrace(true).GetFrame(0), Utils.ExpandException(ex));
}
}
}
}
#if DEBUG
catch(Exception ex)
{
System.Diagnostics.Trace.WriteLine(ex.Message);
}
#else
catch
{
}
#endif
try
{
// 04/23/2010 Lets cap the error cache at 100 messages.
// We are going to assume that the top rows are the oldest records.
while ( dt.Rows.Count > 100 )
{
dt.Rows.RemoveAt(0);
}
}
catch
{
}
}
finally
{
Application.UnLock();
}
}
示例5: SystemMessage
//.........这里部分代码省略.........
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();
}
catch //(Exception ex)
{
trn.Rollback();
// 10/26/2008 Can't throw an exception here as it could create an endless loop.
//SplendidError.SystemMessage(Context, "Error", new StackTrace(true).GetFrame(0), Utils.ExpandException(ex));
}
}
}
}
catch
{
}
// 02/11/2012 Dumping the error message will help when debugging.
#if DEBUG
try
{
if ( sERROR_TYPE == "Error" )
Debug.WriteLine(sMESSAGE);
}
catch
{
}
#endif
}
finally
{
Application.UnLock();
}
}