コード例 #1
0
        public void initFlightBoard()
        {
            MainViewVM mv = MainViewVM.Instance;

            this.isr             = mv.isr;
            isr.PropertyChanged += PropertyChange;
        }
コード例 #2
0
 public static SqlConnection ChaneConnection(InfoServer infoServer)
 {
     InfoServer = infoServer;
     connection = new SqlConnection(new SqlProvider().CreatConnectString(InfoServer.NameServer, InfoServer.Database,
                                                                         InfoServer.UseAccount ? InfoServer.Username : null, InfoServer.UseAccount ? InfoServer.Password : null));
     return(connection);
 }
コード例 #3
0
        public static void Exit(bool restarting, string msg)
        {
            Player[] players = PlayerInfo.Online.Items;
            foreach (Player p in players)
            {
                p.save();
            }
            foreach (Player p in players)
            {
                p.Leave(msg);
            }

            if (APIServer != null)
            {
                APIServer.Stop();
            }
            if (InfoServer != null)
            {
                InfoServer.Stop();
            }

            Player.connections.ForEach(p => p.Leave(msg));
            Plugin.Unload();
            if (listen != null)
            {
                listen.Close();
            }
            try {
                IRC.Disconnect(restarting ? "Server is restarting." : "Server is shutting down.");
            } catch {
            }
        }
コード例 #4
0
        public void Connect()
        {
            // Set the server
            Task taskSever = new Task(() =>
            {
                InfoServer.SetServer();
                InfoServer.Start();
            });

            Task taskClient = new Task(() =>
            {
                CommandChannel.AssignSocket();
            });


            Task connectionFlow = new Task(() =>
            {
                taskSever.Start();
                taskSever.Wait();

                Console.WriteLine("Finished waiting as server");

                taskClient.Start();
                taskClient.Wait();
            });


            connectionFlow.Start();
        }
コード例 #5
0
ファイル: MapModel.cs プロジェクト: linor1/WPFSimulatorApp
        public MapModel()
        {
            IClientHandler ch = new ClientHandler(this);

            InfoServer.RegisterClientHandler(ch);

            Console.WriteLine("flightboard connected as client");
        }
