public void WebServiceTest_Connect()
        {
            var serverThread = new Thread(new ThreadStart(() =>
            {
                var st = new ServiceTest();
                st.ServiceTest_WCFAndCalculationAndWatcherAndCommand(10*60*1000);
            }));
            serverThread.Start();
            try
            {
                var evnt = new ServiceSubscriber();
                evnt.IsCalculationActiveEvent += (s, e) =>
                {
                    Debug.WriteLine(string.Format("[WebServiceTest] IsActive changed to '{0}' by user '{1}'", e.IsActive, e.UserName));
                };
                evnt.LogChangedEvent += (s, e) =>
                {
                    Debug.WriteLine(string.Format("[WebServiceTest] Log changed (id:'{0}')", e != null && e.Id != null ? e.Id : "null"));
                };
                evnt.QueueChangedEvent += (s, e) =>
                {
                    Debug.WriteLine(string.Format("[WebServiceTest] Queue changed (file:'{0}', action:'{1}')", e.Element.File, e.Action));
                };
                InstanceContext evntContext = new InstanceContext(evnt as IControlServiceCallback);

                Thread.Sleep(3000);
                var clientId = Guid.NewGuid();
                using (var proxy = new ControlServiceClient(evntContext))
                {
                    proxy.ClientCredentials.Windows.ClientCredential = System.Net.CredentialCache.DefaultNetworkCredentials;

                    Debug.WriteLine("[WebServiceTest] subscribe events");
                    proxy.SubscribeEvents(clientId);

                    var queueElements = proxy.GetQueue();
                    Assert.AreEqual(3, queueElements.Length);

                    string folderName = @"D:\test3";
                    for (int i = 3; i < 5; i++)
                        System.IO.File.WriteAllText(string.Format(@"{0}\test.d{1}", folderName, i.ToString("00")), "test");

                    Thread.Sleep(3000);

                    queueElements = proxy.GetQueue();
                    Assert.AreEqual(5, queueElements.Length);

                    Debug.WriteLine("[WebServiceTest] SetIsCalculationActive(true)");
                    proxy.SetIsCalculationActive(true);
                    Thread.Sleep(1000);

                    while ((queueElements = proxy.GetQueue()).Length > 0
                        && (proxy.GetIsCalculationActive()))
                        Thread.Sleep(1000);

                    Debug.WriteLine("[WebServiceTest] SetIsCalculationActive(false)");
                    proxy.SetIsCalculationActive(false);
                    Thread.Sleep(1000);

                    Debug.WriteLine("[WebServiceTest] unsubscribe events");
                    proxy.UnsubscribeEvents(clientId);
                }
            }
            finally
            {
                serverThread.Abort();
            }
        }
        private async void TryToConnect()
        {
            try
            {
#if !DEBUG
                var binding = new NetTcpBinding(SecurityMode.Transport);
                var endPoint = new EndpointAddress("net.tcp://S01-ASTRA.OFFICE.GTT.GAZPROM.RU:9929/CalculationManager/ControlService");
                //var endPoint = new EndpointAddress("net.tcp://WS27SYCHSS.OFFICE.GTT.GAZPROM.RU:9929/CalculationManager/ControlService");
                proxy = new ControlServiceClient(new InstanceContext(subscriber as IControlServiceCallback), binding, endPoint);
#else
                proxy = new ControlServiceClient(new InstanceContext(subscriber as IControlServiceCallback));
#endif
                proxy.ClientCredentials.Windows.ClientCredential = System.Net.CredentialCache.DefaultNetworkCredentials;
                proxy.Open();
                ErrorClear();
                
                proxy.SubscribeEvents(clientId);

                ReloadFileQueue();
                ReloadCalculation();

                await Task.Factory.StartNew(() => 
                {
                    lastIsActive = proxy.GetIsCalculationActive();
                    RaisePropertyChanged("IsActive");
                });

                IsConnected = true;
                //lastIsActive = await proxy.GetIsCalculationActiveAsync();
                //RaisePropertyChanged("IsActive");
            }
            catch (Exception ex)
            {
                ErrorSet(ex.Message);
            }
        }