private void TryConnectingToMilestoneServer(string serverName = null, string userName = null, string password = null)
        {
            if (MilestoneServer.ConnectedToMilestone)
            {
                return;
            }

            if (string.IsNullOrEmpty(serverName))
            {
                serverName = Helper.ReadConfigKey(MilestoneServerNameString);
            }

            if (string.IsNullOrEmpty(userName))
            {
                userName = Helper.ReadConfigKey("MilestoneUserName");
            }

            if (string.IsNullOrEmpty(password))
            {
                password = Helper.ReadConfigKey("MilestonePassword");
            }

            if (string.IsNullOrEmpty(serverName))
            {
                serverName = "http://*****:*****@"C:\OpenALPR\OpenALPRMilestone\JsonTestFiles\heartbeat.json");
                    //while (!IsClosing)
                    //{
                    //    worker.Test(@"C:\OpenALPR\OpenALPRMilestone\JsonTestFiles\alpr_group1.json");
                    //    worker.Test(@"C:\OpenALPR\OpenALPRMilestone\JsonTestFiles\alpr_group2.json");
                    //    worker.Test(@"C:\OpenALPR\OpenALPRMilestone\JsonTestFiles\alpr_group3.json");
                    //    worker.Test(@"C:\OpenALPR\OpenALPRMilestone\JsonTestFiles\alpr_group4.json");
                    //    worker.Test(@"C:\OpenALPR\OpenALPRMilestone\JsonTestFiles\alpr_group1.json");
                    //    worker.Test(@"C:\OpenALPR\OpenALPRMilestone\JsonTestFiles\alpr_group2.json");
                    //    worker.Test(@"C:\OpenALPR\OpenALPRMilestone\JsonTestFiles\alpr_group3.json");
                    //    worker.Test(@"C:\OpenALPR\OpenALPRMilestone\JsonTestFiles\alpr_group4.json");
                    //    Thread.Sleep(5000);
                    //}
                    //Console.WriteLine("Done...");
                }
            }
        }
Exemplo n.º 2
0
        private void TryConnectingToMilestoneServer(string serverName = null, string userName = null, string password = null)
        {
            if (MilestoneServer.ConnectedToMilestone)
            {
                return;
            }

            #region Use SQLite
            if (string.IsNullOrEmpty(serverName))
            {
                serverName = settings.MilestoneServerName;
            }

            if (string.IsNullOrEmpty(userName))
            {
                userName = settings.MilestoneUserName;
            }

            if (string.IsNullOrEmpty(password))
            {
                password = settings.MilestonePassword;
            }
            #endregion

            if (string.IsNullOrEmpty(serverName))
            {
                serverName = "http://localhost:80/";
            }

            if (!serverName.StartsWith("http://"))
            {
                serverName = $"http://{serverName}";// $"http://{serverName}:80/";
            }
            if (milestoneServer == null)
            {
                milestoneServer = new MilestoneServer();
            }

            MilestoneServer.LoginUsingCurrentCredentials(serverName, userName, password);

            if (MilestoneServer.ConnectedToMilestone)
            {
                IsConnectedToMilestoneServer = true;

                #region Use SQLite
                string temp = settings.MilestoneServerName;
                if (temp != serverName)
                {
                    using (DB db = new DB("OpenALPRQueueMilestone", false))
                    {
                        settings.MilestoneServerName = serverName;
                        db.SaveSettings(settings);
                    }
                }

                Worker.AddBookmarks            = settings.AddBookmarks;
                Worker.AutoMapping             = settings.AutoMapping;
                Worker.EventExpireAfterDays    = settings.EventExpireAfterDays;
                Worker.EpochStartSecondsBefore = settings.EpochStartSecondsBefore;
                Worker.EpochEndSecondsAfter    = settings.EpochEndSecondsAfter;
                #endregion

                if (worker == null)
                {
                    worker     = new Worker();
                    workerTask = Task.Run(() => worker.DoWork());
                }
            }
        }