public MainWindow()
        {
            DataClient.Connect();
            DataClient.Update();

            InitializeComponent();
        }
Пример #2
0
 internal bool ConnectIot()
 {
     try
     {
         if (client.Connected)
         {
             client.Close();
         }
         client.Connect(iotConfig.IotIp, iotConfig.IotPort);
         client.RegisterAll();
         client.Identify(iotConfig.IotId, iotConfig.IotGroupId);
         return(true);
     }
     catch (SocketException ex)
     {
         NLogHelper.DefalutError("  ConnectIot SocketException:{0}", ex.Message);
         NLogHelper.ExceptionInfo(ex, "  ConnectIot SocketException:{0}", ex.Message);
         return(false);
     }
     catch (Exception ex)
     {
         NLogHelper.DefalutError("  ConnectIot Exception:{0}", ex.Message);
         NLogHelper.ExceptionInfo(ex, "  ConnectIot Exception:{0}", ex.Message);
         return(false);
     }
 }
        public override void Run(OperationContext context, PhaseManager <OperationContext> manager)
        {
            context.WriteLine("Read Configuration");

            context.Configuration = HostConfiguration.Read();

            var data = context.Configuration.TargetAdress.Split(':');

            var port = int.Parse(data[1]);

            context.Write("Open Server ");

            var client = new DataClient(data[0], port);

            client.Connect();

            context.DataClient = client;

            manager.RunNext(context);
        }