private bool ObtainLicenses()
        {
            string[] components = new string[] { "Biometrics.IrisExtraction", "Biometrics.IrisMatching", "Devices.IrisScanners" };

            try
            {
                foreach (string component in components)
                {
                    if (!NLicense.ObtainComponents("/local", 5000, component))
                    {
                        LogModel licensesUnavailable = LogSingleton.Instance.LicensesUnavailable;
                        licensesUnavailable.Description = $"{licensesUnavailable.Description} (\"{component}\")";
                        this.ResultLogs.Add(licensesUnavailable);
                        return(false);
                    }
                }

                return(true);
            }
            catch (Exception)
            {
                this.ResultLogs.Add(LogSingleton.Instance.LicensesUnavailable);
                return(false);
            }
        }
Exemple #2
0
        private void RefreshOptional()
        {
            string text = rtbComponents.Text;

            try
            {
                rtbComponents.SelectionColor = Color.Black;
                rtbComponents.AppendText(", ");
                string[] comps = OptionalComponents.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                for (int i = 0; i < comps.Length; i++)
                {
                    string item = comps[i];
                    rtbComponents.SelectionStart = rtbComponents.TextLength;
                    rtbComponents.SelectionColor = NLicense.IsComponentActivated(item) ? Color.Green : Color.Red;
                    rtbComponents.AppendText(string.Format("{0} (optional)", item));

                    if (i != comps.Length - 1)
                    {
                        rtbComponents.SelectionColor = Color.Black;
                        rtbComponents.AppendText(", ");
                    }
                }
            }
            catch
            {
                rtbComponents.SelectionColor = Color.Black;
                rtbComponents.Text           = text;
                throw;
            }
        }
        public void Initialize()
        {
            bool b = true;

            try
            {
                // check license
                if (!NLicense.ObtainComponents("/local", 5000, components))
                {
                    b = false;
                }

                // Create an extractor
                extractor = new NLExtractor();

                // Set extractor template size (recommended, for enroll to database, is large) (optional)
                extractor.TemplateSize = NleTemplateSize.Large;
            }
            catch (Exception e)
            {
                string msg = e.InnerException != null ? e.InnerException.Message : e.Message;
                throw new VerilookToolException(errormsg + msg);
            }
            if (!b)
            {
                throw new VerilookToolException("Obtaining Verilook License failed");
            }
        }
