private void Form1_Closed(object sender, System.EventArgs e) { this.Channels.AskAccountInfo -= new AskAccountInfoEventHandle(this.Servers.OnAskAccountInfo); // 如果缺了此句,则Servers.Save会出现问题 this.Servers.ServerChanged -= new ServerChangedEventHandle(Servers_ServerChanged); // 保存到文件 // parameters: // strFileName 文件名。如果==null,表示使用装载时保存的那个文件名 Servers.Save(null); Servers = null; LinkInfos.Save(null); LinkInfos = null; // 保存窗口尺寸状态 if (AppInfo != null) { AppInfo.SaveFormStates(this, "mainformstate"); } //记住save,保存信息XML文件 AppInfo.Save(); AppInfo = null; // 避免后面再用这个对象 }
private void MainFormNew_FormClosed(object sender, FormClosedEventArgs e) { this.Servers.ServerChanged -= new ServerChangedEventHandle(Servers_ServerChanged); // 保存到文件 // parameters: // strFileName 文件名。如果==null,表示使用装载时保存的那个文件名 Servers.Save(null); Servers = null; string strError; int nRet = cfgCache.Save(null, out strError); if (nRet == -1) { MessageBox.Show(this, strError); } // 保存窗口尺寸状态 if (AppInfo != null) { // 只要存在Search窗口 this.AppInfo.SetInt( "main_form", "last_search_window", this.TopSearchForm != null ? 1 : 0); /* * // MDI子窗口是否最大化 * if (this.ActiveMdiChild != null) * { * this.applicationInfo.SetString( * "mdiwindows", "window_state", * Enum.GetName(typeof(FormWindowState), * this.ActiveMdiChild.WindowState)); * } */ AppInfo.SaveFormStates(this, "mainformstate"); } //记住save,保存信息XML文件 AppInfo.Save(); AppInfo = null; // 避免后面再用这个对象 }
private void ServerTakeOffline(HttpContext context) { // Get the IP of the server to take offline // from the http request's parameters. string IP = context.Request.Params["IP"]; // Get all defined servers. ServerCollection servers = new ServerCollection(Path.Combine( HttpContext.Current.Request.PhysicalApplicationPath, "App_Data", "Servers.xml" )); if (!servers.Items.ContainsKey(IP)) { return; } servers.Items[IP].State = ServerState.Offline; servers.Save(); }
private void _ProcessRequest() { try { Response.Clear(); string sessionId = CheckSession(); if (sessionId == null) { return; } if (Request.Params["SwitchDebugVar1"] != null) { Response.Write(Global.Sessions[sessionId]); Response.End(); return; } if (Request.Params["DeleteSwitchCache"] != null) { DeleteCacheDirectory("Images"); DeleteCacheDirectory("Scripts"); DeleteCacheDirectory("Stylesheets"); } if (Request.Url.ToString().EndsWith("favicon.ico")) { Response.BinaryWrite(new byte[0]); Response.End(); } Response.Headers.Add("Arr-Disable-Session-Affinity", "True"); // Load all parameter keys to ignore. string[] ignoreParams = File.ReadAllText(Path.Combine( Request.PhysicalApplicationPath, "App_Data", "IgnoreParams.txt" )).Split(','); string parameters = ""; // Run through all request parameters. foreach (string key in Request.Params.AllKeys) { if (key == null) { continue; } if (key.StartsWith("404")) { continue; } if (ignoreParams.Contains(key)) { continue; } if (Request.HttpMethod != "GET") { parameters += key + "=" + HttpUtility.UrlEncode(Request.Params[key]) + "&"; } else { parameters += key + "=" + (Request.Params[key]) + "&"; } } string url; if (Request.Params.ToString().Split('&')[0].StartsWith("404")) { url = ConfigurationManager.AppSettings["Protocol"] + "://" + Global.Sessions[sessionId] + new Uri(HttpUtility.UrlDecode(Request.Params.ToString().Split('&')[0]).Split(';')[1]).PathAndQuery; } else { url = ConfigurationManager.AppSettings["Protocol"] + "://" + Global.Sessions[sessionId] + Request.Params["Path_Info"]; } if (parameters.Length > 0) { parameters = parameters.Remove(parameters.Length - 1, 1); } SwitchHandler switchHandler = new SwitchHandler(); if (switchHandler.Switch( Global.Sessions[sessionId], url, parameters ) == false) { ServerCollection servers = new ServerCollection(Path.Combine( Request.PhysicalApplicationPath, "App_Data", "Servers.xml" )); if (servers.Items.ContainsKey(Global.Sessions[sessionId])) { try { SendServerOfflineNotification(servers.Items[Global.Sessions[sessionId]]); } catch { } servers.Items[Global.Sessions[sessionId]].State = ServerState.Offline; servers.Save(); ProcessRequest(); return; } } Response.AddHeader("LiNK_Server", Global.Sessions[sessionId]); /*if (Response.Cookies["ASP.NET_SessionId"] == null) * { * HttpCookie cookie = new HttpCookie("ASP.NET_SessionId", Request.Cookies["ASP.NET_SessionId"].Value); * cookie.Domain = Request.Url.Host; * cookie.Path = "/"; * * Response.Cookies.Add(cookie); * } * else if (Response.Cookies["ASP.NET_SessionId"].Value == "") * { * Response.Cookies["ASP.NET_SessionId"].Value = Request.Cookies["ASP.NET_SessionId"].Value; * }*/ } catch (Exception ex) { File.WriteAllText(Path.Combine( Request.PhysicalApplicationPath, "Log.txt" ), ex.ToString()); } }