jianinclude4.ascx.cs
上传用户:scene123
上传日期:2010-02-19
资源大小:3311k
文件大小:4k
源码类别:

.net编程

开发平台:

C#

  1. namespace kuangren
  2. {
  3. using System;
  4. using System.Collections;
  5. using System.ComponentModel;
  6. using System.Data;
  7. using System.Drawing;
  8. using System.Web;
  9. using System.Web.SessionState;
  10. using System.Web.UI;
  11. using System.Web.UI.WebControls;
  12. using System.Web.UI.HtmlControls;
  13. using System.Data.OleDb;
  14. using System.Text;
  15. using System.Configuration;
  16. /// <summary>
  17. /// jianinclude4 的摘要说明。
  18. /// </summary>
  19. public class jianinclude4 : System.Web.UI.UserControl
  20. {
  21. protected int intRunTime;
  22. protected DateTime dtStartTime = DateTime.Now;
  23. public string usercookies;
  24. public string jpower;
  25. public    DataSet dsuser;
  26. public string sessionid;
  27. public string jhidden;
  28. public string boardid;
  29. public string OleDbSqlforum;
  30. protected System.Data.OleDb.OleDbCommand cmd4;
  31. public string OleDbSqlforum1;
  32. protected System.Data.OleDb.OleDbCommand cmd41;
  33. private void Page_Load(object sender, System.EventArgs e)
  34. {
  35. sessionid=""+Request.UserHostAddress+"";
  36. sessionid=sessionid.Replace(".","");
  37. if (Request.Cookies["jhidden"]!=null&&Request.Cookies["jhidden"].Value=="0")
  38. {
  39. usercookies=Request.Cookies["jusername"].Value;
  40. jpower=Request.Cookies["jpower"].Value;
  41. jhidden=Request.Cookies["jhidden"].Value;
  42. }
  43. else
  44. {
  45. jpower="42";
  46. usercookies="客人";
  47. jhidden="1";
  48. }
  49. if (Request.QueryString["f2_id"]!=null)
  50. {
  51. boardid=Request.QueryString["f2_id"];
  52. }
  53. else
  54. {
  55. boardid="0";
  56. }
  57. OleDbConnection conn;
  58. string OleDbsql;
  59. OleDbCommand cmd;
  60. StringBuilder sb=new StringBuilder();
  61. ArrayList values=new ArrayList();
  62.       
  63. sb.Append("INSERT INTO [online](id,username,userclass,ip,startime,lastimebk,userhidden,boardid)  values({0},'{1}',{2},'{3}','{4}','{5}',{6},{7})");             
  64. values.Add(sessionid);
  65. values.Add(usercookies);
  66. values.Add(jpower);
  67. values.Add(Request.UserHostAddress);
  68. values.Add(DateTime.Now);
  69. values.Add(DateTime.Now);
  70. values.Add(jhidden);
  71. values.Add(boardid);
  72. OleDbsql=String.Format(sb.ToString(),values.ToArray());
  73. conn=new OleDbConnection(ConfigurationSettings.AppSettings["cnFriends.ConnectionString"]);
  74. cmd=new OleDbCommand("select id from online where id="+sessionid+"",conn);
  75. dsuser=new DataSet();
  76. cmd.Connection.Open();
  77. OleDbDataReader objDataReader ;
  78. objDataReader = cmd.ExecuteReader();
  79. if (objDataReader.Read() == false) 
  80. {  
  81. cmd=new OleDbCommand(OleDbsql,conn);
  82. }
  83. else
  84. {
  85. OleDbSqlforum="update [online] SET lastimebk='"+DateTime.Now+"',boardid="+boardid+",username='"+usercookies+"' ,userhidden="+jhidden+" ,userclass="+jpower+" WHERE id="+sessionid+" ";          
  86. cmd4=new OleDbCommand(OleDbSqlforum,conn);
  87. }
  88. objDataReader.Close();
  89. OleDbSqlforum1="DELETE FROM online WHERE DATEDIFF('s', lastimebk, now()) >15*60 ";          
  90. cmd41=new OleDbCommand(OleDbSqlforum1,conn);
  91. cmd.Connection.Close();
  92. conn.Open();
  93. bool doredirect=true;
  94. try
  95. {
  96. cmd.ExecuteNonQuery();
  97. cmd4.ExecuteNonQuery();
  98. cmd41.ExecuteNonQuery();
  99. }
  100. catch
  101. {
  102. doredirect=false;
  103. }
  104. finally
  105. {
  106. conn.Close();
  107. }
  108. if(doredirect)
  109. {
  110. }
  111. else
  112. {
  113. }
  114. }
  115. #region Web 窗体设计器生成的代码
  116. override protected void OnInit(EventArgs e)
  117. {
  118. //
  119. // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
  120. //
  121. InitializeComponent();
  122. base.OnInit(e);
  123. }
  124. /// <summary>
  125. /// 设计器支持所需的方法 - 不要使用代码编辑器
  126. /// 修改此方法的内容。
  127. /// </summary>
  128. private void InitializeComponent()
  129. {
  130. this.Load += new System.EventHandler(this.Page_Load);
  131. }
  132. #endregion
  133. }
  134. }