示例#1
0
文件: Application.cs 项目: slawer/skc
        protected Tech tech = null; // технологическая примочка

        #endregion Fields

        #region Constructors

        /// <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));
            }
        }
示例#2
0
文件: Application.cs 项目: slawer/skc
        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));
            }
        }