Пример #1
0
 /// <summary>
 /// It is essential that logout is called to avoid leaving cached information in the database and to
 /// ensure that reports of who is logged in are as accurate as possible.
 /// That said, don't keep logging in and out, it is an expensive process.
 /// </summary>
 public static void Logout()
 {
     mIsLoggedInToSIMS = false;
     try
     {
         if (mSignature != 0)
         {
             mLoginProcess.Logout();
         }
     }
     catch (Exception ex)
     {
         mErrorMessage = ex.Message;
     }
     mSignature    = 0;
     mLoginProcess = null;
     return;
 }
Пример #2
0
        /// <summary>
        /// SIMS Login function
        /// </summary>
        /// <param name="server"></param>
        /// <param name="database"></param>
        /// <param name="user"></param>
        /// <param name="password"></param>
        /// <returns>True if successful/</returns>
        public static bool SIMSlogin(string server, string database, string user, string password)
        {
            mSIMSServer   = server;
            mSIMSDatabase = database;
            if (string.IsNullOrEmpty(user))
            {
                mSIMSUser = Environment.UserDomainName + "\\" + Environment.UserName;
            }
            else
            {
                mSIMSUser = user;
            }
            mSIMSPassword = password;
            if (mIsLoggedInToSIMS)
            {
                Logout();
            }
            mIsLoggedInToSIMS = false;
            try
            {
                //
                // Reference required is LoginProcesses.dll
                //
                // Attempt to login
                if (mSIMSServer == "")
                {
                    mLoginProcess = new SIMS.Processes.Login();
                }
                else
                {
                    mLoginProcess = new SIMS.Processes.Login(mSIMSServer, mSIMSDatabase);
                }
                //mLoginProcess.

                mSignature = mLoginProcess.GetDatabaseSignature(mSIMSUser, mSIMSPassword, "TPA1", true);
                mLoginProcess.Init(mSignature, mSIMSUser, mSIMSPassword);

                //
                // References required are
                //		Cache.dll
                //		CacheProcesses.dll
                //		AbstractProcesses.dll
                //		BaseInterfaces.dll
                //
                SIMS.Entities.DatabaseMode dm = new SIMS.Entities.DatabaseMode(false);
                SIMS.Entities.Cache.CurrentDatabase.DatabaseMode = dm;

                // It is essential that the third party conenction flag is set to avoide access being denied due to licensing.
                SIMS.Entities.Cache.ThirdPartyLogin = true;

                // If we get to this point we have been successful and can then build upon it.

                mIsLoggedInToSIMS = true;
            }
            catch (Exception ex)
            {
                WriteToFile(mErrorMessage);
                mErrorMessage = ex.Message;
            }
            return(mIsLoggedInToSIMS);
        }