Exemple #4
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            NLicense license = new NLicense("0e826fb6-fd02-bb01-d5d2-840415e30261");

            NLicenseManager.Instance.SetLicense(license);
            NLicenseManager.Instance.LockLicense = true;
            var lg = new FrmWaiting();

            try
            {
                if (LicenseManager.Validate(typeof(FrmWaiting), lg).LicenseKey != null)
                {
                    if (lg.ShowDialog() == DialogResult.OK)
                    {
                        Busi.Common.LogonUser = lg.LogUser;
                        var mainForm = new Forms.MainForm();
                        Application.Run(mainForm);
                        lg.Close();
                    }
                }
            }
            catch (LicenseException ex)
            {
                if (new Forms.LicenseManager().ShowDialog() == DialogResult.OK)
                {
                    Application.Exit();
                }
            }
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        const int    Port       = 5000;
        const string Address    = "/local";
        const string Components = "Biometrics.FaceExtraction,Biometrics.FaceMatching,Biometrics.FaceDetection,Devices.Cameras,Biometrics.FaceSegmentsDetection";

        foreach (string component in Components.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
        {
            NLicense.ObtainComponents(Address, Port, component);
        }

        /*
         * _biometricClient = new NBiometricClient { BiometricTypes = NBiometricType.Face, UseDeviceManager = true };
         * _biometricClient.Initialize();
         */
        MySqlConnection conn       = new MySqlConnection("server=localhost;database=test;uid=root;password=root");
        String          sqlcommand = "select *  from resultshow order by score desc";
        MySqlCommand    cmd        = new MySqlCommand(sqlcommand, conn);

        conn.Open();
        MySqlDataAdapter ad = new MySqlDataAdapter(cmd);
        DataSet          ds = new DataSet();

        ad.Fill(ds);
        ListView1.DataSource = ds;
        ListView1.DataBind();
//this.FileUpload2.Attributes.Add("onchange", "test2()");
    }
        //ESTE METODO SE ENCARGA DE BUSCAR LAS LICENCIAS DE NEUROTECNOLOGY PARA REALIZAR LOS PROCESOS CON SU SDK
        private bool SetupLicenses()
        {
            var anyMatchingComponent = false;

            try
            {
                const string licenses = "FingerMatcher, FingerExtractor";
                // Obtain licenses
                foreach (string license in licenses.Split(','))
                {
                    if (NLicense.Obtain("/local", 5000, license))
                    {
                        Console.WriteLine("Obtained license: {0}", license);
                        anyMatchingComponent = true;
                    }
                }
                if (!anyMatchingComponent)
                {
                    throw new NotActivatedException("Could not obtain any matching license");
                }
                return(anyMatchingComponent);
            }
            catch (Exception e)
            {
                //GUARDAMOS EL ERROR EN EL LOG
                return(false);
            }
        }
        public void Dispose()
        {
            NLicense.ReleaseComponents(components);

            if (extractor != null)
            {
                extractor.Dispose();
            }
        }
 private void FormCaptureSingleScannerFinger_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (_EnrollFromSingleFingerScanner != null)
     {
         _EnrollFromSingleFingerScanner.DisposeNLComponents();
     }
     if (_biometricClient != null)
     {
         _biometricClient.Cancel();
     }
     NLicense.ReleaseComponents(FingerprintComponents);
 }
    private void SetBiometricClientParams()
    {
        _biometricClient.FacesMaximalRoll = float.Parse(cbRollAngle.SelectedItem.Value);
        _biometricClient.FacesMaximalYaw  = float.Parse(cbYawAngle.SelectedItem.Value);

        if (!_isSegmentationActivated.HasValue)
        {
            _isSegmentationActivated = NLicense.IsComponentActivated("Biometrics.FaceSegmentsDetection");
        }

        _biometricClient.FacesDetectAllFeaturePoints  = _isSegmentationActivated.Value;
        _biometricClient.FacesDetectBaseFeaturePoints = _isSegmentationActivated.Value;
    }
Exemple #10
0
 public static void ObtainLicense(string components)
 {
     try
     {    //Licenses obtain for components
         if (!NLicense.ObtainComponents("/local", 5000, components))
         {
             throw new ApplicationException(string.Format("Could not obtain licenses for components: { 0 }", components));
         }
     }
     catch
     {
         Console.WriteLine(components);
     }
 }
Exemple #11
0
        private void RefreshRequired()
        {
            string text = rtbComponents.Text;

            try
            {
                rtbComponents.Text = string.Empty;
                int      obtainedCount      = 0;
                string[] requiredComponents = RequiredComponents.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                for (int i = 0; i < requiredComponents.Length; i++)
                {
                    string item = requiredComponents[i];
                    rtbComponents.SelectionStart = rtbComponents.TextLength;
                    if (NLicense.IsComponentActivated(item))
                    {
                        rtbComponents.SelectionColor = Color.Green;
                        rtbComponents.AppendText(item);
                        obtainedCount++;
                    }
                    else
                    {
                        rtbComponents.SelectionColor = Color.Red;
                        rtbComponents.AppendText(item);
                    }
                    if (i != requiredComponents.Length - 1)
                    {
                        rtbComponents.SelectionColor = Color.Black;
                        rtbComponents.AppendText(", ");
                    }
                }

                if (obtainedCount == requiredComponents.Length)
                {
                    lblStatus.Text      = Resources.Licenses_obtained;
                    lblStatus.ForeColor = Color.Green;
                }
                else
                {
                    lblStatus.Text      = Resources.Not_all_required_licenses_obtained;
                    lblStatus.ForeColor = Color.Red;
                }
            }
            catch
            {
                rtbComponents.SelectionColor = Color.Black;
                rtbComponents.Text           = text;
                throw;
            }
        }
