UnLock() публичный Метод

public UnLock ( ) : void
Результат void
Пример #1
0
 private string GetSessionId(HttpApplicationState Application)
 {
     if (Application["sessionId"] == null)
     {
         Application.Lock();
         Application["sessionId"] = opentok.CreateSession().Id;
         Application.UnLock();
     }
     return (string)Application["sessionId"];
 }
Пример #2
0
 public void InitOnSessionEnd(System.Web.HttpApplicationState application, System.Web.SessionState.HttpSessionState session)
 {
     if (session != null)
     {
         // Remove employee from list.
         application.Lock();
         Remove(session.SessionID);
         application.UnLock();
     }
     else
     {
         System.Diagnostics.Trace.WriteLine("Session is null!");
     }
 }
Пример #3
0
 /// <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();
 }
 public override void UnLock()
 {
     w.UnLock();
 }
Пример #5
0
        public void ParaInit(System.Web.HttpApplicationState app)
        {
            try
            {
                DataSet dsIn = new DataSet();

                InitCode  inc     = new InitCode();
                Hashtable htapp   = (Hashtable)Application["appconf"];
                string    strcons = (string)htapp["cons"];
                DataSet   dsOut   = inc.LoadCodeTable(strcons);

                //错误返回表

                //返回结果存放到Application
                app["tbCommCode"]          = dsOut.Tables["tbCommCode"];
                app["AllMD"]               = dsOut.Tables["AllMD"];
                app["MAC"]                 = dsOut.Tables["MAC"];
                app["OperFunc"]            = dsOut.Tables["OperFunc"];
                app["IOTime"]              = dsOut.Tables["IOTime"];
                app["Goods"]               = dsOut.Tables["Goods"];
                app["PClass"]              = dsOut.Tables["PClass"];
                app["AllMaterial"]         = dsOut.Tables["AllMaterial"];
                app["Provider"]            = dsOut.Tables["Provider"];
                app["NewDept"]             = dsOut.Tables["NewDept"];
                app["tbNameCodeToStorage"] = dsOut.Tables["tbNameCodeToStorage"];
                app["tbFormula"]           = dsOut.Tables["tbFormula"];
                app["DeptMapInfo"]         = dsOut.Tables["DeptMapInfo"];
                app["Warehouse"]           = dsOut.Tables["Warehouse"];
                app["ComputationGroup"]    = dsOut.Tables["ComputationGroup"];
                app["ComputationUnit"]     = dsOut.Tables["ComputationUnit"];

                Hashtable htOperFunc = new Hashtable();
                DataTable dttmp      = dsOut.Tables["OperFunc"];
                if (dttmp.Rows.Count > 0)
                {
                    string    strOperID  = "";
                    ArrayList alFuncList = null;
                    for (int i = 0; i < dttmp.Rows.Count; i++)
                    {
                        CMSMStruct.MenuStruct menu1 = new CMSMStruct.MenuStruct();
                        menu1.strFuncName    = dttmp.Rows[i]["vcFuncName"].ToString();
                        menu1.strFuncAddress = dttmp.Rows[i]["vcFuncAddress"].ToString();
                        if (strOperID == dttmp.Rows[i]["vcOperID"].ToString())
                        {
                            alFuncList.Add(menu1);
                            if (i == dttmp.Rows.Count - 1)
                            {
                                htOperFunc.Add(strOperID, alFuncList);
                            }
                        }
                        else
                        {
                            if (strOperID != "" && alFuncList.Count > 0)
                            {
                                htOperFunc.Add(strOperID, alFuncList);
                            }

                            alFuncList = new ArrayList();
                            alFuncList.Add(menu1);
                            strOperID = dttmp.Rows[i]["vcOperID"].ToString();
                            if (i == dttmp.Rows.Count - 1)
                            {
                                htOperFunc.Add(strOperID, alFuncList);
                            }
                        }
                    }
                }
                app["OperFunc"] = htOperFunc;

                Hashtable htIOTime = new Hashtable();
                dttmp = null;
                dttmp = dsOut.Tables["IOTime"];
                if (dttmp.Rows.Count > 0)
                {
                    string    strOfficer = "";
                    ArrayList altmp      = null;
                    for (int i = 0; i < dttmp.Rows.Count; i++)
                    {
                        CMSMStruct.SignIOTimeStruct sio1 = new CommCenter.CMSMStruct.SignIOTimeStruct();
                        sio1.strSIOTID    = dttmp.Rows[i]["iotName"].ToString();
                        sio1.strOfficer   = dttmp.Rows[i]["Officer"].ToString();
                        sio1.strClassName = dttmp.Rows[i]["vcClassName"].ToString();
                        sio1.strClassId   = dttmp.Rows[i]["vcClassId"].ToString();
                        sio1.strInTime    = dttmp.Rows[i]["InTime"].ToString();
                        sio1.strOutTime   = dttmp.Rows[i]["OutTime"].ToString();
                        if (strOfficer == sio1.strOfficer)
                        {
                            altmp.Add(sio1);
                            if (i == dttmp.Rows.Count - 1)
                            {
                                htIOTime.Add(strOfficer, altmp);
                            }
                        }
                        else
                        {
                            if (strOfficer != "" && altmp.Count > 0)
                            {
                                htIOTime.Add(strOfficer, altmp);
                            }

                            altmp = new ArrayList();
                            altmp.Add(sio1);
                            strOfficer = sio1.strOfficer;
                            if (i == dttmp.Rows.Count - 1)
                            {
                                htIOTime.Add(strOfficer, altmp);
                            }
                        }
                    }
                }
                app["IOTime"] = htIOTime;

                app.UnLock();
            }
            catch (Exception e)
            {
                AMSLog clog = new AMSLog();
                clog.WriteLine(e);
            }
        }
Пример #6
0
 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();
     }
 }
 public override void UnLock()
 {
     _application.UnLock();
 }
Пример #8
0
		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 )
						{
							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();
			}
		}
Пример #9
0
		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();
							}
							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();
			}
		}