Exemplo n.º 1
0
 /// <summary>
 /// Closes the current connection (if any) to a Hansoft server/database.
 /// </summary>
 public void CloseSession()
 {
     if (hpmSession != null)
     {
         HPMSdkSession.SessionDestroy(ref hpmSession);
         hpmSession = null;
     }
 }
        private void InitHansoftVirtualSession()
        {     
            HPMWISdkSession session = HPMWISdkSession.Instance;

            m_SDKSession = session.Session;
            // get virtual session to use the SDK's built in session pool
            m_VirtSession = HPMSdkSession.SessionOpenVirtual(ref m_SDKSession);
        }
Exemplo n.º 3
0
        private void InitHansoftVirtualSession()
        {
            HPMWISdkSession session = HPMWISdkSession.Instance;

            m_SDKSession = session.Session;
            // get virtual session to use the SDK's built in session pool
            m_VirtSession = HPMSdkSession.SessionOpenVirtual(ref m_SDKSession);
        }
 Program()
 {
     m_Session               = null;
     m_NextUpdate            = 0;
     m_NextConnectionAttempt = 0;
     m_bBrokenConnection     = false;
     m_Callback              = new CHPMSdkCallback();
     m_Callback.m_Program    = this;
 }
 Program()
 {
     m_Session = null;
     m_NextUpdate = 0;
     m_NextConnectionAttempt = 0;
     m_bBrokenConnection = false;
     m_Callback = new CHPMSdkCallback();
     m_Callback.m_Program = this;
 }
Exemplo n.º 6
0
        void DestroyConnection()
        {
            if (m_Session != null)
            {
                HPMSdkSession.SessionDestroy(ref m_Session);
            }

            m_NextUpdate = 0;         // Update when connection is restored
        }
        void DestroyConnection()
        {
            if (m_Session != null)
            {
                m_Session.GlobalUnregisterCustomSettings(m_IntegrationIdentifier);
                HPMSdkSession.SessionDestroy(ref m_Session);
            }

            m_NextUpdate = 0; // Update when connection is restored
        }
Exemplo n.º 8
0
 /// <summary>
 /// Connect to a Hansoft Server/Database with parameters specified in a preceding call to Intialize and
 /// create an Sdk session (retrieved through the Session property).
 /// </summary>
 /// <returns>True if the session could be created, False otherwise.</returns>
 public bool Connect()
 {
     try
     {
         hpmSession = HPMSdkSession.SessionOpen(server, port, database, sdkUser, sdkUserPwd, callbackHandler, callbackSemaphore, true, EHPMSdkDebugMode.Off, (IntPtr)null, 0, "", "", null);
     }
     catch (Exception e)
     {
         hpmSession = null;
     }
     return(hpmSession != null);
 }
        bool InitConnection()
        {
            if (m_Session != null)
            {
                return(true);
            }

            HPMUInt64 CurrentTime = GetTimeSince1970();

            if (CurrentTime > m_NextConnectionAttempt)
            {
                m_NextConnectionAttempt = 0;

                EHPMSdkDebugMode DebugMode = EHPMSdkDebugMode.Off;
#if (DEBUG)
                DebugMode = EHPMSdkDebugMode.Debug;             // Set debug flag so we will get memory leak info.
#endif

                try
                {
                    // You should change these parameters to match your development server and the SDK account you have created. For more information see SDK documentation.
                    m_Session = HPMSdkSession.SessionOpen("localhost", 50256, "Company Projects", "SDK", "SDK", m_Callback, null, true, DebugMode, (IntPtr)0, 0, "", "", null);
                }
                catch (HPMSdkException _Error)
                {
                    Console.WriteLine("SessionOpen failed with error:" + _Error.ErrorAsStr());
                    return(false);
                }
                catch (HPMSdkManagedException _Error)
                {
                    Console.WriteLine("SessionOpen failed with error:" + _Error.ErrorAsStr());
                    return(false);
                }

                Console.WriteLine("Successfully opened session.\r\n");
                m_Session.GlobalRegisterCustomSettings(m_IntegrationIdentifier, m_CustomSettings);
                m_bBrokenConnection = false;

                return(true);
            }

            return(false);
        }
