Exemplo n.º 1
0
        /// <summary>
        /// Попытка установить связь с DevMan
        /// </summary>
        public void attemptConnect()
        {
            Ping        ping    = new Ping();
            PingOptions options = new PingOptions();

            try
            {
                PingReply reply = ping.Send(devManUri.Host);
                if (reply.Status == IPStatus.Success)
                {
                    /*DevManClient.Uri = devManUri;
                     *
                     * DevManClient.Context.Mode = UserMode.Passive;
                     * DevManClient.Context.Role = Role.Common;*/

                    DevManClient.Connect();

/*
 *                  try
 *                  {
 *                      if (client.Client.Connected)
 *                      {
 *                          client.Client.Disconnect();
 *                      }
 *                  }
 *                  catch { }
 *
 *                  try
 *                  {
 *                      client.Client.CloseSocket();
 *                  }
 *                  catch { }
 *
 *                  try
 *                  {
 *                      client = null;
 *                  }
 *                  catch { }
 *
 *                  client = new devTcpManager();
 */
                    string ip = System.Net.Dns.Resolve(devManUri.Host).AddressList[0].ToString();
                    //string ip = System.Net.Dns.GetHostEntry(devManUri.Host).AddressList[0].ToString();

                    /*client.Client.Host = ip;
                    *  client.Client.Port = 56000;
                    *
                    *  client.Client.Connect();*/
                }
                else
                {
                    /*try
                     * {
                     *  client = null;
                     * }
                     * catch {}*/
                }
            }
            catch { }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Подключиться к серверу данных
 /// </summary>
 public void ConnectToServer()
 {
     try
     {
         DevManClient.Connect();
     }
     catch (Exception ex)
     {
         ErrorHandler.WriteToLog(this, new ErrorArgs(ex.Message, ErrorType.NotFatal));
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Подключиться к серверу данных
        /// </summary>
        public void ConnectToServer()
        {
            try
            {
                try
                {
                    Ping        ping    = new Ping();
                    PingOptions options = new PingOptions();

                    Uri       uri   = DevManClient.Uri;
                    PingReply reply = ping.Send(uri.Host, 100);

                    if (reply.Status == IPStatus.Success)
                    {
                        DevManClient.Connect();
                    }
                }
                catch { }
            }
            catch (Exception ex)
            {
                ErrorHandler.WriteToLog(this, new ErrorArgs(ex.Message, ErrorType.NotFatal));
            }
        }
Exemplo n.º 4
0
        protected bool autolocalhost = false;           // автоматически подключаться к локальному серверу данных

        /// <summary>
        /// Инициализирует новый экземпляр класса
        /// </summary>
        protected Application()
        {
            try
            {
                ErrorHandler.InitializeErrorHandler();
                ErrorHandler.OnExit += new EventHandler(ErrorHandler_OnExit);

                buffer  = new RSliceBuffer(72000);
                manager = new DataBaseManager();

                projects = new List <Project>();
                commands = new List <BlockViewCommand>();

                parameters = new Parameter[256];
                for (int index = 0; index < parameters.Length; index++)
                {
                    parameters[index]            = new Parameter(index);
                    parameters[index].Identifier = Identifiers.GetGuid(index);
                }

                tech       = new Tech();
                commutator = new Commutator(tech, parameters, buffer);

                panels = new List <ParametersViewPanel>();
//                devManUri = new Uri("net.tcp://localhost:57000");
                devManUri = new Uri("net.tcp://127.0.0.1:57000");

                CheckRegistry();

                LoadUri();

                DevManClient.Uri = devManUri;

                DevManClient.Context.Mode = UserMode.Passive;
                DevManClient.Context.Role = Role.Common;

                client = new devTcpManager();

                Ping        ping    = new Ping();
                PingOptions options = new PingOptions();

                try
                {
                    PingReply reply = ping.Send(devManUri.Host);
                    if (reply.Status == IPStatus.Success)
                    {
                        /*DevManClient.Uri = devManUri;
                         *
                         * DevManClient.Context.Mode = UserMode.Passive;
                         * DevManClient.Context.Role = Role.Common;*/

                        DevManClient.Connect();

                        // client = new devTcpManager();

                        string ip = System.Net.Dns.Resolve(devManUri.Host).AddressList[0].ToString();
                        //string ip = System.Net.Dns.GetHostEntry(devManUri.Host).AddressList[0].ToString();

                        client.Client.Host = ip;
                        client.Client.Port = 56000;

                        client.Client.Connect();
                    }
                    else
                    {
                        /*try
                         * {
                         *  client = null;
                         * }
                         * catch { }*/
                    }
                }
                catch { }
            }
            catch (Exception ex)
            {
                ErrorHandler.WriteToLog(this, new ErrorArgs(ex.Message, ErrorType.Fatal));
            }
        }