private ServerResponse SendMessage(NameValueCollection nvc)
        {
            string localString = postSender.FormMessage(ApplicationSetting.GetInstance().ServerURL, nvc);
            string resp        = postSender.Post(localString);

            try
            {
                return(JsonConvert.DeserializeObject <ServerResponse>(resp));
            }
            catch
            {
                return(null);
            }
        }
        private void ButtonOk_Click(object sender, RoutedEventArgs e)
        {
            ConnectionModule CM = new DefaultConnectionModule();

            var sp = CM.StartSession(ApplicationSetting.GetInstance().Session.SessionKey);

            if (sp != null)
            {
                ApplicationSetting.GetInstance().Session.SessionKey = ApplicationSetting.GetInstance().Session.SessionKey;
                TimerController TC = new TimerController(sp);
                TC.SessionClose += CloseConnection;
                this.Hide();
            }
            else
            {
                //Графический вывод ошибки
                MessageBox.Show("error");
            }
        }
        public void  Tick(object o)
        {
            ApplicationSetting settings = ApplicationSetting.GetInstance();

            if (PingController.GetPing(settings.PingURL))
            {
                IWebAPI        WebAPI = new DefaultWebAPI(new PostSender.DefaultPostSender());
                ServerResponse response;
                if (settings.Session.PingError == 0)
                {
                    response = WebAPI.SendTrackingTime(settings.Session.SessionKey, GHK.TrackValue);
                    Debug.Print("SendTrackingTime: " + GHK.TrackValue);
                }
                else
                {
                    response = WebAPI.SendPingError(settings.Session.SessionKey, settings.Session.PingError);
                    Debug.Print("SendTrackingTime: " + settings.Session.PingError);
                    settings.Session.PingError = 0;
                }
                if (response == null)
                {
                    timer.Dispose();
                    SessionClose.Invoke();
                }
                else
                {
                    if (!GHK.State)
                    {
                        GHK.SetHook();
                    }

                    timer.Change(response.tracking_time * 1000, response.tracking_time * 1000);
                }
            }
            else
            {
                settings.Session.PingError++;
            }
        }
 public DefaultWebAPI(IPostSender postSender)
 {
     currentSession  = ApplicationSetting.GetInstance().Session;
     this.postSender = postSender;
 }