Esempio n. 1
0
        public bool SwitchOn(string consoleId)
        {
            if (!String.IsNullOrWhiteSpace(consoleId))
            {
                List<device_endpoints_t> allEndPoints = DataBaseClass.Instancedb().GetAllEndPoints();
                var console = (from c in allEndPoints
                               where c.playstation_id == consoleId
                               select c).SingleOrDefault();
                List<devices_t> allDevices = DataBaseClass.Instancedb().GetAllDevices();
                string iPaddress = (from i in allDevices
                                    where console != null && i.device_id == console.device_id
                                    select i.ip_address).SingleOrDefault();
                if (iPaddress != null)
                {
                    var device = new Device(IPAddress.Parse(iPaddress));
                    if (console != null)
                    {
                        var ep = new Endpoint(device, (byte)console.endpoint_index);

                        while (true)
                        {
                            for (int i = 0; i < 5; i++)
                            {
                                if (!ep.On())
                                {
                                    Thread.Sleep(100);
                                }
                                else
                                {
                                    return true;
                                }
                            }
                            if (!ep.On())
                            {
                                DialogResult dr = MessageBox.Show(
                                    @"Нет соединения! Нажмите Повторить чтобы попытатся снова.", @"Ошибка", MessageBoxButtons.RetryCancel);
                                TextFileWriter.TextFileWriterInstance()
                                    .AddSomeDataToLogReport("Нет соединения с приставкой " + consoleId,
                                        Options.FileTypeErrorsLogs);
                                if (dr == DialogResult.Cancel)
                                {
                                    return false;
                                }
                            }
                            else
                            {
                                SwitchOff(consoleId);
                                return false;
                            }

                        }
                    }
                }
            }
            return false;
            //return true;
        }
Esempio n. 2
0
 //        public AddNewSessionController()
 //        {
 //            _addNewSessionModel = new AddNewSessionModel();
 //        }
 public List<Endpoint> LoadingOfEndPoints(Device dev)
 {
     var endpoints = new List<Endpoint>();
     for (int i = 1; i <= 16 /*table_numComboBox.Items.Count*/; i++)
     {
         var ep = new Endpoint(dev, (byte)i);
         endpoints.Add(ep);
     }
     return endpoints;
 }