Exemplo n.º 10
0
        protected void LoginButton_Click(object sender, EventArgs e)
        {
            errorwrapper.Visible = false;

            HPMCredentialResolutionSessionIDsEnum sessionIDs = new HPMCredentialResolutionSessionIDsEnum();

            Array.Resize(ref sessionIDs.m_SessionIDs, 1);
            HPMString user     = UserNameField.Text;
            HPMString password = PasswordField.Text;

            sessionIDs.m_SessionIDs[0] = Convert.ToUInt64(ChannelList.SelectedItem.Value);

            HPMUniqueID userID = new HPMUniqueID(-1);

            try
            {
                HPMChangeCallbackData_AuthenticationResolveCredentialsResponse response = m_VirtSession.AuthenticationResolveCredentialsBlock(user, password, sessionIDs);
                userID = response.m_ResourceID;

                if (userID.m_ID == -1)
                {
                    SetErrorMessage("Could not authenticate user", "");
                }
                HPMSdkSession.SessionDestroy(ref m_VirtSession);
            }
            catch (HPMSdkException error)
            {
                SetErrorMessage("Could not authenticate user", error.ErrorAsStr());
            }
            catch (HPMSdkManagedException error)
            {
                SetErrorMessage("Could not authenticate user", error.ErrorAsStr());
            }

            if (userID != -1)
            {
                HttpCookie aCookie = new HttpCookie("hansoftuser");

                aCookie.Value = user;
                Response.Cookies.Add(aCookie);
                FormsAuthentication.RedirectFromLoginPage(Convert.ToString(userID.m_ID), false);
            }
        }
Exemplo n.º 11
0
 /// <summary>
 /// Connect to a Hansoft Server/Database with parameters specified in a preceding call to Intialize and
 /// create an Sdk session (retrieved through the Session property).
 /// </summary>
 /// <returns>True if the session could be created, False otherwise.</returns>
 public bool Connect()
 {
     try
     {
         hpmSession = HPMSdkSession.SessionOpen(server, port, database, sdkUser, sdkUserPwd, callbackHandler, callbackSemaphore, true, EHPMSdkDebugMode.Off, (IntPtr)null, 0, "", "", null);
     }
     catch (Exception e)
     {
         hpmSession = null;
     }
     return hpmSession != null;
 }
 public override void On_ProcessError(EHPMError _Error)
 {
     Console.Write("On_ProcessError: " + HPMSdkSession.ErrorToStr(_Error) + "\r\n");
     m_Program.m_bBrokenConnection = true;
 }
        bool InitConnection()
        {
            if (m_Session != null)
                return true;

            HPMUInt64 CurrentTime = GetTimeSince1970();
            if (CurrentTime > m_NextConnectionAttempt)
            {
                m_NextConnectionAttempt = 0;

                EHPMSdkDebugMode DebugMode = EHPMSdkDebugMode.Off;
#if (DEBUG)
			    DebugMode = EHPMSdkDebugMode.Debug; // Set debug flag so we will get memory leak info.
#endif

                try
                {
                    // You should change these parameters to match your development server and the SDK account you have created. For more information see SDK documentation.
                    m_Session = HPMSdkSession.SessionOpen("localhost", 50256, "Company Projects", "SDK", "SDK", m_Callback, null, true, DebugMode, (IntPtr)0, 0, "", "", null);
                }
                catch (HPMSdkException _Error)
                {
                    Console.WriteLine("SessionOpen failed with error:" + _Error.ErrorAsStr());
                    return false;
                }
                catch (HPMSdkManagedException _Error)
                {
                    Console.WriteLine("SessionOpen failed with error:" + _Error.ErrorAsStr());
                    return false;
                }

                Console.WriteLine("Successfully opened session.\r\n");
                m_Session.GlobalRegisterCustomSettings(m_IntegrationIdentifier, m_CustomSettings);
                m_bBrokenConnection = false;

                return true;
            }

            return false;
        }
 private void InitHansoftVirtualSession()
 {
     HPMWISdkSession session = HPMWISdkSession.Instance;
     HPMSdkSession sdkSession = session.Session;
     m_VirtSession = HPMSdkSession.SessionOpenVirtual(ref sdkSession);
 }
 /// <summary>
 /// Connect to a Hansoft Server/Database with parameters specified in a preceding call to Intialize and
 /// create an Sdk session (retrieved through the Session property).
 /// </summary>
 public void Connect()
 {
     hpmSession = HPMSdkSession.SessionOpen(server, port, database, sdkUser, sdkUserPwd, callbackHandler, callbackSemaphore, true, EHPMSdkDebugMode.Off, (IntPtr)null, 0, "", "", null);
 }
Exemplo n.º 16
0
 /// <summary>
 /// Closes the current connection (if any) to a Hansoft server/database.
 /// </summary>
 public void CloseSession()
 {
     if (hpmSession != null)
     {
         HPMSdkSession.SessionDestroy(ref hpmSession);
         hpmSession = null;
     }
 }
Exemplo n.º 17
0
 public bool Connect()
 {
     if (hpmSession == null)
     {
         try
         {
             hpmSession = HPMSdkSession.SessionOpen(server, port, database, sdkUser, sdkUserPwd, hpmCallback, null, true, EHPMSdkDebugMode.Debug, (IntPtr)null, 0, "", "", null);
             Logger.Information("Connection established");
         }
         catch (Exception e)
         {
             Logger.Exception("Could not connect to Hansoft Server", e);
         }
     }
     return hpmSession!=null;
 }