Example #1
0
 //处理Session恢复事件
 private void RefreshSession(object sender, RefreshSessionEventArgs e)
 {
     common.RefreshSessionFromLoginID(e.loginID);
 }
Example #2
0
 /// <summary>
 /// Creates the new session.
 /// </summary>
 /// <param name="makeCookie">if set to <c>true</c> [make cookie].</param>
 /// <param name="cn">The cn.</param>
 /// <param name="trns">The TRNS.</param>
 public void CreateNewSession(bool makeCookie, SqlConnection cn, SqlTransaction trns)
 {
     if(Referer == null) {
         Referer = "";
     } else {
         Referer = Referer.MaxLength(1000, false);
     }
     if(UserAgent == null) {
         UserAgent = "";
     } else {
         UserAgent.MaxLength(1000, false);
     }
     RefreshSessionEventArgs args = new RefreshSessionEventArgs(Main.Site.default_orderby,
         Main.Site.default_listmode, Main.Site.default_records_per_page, Referer, UserAgent, Ip,
         new Guid(Main.Site.Defaults.SiteId.ToString()), cn, trns);
     // raise the on refresh session event and see if the default event should proceed
     Main.Site.raiseOnRefreshSession(args);
     if(args.AbortDefault || (!Main.HasDatabaseConnection)) {
         Id = args.SessionId;
     }else{
         // use the reference database for authentication
         SqlCommand cmd = null;
         string sessionCommand = "dbo.createSession @default_order_by,@default_list_mode,@default_records_per_page,@referer,@userAgent,@ipAddr,@unique_site_id";
         if(cn == null) {
             cmd = new SqlCommand(sessionCommand, Site.SqlConnection);
         } else {
             cmd = new SqlCommand(sessionCommand, cn, trns);
         }
         if(HttpContext.Current == null) {
             Referer = "INTERNAL_SESSION";
             UserAgent = "INTERNAL_SESSION";
             Ip = "127.0.0.1";
         }
         cmd.Parameters.Add("@default_order_by", SqlDbType.Int).Value = Main.Site.default_orderby;
         cmd.Parameters.Add("@default_list_mode", SqlDbType.Int).Value = Main.Site.default_listmode;
         cmd.Parameters.Add("@default_records_per_page", SqlDbType.Int).Value = Main.Site.default_records_per_page;
         cmd.Parameters.Add("@referer", SqlDbType.VarChar).Value = Referer;
         cmd.Parameters.Add("@userAgent", SqlDbType.VarChar).Value = UserAgent;
         cmd.Parameters.Add("@ipAddr", SqlDbType.VarChar).Value = Ip.MaxLength(15, false);
         cmd.Parameters.Add("@unique_site_id", SqlDbType.UniqueIdentifier).Value = new Guid(Main.Site.Defaults.SiteId.ToString());
         using(SqlDataReader newSession = cmd.ExecuteReader()) {
             newSession.Read();
             Id = new Guid(newSession.GetValue(0).ToString());
         }
         cmd.Dispose();
     }
     if(makeCookie && HttpContext.Current != null) {
         HttpCookie session_cookie = new HttpCookie(Main.Site.cookie_name);
         session_cookie.Value = Id.ToString();
         DateTime dtNow = DateTime.Now;
         TimeSpan expiresDays = new TimeSpan(0, Main.Site.days_until_session_expires, 0, 0);
         session_cookie.Expires = dtNow + expiresDays;
         HttpContext.Current.Response.Cookies.Add(session_cookie);
     }
     return;
 }
Example #3
0
 /// <summary>
 /// Raises the on session refresh.
 /// </summary>
 /// <param name="args">The <see cref="Rendition.LogOnEventArgs"/> instance containing the event data.</param>
 internal void raiseOnRefreshSession(RefreshSessionEventArgs args)
 {
     if(RefreshSession != null) { RefreshSession(this, args); };
 }
Example #4
0
 //处理Session恢复事件
 private void RefreshSession(object sender, RefreshSessionEventArgs e)
 {
     common.RefreshSessionFromLoginID(e.loginID);
 }