protected void Page_Load(object sender, EventArgs e) { DiscuzSession ds = DiscuzSessionHelper.GetMainSiteSession(); HttpContextSession authToken = new HttpContextSession("AuthToken"); int errorcode = 0; string next = DNTRequest.GetString("next"); if (authToken.GetSession() == null || DNTRequest.GetString("auth_token") != string.Empty) authToken.SetSession(DNTRequest.GetString("auth_token")); if (ValidateAuthToken(ds, ref errorcode)) RedirectPage(next); else GetAuthToken(next, ds); }
public static int ManualAsyncRegister(string asyncSiteId) { if (asyncSiteId == string.Empty) return -1; DiscuzSession ds = DiscuzSessionHelper.GetMainSiteSession(); HttpContextSession authToken = new HttpContextSession("AuthToken"); if (authToken.GetSession() == null || authToken.GetSession().ToString() == "") RedirectToGetAuthToken(); try { ds.session_info = ds.GetSessionFromToken(authToken.GetSession().ToString()); } catch { RedirectToGetAuthToken(); } Me me = ds.GetLoggedInUser(); if (me.UId < 0) return -1; ManualRegLogInfo RegisteredLog = null; if (ManualRegLogList != null) { Predicate<ManualRegLogInfo> matchParent = new Predicate<ManualRegLogInfo>(delegate(ManualRegLogInfo logInfo) { return logInfo.UId == me.UId && logInfo.SiteId == asyncSiteId; }); RegisteredLog = ManualRegLogList.Find(matchParent); if (RegisteredLog != null && RegisteredLog.SiteId != "" && RegisteredLog.UId > 0) return -1; if (ManualRegLogList.Count > 200)//如果已同步数据队列超过了一定值,则清空重建队列 ManualRegLogList = new List<ManualRegLogInfo>(); } else ManualRegLogList = new List<ManualRegLogInfo>(); Discuz.Toolkit.User userInfo = ds.GetUserInfo(me.UId); AsyncSiteInfo asyncSiteInfo = AsyncSites.GetAsyncSiteInfo(asyncSiteId); DiscuzSession targetDs = DiscuzSessionHelper.GetAsyncSiteSession(asyncSiteInfo); int result = -1; try { result = targetDs.Register(userInfo.UserName, userInfo.Password, userInfo.Email, true); if (result > 0)//如果成功注册,则将相关信息加入到已成功列表当中 { ManualRegLogList.Add(new ManualRegLogInfo(asyncSiteId, me.UId)); } } catch (DiscuzException discuzException) { if (discuzException.ErrorCode == 110)//如果返回信息提示用户已经存在,则表示该用户已经同步过 { ManualRegLogList.Add(new ManualRegLogInfo(asyncSiteId, me.UId)); } } return result; }