Beispiel #1
0
 private void InitConnection(string sessionid)
 {
     MgUserInformation mgui = new MgUserInformation(sessionid);
     m_con = new MgSiteConnection();
     m_con.Open(mgui);
     m_sessionId = sessionid;
     DisableAutoSessionRecovery();
 }
Beispiel #2
0
 public override void Dispose()
 {
     if (m_con != null)
     {
         m_con.Dispose();
         m_con = null;
     }
 }
Beispiel #3
0
        /// <summary>
        /// Restarts the server session, and creates a new session ID
        /// </summary>
        /// <param name="throwException">If set to true, the call throws an exception if the call failed</param>
        /// <returns>True if the creation succeed, false otherwise</returns>
        protected override bool RestartSessionInternal(bool throwException)
        {
            if (m_username == null || m_password == null)
                if (throwException)
                    throw new Exception("Cannot recreate session, because connection was not opened with username and password");
                else
                    return false;

            try
            {
                MgUserInformation mgui = new MgUserInformation(m_username, m_password);
                if (m_locale != null)
                    mgui.SetLocale(m_locale);
                else
                    mgui.SetLocale("en");
                MgSiteConnection con = new MgSiteConnection();
                con.Open(mgui);
                string s = con.GetSite().CreateSession();
                if (s == null || s.Trim().Length == 0)
                    throw new Exception("Failed to retrieve new session identifier");

                m_sessionId = s;
                m_con = con;
                return true;
            }
            catch
            {
                if (throwException)
                    throw;
                else
                    return false;
            }
        }