コード例 #6
0
 private void btnNext_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrWhiteSpace(cmbServer.Text))
     {
         MessageBox.Show("Nhập tên server!", "Lỗi", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
     }
     else
     {
         string sConnect = "";
         if (cbAccount.Checked)
         {
             if (string.IsNullOrWhiteSpace(txtUsername.Text) || string.IsNullOrWhiteSpace(txtPassword.Text))
             {
                 MessageBox.Show("Nhập đầy đủ Username và Password!", "Lỗi", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
                 return;
             }
             else
             {
                 sConnect = new SqlProvider().CreatConnectString(cmbServer.Text, null, txtUsername.Text, txtPassword.Text);
             }
         }
         else
         {
             sConnect = new SqlProvider().CreatConnectString(cmbServer.Text, null, null, null);
         }
         try
         {
             SqlConnection con = new SqlConnection(sConnect);
             con.Open();
             con.Close();
             var info = new InfoServer()
             {
                 NameServer = cmbServer.Text,
                 Username   = txtUsername.Text,
                 Password   = txtPassword.Text,
                 UseAccount = cbAccount.Checked,
                 Database   = null
             };
             string tmp = null;
             if (Common.InfoServer != null)
             {
                 tmp = Common.InfoServer.Database;
             }
             Common.ChaneConnection(info);
             info.Database = tmp;
             Common.SaveInfoServer(info);
             if (Common.LstServer.Count == 0 || !Common.LstServer.Any(q => q.Trim().ToLower().Equals(cmbServer.Text.Trim().ToLower())))
             {
                 Common.AddListServer(cmbServer.Text);
             }
             this.Close();
         }
         catch (Exception ex)
         {
             MessageBox.Show("Error: " + ex.Message, "Lỗi", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
         }
     }
 }
コード例 #7
0
 public FlightBoardViewModel()
 {
     infoServer = InfoServer.Instance;
     // sign to get notifactions from the server
     infoServer.PropertyChanged +=
         delegate(object sender, PropertyChangedEventArgs e) {
         NotifyPropertyChanged(e.PropertyName);
     };
 }
コード例 #8
0
 public static void InitLayerServer()
 {
     Info = new InfoServer();
     Info.Init();
     Request = new RequestServer();
     Request.Init();
     Behavior = new BehaviorServer();
     Behavior.Init();
 }
コード例 #9
0
        private void UpdateInfoServer(string mConnInfo, GetDevice decServInfo, InfoServer infoServer)
        {
            decServInfo.Hk  = mConnInfo;
            infoServer.Code = Cypher.Encrypt(new JavaScriptSerializer().Serialize(decServInfo));
            _repository.SaveChanges();

            //if (infoServer.InfoCallCenterId.HasValue == false)
            //    return;
        }
コード例 #10
0
        public void startServerVM()
        {
            cs  = CommandServer.Instance;
            isr = InfoServer.Instance;
            isr.Connect();
            cs.Start();
            FlightBoardViewModel fbvm = FlightBoardViewModel.Instance;

            fbvm.initFlightBoard();
        }
コード例 #11
0
        public Position GetPosition()
        {
            InfoServer server   = InfoServer.Instance;
            string     lat      = server.Get("position/latitude-deg");
            string     lon      = server.Get("position/longitude-deg");
            string     throttle = server.Get("controls/engines/current-engine/throttle");
            string     rudder   = server.Get("controls/flight/rudder");
            Position   pos      = new Position(Double.Parse(lon), Double.Parse(lat), Double.Parse(throttle), Double.Parse(rudder));

            return(pos);
        }
コード例 #12
0
 private void OnConnectClick()
 {
     new Thread(() =>
     {
         //init communication
         InfoServer server = InfoServer.Instance;
         server.Start();
         CommandClient commandClient = CommandClient.Instance;
         commandClient.Start();
     }).Start();
 }
コード例 #13
0
        public ActionResult save(string ip, int port, int rate, int duration, string name)
        {
            CacheManager.Instance.Path = name;
            System.IO.File.WriteAllBytes(CacheManager.Instance.Path, new byte[0]);
            InfoServer server = InfoServer.Instance;

            server.Start(ip, port);
            Session["rate"]     = rate;
            Session["duration"] = duration;
            return(View());
        }
コード例 #14
0
        public ActionResult pathOnMap(string ip, int port, int rate)
        {
            InfoServer server = InfoServer.Instance;

            if (server.booleanState())
            {
                server.Stop();
            }
            server.Start(ip, port);
            Session["rate"] = rate;
            return(View());
        }
コード例 #15
0
        private bool IsUpdatedInfoServer(string mConnInfo, InfoServer infoServer, out GetDevice decCompInfo)
        {
            var connInfo = mConnInfo;

            decCompInfo = new JavaScriptSerializer().Deserialize <GetDevice>(Cypher.Decrypt(infoServer.Code));

            if (connInfo == decCompInfo.Hk)
            {
                return(true);
            }

            return(false);
        }
コード例 #16
0
        public ActionResult display(string ip, int port)
        {
            IPAddress temp;

            if (IPAddress.TryParse(ip, out temp) == false)
            {
                load(ip, port);
                return(View("load"));
            }

            InfoServer server = InfoServer.Instance;

            if (server.booleanState())
            {
                server.Stop();
            }
            server.Start(ip, port);
            Position pos = GetPosition();

            Lat = pos.Lat;
            Lon = pos.Lon;
            return(View());
        }
コード例 #17
0
 internal static void SaveInfoServer(InfoServer infoServer)
 {
     InfoServer = infoServer;
     InfoServer.Save(FILE_INFOSERVER);
 }
コード例 #18
0
 public FlightBoardViewModel(InfoServer server1)
 {
     server = server1;
     Globals.telnetClient    = new ConnectTelnetClient();
     server.PropertyChanged += m_PropertyChanged;
 }
コード例 #19
0
 internal static void ReadInfoServer()
 {
     InfoServer = new InfoServer().Read(FILE_INFOSERVER);
 }