Exemple #12
0
 private void mainForm_FormClosing(object sender, FormClosingEventArgs e)
 {
     try {
         isLive = false;
         if (myThread != null)
         {
             myThread.Abort();
         }
         NLicense.ReleaseComponents(Components);
     } catch (Exception ex) {
         MessageBox.Show(ex.ToString());
     } finally {
         Application.Exit();
     }
 }
Exemple #13
0
        private void CheckLicense()
        {
            const string Components =
                "Biometrics.FaceExtraction," +
                "Biometrics.FaceDetection," +
                "Biometrics.FaceMatching," +
                "Devices.Cameras";

            foreach (var component in Components.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
            {
                if (!NLicense.IsComponentActivated(component))
                {
                    Logger.Error("License not acquired");
                }
            }
            licensePanel1.RefreshComponentsStatus();
        }
Exemple #14
0
        private void ClientInit()
        {
            _biometricClient = new NBiometricClient {
                BiometricTypes = NBiometricType.Face, UseDeviceManager = true
            };
            _biometricClient.Initialize();
            _biometricClient.FacesTemplateSize = NTemplateSize.Small;

            if (!_isSegmentationActivated.HasValue)
            {
                _isSegmentationActivated = NLicense.IsComponentActivated("Biometrics.FaceSegmentsDetection");
            }

            _biometricClient.FacesDetectAllFeaturePoints = _isSegmentationActivated.Value;
            _biometricClient.FacesQualityThreshold       = 50;

            _deviceManager = _biometricClient.DeviceManager;
        }
Exemple #15
0
        private void ActivarLicenciaNT()
        {
            const int    Port       = 5000;
            const string Address    = "/local";
            const string Components = "Biometrics.FingerExtraction,Biometrics.FingerMatching,Biometrics.FaceExtraction,Biometrics.FaceMatching,Biometrics.IrisExtraction,Biometrics.IrisMatching";

            try
            {
                foreach (string component in Components.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
                {
                    NLicense.ObtainComponents(Address, Port, component);
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Exemple #16
0
        private bool createTemplate(Bitmap enrollmentBmp, bool largeTemplate, out NleDetectionDetails detDetails)
        {
            NLExtractor templateExtractor = new NLExtractor();

            if (largeTemplate)
            {
                templateExtractor.TemplateSize = NleTemplateSize.Large;
            }
            else
            {
                templateExtractor.TemplateSize = NleTemplateSize.Medium;
            }
            NImage              enrollmentImage     = NImage.FromBitmap(enrollmentBmp);
            NGrayscaleImage     enrollmentGrayscale = enrollmentImage.ToGrayscale();
            NleDetectionDetails _detDetails         = null;

            try {
                verifyLicense();
                NleExtractionStatus extractionStatus;
                facialTemplate = templateExtractor.Extract(enrollmentGrayscale, out _detDetails, out extractionStatus);

                if (extractionStatus != NleExtractionStatus.TemplateCreated)
                {
                    MessageBox.Show("Face Template Extraction Failed!\nPlease try again.\n" + extractionStatus.ToString());
                    detDetails = _detDetails;
                    return(false);
                }
                else
                {
                    detDetails = _detDetails;
                    return(true);
                }
            } catch (Exception ex) {
                MessageBox.Show("" + ex);
                detDetails = null;
                return(false);
            } finally {
                NLicense.ReleaseComponents(Components);
                if (templateExtractor != null)
                {
                    templateExtractor.Dispose();
                }
            }
        }
Exemple #17
0
        static void Main()
        {
            const string Components = "Biometrics.FaceExtraction,Biometrics.FaceMatching,Biometrics.FaceDetection,Devices.Cameras,Biometrics.FaceSegmentsDetection";

            try
            {
                foreach (string component in Components.Split(new [] { ',' }, StringSplitOptions.RemoveEmptyEntries))
                {
                    NLicense.ObtainComponents("192.168.100.15", 6000, Components);
                }

                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new MainForm());
            } catch (Exception ex)
            {
                Utils.ShowException(ex);
            }
        }
Exemple #18
0
 public void verifyLicense()
 {
     if (!NLicense.ObtainComponents("/local", 5000, Components))
     {
         if (this.InvokeRequired)
         {
             this.Invoke(new Action(() => MessageBox.Show(this, "Please insert the license key and try again.")));
             this.Invoke(new Action(() => { this.Close(); }));
         }
         else
         {
             MessageBox.Show(this, "Please insert the license key and try again.");
             this.Close();
         }
         if (myThread != null)
         {
             myThread.Abort();
         }
     }
 }
Exemple #19
0
        public static void ReleaseLicenses(IList <string> licenses)
        {
#if !N_NOT_USES_LICENSES
            for (int i = 0; i < licenses.Count; i++)
            {
                if (licenses[i] == string.Empty)
                {
                    continue;
                }

                try
                {
                    NLicense.Release(licenses[i]);
                }
                catch (Exception)
                {
                }
            }
#endif
        }
Exemple #20
0
        public Scanner()
        {
            if (!_registered)
            {
                NLicense.ObtainComponents("/local", 5000, BiometricsComponents);
            }
            _registered = true;

            _biometricClient = new NBiometricClient
            {
                MatchingThreshold            = 48,
                FacesMatchingSpeed           = NMatchingSpeed.Low,
                FacesDetectBaseFeaturePoints = true,
                FacesDetectAllFeaturePoints  = true,
                FacesRecognizeEmotion        = true,
                FacesRecognizeExpression     = true,
                FacesDetectProperties        = true,
                FacesDetermineGender         = true,
                FacesDetermineAge            = true
            };
        }
Exemple #21
0
        public Graph(ResultData _rData, string projectName, List<string> scenarioNames)
        {
            NLicense license = new NLicense("096ff936-7602-3c02-009c-5ea6176b006d");
            NLicenseManager.Instance.SetLicense(license);
            NLicenseManager.Instance.LockLicense = true;

            InitializeComponent();
            rData = _rData;
            curProjectName = projectName;

            //font and location of left bar
            pfc.AddFontFile(Path.Combine(Application.StartupPath, "KOPUBDOTUM_PRO_LIGHT.OTF"));
            label_1.Font = new Font(pfc.Families[0], 18, FontStyle.Regular);
            label_2.Font = new Font(pfc.Families[0], 18, FontStyle.Regular);
            label_3.Font = new Font(pfc.Families[0], 18, FontStyle.Regular);
            chartType.Font = new Font(pfc.Families[0], 14, FontStyle.Regular);
            taskNameBox.Font = new Font(pfc.Families[0], 14, FontStyle.Regular);
            personalBox.Font = new Font(pfc.Families[0], 14, FontStyle.Regular);


            chartType.SelectedIndex = 0;

            ImgTimeInfo = new List<ImgTime>();
            ImgAverageInfo = new List<ImgAverageTime>();

            if (rData == null)
            {
                MessageBox.Show("NULL!!!");
            }

            foreach (ResultData.ResultInfo temp in rData.getRData())
            {
                if (ListBox.NoMatches == taskNameBox.FindStringExact(temp.taskName) && curProjectName == temp.projectName)
                {
                    taskNameBox.Items.Add(temp.taskName);
                }
            }

        }
Exemple #22
0
        static void Main(string[] args)
        {
            const int    Port       = 5000;
            const string Address    = "/local";
            const string Components = "Biometrics.FingerExtraction,Devices.FingerScanners,Biometrics.FaceExtraction,Biometrics.FaceDetection,Devices.Cameras,Biometrics.IrisExtraction,Biometrics.IrisSegmentation,Devices.IrisScanners";

            try
            {
                foreach (string component in Components.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
                {
                    NLicense.ObtainComponents(Address, Port, component);
                }
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                //Application.Run(new BuscarHuella(args));
                Application.Run(new MainForm(args));
            }
            catch (Exception ex)
            {
                Utils.ShowException(ex);
            }
        }
 public FormCaptureSingleScannerFinger(FormMain formMain, CaptureFingerNotifyer captureFingerNotifyer, FingerDescription fingerDescription, int capturedFingersprintCount)
 {
     //Obtain Fingerprint Components Licenses
     try
     {
         _formMain = formMain;
         NLicense.ObtainComponents(Address, Port, FingerprintComponents);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString(), string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     _FingerDescription       = fingerDescription;
     _fingerprintScanPosition = capturedFingersprintCount;
     _fingerprintCount        = capturedFingersprintCount;
     _CaptureFingerNotifyer   = captureFingerNotifyer;
     InitializeComponent();
     _formMain.UpdateFingerInit();
     _fingerDescriptions = new List <FingerDescription>();
     EnumerateFingerDescription();
 }
Exemple #24
0
        static void Main()
        {
            const string Address    = "/local";
            const string Port       = "5000";
            const string Components = "Biometrics.FingerExtraction,Biometrics.FingerMatching,Devices.FingerScanners,Images.WSQ";

            try
            {
                NLicense.ObtainComponents(Address, Port, Components);

                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new MainForm());
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ex.StackTrace.ToString());
                Logger.logToFile(ex, AppSettings.ErrorLogPath);
            }
            finally
            {
                NLicense.ReleaseComponents(Components);
            }
        }
Exemple #25
0
        public void ObtainLicenses()
        {
            //Obtain Face Components Licenses

            try
            {
                if (!NLicense.ObtainComponents(Address, Port, _faceComponents))
                {
                    throw new ApplicationException($"Could not obtain licenses for components: {components}");
                }
                //if (NLicense.ObtainComponents(Address, Port, AdditionalComponents))
                //{
                //    _faceComponents += "," + AdditionalComponents;
                //}
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            //finally
            //{
            //    NLicense.ReleaseComponents(_faceComponents);
            //}
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        const int    Port       = 5000;
        const string Address    = "/local";
        const string Components = "Biometrics.FaceExtraction,Biometrics.FaceMatching,Biometrics.FaceDetection,Devices.Cameras,Biometrics.FaceSegmentsDetection";

        foreach (string component in Components.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
        {
            NLicense.ObtainComponents(Address, Port, component);
        }
        _biometricClient = new NBiometricClient {
            BiometricTypes = NBiometricType.Face, UseDeviceManager = true
        };
        _biometricClient.Initialize();
        this.FileUpload1.Attributes.Add("onchange", "test2();");

        float        item  = _biometricClient.FacesMaximalRoll;
        List <float> items = new List <float>();

        for (float i = 15; i <= 180; i += 15)
        {
            items.Add((i));
        }
        if (!items.Contains(item))
        {
            items.Add(item);
        }
        items.Sort();

        int index = items.IndexOf(item);

        for (int i = 0; i != items.Count; i++)
        {
            cbRollAngle.Items.Add(items[i].ToString());
        }
        cbRollAngle.SelectedIndex = index;

        item = _biometricClient.FacesMaximalYaw;
        items.Clear();
        for (float i = 15; i <= 90; i += 15)
        {
            items.Add((i));
        }
        if (!items.Contains(item))
        {
            items.Add(item);
        }
        items.Sort();

        index = items.IndexOf(item);
        for (int i = 0; i != items.Count; i++)
        {
            cbYawAngle.Items.Add(items[i].ToString());
        }
        cbYawAngle.SelectedIndex = index;
        DataSet set = isLogin(Session["result"]);

        if (set.DataSetName == "result")
        {
            ListView1.DataSource = set;
            ListView1.DataBind();
        }
    }
Exemple #27
0
        static void Main()
        {
            String         stPr_VersionApp = Application.ProductVersion; // Version de la aplicacion
            ClasX_EventLog log             = new ClasX_EventLog("FENIX", "C:\\FENIX_KIOSCO\\LOGMAIN.log", false, true, false);

            try
            {
                bool   created;
                string name = Assembly.GetEntryAssembly().FullName;
                using (Mutex mtex = new Mutex(true, name, out created))
                {
                    if (created)
                    {
                        bool blPr_licStatus = NLicense.ObtainComponents(Address, Port, Components);
                        splashscreen = new SplashScreen();
                        splashscreen.Show();
                        if (blPr_licStatus)
                        {
                            // Creamos una instancia de MainForm y la asignamos dentro de los eventos mostrados y cerrados.
                            Frm_Principal main = new Frm_Principal();
                            main.Shown += main_Shown;
                            Application.Run(main);
                            Application.EnableVisualStyles();
                            Application.SetCompatibleTextRenderingDefault(false);
                            //
                            log.setTextErrLog("Main(),   INICIANDO APLICACION KIOSCO FENIX ...");
                            //
                            Application.Run(new FENIX_KIOSCO.Frm_Principal());
                            log.setTextErrLog("Main(), Iniciando Aplicacion Kiosco ...");
                        }
                        else
                        {
                            MessageBox.Show("No se encuentra licencia de huella, se iniciará la aplicación pero la verificación no será realizada", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            Frm_Principal main = new Frm_Principal();
                            main.Shown += main_Shown;
                            Application.Run(main);
                            Application.EnableVisualStyles();
                            Application.SetCompatibleTextRenderingDefault(false);
                            //
                            log.setTextErrLog("Main(),   INICIANDO APLICACION KIOSCO FENIX ...");
                            //

                            log.setTextErrLog("Main(), Iniciando Aplicacion Kiosco ...");
                        }
                    }
                    else
                    {
                        log.setTextErrLog("Main(), La Aplicacion Kiosco se esta Ejecutando ...");
                        //
                        MessageBox.Show("Fenix Kiosco " + stPr_VersionApp + " se encuentra en ejecución o utilizado en otra sesión de usuario de este equipo.", "Atención", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        Application.Exit();
                        Environment.Exit(1);
                    }
                }
                log.setTextErrLog("Main(), Terminando Aplicacion Kiosco ...");
                Environment.Exit(1);
            }
            catch (AccessViolationException ano)
            {
                log.outMensajError("FENIX_KIOSCO", "Program", "Main", "", ano.Message, "", "");
            }
            catch (Exception ex)
            {
                log.outMensajError("FENIX_KIOSCO", "Program", "Main", "", ex.Message, "", "");
            }
        }
Exemple #28
0
        static void Main()
        {
            //Check Neurotechnology licenses
            string address = "/local";
            string port    = "5000";
            bool   retry;

            string[] licenses =
            {
                "Biometrics.FingerExtraction",
                "Biometrics.FaceExtraction",
                "Biometrics.FingerMatchingFast",
                "Biometrics.FingerMatching",
                "Biometrics.FaceMatchingFast",
                "Biometrics.FaceMatching",
                "Biometrics.FingerQualityAssessment",
                "Biometrics.FingerSegmentation",
                "Biometrics.FingerSegmentsDetection",
                "Biometrics.FaceSegmentation",
                "Biometrics.Standards.Fingers",
                "Biometrics.Standards.FingerTemplates",
                "Biometrics.Standards.Faces",
                "Devices.Cameras",
                "Devices.FingerScanners",
                "Devices.Microphones",
                "Images.WSQ",
                "Media"
            };

            NLicenseManager.TrialMode = false;

            do
            {
                try
                {
                    retry = false;
                    foreach (string license in licenses)
                    {
                        NLicense.ObtainComponents(address, port, license);
                    }
                }
                catch (Exception ex)
                {
                    string message = string.Format("Failed to obtain licenses for components.\nError message: {0}", ex.Message);
                    if (ex is IOException)
                    {
                        message += "\n(Probably licensing service is not running. Use Activation Wizard to figure it out.)";
                    }
                    if (MessageBox.Show(message, @"Error", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error) == DialogResult.Retry)
                    {
                        retry = true;
                    }
                    else
                    {
                        retry = false;
                        return;
                    }
                }
            }while (retry);

            //Start app in minimized state
            Utils.Logging("StartApp");
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Main main = new Main
            {
                WindowState   = FormWindowState.Minimized,
                ShowInTaskbar = false,
                Visible       = false
            };

            Application.Run(main);
        }
Exemple #29
0
        private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            const string Components = "Biometrics.FingerExtraction,Biometrics.FingerMatching,Devices.FingerScanners,Images.WSQ";

            NLicense.ReleaseComponents(Components);
        }
Exemple #30
0
        protected override bool OnStartup(StartupEventArgs e)
        {
            const int    Port    = 5000;
            const string Address = "/local";

            const string Components =
                "Biometrics.FaceExtraction," +
                "Biometrics.FaceMatching," +
                "Biometrics.FaceDetection," +
                "Devices.Cameras";

            try
            {
                foreach (string component in Components.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
                {
                    NLicense.ObtainComponents(Address, Port, component);
                    Logger.Debug("Obtaining licenses");
                }

                var args = new string[e.CommandLine.Count];
                e.CommandLine.CopyTo(args, 0);

                if (args.Length > 0)
                {
                    var choice = ArgumentParser.Parse(args);
                    Logger.Debug("Argument parser returned choice : " + choice);

                    switch (choice)
                    {
                    case 0:
                        _app = Operations.OpenNLockFile(args);
                        break;

                    case 1:
                        _app = Operations.UnlockTo(args);
                        break;

                    case 2:
                        _app = Operations.UnlockHere(args);
                        break;

                    case 3:
                        _app = Operations.NLockThisFile(args);
                        break;

                    case 4:
                        _app = Operations.LockThisFolder(args);
                        break;

                    default:
                        MessageBox.Show(Resources.Invalid_command, Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        break;
                    }
                }
                else
                {
                    _app = new App(new MainForm(OperationModes.Default));
                }

                if (_app != null)
                {
                    Application.Run(_app);
                    _app.FocusMe();
                }
            }
            catch (Exception rx)
            {
                Logger.Debug("tray OnStartup failed");
                Logger.Error(rx);
            }
            return(false);
        }
Exemple #31
0
        public static void ObtainLicenses(IList <string> licenses)
        {
#if !N_NOT_USES_LICENSES
            int i, j;

            if (_licenseCfg == null)
            {
                LoadConfiguration();
            }

            for (i = 0; i < licenses.Count; i++)
            {
                if (_licenseCfg.ContainsKey(licenses[i]))
                {
                    licenses[i] = _licenseCfg[licenses[i]];
                }
                else
                {
                    licenses[i] = string.Empty;
                }
            }

            // Remove duplicates
            for (i = 0; i < licenses.Count - 1; i++)
            {
                if (licenses[i] == string.Empty)
                {
                    continue;
                }

                for (j = i + 1; j < licenses.Count; j++)
                {
                    if (licenses[i] == licenses[j])
                    {
                        licenses[j] = string.Empty;
                    }
                }
            }

            string licenseServer = _licenseCfg["Address"];
            string licensePort   = _licenseCfg["Port"];

            for (i = 0; i < licenses.Count; i++)
            {
                if (licenses[i] == string.Empty)
                {
                    continue;
                }

                try
                {
                    bool available = NLicense.Obtain("/local", "5000", licenses[i]);

                    if (!available)
                    {
                        throw new Exception(string.Format("license for {0} was not obtained", licenses[i]));
                    }
                }
                catch (Exception ex)
                {
                    throw new Exception(string.Format("Error while obtaining license. Please check if Neurotec License Manager is running. Details: {0}", ex.Message));
                }
            }
#endif
        }