Пример #1
0
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            mp_aureus = AureusEdge.CreateAndInitializeAureus(msg);
            checkLicense();

            settingsContent = readFromFile(Settings);

            //Declare all of the new global variables from above
            CAMS       = new CameraCollection();
            defaultAOI = new AOISettings();
            email      = new EmailSettings();

            //Call the function to load everything
            loadAll();

            TempCAMs = CAMS.clone(true);

            getLicenseNumber();

            CM = new CameraMonitor();
            camMonitorThread = new System.Threading.Thread(new System.Threading.ThreadStart(CM.monitor));
            camMonitorThread.Start();

            CF = new CameraForm();
            Application.Run(CF);
        }
Пример #2
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);
            }
        }