コード例 #1
0
        /// <summary>
        /// Check if the user has their license. If not, do not let them continue
        /// This will put the user in essentially an infinite loop until they get their license
        /// </summary>
        internal static void checkLicense()
        {
            bool   canContinue = false;
            bool   firstLoop   = true;
            string failReason  = "";

            while (!canContinue)
            {
                if (File.Exists(licenseFile))
                {
                    //File does exist
                    string fileContent = readFromFile(licenseFile).Trim();
                    if (fileContent == "")
                    {
                        //File exists but is empty
                        failReason = "FILE-EMPTY";
                    }
                    else
                    {
                        if (!firstLoop)
                        {
                            //Kill it
                            AureusEdge.FreeAureus(mp_aureus, msg);
                            //Re-initilize it
                            mp_aureus = AureusEdge.CreateAndInitializeAureus(msg);
                        }
                        //Check if the license is valid
                        AureusEdge.GetLicenseInfo(mp_aureus, msg);
                        if (msg.ToString().Contains("Error!"))
                        {
                            //Invalid license
                            failReason = "INVALID-CONTENT";
                        }
                        else
                        {
                            //Do calculation
                            licenseEXP = getLicenseExp(msg.ToString());
                            if (licenseEXP <= DateTime.Now)
                            {
                                //License has expired
                                failReason = "EXPIRED";
                            }
                            else
                            {
                                canContinue = true;
                                break;
                            }
                        }
                    }
                }
                else
                {
                    //File does not exist.
                    failReason = "FILE-NOT-FOUND";
                }
                if (!canContinue)
                {
                    //Display the error form
                    IL = new InvalidLicense();
                    IL.errorMessage = failReason;
                    IL.loadDisplay();
                    IL.ShowDialog();
                    if (killApplication)
                    {
                        canContinue = true; break;
                    }
                }
                firstLoop = false;
            }

            //Kill the application. We needed to exit the loop first
            if (canContinue && killApplication)
            {
                exitApp(true);
            }
        }
コード例 #2
0
        //=================================== ALL OF THE GLOBAL FUNCTIONS WILL BE BELOW HERE ===================================\\

        /// <summary>
        /// Exit the application and kill all running items
        /// </summary>
        internal static void exitApp(bool exitEnvironment = false)
        {
            //Delete the contents of the "Results" folder
            if (System.IO.Directory.Exists(@"C:\Allevate\Face-Searcher\Results"))
            {
                System.IO.Directory.Delete(@"C:\Allevate\Face-Searcher\Results", true);
                System.IO.Directory.CreateDirectory(@"C:\Allevate\Face-Searcher\Results");
            }
            //Kill the monitor thread
            if (camMonitorThread != null)
            {
                camMonitorThread.Abort();
            }
            //Kil the AureusEdge program
            AureusEdge.FreeAureus(mp_aureus, msg);
            //If anything else needs to be done before exit. Do it here
            try
            {
                if (CF != null)
                {
                    CF.Dispose();
                }
                if (DT != null)
                {
                    DT.Dispose();
                }
                if (ES != null)
                {
                    ES.Dispose();
                }
                if (LP != null)
                {
                    LP.Dispose();
                }
                if (NF != null)
                {
                    NF.Dispose();
                }
                if (DA != null)
                {
                    DA.Dispose();
                }
                if (IL != null)
                {
                    IL.Dispose();
                }

                Application.Exit();
                try
                {
                    Environment.Exit(0);
                }catch
                {
                    Environment.Exit(1);
                }
                //if (exitEnvironment)
                //{
                //    Environment.Exit(0);
                //}
            }
            catch
            {
                //Do Nothing
            }
        }